Orthogonal transformation in a nonorthonormal basis (source code)

= Orthogonal transformation in a nonorthonormal basis
{title2=$A^TGA=G$}

Let $b_1,\ldots,b_n$ be an arbitrary <basis> of a real <inner product space>, with <Gram matrix> $G=(\langle b_i,b_j\rangle)$. If a <linear map> $T$ has <matrix> $A$ in this <basis>, then
$$
\langle Tu,Tv\rangle=[u]^TA^TGA[v],\qquad
\langle u,v\rangle=[u]^TG[v].
$$
Consequently $T$ is an <orthogonal transformation> exactly when $A^TGA=G$. The simpler <orthogonal matrix> condition $A^TA=I$ applies directly when the chosen <basis> is an <orthonormal basis>, so that $G=I$.

For example, take a two-dimensional <vector space> with <weighted Euclidean inner product> having $G=\operatorname{diag}(1,4)$. Then
$$
A=\begin{pmatrix}0&2\\-1/2&0\end{pmatrix}
$$
satisfies $A^TGA=G$, but $A^TA=\operatorname{diag}(1/4,4)\ne I$. Thus it represents an <orthogonal transformation> even though it is not an <orthogonal matrix>.