Unnecessary use of complex numbers when factorizing a sum of squares? Let's assume we have a 2d vector $\vec{x}=\begin{pmatrix} a \\ b \end{pmatrix}$. The square of it's length is easily computed as
$
|x|^2 = a^2 + b^2
$
Also note that always $|x|^2 \geq 0$. So to compute $|x|$ we can simply factorize by taking the square root
$
|x|^2 = a^2 + b^2 = \sqrt{a^2 + b^2}\sqrt{a^2 + b^2}
$
However sometimes I see people factorizing this sum of squares using complex numbers like
$
a^2 + b^2 = (a + i b)(a - i b)
$
But what is the point of introducing complex numbers here? The sum of squares is by definition a positive number. So taking the square root is always a valid operation. Isn't this a completely unnecessary use of complex numbers? Or am I overlooking something here? Is there some advantage in using the factorization with complex numbers?
 A: Sometimes it is very useful to factor sums of squares into complex numbers. For example, if you are trying to solve $\displaystyle \int \dfrac {a(x)}{x^2+1} dx$, it may be easier to rewrite it as $\displaystyle \int \dfrac {a(x)}{(x+i)(x-i)} dx$, use partial fraction decomposition, and solve it that way.
Also note that your factorization $a^2 + b^2 = \sqrt{a^2 + b^2}\sqrt{a^2 + b^2}$ is not a factorization into polynomials. Sometimes it matters what you factorize into; for example, prime numbers are important because they cannot be factored into integers. But of course they could be factored into real numbers, $5 = 2 \cdot 2.5$
A: The famous theorem that characterizes which integers are sums of two squares is best solved in the context of complex numbers with integer real and imaginary parts.
The Brahmagupta–Fibonacci identity plays a role here. It explains why products of number that are sums of two squares are themselves sums of two squares. It follows from the multiplicativity property for absolute values of complex numbers.
Complex numbers are not needed here but their introduction sheds important light on the problem.
