PROGRAM PASCAL METODE NUMERIK DENGAN METODE NEWTON RAPSHON
uses crt;
label ulang;
var
x,x1,y,y1,z,f,f1,f2 : real;
i : integer;
ab :char;
begin
ulang:
clrscr;
writeln('Tent. nilai akar dari persamaan f(x)=3x+sin(x)+exp x dgn Metode Newton Raphson');
write('Input x1 = ');
readln(x1);
y1:= 3 * x1 + sin (x1) - exp (x1);
f1:= 3 + cos (x1) - exp(x1);
f2:= -sin(x1) - exp (x1);
z:= (y1*f2) / (f1*f1);
writeln(' Nilai f(x1)= ',y1:0:5);
writeln(' Nilai f`(x1)= ',y1:0:5);
writeln(' Nilai f``(x1)= ',y1:0:5);
if abs (z)<1 then;
i := 1;
readln;
writeln('Penyelesaian persamaan karekteristik dengan Metode Newton Raphson');
writeln('----------------------------------------------------------------------');
writeln(' n x f(x) error ');
writeln('----------------------------------------------------------------------');
repeat
begin
i := i + 1;
x := x1 - (y1/f1);
Y := 3 * x + sin (x) - exp (x);
f := 3 + cos (x) - exp (x);
if i<10 then
writeln(i,' :: ',x,' : ',y,' ',abs(y),' :: ')
else
writeln(': ,i, :: ,x, :: ,y, :: ',abs(y),' :: ');
x1 := x;
y1 := y;
f1 := f;
end;
until abs(y) < 1E-08;
writeln('----------------------------------------------------------------------');
writeln('Akar persamaan= ',x);
writeln('Errornya=' ,abs(y));
writeln('----------------------------------------------------------------------');
writeln('Apakah anda ingin mengulangi (y/t): ');
readln(ab);
if (ab='y') or (ab='Y') then
begin
goto ulang;
end
else
end.
Tidak ada komentar:
Posting Komentar