From Rational Inputs to Orthonormal Vectors
Gram–Schmidt starts with a linearly independent list and replaces it with an orthonormal list that spans the same subspace. In \(\mathbb{R}^4\), each input and each residual has four coordinates, but the calculation follows the same principle at every step: remove the components in directions already constructed, then normalize what remains. Rational input coordinates do not guarantee rational normalized vectors. Norms can introduce square roots, so keeping exact fractions and radicals throughout is essential.
Throughout this tutorial the scalar field is \(\mathbb{R}\), and the inner product is the dot product \(\mathbf{x}\cdot\mathbf{y}=\mathbf{x}^{\top}\mathbf{y}\). The norm is \(\|\mathbf{x}\|=\sqrt{\mathbf{x}\cdot\mathbf{x}}\). Vectors in \(\mathbb{R}^4\) are columns. A list is orthogonal if distinct vectors have dot product zero; it is orthonormal if it is orthogonal and every vector has norm \(1\).
Each coefficient \(\mathbf{x}_k\cdot\mathbf{e}_j\) measures the component of the current input in the direction of a previously constructed unit vector. The earlier material on coefficients along an orthonormal list gives this coefficient rule. The calculation below also shows directly why the chosen coefficients remove those components.
Proof. To make \(\mathbf{x}-\sum_{i=1}^{k-1}a_i\mathbf{e}_i\) perpendicular to \(\mathbf{e}_j\), its dot product with \(\mathbf{e}_j\) must be zero. Orthonormality gives $$ \left(\mathbf{x}-\sum_{i=1}^{k-1}a_i\mathbf{e}_i\right)\cdot\mathbf{e}_j =\mathbf{x}\cdot\mathbf{e}_j-\sum_{i=1}^{k-1}a_i(\mathbf{e}_i\cdot\mathbf{e}_j) =\mathbf{x}\cdot\mathbf{e}_j-a_j. $$ Thus perpendicularity requires \(a_j=\mathbf{x}\cdot\mathbf{e}_j\). This choice works for every \(j\), and each coefficient is forced by its equation, proving uniqueness. \(\square\)
This proposition justifies the subtraction at each stage: it removes precisely the components along the earlier unit vectors. If the resulting residual is nonzero, dividing by its norm makes it a unit vector without changing its direction. If it is zero, there is no direction left to normalize.
A Four-Vector Calculation in \(\mathbb{R}^4\)
Worked Example: Four Rational Inputs
Apply Gram–Schmidt to the following list, keeping all quantities exact: $$ \mathbf{x}_1=\begin{bmatrix}1\\1\\0\\0\end{bmatrix},\quad \mathbf{x}_2=\begin{bmatrix}2\\0\\2\\0\end{bmatrix},\quad \mathbf{x}_3=\begin{bmatrix}4\\-2\\3\\0\end{bmatrix},\quad \mathbf{x}_4=\begin{bmatrix}1\\1\\-3\\1\end{bmatrix}. $$
For the first vector, the residual is \(\mathbf{u}_1=\mathbf{x}_1\). Its squared norm is \(1^2+1^2=2\), so \(\|\mathbf{u}_1\|=\sqrt{2}\) and $$ \mathbf{e}_1=\frac{1}{\sqrt{2}}\begin{bmatrix}1\\1\\0\\0\end{bmatrix}. $$
For the second vector, its coefficient along \(\mathbf{e}_1\) is \(\mathbf{x}_2\cdot\mathbf{e}_1=2/\sqrt{2}=\sqrt{2}\). Therefore $$ \mathbf{u}_2=\mathbf{x}_2-\sqrt{2}\mathbf{e}_1 =\begin{bmatrix}2\\0\\2\\0\end{bmatrix} -\begin{bmatrix}1\\1\\0\\0\end{bmatrix} =\begin{bmatrix}1\\-1\\2\\0\end{bmatrix}. $$ Its squared norm is \(1+1+4=6\), hence $$ \mathbf{e}_2=\frac{1}{\sqrt{6}}\begin{bmatrix}1\\-1\\2\\0\end{bmatrix}. $$
For \(\mathbf{x}_3\), the two coefficients are $$ \mathbf{x}_3\cdot\mathbf{e}_1=\frac{4-2}{\sqrt{2}}=\sqrt{2}, \qquad \mathbf{x}_3\cdot\mathbf{e}_2=\frac{4+2+6}{\sqrt{6}}=2\sqrt{6}. $$ The corresponding components are \(\sqrt{2}\mathbf{e}_1=(1,1,0,0)^{\top}\) and \(2\sqrt{6}\mathbf{e}_2=(2,-2,4,0)^{\top}\). Subtracting both gives $$ \mathbf{u}_3= \begin{bmatrix}4\\-2\\3\\0\end{bmatrix} -\begin{bmatrix}1\\1\\0\\0\end{bmatrix} -\begin{bmatrix}2\\-2\\4\\0\end{bmatrix} =\begin{bmatrix}1\\-1\\-1\\0\end{bmatrix}. $$ Its squared norm is \(1+1+1=3\), so $$ \mathbf{e}_3=\frac{1}{\sqrt{3}}\begin{bmatrix}1\\-1\\-1\\0\end{bmatrix}. $$
For the last vector, calculate all three coefficients before subtracting: $$ \mathbf{x}_4\cdot\mathbf{e}_1=\frac{1+1}{\sqrt{2}}=\sqrt{2},\quad \mathbf{x}_4\cdot\mathbf{e}_2=\frac{1-1-6}{\sqrt{6}}=-\sqrt{6},\quad \mathbf{x}_4\cdot\mathbf{e}_3=\frac{1-1+3}{\sqrt{3}}=\sqrt{3}. $$ Their components are respectively \((1,1,0,0)^{\top}\), \((-1,1,-2,0)^{\top}\), and \((1,-1,-1,0)^{\top}\). Thus $$ \mathbf{u}_4= \begin{bmatrix}1\\1\\-3\\1\end{bmatrix} -\begin{bmatrix}1\\1\\0\\0\end{bmatrix} -\begin{bmatrix}-1\\1\\-2\\0\end{bmatrix} -\begin{bmatrix}1\\-1\\-1\\0\end{bmatrix} =\begin{bmatrix}0\\0\\0\\1\end{bmatrix}. $$ Its norm is \(1\), so \(\mathbf{e}_4=(0,0,0,1)^{\top}\).
Check. The residuals are mutually perpendicular: their pairwise dot products are \(\mathbf{u}_1\cdot\mathbf{u}_2=1-1=0\), \(\mathbf{u}_1\cdot\mathbf{u}_3=1-1=0\), \(\mathbf{u}_2\cdot\mathbf{u}_3=1+1-2=0\), and each of \(\mathbf{u}_1,\mathbf{u}_2,\mathbf{u}_3\) has fourth coordinate zero, so it is perpendicular to \(\mathbf{u}_4\). Dividing by nonzero norms preserves these zero dot products, and the displayed norms show that every \(\mathbf{e}_i\) has norm \(1\). Reconstruction also checks each subtraction: \(\mathbf{x}_1=\mathbf{u}_1\), \(\mathbf{x}_2=\mathbf{u}_1+\mathbf{u}_2\), \(\mathbf{x}_3=\mathbf{u}_1+2\mathbf{u}_2+\mathbf{u}_3\), and \(\mathbf{x}_4=\mathbf{u}_1-\mathbf{u}_2+\mathbf{u}_3+\mathbf{u}_4\).
The input list is independent. Indeed, the four residual directions are nonzero and mutually orthogonal, hence independent by the earlier result on orthogonal nonzero vectors. The displayed reconstruction relations express the inputs from the residuals by a triangular system with diagonal coefficients \(1\); successively comparing the \(\mathbf{u}_4,\mathbf{u}_3,\mathbf{u}_2,\mathbf{u}_1\) coefficients shows that a zero linear combination of the inputs must have all coefficients zero.
Two and Three Inputs: The Same Exact Steps
Worked Example: A Two-Vector List with Fractions
Apply Gram–Schmidt to \(\mathbf{x}_1=(1,1,1,1)^{\top}\) and \(\mathbf{x}_2=(1,0,0,0)^{\top}\). The first norm is \(\sqrt{4}=2\), so $$ \mathbf{e}_1=\frac12\begin{bmatrix}1\\1\\1\\1\end{bmatrix}. $$ The coefficient for the second input is \(\mathbf{x}_2\cdot\mathbf{e}_1=\tfrac12\). Hence $$ \mathbf{u}_2= \begin{bmatrix}1\\0\\0\\0\end{bmatrix} -\frac12\mathbf{e}_1 = \begin{bmatrix}1\\0\\0\\0\end{bmatrix} -\begin{bmatrix}1/4\\1/4\\1/4\\1/4\end{bmatrix} = \begin{bmatrix}3/4\\-1/4\\-1/4\\-1/4\end{bmatrix}. $$ The squared norm is \((9+1+1+1)/16=3/4\), so \(\|\mathbf{u}_2\|=\sqrt{3}/2\), and $$ \mathbf{e}_2=\frac{1}{2\sqrt{3}}\begin{bmatrix}3\\-1\\-1\\-1\end{bmatrix}. $$
Check. The dot product of the two unit vectors is \((3-1-1-1)/(4\sqrt{3})=0\), and \(\|\mathbf{e}_2\|^2=(9+1+1+1)/12=1\). Also \(\tfrac12\mathbf{e}_1+\tfrac{\sqrt{3}}2\mathbf{e}_2=(1,0,0,0)^{\top}=\mathbf{x}_2\), confirming the decomposition. The inputs are independent: in \(c_1\mathbf{x}_1+c_2\mathbf{x}_2=\mathbf{0}\), the second coordinate forces \(c_1=0\), and then the first forces \(c_2=0\).
Worked Example: Three Inputs with a Simple Final Residual
Take \(\mathbf{y}_1=(1,0,0,0)^{\top}\), \(\mathbf{y}_2=(1,1,0,0)^{\top}\), and \(\mathbf{y}_3=(1,1,1,1)^{\top}\). The first vector is already a unit vector, so \(\mathbf{e}_1=(1,0,0,0)^{\top}\). The second coefficient is \(\mathbf{y}_2\cdot\mathbf{e}_1=1\), giving $$ \mathbf{u}_2=\mathbf{y}_2-\mathbf{e}_1 =\begin{bmatrix}0\\1\\0\\0\end{bmatrix}, \qquad \mathbf{e}_2=\begin{bmatrix}0\\1\\0\\0\end{bmatrix}. $$ For \(\mathbf{y}_3\), the coefficients along \(\mathbf{e}_1,\mathbf{e}_2\) are both \(1\). Therefore $$ \mathbf{u}_3=\mathbf{y}_3-\mathbf{e}_1-\mathbf{e}_2 =\begin{bmatrix}0\\0\\1\\1\end{bmatrix}, \qquad \|\mathbf{u}_3\|=\sqrt{2}, \qquad \mathbf{e}_3=\frac{1}{\sqrt{2}}\begin{bmatrix}0\\0\\1\\1\end{bmatrix}. $$
Check. The first two vectors are coordinate directions, so each is perpendicular to \(\mathbf{u}_3\) and to the other. The norm of \(\mathbf{e}_3\) is \(\sqrt{(1+1)/2}=1\). Finally, \(\mathbf{y}_3=\mathbf{e}_1+\mathbf{e}_2+\sqrt{2}\mathbf{e}_3\), while \(\mathbf{y}_2=\mathbf{e}_1+\mathbf{e}_2\) and \(\mathbf{y}_1=\mathbf{e}_1\); these equations verify the construction.
Keeping the Arithmetic Reliable
For exact calculations, keep each residual as an unnormalized vector until its coordinates have been checked. Its norm is computed from the sum of the squares of those coordinates. Only then divide by that norm. This order makes it easier to distinguish a coefficient error in the subtraction from an arithmetic error in the square root.
Common mistake: confusing a squared norm with a norm. In the four-vector example, \(\mathbf{u}_3=(1,-1,-1,0)^{\top}\). A wrong normalization is \(\mathbf{u}_3/3\), because \(3\) is the sum of its squared coordinates. But \(\|\mathbf{u}_3\|=\sqrt{3}\), not \(3\), and the incorrect vector has squared norm \(3/9=1/3\), so it is not a unit vector. The correct normalization is \(\mathbf{u}_3/\sqrt{3}\), whose squared norm is \(3/3=1\).
There are two checks worth making after every step. First, test the new residual against each earlier unit vector by taking dot products; every result should be zero. Second, check that its normalized version has squared norm \(1\). At the end, reconstruct each original input from its residual components. A mistaken sign or omitted component will often be detected by one of these checks.
A zero residual has a precise meaning: the current input was entirely accounted for by the earlier directions, so it contributes no new orthogonal direction. The normalization formula then cannot be used because division by \(\|\mathbf{0}\|=0\) is undefined. For an independent input list this does not occur; for a list that is not independent, a zero residual signals that the list has supplied a redundant vector.
Check Your Understanding
For each calculation, keep fractions and radicals exact, then check orthogonality and norms.
- Starting with \(\mathbf{a}_1=(1,1,0,0)^{\top}\) and \(\mathbf{a}_2=(1,0,1,0)^{\top}\), find the second Gram–Schmidt residual and its normalized vector.
- For \(\mathbf{b}_1=(1,0,0,0)^{\top}\), \(\mathbf{b}_2=(1,1,1,0)^{\top}\), compute the projection coefficient and the second residual.
- Explain why \((1,0,0,0)^{\top},(0,1,0,0)^{\top},(1,1,0,0)^{\top}\) produce a zero residual at the third step.
- If a residual is \((2,-1,2,0)^{\top}\), compute its norm and its normalized vector.
- State two exact checks that can be used to catch errors in a Gram–Schmidt calculation.