You are on page 1of 3

PROGRAM PASCAL

METODE NEWTON RAPHSON


Nama : Laila Intani Putri
Nim

: 1301407

Prodi : Matematika

1.a
program newton_rapshon;
uses crt;
var i: integer;
fx0,fx1,x0,xbaru,galat, akar: real;
begin
clrscr;
gotoxy (29,1); writeln (' METODE NEWTON RAPHSON ');
gotoxy (30,2); writeln (' f(x) = x + cos (x) ');
writeln('Nama

: laila intani putri

writeln('NIM

: 1301407 ');

');

writeln;
write ('Masukkan nilai x0 : '); readln(x0);
writeln;
writeln
('---------------------------------------------------------------------------------');
gotoxy(1,10);

writeln

('-------------------------------------------------------------------------------');
i:= 1;
gotoxy(1,9);writeln('Literasi');
gotoxy(13,9);writeln('x');
gotoxy(27,9);writeln('f(x)');
gotoxy(42,9);writeln('f"(x)');
gotoxy(57,9);writeln('Galat');
repeat
gotoxy(4,11+i);writeln(i);
gotoxy(10,11+i);writeln(x0:0:6);
gotoxy(25,11+i);writeln(fx0:0:6);

gotoxy(40,11+i);writeln(fx1:0:6);
gotoxy(55,11+i);writeln(Galat:0:6);
fx0:= x0 + cos (x0) ;
fx1:= 1 - sin (x0) ;
if fx1=0 then
begin
writeln('SELESAI. ket: fx0=0 ');
end;
xbaru:=x0-(fx0/fx1);
galat:=abs((xbaru-x0)/xbaru);
x0:=xbaru;
akar:=x0 ;
i:=i+1;
until galat<=0.000001;
writeln;
writeln;
writeln('maka akar persamaannya adalah ',x0:0:6);
readln;
end.
OUTPUT :

You might also like