The Gram-Schmidt process
A subspace comes with a basis whose vectors lean on one another. How do you trade it for a perpendicular basis of the same subspace, and what does the trade record about the vectors you started with?
Where you are 3 in Orthogonality and least squares
When you reach for it
Meseret, Biruk and Kidist run a robotics lab. Their camera rig reports a position as amounts along three sensor axes which, in the lab’s calibration frame (units of decimeters), are
The axes are skewed: \mathbf{x}_1 \cdot \mathbf{x}_2 = 9 \neq 0. A reading (c_1, c_2, c_3) means the point c_1\mathbf{x}_1 + c_2\mathbf{x}_2 + c_3\mathbf{x}_3, so turning a point into a reading means solving a system. Along perpendicular unit axes, each coordinate would be one dot product. The team wants perpendicular axes that keep the first new axis along \mathbf{x}_1 and the first two in the plane of \mathbf{x}_1 and \mathbf{x}_2.
Reach for the Gram-Schmidt process whenever a subspace W of \mathbb{R}^n is given by a basis, or any spanning list, and an orthogonal or orthonormal basis of W is needed: to project onto W (Orthogonal bases and projection onto a subspace), to read off coordinates by dot products, or to factor A = QR. That lesson’s last example repaired a basis of a plane with one subtraction; here the subtraction is repeated for any number of vectors, with a proof that it always works.
The procedure
Subtract the projections onto what is already built
Let \mathbf{x}_1, \dots, \mathbf{x}_p be a basis of a subspace W of \mathbb{R}^n. Keep the first vector, and from each later vector remove its projections onto the new vectors already built:
for k = 2, \dots, p.
Write X_k = \operatorname{span}\{\mathbf{x}_1, \dots, \mathbf{x}_k\}. Once \mathbf{v}_1, \dots, \mathbf{v}_{k-1} are known to be an orthogonal basis of X_{k-1}, the subtracted sum is exactly \operatorname{proj}_{X_{k-1}} \mathbf{x}_k, so
the residual of \mathbf{x}_k, which is orthogonal to X_{k-1} by the orthogonal decomposition theorem of Orthogonal bases and projection onto a subspace. Each step keeps the part of \mathbf{x}_k that is new. The figure shows one step in the plane.
For an orthonormal basis, divide each vector by its length: \mathbf{q}_k = \mathbf{v}_k / \lVert \mathbf{v}_k \rVert. Any \mathbf{v}_i may be replaced by a nonzero multiple partway through, to clear fractions, because a projection onto a line does not depend on which vector of the line is used (Exercise 8).
Why it works
Theorem 1 (Gram-Schmidt). If \mathbf{x}_1, \dots, \mathbf{x}_p is a basis of W, then \mathbf{v}_1, \dots, \mathbf{v}_p are nonzero and orthogonal, and for every k,
So \{\mathbf{v}_1, \dots, \mathbf{v}_p\} is an orthogonal basis of W, and \{\mathbf{q}_1, \dots, \mathbf{q}_p\} is an orthonormal basis of W.
Proof, by induction on k. For k = 1: \mathbf{v}_1 = \mathbf{x}_1 is nonzero because a vector of an independent set is never \mathbf{0}, and the two spans are the same line.
Now suppose \mathbf{v}_1, \dots, \mathbf{v}_{k-1} are nonzero, orthogonal, and span X_{k-1}. The denominators \mathbf{v}_i \cdot \mathbf{v}_i are positive, so \mathbf{v}_k is defined.
In X_k: each \mathbf{v}_i with i < k lies in X_{k-1} \subseteq X_k, and so does \mathbf{x}_k, so their combination \mathbf{v}_k does. Nonzero: if \mathbf{v}_k = \mathbf{0}, then \mathbf{x}_k equals the subtracted combination, so it lies in X_{k-1}, against the independence of the \mathbf{x}’s (Linear independence). Orthogonal: dot the definition with \mathbf{v}_j, j < k. Every \mathbf{v}_i \cdot \mathbf{v}_j with i \neq j is 0 by the hypothesis, which leaves
Same span: \mathbf{v}_1, \dots, \mathbf{v}_k are k nonzero orthogonal vectors, hence independent (Orthogonal bases and projection onto a subspace), inside the k-dimensional space X_k, so they span it (Basis and dimension).
That completes the induction. \square
Moving the subtracted terms to the other side gives
each old vector is its new vector plus earlier new vectors. That triangular pattern is the QR factorization below.
When the list is dependent
The same formulas can be run on a list that spans W but may not be independent. Suppose \mathbf{v}_1, \dots, \mathbf{v}_{k-1} have come out nonzero, so they are an orthogonal basis of X_{k-1}. Then \mathbf{v}_k = \mathbf{0} exactly when \mathbf{x}_k lies in X_{k-1}. If \mathbf{v}_k = \mathbf{0}, then \mathbf{x}_k equals its projection, which lies in X_{k-1}. If \mathbf{x}_k lies in X_{k-1}, its projection onto X_{k-1} is \mathbf{x}_k itself, by the weights formula for an orthogonal basis, so \mathbf{v}_k = \mathbf{0}.
So a zero vector says that \mathbf{x}_k adds nothing to the span so far. Drop it and continue with \mathbf{x}_{k+1}, which is the run on the shorter list. The nonzero \mathbf{v}’s form an orthogonal basis of the span of the whole list, and their number is its dimension.
The order matters, the spans do not
Since \mathbf{v}_1 = \mathbf{x}_1, listing the vectors in another order generally gives another orthogonal basis of W. What does not change: \mathbf{v}_k = \mathbf{x}_k - \operatorname{proj}_{X_{k-1}} \mathbf{x}_k depends only on \mathbf{x}_k and the subspace X_{k-1}, and a projection does not depend on which orthogonal basis of the subspace computes it. So reordering the first k - 1 vectors leaves \mathbf{v}_k, and every vector after it, unchanged (Exercise 20).
The QR factorization
Theorem 2 (QR factorization). Let A be an n \times p matrix with independent columns \mathbf{x}_1, \dots, \mathbf{x}_p, and let \mathbf{q}_1, \dots, \mathbf{q}_p be the orthonormal basis of its column space given by the Gram-Schmidt process. Let Q be the n \times p matrix with columns \mathbf{q}_1, \dots, \mathbf{q}_p, and R the p \times p matrix with entries r_{ij} = \mathbf{q}_i \cdot \mathbf{x}_j for i \leq j and 0 below the diagonal. Then
R is upper triangular with diagonal entries r_{kk} = \lVert \mathbf{v}_k \rVert > 0, and R is invertible.
Proof. By Theorem 1, \mathbf{x}_j lies in \operatorname{span}\{\mathbf{q}_1, \dots, \mathbf{q}_j\}, and the weights in an orthonormal basis are single dot products (Orthogonal bases and projection onto a subspace), so \mathbf{x}_j = r_{1j}\mathbf{q}_1 + \dots + r_{jj}\mathbf{q}_j. Column j of QR is Q times column j of R, the combination of the columns of Q with weights r_{1j}, \dots, r_{jj}, 0, \dots, 0 (Matrix multiplication), which is \mathbf{x}_j. So QR = A, and the zeros below the diagonal come from \mathbf{x}_j needing only \mathbf{q}_1, \dots, \mathbf{q}_j. For the diagonal, \mathbf{x}_k is \mathbf{v}_k plus a combination of \mathbf{v}_1, \dots, \mathbf{v}_{k-1}, each orthogonal to \mathbf{q}_k, so r_{kk} = \mathbf{q}_k \cdot \mathbf{v}_k = \lVert \mathbf{v}_k \rVert, positive since \mathbf{v}_k \neq \mathbf{0}. The determinant of a triangular matrix is the product of its diagonal entries (Properties of determinants: row operations, products, transposes), here nonzero, so R is invertible (The invertible matrix theorem). Finally Q^{T}Q = I_p because the columns are orthonormal, so Q^{T}A = Q^{T}QR = R. \square
When A is square, Q is square with Q^{T}Q = I, so Q^{-1} = Q^{T}, and
a triangular system solved from the bottom row up.
Worked examples
Day 1: one step in the plane
Apply the process to \mathbf{x}_1 = (6, 2) and \mathbf{x}_2 = (2, 4), and turn the result into an orthonormal basis of \mathbb{R}^2.
SolutionKeep \mathbf{v}_1 = \mathbf{x}_1. Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 12 + 8 = 20 and \mathbf{v}_1 \cdot \mathbf{v}_1 = 40, the projection of \mathbf{x}_2 onto the line L through \mathbf{x}_1 is \displaystyle \frac{20}{40}(6, 2) = (3, 1), and
Check: \mathbf{v}_2 \cdot \mathbf{v}_1 = -6 + 6 = 0. In the figure, \mathbf{v}_2 is the perpendicular from L to the tip of \mathbf{x}_2, moved to the origin. Two nonzero orthogonal vectors in \mathbb{R}^2 are a basis of it. The lengths are \displaystyle \lVert \mathbf{v}_1 \rVert = \sqrt{40} = 2\sqrt{10} and \displaystyle \lVert \mathbf{v}_2 \rVert = \sqrt{10}, so
Day 1: straightening the sensor axes
Apply the process to the rig’s axes \mathbf{x}_1 = (2, 2, 1), \mathbf{x}_2 = (3, 0, 3), \mathbf{x}_3 = (7, 1, 2). Give the orthonormal axes, and find the coordinates of the point \mathbf{p} = (12, 3, 6) along them.
SolutionKeep \mathbf{v}_1 = (2, 2, 1), with \mathbf{v}_1 \cdot \mathbf{v}_1 = 9. Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 6 + 0 + 3 = 9,
and \mathbf{v}_2 \cdot \mathbf{v}_1 = 2 - 4 + 2 = 0, \mathbf{v}_2 \cdot \mathbf{v}_2 = 9. Next \mathbf{x}_3 \cdot \mathbf{v}_1 = 14 + 2 + 2 = 18 and \mathbf{x}_3 \cdot \mathbf{v}_2 = 7 - 2 + 4 = 9, so
Check: \mathbf{v}_3 \cdot \mathbf{v}_1 = 4 - 2 - 2 = 0 and \mathbf{v}_3 \cdot \mathbf{v}_2 = 2 + 2 - 4 = 0. Each \mathbf{v}_i has length 3, so the straightened axes are \displaystyle \mathbf{q}_i = \frac{1}{3}\mathbf{v}_i. By Theorem 1 they keep the first axis and the first plane, as the team wanted.
Coordinates along an orthonormal basis are dot products: \displaystyle \mathbf{q}_1 \cdot \mathbf{p} = \frac{1}{3}(24 + 6 + 6) = 12, \displaystyle \mathbf{q}_2 \cdot \mathbf{p} = \frac{1}{3}(12 - 6 + 12) = 6 and \displaystyle \mathbf{q}_3 \cdot \mathbf{p} = \frac{1}{3}(24 - 3 - 12) = 3. So \mathbf{p} = 12\mathbf{q}_1 + 6\mathbf{q}_2 + 3\mathbf{q}_3, and indeed (8, 8, 4) + (2, -4, 4) + (2, -1, -2) = (12, 3, 6).
Day 1: three vectors in \mathbb{R}^4
Find an orthogonal basis and an orthonormal basis of W = \operatorname{span}\{\mathbf{x}_1, \mathbf{x}_2, \mathbf{x}_3\} in \mathbb{R}^4, where \mathbf{x}_1 = (1, 1, 1, 1), \mathbf{x}_2 = (5, 3, 1, 3), \mathbf{x}_3 = (3, 1, 1, 3).
SolutionKeep \mathbf{v}_1 = (1, 1, 1, 1), with \mathbf{v}_1 \cdot \mathbf{v}_1 = 4. Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 12,
with \mathbf{v}_2 \cdot \mathbf{v}_1 = 0 and \mathbf{v}_2 \cdot \mathbf{v}_2 = 8. Next \mathbf{x}_3 \cdot \mathbf{v}_1 = 8 and \mathbf{x}_3 \cdot \mathbf{v}_2 = 6 - 2 = 4, so
Check: \mathbf{v}_3 \cdot \mathbf{v}_1 = -1 + 1 = 0 and \mathbf{v}_3 \cdot \mathbf{v}_2 = 0. No vector came out zero, so the three \mathbf{x}’s are independent and \dim W = 3. The lengths are 2, \displaystyle 2\sqrt{2} and \displaystyle \sqrt{2}, so the orthonormal basis is
Day 2: the QR factorization of a 4 \times 3 matrix
Factor A = QR, where A is the 4 \times 3 matrix with columns \mathbf{x}_1 = (1, 1, 1, 1), \mathbf{x}_2 = (5, 3, 1, 3), \mathbf{x}_3 = (3, 1, 1, 3) from the previous example.
SolutionThe columns of Q are the \mathbf{q}_i already found. The entries of R are r_{ij} = \mathbf{q}_i \cdot \mathbf{x}_j for i \leq j: \displaystyle r_{11} = \frac{4}{2} = 2, \displaystyle r_{12} = \frac{12}{2} = 6, \displaystyle r_{13} = \frac{8}{2} = 4, then \displaystyle r_{22} = \frac{5 - 1}{\sqrt{2}} = 2\sqrt{2}, \displaystyle r_{23} = \frac{3 - 1}{\sqrt{2}} = \sqrt{2}, and \displaystyle r_{33} = \frac{-1 + 3}{\sqrt{2}} = \sqrt{2}. So
The diagonal \displaystyle 2, 2\sqrt{2}, \sqrt{2} is the list of lengths of \mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3, as Theorem 2 says, and \displaystyle \det R = 2 \cdot 2\sqrt{2} \cdot \sqrt{2} = 8 \neq 0. Column check: \displaystyle 6\mathbf{q}_1 + 2\sqrt{2}\,\mathbf{q}_2 = (3, 3, 3, 3) + (2, 0, -2, 0), which is (5, 3, 1, 3). Here Q^{T}Q = I_3, while QQ^{T} is the projection matrix onto W, not I_4.
Day 2: reading the rig through QR
Kidist needs the rig reading (c_1, c_2, c_3) of the target point \mathbf{p} = (13, 4, 2), that is, the solution of A\mathbf{c} = \mathbf{p} where A has the sensor axes (2, 2, 1), (3, 0, 3), (7, 1, 2) as columns. Factor A = QR and solve.
SolutionFrom the sensor example, Q has columns \displaystyle \frac{1}{3}(2, 2, 1), \displaystyle \frac{1}{3}(1, -2, 2), \displaystyle \frac{1}{3}(2, -1, -2). The dot products give r_{11} = 3, \displaystyle r_{12} = \frac{6 + 3}{3} = 3, \displaystyle r_{13} = \frac{14 + 2 + 2}{3} = 6, \displaystyle r_{22} = \frac{3 + 6}{3} = 3, \displaystyle r_{23} = \frac{7 - 2 + 4}{3} = 3 and \displaystyle r_{33} = \frac{14 - 1 - 4}{3} = 3:
Q is square with orthonormal columns, so A\mathbf{c} = \mathbf{p} becomes R\mathbf{c} = Q^{T}\mathbf{p}, where Q^{T}\mathbf{p} is \displaystyle \frac{1}{3}(26 + 8 + 2, 13 - 8 + 4, 26 - 4 - 4), that is, (12, 3, 6). From the bottom row up: 3c_3 = 6 gives c_3 = 2; 3c_2 + 3c_3 = 3 gives c_2 = -1; 3c_1 + 3c_2 + 6c_3 = 12 gives 3c_1 = 3, so c_1 = 1. The reading is (1, -1, 2). Check: (2, 2, 1) - (3, 0, 3) + 2(7, 1, 2) = (13, 4, 2).
Day 2: a list with a redundant vector
Biruk logs four direction vectors in a rig test: (1, 1, -1), (2, 3, 2), (1, 0, -5), (0, 1, 0). Run the process in this order to find an orthogonal basis of their span.
SolutionKeep \mathbf{v}_1 = (1, 1, -1), with \mathbf{v}_1 \cdot \mathbf{v}_1 = 3. Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 3, \mathbf{v}_2 = (2, 3, 2) - (1, 1, -1) = (1, 2, 3), with \mathbf{v}_2 \cdot \mathbf{v}_1 = 0 and \mathbf{v}_2 \cdot \mathbf{v}_2 = 14. For the third vector, \mathbf{x}_3 \cdot \mathbf{v}_1 = 1 + 5 = 6 and \mathbf{x}_3 \cdot \mathbf{v}_2 = 1 - 15 = -14:
So (1, 0, -5) lies in the span of the first two. The computation even says how: \mathbf{x}_3 = 2\mathbf{v}_1 - \mathbf{v}_2 = 2\mathbf{x}_1 - (\mathbf{x}_2 - \mathbf{x}_1) = 3\mathbf{x}_1 - \mathbf{x}_2, and (3, 3, -3) - (2, 3, 2) = (1, 0, -5). Drop it. For the fourth, \mathbf{x}_4 \cdot \mathbf{v}_1 = 1 and \mathbf{x}_4 \cdot \mathbf{v}_2 = 2:
Scale it to (-5, 4, -1); its dot products with \mathbf{v}_1 and \mathbf{v}_2 are -5 + 4 + 1 = 0 and -5 + 8 - 3 = 0. The orthogonal basis is \{(1, 1, -1), (1, 2, 3), (-5, 4, -1)\}: three nonzero orthogonal vectors, so the span is all of \mathbb{R}^3.
Day 2: the sensor axes in another order
Run the process on the sensor axes in the order \mathbf{x}_2, \mathbf{x}_1, \mathbf{x}_3 and compare with Example 2.
SolutionNow \mathbf{w}_1 = \mathbf{x}_2 = (3, 0, 3), with \mathbf{w}_1 \cdot \mathbf{w}_1 = 18. Since \mathbf{x}_1 \cdot \mathbf{w}_1 = 9, the next vector is \displaystyle (2, 2, 1) - \frac{1}{2}(3, 0, 3) = \left(\frac{1}{2}, 2, -\frac{1}{2}\right); scale it to \mathbf{w}_2 = (1, 4, -1). Then \mathbf{w}_2 \cdot \mathbf{w}_1 = 3 - 3 = 0 and \mathbf{w}_2 \cdot \mathbf{w}_2 = 18. With \mathbf{x}_3 \cdot \mathbf{w}_1 = 21 + 6 = 27 and \mathbf{x}_3 \cdot \mathbf{w}_2 = 7 + 4 - 2 = 9,
The first two vectors are new ((3, 0, 3) is not a multiple of (2, 2, 1) or of (1, -2, 2)), but they span the same plane: (3, 0, 3) = (2, 2, 1) + (1, -2, 2) and (1, 4, -1) = (2, 2, 1) - (1, -2, 2). The third vector is exactly the old \mathbf{v}_3, because it is \mathbf{x}_3 minus its projection onto that same plane. This order keeps the second sensor axis exactly instead of the first.
Boundaries
- Theorem 1 needs an independent list. On a dependent list a zero vector appears, and the next step would divide by 0 unless it is dropped (Example 6).
- The result depends on the order and on the starting basis; an orthogonal basis of a nonzero subspace is never unique. What the process fixes is \operatorname{span}\{\mathbf{v}_1, \dots, \mathbf{v}_k\} = X_k at every stage.
- Theorem 2 needs independent columns: that is what makes every r_{kk} positive and R invertible.
- With rounded computer arithmetic, the formulas as written can lose orthogonality on nearly dependent vectors; numerical software rearranges them.
Where this goes next
Every subspace of \mathbb{R}^n now has an orthogonal basis, so the projection formula of Orthogonal bases and projection onto a subspace always applies, and QQ^{T} is the projection matrix onto the column space of A. Running the process on a basis of W extended to \mathbb{R}^n also gives an orthogonal basis of W^{\perp} (Exercise 19). When A\mathbf{x} = \mathbf{b} has no exact solution, the factorization A = QR is one route to the best approximate one, taken up in Least squares: the best approximate solution of Ax = b.
Exercises
Day 1: running the process
- Apply the process to \mathbf{x}_1 = (1, 2), \mathbf{x}_2 = (4, 3), and give an orthonormal basis of \mathbb{R}^2.
- Apply the process to (1, 1, 1), (2, 1, 3), (4, 0, 2) to get an orthogonal basis of \mathbb{R}^3.
- Turn the basis of Exercise 2 into an orthonormal basis.
- Find an orthogonal basis of W = \operatorname{span}\{(2, 0, 1, 2), (3, 1, 1, 1)\} in \mathbb{R}^4, then the projection of \mathbf{y} = (1, 3, 2, 1) onto W.
- The vectors (a, b, c) with a + b + c = 0 form a plane in \mathbb{R}^3 with basis (1, -1, 0), (1, 0, -1). Starting from that basis, find an orthonormal basis of the plane.
- Apply the process to (0, 3, 4), (5, 0, 0), (5, 7, 1), and give the orthonormal basis.
Day 1: reasoning
- Show that the process returns an orthogonal list of nonzero vectors unchanged.
- Show that replacing \mathbf{v}_k by c\mathbf{v}_k, c \neq 0, before computing the later vectors changes none of them. Conclude that normalizing as you go gives the same \mathbf{q}’s as normalizing at the end.
- Show that \lVert \mathbf{v}_k \rVert \leq \lVert \mathbf{x}_k \rVert, with equality exactly when \mathbf{x}_k is orthogonal to each of \mathbf{x}_1, \dots, \mathbf{x}_{k-1}.
- For independent \mathbf{x}_1, \mathbf{x}_2 in \mathbb{R}^2, explain why the parallelogram with sides \mathbf{x}_1 and \mathbf{x}_2 has area \lVert \mathbf{x}_1 \rVert \lVert \mathbf{v}_2 \rVert, and check it against the determinant for the vectors of Exercise 1.
Day 2: QR, dependence and order
- Find the QR factorization of \begin{bmatrix} 1 & 4 \\ 2 & 3 \end{bmatrix}.
- Find the QR factorization of the matrix whose columns are (1, 1, 1), (2, 1, 3), (4, 0, 2).
- With the factorization of Exercise 12, solve A\mathbf{x} = (4, 1, 1) by solving R\mathbf{x} = Q^{T}\mathbf{b}.
- Apply the process to (1, 0, 1), (0, 1, 1), (1, 1, 2). What does the result say about the third vector, and what is the dimension of the span?
- Apply the process to (4, 3), (1, 2), the vectors of Exercise 1 in the other order, and compare the two orthogonal bases.
- Find the QR factorization of the 4 \times 2 matrix with columns (1, 1, 1, 1) and (1, 2, 3, 6).
Day 2: reasoning
- For A = QR as in Theorem 2, show that R = Q^{T}A and A^{T}A = R^{T}R.
- For a square A with independent columns, show that \lvert \det A \rvert = r_{11}r_{22}\cdots r_{nn}, and check it on the sensor matrix of Example 5.
- Let \mathbf{x}_1, \dots, \mathbf{x}_p be a basis of W, extended to a basis \mathbf{x}_1, \dots, \mathbf{x}_n of \mathbb{R}^n. Show that the process gives \mathbf{v}_{p+1}, \dots, \mathbf{v}_n forming an orthogonal basis of W^{\perp}.
- Show that if \mathbf{x}_1, \dots, \mathbf{x}_{k-1} are reordered among themselves, then \mathbf{v}_k, \dots, \mathbf{v}_p do not change.
Answers
- \mathbf{v}_1 = (1, 2). Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 10 and \mathbf{v}_1 \cdot \mathbf{v}_1 = 5, \mathbf{v}_2 = (4, 3) - 2(1, 2) = (2, -1), and \mathbf{v}_2 \cdot \mathbf{v}_1 = 0. Both have length \displaystyle \sqrt{5}: \displaystyle \mathbf{q}_1 = \frac{1}{\sqrt{5}}(1, 2), \displaystyle \mathbf{q}_2 = \frac{1}{\sqrt{5}}(2, -1).
- \mathbf{v}_1 = (1, 1, 1). Then \mathbf{x}_2 \cdot \mathbf{v}_1 = 6, so \mathbf{v}_2 = (2, 1, 3) - 2(1, 1, 1) = (0, -1, 1). Then \mathbf{x}_3 \cdot \mathbf{v}_1 = 6 and \mathbf{x}_3 \cdot \mathbf{v}_2 = 2 with \mathbf{v}_2 \cdot \mathbf{v}_2 = 2, so \mathbf{v}_3 = (4, 0, 2) - 2(1, 1, 1) - (0, -1, 1), which is (2, -1, -1). The three pairwise dot products are 0.
- The lengths are \displaystyle \sqrt{3}, \displaystyle \sqrt{2}, \displaystyle \sqrt{6}: \displaystyle \frac{1}{\sqrt{3}}(1, 1, 1), \displaystyle \frac{1}{\sqrt{2}}(0, -1, 1), \displaystyle \frac{1}{\sqrt{6}}(2, -1, -1).
- \mathbf{v}_1 = (2, 0, 1, 2) with \mathbf{v}_1 \cdot \mathbf{v}_1 = 9, and \mathbf{x}_2 \cdot \mathbf{v}_1 = 9, so \mathbf{v}_2 = (1, 1, 0, -1). Then \mathbf{y} \cdot \mathbf{v}_1 = 6 and \mathbf{y} \cdot \mathbf{v}_2 = 3 with \mathbf{v}_2 \cdot \mathbf{v}_2 = 3, so \displaystyle \operatorname{proj}_W \mathbf{y} = \frac{2}{3}\mathbf{v}_1 + \mathbf{v}_2 = \left(\frac{7}{3}, 1, \frac{2}{3}, \frac{1}{3}\right). The residual \displaystyle \left(-\frac{4}{3}, 2, \frac{4}{3}, \frac{2}{3}\right) is orthogonal to both \mathbf{v}’s.
- \mathbf{v}_1 = (1, -1, 0); the coefficient is \displaystyle \frac{1}{2}, so \displaystyle \mathbf{v}_2 = (1, 0, -1) - \frac{1}{2}(1, -1, 0) = \left(\frac{1}{2}, \frac{1}{2}, -1\right), scaled to (1, 1, -2). Orthonormal basis: \displaystyle \frac{1}{\sqrt{2}}(1, -1, 0), \displaystyle \frac{1}{\sqrt{6}}(1, 1, -2). Both satisfy a + b + c = 0.
- \mathbf{v}_1 = (0, 3, 4). Since \mathbf{x}_2 \cdot \mathbf{v}_1 = 0, \mathbf{v}_2 = (5, 0, 0) unchanged. Then \mathbf{x}_3 \cdot \mathbf{v}_1 = 25 and \mathbf{x}_3 \cdot \mathbf{v}_2 = 25, each over 25, so \mathbf{v}_3 = (5, 7, 1) - (0, 3, 4) - (5, 0, 0) = (0, 4, -3). All three have length 5: \displaystyle \frac{1}{5}(0, 3, 4), (1, 0, 0), \displaystyle \frac{1}{5}(0, 4, -3).
- By induction, if \mathbf{v}_i = \mathbf{x}_i for i < k, then every coefficient \displaystyle \frac{\mathbf{x}_k \cdot \mathbf{x}_i}{\mathbf{x}_i \cdot \mathbf{x}_i} is 0 because the list is orthogonal, so \mathbf{v}_k = \mathbf{x}_k.
- The term for c\mathbf{v}_k in a later step is \displaystyle \frac{\mathbf{x}_j \cdot c\mathbf{v}_k}{c\mathbf{v}_k \cdot c\mathbf{v}_k}c\mathbf{v}_k = \frac{c^2}{c^2}\frac{\mathbf{x}_j \cdot \mathbf{v}_k}{\mathbf{v}_k \cdot \mathbf{v}_k}\mathbf{v}_k, the same as before. Normalizing as you go uses the positive multiples \mathbf{q}_k, so the later \mathbf{v}’s, and their unit vectors, are unchanged.
- \mathbf{x}_k = \mathbf{v}_k + \mathbf{h} with \mathbf{h} = \operatorname{proj}_{X_{k-1}} \mathbf{x}_k orthogonal to \mathbf{v}_k, so by the Pythagorean theorem \lVert \mathbf{x}_k \rVert^2 = \lVert \mathbf{v}_k \rVert^2 + \lVert \mathbf{h} \rVert^2 \geq \lVert \mathbf{v}_k \rVert^2. Equality holds exactly when \mathbf{h} = \mathbf{0}, that is, when \mathbf{x}_k is orthogonal to X_{k-1}, or equivalently to each of its spanning vectors \mathbf{x}_1, \dots, \mathbf{x}_{k-1}.
- With base \mathbf{x}_1, the height is the distance from the tip of \mathbf{x}_2 to the line through \mathbf{x}_1, the length of \mathbf{v}_2. For Exercise 1, \displaystyle \lVert \mathbf{x}_1 \rVert \lVert \mathbf{v}_2 \rVert = \sqrt{5} \cdot \sqrt{5} = 5, and \lvert 1 \cdot 3 - 4 \cdot 2 \rvert = 5.
- From Exercise 1, \displaystyle Q = \frac{1}{\sqrt{5}}\begin{bmatrix} 1 & 2 \\ 2 & -1 \end{bmatrix}. Then \displaystyle r_{11} = \sqrt{5}, \displaystyle r_{12} = \frac{10}{\sqrt{5}} = 2\sqrt{5}, \displaystyle r_{22} = \frac{8 - 3}{\sqrt{5}} = \sqrt{5}, so \displaystyle R = \begin{bmatrix} \sqrt{5} & 2\sqrt{5} \\ 0 & \sqrt{5} \end{bmatrix}. Check column 2: 2(1, 2) + (2, -1) = (4, 3).
- Q has the columns of Exercise 3. With \displaystyle r_{12} = r_{13} = \frac{6}{\sqrt{3}} = 2\sqrt{3}, \displaystyle r_{22} = \frac{-1 + 3}{\sqrt{2}} = \sqrt{2}, \displaystyle r_{23} = \frac{2}{\sqrt{2}} = \sqrt{2} and \displaystyle r_{33} = \frac{8 - 2}{\sqrt{6}} = \sqrt{6}: \displaystyle R = \begin{bmatrix} \sqrt{3} & 2\sqrt{3} & 2\sqrt{3} \\ 0 & \sqrt{2} & \sqrt{2} \\ 0 & 0 & \sqrt{6} \end{bmatrix}.
- \displaystyle Q^{T}\mathbf{b} = \left(\frac{6}{\sqrt{3}}, \frac{0}{\sqrt{2}}, \frac{6}{\sqrt{6}}\right) = (2\sqrt{3}, 0, \sqrt{6}). Bottom up: x_3 = 1; \displaystyle \sqrt{2}\,x_2 + \sqrt{2} = 0 gives x_2 = -1; \displaystyle \sqrt{3}\,x_1 - 2\sqrt{3} + 2\sqrt{3} = 2\sqrt{3} gives x_1 = 2. So \mathbf{x} = (2, -1, 1), and 2(1, 1, 1) - (2, 1, 3) + (4, 0, 2) = (4, 1, 1).
- \mathbf{v}_1 = (1, 0, 1); \displaystyle \mathbf{v}_2 = (0, 1, 1) - \frac{1}{2}(1, 0, 1), scaled to (-1, 2, 1). Then the coefficients are \displaystyle \frac{3}{2} and \displaystyle \frac{3}{6} = \frac{1}{2}, and \displaystyle \mathbf{v}_3 = (1, 1, 2) - \frac{3}{2}(1, 0, 1) - \frac{1}{2}(-1, 2, 1), which is (0, 0, 0). So the third vector lies in the span of the first two (it is their sum), the span has dimension 2, and \{(1, 0, 1), (-1, 2, 1)\} is an orthogonal basis of it.
- \mathbf{w}_1 = (4, 3); the coefficient is \displaystyle \frac{10}{25} = \frac{2}{5}, so \displaystyle \mathbf{w}_2 = (1, 2) - \left(\frac{8}{5}, \frac{6}{5}\right) = \left(-\frac{3}{5}, \frac{4}{5}\right), scaled to (-3, 4). The basis \{(4, 3), (-3, 4)\} differs from \{(1, 2), (2, -1)\} of Exercise 1 (no vector of one is a multiple of a vector of the other), yet both are orthogonal bases of \mathbb{R}^2.
- \mathbf{v}_1 = (1, 1, 1, 1); the coefficient is \displaystyle \frac{12}{4} = 3, so \mathbf{v}_2 = (-2, -1, 0, 3) with length \displaystyle \sqrt{14}. So \displaystyle \mathbf{q}_1 = \frac{1}{2}(1, 1, 1, 1), \displaystyle \mathbf{q}_2 = \frac{1}{\sqrt{14}}(-2, -1, 0, 3), and r_{11} = 2, \displaystyle r_{12} = \frac{12}{2} = 6, \displaystyle r_{22} = \frac{-2 - 2 + 18}{\sqrt{14}} = \sqrt{14}: \displaystyle R = \begin{bmatrix} 2 & 6 \\ 0 & \sqrt{14} \end{bmatrix}.
- The columns of Q are orthonormal, so Q^{T}Q = I_p and Q^{T}A = Q^{T}QR = R. Then A^{T}A = (QR)^{T}QR = R^{T}Q^{T}QR = R^{T}R, using (QR)^{T} = R^{T}Q^{T} (The transpose and symmetric matrices).
- Here Q is square with Q^{T}Q = I, so \det(Q^{T})\det Q = 1, and since \det Q^{T} = \det Q, (\det Q)^2 = 1. Then \det A = \det Q \det R = \pm r_{11}\cdots r_{nn}, and the r_{kk} are positive. For the sensor matrix, r_{11}r_{22}r_{33} = 27, and expanding along the first row, 2(0 - 3) - 3(4 - 1) + 7(6 - 0) = 27.
- Each \mathbf{v}_j with j > p is orthogonal to \mathbf{v}_1, \dots, \mathbf{v}_p, which span W, so it lies in W^{\perp}. They are nonzero and orthogonal, so independent. Any \mathbf{z} in W^{\perp}, written in the orthogonal basis \mathbf{v}_1, \dots, \mathbf{v}_n of \mathbb{R}^n, has weight \displaystyle \frac{\mathbf{z} \cdot \mathbf{v}_i}{\mathbf{v}_i \cdot \mathbf{v}_i} = 0 for i \leq p, so it is a combination of \mathbf{v}_{p+1}, \dots, \mathbf{v}_n.
- Reordering \mathbf{x}_1, \dots, \mathbf{x}_{k-1} changes neither X_{k-1} nor any later X_j. Each \mathbf{v}_j with j \geq k is \mathbf{x}_j - \operatorname{proj}_{X_{j-1}} \mathbf{x}_j, and by the uniqueness in the orthogonal decomposition theorem the projection does not depend on the orthogonal basis used.