Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- double find(double x, double eps, int c)
- {
- double t = (double) c;
- double f, df;
- do {
- f = x * x + x + sqrt(x) - t;
- df = 2*x + 1 + 0.5 / sqrt(x);
- x = x - f / df;
- } while (fabs(f) > eps);
- return x;
- }
- int main()
- {
- int c;
- cin >> c;
- cout << fixed << setprecision(7) << find(0.5, 0.0000001, c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement