/*
Secant Method
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))));
a=b;
b=c;
}
printf("\nRoot is:: %f",c);
getch();
}
float f(float x)
{
return (x*x*x)-(4*x)-9;
}
0 Comments