was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

39 Visitors Online


 
...Wert eines Polynoms n-ten Grades an einem gegebenen Punkt bestimmen?
Autor: Loïs Bégué
[ Tip ausdrucken ]  

Tip Bewertung (3):  
     


// Simultaneous evaluation of a given polynomial and its first derivative at a given point
// Simultane Berechnung des Wertes eines Polynoms n-ten Grades und seiner Ableitung

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 do
  begin
    
derivation := derivation * X + FX;
    FX := FX * X + Polynom[i];
  end;
end;

{Beispiel / Sample code }

procedure TForm1.Button1Click(Sender: TObject);
var
  
X, FX, derivation: Extended;
begin
 
(* Horner's scheme give an algorithm for the simultaneous evaluation
   of a given polynomial and its first derivative at a given point *)

 (* Hornerschema zur Berechnung eines Polynoms n-ten Grades an einem
    bestimmten Punkt *)

  (* 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;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners