Skip to content

Regula Falsi

October 4, 2008

program regula_falsi;
uses crt;
label ulang;
var
x1,x2,x3,y1,y2,y3 : real;
i : integer;
Ab :char;
data1 : real;
begin
ulang:
clrscr;
writeln(‘Tentukan nilai akar dari persamaan f(x)=x^3+x^2-3x-3=0 dengan Regula Falsi’);
write(‘Masukan nilai x1 = ‘);readln(x1);
y1 := x1 * x1 * x1 + x1 * x1 – 3 * x1 – 3;
writeln(‘ Nilai f(x1)= ‘,y1:0:4);
repeat
begin
write( ‘Masukan nilai x2 = ‘ ); readln(x2);
y2 := x2 * x2 * x2 + x2 * x2 – 3 * x2 – 3;
write(‘ Nilai f(x2)= ‘,y2:0:4);
end;
if (y1*y2)<0 then
Writeln(‘ Syarat Nilai Ok’)
else
Writeln(‘ Nilai X2 Belum Sesuai’);
until ( y1 * y2 ) <0;
writeln;
writeln(‘Penyelesaian persamaan karekteristik dengan metoda regula falsi’);
writeln(‘———————————————————————-‘);
writeln(‘ n x f(x) error ‘);
writeln(‘———————————————————————-‘);
repeat
begin
i:= i + 1; x3 := ( x2-( y2 / ( y2 – y1))*(x2-x1));
y3 := x3 * x3 * x3 + x3 * x3 – 3 * x3 – 3;
if i<10 then
writeln(‘ ‘,i,’ : ‘,x3,’ : ‘,y3,’ : ‘,abs(y3),’ : ‘)
else
writeln(i,’ : ‘,x3,’ : ‘,y3,’ : ‘,abs(y3),’ : ‘);
if ( y1 * y3 ) <0 then
begin
x2 := x3 ; y2 := y3 ;
end
else
begin
x1 := x3 ; y1 := y3;
end;
end;
until abs( y3 ) < 1E-08;
writeln(‘———————————————————————-‘);
writeln(‘Akar persamaannya= ‘,x3);
writeln(‘Errornya=’ ,abs( y3 ));
writeln(‘———————————————————————-‘);
writeln(‘Apakah anda ingin mengulangi (y/t): ‘);
readln(ab);
if (ab=’y’) or (ab=’Y’) then
goto ulang;
end.

3 Comments
  1. Anonymous permalink

    gag jalaan bro?? error 200:division by zero.. gmanaa yah??

  2. masak sie bro..
    cb inputnya pake angka yg laen.. mungkin ada validasi yang belum saya tambahkan..

  3. Regula Falsi..(mksd ny apa yaa?)
    bisa tolong ceritakan gak jalannya program?
    saya dpt tugas nee..
    tq

Leave a Reply

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 / Change )

Twitter picture

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

Facebook photo

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

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: