Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- double epsilon;
- cout << "Enter epsilon: ";
- cin >> epsilon;
- double x;
- cout << "Enter X: ";
- cin >> x;
- int iterations = 1;
- double prev = 0;
- double current = x;
- while (fabs(current - prev) > epsilon) {
- prev = current;
- current *= (1 - (x * x) / (iterations * iterations * M_PI * M_PI));
- iterations++;
- }
- cout << "Iterations: " << iterations << endl;
- cout << "Result: " << current << endl;
- cout << "Fact difference: " << fabs(current - sin(x)) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement