Hello, the task I have here is this: enter image description here

It is necessary to deduce: the value of the argument, the value of the function, the number of totalized members of the series and the calculation of the function by standard means with ++.

Actually I wrote the code, but how to calculate this arth? He simply does not consider him to me ... Please tell me.

#include <iostream> #include <math.h> using namespace std; int main() { const int max = 500; double Xstart, Xend, dX, sum, e, element, x; int c; cin >> Xstart >> Xend >> dX >> e; for ( x = Xstart; (Xend - x)>-0.00001; x += dX) { c = 0; element = 1; sum = 0; for (int n = 0; fabs(element)>e && n <= max; n++) { element = 1 / ((2*n+1) * pow(x, (2*n+1))); sum += element; c++; } if (c < max) cout << x << " " << round(sum * 10000) / 10000 << " " << c << " " << round(atanh(x) * 10000)/10000 << endl; } return 0; } 

    1 answer 1

    Like that:

     double arth(double x, double eps) { double res = 1/x, term = 1/x, x2 = 1/(x*x); for(int k = 0;abs(term) > eps;++k) res += term *= x2*(2*k+1)/(2*k+3); return res; } 

    Be sure to check that x>1 .

    • for(int k = 0; abs(term) > eps; res += term *= x2*(1-1/(k++ + 1.5))); :) - Mikhailo
    • @Mikhailo Well, you can. Then add all the variables in one cycle. For example, x2 can be simply assigned to x . And you have a brace after for lost. - Harry
    • Thanks, I managed to fix it. - Mikhailo