Regula Falsi (False Position Method)

Source Code:

Write a program in C to find the root of 𝒇(𝒙) = 𝒙𝟑 − 𝒙 − 𝟐 using the Regula Falsi Method.

#include <stdio.h>
#include <conio.h>
double f(double x){ return x*x*x - x - 2; }
int main(){
 clrscr();
 double a=1, b=2, c;
 for(int i=0;i<20;i++){
 c = (a*f(b) - b*f(a)) / (f(b) - f(a));
 if(f(a)*f(c)<0) b=c;
 else a=c;
 }
 printf("\n\nRoot : %.4f\n", c);
 getch();
 return 0;
}

Output