# Square root

Do you remember how to solve a square root using pen and paper?

If you are a literature major, you might need reminding what a square root is. When you multiply a number by itself, you are calculating its square. The inverse operation, that is, having a certain number, calculating the number that, when you multiply it by itself, gives you the number you have, is the square root. So, the square of 5 is 25, since 5x5=25; also, the square root of 16 is 4 since 16=4x4.

Of course, calculating the square root of some numbers, like 4, 9, 16 or 25 is very easy. However, it is not so easy to calculate the square root of other numbers, such as 529. To do that, you would usually take your pen and paper and start drawing figures, following some steps similar to those depicted in the following figure: A written summary of the method would be very long, so I'll just assume you already know how to solve square roots on paper, and go ahead with the post.

The thing is... do you know how that method works? Do you know why we have to multiply the partial results by two, and then append the digit, and multiply the result by the same digit, and then substract the result...? And have you got any idea of how the end result comes together in the end?

I thought you didn't :) Take care, the following explanation has lots of numbers and letters representing numbers, which is worse. This story is in the "nerd stuff" section for a reason! Also, I haven't done serious maths in a long time, so please excuse the inaccuracies :)

First, let's assume we want to calculate the square root of a number with three or four digits. We make this assumption so that the explanation will be short, but as we'll see later, it can be extended quickly to any number of digits.

The number we want to calculate the square root of can be represented as x2, which means that there's some number "x", which, when squared, is our number. That number "x" is the square root we want to calculate.

We can write that x2=c0+100c1. If c0 and c1 are natural numbers, this means that we are dividing our number into two groups of 1 or 2 digits. For example, if our number is 529, then c1=5 and c0=29. If it is 3971, then c1=39 and c0=71.

This is analogous to the first step in the pen and paper solution, of dividing the number in groups of 2 digits starting from the right. Our previous example, 529, would be divided in 5 and 29.

As you know, any number can be represented as the sum of two numbers. For example, you could represent 7 as 2+5, or as 4+3, or as 1+6. So, as the square root of any number is also a number, it is also representable as the sum of two numbers. We write it like this: x=a+b. If you remember your algebra, you know that x2 = (a+b)2 = a2+b2+2ab.

Now we have that x2 = c0+100c1 = a2+b2+2ab, so we can try to calculate "a" and "b" from c0 and c1.

We can start by finding the highest natural number "y" such that y^2=c1, which can be written as y=⌊√c1⌋, which means that y is the highest natural number which is less than or equal to the square root of c1. Then we would establish that 100y^2=a^2, which means that a = 10y = 10⌊√c1⌋.

Using the square root to calculate a square root may look a bit... circular, but take into account that c1 only has 1 or 2 digits, so its square root only has 1 digit, which means that it is a number from 0 to 9, so it is extremely easy to calculate!

This step is analogous to finding the highest number from 0 to 9 whose square is less than or equal to the leftmost digit group. In our 529 example, we would find y=2, as 22 = 4 ≤ 5, which gives us a = 20.

So, now that we have the value of "a", we can substract a2 from x2, giving us x2-a2 = a2+b2+2ab-a2 = b2+2ab.

In our example, x2-a2 is 529-400=129. In the pen and paper solution, we substracted 4 (22) from 5, giving us 1, and then we pulled the next digit group, 29, down, giving us 129. The equivalence is obvious.

Continuing the previous expression, x2-a2 = b2+2ab = (2a+b)b = (2·10y+b)b. Now we have to try to find the highest natural number "b" from 0 to 9 such that (2·10y+b)b ≤ x2-a2.

This is equivalent to, in our solution, getting the partial result (2), multiplying it by 2 (getting 4) and then finding a digit "b" such that 4b·b is less than or equal to 129. In our example, that "b" is 3, as 43·3=129.

Once you have found your "a" and "b" you can use the previous expression, x=a+b, to figure x out. In our example, a=20 and b=3, so x=23.

This method only gives you the "integer floor" of the square root; that is, the highest positive integer number which is less than or equal to the positive square root of the number.

You can also use the method to solve cases for more than 4 digits by solving the integer floor of the square root for all but the two rightmost digits first, using the result as the value for "y", calculating "a" from it and then obtaining the value of "b".

For example, to solve the square root of 394002 you would first calculate the floor of the square root of 3940, find out it is 62, so y=62 and a=620, and then calculate b from 394002-6202 = 9602 = (2·10·62+b)b = (1240+b)b, therefore b lies between 7 and 8, so x=a+b is between 627 and 628 and the integer floor of the square root of 394002 is 627.

And, you know what? If you take a calculator and press 394002 and the square root button, you will get 627 followed by many more decimal digits. So the method works! And no wonder, as that's what we do without noticing every time we solve a square root with pen and paper.