Sabtu, 19 November 2016

Program Interpolasi Lagrange Menggunakan Delphi

procedure TInterpolasiLagrange.Panel6Click(Sender: TObject);
var
x:array[0..100] of real;
fx:array[0..100] of real;
xt,plag,faktor:real;
i,j,n,m,p:integer;
begin
p:=0;
m:=-1;
repeat
m:=m+1;
p:=p+1;
listbox1.Items.Add(inttostr(m));
until p=listbox2.Count;
for i:=0 to listbox2.Count-1 do x[i]:=strtofloat(listbox2.Items[i]);
for i:=0 to listbox3.Count-1 do fx[i]:=strtofloat(listbox3.Items[i]);
n:=strtoint(edit5.Text);
xt:=strtofloat(edit3.Text);
plag:=0;
for i:=0 to n do
begin
faktor:=1;
for j:=0 to n do if j=i then faktor:=faktor else faktor:=faktor*((xt-x[j])/(x[i]-x[j]));
plag:=plag+faktor*fx[i];
edit4.Text:=floattostr(plag);
end;

end;

procedure TInterpolasiLagrange.Panel7Click(Sender: TObject);
begin
edit1.text:=' ';
edit2.text:=' ';
edit3.text:=' ';
edit4.text:=' ';
edit5.text:=' ';
listbox1.Items.clear;
listbox2.Items.clear;
listbox3.Items.clear;
end;

procedure TInterpolasiLagrange.Panel8Click(Sender: TObject);
begin
close;
end;

end.

0 komentar:

Posting Komentar