Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Бойкотик, [24.04.19 19:36]
- #include <iostream>
- #include <cmath>
- using namespace std;
- double func(double x)
- {
- return pow(x, 5) - 3 * pow(x, 2) + 1;
- }
- double find(double infinum, double supremum, double epsilon)
- {
- while (fabs(supremum - infinum) > epsilon)
- {
- infinum = supremum - (supremum - infinum) * func(supremum) / (func(
- supremum) - func(infinum));
- supremum = infinum - (infinum - supremum) * func(infinum) / (func(
- infinum) - func(supremum));
- }
- return supremum;
- }
- int main()
- {
- double a, b, e;
- setlocale(0, "");
- cout << " x^5 - 3*x^2 +1 = 0 [1;1.6]\n";
- cout << "Лiва границя a=";
- cin >> a;
- cout << "Права границя b=";
- cin >> b;
- cout << "Точнiсть e=";
- cin >> e;
- cout << find(a, b, e) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement