program Beda_Terbagi_Newton_The_Queen_of_Science;
uses wincrt;
var
i, j, n : integer;
z, tol, pbagi, faktor, suku : real;
x, y, b : array[0..100] of real;
label 1, 2, 3;
begin
1:
write('Titik dicari: ');readln(z);
write('n = ');readln(n);
write('Toleransi = ');readln(tol);
writeln('===============================');
writeln('Titik dan nilai diketahui:');
for i:= 0 to n do
begin
write(' Untuk x',i,' = ');readln(x[i]);
write(' f(',x[i]:0:2,') = ');readln(y[i]);
end;
writeln('===============================');
b[0]:= y[0];
pbagi:= b[0];
faktor:= 1;
for i:= 1 to n do
begin
b[i]:= y[i];
for j:= i-1 downto 0 do
begin
b[j]:= (b[j+1] - b[j])/(x[i]-x[j]);
end;
faktor:= faktor*(z - x[i-1]);
suku:= b[0]*faktor;
pbagi:= pbagi + suku;
if abs(suku) <= tol then goto 2;
end;
2:
writeln('Jadi f(',z:0:2,') = ',pbagi:0:6);
Tidak ada komentar:
Posting Komentar