PROGRAM SECANT;
USES WINCRT;
FUNCTION F(X:REAL):REAL;
BEGIN
F:=EXP(X)-5*X*X;
END;
VAR E,X0,X1,X2,M : REAL;
X :INTEGER;
BEGIN
CLRSCR;
WRITELN('---------------------------------------------------------');
WRITELN(' PROGRAM METODE SECANT ');
WRITELN(' OLEH: ');
WRITELN(' * ASTOKO YOGA S (09.04.111.00094) ');
WRITELN(' * ZAINAL ARIFIN (09.04.111.00104) ');
WRITELN(' * FITRIANSYAH PERDANA P (09.04.111.00125) ');
WRITELN('_________________________________________________________');
WRITELN('');
E:=0.00001;
WRITE('MASUKKAN X0 = ');READLN(X0);
WRITE('MASUKKAN X1 = ');READLN(X1);
WRITELN;
X:=0;
WRITELN('--------------------------------------------------------------------');
WRITELN(' Iterasi Ke | Xr | Xr+1-Xr |');
REPEAT
X2:=X1-(F(X1)*(X1-X0))/(F(X1)-F(X0));
M:=ABS(X2-X1);
X0:=X1;
X1:=X2;
X:=X+1;
WRITELN('--------------------------------------------------------------------');
WRITELN(' ',X,' | ',X1:0:5,' | ',M:0:5,' |');
UNTIL M < E;
WRITELN('--------------------------------------------------------------------');
WRITELN;
WRITELN('JADI AKARNYA ADALAH = ',X1:0:5);
READLN;
END.
ref:
http://astoko.blogspot.com/2011/06/kode-program-metode-secant-dengan.html
http://en.wikipedia.org/wiki/Secant_method