All pastes #929032 Raw Edit

Anonym

public text v1 · immutable
·published 2008-03-05 14:15 UTC
rendered paste body
FUNCTION TPolynom.NullStelle(x:REAL):REAL; 
VAR Abl      : TPolynom; 
    y,yAbl   : REAL; 
    Abbruch  : BOOLEAN; 
    i        : Integer; 
BEGIN 

  Abl:= TPolynom.Ableitung(Self); 
  f0:=P.Parse(EdEin.text);
  f1:=f0.Ableitung; 
  f1:=f1.Vereinfachung;
  Abl := f1;
  i:=1; 
  REPEAT 
    INC(i); 
    yAbl:= Abl.Wert(x); 
    Abbruch := (i=MaxIter) OR (yAbl = 0.0); 
    y:= Wert(x); 
    IF NOT Abbruch AND (y<>0.0) THEN x:=x-y/yAbl 
  UNTIL Abbruch OR (Abs(y)<Eps); 
  /* Ende derSchleife ist erreicht und das Ergebnis ist entweder Schrott (was das auch immer ist) oder
  der erreichte wert für X und wird zurückgegeben */  
  IF Abbruch AND (y<>0.0) THEN NullStelle:=Schrott ELSE Nullstelle:=x; 
  Abl.Destroy 
END;