Chapter 6: Inner product spaces
6.4Orthogonal projection and Gram–Schmidt
Let be a subspace of an inner product space , and let . Which vector of is closest to ? When is a plane through in , geometry gives the answer: drop the perpendicular from to , and take its foot. This section turns that answer into a theorem about every inner product space, provided is finite-dimensional. The foot of the perpendicular is the orthogonal projection . If has an orthonormal basis, it is given by the formula from the proof of Bessel’s inequality (Theorem 6.3.24), and the Gram–Schmidt algorithm produces an orthonormal basis of every finite-dimensional subspace. The leftover vectors make up the orthogonal complement , which turns out to be a complement of in the sense of Section 4.4. Since distances also make sense between functions, the same theorem answers questions such as: which quadratic polynomial is closest to on ?
Throughout, is an inner product space over , where is or (Notation 6.1.1). We do not assume that is finite-dimensional. The subspaces we project onto will be finite-dimensional, but the ambient space is often a space of functions.
6.4.1Projecting onto the span of an orthonormal list
Intuition (From a line to a plane). In Section 6.2.1 we split a vector against a nonzero vector as , where lies on the line and (Figure 6.2.1). The vector is the foot of the perpendicular from to the line, and the requirement forced .
Now replace the line by a plane in spanned by orthonormal vectors , and look for the foot of the perpendicular from to . That is, we want such that is perpendicular to . Write . By Proposition 6.3.9(c), means that for , and taking the inner product with isolates the coefficient (Technique 6.3.12):
So
The shadows can be computed separately and then added because . For a basis of that is not orthogonal, the sum of the shadows is not the foot; see the example after Corollary 6.3.21.
Definition 6.4.1 (Projection onto the span of an orthonormal list). Let be an orthonormal list in . The projection onto is the function given by
If , the sum is empty and .
This is the vector from the proof of Bessel’s inequality (Theorem 6.3.24). As with coordinates (Remark 6.3.19), goes in the first slot. For a single unit vector ,
Example 6.4.2 (A projection in ). Take the orthonormal list with and from Example 6.3.16(c), and . In Example 6.3.20 we computed and . So
and
Example 6.4.3 (Projecting a function). Give the inner product
So is orthogonal to and to . The polynomial of Example 6.3.17 arises in exactly this way, and Section 6.4.2 turns the computation into an algorithm.
The next proposition collects what we know about . Most of it was proved along the way to Bessel’s inequality.
Proposition 6.4.4 (Properties of ). Let be an orthonormal list in , let , and let .
- (a).
- (b).
- (c) if and only if .
- (d) is linear.
- (e)
, and . In particular , with equality if and only if .
Uses. Definition 6.4.1 (Projection onto the span of an orthonormal list), Definition 6.3.15 (Orthonormal list, orthonormal basis), Proposition 6.3.9 (Properties of ), Proposition 6.3.18 (Coordinates in an orthonormal basis), Theorem 6.3.3 (Pythagorean theorem), Corollary 6.3.6 (Pythagoras for orthogonal lists), Proposition 6.1.27 (Basic properties of the norm)
Techniques. Take an inner product to isolate a coefficient (Technique 6.3.12)
(a) is a linear combination of .
(b) For each , linearity in the first slot and orthonormality give
So , and
(c) If , then by (a). Conversely, if , then
(d) For and , linearity in the first slot gives
(e) By (a) and (b),
Part (e) is (6.3.2), and its inequality is Bessel’s inequality. The move behind it deserves a name, since it is the main source of upper bounds in this chapter.
Technique 6.4.5 (Projections shrink norms). Suppose , where lies in a subspace and , as for and . By Pythagoras,
So each piece is at most as long as . Moreover exactly when , that is, when , and exactly when .
Reach for it when you need an upper bound for a sum over an orthonormal list, which is , or more generally when the quantity to be bounded is the length of one orthogonal piece of a vector whose length you know. The equality case turns the bound into a test for membership in . The canonical example is Bessel’s inequality (Theorem 6.3.24). In Theorem 6.4.33 the error turns out to be the piece of orthogonal to , for every ; and in infinite dimensions (Section 15.3) Bessel’s inequality survives where Parseval’s identity needs more work.
Used in 3 places and 1 practice exercise
Theorem 6.4.33, Exercise 6.4.60, Problem 6.2; 1 practice exercise.
The projection is determined by orthogonality
Part (b) of Proposition 6.4.4 is the property that made the foot of the perpendicular in the intuition above. It determines completely. This matters because the condition “ and ” mentions only the subspace , not the orthonormal list that the formula uses.
Theorem 6.4.6 (The projection is characterized by orthogonality). Let be an orthonormal list in , let , and let . Then is the unique vector such that
Proof (by two candidates).
Uses. Proposition 6.4.4 (Properties of ), Proposition 6.3.9 (Properties of )
Techniques. Uniqueness via two candidates (Technique 1.1.8)
By (a) and (b) of Proposition 6.4.4, has both properties. Suppose and both have them. Since is a subspace, . Since is a subspace (Proposition 6.3.9(a)),
So , which is by Proposition 6.3.9(d). Hence . □
Proof (by computing coordinates).
Uses. Proposition 6.3.18 (Coordinates in an orthonormal basis), Proposition 6.4.4 (Properties of ), Definition 6.4.1 (Projection onto the span of an orthonormal list)
Techniques. Take an inner product to isolate a coefficient (Technique 6.3.12)
Write . Existence is (a) and (b) of Proposition 6.4.4. Conversely, let with . Since , we have , so
Since , Proposition 6.3.18(a) gives
as desired. □
The first proof never uses the formula for . It shows that any two vectors with the two properties agree, whatever produced them, and all it needs is . The second proof computes the coordinates of such a vector and recognizes them as those of ; this is how the lecture argues. The first proof is the one that generalizes, and it gives the following technique.
Technique 6.4.7 (Recognize a projection by its two conditions). To show that a vector is the projection of onto , do not compute the projection. Check the two conditions of Theorem 6.4.6: , and . By Proposition 6.3.9(c), the second condition only has to be checked against a spanning list of . Uniqueness then does the rest, much as a two-sided inverse is recognized by checking two products (Technique 2.5.16).
Reach for it when a formula or a vector is proposed as a projection, when projections onto related subspaces are compared, and when you need to know that a projection does not depend on the choices made to compute it. The canonical example is Corollary 6.4.8. Later examples are the projection onto (Proposition 6.4.29), the recognition of orthogonal projections among all linear maps (Proposition 6.4.30), and the projection formula of Section 6.5.
Used in 19 places and 4 practice exercises
Corollary 6.4.8, Exercise 6.4.28, Proposition 6.4.29, Proposition 6.4.30, Exercise 6.4.42, Exercise 6.4.49, Exercise 6.4.57, Exercise 6.4.58, Theorem 6.5.5, Proposition 6.5.13, Proposition 6.5.17, Proposition 6.5.23, Exercise 6.5.42, Corollary 6.6.29, Exercise 6.7.5, Exercise 6.7.13, Problem 6.2, Problem 6.4, Exercise 8.1.32; 4 practice exercises.
Uses. Theorem 6.4.6 (The projection is characterized by orthogonality), Proposition 6.4.4 (Properties of )
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
Example 6.4.9 (Two orthonormal bases, one projection). Let
are orthonormal lists of two vectors in the -dimensional plane , so both are orthonormal bases of (Corollary 6.3.14). For ,
The individual shadows differ, because they depend on the axes, but their sums agree. As a check,
By hand it is often easier to work with an orthogonal list and postpone normalizing.
Corollary 6.4.10 (Projecting with an orthogonal list). Let be an orthogonal list of nonzero vectors in , and let be the orthonormal list
Each term is unchanged if is replaced by for a scalar .
Uses. Definition 6.4.1 (Projection onto the span of an orthonormal list), Proposition 6.1.4 (Sesquilinearity), Proposition 6.1.27 (Basic properties of the norm)
Since is a positive real number, it equals its conjugate, and Proposition 6.1.4 gives
Summing over gives the formula. If is replaced by , the th term becomes
by Proposition 6.1.4 and Proposition 6.1.27(b). □
For this is the shadow of Technique 6.2.4, and for an orthogonal basis of it is Corollary 6.3.21.
Orthogonal projection onto a subspace
By Corollary 6.4.8, depends only on the subspace spanned by . So we may name it after the subspace.
Definition 6.4.11 (Orthogonal projection). Let be a subspace of that has an orthonormal basis . The orthogonal projection onto is the map , that is,
By Corollary 6.4.8 this does not depend on the choice of the orthonormal basis . By Theorem 6.4.6, is the unique vector with .
A basis is a finite list, so only a finite-dimensional subspace can have an orthonormal basis. Conversely, Theorem 6.4.20 below shows that every finite-dimensional subspace has one. So is defined exactly for the finite-dimensional subspaces of , while itself may be infinite-dimensional. In Example 6.4.3, for instance, for
Exercise 6.4.13. In with the dot product, let and .
- (a)Compute , and check that .
- (b)A student uses instead. Show that this vector does not have the property in (a).
Uses. Definition 6.4.1 (Projection onto the span of an orthonormal list), Definition 6.1.8 (Dot product), Proposition 6.4.4 (Properties of )
(a) By Definition 6.1.8,
and
(b)
6.4.2The Gram–Schmidt algorithm
To use Definition 6.4.11 we need orthonormal bases. A subspace usually arrives as the span of some list , such as the columns of a matrix or the monomials , and that list is rarely orthonormal. The Gram–Schmidt algorithm converts it into an orthonormal basis of the same span.
Intuition (Keep only what is new). Process the vectors one at a time, and keep an orthonormal list with the same span as the vectors processed so far. When arrives, split it as in Figure 6.4.1: is its projection onto plus the remainder
The projection lies in the span we already have, so it contributes nothing new. The remainder is orthogonal to by Proposition 6.4.4(b), so after normalizing it can be appended to the orthonormal list, and it carries exactly the direction that adds (Figure 6.4.2). If the remainder is , then lies in the span of the earlier vectors and adds no new direction, so we skip it.
Algorithm 6.4.14 (Gram–Schmidt)
- Input
- A list in .
- Output
- An orthonormal list , where , with
.
The sum in step 1 is for the current list ; when it is empty and . We call the residuals. If no vector is skipped, then after the th pass, and the algorithm is the recursion
That the output is orthonormal and has the right span is a statement about what the algorithm keeps true from one pass to the next, so we prove it as in Technique 3.3.5.
Theorem 6.4.15 (Gram–Schmidt is correct). Run Algorithm 6.4.14 on a list in . For , let be the list of vectors kept after the first passes, so that is empty.
- (a)For every , is orthonormal and
. - (b)In pass , the vector is skipped if and only if
. - (c)The output is an orthonormal basis of .
- (d)If is linearly independent, then no vector is skipped, and the output satisfies
and for every .
Uses. Proposition 6.4.4 (Properties of ), Proposition 1.3.18 (Comparing spans), Proposition 6.3.13 (Orthogonal lists are independent), Theorem 1.5.5 (Independence is decided at zero), Definition 6.3.15 (Orthonormal list, orthonormal basis)
Techniques. Algorithms as proofs: invariants and termination (Technique 3.3.5), Induction on the length of a list (Technique 1.6.9), Double containment (Technique 1.3.14)
(a) We induct on . For , the empty list is orthonormal, and both sides equal .
Let , and suppose that
Suppose . Then is orthonormal. Since
Suppose . Then is with , a unit vector. By Proposition 6.4.4(b), , so
because
So
(b) We saw in the proof of (a) that pass keeps nothing exactly when
(c) The output is . By (a) it is orthonormal, hence linearly independent (Proposition 6.3.13), and it spans .
(d) If
where the first term lies in and is therefore orthogonal to . Hence
The invariant (a) is exactly what makes step 1 the right move. Because is the span of all the earlier vectors, the residual is orthogonal to each earlier output, not only to the most recent one. Subtracting only the shadow on would leave components along .
Remark 6.4.16 (Postponing the normalization). By Corollary 6.4.10, the projection in step 1 can be computed from the residuals instead of the normalized vectors:
and each may be replaced by any nonzero multiple of itself without changing this sum. So by hand one runs the algorithm with residuals only, clears denominators in each residual as it appears, and normalizes once at the end. Square roots then appear only in the last step.
Example 6.4.17 (Gram–Schmidt in ). Let , , . Following Remark 6.4.16:
which we replace by . Since with , and with ,
which we replace by . The rescaled residuals , , are pairwise orthogonal, and normalizing them gives the orthonormal basis
of . As Theorem 6.4.15(d) predicts, is the length of the unrescaled residual .
Example 6.4.18 (A dependent list). Run the algorithm on , , , in , again with residuals only. First , and
In the third pass, and , so
So is skipped: by Theorem 6.4.15(b) it lies in , and the computation even exhibits the relation
which we replace by . The output, after normalizing, is , , : an orthonormal basis of
So Gram–Schmidt also detects linear dependence, much as row reduction does, and the number of vectors it keeps is the dimension of the span.
Example 6.4.19 (Legendre polynomials). Give the inner product
which recovers the orthogonal basis of Example 6.3.17. The next pass gives , the polynomial of Exercise 6.3.49. By Theorem 6.4.15(d),
The output depends on the inner product. The lecture’s example uses
Now we can show that the hypothesis of Definition 6.4.11 holds for every finite-dimensional subspace.
- (a)Every finite-dimensional inner product space has an orthonormal basis.
- (b)In a finite-dimensional inner product space, every orthonormal list extends to an orthonormal basis.
- (c)Every finite-dimensional subspace of an inner product space has an orthonormal basis. In particular, is defined.
Uses. Theorem 6.4.15 (Gram–Schmidt is correct), Corollary 1.6.24 (Bases exist in finite dimensions), Definition 6.4.11 (Orthogonal projection), Definition 6.1.2 (Inner product)
(a) Let be finite-dimensional. It has a basis (Corollary 1.6.24). By Theorem 6.4.15(c), Gram–Schmidt turns it into an orthonormal basis of
(b) Let be orthonormal, and let be a basis of . Run Gram–Schmidt on the list
a unit vector, which is kept unchanged. So the output begins with , and by Theorem 6.4.15(c) it is an orthonormal basis of the span of the whole list, which is because the list contains a basis.
(c) The inner product of , restricted to pairs of vectors of , satisfies the axioms of Definition 6.1.2 on . So is a finite-dimensional inner product space, and it has an orthonormal basis by (a). Then is defined by Definition 6.4.11. □
Part (b) is the orthonormal version of extending an independent list to a basis (Theorem 4.1.16). Together with Parseval’s identity, part (a) completes the picture sketched after Theorem 6.3.22: every -dimensional inner product space has an orthonormal basis, and its coordinates carry the inner product to the dot product of .
Uses. Algorithm 6.4.14 (Gram–Schmidt), Definition 6.1.8 (Dot product), Corollary 6.4.10 (Projecting with an orthogonal list)
We use Remark 6.4.16. First with . Next
Check:
With the slots exchanged, the coefficient becomes , and the “residual” is
6.4.3Orthogonal complements
In Orthogonality to a set we defined for every subset of . When is a subspace, deserves a name of its own, which we now justify.
Definition 6.4.22 (Orthogonal complement). Let be a subspace of . The orthogonal complement of is the subspace
of Definition 6.3.8.
By Proposition 6.3.9, is a subspace of , , and implies . By Exercise 6.3.11, . Note that depends on the ambient space: the perp of the -axis is a line in and a plane in .
- (a)In , is the plane
of Example 6.4.9 (Example 6.3.10). Conversely . Indeed is orthogonal to the spanning vectors and of , so , and Theorem 6.4.26 below gives equality. - (b)For , let be the span of the rows of . By Example 6.3.10 and Proposition 6.3.9(c), : solving means finding the vectors orthogonal to every row.
- (c)In with
, every odd function is orthogonal to every even function (Example 6.3.2(c)). Exercise 6.4.54 shows that the odd functions form exactly the orthogonal complement of the even functions.
The main theorem says that really is a complement of , as soon as is finite-dimensional. The proof is already contained in Proposition 6.4.4: every vector is its projection onto plus something orthogonal to .
Theorem 6.4.24 (Orthogonal decomposition). Let be a finite-dimensional subspace of . Every can be written in exactly one way as
namely with and . That is, .
Uses. Theorem 6.4.20 (Orthonormal bases exist), Proposition 6.4.4 (Properties of ), Proposition 6.3.9 (Properties of ), Definition 4.4.4 (Direct sum), Theorem 4.4.7 (Criteria for direct sums)
Techniques. Uniqueness via two candidates (Technique 1.1.8)
By Theorem 6.4.20, has an orthonormal basis, so is defined. For , (a) and (b) of Proposition 6.4.4 give and , and these two vectors add up to . So a decomposition exists.
Suppose with and . Then
The left side lies in and the right side in , since both are subspaces. So both sides lie in (Proposition 6.3.9(d)), and , . In the language of Section 4.4, and , so the sum is direct (Theorem 4.4.7, Definition 4.4.4). □
Uniqueness can also be read off from Theorem 6.4.6: if with and , then and , so . In the theorem says that every vector is the sum of a vector in a given plane through and a vector along the normal line, which is how one splits a force into the part along a surface and the part pushing against it.
Note what was assumed: is finite-dimensional, but need not be. When is infinite-dimensional the theorem can fail. Exercise 6.4.63 gives a proper subspace of an inner product space with , so that ; Section 15.3 explains what survives in infinite dimensions.
Proof (by the dimension formula).
Uses. Theorem 6.4.24 (Orthogonal decomposition), Theorem 4.4.19 (Dimension of a sum), Proposition 6.3.9 (Properties of ), Proposition 4.1.21 (Dimensions of subspaces)
Techniques. Dimension counting (Technique 4.2.24)
Subspaces of the finite-dimensional space are finite-dimensional (Proposition 4.1.21). By Theorem 6.4.24, , and by Proposition 6.3.9(d). By Theorem 4.4.19,
which gives the dimension formula. The statement about bases is proved in the second approach. □
Proof (by extending an orthonormal basis).
Uses. Theorem 6.4.20 (Orthonormal bases exist), Proposition 6.3.18 (Coordinates in an orthonormal basis), Proposition 6.3.9 (Properties of ), Definition 6.3.15 (Orthonormal list, orthonormal basis)
Techniques. Double containment (Technique 1.3.14), Take an inner product to isolate a coefficient (Technique 6.3.12)
By Theorem 6.4.20, has an orthonormal basis , and it extends to an orthonormal basis of , where . (Conversely, every orthonormal basis of whose first vectors span arises this way.) Let
For , is orthogonal to , so by Proposition 6.3.9(c). As is a subspace, . Conversely, let . Then for , so by Proposition 6.3.18(b),
So . The list is orthonormal and spans , so it is an orthonormal basis of , and
The first proof counts. The second builds the basis of , and it shows that, in coordinates with respect to an orthonormal basis adapted to , the decomposition
For the matrix of Example 6.4.23(b), the corollary gives , and rank–nullity (Theorem 4.2.11) gives
Since always holds, the next question is whether taking the complement twice returns . In the complement of a plane is its normal line, and the complement of that line is the plane again.
Proof (by the orthogonal decomposition).
Uses. Theorem 6.4.24 (Orthogonal decomposition), Proposition 6.3.9 (Properties of ), Exercise 6.3.11
Techniques. Double containment (Technique 1.3.14)
Proof (by counting dimensions, when is finite-dimensional).
Uses. Corollary 6.4.25 (Dimension of the orthogonal complement), Proposition 4.1.21 (Dimensions of subspaces), Exercise 6.3.11
Techniques. Dimension counting (Technique 4.2.24)
Suppose is finite-dimensional, with . By Corollary 6.4.25, applied to and then to ,
Since (Exercise 6.3.11) and the dimensions agree, by Proposition 4.1.21. □
The second proof is shorter but needs finite-dimensional, so that has a dimension at all. The first needs only that is finite-dimensional, which is the setting of the approximation problems below, where is a space of functions.
Uses. Theorem 6.4.24 (Orthogonal decomposition), Proposition 6.3.9 (Properties of )
So to show that a finite-dimensional subspace is all of , it suffices to show that the only vector orthogonal to is .
Uses. Theorem 6.4.26 (The double complement), Corollary 6.4.10 (Projecting with an orthogonal list), Theorem 6.4.6 (The projection is characterized by orthogonality), Proposition 6.3.9 (Properties of )
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
Let . Then
In particular . Let
Its coordinates add up to , so , and . By Theorem 6.4.6 (applied with an orthonormal basis of ), . By Theorem 6.4.33 below, this is the vector of closest to , at distance . (Proposition 6.4.29(d) below explains the shortcut: .)
The projection as a linear map
We now collect the properties of as a map .
Proposition 6.4.29 (The orthogonal projection as a linear map). Let be a finite-dimensional subspace of , and let .
- (a) is linear, , and .
- (b). In fact for every .
- (c)
for all . - (d)If is finite-dimensional, then .
Uses. Proposition 6.4.4 (Properties of ), Theorem 6.4.6 (The projection is characterized by orthogonality), Definition 6.4.11 (Orthogonal projection), Theorem 6.4.20 (Orthonormal bases exist), Proposition 4.1.21 (Dimensions of subspaces), Exercise 6.3.11
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
(a) is linear by Proposition 6.4.4(d), and by part (a) of the same proposition. If , then by part (c), so . For the kernel: by Theorem 6.4.6, if and only if satisfies and , that is, if and only if .
(b) For , , so by Proposition 6.4.4(c).
(c) Let . Since and ,
Similarly, since and ,
(d) Since is finite-dimensional, so is (Proposition 4.1.21), so is defined (Theorem 6.4.20). Let and . Then by Proposition 6.4.4(b), and
In (d), finite-dimensionality of was used only to know that is defined. For any , the map is linear, has image , and picks out the -component in Theorem 6.4.24.
Parts (b) and (c) characterize orthogonal projections among all linear maps. Part (b) alone does not: the map of Remark 6.4.12 satisfies , but
Proposition 6.4.30 (Recognizing orthogonal projections). Let be finite-dimensional and . Then for some subspace of if and only if
In that case .
Uses. Proposition 6.4.29 (The orthogonal projection as a linear map), Theorem 6.4.6 (The projection is characterized by orthogonality), Theorem 6.4.20 (Orthonormal bases exist), Proposition 4.1.21 (Dimensions of subspaces)
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
If , then and
Conversely, suppose has the two properties, and let . It is a subspace of the finite-dimensional space , so it is finite-dimensional (Proposition 4.1.21) and is defined (Theorem 6.4.20). Let . Then . Every vector of has the form for some , and by the second property, applied to the vectors and ,
So . By Theorem 6.4.6, . As was arbitrary, . □
The second condition says that can be moved from one slot of the inner product to the other. In the language of Section 6.6, it says that equals its adjoint, , that is, is self-adjoint (Definition 6.6.26). So the orthogonal projections are exactly the operators with . For with the dot product, Proposition 6.3.27(d) shows that the condition says that the matrix of is Hermitian.
Projection matrices
In with the dot product, is a linear map , so it is multiplication by a matrix. The matrix is built from an orthonormal basis of and its conjugate transpose.
Theorem 6.4.31 (The matrix of an orthogonal projection). Let be a subspace of with the dot product, let be an orthonormal basis of , and let be the matrix with columns . Then
and
Uses. Definition 6.3.26 (Conjugate transpose), Proposition 2.4.8 (Four views of the product), Definition 6.1.8 (Dot product), Theorem 6.3.29 (Orthonormal columns), Proposition 6.3.27 (Properties of the conjugate transpose), Proposition 2.4.14 (Algebra of matrices)
Row of is (Definition 6.3.26), so the th entry of is
The columns-times-rows view of Proposition 2.4.8 gives
□
The two products of and play different roles. records that the columns are orthonormal. is the projection onto their span, and it equals only when , that is, when is unitary. This is the identification promised after Theorem 6.3.29. Each term is the projection onto the line , so is the sum of the projections onto the lines of an orthonormal basis, as in Figure 6.4.1. By Corollary 6.4.10, for an orthogonal basis of the matrix is
In particular, the projection onto the line spanned by a nonzero has matrix . For a general basis of the formula needs an inverse, , which is the subject of Section 6.5.
Example 6.4.32 (Projecting onto a plane in ). Let be the plane of Example 6.4.9, and , so that (Example 6.4.23(a)). By Proposition 6.4.29(d) and the formula for lines,
For instance
6.4.4Best approximation
We return to the question that opened the section: which vector of is closest to ?
Intuition (The right triangle). Let be a plane through in , and any point of . The three points , , and form a triangle with a right angle at : one leg, , is perpendicular to , and the other, , lies in (Figure 6.4.3). The distance from to is the hypotenuse, which is longer than the leg unless the other leg is . So no point of is closer to than , and every other point of is farther away.
This is the shadow argument of Figure 6.2.1, with the line replaced by a subspace. It uses only Pythagoras, so it works in every inner product space.
Theorem 6.4.33 (Best approximation). Let be a finite-dimensional subspace of , and let . Then
with equality if and only if . That is, is the unique vector of closest to . If is an orthonormal basis of , the least distance is given by
Proof (by Pythagoras).
Uses. Proposition 6.4.4 (Properties of ), Theorem 6.3.3 (Pythagorean theorem), Proposition 6.1.27 (Basic properties of the norm), Theorem 6.4.20 (Orthonormal bases exist)
Techniques. Orthogonal decomposition (Technique 6.2.4), Projections shrink norms (Technique 6.4.5)
is defined by Theorem 6.4.20. Let . Then
where by Proposition 6.4.4(b), and because both terms lie in . So the two pieces are orthogonal, and by Theorem 6.3.3(a),
Taking nonnegative square roots gives the inequality. By (6.4.2), equality holds if and only if , that is (Proposition 6.1.27(a)), if and only if . Finally, by Proposition 6.4.4(e),
□
Proof (by completing the square).
Uses. Proposition 6.1.29 (Expanding a norm), Proposition 6.1.4 (Sesquilinearity), Corollary 6.3.6 (Pythagoras for orthogonal lists), Theorem 6.4.20 (Orthonormal bases exist), Definition 6.4.11 (Orthogonal projection)
Techniques. A sum of nonnegative terms (Technique 6.1.9)
By Theorem 6.4.20, has an orthonormal basis . Let , so that
By Proposition 6.1.4,
The first two terms do not depend on , and the last sum is a sum of nonnegative terms, which is if and only if for every . So is smallest exactly when
The first proof starts from the candidate and shows that it wins. The second does not need to know the answer in advance: completing the square produces the minimizing coefficients and the minimum at the same time, and it shows that the squared error grows like as moves away from the optimum. In the language of Technique 6.4.5, the first proof says that for every , the error is the piece of orthogonal to : moving around changes only the piece in , and dropping that piece can only shorten a vector.
The theorem gives a third reason why does not depend on the orthonormal basis used to compute it: “the closest vector of ” is defined by distances alone. Putting Theorem 6.4.6 and Theorem 6.4.33 together, for the following are equivalent:
- (i), the formula computed from an orthonormal basis of ;
- (ii);
- (iii) for every .
In proofs one usually checks (ii), in computations one uses (i), and in applications the reason to care is (iii).
Definition 6.4.34 (Distance to a subspace). Let be a finite-dimensional subspace of and . The distance from to is
The minimum exists by Theorem 6.4.33. So if and only if , and by Theorem 6.4.24, is the length of the component of in . When is finite-dimensional, that component is (Proposition 6.4.29(d)).
Example 6.4.35 (Distance to a hyperplane). Let be nonzero and
For the plane in and , with : and , so , and the closest point of the plane is
Uses. Example 6.4.17 (Gram–Schmidt in ), Theorem 6.4.33 (Best approximation), Example 6.4.35 (Distance to a hyperplane)
By Example 6.4.17, , is an orthonormal basis of . Here and , so by Theorem 6.4.33 the closest point is
The distance is
Approximating functions
In a space of functions, Theorem 6.4.33 solves approximation problems. The inner product decides what “close” means. For
Example 6.4.37 (The quadratic closest to ). In with
Integrating by parts,
so
Compare the Taylor polynomial , which is also quadratic. Figure 6.4.4 plots both errors. Near , is better: it agrees with to second order there. Over the whole interval, is better. Its squared distance from is
The error
Aside (Fourier truncation). Take the inner product
and
The left side is nonnegative, so
Best approximation in is the subject of Section 6.5. There is the image of a matrix , and is the closest one can come to solving an inconsistent system .
6.4.5QR factorization Beyond 21-242
QR factorization is Gram–Schmidt in matrix form. It is not covered in lecture; see LADR 7D.
Gram–Schmidt applied to the columns of a matrix factors the matrix. If has linearly independent columns and Gram–Schmidt turns them into , then
Uses. Theorem 6.4.15 (Gram–Schmidt is correct), Proposition 6.3.18 (Coordinates in an orthonormal basis), Proposition 2.4.8 (Four views of the product), Lemma 3.3.32 (Products and inverses of triangular matrices), Theorem 6.3.29 (Orthonormal columns), Exercise 6.3.57, Proposition 6.3.27 (Properties of the conjugate transpose)
Techniques. Uniqueness via two candidates (Technique 1.1.8)
Existence. By Theorem 6.4.15(d), Gram–Schmidt applied to skips nothing, and its output is orthonormal with
Let have columns , and let
Uniqueness. Suppose , where both pairs have the stated properties. An upper triangular matrix with nonzero diagonal entries is invertible with upper triangular inverse, whose diagonal entries are : write with the diagonal matrix of the and unit upper triangular, and apply Lemma 3.3.32 to get . So is upper triangular with diagonal entries , again by Lemma 3.3.32. Multiplying on the right by gives . Since and have orthonormal columns, Theorem 6.3.29 and Proposition 6.3.27 give
So the square matrix is unitary and upper triangular. By Exercise 6.3.57(c) it is diagonal with diagonal entries of modulus , and these entries are positive, so . Hence and . □
The factorization repackages several earlier facts. The columns of are an orthonormal basis of , so by Theorem 6.4.31. If is square, then is unitary, so
Example 6.4.39 (A QR factorization). Let have the columns , , of Example 6.4.17. The output of Gram–Schmidt was , , , and the entries of are the inner products
where
The diagonal entries , , are the lengths of the residuals, and their product is .
In floating-point arithmetic, Algorithm 6.4.14 as written can lose orthogonality badly when the columns are nearly dependent. Practical codes reorder the same computation (modified Gram–Schmidt) or build from reflections instead (Section 9.3).
Exercises
Exercise 6.4.40. In , let
- (a)Find an orthonormal basis of with Gram–Schmidt.
- (b)Find for , and .
- (c)Find .
Uses. Algorithm 6.4.14 (Gram–Schmidt), Remark 6.4.16 (Postponing the normalization), Corollary 6.4.10 (Projecting with an orthogonal list), Theorem 6.4.33 (Best approximation), Corollary 6.4.25 (Dimension of the orthogonal complement)
(a) By Remark 6.4.16 we may work with residuals. First , with . Next , so
with . Then and , so
with . No residual is , so is independent, and
is an orthonormal basis of (Theorem 6.4.15).
(b) We have ,
So
(c) By Corollary 6.4.25, . The vector is orthogonal to , , , which span , so it lies in (Proposition 6.3.9(c)). Hence
Uses. Theorem 6.4.31 (The matrix of an orthogonal projection), Corollary 6.4.10 (Projecting with an orthogonal list), Proposition 6.4.29 (The orthogonal projection as a linear map), Corollary 6.4.25 (Dimension of the orthogonal complement)
(a) Gram–Schmidt with residuals: , and
(b) The vector is orthogonal to and , so it lies in , which is a line by Corollary 6.4.25. So and, by Proposition 6.4.29(d),
The matrix is symmetric, and . For , by Theorem 6.4.31 there is nothing to check, but directly: the first row of times the columns of gives
Exercise 6.4.42. To project onto , where and , a student adds the shadows of on the two spanning vectors:
Find the error, show that the answer fails the test of Theorem 6.4.6, and compute correctly.
Uses. Corollary 6.4.10 (Projecting with an orthogonal list), Theorem 6.4.6 (The projection is characterized by orthogonality), Algorithm 6.4.14 (Gram–Schmidt)
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
The formula of Corollary 6.4.10 holds for orthogonal lists, and . The test of Theorem 6.4.6 detects the error: for , the vector
Gram–Schmidt turns into the orthogonal list ,
and
Uses. Algorithm 6.4.14 (Gram–Schmidt), Theorem 6.4.15 (Gram–Schmidt is correct), Remark 6.4.16 (Postponing the normalization)
With residuals (Remark 6.4.16): , . Then , and
which we replace by
So is skipped, and by Theorem 6.4.15(b) it lies in . Explicitly,
is an orthonormal basis of (Theorem 6.4.15(c)), whose dimension is therefore .
Uses. Theorem 6.4.33 (Best approximation), Example 6.4.19 (Legendre polynomials), Corollary 6.4.10 (Projecting with an orthogonal list)
Let . The polynomial functions of degree at most form a finite-dimensional subspace , and by Theorem 6.4.33 the closest one to is . By Example 6.4.19, ; ; and are orthogonal bases of , , , with squared norms , , . We need
where because is odd. By Corollary 6.4.10,
For the distances,
The best linear approximation is no better than the best constant, because is even and is odd. Allowing cuts the squared error by a factor of , although is not differentiable at and has no Taylor polynomial there.
Uses. Theorem 6.4.33 (Best approximation), Example 6.4.19 (Legendre polynomials), Exercise 6.3.49
Let be the space of polynomial functions of degree at most in with . The integral is with
By Example 6.4.19, , and the fourth Gram–Schmidt residual is
as computed in Exercise 6.3.49. (Calculus would set three partial derivatives to and solve a system; the orthogonal basis does that work once and for all.)
Exercise 6.4.46. Give the inner product
- (a)Apply Gram–Schmidt to , and show that the output is , , .
- (b)Find .
Uses. Algorithm 6.4.14 (Gram–Schmidt), Remark 6.4.16 (Postponing the normalization), Theorem 6.4.33 (Best approximation)
(a) Here
Next, and
Expanding,
The first two are the output of the lecture’s example.
(b) As ranges over , ranges over
Exercise 6.4.47. Let and be subspaces of .
- (a)Show that .
- (b)Suppose is finite-dimensional. Show that .
Uses. Definition 6.4.22 (Orthogonal complement), Proposition 1.4.24 (The sum of two subspaces), Theorem 6.4.26 (The double complement), Proposition 6.3.9 (Properties of )
Techniques. Double containment (Technique 1.3.14)
(a) Since and (Proposition 1.4.24), Proposition 6.3.9(b) gives and . Conversely, let . Every vector of is with and , and
So .
(b) Every subspace of the finite-dimensional space is finite-dimensional, so by Theorem 6.4.26. Apply (a) to the subspaces and :
Taking orthogonal complements of both sides and applying Theorem 6.4.26 to ,
as desired.
Exercise 6.4.48. Let be a finite-dimensional inner product space and subspaces of . Prove or disprove each statement.
- (a)If , then .
- (b)If every vector of is orthogonal to every vector of and , then .
- (c).
- (d)If , then .
- (e)Every with satisfies for all .
Uses. Theorem 6.4.24 (Orthogonal decomposition), Proposition 6.4.4 (Properties of ), Remark 6.4.12 (Why “orthogonal”), Definition 4.4.4 (Direct sum)
Techniques. Finding counterexamples and minimal examples (Technique 1.4.18)
(a) False. In , let and . Then and , so , but . Every subspace has many complements, and is only one of them.
(b) True. By hypothesis . Conversely, let , and write with and . Then
so and .
(c) False. With and as in (a),
(Exercise 6.4.58 shows when the two products agree.)
(d) True. By Proposition 6.4.4(e) applied to an orthonormal basis of , holds only if .
(e) False.
Exercise 6.4.49. Let and be finite-dimensional subspaces of .
- (a)Suppose every vector of is orthogonal to every vector of . Show that and .
- (b)Conversely, show that if , then every vector of is orthogonal to every vector of .
Uses. Theorem 6.4.6 (The projection is characterized by orthogonality), Proposition 6.4.29 (The orthogonal projection as a linear map), Proposition 1.4.24 (The sum of two subspaces), Theorem 6.4.20 (Orthonormal bases exist)
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
(a) Let and be orthonormal bases of and (Theorem 6.4.20). By hypothesis , so the concatenated list is orthonormal, and it spans . So is finite-dimensional and is defined. (In fact the formula of Definition 6.4.11 for this basis already gives the claim; we give the argument of Technique 6.4.7 instead.)
Let and
In the same way for . So is orthogonal to every , that is, to , and by Theorem 6.4.6.
The hypothesis says , and by Proposition 6.4.29(a). Since , we get for every .
(b) Let and . Then and , and by Proposition 6.4.29(c) for ,
Exercise 6.4.50. Find the error in the following argument, and decide whether the claim is true.
Claim. If and are finite-dimensional subspaces of , then .
Argument. Let and
Uses. Theorem 6.4.6 (The projection is characterized by orthogonality), Exercise 6.4.49
Techniques. Finding counterexamples and minimal examples (Technique 1.4.18)
The error is the assertion . All we know is that , and a vector of is orthogonal to only if, for instance, every vector of is orthogonal to every vector of .
The claim is false. Let in . Then , and
The argument becomes correct under the extra hypothesis that every vector of is orthogonal to every vector of , and then it proves Exercise 6.4.49(a).
Exercise 6.4.51. Let be a -dimensional subspace of , and let be the matrix of .
- (a)Show that .
- (b)Show that for each , and deduce that
. - (c)Deduce that some standard basis vector satisfies
.
Uses. Theorem 6.4.31 (The matrix of an orthogonal projection), Proposition 2.4.28 (Cyclicity of the trace), Proposition 6.4.29 (The orthogonal projection as a linear map), Theorem 6.4.33 (Best approximation), Theorem 6.4.20 (Orthonormal bases exist)
Techniques. Cyclicity of trace (Technique 2.4.29)
(a) By Proposition 6.4.29(a), the image of is , so . By Theorem 6.4.20, has an orthonormal basis, and by Theorem 6.4.31, with and . By Proposition 2.4.28,
(b) The th entry of is , so
(c) By Theorem 6.4.33,
Exercise 6.4.52. Let be a finite-dimensional subspace of and with .
(a)Show that
and find the attaining the maximum.
- (b)In with , find the largest value of over all with that are orthogonal to .
Uses. Theorem 6.4.24 (Orthogonal decomposition), Theorem 6.2.1 (Cauchy–Schwarz inequality), Definition 6.4.34 (Distance to a subspace), Exercise 6.4.45
Techniques. Apply Cauchy–Schwarz to a well-chosen inner product (Technique 6.2.21)
(a) Let , so and
For , which is a unit vector in , we get
(b) Let be the space of polynomial functions of degree at most . A function orthogonal to is orthogonal to (Proposition 6.3.9(c)), so we are maximizing over unit vectors . By (a) and Exercise 6.4.45, the maximum of is
So the distance from to can be computed in two dual ways: as a minimum over , or as a maximum over unit vectors of .
- (a)Let be a finite-dimensional subspace of , and let . Show that among the vectors of
, the one closest to is , and that it is unique. - (b)Find the solution of smallest norm of the system , in , and check that it is orthogonal to every solution of the homogeneous system.
Uses. Theorem 6.4.33 (Best approximation), Proposition 3.1.19 (Solution sets are translates of the kernel), Corollary 6.4.10 (Projecting with an orthogonal list)
(a) For ,
(b) Let . One solution is , and
using Corollary 6.4.10. Check: and ; the norm is ; and
Exercise 6.4.54. In with
- (a)Show that and .
- (b)Let and
. Show that is the unique even function closest to , although is infinite-dimensional.
Uses. Example 6.3.2 (Orthogonal vectors), Proposition 6.1.27 (Basic properties of the norm), Theorem 6.3.3 (Pythagorean theorem), Definition 6.4.22 (Orthogonal complement)
Every is with
(a) If is even and is odd, then is odd, so (Example 6.3.2(c)). This gives and . Conversely, let . Since ,
so (Proposition 6.1.27) and . Similarly, if , then
(b) Let . Then
with equality if and only if . So is the unique even function closest to . The proof of Theorem 6.4.33 only needed the decomposition into a part in and a part orthogonal to . For finite-dimensional subspaces that decomposition always exists (Theorem 6.4.24); here it exists for a reason specific to , and Exercise 6.4.63 shows that it need not exist in general.
- (a)Let and be orthonormal lists in with
for every . Show that for scalars with . - (b)Let be linearly independent. Show that the output of Gram–Schmidt is the only orthonormal list such that, for every ,
and is a positive real number.
Uses. Proposition 6.3.18 (Coordinates in an orthonormal basis), Theorem 6.4.15 (Gram–Schmidt is correct), Proposition 6.1.4 (Sesquilinearity), Proposition 6.1.27 (Basic properties of the norm)
Techniques. Take an inner product to isolate a coefficient (Technique 6.3.12)
(a) Fix . Since
For ,
(b) By Theorem 6.4.15(d), the output of Gram–Schmidt has both properties. Let be another orthonormal list with both properties. The two lists have the same spans , so by (a), with . By Proposition 6.1.4,
Both inner products are positive reals, so is a positive real number of modulus , that is, . Hence for every .
Uses. Theorem 6.4.33 (Best approximation), Example 6.4.19 (Legendre polynomials), Exercise 6.3.49
A polynomial of degree with leading coefficient is with , and every such difference is one. The space is finite-dimensional, so by Theorem 6.4.33, is smallest for exactly one , namely . When Gram–Schmidt is run on , the first outputs span
By Example 6.4.19, for the minimizer is , with (Example 6.3.17), and for it is , with squared norm (Exercise 6.3.49). So among all monic quadratics, is the smallest on in the mean-square sense.
- (i) is an orthogonal projection, that is, ;
- (ii)every vector of is orthogonal to every vector of ;
- (iii) for every .
Uses. Proposition 6.4.29 (The orthogonal projection as a linear map), Proposition 6.4.4 (Properties of ), Theorem 6.4.6 (The projection is characterized by orthogonality), Proposition 6.1.29 (Expanding a norm)
Techniques. Recognize a projection by its two conditions (Technique 6.4.7), Orthogonal decomposition (Technique 6.2.4), Proving TFAE (Technique 2.7.1)
We prove (i) (iii) (ii) (i).
(i) (iii). This is Proposition 6.4.4(e), applied to an orthonormal basis of .
(iii) (ii). Let and ; we may assume . Write ; then
Combined with , this gives , so .
(ii) (i). Let , which is finite-dimensional. For , , and
So an idempotent operator fails to be an orthogonal projection exactly when it stretches some vector, as the map in Exercise 6.4.48(e) does.
Uses. Proposition 6.4.30 (Recognizing orthogonal projections), Proposition 6.4.29 (The orthogonal projection as a linear map), Proposition 6.1.37 (Inner products distinguish vectors)
Techniques. Recognize a projection by its two conditions (Technique 6.4.7)
For all , Proposition 6.4.29(c), applied first to and then to , gives
Suppose . Then
Conversely, suppose is an orthogonal projection. By Proposition 6.4.30,
Exercise 6.4.48(c) gives two subspaces for which is not an orthogonal projection. The commuting case includes , where , and , where (Exercise 6.4.49).
Exercise 6.4.59. Let be linearly independent in , with Gram matrix (Definition 6.3.28). Run Gram–Schmidt, with residuals and output , and let have entries
- (a)Show that is upper triangular with diagonal entries , and that .
- (b)Deduce that
, and that , where is the Gram matrix of and . - (c)(Hadamard’s inequality.) Show that
, with equality if and only if the list is orthogonal. Deduce that for every with columns .
Uses. Theorem 6.4.15 (Gram–Schmidt is correct), Theorem 6.3.22 (Parseval’s identity), Proposition 5.3.15 (Triangular matrices), Theorem 5.4.10 (Multiplicativity), Exercise 6.3.57, Technique 6.4.5 (Projections shrink norms), Theorem 6.3.29 (Orthonormal columns), Theorem 5.4.7 (Invertibility and the determinant), Proposition 6.4.29 (The orthogonal projection as a linear map)
Techniques. Gram matrices (Technique 6.3.31)
(a) Let
(b) By Theorem 5.4.10 and Exercise 6.3.57(a),
(c) Write
For : if its columns are dependent, then is not invertible and (Theorem 5.4.7), and there is nothing to prove. Otherwise, by Theorem 6.3.29, is the Gram matrix of the columns, so
Exercise 6.4.60. Let be finite-dimensional, and let be subspaces of with
Show that every vector of is orthogonal to every vector of for , and that every can be written in exactly one way as with .
Uses. Proposition 6.4.29 (The orthogonal projection as a linear map), Proposition 6.1.27 (Basic properties of the norm)
Techniques. A sum of nonnegative terms (Technique 6.1.9), Projections shrink norms (Technique 6.4.5)
Write . For every , by the hypothesis and Proposition 6.4.29(c),
Now let . Then , so the identity reads
For , the hypothesis gives with . If also with , apply : for ,
For example, if is an orthonormal basis of , then
Uses. Lemma 6.1.14 (Nonnegative functions with zero integral), Proposition 7.1.22 (Counting roots), the intermediate value theorem
Techniques. Extremal choice and minimal counterexamples (Technique 1.5.9)
The polynomial is nonzero, so it has at most roots (Proposition 7.1.22). Let be its roots in , and put , . On each open interval , has no root, so by the intermediate value theorem it has constant sign there. Say that changes sign at () if its signs on and differ, and let be the roots at which changes sign. Let
( if ). Each factor changes sign at and nowhere else, so has constant sign on each interval and changes sign exactly at . Hence the product has constant sign on each , and at each either both factors change sign or neither does, so has the same sign on all of these intervals. Replacing by if necessary, on by continuity.
Suppose . Then , so
The argument used only that is continuous, has finitely many zeros in , and is orthogonal to all polynomials of degree less than . So it applies to the error of Example 6.4.37 with : that error has at most three zeros (see the remark after Example 6.4.37), and therefore changes sign at least three times in .
Uses. Corollary 6.4.25 (Dimension of the orthogonal complement), Corollary 6.4.10 (Projecting with an orthogonal list), Proposition 6.4.4 (Properties of )
Techniques. Induction on the length of a list (Technique 1.6.9), Orthogonal decomposition (Technique 6.2.4)
We prove, by induction on , the following statement: if is an -dimensional subspace of (for some ) and satisfy for all , then . The case is the claim.
If , then and , so there is no pair , and .
Let , and assume the statement for -dimensional subspaces. If there is nothing to prove, so let . Every is nonzero, since for some . Let
By Corollary 6.4.10 and Proposition 6.4.4(b),
because and . So are vectors in the -dimensional space with pairwise negative inner products, and the induction hypothesis gives , that is, .
For an example with , let ,
The proof is an induction on dimension in which projecting onto a hyperplane preserves the hypothesis. The triangularization theorems of Section 7.5 are proved by the same pattern (Technique 7.5.12).
Exercise 6.4.63. Give the inner product
- (a)Show that is a subspace with , but .
- (b)Deduce that and .
- (c)Show that no vector of is closest to the constant polynomial , although .
Uses. Definition 1.2.13 (Polynomials), Definition 1.2.17 (Evaluation), Proposition 1.2.18 (Degree and evaluation versus the operations), Proposition 6.3.9 (Properties of ), Theorem 6.4.24 (Orthogonal decomposition)
Techniques. Finding counterexamples and minimal examples (Technique 1.4.18)
(a) For each only finitely many are nonzero, so the sum is finite. It is symmetric and linear in each slot, and
Let . For each , the polynomial vanishes at , so it lies in , and
So . Since for all large , every coefficient is , and . Hence .
(b) , so is not . And
(c) Let
So . But , so for every . If some were closest to , then
Exercise 6.4.64. Let .
- (a)Find the QR factorization of .
- (b)Use it to find .
- (c)Check that .
Uses. Theorem 6.4.38 (QR factorization), Theorem 6.4.31 (The matrix of an orthogonal projection), Algorithm 6.4.14 (Gram–Schmidt)
(a) Let and . Then , so and . Next
(b) The columns of are an orthonormal basis of , so by Theorem 6.4.31,
(c)
More practice
The practice bank has 38 exercises on this section’s topics.