program bisection bolzano

10 09 2008

uses crt;
var
a,b,c,k:real;
fa,fb,fc:real;
n:integer;

begin
clrscr;
writeln (‘f(x)=2e^x-2x-8′);
n:=0;
repeat
write (‘masukan a0=’); readln(a);
fa:=(2*exp(a))-(2*a)-8;
writeln(‘f(‘,a:0:2,’)=’,fa:0:2);

write (‘masukan b0=’); readln(b);
fb:=(2*exp(b))-(2*b)-8;
writeln(‘f(‘,b:0:2,’)=’,fb:0:2);
until (fa*fb<0);

writeln(‘———————————-’);
writeln(‘n an bn cn fc’);
writeln(‘———————————-’);

repeat
c:=(a+b)/2;
fc:=(2*exp(c))-(2*c)-8;
write(n,’ ‘);
write(a:0:3,’ ‘);
write(b:0:3,’ ‘);
write(c:0:3,’ ‘);
writeln(fc:0:3,’ ‘);
if fc<0 then a:=c
else b:=c;
n:=n+1;
k:=abs(fc);
until k<0.001;
readln;

end.


Tindakan

Information

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s




Ikuti

Get every new post delivered to your Inbox.