Roots of a complex polynomial
Solution 1:
The idea is that when you go along the real axis, $f(x)$ makes $n/2$ complete loops around $0$, so has to cross the horizontal axis $n$ times (and the same for the vertical axis).
To make this precise, integrate $f'(z)/f(z)$ along the loop $\gamma_R(t) = Re^{it}$ for $t \in [0; \pi]$, and $\gamma_R(t) = R\cos(t)$ for $t \in [\pi ; 2 \pi]$. For $R$ large enough, the loop contains all roots of $P$, so the residue theorem tells you that the integral is $2in \pi$. Meanwhile, as $R$ goes to infinity, the integral on the semi-circle part converges to $ni \pi$
Thus, $\int_\mathbb{R} f'(x)/f(x) dx = ni \pi$. This means that the argument of $f(x)$ moves by $n\pi$ while $x$ moves along the real axis.
Since $\lim_{x \to \infty} \textrm{Arg}(f(x)) = \textrm{Arg}(a_n)$, the case when $a_n$ is neither real nor purely imaginary is easy : $P(x)$ has to cross each axis at least $n$ times in order for the argument to move by $n \pi$. This means that $P$ and $Q$ have at least $n$ roots in $\mathbb{R}$. Since they are of degree $n$, they both have their $n$ roots in $\mathbb{R}$.
In the case where $a_n$ is real or purely imaginery, it means that one of the axis is crossed only $n-1$ times, but since the corresponding polynom is of degree $n-1$, it is again the case that both polynoms have all their roots in $\mathbb{R}$.