Вычислить значение полинома в данной точке
type
TPolynomArray = array of Double;
procedure Horner(Polynom: TPolynomArray; X: Extended; var FX, derivation: Extended);
var
i: Integer;
H: Integer;
begin
H := High(Polynom);
FX := Polynom[H];
derivation := 0.0;
for i := H - 1 downto 0 do
begin
derivation := derivation * X + FX;
FX := FX * X + Polynom[i];
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
X, FX, derivation: Extended;
begin
(* f(x) = 3 x^5 + 4 x^4 + 13 x^3 - 59 x^2 + 19 x - 97 *)
X := 2.5;
Horner(VarArrayOf([-97, 19, - 59, 13, 4, 3]), X, FX, derivation);
ShowMessage(Format('x = %n'#13#10'f(x) = %n'#13#10'f''(x) = %n' , [X, FX, derivation]));
end;