![Numerical Methods Sumit Kar, Numerical Methods, C, Timus Rak](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgEEuiVQujzDYGlv1PMDzDKYb5ozvCbIjo_Mt3FOu_A8h6GVex9UkCglRQEuc0wTKxbm_OgzCSMsAl0xTsTrdYwnZVmL3fFis99MAlE7B7SZTE3u-l8-Yoy14a7zhjLCMXS_y2grkLeaBz/s1600/c-programming-tutorial.jpg)
/*
Method of Regula-Falsi
Equation: x^3-4x-9=0
*/
#include<conio.h>
#include<stdio.h>
void main()
{
float a,b,k,c;
int i;
float f(float);
clrscr();
printf("\nEnter first initial value:: ");
scanf("%f",&a);
printf("\nEnter second initial value:: ");
scanf("%f",&b);
for(i=1;i<=5;i++)
{
c=b-((b-a)*(f(b)/(f(b)-f(a))));
k=f(c);
if(k>0)
b=c;
if(k<=0)
a=c;
}
printf("\nRoot is:: %f",c);
getch();
}
float f(float x)
{
return (x*x*x)-(4*x)-9;
}
0 Comments