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

Goedangilmu

Source Code Metode Interpolasi Newton Dan Lagrange

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

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

procedure TForm1.Button5Click(Sender: TObject);
begin
x[i]:=strtofloat(edit4.text);
fx[i]:=strtofloat(edit5.Text);
tabel[i,0]:=strtofloat(edit5.Text);
i:=i+1;
edit4.Text:=”;
edit5.Text:=”;
end;


procedure TForm1.Button6Click(Sender: TObject);
var
i,n:integer;
begin
n:=strtoint(edit1.text);
for i:=0 to n do
begin
memo1.Lines.add(inttostr(i)+chr(vk_tab)+floattostr(x[i])+chr(vk_tab)+floattostr(fx[i]));
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
m,i,j,n: integer;
suku,xa,jumlah: real;
b:array [0..100] of real;
begin
xa:=strtofloat(edit3.text);
n:=strtoint(edit1.text);

m:=0;
for i:=1 to n do
begin
for j:=0 to n-i do
begin
tabel[j,i]:=(tabel[j+1,i-1]-tabel[j,i-1])/(x[j+i]-x[j]);
if m=0 then
begin
b[i]:=tabel[j,i];
m:=m+1;
end;
end;
m:=0;
end;

b[0]:=fx[0];
for i:=0 to n do
begin
memo1.Lines.add(inttostr(i)+chr(vk_tab)+floattostr(b[i]));
end;

jumlah:=0;

for i:=1 to n do
begin
suku:=tabel[0,i];
for j:=0 to i-1 do
begin
suku:=suku*(xa-x[j]);
end;
jumlah:=jumlah+suku;
end;
jumlah:=jumlah+tabel[0,0];
edit2.Text:=formatfloat(’#0.######’,jumlah);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
l:array [0..100] of real;
i,j,n:integer;
hasil,xa:real;
begin
n:=strtoint(edit1.text);
xa:=strtofloat(edit3.Text);

hasil:=0;
for i:=0 to n do
begin
l[i]:=1;
for j:=0 to n do
begin
if i<>j then
begin
l[i]:=l[i]*((xa-x[j])/(x[i]-x[j]));
end;
end;
hasil:=hasil+(fx[i]*l[i]);
end;
edit2.Text:=formatfloat(’#0.######’,hasil);
end;

Related Posts :

Published by Adith

1 Comment

  1. Yudi on 25.10.2008 at 10:07 (Reply)

    tolong jelasin syntaxnya dong gw blom blajar tuh…….

Leave a comment