Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double pow(double number, int power)
- {
- double result = 1;
- for (int i = 1; i <= power; i++)
- {
- result *= number;
- }
- return result;
- }
- void Solution2(const double& x, const double& alpha)
- {
- bool is_accuracy_exist = false;
- double accuracy = DBL_MAX;
- int iterationIndex = 0;
- double summ = 0;
- while (abs(alpha) < accuracy) {
- double summand = pow(x, iterationIndex * 2 + 1) / (iterationIndex * 2 + 1);
- if (summ != 0) {
- accuracy = abs(summand) / abs(summ);
- is_accuracy_exist = true;
- }
- summ += summand;
- cout << setprecision(15) << "Номер итерации: " << iterationIndex << endl
- << "Последний просуммированный член ряда: " << summand << endl
- << "Текущая частичная сумма: " << summ << endl;
- if (is_accuracy_exist) {
- cout << "Точность вычисления заданной текущей частичной суммы: " << accuracy << endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment