Gram–Schmidt, one step at a time
Assignment 2 · Problem 4 · Orthogonalize, normalize, then project.
The homework problem
Find an orthonormal basis for S ⊂ ℝ⁴, where
a₁ = (1, 1, 1, 1), a₂ = (3, 1, 1, 3), a₃ = a₁ + a₂ = (4, 2, 2, 4).
Then find the closest vector p ∈ S to b = (1, 0, 0, 0). Vectors are written as tuples here; they are column vectors in the assignment PDF.
Drag to rotate. Use the view buttons to reset the camera.
The shaded plane is S. Axes are q₁, q₂, n, not the original coordinates of ℝ⁴. All arrows start at the origin unless marked as a translated component.
The method to remember
Gram–Schmidt takes each spanning vector and subtracts its projections onto the directions already accepted. Normalize each nonzero remainder to get a unit vector. A zero remainder means the input adds no independent direction; skip it rather than dividing by zero.
For an orthonormal set already constructed:
uₖ = aₖ − Σ (aₖ · qⱼ) qⱼ, then qₖ = uₖ / ‖uₖ‖ if uₖ ≠ 0.
Here the sum is over the previously accepted basis vectors. Once those vectors are orthonormal, the projection coefficients are just dot products.
Why a 3D view works for this ℝ⁴ problem
All the vectors in this problem lie in the three-dimensional space T = span{q₁, q₂, n}, where
- q₁ = ½(1, 1, 1, 1)
- q₂ = ½(1, −1, −1, 1)
- n = (1, 0, 0, −1) / √2
These three vectors are orthonormal. The display maps any v ∈ T to (v · q₁, v · q₂, v · n). This preserves dot products, lengths, and angles for these vectors, so the geometry you see is exact. In this coordinate system S is the horizontal plane with third coordinate zero. The fourth ambient direction is unused by this problem.
For example, a₂ appears at (4, 2, 0) and b at (½, ½, 1/√2). These displayed coordinates express components along the new axes; the explanation always gives the original ℝ⁴ coordinates.
Complete answer
u₁ = a₁, ‖u₁‖ = 2, so q₁ = ½(1, 1, 1, 1).
a₂ · q₁ = 4, hence u₂ = a₂ − 4q₁ = (1, −1, −1, 1). Since ‖u₂‖ = 2, q₂ = ½(1, −1, −1, 1).
a₃ · q₁ = 6 and a₃ · q₂ = 2, giving u₃ = a₃ − 6q₁ − 2q₂ = 0. Therefore {q₁, q₂} is an orthonormal basis of S.
For part (b): p = (b · q₁)q₁ + (b · q₂)q₂ = ½q₁ + ½q₂ = (½, 0, 0, ½).
The residual r = b − p = (½, 0, 0, −½) is perpendicular to both basis vectors. The distance to S is ‖r‖ = 1/√2. For any s ∈ S, Pythagoras gives ‖b − s‖² = ‖r‖² + ‖p − s‖², which is minimized uniquely at s = p.