The task is ...
Enter e (precision, for example, 0.0012), m (the number of members of a polynomial, for example, 25) and x (for example, 3).

Calculate the value of the function: function
How to implement it?

Update

My version is simple, normal function, but wrong.

float ex=0, znam=4, chisl=1, _item= 1/4, sumx = 1, n=0; for (int i = 0; i < m; i++) { sumx += (_item *= (((chisl += 4)*pow(x, ex +i)) / (znam += 4))); printf("%.8f\n", sumx); } return sumx; 

It should be as easy to do.

Closed due to the fact that the essence of the issue is unclear by the participants pavel , αλεχολυτ , Kirill Stoianov , HamSter , tutankhamun 4 Oct '16 at 7:16 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Well, what about your options ??? My option is to write a class polynomial. Describe what it consists of. Well, substitute your values. - Alex.B

1 answer 1

Hmm ... Why just if you can be difficult? :)

The problem is that it is necessary to solve - or accuracy, or the number of members. At the same time, both are nonsense. If accuracy is needed, then it is possible to stop the cycle with a member less than the specified accuracy (but this estimate is not the strictest ... the series for x>=1 generally divergent). You can write to achieve what will happen earlier - accuracy will be achieved, or a specified number of members will be calculated. In a word, dare :) Edit the proposed version - which displays the values ​​for different numbers of members:

 int main(int argc, const char * argv[]) { double a = 1.0; double sum = a; double x; int m; cout << "m = "; cin >> m; cout << "x = "; cin >> x; for(int i = 0; i < m; ++i) { a *= x*(4*i+1)/(4*i+4); sum += a; cout << "n = " << setw(4) << (i+1) << " Sum = " << setw(12) << sum << endl; } }