X4 + 3X3 + 2X2 + 5X = 0
DENGAN MENGGUNAKAN METODE SECANT
A. Flowchart Program
START
Input x1
Input x2
tidak
Y1*Y3 < 0
ya
X1X3
X2 X3
Y1 Y3
Y2 Y3
tidak
Abs(Y3) < 10-8
ya
Output Y3
dan X3
ya
Coba Lagi?
tidak
STOP
Procedure delay;
Var
Wkt : longint;
Begin
For Wkt := 1 to 10000000 do
Write('');
End;
procedure mulai;
begin
GotoXY (15,1);
WriteLn
('**************************************************');
GotoXY (15,2);
WriteLn ('**');
GotoXY (63,2);
WriteLn ('**');
GotoXY (15,3);
WriteLn ('**');
GotoXY (63,3);
WriteLn ('**');
GotoXY (15,4);
WriteLn ('**');
GotoXY (63,4);
WriteLn ('**');
GotoXY (15,5);
WriteLn ('**');
GotoXY (63,5);
WriteLn ('**');
GotoXY (15,6);
WriteLn
('**************************************************');
GotoXY (29,3);
WriteLn ('PENCARIAN AKAR-AKAR DARI');
GotoXY (30,4);
WriteLn ('X^4 + 3X^3 + 2X^2 + 5X');
GotoXY (1,8);
WriteLn
('*******************************************************************
*************');
end;
procedure start;
begin
GotoXY (30,10);
WriteLn ('***************************');
GotoXY (29,11);
end;
procedure stop;
begin
GotoXY (30,10);
WriteLn ('***************************');
GotoXY (29,11);
WriteLn ('**');
GotoXY (56,11);
WriteLn ('**');
GotoXY (25,12);
WriteLn ('*****');
GotoXY (57,12);
WriteLn ('*****');
GotoXY (29,13);
WriteLn ('**');
GotoXY (56,13);
WriteLn ('**');
GotoXY (30,14);
WriteLn ('***************************');
GotoXY (38,12);
WriteLn ('TERIMA KASIH');
end;
procedure input1;
begin
val (x1s, x1, code);
if (code <> 0)then
begin
GotoXY (5,11);
Writeln ('Maaf, Input Harus Berupa Angka');
j := 0;
end
else
if (x1 < -7) or (x1 > 7)then
begin
GotoXY (5,11);
writeln(' Masukkan nilai tebakan x1 antara -7 s/d 7');
j := 0;
end
else
if (x1 = 0) then
begin
procedure input2;
begin
val (x2s, x2, code);
if (code <> 0)then
begin
GotoXY (5,11);
Writeln ('Maaf, Input Harus Berupa Angka');
j := 0;
end
else
if (x2 < -7) or (x2 > 7)then
begin
GotoXY (5,11);
writeln(' Masukkan Nilai Tebakan X2 Antara -7 s/d 7');
j := 0;
end
else
if (x2 = 0) then
begin
GotoXY (5,11);
writeln(' Nilai Tebakan X2 Tidak Boleh Nol');
j := 0;
end
else
j := 1;
end;
procedure input3 ;
begin
if (x1 = x2) then
begin
repeat
GotoXY (5,11);
writeln(' Nilai Kedua Tebakan Harus Berbeda');
repeat
mulai;
GotoXY (5,9);
write ('Masukkan Nilai X1 = ');
readln(x1s);
clrscr;
input1;
until j = 1;
repeat
mulai;
GotoXY (5,9);
write ('Masukkan Nilai X2 = ');
readln(x2s);
clrscr;
input2;
until j = 1;
if (x1> 0) and (x2 < 0) then
{program utama}
begin
clrscr;
start;
delay ;
repeat
clrscr;
mulai;
repeat
GotoXY (5,9);
write ('MASUKKAN NILAI TEBAKAN X1 = ');
readln(x1s);
clrscr;
mulai;
input1;
until j = 1;
repeat
GotoXY (5,9);
write ('MASUKKAN NILAI TEBAKAN X2= ');
readln(x2s);
clrscr;
mulai;
input2;
until j = 1 ;
input3;
begin
repeat
begin
i:= i+1;
x3:= x2 - (y2 * ( x2 - x1) / (y2 -y1 ));
y3:= x3*x3*x3*x3 + 3*x3*x3*x3 + 2*x3*x3 + 5*x3;
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('===================================================');
WriteLn(' AKAR PERSAMAANNYA ADALAH = ', x3);
WriteLn(' NILAI ERRORNYA ADALAH = ', Abs(y3) );
WriteLn('===================================================');
WriteLn;
end;
X4 + 3X3 + 2X2 + 5X = 0
1. Procedure Delay.
Procedure delay;
Var
Wkt : longint;
Begin
For Wkt := 1 to 10000000 do
Write('');
End;
Procedure ini digunakan untuk menyisipkan waktu jeda, dan akan digunakan
pada program utama.
procedure start;
begin
GotoXY (30,10);
WriteLn ('***************************');
GotoXY (29,11);
WriteLn ('**');
GotoXY (56,11);
WriteLn ('**');
GotoXY (25,12);
WriteLn ('*****');
GotoXY (57,12);
WriteLn ('*****');
GotoXY (29,13);
WriteLn ('**');
GotoXY (56,13);
WriteLn ('**');
GotoXY (30,14);
WriteLn ('***************************');
GotoXY (37,12);
WriteLn ('METODE SECANT');
end;
procedure stop;
begin
GotoXY (30,10);
WriteLn ('***************************');
GotoXY (29,11);
WriteLn ('**');
GotoXY (56,11);
WriteLn ('**');
GotoXY (25,12);
WriteLn ('*****');
GotoXY (57,12);
WriteLn ('*****');
GotoXY (29,13);
WriteLn ('**');
GotoXY (56,13);
WriteLn ('**');
GotoXY (30,14);
WriteLn ('***************************');
GotoXY (38,12);
WriteLn ('TERIMA KASIH');
end;
begin
val (x1s, x1, code);
if (code <> 0)then
begin
GotoXY (5,11);
Writeln ('Maaf, Input Harus Berupa Angka');
j := 0;
end
else
if (x1 < -7) or (x1 > 7)then
begin
GotoXY (5,11);
writeln(' Masukkan nilai tebakan x1 antara -7 s/d 7');
j := 0;
end
else
if (x1 = 0) then
begin
GotoXY (5,11);
writeln(' Nilai Tebakan X1 Tidak Boleh Nol');
j := 0;
end
else
j := 1;
end;
4. Procedure Input2.
procedure input2;
begin
val (x2s, x2, code);
if (code <> 0)then
begin
GotoXY (5,11);
Writeln ('Maaf, Input Harus Berupa Angka');
j := 0;
end
else
if (x2 < -7) or (x2 > 7)then
begin
GotoXY (5,11);
writeln(' Masukkan Nilai Tebakan X2 Antara -7 s/d 7');
j := 0;
end
else
if (x2 = 0) then
begin
GotoXY (5,11);
5. Procedure Input3.
procedure input3 ;
begin
if (x1 = x2) then
begin
repeat
GotoXY (5,11);
writeln(' Nilai Kedua Tebakan Harus Berbeda');
repeat
mulai;
GotoXY (5,9);
write ('Masukkan Nilai X1 = ');
readln(x1s);
clrscr;
input1;
until j = 1;
repeat
mulai;
GotoXY (5,9);
write ('Masukkan Nilai X2 = ');
readln(x2s);
clrscr;
input2;
until j = 1;
if (x1> 0) and (x2 < 0) then
begin
repeat
GotoXY (5,11);
writeln(' Nilai X2 Harus Positif');
repeat
mulai;
GotoXY (5,9);
write ('Masukkan Nilai X2 = ');
readln(x2s);
clrscr;
input2;
until j = 1;
until x2 > 0
end;
until (x1 <> x2)
end
else
if (x1> 0) and (x2 < 0) then
begin
repeat
c. Diinputkan angka yang lebih dari nilai -7 s/d 7 maka program akan meminta
penginputan lagi dan akan tampil di layar :
Dan jika nilai yang diinputkan sesuai dengan permintaan program tidak
melewati aturan-aturan yang telah diset dalam program, maka program akan meminta
a. Jika nilai input X2 sama dengan nilai input X1 maka akan tampil di layar :
Uji Coba :
Input X1 : 1
Input X2 : 2
Outputnya :
Langkah 1.
Langkah 3.
Agama : Hindu
Email : turusdi.info@gmail.com
www.facebook.com/turusdi