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

Goedangilmu

Source Code Metode Interpolasi

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

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

procedure TForm1.Button1Click(Sender: TObject);
var
x,x0,x1,fx0,fx1,fx:real;
begin
x:=2;
x0:=1;
x1:=6;
fx0:=0;
fx1:=1.7917;

fx:=fx0+((fx1-fx0)/(x1-x0))*(x-x0);

edit1.text:=formatfloat(’#0.######’,fx);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
edit1.Clear;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
x0,x1,x2,x,fx0,fx1,fx2,fx,b0,b1,b2:real;
begin
x0:=1; fx0:=0;
x1:=4; fx1:=1.3863;
x2:=6; fx2:=1.7917;
x:=2;

b0:=fx0;
b1:=(fx1-fx0)/(x1-x0);
b2:=(((fx2-fx1)/(x2-x1))-((fx1-fx0)/(x1-x0)))/(x2-x0);

fx:=(b0+(b1*(x-x0)))+(b2*((x-x0)*(x-x1)));

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

procedure TForm1.Button3Click(Sender: TObject);
var
x0,x1,x2,x3,x,fx,fx1,fx0,fx2,fx3,b0,b1,b2,b3:real;
begin
x:=2;
x0:=1; fx0:=0;
x1:=4; fx1:=1.3863;
x2:=6; fx2:=1.7917;
x3:=8; fx3:=2.3863;

b0:=fx0;
b1:=(fx1-fx0)/(x1-x0);
b2:=(((fx2-fx1)/(x2-x1))-((fx1-fx0)/(x1-x0)))/(x2-x0);

b3:=(((((fx3-fx2)/(x3-x2))-((fx2-fx1)/(x2-x1)))/(x3-x1))-((((fx2-fx1)/(x2-x1))-((fx1-fx0)/(x1-x0)))/(x2-x0)))/(x1-x0);

fx:=(b0+(b1*(x-x0)))+(b2*(x-x0)*(x-x1))+(b3*(x-x0)*(x-x1)*x-x2);

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

end.

Related Posts :

Published by Adith

No Comments

Leave a comment