Given the task - to calculate the value of the function using the library function and by summing over the expansion in a row. It is necessary to count in the specified range - from a to b, at regular intervals, the number of which is m, i.e. with step h = (b - a) / m; m, e - are entered from the keyboard. Here is the code. I do not see why the amount always goes zero.

#include <iostream.h> #include <math.h> int main() { double a = 0.2, b = 1, e = 0.00000001; int m = 5; double h = (b - a) / m; cout << "xi log(x/2) S" << "\n"; for (int i = 0; i <= m; i++) { double xi = a + i * h; double Fx = log(xi / 2), s = 0, dn = (xi - 1) / (xi + 1), xi1 = (xi - 1) / (xi + 1); double current; for (int n = 0;; n++) { current = dn / (n + n + 1); if (current >= e) { s += current; } else break; dn *= xi1 * xi1; } cout << xi << " " << Fx << " " << s << "\n"; } return 0; } 

    1 answer 1

    In a nested loop, correct:

     if(fabs(current) >= e){