You are on page 1of 2

 Newton Raphson method: Madhuri Divekar

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:

the equation is x^3-x-1the derivative of equation is 3x^2-1


the roots of the equation:1.000000 2.000000
the roots of the equation:1.545455

the roots of the equation:1.359615

the roots of the equation:1.325801

the roots of the equation:1.324719

You might also like