Question: Please check if i did this code right /* Roots of an Equation -Newton-Raphson Method*/ #include #include #define EPS0 1.0e-12 double f(double x); double fp(double
Please check if i did this code right
/* Roots of an Equation -Newton-Raphson Method*/
#include
#include
#define EPS0 1.0e-12
double f(double x);
double fp(double x);
double newton_raphson(double x, double eps);
int main(){
double xi = 2, eps = 1.0e-6;
printf( "The root is %f ", newton_raphson(xi, eps) );
return 0;}
double f(double x){
double y;
y = x*x*x - 3*(x*x)+ 2.3146*x - .504188;
return y;}
double fp(double x){
double y;
y = 3*(x*x)-6*x+2.3146;
return y;
}
double newton_raphson(double x, double eps){
double x1, dx, fx, fpx;
do {fx = f(x);
fpx = fp(x);
if (fabs(fpx)
printf( "Warning: slope --> 0 !!! ");
break;}
x1 = x -fx/fpx;
dx = x1 -x;
x = x1;}
while (fabs(dx) > eps || fabs(fx) > EPS0);
return x1;
}
And please help me with this one

Problem 3: Newton-Raphson method: Modify a C code to find the roots of equation with initial guess of xo = 2: f(A)= ?. 3A" + 2.31462-0.504188 = 0 df fa)-4. 3 2-62+ 2.3146
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
