2009年1月22日 星期四

A simple method to approximate square root without calculator

I thought of this when I am in Secondary School which I love to compete with calculator for speed and accuracy. I encounter a problem when to calculate square root of 5, there is no built-in mechanism for my brain to square root. So how?
Then I remember that
(X+1/X)^2=2+X^2+1/X^2
or (X+1/2X)^2=1+X^2+1/X^2
Since 5=2^2+1, therefore we first approximate square root of 5 by 2, to add one in the square of the result, we need 2+1/4.
However, although the square of 2+1/4 is closer to 5 than 2, but there is an excess of square of 1/4 or 1/16 from the real square root. That is an error of 6.25%.
To eliminate this excess value, we remember that (X-1/X)^2=X^2-2+1/X^2
or (X-1/2X)^2=X^2-1+1/X^2
So we can try 2+1/4-(1/16/(2+1/4)/2), which would give us the excess of (1/16/(2+1/4)/2) squared, i.e. an excess of 1/72 squared or 1/5104. We are thus now making error of only 0.02% from the true value of square root of 5. That is good enough for most purpose.

The general methodology is like this: Suppose we need to find the square root of X^2+q.
Then we first approximate it by nearest square root, i.e. X, and remember we need to make the difference of q.
Thus the next step is adding q/2X to X for suppling this difference, giving an excess of q^2/4X^2.
Yet another step is treating the answer X+q/2X as X in the first step and difference as the q then we try to eliminate the difference by X-q/2X.
We could repeat the process however many times until the answer reach the accuracy we needed.

沒有留言: