1. Teks berjalan dari kanan ke kiri

"ASALAMUALAIKUM"welcome to my blogger SEDIKIT MEMBANTU DAN BERBAGI

Selasa, 16 April 2013

CONTOH PROGRAM PASCAL PADA METODE RUGULAFALSI


Program Regulafalsi (MetNum)

Berikut adala contoh program Regulafalsi Metode Numerik dengan menggunakan bahasa pemrograman pascal :
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)= x3 x^3 + x^2 – 3x – 3 – 0 dengan metode regula falsi ‘) ;
write ( ‘ masukan nilai x1 = ‘ ) ; readln (x1);
y1 := x1 * x1 * x1 + x1 * x1 – 3 * x1 – 3 ;
writeln ( ‘ nilai f(x) = ‘, 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 tidak sesuai ‘ );
until ( y1 * y2 ) < 0 ;
writeln ;
writeln ( ‘ penyelesaian karakteristik dengan metode regulafalsi : ‘ ) ;
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),’:');
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 mengulanginya (y/t)’ ) ;
readln (ab) ;
if ( ab = ‘y’ ) or ( ab = ‘Y’ ) then
begin
goto ulang
end ;
end.

Tidak ada komentar:

Posting Komentar