Love What You Do, Do What You Love

Program Interpolasi lagrange Menggunakan Delphi 7

Posted by : Unknown
Selasa, 26 November 2013


Pseudo Code:
var
  x0,x1,x2,x3,x4,x5,x6 :real;
  y0,y1,y2,y3,y4,y5,y6 :real;
  L0x,L1x,L2x,L3x,L4x,L5x,L6x :real;
  x,p6x :real;

begin
  x0:=StrToFloat(edit1.Text);
  x1:=StrToFloat(edit2.Text);
  x2:=StrToFloat(edit3.Text);
  x3:=StrToFloat(edit4.Text);
  x4:=StrToFloat(edit5.Text);
  x5:=StrToFloat(edit6.Text);
  x6:=StrToFloat(edit7.Text);

  y0:=StrToFloat(edit8.Text);
  y1:=StrToFloat(edit9.Text);
  y2:=StrToFloat(edit10.Text);
  y3:=StrToFloat(edit11.Text);
  y4:=StrToFloat(edit12.Text);
  y5:=StrToFloat(edit13.Text);
  y6:=StrToFloat(edit14.Text);

  x:=STrToFloat(edit15.Text);

  //mencari Li(x)
  L0x:=((x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6))/((x0-x1)*(x0-x2)*(x0-x3)*(x0-x4)*(x0-x5)*(x0-x6));
  L1x:=((x-x0)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6))/((x1-x0)*(x1-x2)*(x1-x3)*(x1-x4)*(x1-x5)*(x1-x6));
  L2x:=((x-x0)*(x-x1)*(x-x3)*(x-x4)*(x-x5)*(x-x6))/((x2-x0)*(x2-x1)*(x2-x3)*(x2-x4)*(x2-x5)*(x2-x6));
  L3x:=((x-x0)*(x-x1)*(x-x2)*(x-x4)*(x-x5)*(x-x6))/((x3-x0)*(x3-x1)*(x3-x2)*(x3-x4)*(x3-x5)*(x3-x6));
  L4x:=((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x5)*(x-x6))/((x4-x0)*(x4-x1)*(x4-x2)*(x4-x3)*(x4-x5)*(x4-x6));
  L5x:=((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x6))/((x5-x0)*(x5-x1)*(x5-x2)*(x5-x3)*(x5-x4)*(x5-x6));
  L6x:=((x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5))/((x6-x0)*(x6-x1)*(x6-x2)*(x6-x3)*(x6-x4)*(x6-x5));

  //mencari P6(x)
  p6x:=(y0*L0x)+(y1*L1x)+(y2*L2x)+(y3*L3x)+(y4*L4x)+(y5*L5x)+(y6*L6x);
  edit16.Text:=(format('%8.4f',[p6x]));

end;

2 comments:

Unknown mengatakan...

bermanffat bgt :)

Sayyid Syafiq Abdul Aziz mengatakan...

kalkulator delphi aja brati sudah menerapkan konsep interpolasi?

Copyright © 2012 Zuka Zuka World | Hatsune Miku Theme | Designed by Johanes DJ