Newton–Raphson Method
Source Code:
Write a program in C to find the root of 𝒇(𝒙) = 𝒙𝟑 − 𝒙 − 𝟐 using the Newton–Raphson Method
#include <stdio.h>
#include <conio.h>
double f(double x){ return x*x*x - x - 2; }
double df(double x){ return 3*x*x - 1; }
int main(){
clrscr();
double x=1.5;
for(int i=0;i<20;i++)
x = x - f(x)/df(x);
printf("\n\nRoot : %.4f\n", x);
getch();
return 0;
}
Output

