On Saturday 23 Feb 2008 02:05, Don Higgins wrote:
> 4. I've posted 2 additional solutions for problem 12 calculation of
> standard deviation. Now there are 3 solutions; one using BFP, one using
> HFP, and one using just DFP instructions. The DFP solution proved to be
> more challenging than expected as the latest POP (at least for today) is
> missing the opcode SQXTR corresponding to the existing SQXBR and SQXR used
> in the other solutions. As a result I have coded a substitute SQXTR macro
> which calls standalone SQXTR CSECT which uses DFP instructions to perform
> the square root function using Newton Raphson method. For the current
> problem it converged to 34 digit solution in 7 iterations. Suggestions for
> improving the first guess will help. Note all 3 solutions produce the same
> result to 33+ decimal places.
This web page:
http://www.mactech.com/articles/mactech/Vol.14/14.01/FastSquareRootCalc/
describes how to use a table to obtain a more accurate first approximation.
Given that the first approximation has a known maximum error, it should be
possible to compute the maximum number of iterations required to
guarantee convergance. This saves an iteration, since the final iteration
is there just to prove convergance (the result does not improve on the final
iteration). Given that the number of iterations is fixed (and small!),
you can also fully unroll the loop.
--
Martin
martin@... http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/