Professional Documents
Culture Documents
Newton Raphson Method
Newton Raphson Method
Roll no-13,SYIT
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,y,a,b,x1[4],fx1[4],c[4],i;
clrscr();
printf("the equation is x^3-x-1");
printf("the derivative of equation is 3x^2-1");
x=0;
while(y<0)
{
a=x;
x=x+1;
y=pow(x,3)-x-i;
}
b=x;
printf("\n the roots of the equation:");
printf("%f %f",a,b);
x1[0]=b;
for(i=0;i<4;i++)
{
fx1[i]=pow(x1[i],3)-x1[i]-1;
c[i]=3*pow(x1[i],2)-1;
x1[i+1]=x1[i]-(fx1[i]/c[i]);
printf("\n the roots of the equation:%f \n",x1[i+1]);
}
getch();
}
o/p: