Build orthonormal bases and nearest-point projections in finite dimensions.
§3.1Estimated reading time: 18 min
Before you start
Prerequisites: direct sums and dimension; inner products, norms and angles. You should be able to expand an inner product and check independence. The new ingredient is geometry: an inner product selects a unique orthogonal complement and a closest-point projection from the many algebraic complement choices.
All spaces are finite-dimensional over R or C.
Throughout the inner-product units F=R or C, and ⟨u,v⟩ is linear in its first argument and conjugate-linear in its second. A different convention reverses some coefficients, so fix one before computing.
Definition 3.1.1
(Inner product and orthogonality)
An inner product satisfies conjugate symmetry ⟨u,v⟩=⟨v,u⟩, linearity in the first argument, and ⟨v,v⟩>0 for v=0. Put ∥v∥=⟨v,v⟩. Vectors are orthogonal if their inner product is zero. For U⊆V, U⊥={v:⟨v,u⟩=0∀u∈U}.
For w=0, put α=⟨v,w⟩/∥w∥2. Expanding ∥v−αw∥2≥0 yields the Cauchy–Schwarz inequality
∣⟨v,w⟩∣≤∥v∥∥w∥,
with equality exactly when v,w are dependent. The triangle inequality follows by expanding ∥v+w∥2 and applying this bound to the cross term. Positive definiteness, not mere symmetry, is essential here.
Here is the triangle step explicitly. Conjugate symmetry gives
Here Re means real part; over R it changes nothing. Taking nonnegative square roots proves the triangle inequality over either field. This uses positivity of the norm as well as Cauchy–Schwarz, not an ordering on complex scalars.
Counterexample mode
Symmetry alone does not give Cauchy–Schwarz
Suppose a symmetric bilinear form were enough. On R2 take ⟨x,y⟩=x1y1−x2y2, which is symmetric and linear in each argument. For v=(1,1) and w=(1,0) we get ⟨v,w⟩=1, ⟨v,v⟩=0 and ⟨w,w⟩=1, so the squared inequality ⟨v,w⟩2≤⟨v,v⟩⟨w,w⟩ would read 1≤0. The proof breaks because v−αw=(0,1) pairs with itself to −1. Positive definiteness is exactly what excludes this.
Gram–Schmidt converts an independent list v1,…,vk to an orthonormal list spanning the same successive subspaces:
wj=vj−i<j∑⟨vj,qi⟩qi,qj=wj/∥wj∥.
Each wj is orthogonal to previous qi and is nonzero because otherwise vj would lie in the span of its predecessors. A zero or dependent input requires omitting a vector rather than dividing by zero.
In the following expanded calculation, ei denotes the same orthonormal vector called qi above.
Proof
(The two arguments)
If v=0, nonnegativity of ∥u−⟨u,v⟩v/∥v∥2∥2 gives Cauchy–Schwarz; equality occurs exactly when the residual is zero. If v=0, equality and dependence are immediate. In Gram–Schmidt, each residual is orthogonal to all earlier ei. It cannot be zero, since vj is not in the span of the preceding vectors. Normalization yields an orthonormal vector without changing the successive span. Induction completes the proof.
In the case v=0, put c=⟨u,v⟩/∥v∥2. Conjugate symmetry and linearity in the first argument give the explicit expansion
Nonnegativity proves the inequality, and equality is equivalent to u=cv. For Gram–Schmidt, each ℓ<j satisfies
⟨wj,eℓ⟩=⟨vj,eℓ⟩−i<j∑⟨vj,ei⟩⟨ei,eℓ⟩=0.
The independent-input hypothesis excludes a zero residual, so every displayed denominator is positive.
Proof X-ray
The inequality is a perpendicular split in disguise
The coefficient c is chosen so that u−cv is orthogonal to v: it removes exactly the component of u along v. The expansion then says ∥u∥2=∣c∣2∥v∥2+∥u−cv∥2, a Pythagorean identity for the two perpendicular pieces. Conjugate symmetry and conjugate-linearity in the second slot make each middle term equal to −∣⟨u,v⟩∣2/∥v∥2. Dropping the last term, which is nonnegative by positive definiteness, gives the inequality, and equality means that this dropped piece is zero. Gram–Schmidt repeats the same removal once for each earlier vector.
For a subspace U with orthonormal basis q1,…,qk, define
PUv=j=1∑k⟨v,qj⟩qj.
Then PUv∈U and v−PUv∈U⊥, so V=U⊕U⊥ and the projection is independent of the chosen orthonormal basis. For every u∈U,
∥v−u∥2=∥v−PUv∥2+∥PUv−u∥2,
proving PUv is the unique closest point. Orthogonality gives both existence and optimality.
Worked example 3.1.2
(Project onto a plane)
In R3 let U=span{(1,1,0),(1,−1,0)}. These vectors are orthogonal and both have norm 2. Thus for v=(2,3,4) the projection is (2,3,0) and the residual is (0,0,4), whose length 4 is the distance to U.
Worked example 3.1.3
(The best linear approximation to x² in an integral inner product)
On P2 over R use ⟨f,g⟩=∫01f(x)g(x)dx. It is symmetric and bilinear, and ⟨f,f⟩=∫01f2>0 for a nonzero polynomial f, because f2 is continuous, nonnegative and vanishes at only finitely many points. Here ⟨1,x⟩=21, ∥1∥2=1 and ∥x∥2=31, so Cauchy–Schwarz reads 41≤31: strict, as it must be for the independent pair 1,x.
Now project v=x2 onto U=P1=span(q1,q2). The coefficients are ⟨x2,q1⟩=31 and ⟨x2,q2⟩=23(41−61)=63, so
PU(x2)=31+63⋅23(x−21)=x−61.
The residual r=x2−x+61 satisfies ⟨r,1⟩=31−21+61=0 and ⟨r,x⟩=41−31+121=0, so it is orthogonal to all of P1, and ∥r∥2=∫01r2=1801. By the closest-point identity, x−61 is the unique linear polynomial minimizing ∫01(x2−p)2, and the minimum value is 1801. The answer depends on the inner product: a different weight or interval gives a different best line.
A nonorthogonal plane: construct and verify the closest point
In the standard real inner product, let a=(1,1,0)T, b=(1,0,1)T, W=span(a,b) and v=(2,1,3)T. Both generators are nonzero and independent, but aTb=1, so using them directly in the orthonormal projection formula would be wrong. Gram–Schmidt first removes from b the part already represented by a:
The residual has squared norm 3/2>0, so this normalization is legal. Check q1Tq2=0 and ∥q1∥=∥q2∥=1. The successive-span identity shows these vectors span W. Now compute the coefficients and the projection:
Thus the distance is 2/3. Orthogonality to both generators proves orthogonality to their whole span. For every other w∈W, the identity ∥v−w∥2=4/3+∥p−w∥2 proves optimality and uniqueness; merely displaying a plausible point in the plane would not prove either. An independent calculation in the original nonorthogonal basis gives the same answer: write p=ca+db and impose aT(v−p)=bT(v−p)=0. This yields
(2112)(dc)=(53),(c,d)=(1/3,7/3),ca+db=p.
The Gram matrix is invertible because the generators are independent: for nonzero z, zTGz=∥z1a+z2b∥2>0. With dependent generators, coefficients may fail to be unique although the closest point remains unique. The distinction is between a point and its coordinates.
Worked example 3.1.4
(An orthogonal complement as a null space)
In R4 with the dot product let U=span(a,b), a=(1,1,1,1)T, b=(1,2,3,4)T. A vector x lies in U⊥ exactly when it is orthogonal to both generators, that is, when it solves
x1+x2+x3+x4=0,x1+2x2+3x3+4x4=0.
Subtracting gives x2+2x3+3x4=0, so x2=−2x3−3x4 and then x1=x3+2x4. With x3,x4 free,
U⊥=span((1,−2,1,0)T,(2,−3,0,1)T).
Both vectors are orthogonal to a and b: for instance (2,−3,0,1)⋅b=2−6+0+4=0. Thus dimU+dimU⊥=2+2=4, as V=U⊕U⊥ requires.
To split v=e1, solve the normal equations with the Gram matrix of (a,b):
(4101030)(dc)=(bTvaTv)=(11),(c,d)=(1,−103).
Hence PUv=a−103b=(107,52,101,−51)T and v−PUv=(103,−52,−101,51)T. The residual has coordinate sum 0 and weighted sum 103−54−103+54=0, so it lies in U⊥; the squared distance from e1 to U is 1009+10016+1001+1004=103.
A complex calculation that exposes the argument convention
In C2 use the first-linear product ⟨x,y⟩=y∗x. Take u=(1,i)T and v=(1,1)T. These are independent since their column determinant is 1−i=0. Gram–Schmidt starts with q1=u/2. Its projection coefficient and residual are
Directly ⟨r,q1⟩=0 and ∥r∥2=1, so q2=r is already normalized. Thus (q1,q2) is an orthonormal basis, and v=aq1+q2; checking both coefficient columns also gives Q∗Q=I2 for Q=(q1q2).
The projection onto U=spanC(q1) is p. For any c∈C, orthogonality gives the fully numerical closest-point identity
∥v−cq1∥2=∥r+(a−c)q1∥2=1+∣a−c∣2.
The minimum distance is one and the minimizing coefficient is uniquely c=a. Using the opposite argument order gives ⟨q1,v⟩=(1+i)/2, a different coefficient. Its residual has inner product −2i with q1 and squared norm three, so it is neither orthogonal nor closest. The two argument orders coincide for real data but not for this example; the convention changes a computation, not merely its notation.
Choosing a method and avoiding mistakes
Use Gram–Schmidt when the given independent basis is not orthogonal; use projection directly once an orthonormal basis is known. For merely orthogonal non-unit ui, divide each coefficient by ∥ui∥2. Do not omit conjugation in a complex inner product or apply the finite-dimensional complement theorem to an arbitrary infinite-dimensional subspace without additional hypotheses.
Quick checks
Quick check
(For u=(1,2,2) and v=(3,0,4) in R3, verify the Cauchy–Schwarz and triangle inequalities and find cosθ for the angle between them.)
Solution · Answer
⟨u,v⟩=3+0+8=11, ∥u∥=1+4+4=3 and ∥v∥=9+16=5, so ∣⟨u,v⟩∣=11≤15=∥u∥∥v∥, strictly, since u,v are independent. Then cosθ=1511. For the triangle inequality, u+v=(4,2,6) has ∥u+v∥2=56, while (∥u∥+∥v∥)2=64, so ∥u+v∥=56<8; indeed 56=9+2⋅11+25.
Quick check
(Is ⟨x,y⟩=x1y1+x1y2+x2y1+2x2y2 an inner product on R2?)
Solution · Answer
Yes. It is bilinear, and symmetric because the two mixed terms x1y2+x2y1 are unchanged when x and y are swapped. For positivity complete the square: ⟨x,x⟩=x12+2x1x2+2x22=(x1+x2)2+x22, which is zero only when x2=0 and x1+x2=0, that is, only for x=0. So the form is positive definite.
Quick check
(In C2 with the first-linear product ⟨x,y⟩=x1y1+x2y2, find the orthogonal complement of U=span((1,1+i)).)
Solution · Answer
x∈U⊥ means ⟨x,(1,1+i)⟩=x1+x2(1+i)=x1+(1−i)x2=0. Hence x=s(−1+i,1) for s∈C, and U⊥=span((−1+i,1)). Check: ⟨(−1+i,1),(1,1+i)⟩=(−1+i)+(1−i)=0. Forgetting the conjugate would give (−1−i,1), whose inner product with (1,1+i) is −1−i+1−i=−2i=0.
Exercises
Apply Gram–Schmidt to (1,1), (1,0) in R2 in that order.
Find the nearest point to (1,2,3) in U=span{(1,1,1)} and its distance.
For z,w∈C2 use ⟨z,w⟩=z1w1+z2w2. Compute the projection of (i,1) onto span{(1,i)}.
Complex convention diagnostic. With the first-linear standard inner product, project v=(i,0) onto the complex line spanned by a=(1,i). Verify the residual is orthogonal to a and find the squared distance. Explain why conjugating the projection coefficient would change the answer.
Complex coordinates. For the complex orthonormal basis (q1,q2) just constructed, find the coordinates of w=(i,i)T and its projection onto U=spanC(q1). Check PU(iv)=iPU(v) for v=(1,1)T using the stated first-linear convention.
Full solutions
e1=(1,1)/2. Subtracting the first component from (1,0) gives w2=(1/2,−1/2), so e2=(1,−1)/2.
The coefficient on (1,1,1) is (1+2+3)/3=2, so the nearest point is (2,2,2). The residual (−1,0,1) has length 2.
The spanning vector has squared norm 2, and ⟨(i,1),(1,i)⟩=i−i=0. The projection is therefore zero.
Here ⟨v,a⟩=i and ⟨a,a⟩=2, so p=(i/2)a=(i/2,−1/2). The residual is r=(i/2,1/2) and ⟨r,a⟩=i/2+(1/2)(−i)=0. Its squared norm is 1/4+1/4=1/2. Using i/2=−i/2 instead would give a residual with nonzero inner product with a; the coefficient must follow the fixed first-linear convention.
Because w=iv, first-slot linearity gives ⟨w,q1⟩=i(1−i)/2=(1+i)/2 and ⟨w,q2⟩=i. Thus [w](q1,q2)=((1+i)/2,i)T. Multiplying those coordinates by Q recovers (i,i)T. The projection is ((1+i)/2)q1=((1+i)/2,(−1+i)/2)T=i((1−i)/2,(1+i)/2)T=iPU(v). Its residual is ((−1+i)/2,(1+i)/2)T, orthogonal to q1 with squared norm one. Using ⟨q1,w⟩ instead would conjugate the scalar in this step and would not establish complex linearity.
Connection
Orthogonal projection is a self-adjoint operator. Adjoints generalize the transpose and express how a map interacts with the inner product.