Gram–Schmidt resolves each basis vector into projections onto earlier directions and a new perpendicular component. QR stores the normalized directions as columns of QQ and the projection coefficients in an upper triangular matrix RR.

Compute the projections

μij=⟨bi,bj∗⟩∥bj∗∥2,bi∗=bi−∑j<iμijbj∗.\mu_{ij}=\frac{\langle b_i,b_j^*\rangle}{\|b_j^*\|^2},\qquad b_i^*=b_i-\sum_{j<i}\mu_{ij}b_j^*.

For columns b1=(1,1)b_1=(1,1) and b2=(1,3)b_2=(1,3), the projection coefficient is 2. Subtracting 2(1,1)2(1,1) leaves b2∗=(−1,1)b_2^*=(-1,1). The two perpendicular vectors have squared lengths 2 and 2.

Here the projection coefficient is an integer, so the perpendicular vector lies in the lattice. For a fractional projection coefficient, subtracting that fraction of a basis vector can leave the lattice. For example, with columns (2,0),(1,1)(2,0),(1,1), the perpendicular vector (0,1)(0,1) is outside.

Read the matrices

Normalize the perpendicular vectors to get QQ. Entry Rji=⟨qj,bi⟩R_{ji}=\langle q_j,b_i\rangle has row index jj and column index ii. In particular Rii=∥bi∗∥R_{ii}=\|b_i^*\|.

B=QR=12(1−111)(22202).B=QR=\frac{1}{\sqrt{2}}\begin{pmatrix}1&-1\\1&1\end{pmatrix}\begin{pmatrix}\sqrt{2}&2\sqrt{2}\\0&\sqrt{2}\end{pmatrix}.

Multiply the factors to recover both original columns. The Gram–Schmidt length profile is (2,2)(\sqrt2,\sqrt2). Its product is 2, equal to ∣det⁡B∣|\det B|.

Volume and basis changes

For a full-column-rank rectangular basis, thin QR gives B⊤B=R⊤RB^\top B=R^\top R, so the covolume in the span is the product of the positive diagonal entries of RR. The profile can change under a unimodular basis change. Its product stays fixed.

For the shared rectangular and skew bases, QQ is the identity and the profile is (2,3)(2,3) in either case. The off-diagonal entry changes from 0 to 6. See Gauss reduction for the integer subtraction that removes it.

Further reading

MIT OpenCourseWare, Orthogonal Matrices and Gram–Schmidt.