Delphi版本插值Lagrange
function Lagrange(x, y:ArrayDouble; N: integer; x1: Double): double;
var
I, J: Integer;
a: Double;
begin
Result := 0;
for i := 0 to N - 1 do
begin
a := 1;
for J := 0 to N - 1 do
begin
if (I <> J) then
a := a * (x1 - x[J]) / (x[I] - x[J]);
end;
Result := Result + a * y[I];
end;
end;