Pseudo Code:
var
x0,x1,x2,x3,x4,x5,x6 :real;
f0,f1,f2,f3,f4,f5,f6 :real;
f01,f12,f23,f34,f45,f56 :real;
f012,f123,f234,f345,f456 :real;
f0123, f1234, f2345, f3456 :real;
f01234, f12345, f23456 :real;
f012345, f123456 :real;
f0123456 :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);
f0:=StrToFloat(edit8.Text);
f1:=StrToFloat(edit9.Text);
f2:=StrToFloat(edit10.Text);
f3:=StrToFloat(edit11.Text);
f4:=StrToFloat(edit12.Text);
f5:=StrToFloat(edit13.Text);
f6:=StrToFloat(edit14.Text);
//f[Xi,Xi+1]
f01:=(f1-f0)/(x1-x0);
f12:=(f2-f1)/(x2-x1);
f23:=(f3-f2)/(x3-x2);
f34:=(f4-f3)/(x4-x3);
f45:=(f5-f4)/(x5-x4);
f56:=(f6-f5)/(x6-x5);
edit15.Text:=(format('%8.4f',[f01]));
edit16.Text:=(format('%8.4f',[f12]));
edit17.Text:=(format('%8.4f',[f23]));
edit18.Text:=(format('%8.4f',[f34]));
edit19.Text:=(format('%8.4f',[f45]));
edit20.Text:=(format('%8.4f',[f56]));
//f[X1,...,Xi+2]
f012:=(f12-f01)/(x2-x0);
f123:=(f23-f12)/(x3-x1);
f234:=(f34-f23)/(x4-x2);
f345:=(f45-f34)/(x5-x3);
f456:=(f56-f45)/(x6-x4);
edit21.Text:=(format('%8.4f',[f012]));
edit22.Text:=(format('%8.4f',[f123]));
edit23.Text:=(format('%8.4f',[f234]));
edit24.Text:=(format('%8.4f',[f345]));
edit25.Text:=(format('%8.4f',[f456]));
//f[Xi,...,Xi+3]
f0123:=(f123-f012)/(x3-x0);
f1234:=(f234-f123)/(x4-x1);
f2345:=(f345-f234)/(x5-x2);
f3456:=(f456-f345)/(x6-x3);
edit26.Text:=(format('%8.4f',[f0123]));
edit27.Text:=(format('%8.4f',[f1234]));
edit28.Text:=(format('%8.4f',[f2345]));
edit29.Text:=(format('%8.4f',[f3456]));
//f[Xi,...,Xi+4]
f01234:=(f1234-f0123)/(x4-x0);
f12345:=(f2345-f1234)/(x5-x1);
f23456:=(f3456-f2345)/(x6-x2);
edit30.Text:=(format('%8.4f',[f01234]));
edit31.Text:=(format('%8.4f',[f12345]));
edit32.Text:=(format('%8.4f',[f23456]));
//f[X1,...,Xi+5]
f012345:=(f12345-f01234)/(x5-x0);
f123456:=(f23456-f12345)/(x6-x1);
edit33.Text:=(format('%8.4f',[f012345]));
edit34.Text:=(format('%8.4f',[f123456]));
//f[Xi,...,Xi+6]
f0123456:=(f12345-f01234)/(x6-x0);
edit35.Text:=(format('%8.4f',[f0123456]));
//mencari p6(x)
x:=StrToFloat(edit36.Text);
p6x:=(f0)+(f01*(x-x0))+(f012*(x-x0)*(x-x1))+(f0123*(x-x0)*(x-x1)*(x-x2))+(f01234*(x-x0)*(x-x1)*(x-x2)*(x-x3))+(f012345*(x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4))+(f0123456*(x-x0)*(x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5));
edit37.Text:=(format('%8.4f',[p6x]));
end;
end.
0 comments: