Solution (source code)

= Solution

A <Givens rotation> acts as the <identity matrix> outside two selected coordinates $i,j$, and has the following block on those coordinates:
$$
\boxed{G_{\{i,j\},\{i,j\}}=\begin{pmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{pmatrix}.}
$$
The convention with the opposite signs of the sines is equivalent after replacing $\theta$ by $-\theta$. A <Householder reflection> with nonzero normal <vector> $w\in\mathbb R^n$ is
$$
\boxed{H(w)=I-\frac{2ww^T}{w^Tw}.}
$$
It reverses the component parallel to $w$ and fixes the perpendicular <hyperplane>. Both are <orthogonal matrices>, so their transposes are their inverses and they preserve the <Euclidean norm>.