OLiSwEll

Sharing is My Style

Search This Blog

Bisection method

/* Write a Program to solve equation using Bisection Method */
#include
float bisection(float,float,float);
void main()
{
float xl,xu,ea,fxr;
clrscr();
printf("Enter Lower Bound : ");
scanf("%f",&xl);
printf("Enter Upper Bound : ");
scanf("%f",&xu);
printf("Enter Percentage Error : ");
scanf("%f",&ea);
fxr = bisection(xl,xu,ea);
printf("F(xr) : %.2f",fxr);
getch();
}

float bisection(float xl,float xu,float ea)
{
float xr,fxr,tmp;
do
{
xr = (xl + xu) / 2;
fxr = ((xr*xr*xr) -9 * xr + 1);

if(fxr*xu < 0)
xu = xr;
else if(fxr*xu>0)
xl = xr;
else
xr = 0;

if(fxr<0)
tmp = fxr * -1;
}while(tmp>ea);
return xr;
}

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Followers

Infolinks In Text Ads


Bloggers - Meet Millions of Bloggers

Traker

eXTReMe Tracker

online

PageRank Entertainment
Mobilt Bredband Guiden Submit Blog & RSS Feeds