Implement Newton-Raphson Method using C



Implement Newton-Raphson Method using C,Sumit Kar, Numerical Methods, C, Timus Rak




/*


Method of Newton-Raphson



Equation: x^3-4x-9=0


*/

#include<stdio.h>

void main()
{
float a,h;
int i;
float f(float);
float f1(float);
printf("\nEnter initial value:: ");
scanf("%f",&a);
for(i=1;i<=5;i++)
{
h=-f(a)/f1(a);
a=a+h;
}
printf("\nRoot is:: %f",a);
}
float f(float x)
{
return (x*x*x)-(4*x)-9;
}
float f1(float x)
{
return (3*x*x)-4;
}


0 Comments