Givens rotation (source code)

= Givens rotation
{c}
{title2=$G_{ij}(c,s)$}
{wiki}

A <Givens rotation> eliminates one component of a <vector> by rotating just two coordinates, preserving its <Euclidean norm>. For example,
$$
\begin{pmatrix}3/5&4/5\\-4/5&3/5\end{pmatrix}
\begin{pmatrix}3\\4\end{pmatrix}
=\begin{pmatrix}5\\0\end{pmatrix}.
$$
The length remains five: elimination moves the component into the retained coordinate rather than discarding it. Applied to a <matrix>, the same operation mixes two rows; <QR decomposition by Givens rotations> uses these local operations to build an <upper triangular matrix>.

\Image[/givens-rotation-geometry.png]
{title=A <Givens rotation> takes $(3,4)^T$ clockwise to $(5,0)^T$ while preserving the <Euclidean norm>}

For indices $i<j$, the <matrix> $G_{ij}(c,s)$ is the <identity matrix> except for its block on coordinates $i,j$:
$$
G\big|_{i,j}=\begin{pmatrix}c&s\\-s&c\end{pmatrix},\qquad c^2+s^2=1.
$$
This article uses left <matrix multiplication> on column <vectors>. If $c=\cos\theta$ and $s=\sin\theta$, the block is a <rotation matrix> through angle $-\theta$: the minus sign belongs in the lower left. Its <transpose> reverses the <rotation>. Direct multiplication gives $G^TG=I$ and <determinant> one, so it is an <orthogonal matrix>; consequently $\|Gx\|_2^2=x^TG^TGx=\|x\|_2^2$. Only two coordinates change, but this <Euclidean norm> identity holds for the entire <vector>.