Square roots by hand (and Newton's method)


In elementary school they teach us how to sum, subtract, multiply and divide; what they never teach us is how to compute square roots. There is a method (which is not trivial) to compute square roots by hand, but the majority of times a good approximation is all we need. It just so happens that there is a nice geometrical trick that allows one to find really good approximations to square roots. By the end of the post I will also hint at how that trick is related to a more general method to solve equations.

To explain the trick we will apply it directly. Let us try to find the square root of 7373. The first thing to do is find a good guess. The better the initial guess is, the better the successive approximations will be, but you don't need a really good first guess to produce really decent approximations! I know that 802=6400 and 902=8100. 7373 seems to be somewhere in between, so I will take 85 as my initial guess.
If we want, we can take as initial guess the integer that, when squared, is closer to 7373. As a matter of fact, 832=(80+3)2=6400+480+9=6889842=(80+4)2=6400+640+16=7056852=(80+5)2=6400+800+25=7225862=(80+6)2=6400+960+36=7396
therefore 86 is the integer whose square is closer to 7373. Nevertheless, let us start with 85.
We know 85 isn't the right answer. Actually, the right answer (the square root of 7373) will be 85+x, where x is the bit we are missing. Let us draw a square of side 85 inside a square of side 85+x:

We have (85+x)2=7373852+2×85x+x2=7373. The term 852 corresponds to the area of the blue square, the term 2×85x to the areas of the green rectangles and x2 to the area of the red square. If we put them all together, those areas sum up to 7373, the area of the big square formed by the smaller squares and rectangles.
Simplifying 852+2×85x+x2=7373 we get 170x+x2=148. Because 85 was a good first guess, the area of the red square is much smaller than that of the green rectangles, thus we can consider that between the two terms 170x and x2, the 170x contributes the most to the total of 148, hence 170x148x1481700.870588. If we take that value to be approximately x, then 7373=85+x85.870588 and actually 85.87058827373.757883, where the 0.757883 in excess come from the x2 we ignored: (85+x)2=852+170x+x2=7373+x2=7373.757883x2=0.757883.
We can repeat this whole train of thought to get an even better approximation! This time, the initial guess is 85.870588 and the actual square root is going to be 85.870588y, where y represents an adjustment to be made. If we repeat the maths: (85.870588y)2=85.87058822×85.870588y+y285.87058822×85.870588y=7373
This time we ignored the y2 which will still represent a small square with negligible area when compared to the 2×85.870588y. From this we get 85.8705882171.741176y=7373y0.0044284.
Taking this approximate value for y we get 7373=85.870588y85.8705880.0044284=85.8661596 and making use of a calculator we see that 7373=85.8661749..., which means we already have 4 decimal places correct!

The small window below contains a small Python script that applies this method successively until the error is smaller than 0.0000000001=1010. t holds the number whose square root we want and a holds the value of our first guess. The script will present the list of successive guesses, along with their squares, and in the end shows our final approximation side by side with the actual square root, so we can compare the two.



All that is left for this post is to relate this method to approximate square roots with Newton's method! Suppose f(x) is a well-behaved function and that we want to find a root of this function, i.e. a point z such that f(z)=0. Suppose as well that a is a good approximation of z, and thus a+ϵ=z. We have 0=f(z)=f(a+ϵ)=f(a)+ϵf(a)+ϵ22f(ξ)
because of the Taylor expansion of f. Because a is a good approximation, ϵ is very small and thus the term with ϵ2 is very small; if we ignore it we get 0f(a)+ϵf(a)ϵf(a)f(a)
Having found an approximation for ϵ we can refine the approximation a with a new approximation for z: b=a+ϵ=af(a)f(a)
And we can repeat this process. If a1 is the first approximation I can write a1=af(a)f(a)
and if we repeat the maths above, remembering that z=a1+ϵ, I can let a2 be the second approximation with a2=a1f(a1)f(a1)
and so on and so forth, giving a succession an+1=anf(an)f(an)
This iterative method, called Newton's method, doesn't work all the time for any f; certain conditions must be met (for example, it seems reasonable to assume that f must have the first two derivatives, given that we derived the method with a Taylor series of order 2). Even so, for c>0, we can define f(x)=x2c (thus f(x)=2x) and in this case, the root we are looking for is f(z)=0z=±c. This means we can apply Newton's method to the function f(x)=x27373 to find the square root of 7373. In general, for c>0 and a decent first guess, this method will always work: just consider the geometrical interpretation given above.

We let the more meticulous reader verify that applying Newton's method to the function f(x)=x27373 with initial guess a=85 corresponds to the maths we did above.

Please leave your thoughts in the comment section below!

  - RGS

Square roots by hand (and Newton's method) Square roots by hand (and Newton's method) Reviewed by Unknown on April 28, 2018 Rating: 5

No comments:

Powered by Blogger.