Advertisement
berinkaq

Untitled

Apr 1st, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <iostream>
  3. #include <cmath>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. double find(double x, double eps, int c)
  8. {
  9. double t = (double) c;
  10. double f, df;
  11. do {
  12. f = x * x + x + sqrt(x) - t;
  13. df = 2*x + 1 + 0.5 / sqrt(x);
  14. x = x - f / df;
  15. } while (fabs(f) > eps);
  16. return x;
  17. }
  18.  
  19. int main()
  20. {
  21. int c;
  22. cin >> c;
  23. cout << fixed << setprecision(7) << find(0.5, 0.0000001, c);
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement