# A square-root approximation method that would halt on $\sqrt{378}$

Back in the early $'90$s, I used to program in a (now obsolete) scripting language called LOGO.

Now, one peculiar glitch that I encountered at the time, was the interpreter halting on $\sqrt{378}$.

I clearly recall not being able to reproduce it with any value of than that specific one.

Ctrl/Break would terminate the operation, so that rules out HW-architecture issues.

My guess is that the approximation method has reached some sort of infinite loop.

So I've been wondering if it's possible to trace back on this method.

I am almost certain that I will not get an answer here, but I decided to give it a shot anyway:

• What square-root approximation methods are typically used?
• Is there a possible explanation for failing to approximate specific values?

Thanks

• Look at stackoverflow.com/q/12304577/1413643 perhaps? Commented Jul 4, 2016 at 15:44
• Possible explanation for "halting": An infinite loop in an iterative algorithm such as a Newton-Raphson iteration, designed to stop when two successive iterations produce the same value. An infinite loop occurs when the iteration instead results in a permanent oscillation between two neighboring floating-point numbers. Commented Jul 5, 2016 at 17:34
• @njuffa: If I remember correctly, then for Newton-Raphson (which I have actually implemented in the past), you only need to go below some absolute threshold before halting. Are you suggesting that the method was alternating between two values, one negative and one positive, neither of which below that threshold (when taking the corresponding absolute value)? That would actually make a lot of sense. Thank you for responding. Commented Jul 5, 2016 at 21:19
• @barakmanos When computed with finite-precision arithmetic, iterative methods may not converge to one single floating-point number, but may, after initial convergence, oscillate between two neighboring floating-point numbers which are both close to the mathematical result. This can be worked around by placing a hard limit on the number of iterations, or by comparing for $\epsilon$ difference between consecutive results instead of $0$. Commented Jul 5, 2016 at 22:53

Welcome to Berkeley Logo version 5.5