非線形方程式を解くための反復法

区間[1,2]の根元で、小数点以下第3位まで正確な非線形方程式y = x ^ 3 + 4 * x ^ 2-10を解きます。
同等の方程式を自分で決定する必要があります

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

ここに画像の説明を挿入
ここに画像の説明を挿入

元の記事を30件公開 Liked9 Visits1331

おすすめ

転載: blog.csdn.net/weixin_43625164/article/details/104616282