Numerical Method Newton Method for Nonlinear Equations

3 + 4 * x ^ 2-10 Nonlinear Equations roots y = x ^ in the interval [1,2], accurate to three decimal places
hanshu iterative formula

#include <iostream>
using namespace std;
#define WUCHA 0.0005
double hanshu(double x) {
    return x - (x * x * x + 4 * x * x - 10) / (3 * x * x + 8 * x);
}
int main()
{
    double x = 1.5;
    double xx = 100000;
    int count = 0;
    while (abs(x-xx)>WUCHA) {
        xx = x;
        x = hanshu(x);
        count++;
        
    }
    cout << "结果:" << x << endl;
    cout << "迭代次数:" << count;
}

Here Insert Picture Description

Released four original articles · won praise 0 · Views 121

Guess you like

Origin blog.csdn.net/weixin_43625164/article/details/104617434