Sabtu, 08 Oktober 2011

0 Metode Bisection


#include
#include
#include

float f(float x){
return (x*x - 6*x + 8);
}

void garis(){
for (int a = 1; a<= 70;a++)
cout<<"=";
}

void main(){
float xl,yxl,xr,yxr,xt,yxt,e;
char lagi;
int k = 0;
garis();
cout<<"\nPROGRAM MENCARI SOLUSI METODE NUMERIK\nDENGAN METODE BISECTION\n";
garis();
cout<<"\n\n\nPersamaan kuadrat yang dipakai : x.x - 6.x + 8";
cout<<"\nMasukkan nilai xl : "; cin>>xl;
cout<<"Masukkan nilai xr : "; cin>>xr;
cout<<"Masukkan nilai error : "; cin>>e;
garis();
cout<<"\nNo xl\t xr\tf(xl)\t\tf(xr)\t e\txt\t\tf(xt)\n" ;
garis();
do{
cout<
k = k + 1;
cout<
printf("%6.2f",xl);
printf("%6.2f",xr);
yxl= f(xl);
printf("%13.4e",yxl);
yxr= f(xr);
printf("%13.4e",yxr);
cout<<" "<
xt = (xl + xr) / 2;
printf("%13.4e",xt);
yxt = f(xt);
printf("%13.4e",yxt);
if (fabs(yxt) <= e){
cout<<"\nmaka solusinya adalah : " << xt;
}
else if (yxl * yxt > 0){
xl = xt;
xr =xr;
}
else{
xr = xt;
xl = xl;
}
}
while (fabs(yxt) >= e);
}

About the Author

I'm Author description here. Go to Blogger edit html and find these sentences. Now replace these sentences with your own descriptions. Subscribe to Our Feed and Follow Me on Twitter My user

    Other Recommended Posts

0 komentar:

Posting Komentar

 
back to top