>FUNCTION FindRoot
>LPARA tnSquare, tnPrecision
>lnTry = tnSquare
>lnIncrement = tnSquare/2
>lnSquare = tnSquare
>lnPrecision = IIF(!EMPTY(tnPrecision), tnPrecision, SET("DECIMAL"))
>DO WHILE ROUND(lnTRY^2, lnPrecision) <> lnSquare
> lntry = lnTry + lnIncrement
> ?lnTry, lnIncrement, ROUND(lnTRY^2, lnPrecision)
> IF (lnIncrement > 0 AND lnSquare < lnTry^2) OR (lnIncrement < 0 AND lnTry^2 < lnSquare)
> lnIncrement = lnIncrement /-2
> ENDIF
>ENDDO
>RETURN lnTry
>
>This was a very interesting excercise indeed. Only one of your solutions even used the same principles as I did. Mike and Christof circumvented the problem altogether, and Bruce- I have to admit I have no idea what your code is doing, though I am sure it is the correct mathematical way to handle the problem. Thanks for your inpput everybody...
So, how many iterations do you need to get, say, 15 digits of accuracy?
BTW, my code (really Isaac Newton's), uses a ratio of a function and its first derivative, which for simple roots, is remarkably simple and accurate. Usually a Taylor series is better for things like polynomial roots...
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.