Exact-shift diagonalization of a two-state swap matrix (source code)

= Exact-shift diagonalization of a two-state swap matrix
{c}
{title2=$\mu=\pm1$}

For $A=\left(\begin{smallmatrix}0&1\\1&0\end{smallmatrix}\right)$, one shifted <QR algorithm> step with real <QR shift> $\mu$ gives, with a consistent choice of factor signs,
$$
A_1=\frac1{1+\mu^2}\begin{pmatrix}-2\mu&\mu^2-1\\\mu^2-1&2\mu\end{pmatrix}.
$$
To verify this, factor $A-\mu I=QR$ with $Q=(1+\mu^2)^{-1/2}\left(\begin{smallmatrix}-\mu&-1\\1&-\mu\end{smallmatrix}\right)$. Its columns are <orthonormal>, and $R=Q^T(A-\mu I)$ is upper triangular. Then $A_1=Q^TAQ$. Thus $A_1$ is diagonal exactly when $\mu=\pm1$, the two <eigenvalues>. The bottom-right-entry shift is zero and leaves the <matrix> unchanged under the positive-diagonal factor convention. This illustrates why a poorly chosen <QR shift> can stall even a two-by-two symmetric <eigenvalue> computation.