Session 14 · Unit 2

Orthogonal Vectors and Subspaces


A new chapter about orthogonality, and it opens by upgrading the big picture of the four subspaces. The test for perpendicular vectors is the dot product being zero, and the same idea extends to whole subspaces. The row space and null space turn out to be orthogonal complements, and the lecture closes by introducing the matrix A transpose A, the key to solving Ax = b when there is no solution.

A ninety-degree chapter

Lecture fourteen starts a new chapter — a chapter about orthogonality. What it means for vectors to be orthogonal, what it means for subspaces to be orthogonal, and eventually what it means for bases to be orthogonal. “This is a ninety-degree chapter,” Strang says.

The motivation is the big picture — the 18.06 picture of the four fundamental subspaces. We already know a lot about it: the row space and null space live in Rn\mathbb{R}^n with dimensions rr and nrn - r; the column space and left null space live in Rm\mathbb{R}^m with dimensions rr and mrm - r. What the figure has been quietly claiming all along, and what this lecture proves, is that the angle between those paired subspaces is ninety degrees. The row space is orthogonal to the null space; the column space is orthogonal to the left null space. We knew what each subspace was and could compute bases for them. Now we know how they sit relative to each other.

When are two vectors orthogonal?

Orthogonal is just another word for perpendicular: in nn-dimensional space, the angle between the vectors is ninety degrees — they form a right triangle. So how do you test two vectors for orthogonality?

Why is that the right test? Go back to the Greeks. Pythagoras says: we have a right triangle exactly when the two leg lengths squared add up to the hypotenuse squared. With legs x\mathbf{x} and y\mathbf{y}, the hypotenuse is x+y\mathbf{x} + \mathbf{y}, so the right-angle condition is

x2+y2=x+y2.\|\mathbf{x}\|^2 + \|\mathbf{y}\|^2 = \|\mathbf{x} + \mathbf{y}\|^2.

Don’t think this is always true — for other triangles it isn’t. It’s equivalent to orthogonality. And the length squared of a vector is itself a transpose product: x2=xTx=x12++xn2\|\mathbf{x}\|^2 = \mathbf{x}^T\mathbf{x} = x_1^2 + \cdots + x_n^2, a number that’s positive unless x\mathbf{x} is the zero vector.

Now the same computation in letters. Expand the right side by matrix multiplication — just follow the rules:

(x+y)T(x+y)=xTx+yTy+xTy+yTx.(\mathbf{x} + \mathbf{y})^T(\mathbf{x} + \mathbf{y}) = \mathbf{x}^T\mathbf{x} + \mathbf{y}^T\mathbf{y} + \mathbf{x}^T\mathbf{y} + \mathbf{y}^T\mathbf{x}.

The xTx\mathbf{x}^T\mathbf{x} and yTy\mathbf{y}^T\mathbf{y} cancel against the left side of Pythagoras. And for real vectors there’s no difference between xTy\mathbf{x}^T\mathbf{y} and yTx\mathbf{y}^T\mathbf{x} — both are x1y1+x2y2+x_1y_1 + x_2y_2 + \cdots — so what’s left is 2xTy=02\,\mathbf{x}^T\mathbf{y} = 0. Pythagoras boils down exactly to the dot-product test. “It’s just — I just want to say that’s really neat.”

One boundary case: what if x\mathbf{x} is the zero vector? Follow the rules — zero dotted with anything is zero — so the zero vector is orthogonal to everybody.

When are two subspaces orthogonal?

Now extend the idea from vectors to subspaces.

To see what that definition really demands, take Strang’s classroom example in R3\mathbb{R}^3: the blackboard, extended to infinity, is a two-dimensional subspace; the floor is another one; put the origin at the crack where they meet — “thereby giving linear algebra its proper importance.” Are the blackboard and the floor orthogonal subspaces? The class votes; some yeses, some noes. No. A forty-five-degree vector in the blackboard and a vector in the floor are not at ninety degrees. Even worse, there’s a vector running along the crack that lies in both planes — and a nonzero vector is certainly not orthogonal to itself. In fact, if two subspaces meet in any nonzero vector, they cannot be orthogonal.

Run through the subspaces of the plane — the zero vector, lines through the origin, the whole plane. When is a line through the origin orthogonal to the whole plane? Never. To the zero subspace? Always. To a different line through the origin? Exactly when the two lines meet at ninety degrees — they intersect only at zero, and they’re orthogonal. That’s the clean picture to hold on to.

The row space is orthogonal to the null space

Here is the neat fact this machinery was built for.

Why? All we know about the null space is the equation Ax=0A\mathbf{x} = \mathbf{0} — and the proof is just sitting there in that equation. Write it out by rows:

[row 1 of Arow 2 of Arow m of A]x=[000]\begin{bmatrix} \text{row 1 of } A \\ \text{row 2 of } A \\ \vdots \\ \text{row } m \text{ of } A \end{bmatrix} \mathbf{x} = \begin{bmatrix} 0 \\ 0 \\ \vdots \\ 0 \end{bmatrix}

Each zero on the right says that a row of AA, dotted with x\mathbf{x}, gives zero. So x\mathbf{x} is orthogonal to row one, to row two, to every row. But strictly speaking that’s not the whole row space — the row space contains all the combinations of the rows too. No problem: if (row 1)Tx=0(\text{row } 1)^T\mathbf{x} = 0 and (row 2)Tx=0(\text{row } 2)^T\mathbf{x} = 0, multiply by any c1c_1, c2c_2 and add — still zero:

(c1row 1+c2row 2+)Tx=0.(c_1\,\text{row } 1 + c_2\,\text{row } 2 + \cdots)^T\,\mathbf{x} = 0.

“I just added the zeroes and got zero.” So x\mathbf{x} is perpendicular to every vector in the row space, and the two subspaces are orthogonal. The statement for the column space and left null space is the same statement applied to ATA^T — and ”ATA^T is just as good a matrix as AA” — so no second proof needed. The big picture is now carved up correctly: Rn\mathbb{R}^n splits into two perpendicular subspaces, and so does Rm\mathbb{R}^m.

Orthogonal complements

There’s a little more that’s true, and it comes from the dimensions. Could two perpendicular lines in R3\mathbb{R}^3 be a row space and a null space? No — the dimensions are no good. They must add to nn: r+(nr)=nr + (n - r) = n, and 1+131 + 1 \neq 3.

Try the concrete case: let AA have rows (1,2,5)(1, 2, 5) and (2,4,10)(2, 4, 10). The rank is one, so the row space is a line through (1,2,5)(1, 2, 5) — the second row changed nothing, and we could just as well keep the single equation x1+2x2+5x3=0x_1 + 2x_2 + 5x_3 = 0. Its solutions form the null space: a plane, dimension nr=2n - r = 2. And now we see the geometry we missed back in September: it is exactly the plane perpendicular to (1,2,5)(1, 2, 5). That “dumb normal vector called N” from calculus — there it is, the row of the matrix.

Coming attraction: solving Ax = b when there is no solution

Now the main problem of the chapter — the last chapter about Ax=bA\mathbf{x} = \mathbf{b}. Strang wants to “solve” the system when there is no solution: when b\mathbf{b} is not in the column space. Ridiculous? It’s done all the time — it has to be done. A satellite buzzes along and you make a thousand position measurements, but there are only six or so parameters to find: a thousand equations, six unknowns. Or you measure one pulse rate several times and every measurement carries noise. Typically mm is much bigger than nn, the rank can’t be mm, and most right-hand sides are unsolvable. The measurements have junk in them — but they also carry real information about x\mathbf{x}, and the job is to separate the information from the noise.

One bad idea: throw away equations until a nice square invertible system remains. Not satisfactory — there’s no reason to call some measurements perfect and others useless. We want the maximum information from all of them. Elimination won’t rescue us either; it will just certify that there is no solution.

So Strang jumps ahead to the matrix that will play the key role: ATAA^T A. If AA is mm by nn, then ATAA^T A is nn by nnsquare. And it’s symmetric: transposing gives (ATA)T=AT(AT)T=ATA(A^T A)^T = A^T (A^T)^T = A^T A. He even admits the central equation of the chapter right away. When Ax=bA\mathbf{x} = \mathbf{b} has no solution, multiply both sides by ATA^T and solve

ATAx^=ATb,A^T A\,\hat{\mathbf{x}} = A^T \mathbf{b},

where the hat on x^\hat{\mathbf{x}} signals that this is not the (nonexistent) solution of the original system but the best solution — what “best” means is next lecture’s business. Everything hinges on whether ATAA^T A is invertible.

That example is the general pattern. ATAA^T A is not always invertible — it could even be the zero matrix. The fact that always holds, to be proved as soon as possible, is that N(ATA)=N(A)N(A^T A) = N(A), and so the rank of ATAA^T A equals the rank of AA. From that comes the conclusion the whole chapter needs:

Next lecture — a crucial one — shows how ATAA^T A enters everything.

Problems

Work these before revealing the solutions — every one uses only this lecture’s tools.

Problem 14.1 Dot product & Pythagoras

Verify that x=(1,2,2)\mathbf{x} = (1, -2, 2) and y=(4,2,0)\mathbf{y} = (4, 2, 0) are orthogonal, and confirm Pythagoras: check that x2+y2=x+y2\|\mathbf{x}\|^2 + \|\mathbf{y}\|^2 = \|\mathbf{x}+\mathbf{y}\|^2.

Show solution

Orthogonality test: xTy=(1)(4)+(2)(2)+(2)(0)=44+0=0\mathbf{x}^T\mathbf{y} = (1)(4) + (-2)(2) + (2)(0) = 4 - 4 + 0 = 0. ✓

Lengths: x2=1+4+4=9\|\mathbf{x}\|^2 = 1 + 4 + 4 = 9 and y2=16+4+0=20\|\mathbf{y}\|^2 = 16 + 4 + 0 = 20.

Hypotenuse: x+y=(5,0,2)\mathbf{x} + \mathbf{y} = (5, 0, 2), so x+y2=25+0+4=29\|\mathbf{x}+\mathbf{y}\|^2 = 25 + 0 + 4 = 29.

Indeed 9+20=299 + 20 = 29 — Pythagoras holds, exactly because the dot product is zero.

Problem 14.2 Row space ⊥ null space, concretely

Let

A=[213426].A = \begin{bmatrix} 2 & 1 & -3 \\ 4 & 2 & -6 \end{bmatrix}.

Describe the row space and the null space geometrically, verify that they are orthogonal, and check that their dimensions add to n=3n = 3.

Show solution

The second row is twice the first, so the rank is r=1r = 1. The row space is the line through (2,1,3)(2, 1, -3).

The null space is the set of solutions of the single equation 2x1+x23x3=02x_1 + x_2 - 3x_3 = 0 — a plane through the origin with normal vector (2,1,3)(2, 1, -3), dimension nr=2n - r = 2.

Orthogonality: any x\mathbf{x} in the null space satisfies (2,1,3)Tx=0(2, 1, -3)^T\mathbf{x} = 0, so it is perpendicular to the row (2,1,3)(2,1,-3) and hence to every multiple of it — every vector in the row space.

Dimensions: 1+2=3=n1 + 2 = 3 = n. The plane is the orthogonal complement of the line.

Problem 14.3 Dimensions must add up

In R3\mathbb{R}^3, could a line through the origin be the row space of some matrix while a perpendicular line through the origin is its null space? In R4\mathbb{R}^4, could the row space and null space of a matrix both be two-dimensional planes? Explain.

Show solution

In R3\mathbb{R}^3: no. The dimensions of the row space and null space are rr and nrn - r, which must add to n=3n = 3. Two lines give 1+1=231 + 1 = 2 \neq 3. Orthogonality alone isn’t enough — the null space must be the orthogonal complement, containing all vectors perpendicular to the row space, and in R3\mathbb{R}^3 everything perpendicular to a line is a whole plane.

In R4\mathbb{R}^4: yes. Now 2+2=4=n2 + 2 = 4 = n, so the dimensions are right. For example

A=[10000100]A = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix}

has row space the x1x2x_1 x_2-plane and null space the x3x4x_3 x_4-plane — orthogonal complements in R4\mathbb{R}^4.

Problem 14.4 Computing A^T A

For

A=[101112],A = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \end{bmatrix},

compute ATAA^T A, decide whether it is invertible, and explain how you could have predicted invertibility from the columns of AA alone. Then replace the second column of AA by (2,2,2)(2, 2, 2) and repeat.

Show solution

ATAA^T A is 2 by 2; its entries are dot products of the columns of AA:

ATA=[3335].A^T A = \begin{bmatrix} 3 & 3 \\ 3 & 5 \end{bmatrix}.

The columns (3,3)(3,3) and (3,5)(3,5) are not multiples of each other, so ATAA^T A is invertible. Predicted: the columns (1,1,1)(1,1,1) and (0,1,2)(0,1,2) of AA are independent, and ATAA^T A is invertible exactly when the columns of AA are independent.

With second column (2,2,2)=2×(1,1,1)(2,2,2) = 2 \times (1,1,1), the columns of AA are dependent (rank one), and

ATA=[36612]A^T A = \begin{bmatrix} 3 & 6 \\ 6 & 12 \end{bmatrix}

has its second column twice its first — rank one, not invertible. The rank of ATAA^T A matched the rank of AA both times.

Problem 14.5 Why N(A^T A) = N(A)

Prove the fact Strang promised: ATAx=0A^T A\,\mathbf{x} = \mathbf{0} exactly when Ax=0A\mathbf{x} = \mathbf{0}. Hint for the harder direction: if ATAx=0A^T A\,\mathbf{x} = \mathbf{0}, multiply on the left by xT\mathbf{x}^T and remember what vTv\mathbf{v}^T\mathbf{v} means.

Show solution

Easy direction: if Ax=0A\mathbf{x} = \mathbf{0}, then ATAx=AT(Ax)=AT0=0A^T A\,\mathbf{x} = A^T(A\mathbf{x}) = A^T\mathbf{0} = \mathbf{0}. So N(A)N(ATA)N(A) \subseteq N(A^T A).

Harder direction: suppose ATAx=0A^T A\,\mathbf{x} = \mathbf{0}. Multiply by xT\mathbf{x}^T:

xTATAx=0,i.e.(Ax)T(Ax)=0.\mathbf{x}^T A^T A\,\mathbf{x} = 0, \quad \text{i.e.} \quad (A\mathbf{x})^T(A\mathbf{x}) = 0.

But vTv\mathbf{v}^T\mathbf{v} is the length squared of v\mathbf{v} — a sum of squares, zero only when v\mathbf{v} is the zero vector. So Ax=0A\mathbf{x} = \mathbf{0}.

The two null spaces contain each other, so N(ATA)=N(A)N(A^T A) = N(A). Since ATAA^T A and AA have the same null space and the same number of columns nn, they have the same rank — and in particular ATAA^T A is invertible exactly when N(A)={0}N(A) = \lbrace\mathbf{0}\rbrace, i.e. when the columns of AA are independent.