Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. Бойкотик, [24.04.19 19:36]
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double func(double x)
  8. {
  9.   return pow(x, 5) - 3 * pow(x, 2) + 1;
  10. }
  11.  
  12. double find(double infinum, double supremum, double epsilon)
  13. {
  14.   while (fabs(supremum - infinum) > epsilon)
  15.   {
  16.     infinum = supremum - (supremum - infinum) * func(supremum) / (func(
  17.       supremum) - func(infinum));
  18.     supremum = infinum - (infinum - supremum) * func(infinum) / (func(
  19.       infinum) - func(supremum));
  20.   }
  21.  
  22.   return supremum;
  23. }
  24.  
  25. int main()
  26. {
  27.   double a, b, e;
  28.   setlocale(0, "");
  29.   cout << " x^5 - 3*x^2 +1 = 0  [1;1.6]\n";
  30.   cout << "Лiва границя a=";
  31.   cin >> a;
  32.   cout << "Права границя b=";
  33.   cin >> b;
  34.   cout << "Точнiсть e=";
  35.   cin >> e;
  36.   cout << find(a, b, e) << endl;
  37.   system("pause");
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement