Information Technology Articles :: SEO Tips :: WAP Articles :: Search Engine Marketing :: Internet Tips

Goedangilmu

Source Code Metode Interpolasi Newton

Posted on April 27th, 2007 in Programming, 409 views

Berikut ini merupakan source code metode interpolasi newton yang saya buat menggunakan delphi.

var
b,x,fx: array [0..20] of real;
hasil1,hasilakhir,hasil,xa:real;
n,i,j:integer;
begin
x[0]:=1; fx[0]:=0;
x[1]:=4; fx[1]:=1.3863;
x[2]:=6; fx[2]:=1.7917;
xa:=2;
n:=strtoint(edit2.text);

for i:=1 to n do
begin
if i=1 then
begin
b[i]:=(fx[i]-fx[i-1])/(x[i]-x[i-1]);
end
else
begin
b[i]:=(((fx[i]-fx[i-1])/(x[i]-x[i-1]))-b[i-1])/(x[i]-x[0]);
end;
memo1.Lines.add(inttostr(i)+chr(vk_tab)+formatfloat(’#0.######’,b[i]));
end;

hasil:=0;
hasil1:=0;

for i:=1 to n do
begin
if i=1 then
begin
hasil:=xa-x[0];
end
else
begin
for j:=1 to i-1 do
begin
hasil:=hasil*(xa-x[j]);
end;
end;
hasil1:=hasil1+(b[i]*hasil);
end;
hasilakhir:=hasil1+fx[0];

edit1.Text:=formatfloat(’#0.######’,hasilakhir);
end;

Related Posts :

Published by Adith

No Comments

Leave a comment