Applications of complex numbers to solve non-complex problems

Recently I asked a question regarding the diophantine equation $x^2+y^2=z^n$ for $x, y, z, n \in \mathbb{N}$, which to my surprise was answered with the help complex numbers. I find it fascinating that for a question which only concerns integers, and whose answers can only be integers, such an elegant solution comes from the seemingly unrelated complex numbers – looking only at the question and solution one would never suspect that complex numbers were lurking behind the curtain!

Can anyone give some more examples where a problem which seems to deal entirely with real numbers can be solved using complex numbers behind the scenes? One other example which springs to mind for me is solving a homogeneous second order differential equation whose coefficients form a quadratic with complex roots, which in some cases gives real solutions for real coefficients but requires complex arithmetic to calculate.

(If anyone is interested, the original question I asked can be found here: $x^2+y^2=z^n$: Find solutions without Pythagoras!)

EDIT:

I just wanted to thank everyone for all the great answers! I’m working my way through all of them, although some are beyond me for now!

I suppose the most common one on this site is an application of the Residue Theorem. That is:

where $f$ is an analytic function with only finitely many isolated singularities $z_k$ inside a closed curve $\gamma$ in the complex plane.

While this theorem is clearly a result of Complex Analysis, it in fact has many uses in computing integrals along the real line. Indeed, by constructing $\gamma$ to be semicircular contours, we can immediately compute the real integral $\int_{-\infty}^\infty f(x) dx$ for functions $f(z)$ that are the complex extension of real-valued $f(x)$ (as long as $f(z)$ disappears as $|z|\rightarrow \infty$).

This typical contour $\gamma$ appears as:

where $j$ is an isolated singularity of $f(z)$ and we take $a\rightarrow \infty$.

Here is a straight-forward example. We attempt to compute the definite integral:

Defining $f(z):= \cfrac{1}{(1+z^2)^2} = \cfrac{1}{(z+i)^2(z-i)^2}$ where $z\in \mathbb{C}$, and the complex contour $\gamma_a$ to be the semicircle in the upper-half plane, we have by the Residue Theorem:

Now, noting that as $|z|\rightarrow \infty, |f(z)| \rightarrow 0$, so

and we have computed our real-valued integral of a real-valued function using Complex Analysis.