Need to compute the function using the recurrence relation of the members of the series.

Here is my recursive formula:

Program code:

Actually the problem is that the result of my formula varies wildly with the result of functions from the library. It is suspected that the formula is not true, but some times copied.

Here is my recursive formula:

Program code:

```
#include <cmath>
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
const double pi = 3.14159265358979323846;
double x = pi / 2;
double s = 0,
eps = 1e-06;
int k = 1;
double elem = x * x;
s = elem;
while(fabs(elem) >= eps) {
cout << k << " : "<< elem << " : "<< s << endl;
k++;
elem *= (-4 * x * x) / ((2 * k + 1) * (2 * k + 2));
s += elem;
}
cout << "S:" << s << endl;
cout << "MATH:" << sin(x) * sin(x);
_getch();
return 0;
}</conio.h></iostream></cmath>
```

Actually the problem is that the result of my formula varies wildly with the result of functions from the library. It is suspected that the formula is not true, but some times copied.

asked July 2nd 19 at 17:16

3 answers

answered on

Solution

Try 2 options:

1. a(k) / a(k-1)

2. a(k+2) / a(k+1)

And anyway, your loop in the first iteration, k=2, and then computes a new member. Check that the second term that must be in the original formula

1. a(k) / a(k-1)

2. a(k+2) / a(k+1)

And anyway, your loop in the first iteration, k=2, and then computes a new member. Check that the second term that must be in the original formula

answered on

Solution

You have a formula retrieve the k+1 element of the k-th, and use it to obtain the k-th element of the k-1. This is a different formula.

answered on July 2nd 19 at 17:22

There is only the ratio displayed correctly. Next you need to choose the correct initial values and correct the test to stop.

Find more questions by tags Higher mathematicsMathematicsCC++

When k=1. The member will be x^2

When k=2. In the above formula, the member is -1/3 * x^4. And your program -4x^4 / 30.

Try those 2 cases that I have suggested - Mandy62 commented on July 2nd 19 at 17:24