Real square roots of operators with simple real spectrum (source code)

= Real square roots of operators with simple real spectrum
{title2=$B^2=A\Longrightarrow\lambda_i(A)\geq0$}

If a real <linear operator> $A$ on an $n$-dimensional <vector space> has $n$ distinct real <eigenvalues>, any real square root $B$ commutes with $A$ and preserves each one-dimensional <eigenspace>. There $B$ is multiplication by a real $b_i$, hence $\lambda_i=b_i^2\geq0$. Conversely, if all the eigenvalues are nonnegative, choosing $b_i=\sqrt{\lambda_i}$ on an <eigenbasis> supplies a real square root. Without simple spectrum the necessity fails: a real quarter-turn squares to $-I$.