Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<cmath>
- #include<iostream>
- #define ESP 0.000001
- #define F(x) (1-4*x*x)/6
- using namespace std;
- int main()
- {
- double x1, x2, x3, x4, y;
- cin >> x1;
- for (int i=1; ; i=i+3)
- {
- x2 = F(x1);
- x3 = F(x2);
- if(fabs(x3-x2) < ESP)
- {
- cout << x3;
- break;
- }
- else
- {
- y = x3-2*x2+x1;
- x1 = x3-(((x3-x2)*(x3-x2))/y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement