Program Bagi_dua;

Uses Crt;

function f(x:real):real;

begin

f:=2*exp(x)-4*x*x;

end;

var x0,x1,c,m:real;

i:integer;

begin

ClrScr; (Download Filenya Disini)

writeln(‘ http://www.lem.co.cc ‘);

writeln(‘ =======================================’);

writeln(‘ Mencari akar 2exp(x)-4x^2 = 0’);

writeln(‘ Menggunakan Metode Bagi Dua’);

Writeln(‘ =======================================’);

write(‘ input x0= ‘); readln(x0);

write(‘ input x1= ‘); readln(x1);

writeln(‘ =======================================’);

writeln(‘ i taksiran-akar ke-i lebar selang’);

writeln(‘ =======================================’);

i:=0;

repeat

c:=(x0+x1)/2;

m:=f(x0)*f(c);

i:=i+1;

if m < 0 then

begin

writeln(‘ ‘,i:2,’ ‘,c:0:7,’ ‘,abs(x1-x0):0:7);

x1:=c;

end

else

begin

writeln(‘ ‘,i:2,’ ‘,c:0:7,’ ‘,abs(x1-x0):0:7);

x0:=c;

end;

until abs(x1-x0)<=0.000001;

writeln;

writeln(‘ =======================================’);

writeln(‘ Jadi akar persamaannya adalah ‘,c:0:7);

readln;

readln;

end.