MIT 18.06 Completed

Lecture 17 · Orthogonal matrices and Gram-Schmidt orthogonalization

Use Gram-Schmidt to turn a set of basis into an orthonormal basis and understand QR decomposition.

On this page

Orthogonal matrices and Gram-Schmidt | Gilbert Strang | MIT 18.06 Linear Algebra

Lecture 17 / Total 35 Lectures |Part 2 · Orthogonality and Determinant

Video of this lecture: Bilibili p17 · Orthogonal matrices and Gram-Schmidt orthogonalization ↗(49:25)| MIT OCW official page ↗

Illustration: MIT OCW 18.06SC official lecture summary (CC BY-NC-SA 4.0) and Bilibili classroom video frames (time stamped), about 10 frames per lecture.

Introduction to this lecture

The chapter on orthogonality concludes this lecture. We have dealt with two kinds of “orthogonality” before: two vectors inner product (inner product) is zero, and one subspace is perpendicular to another subspace everywhere (the row space and the null space are a pair). This lecture generalizes orthogonality from “two” to “a set”: If each vector in a set of bases is perpendicular to all other vectors, and each vector is reduced to length 11 The unit vector of , this group of basis is called orthonormal basis (orthonormal basis). Arrange orthonormal vectors in columns into a matrix QQ, you will get the cleanest equation in this chapter: QTQ=IQ^{\mathsf T}Q=I.

This lecture is divided into two halves. The first half explains why this equation is worth pursuing. projection matrix (projection matrix) was originally A(ATA)−1ATA(A^{\mathsf T}A)^{-1}A^{\mathsf T}, requires inversion; change to standard orthogonal QQ After that, the middle QTQQ^{\mathsf T}Q That’s it II, the projection matrix immediately degenerates into QQTQQ^{\mathsf T}.least squares The core equation of (least squares) ATAx^=ATbA^{\mathsf T}A\hat{\boldsymbol{x}}=A^{\mathsf T}\boldsymbol{b} Similarly degenerated, the left side becomes the identity matrix, and the solution is directly x^=QTb\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}——Each component is just an inner product, and no inversion is required. This is also why numerical linear algebra is largely organized around orthonormal vectors: the lengths are nailed to 11, the component will not get larger or smaller, nor will it overflow or underflow.

The second half solves “What to do if you don’t have an orthonormal basis in hand”. Given a set of linearly independent (linearly independent) vectors with arbitrary directions, Gram-Schmidt (Gram-Schmidt) Orthogonalization is corrected direction by direction: retain the first direction, subtract the component of the second vector along the first direction, then subtract the components of the third vector along the first two directions, and finally divide each vector by its own length. The whole process is written as a matrix A=QRA=QR: QQ The columns of are orthogonal, RR is upper triangular matrix (upper triangular matrix). This is the same as the elimination derivation A=LUA=LU At the same level - elimination makes the matrix into a triangle, and Gram-Schmidt makes the matrix into “an orthonormal column matrix multiplied by a triangular matrix”.

Official Handout Summary Page 1/3

MIT OCW Official Lecture Notes Summary Page 1/3 (18.06SC Lecture 17 Summary, CC BY-NC-SA 4.0).

1. Standard orthogonal vector group and QTQ=IQ^{\mathsf T}Q=I

The question to be answered in this section is: How to use a matrix equation to summarize “a set of vectors that are perpendicular to each other and have unit length”.

Let the vector group q1,q2,…,qn\boldsymbol{q}_1,\boldsymbol{q}_2,\dots,\boldsymbol{q}_n. It is customary to use letters qq Represents this family of vectors because it suggests that these vectors are orthogonal in pairs, rather than a bunch of vectors picked at random. Standard orthogonality contains two requirements, corresponding to two conditions:

qiTqj={0,i≠j,1,i=j.\boldsymbol{q}_i^{\mathsf T}\boldsymbol{q}_j= \begin{cases} 0, & i\neq j,\\ 1, & i=j. \end{cases}

The first one is orthogonal (orthogonal): The inner product of any two different vectors is zero and their directions are ninety degrees to each other. The second item is the unit length: qiTqi=∥qi∥2=1\boldsymbol{q}_i^{\mathsf T}\boldsymbol{q}_i=\|\boldsymbol{q}_i\|^2=1. A vector is of course not orthogonal to itself, so the diagonal position must be specified separately as 11; “Orthogonal” plus “unitized” are collectively called orthogonal (orthonormal). A basis that only satisfies the first condition is called an orthonormal basis, and a basis that satisfies both of the two is called a standard orthonormal basis; this lecture uses the latter.

put this nn vectors are put into the matrix one by one QQ of columns. QQ It doesn’t have to be a square matrix - for example, two orthogonal vectors placed in a four-dimensional space, QQ That’s it 4×24\times2 of. Calculate now QTQQ^{\mathsf T}Q: QTQ^{\mathsf T} of the ii OK qiT\boldsymbol{q}_i^{\mathsf T}, QQ of the jj Column is qj\boldsymbol{q}_j, so the product of (i,j)(i,j) element is qiTqj\boldsymbol{q}_i^{\mathsf T}\boldsymbol{q}_j. The above two conditions determine each position: on the diagonal is 11, the remaining positions are 00. So

QTQ=I.Q^{\mathsf T}Q=I .

This is a “row times column” multiplication: QTQQ^{\mathsf T}Q All the inner products were asked at once, and the standard positive answer was the best of all possible answers——identity matrix (identity matrix). Think back to the recurring theme in this chapter ATAA^{\mathsf T}A, which records exactly all the inner products between each column; QTQ=IQ^{\mathsf T}Q=I It shows that when the columns are orthogonal, this inner product table degenerates into its simplest form.

if QQ It is a square matrix, and the conclusion is stronger: QTQ=IQ^{\mathsf T}Q=I Description QTQ^{\mathsf T} That’s it QQ The inverse of QT=Q−1Q^{\mathsf T}=Q^{-1}. At this time, left multiplication and right multiplication are equal to II, QQT=IQQ^{\mathsf T}=I is also established. Note that this last one only applies to square array is established; the rectangular matrix only has QTQ=IQ^{\mathsf T}Q=I, while QQTQQ^{\mathsf T} No II.

There is an asymmetry in terminology worth noting: QQ When the columns of are orthogonal, the most appropriate name should be “orthogonal matrix”, but the agreement only refers to square array called orthogonal matrix (orthogonal matrix), the rectangular matrix only says “has standard orthogonal columns”. There is no mathematical reason for this habit. Just remember the conclusion: an orthogonal matrix must be a square matrix, and QTQ=QQT=IQ^{\mathsf T}Q=QQ^{\mathsf T}=I.

There is also a basic fact: orthonormal vectors must be linearly independent. If a certain combination c1q1+⋯+cnqn=0c_1\boldsymbol{q}_1+\cdots+c_n\boldsymbol{q}_n=\boldsymbol{0}, use it with qi\boldsymbol{q}_i Do inner product, divide cic_i Everything except that term disappears due to orthogonality, leaving only ci=0c_i=0. Every coefficient must be zero, and the set of vectors is irrelevant. So “orthogonal” is stronger than “irrelevant”: it guarantees independence, and additionally controls the length and angle.

Video 00:04:56: Classroom blackboard writing

Video 00:04:56|Approximately corresponding to Section 1 “1. Standard orthogonal vector group and QTQ=IQ^{\mathsf T}Q=I“Nearby.

Video 00:09:17: Classroom blackboard writing

Video 00:09:17|Approximately corresponding to Section 1 “1. Standard orthogonal vector group and QTQ=IQ^{\mathsf T}Q=I“Nearby.

2. Several examples that must be remembered

The purpose of this section is to use specific matrices to implement the definition in the previous section, and at the same time accumulate models that will be used repeatedly later.

The simplest source is permutation matrix (permutation matrix): only one per row and column 11, the rest are all zero. For example

Q=[001100010].Q=\begin{bmatrix}0&0&1\\1&0&0\\0&1&0\end{bmatrix}.

Its three columns are e2,e3,e1\boldsymbol{e}_2,\boldsymbol{e}_3,\boldsymbol{e}_1, are all unit vectors and the inner product of each pair is zero, so they are orthogonal matrices. Its transpose is another permutation matrix and therefore also orthonormal. Use one column 11 Of course it is too easy to create a standard orthogonal column, but it illustrates an important point: standard orthogonality only requires direction and length, and does not require the vector to be “complex”.

The second source is “a unit vector plus its vertical direction” in the plane. Any angle θ\theta,

Q=[cos⁡θ−sin⁡θsin⁡θcos⁡θ].Q=\begin{bmatrix}\cos\theta&-\sin\theta\\ \sin\theta&\cos\theta\end{bmatrix}.

first column (cos⁡θ,sin⁡θ)(\cos\theta,\sin\theta) satisfy cos⁡2θ+sin⁡2θ=1\cos^2\theta+\sin^2\theta=1, is the unit vector; the second column (−sin⁡θ,cos⁡θ)(-\sin\theta,\cos\theta) Likewise. The inner product of two columns is −cos⁡θsin⁡θ+sin⁡θcos⁡θ=0-\cos\theta\sin\theta+\sin\theta\cos\theta=0, so they are perpendicular to each other. put θ=π4\theta=\frac{\pi}{4} Substitute it in and make some sign adjustments, and you get the simplest non-trivial example:

[111−1].\begin{bmatrix}1&1\\1&-1\end{bmatrix}.

Its two columns are indeed perpendicular, but the square length of each column is 12+12=21^2+1^2=2, the length is 2\sqrt2, so it is not an orthogonal matrix yet. The correction is simply to divide the whole by 2\sqrt2:

Q=12[111−1].Q=\frac{1}{\sqrt2}\begin{bmatrix}1&1\\1&-1\end{bmatrix}.

This sequence of “first laying out the vertical direction, and finally dividing it by the length” is exactly the general structure of Gramm-Schmidt later.

The third source contains only ±1\pm1 matrix, called Hadamard matrix. The fourth-order example is to repeat the pattern of the previous second-order matrix and then negative one of the entire blocks:

Q=12[11111−11−111−1−11−1−11].Q=\frac12\begin{bmatrix} 1&1&1&1\\ 1&-1&1&-1\\ 1&1&-1&-1\\ 1&-1&-1&1 \end{bmatrix}.

Randomly check several pairs of columns: the inner product of the first column and the second column is 1−1+1−1=01-1+1-1=0;The first and third columns are 1+1−1−1=01+1-1-1=0;The second and third columns are 1−1−1+1=01-1-1+1=0. Each column has four ±1\pm1, the length squared is 44, divided by 22 Then the length is exactly 11. All these elements are ±1\pm1 the orthogonal matrix, 22 level, 44 level, 1616 level, 6464 Hierarchical situations people know how to construct; 55 Orders cannot exist; there are still some orders that no one knows whether they exist.

The fourth source is the orthonormal column of rectangles, which is the shape that projection and least squares really encounter. Take two vectors in three-dimensional space

[122],[−2−12].\begin{bmatrix}1\\2\\2\end{bmatrix}, \qquad \begin{bmatrix}-2\\-1\\2\end{bmatrix}.

Their inner product is −2−2+4=0-2-2+4=0, the square of each length is 1+4+4=91+4+4=9, the length is 33. Therefore

Q=13[1−22−122]Q=\frac13\begin{bmatrix}1&-2\\2&-1\\2&2\end{bmatrix}

is a 3×23\times2 The matrix of QTQ=I2Q^{\mathsf T}Q=I_2, its two columns are the orthonormal basis of a certain two-dimensional subspace. To make it up 3×33\times3 For an orthogonal matrix, you can add another column following this symbolic pattern: take the third column (2,−2,1)T(2,-2,1)^{\mathsf T}, its inner product with the first two columns is respectively 2−4+2=02-4+2=0 and −4+2+2=0-4+2+2=0, the length squared is 4+4+1=94+4+1=9. So

Q=13[1−222−1−2221]Q=\frac13\begin{bmatrix} 1&-2&2\\ 2&-1&-2\\ 2&2&1 \end{bmatrix}

is an orthogonal matrix, all elements are simply divided by 33, not a single square root appears. This kind of good luck is not common: when doing Gram-Schmidt, dividing by the length always brings up the square root.

Video 00:18:47: Classroom blackboard writing

Video 00:18:47 | Approximately corresponding to section 2 “2. Several examples that must be remembered”.

3. Benefits brought by standard orthogonality: projection and least squares

This section answers the motivational question: What exactly do you get in exchange for the effort to create an orthonormal basis. The answer is that the formulas in this chapter also become simpler.

Let’s look at the projection first. to vector b\boldsymbol{b} Project to QQ of column space (column space), the general formula given in the previous lectures is

P=Q(QTQ)−1QT.P=Q(Q^{\mathsf T}Q)^{-1}Q^{\mathsf T}.

when QQ When the columns of QTQ=IQ^{\mathsf T}Q=I, the one in the middle completely disappears, leaving

P=QQT.P=QQ^{\mathsf T}.

There is no need to calculate any inverse, and the product is just a combination of “column times row”. Let’s easily verify the two properties that the projection matrix must satisfy. The first one is symmetry: (QQT)T=QQT(QQ^{\mathsf T})^{\mathsf T}=QQ^{\mathsf T}, transpose swaps the positions of two factors and transposes each, and finally returns to the original state. The second one is “projecting twice equals projecting once”:

P2=(QQT)(QQT)=Q(QTQ)QT=Q I QT=QQT=P.P^2=(QQ^{\mathsf T})(QQ^{\mathsf T})=Q(Q^{\mathsf T}Q)Q^{\mathsf T}=Q\,I\,Q^{\mathsf T}=QQ^{\mathsf T}=P .

In the middle step, put the two QQ between QTQQ^{\mathsf T}Q Replace with II It is eliminated, and the basis is exactly “column standard orthogonality”.

The two extremes must be distinguished. if QQ is a square matrix, its column space is the entire space, and the projection should not move any vector. At this time QQT=IQQ^{\mathsf T}=I, which is the same as the “square matrix QT=Q−1Q^{\mathsf T}=Q^{-1}“Consistent. if QQ It’s rectangular, QQTQQ^{\mathsf T} No II: It is a matrix that acts on the entire space, pressing the vector to QQ of nn In dimensional space, vectors generally change.

Let’s look at least squares again. The core equations in the previous lectures are normal equation(normal equation)

ATAx^=ATb.A^{\mathsf T}A\hat{\boldsymbol{x}}=A^{\mathsf T}\boldsymbol{b}.

put AA Replace with QQ, the equation becomes QTQx^=QTbQ^{\mathsf T}Q\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}, the left side is the identity matrix, so

x^=QTb,即x^i=qiTb.\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}, \qquad\text{即}\qquad \hat{x}_i=\boldsymbol{q}_i^{\mathsf T}\boldsymbol{b}.

No. ii The coefficient is the ii basis vectors and b\boldsymbol{b} The inner product of. The original method requires first calculating all the inner accumulations to form ATAA^{\mathsf T}A, solve another system of equations; now there is no system of equations to solve, no matrix requiring inversion, just calculate a dot product for each component separately. This is the most valuable formula of the standard orthonormal basis: under the standard orthonormal basis, the coordinates are projections, which are inner products, and do not require “solution”.

The numerical benefit is here too. The length of an orthonormal vector is always 11, no matter how messy the direction is, it will not make the components become extremely large or extremely small, and there will be neither overflow nor underflow in the calculation; this is why a large number of numerical linear algebra uses standard orthogonal vectors as the basic building blocks.

Official Handout Summary Page 2/3

MIT OCW Official Lecture Notes Summary Page 2/3 (18.06SC Lecture 17 Summary, CC BY-NC-SA 4.0).

Video 00:25:31: Classroom blackboard writing

Video 00:25:31 | Approximately corresponding to Section 3 “3. Benefits of orthogonality: projection and least squares”.

4. Gramm-Schmidt: case of two vectors

The remaining problem is construction: How to get the orthonormal vectors when we only have a set of vectors that are linearly independent but have random directions?

First deal with two vectors. Set a1,a2\boldsymbol{a}_1,\boldsymbol{a}_2 Linear independence, to create q1,q2\boldsymbol{q}_1,\boldsymbol{q}_2. The process is divided into two steps: first turn them into two mutually perpendicular vectors, and then divide each by their length. To avoid having to deal with the matrix AA Confused, this paragraph marks the vector after orthogonalization but not unitized as v1,v2\boldsymbol{v}_1,\boldsymbol{v}_2.

There is almost no need to do this first step. a1\boldsymbol{a}_1 There is no problem with the direction itself. Any direction can be used as the first direction. Just take

v1=a1.\boldsymbol{v}_1=\boldsymbol{a}_1 .

The trouble is with the second vector: a2\boldsymbol{a}_2 Generally not perpendicular to a1\boldsymbol{a}_1. What you are looking for is “from a2\boldsymbol{a}_2 Set off, just take the edge a1\boldsymbol{a}_1 “Remove that part of the direction”. This is the earliest basic calculation in this chapter: put a2\boldsymbol{a}_2 Project to a1\boldsymbol{a}_1 on, the projection is along a1\boldsymbol{a}_1 That part, minus it, the remainder is the vertical part, which is the error vector at that time e\boldsymbol{e}. What we want now is this error vector:

v2=a2−v1Ta2v1Tv1 v1.\boldsymbol{v}_2=\boldsymbol{a}_2-\frac{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2}{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1}\,\boldsymbol{v}_1 .

The coefficient is the ratio of “how many times to reduce”: the numerator is a2\boldsymbol{a}_2 in v1\boldsymbol{v}_1 The inner product in the direction, the denominator is v1\boldsymbol{v}_1 and its own inner product, divide the two to align the units, so that what is subtracted is exactly a multiple of the projection, not the v1\boldsymbol{v}_1 Lose the whole thing. Orthogonalization and unitization are two independent things: orthogonalization only uses inner products and multiples, which is the essence of the algorithm; unitization is just the final division of the length.

Whether this structure is correct or not can be seen by multiplying it:

v1Tv2=v1Ta2−v1Ta2v1Tv1 v1Tv1=v1Ta2−v1Ta2=0.\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_2 =\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2 -\frac{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2}{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1}\,\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1 =\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2-\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2=0 .

If you subtract the same numbers in the numerator and denominator, the result is indeed zero. v2\boldsymbol{v}_2 Nor will it be a zero vector: if v2=0\boldsymbol{v}_2=\boldsymbol{0}, then a2\boldsymbol{a}_2 is v1=a1\boldsymbol{v}_1=\boldsymbol{a}_1 A multiple of , the two vectors are linearly related, which is inconsistent with the assumption. So these two vectors still form the original two-dimensional subspace, but the directions are corrected.

The final step is normalization, where the square root appears:

q1=v1∥v1∥,q2=v2∥v2∥.\boldsymbol{q}_1=\frac{\boldsymbol{v}_1}{\|\boldsymbol{v}_1\|}, \qquad \boldsymbol{q}_2=\frac{\boldsymbol{v}_2}{\|\boldsymbol{v}_2\|}.

Dividing by a positive number does not change the direction, only changes the length to 11; Two vectors are originally perpendicular, but remain perpendicular after dividing by a positive number. The algorithm ends here: q1,q2\boldsymbol{q}_1,\boldsymbol{q}_2 orthonormal and with a1,a2\boldsymbol{a}_1,\boldsymbol{a}_2 into the same subspace.

Video 00:32:07: Classroom blackboard writing

Video 00:32:07 | Approximately corresponding to Section 4 “4. Gramm-Schmidt: The case of two vectors”.

5. Three vectors and one numerical example

The situation of the three vectors is exactly the same. Set a1,a2,a3\boldsymbol{a}_1,\boldsymbol{a}_2,\boldsymbol{a}_3 Linearly independent, the first two have been processed into v1,v2\boldsymbol{v}_1,\boldsymbol{v}_2, the third one should start from a3\boldsymbol{a}_3 subtract all its components in the first two directions:

v3=a3−v1Ta3v1Tv1 v1−v2Ta3v2Tv2 v2.\boldsymbol{v}_3=\boldsymbol{a}_3 -\frac{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_3}{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1}\,\boldsymbol{v}_1 -\frac{\boldsymbol{v}_2^{\mathsf T}\boldsymbol{a}_3}{\boldsymbol{v}_2^{\mathsf T}\boldsymbol{v}_2}\,\boldsymbol{v}_2 .

The two items are divided into v1\boldsymbol{v}_1, along v2\boldsymbol{v}_2 components are reduced. due to v1,v2\boldsymbol{v}_1,\boldsymbol{v}_2 are already perpendicular to each other. These two subtractions do not interfere with each other. After the subtraction, v3\boldsymbol{v}_3 Perpendicular to both. It will not be a zero vector because linear independence guarantees a3\boldsymbol{a}_3 Not in the plane spanned by the first two vectors. Finally divided by the length, we get q3\boldsymbol{q}_3. The whole method has nothing to do with dimensionality: the vector can be in a two-dimensional plane or in a twelve-dimensional space, and the formula only uses the inner product and length. Generally, no. kk vector to be subtracted from the front k−1k-1 all components in known directions, and each later obtained q\boldsymbol{q} are perpendicular to all earlier vectors - this property is what the next section RR Become the source of the upper triangle.

Go through it with a specific example. take

a1=[111],a2=[102].\boldsymbol{a}_1=\begin{bmatrix}1\\1\\1\end{bmatrix}, \qquad \boldsymbol{a}_2=\begin{bmatrix}1\\0\\2\end{bmatrix}.

The two vectors are not perpendicular: the inner product is 1⋅1+1⋅0+1⋅2=31\cdot1+1\cdot0+1\cdot2=3, just needs orthogonalization.

Copy the first direction: v1=a1=(1,1,1)T\boldsymbol{v}_1=\boldsymbol{a}_1=(1,1,1)^{\mathsf T}. Calculate the ratio:

v1Ta2v1Tv1=31+1+1=33=1.\frac{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2}{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1} =\frac{3}{1+1+1}=\frac33=1 .

thus

v2=a2−1⋅v1=[102]−[111]=[0−11].\boldsymbol{v}_2=\boldsymbol{a}_2-1\cdot\boldsymbol{v}_1 =\begin{bmatrix}1\\0\\2\end{bmatrix}-\begin{bmatrix}1\\1\\1\end{bmatrix} =\begin{bmatrix}0\\-1\\1\end{bmatrix}.

Check orthogonality: v1Tv2=1⋅0+1⋅(−1)+1⋅1=0\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_2=1\cdot0+1\cdot(-1)+1\cdot1=0, indeed vertical. The proportion is exactly 11 It is a coincidence of numbers, generally not integers.

Finally unitized. ∥v1∥=3\|\boldsymbol{v}_1\|=\sqrt3, ∥v2∥=2\|\boldsymbol{v}_2\|=\sqrt2, so

q1=13[111],q2=12[0−11].\boldsymbol{q}_1=\frac{1}{\sqrt3}\begin{bmatrix}1\\1\\1\end{bmatrix}, \qquad \boldsymbol{q}_2=\frac{1}{\sqrt2}\begin{bmatrix}0\\-1\\1\end{bmatrix}.

Arrange them in a matrix

Q=[1/301/3−1/21/31/2].Q=\begin{bmatrix} 1/\sqrt3&0\\ 1/\sqrt3&-1/\sqrt2\\ 1/\sqrt3&1/\sqrt2 \end{bmatrix}.

Its two columns are orthogonal and can be directly checked QTQ=I2Q^{\mathsf T}Q=I_2: On the diagonal is 33=1\frac33=1 with 22=1\frac22=1, the off-diagonal line is (0−1+1)/6=0(0-1+1)/\sqrt6=0.

The most critical point in this example is Column space has not changed.QQ The column space and original reason of a1,a2\boldsymbol{a}_1,\boldsymbol{a}_2 The planes formed are the same plane: v2=a2−a1\boldsymbol{v}_2=\boldsymbol{a}_2-\boldsymbol{a}_1 It is originally a combination of the two, and unitization just replaces the columns with another set of basis in the same plane. What Gram-Schmidt changed was only the mass of the basis, but not the space spanned by the basis. So any calculations on the original plane - projection, least squares, coordinates - can be done on the new basis, and the new basis makes every step a dot product.

Video 00:38:32: Classroom blackboard writing

Video 00:38:32 | Approximately corresponding to Section 5 “5. Three vectors and a numerical example”.

6. Matrix language: A=QRA=QR

Orthogonalization also needs to be written as a matrix factorization, just like elimination is finally written as A=LUA=LU. In practice, no one would always write “these columns are perpendicular to each other and the length of these columns is 11”, people wrote AA with QQ the matrix between.

Let’s sort out the examples from the previous section. AA The columns are a1,a2\boldsymbol{a}_1,\boldsymbol{a}_2, QQ The columns are q1,q2\boldsymbol{q}_1,\boldsymbol{q}_2. The two sets of columns are stretched into the same plane, and each aj\boldsymbol{a}_j can be written q1,q2\boldsymbol{q}_1,\boldsymbol{q}_2 combination of , then there exists a 2×22\times2 matrix RR such that

A=QR.A=QR .

RR This can be calculated column by column. a1=(1,1,1)T\boldsymbol{a}_1=(1,1,1)^{\mathsf T} with q1\boldsymbol{q}_1 In the same direction, the length is 3\sqrt3, so a1=3 q1\boldsymbol{a}_1=\sqrt3\,\boldsymbol{q}_1; a2\boldsymbol{a}_2 Write it first a1+v2\boldsymbol{a}_1+\boldsymbol{v}_2, and then use q1,q2\boldsymbol{q}_1,\boldsymbol{q}_2 express, get a2=3 q1+2 q2\boldsymbol{a}_2=\sqrt3\,\boldsymbol{q}_1+\sqrt2\,\boldsymbol{q}_2. Together it is

A=[111012]=[1/301/3−1/21/31/2][3302]=QR.A=\begin{bmatrix}1&1\\1&0\\1&2\end{bmatrix} =\begin{bmatrix} 1/\sqrt3&0\\ 1/\sqrt3&-1/\sqrt2\\ 1/\sqrt3&1/\sqrt2 \end{bmatrix} \begin{bmatrix} \sqrt3&\sqrt3\\ 0&\sqrt2 \end{bmatrix} =QR .

RR The upper triangle shape is no coincidence. Generally, if QQ The columns of are orthogonal, AA The columns are a1,…,an\boldsymbol{a}_1,\dots,\boldsymbol{a}_n, then A=QRA=QR of the jj column gives aj=∑i=1nqiRij\boldsymbol{a}_j=\sum_{i=1}^{n}\boldsymbol{q}_iR_{ij}. Take left on both sides qkT\boldsymbol{q}_k^{\mathsf T}, due to QQ The columns of are orthogonal in pairs, leaving only i=ki=k One item:

Rkj=qkTaj.R_{kj}=\boldsymbol{q}_k^{\mathsf T}\boldsymbol{a}_j .

Now let’s see why everything below the diagonal is zero. When k>jk>j when, aj\boldsymbol{a}_j fall on q1,…,qj\boldsymbol{q}_1,\dots,\boldsymbol{q}_j in the Zhang Cheng space, and qk\boldsymbol{q}_k was created later, and is constructed perpendicular to all earlier directions according to the algorithm, so qkTaj=0\boldsymbol{q}_k^{\mathsf T}\boldsymbol{a}_j=0, that is Rkj=0R_{kj}=0. This is exactly the definition of an upper triangular matrix: all zeros below the main diagonal. The diagonal element is Rjj=qjTaj=∥vj∥>0R_{jj}=\boldsymbol{q}_j^{\mathsf T}\boldsymbol{a}_j=\|\boldsymbol{v}_j\|>0, in the example 3\sqrt3 with 2\sqrt2.

So we get the final conclusion of this lecture: any linearly independent matrix can be decomposed into the product of an orthogonal column matrix and an upper triangular matrix. This decomposition is called QR decomposition(QR factorization):

A=QR.A=QR .

QQ gives the orthonormal basis of the same column space, RR Record the coefficients required for the new basis to represent the old column; RR Each number in is the inner product and length that have been calculated during the orthogonalization process, and no new quantities are introduced. Got it QQ, the projection is QQTQQ^{\mathsf T}, the least squares solution is QTbQ^{\mathsf T}\boldsymbol{b}, all no longer need to be inverse; with RR, only then do we know how to convert this set of beautiful bases to the original matrix. This is exactly how elimination and orthogonalization work: A=LUA=LU Store the elimination information into the lower triangular matrix, A=QRA=QR Store the orthogonalized information into an upper triangular matrix.

Video 00:44:28: Classroom blackboard writing

Video 00:44:28|Approximately corresponding to Section 6 “6. Matrix Language: A=QRA=QR“Nearby.

Official Handout Summary Page 3/3

MIT OCW Official Lecture Notes Summary Page 3/3 (18.06SC Lecture 17 Summary, CC BY-NC-SA 4.0).

Summary of this lecture

  • orthogonal (orthonormal) means that the inner product of each pair is zero, and the length of each vector is 11;The condition is written as qiTqj=δij\boldsymbol{q}_i^{\mathsf T}\boldsymbol{q}_j=\delta_{ij}, that is, the diagonal angle is 11, the rest are 00.
  • If QQ The columns of are orthogonal, then QTQ=IQ^{\mathsf T}Q=I;if QQ Or square array, then QT=Q−1Q^{\mathsf T}=Q^{-1}, that is QQT=IQQ^{\mathsf T}=I. It was agreed to only call the square array orthogonal matrix(orthogonal matrix).
  • Orthogonal vectors must be linearly independent: use qi\boldsymbol{q}_i Go to the dot multiplication zero combination to force out the first ii coefficient is zero.
  • Typical example: permutation matrix; the two columns are (cos⁡θ,sin⁡θ)T(\cos\theta,\sin\theta)^{\mathsf T} with (−sin⁡θ,cos⁡θ)T(-\sin\theta,\cos\theta)^{\mathsf T} matrix; 2×22\times2 of ±1\pm1 Divide the entire matrix by 2\sqrt2;The entire fourth-order Hadamard matrix is divided by 22;The example with three rows and two columns divides the whole by 33.
  • When the columns are orthogonal, the projection matrix degenerates into P=QQTP=QQ^{\mathsf T}, it is symmetrical and satisfies P2=PP^2=P; QQ When it is a square matrix P=IP=I.
  • The normal equation degenerates into QTQx^=QTbQ^{\mathsf T}Q\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}, that is x^=QTb\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}, No. ii The coefficient is x^i=qiTb\hat{x}_i=\boldsymbol{q}_i^{\mathsf T}\boldsymbol{b}: “Coordinates are dot products”.
  • Two core steps of Gramm-Schmidt: orthogonalization v1=a1\boldsymbol{v}_1=\boldsymbol{a}_1, v2=a2−v1Ta2v1Tv1v1\boldsymbol{v}_2=\boldsymbol{a}_2-\frac{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{a}_2}{\boldsymbol{v}_1^{\mathsf T}\boldsymbol{v}_1}\boldsymbol{v}_1, when there are three vectors, subtract the edge v2\boldsymbol{v}_2 component; then unitize qi=vi/∥vi∥\boldsymbol{q}_i=\boldsymbol{v}_i/\|\boldsymbol{v}_i\|.
  • Numerical example: a1=(1,1,1)T\boldsymbol{a}_1=(1,1,1)^{\mathsf T}, a2=(1,0,2)T\boldsymbol{a}_2=(1,0,2)^{\mathsf T} given v2=(0,−1,1)T\boldsymbol{v}_2=(0,-1,1)^{\mathsf T};The two columns after unitization are (1,1,1)T/3(1,1,1)^{\mathsf T}/\sqrt3 with (0,−1,1)T/2(0,-1,1)^{\mathsf T}/\sqrt2, the column space is still the original plane.
  • The whole process is written as A=QRA=QR, Rkj=qkTajR_{kj}=\boldsymbol{q}_k^{\mathsf T}\boldsymbol{a}_j is an upper triangular matrix; Rkj=0 (k>j)R_{kj}=0\ (k>j) It’s because it’s later qk\boldsymbol{q}_k perpendicular to earlier aj\boldsymbol{a}_j.

keywords

EnglishChineseOne sentence explanation
orthonormalorthogonalThe inner product of each pair is zero and the length of each vector is 11
orthonormal basisorthonormal basisA basis consisting of orthonormal vectors, the coordinates can be read directly from the inner product
orthogonal matrixorthogonal matrixA standard orthogonal square matrix satisfies QT=Q−1Q^{\mathsf T}=Q^{-1}
Gram-SchmidtGram-SchmidtOrthogonalization algorithm that subtracts the projection in the obtained direction one by one from the linearly independent vector group and then normalizes it
QR factorizationQR decompositionWrite a matrix whose columns are linearly independent as the product of an orthogonal column matrix and an upper triangular matrix
projection matrixprojection matrixProject the vector into a matrix in the column space. When the columns are orthogonal, it simplifies to QQTQQ^{\mathsf T}
normal equationnormal equationleast squares equation ATAx^=ATbA^{\mathsf T}A\hat{\boldsymbol{x}}=A^{\mathsf T}\boldsymbol{b}, QQ The situation degenerates into x^=QTb\hat{\boldsymbol{x}}=Q^{\mathsf T}\boldsymbol{b}
permutation matrixpermutation matrixOnly one per row and column 11 The square matrix of is always an orthogonal matrix
Hadamard matrixHadamard matrixAll elements are ±1\pm1 Orthogonal matrix of , the fourth-order example requires dividing the whole by 22
upper triangular matrixupper triangular matrixA matrix with all zeros below the main diagonal, A=QRA=QR in RR That’s this kind of thing

← Lecture 16 | Course Catalog | Lecture 18 →

Machine-assisted translation · Read Chinese original