Pascal Code

procedure NEWRAP ( {FUNCTION F(X: REAL): REAL;}
P0, Delta, Epsilon: REAL; Max: INTEGER; var P1, Dp, Y1, Pone, Ptwo: REAL; var Cond, K: INTEGER);
  const
    Small = 1E-20;
  var
    Df, Y0, RelErr: REAL;
  begin
    K := 0;
    Cond := 0;
    VP[0] := P0;    {Store array of approximation}
    Y0 := F(P0);
    VQ[0] := Y0;
    P1 := P0 + 1;
    while (K < Max) and (Cond = 0) do
      begin
        Df := F1(P0);
        if Df = 0 then
          begin
            Cond := 1;
            Dp := P1 - P0;
            P1 := P0;
          end
        else
          begin
            Dp := Y0 / Df;
            P1 := P0 - Dp;
          end;
        Y1 := F(P1);
        RelErr := ABS(Dp);               { /(ABS(P1)+Small); }
        if (RelErr <= Delta) then
          Cond := 2;
        if (ABS(Y1) < Epsilon) then
          Cond := 3;
        if (RelErr <= Delta) and (ABS(Y1) < Epsilon) then
          Cond := 4;
        P0 := P1;
        Y0 := Y1;
        K := K + 1;
        VP[K] := P0;  {Store array of approximation}
        VQ[K] := F(P0);
        if K = 1 then
          Pone := P0;
        if K = 2 then
          Ptwo := P0;
      end;
  end;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004