# An algorithm to obtain square of any number.

I have discovered a new way to obtain square of any number. I think its a new algorithm to find square of a number than just multiplying it with itself; if its not new then let me know. Algorithm is as follows:

1. Divide the number in two parts with one part containing only the number at unit's place say part 'A', and other part say 'B', containing the remaining number.
2. Now square the number at unit's place. The square will be one of these; {0,1,4,9,16,25,36,49,64,81}. The unit's place digit in this square is the unit's place digit in actual final answer.Write it in the answer. If the square of digit at unit's place is a two digit no like from 16 to 81 in above set; write only the digit at unit's place from this square in the final answer and carry the remaining digit.
3. Multiply the actual number to be squared by part 'B'(the remaining part than the number at unit's place as described in step 1 ).
4. Multiply the parts 'A' and 'B'.
5. Add results of step 3 with results of step 4.
6. Add the carried digit from step 2 to the sum in prior step, that is step 5.
7. Now write this sum before the number we wrote at unit's place of final answer in step 2.
8. This number we now obtain from step 7, is the square of our number.

Example:

Lets find square of 127 by above algorithm;
1. A = 7 and B = 12 here...
2. A^2 = 49 thus final answer will have 9 at units place and 4 is carried to add later.
3. Given number multiplied by 'B' => 127*12 = 1524
4. A*B => 12*7 = 84
5. 1524+84 = 1608 ..... ( step 3 + step 4 )
6. 1608+4 =1612 .... (4 is carried as stated in step 2)
7. Now, 16129 is the answer... (From step 2 and 6)

• You have some number $N = A+10B$. Then $N^2 = N\left( A + 10B\right) = NB + \left( A+10B\right)A = 10NB + 10AB + A^2$. You're performing this third calculation. You seem to have a firm grasp of arithmetic, at least. ;) – COTO Sep 7 '14 at 14:07

Ok so let's try to square $10b+a$ and we let $a^2=10c+d$ where it is possible that $c=0$.

Step $1$ tells us to identify $a$ and $b$

For step $2$ we have $a^2=10c+d$ and we write $d$ in the final place and remember $c$

Step $3$ gives us $b\cdot (10b+a) =10b^2+ab$

Step $4$ gives us $ab$

Step $5$ gives us $10b^2+2ab$

Step $6$ gives us $10b^2+2ab+c$

In step $7$ "putting the number before" is the same as multiplying by $10$ and adding so we get $10\cdot(10b^2+2ab+c)+d$

To check at step 8 we have $100b^2+20ab+10c+d=100b^2+20ab+b^2=(10b+a)^2$

So your method works. I couldn't say whether it is new, but it requires two multiplications at steps $3$ and $4$, plus the squaring step.

There is an interestingly similar method for speeding up the multiplication of two large numbers. Let $M$ be a large power of $10$, say, so that the numbers $a, b, c, d$ are of comparable size.

Multiplying $(aM+b)(cM+d)=acM^2+(ad+bc)M+bd$ looks as though it requires the computation of four products $ac, ad, bc, bd$, but if we compute $ac, bd$ and $(a+b)(c+d)$ (three products) we find that $ad+bc=(a+b)(c+d)-ac-bd$. This turns out to be computationally more efficient.

The key thing about a method like yours is not so much whether it works (all sorts of methods work) or whether it is new, but whether it is a practical improvement on existing methods.

$$\Large (10X+Y)^2=100X^2+20XY+Y^2$$

• Although the OP used $A$ and $B$ in the other way ($10B+A$). – Clement C. Sep 7 '14 at 14:01
• @ClementC. see the edit? – RE60K Sep 7 '14 at 14:03
• (yes... sorry for nitpicking.) – Clement C. Sep 7 '14 at 14:22