(*Newton iteration ... *) dig:=50. APSPRE(dig). AbsErr:=APFRN(RNRED(1,IEXP(10,dig/2))). MaxIter:=100. PROCEDURE Newton(f,fp,x); (*Newton iteration. f and fp are functions. x is the starting value for iteration. A fix point of x-f(x)/fp(x) is returned. *) VAR i, y, z, zp, w: ANY; BEGIN (*1*) i:=0; y:=x; (*2*) WHILE i < MaxIter DO i:=i+1; z:=f(y); zp:=fp(y); IF APCMPR(APABS(zp),AbsErr) <= 0 THEN CLOUT("Derivation becommes zero."); BLINES(1); RETURN(y) END; w:=APQ(z,zp); y:=APDIFF(y,w); IF APCMPR(APABS(z),AbsErr) <= 0 THEN RETURN(y) END; END; CLOUT("Maximal number of iterations reached."); BLINES(1); RETURN(y); (*9*) END Newton. zwei:=APFINT(2). PROCEDURE E(x); (*Expression function. An expression is evaluated at x. *) VAR y: ANY; BEGIN (*1*) y:=APEXP(x,2); y:=APDIFF(y,zwei); (*RETURN(y);*) (*9*) END E. PROCEDURE Ep(x); (*Expression function derivation. The derivation of an expression is evaluated at x. *) VAR y: ANY; BEGIN (*1*) y:=APPROD(x,zwei); (*RETURN(y);*) (*9*) END Ep. start:=APFINT(1). b:=Newton(E,Ep,start). BEGIN CLOUT("AbsErr = "); APWRIT(AbsErr); BLINES(0) END. BEGIN CLOUT("Result = "); APWRIT(b); BLINES(0) END. BEGIN CLOUT("W2 = "); APWRIT(APROOT(zwei,2)); BLINES(0) END.