Multiplying two binary numbers takes n^2 time, yet squaring a number can be done more efficiently somehow. (with n being the number of bits) How could that be?
Or is i
Suppose you want to expand out the multiplication (a+b)×(c+d)
. It splits up into four individual multiplications: a×c + a×d + b×c + b×d
.
But if you want to expand out (a+b)²
, then it only needs three multiplications (and a doubling): a² + 2ab + b²
.
(Note also that two of the multiplications are themselves squares.)
Hopefully this just begins to give an insight into some of the speedups that are possible when performing a square over a regular multiplication.