Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #define EPS 0.0001
- using namespace std;
- double initial(double x) {
- return x - 0.05 * (pow(5., x) - 6 * x - 3);
- }
- int main() {
- double x_1,
- x_0,
- dif_x;
- cout << "Enter x0 in between[1.4; 1.7]: ";
- cin >> x_0;
- int i = 0;
- do {
- i++;
- x_1 = initial(x_0);
- dif_x = fabs(x_1 - x_0);
- x_0 = x_1;
- cout << "Itetarion " << i
- << " xi = " << x_1
- << "\tdifference = " << dif_x << endl;
- } while (dif_x >= EPS);
- cout << "\nThe root of the equation = " << x_1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement