13 lines
333 B
Text
13 lines
333 B
Text
/* Finds the N-th root of the number A */
|
|
root: procedure (A, N) returns (float);
|
|
declare A float, N fixed binary;
|
|
declare (xi, xip1) float;
|
|
|
|
xi = 1; /* An initial guess */
|
|
do forever;
|
|
xip1 = ((n-1)*xi + A/xi**(n-1) ) / n;
|
|
if abs(xip1-xi) < 1e-5 then leave;
|
|
xi = xip1;
|
|
end;
|
|
return (xi);
|
|
end root;
|