[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum » Codeing » C ++ Examples of maths » REGULA FASAI (REGULA FASAI)
REGULA FASAI
pradeepDate: Monday, 16 January 12, 11:13 AM | Message # 1
pk
Group: Administrators
Messages: 82
Status: Offline
#include
#include
#include
#define f(x) x*x+x-1
void main()
{
float x0,x1,x2,f0,f1,f2,e;
int max,i;
clrscr();
printf("?Input Two initial Roots,Max iteration and torlerance value:");
scanf("%f%f%d%f",&x0,&x1,&max,&e);
f0=f(x0);
f1=f(x1);
if(f0*f1>0.0)
{
printf("\ Initial roots are unsuitable\n");
}
else
{
for(i=1;i<=max; i++)
{
x2=(x0*f1-x1*f0)/(f1-f0);
f2=f(x2);
if(fabs(f2) {
printf("\solution is converge\n");
printf("\Root of the given equation is =%8.4f\n",x2);
max=i;
}
else
{
if(f2*f0<0)
{
x1=x2;
f1=f2;
}
else
{
x0=x2;
f0=f2;
}
}
}
}
getch();
}
 
Forum » Codeing » C ++ Examples of maths » REGULA FASAI (REGULA FASAI)
  • Page 1 of 1
  • 1
Search: