Polynomial cannot have all roots real?

Assume that $P$ has degree $n$ and let $x_1,x_2,\dots,x _n$ be all its roots (repetitions are allowed). Then $P(x)=c\prod_{k=1}^n (x-x_k)$, and if $x$ is not a root of $P$ we have that $$\frac{P'(x)}{P(x)}=\sum_{k=1}^n \frac{1}{x-x_k}.$$ After taking the derivative we obtain $$\frac{P''(x)P(x)-(P'(x))^2}{(P(x))^2}=-\sum_{k=1}^n \frac{1}{(x-x_k)^2}.$$ Finally by letting $x=a$ (which is not a root) we get a contradiction: $$0=\frac{P''(a)P(a)-(P'(a))^2}{(P(a))^2}=-\sum_{k=1}^n \frac{1}{(a-x_k)^2}<0$$ where the right-hand side is negative because $a, x_1,x_2,\dots,x _n$ are all real.


Sketch of proof: Assume all roots of $P$ are real, and let $x_1\leq x_2\leq \ldots\leq x_n$ be the $n$ roots (with repetition if $P$ has repeated roots). What does Rolle's theorem say about the roots of $P'$? How many roots does $P'$ have (counted with multiplicity)? Can $P'$ have a repeated root which is not one of the $x_i$?


I guess $P$ is not constant, otherwise the statement is false: all the roots of the constant $a$ polynomial are real, as everything holds for the elements of the emptyset.

Translate the polynomial by $a$, i.e., $Q(x):= P(x-a)$. Then the conditions can be rephrased to $Q$ equivalently as follows: $Q(0)\neq 0$, $Q'(0)=Q''(0)=0$. In other words, $Q(x)= a_nx^n+ \cdots +a_3x^3 + a_2x^2+a_1x+a_0$, where $a_0\neq 0$ and $a_1=a_2=0$.

Write the Viete formulas for the roots $x_i$:

$\prod x_i= (-1)^na_0\neq 0, \prod x_i \cdot \sum 1/x_i=0$, and $\prod x_i \cdot \sum\limits_{i\neq j} 1/(x_ix_j)=0$.

Put $y_i=1/x_i$ (possible, as $0$ is not a root, as the constant term is nonzero), then after simplification, you obtain $\sum y_i= \sum\limits_{i\neq j} y_iy_j=0$, but then $\sum y_i^2= 0$. So if these are real numbers, then all the $y_i$ are zero, a contradiction.