0

多項式関数 (ax^6 + bx^5 + cx^4 + dx^3 + ex^3 + fx^2 + gx + h) にニュートン ラフソン法を適用するための cpp コードを作成しました (すべての変数が 1 であると仮定しました)。 、だから私はa)を定義したばかりで、8085シミュレータ用に変換したいのですが、助けてもらえますか? これが私のコードです:

#include <iostream>
#define EPSILON 0.001
using namespace std;

double func(double x)
{
    int a=1;
    return a*x*x*x*x*x*x+a*x*x*x*x*x+a*x*x*x*x+a*x*x*x+a*x*x*x+a*x*x+a*x+a;
}

double derivFunc(double x)
{
    int a=1;
    return 6*a*x*x*x*x*x+5*a*x*x*x*x+4*a*x*x*x+3*a*x*x+3*a*x*x+2*a*x+a;
}

void newtonRaphson(double x)
{
    double h = func(x) / derivFunc(x);
    while (abs(h) >= EPSILON)
    {
        h = func(x)/derivFunc(x);

        x = x - h;
    }
    cout << "The value of the root is : " << x;
}

int main()
{
    double x0 = 10;
    newtonRaphson(x0);
    return 0;
} 
4

0 に答える 0