第 14 章

正交向量与正交子空间

点积为零是正交的判据;行空间与零空间、列空间与左零空间分别互相垂直,并互为正交补;这直接引出最小二乘方程 AᵀA x̂ = Aᵀb。

Orthogonal Vectors and Subspaces

A zero dot product is the test for orthogonality; row space is perpendicular to null space and column space to left null space, each pair an orthogonal complement. This leads directly to the least-squares equation AᵀA x̂ = Aᵀb.

首发于 2009.05.07中 / EN
系统课程linear-algebraorthogonalityorthogonal-complementleast-squares
语言
字号
目录
篇内目录

从向量正交到子空间正交

正交就是垂直。Rn\mathbb{R}^n 中两个向量 x,y\mathbf{x},\mathbf{y} 正交,当且仅当

x⊤y=x1y1+x2y2+⋯+xnyn=0.\mathbf{x}^\top\mathbf{y}=x_1y_1+x_2y_2+\cdots+x_ny_n=0.

这是整章唯一需要记的判据。零向量与任何向量都正交,因为点积恒为 0。

为什么点积为零等价于垂直

设直角三角形两条直角边为 x\mathbf{x} 与 y\mathbf{y},斜边为 x+y\mathbf{x}+\mathbf{y}。勾股定理说

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

把右边展开:

∥x+y∥2=(x+y)⊤(x+y)=x⊤x+x⊤y+y⊤x+y⊤y.\|\mathbf{x}+\mathbf{y}\|^2 =(\mathbf{x}+\mathbf{y})^\top(\mathbf{x}+\mathbf{y}) =\mathbf{x}^\top\mathbf{x}+\mathbf{x}^\top\mathbf{y}+\mathbf{y}^\top\mathbf{x}+\mathbf{y}^\top\mathbf{y}.

对实向量,x⊤y=y⊤x\mathbf{x}^\top\mathbf{y}=\mathbf{y}^\top\mathbf{x},所以

∥x+y∥2=∥x∥2+2x⊤y+∥y∥2.\|\mathbf{x}+\mathbf{y}\|^2=\|\mathbf{x}\|^2+2\mathbf{x}^\top\mathbf{y}+\|\mathbf{y}\|^2.

勾股等式成立,当且仅当

2x⊤y=0.2\mathbf{x}^\top\mathbf{y}=0.

勾股定理与点积判据是同一件事的两种写法。

一个数值例子

取 x=(1,2,3)⊤\mathbf{x}=(1,2,3)^\top。先试 y=(1,2,−1)⊤\mathbf{y}=(1,2,-1)^\top:

x⊤y=1+4−3=2≠0,\mathbf{x}^\top\mathbf{y}=1+4-3=2\neq0,

并不正交。换成 y=(2,−1,0)⊤\mathbf{y}=(2,-1,0)^\top:

x⊤y=2−2+0=0,\mathbf{x}^\top\mathbf{y}=2-2+0=0,

两向量正交。此时

∥x∥2=14,∥y∥2=5,∥x+y∥2=∥(3,1,3)∥2=9+1+9=19,\|\mathbf{x}\|^2=14,\qquad \|\mathbf{y}\|^2=5,\qquad \|\mathbf{x}+\mathbf{y}\|^2=\|(3,1,3)\|^2=9+1+9=19,

而 14+5=1914+5=19,勾股定理成立。

时间轴

时间内容
0:11向量正交与点积
3:42直角与内积为零
5:33勾股定理
7:19长度的平方等于 xTx\mathbf{x}^{T}\mathbf{x}
10:55零向量与一切向量正交
16:30子空间正交的定义:每个向量两两正交
23:31正交补
25:34行空间与零空间互为正交补
27:15两者维数相加等于 nn
30:46法向量与平面
34:16最小二乘:本章的主问题
36:00卫星定位的例子
44:26方程组何时可解
46:09ATAA^{T}A 是否总是可逆
48:01列无关时 ATAA^{T}A 可逆

子空间正交

两个子空间 SS 与 TT 正交,意思是:

SS 中的每一个向量都与 TT 中的每一个向量正交。

这个定义比「交集为零」更强。三维空间中的两块平面(例如黑板与地面)都经过原点,交集是一条直线,因此不正交——交线上的向量不可能与自身正交。

在平面 R2\mathbb{R}^2 中,可能的情形只有:零空间、过原点的直线、整个平面。两条过原点的直线正交,当且仅当它们成 90°;一条直线与零空间永远正交;一条直线与整个平面永远不正交。

四个基本子空间的正交关系

行空间与零空间

设 x∈N(A)\mathbf{x}\in N(A),则 Ax=0A\mathbf{x}=\mathbf{0}。把 AA 按行写出:

Ax=[row1⋮rowm]x=[row1⋅x⋮rowm⋅x]=[0⋮0].A\mathbf{x}= \begin{bmatrix} \text{row}_1\\ \vdots\\ \text{row}_m \end{bmatrix}\mathbf{x} = \begin{bmatrix} \text{row}_1\cdot\mathbf{x}\\ \vdots\\ \text{row}_m\cdot\mathbf{x} \end{bmatrix} = \begin{bmatrix}0\\\vdots\\0\end{bmatrix}.

所以 x\mathbf{x} 与 AA 的每一行都正交。

行空间中的任意向量是这些行的组合 ∑ci rowi\sum c_i\,\text{row}_i,于是

(∑ici rowi)⋅x=∑ici(rowi⋅x)=0.\left(\sum_i c_i\,\text{row}_i\right)\cdot\mathbf{x} =\sum_i c_i(\text{row}_i\cdot\mathbf{x})=0.

因此 N(A)N(A) 中的每个向量都与行空间中的每个向量正交:

C(A⊤)⊥N(A).C(A^\top)\perp N(A).

列空间与左零空间

把同样的论证用在 A⊤A^\top 上:

C(A)⊥N(A⊤).C(A)\perp N(A^\top).

维数互补

上一讲已知

dim⁡C(A⊤)+dim⁡N(A)=r+(n−r)=n,\dim C(A^\top)+\dim N(A)=r+(n-r)=n, dim⁡C(A)+dim⁡N(A⊤)=r+(m−r)=m.\dim C(A)+\dim N(A^\top)=r+(m-r)=m.

两个正交子空间的维数相加恰好等于整个空间的维数,这样的关系称为正交补:

N(A)=C(A⊤)⊥,N(A⊤)=C(A)⊥.N(A)=C(A^\top)^\perp,\qquad N(A^\top)=C(A)^\perp.

「补」的含义不只是「包含一些正交向量」,而是包含全部:零空间恰好由所有与行空间正交的向量组成,一个不多,一个不少。

这就是线性代数基本定理的第二部分:第一部分是维数,第二部分是正交性,第三部分(下一讲)是正交基。

例子:秩为 1 的矩阵

取一行矩阵

A=[125].A=\begin{bmatrix}1&2&5\end{bmatrix}.
  • 行空间是 (1,2,5)(1,2,5) 张成的直线;
  • 零空间是方程 x1+2x2+5x3=0x_1+2x_2+5x_3=0 的解,即一个平面,恰好垂直于该直线;
  • 维数 1+2=31+2=3。

在 R3\mathbb{R}^3 中,一条直线与一个平面可以互相垂直且维数相加为 3;但两条直线即使垂直,维数也只加到 2,不能成为正交补。

最小二乘:本章的主问题

当 Ax=bA\mathbf{x}=\mathbf{b} 无解时,仍然要给出「最好的近似解」。

典型场景:m>nm>n,方程数多于未知数,且 b\mathbf{b} 含有测量噪声。例如用上千次卫星观测估计六个参数,或多次测量同一个人的脉搏。丢弃方程不可取——每个测量都含有信息。

正确做法是把两边左乘 A⊤A^\top:

A⊤A x^=A⊤b.A^\top A\,\hat{\mathbf{x}}=A^\top\mathbf{b}.

这个方程称为正规方程,x^\hat{\mathbf{x}} 是最小二乘解。它总有解;当 AA 的列线性无关时,解唯一。

A⊤AA^\top A 的性质

性质理由
方阵AA 是 m×nm\times n,A⊤AA^\top A 是 n×nn\times n
对称(A⊤A)⊤=A⊤A(A^\top A)^\top=A^\top A
秩等于 rank⁡(A)\operatorname{rank}(A)见下
零空间等于 N(A)N(A)见下
可逆   ⟺  A\iff A 的列无关由前两条推出

关键在于:若 A⊤Ax=0A^\top A\mathbf{x}=\mathbf{0},左乘 x⊤\mathbf{x}^\top:

x⊤A⊤Ax=(Ax)⊤(Ax)=∥Ax∥2=0.\mathbf{x}^\top A^\top A\mathbf{x} =(A\mathbf{x})^\top(A\mathbf{x}) =\|A\mathbf{x}\|^2=0.

范数为零意味着 Ax=0A\mathbf{x}=\mathbf{0}。所以

N(A⊤A)=N(A),N(A^\top A)=N(A),

秩也相同。于是 A⊤AA^\top A 可逆当且仅当 N(A)={0}N(A)=\{\mathbf{0}\},即 AA 的列线性无关。

数值例子

A=[111215].A=\begin{bmatrix}1&1\\1&2\\1&5\end{bmatrix}.

则

A⊤A=[111125][111215]=[38830].A^\top A= \begin{bmatrix} 1&1&1\\ 1&2&5 \end{bmatrix} \begin{bmatrix}1&1\\1&2\\1&5\end{bmatrix} = \begin{bmatrix}3&8\\8&30\end{bmatrix}.

行列式 3⋅30−8⋅8=90−64=26≠03\cdot30-8\cdot8=90-64=26\neq0,可逆。两列独立,符合预期。

若把第二列改成第一列的倍数,例如

A=[112233],A⊤A=[14141414],A=\begin{bmatrix}1&1\\2&2\\3&3\end{bmatrix}, \qquad A^\top A= \begin{bmatrix}14&14\\14&14\end{bmatrix},

秩为 1,不可逆。列相关,正规方程有无穷多解。

本讲结论

  • 向量正交   ⟺  \iff 点积为零;勾股定理与点积判据等价。
  • 子空间正交要求「每一对向量」都正交,比交集为零更强。
  • 行空间 ⊥\perp 零空间,列空间 ⊥\perp 左零空间,且分别互为正交补。
  • 无解时求解 A⊤Ax^=A⊤bA^\top A\hat{\mathbf{x}}=A^\top\mathbf{b}。
  • A⊤AA^\top A 对称,零空间与秩都与 AA 相同,列无关时可逆。

理解检验

1. 为什么零向量与所有向量都正交?这与「子空间必须含零」有什么关系?

参考答案:对任意 y\mathbf{y},0⊤y=0\mathbf{0}^\top\mathbf{y}=0,点积恒为零,所以零向量与一切向量正交。

每个子空间都含零向量,因此零向量与所有子空间的所有向量都正交。但这不意味着任何两个子空间都正交:子空间正交要求「SS 中每个向量与 TT 中每个向量正交」,而只要 S∩TS\cap T 里有非零向量 v\mathbf{v},就有 v⊤v=∥v∥2>0\mathbf{v}^\top\mathbf{v}=\|\mathbf{v}\|^2>0,正交性立刻失败。所以「交集只有零」是子空间正交的必要条件,这一点正是零向量与一切正交的直接后果;但它不是充分条件——三维中两块过原点的平面交集是一条直线,虽然交集不含别的,却也不正交。

2. 两块过原点的平面如果有非零交线,为什么一定不正交?

参考答案:设交线方向为 v≠0\mathbf{v}\ne\mathbf{0}。v\mathbf{v} 同时属于两个平面,于是取 SS 中的 v\mathbf{v} 与 TT 中的 v\mathbf{v}(同一个向量),它们的点积

v⊤v=∥v∥2>0\mathbf{v}^\top\mathbf{v}=\|\mathbf{v}\|^2>0

不为零。子空间正交要求 SS 中每一个向量与 TT 中每一个向量正交,这里已经找到一对不正交的向量,所以两个平面不正交。换句话说,非零向量不可能与自身正交。

3. 用 Ax=0A\mathbf{x}=\mathbf{0} 证明零空间与行空间正交,并说明为什么「行的组合」也正交。

参考答案:设 x∈N(A)\mathbf{x}\in N(A),即 Ax=0A\mathbf{x}=\mathbf{0}。把 AA 按行写出,乘积的每个分量就是一行与 x\mathbf{x} 的点积:

Ax=[row1⋅x⋮rowm⋅x]=0,A\mathbf{x}= \begin{bmatrix} \text{row}_1\cdot\mathbf{x}\\ \vdots\\ \text{row}_m\cdot\mathbf{x} \end{bmatrix} =\mathbf{0},

所以每一行都与 x\mathbf{x} 正交。

行空间中的任意向量是 ∑ici rowi\sum_i c_i\,\text{row}_i,由点积的双线性,

(∑ici rowi)⋅x=∑ici(rowi⋅x)=∑ici⋅0=0.\left(\sum_i c_i\,\text{row}_i\right)\cdot\mathbf{x} =\sum_i c_i(\text{row}_i\cdot\mathbf{x})=\sum_i c_i\cdot 0=0 .

因此行空间的每个向量都与 x\mathbf{x} 正交;x\mathbf{x} 又是 N(A)N(A) 中任取的,故 C(A⊤)⊥N(A)C(A^\top)\perp N(A)。

4. A⊤AA^\top A 与 AA 的零空间为什么相同?写出关键的那一步。

参考答案:两个方向。

若 Ax=0A\mathbf{x}=\mathbf{0},则 A⊤Ax=A⊤0=0A^\top A\mathbf{x}=A^\top\mathbf{0}=\mathbf{0},所以 N(A)⊆N(A⊤A)N(A)\subseteq N(A^\top A)。

反过来,若 A⊤Ax=0A^\top A\mathbf{x}=\mathbf{0},左乘 x⊤\mathbf{x}^\top:

0=x⊤A⊤Ax=(Ax)⊤(Ax)=∥Ax∥2.0=\mathbf{x}^\top A^\top A\mathbf{x}=(A\mathbf{x})^\top(A\mathbf{x})=\|A\mathbf{x}\|^2 .

关键的一步是:范数的平方为零,当且仅当向量本身为零,于是 Ax=0A\mathbf{x}=\mathbf{0},即 N(A⊤A)⊆N(A)N(A^\top A)\subseteq N(A)。

两边合起来 N(A⊤A)=N(A)N(A^\top A)=N(A),维数相同,秩也相同。因此 A⊤AA^\top A 可逆当且仅当 N(A)={0}N(A)=\{\mathbf{0}\},也就是 AA 的列线性无关。

5. 一个 5×25\times2 矩阵的列相关,A⊤AA^\top A 的秩是多少?正规方程有多少解?

参考答案:AA 是 5×25\times2,两列相关,所以 rank⁡(A)≤1\operatorname{rank}(A)\le 1。若 AA 非零,则 rank⁡(A)=1\operatorname{rank}(A)=1;由 rank⁡(A⊤A)=rank⁡(A)\operatorname{rank}(A^\top A)=\operatorname{rank}(A),

rank⁡(A⊤A)=1.\operatorname{rank}(A^\top A)=1 .

A⊤AA^\top A 是 2×22\times2 但秩为 1,因此奇异不可逆,N(A⊤A)=N(A)N(A^\top A)=N(A) 的维数为 2−1=12-1=1。

正规方程 A⊤Ax^=A⊤bA^\top A\hat{\mathbf{x}}=A^\top\mathbf{b} 总是有解(A⊤bA^\top\mathbf{b} 落在 A⊤AA^\top A 的列空间里),此时解不唯一,形如

x^=x^p+c v,\hat{\mathbf{x}}=\hat{\mathbf{x}}_p+c\,\mathbf{v},

其中 v\mathbf{v} 张成 N(A)N(A),cc 任意——即有无穷多个最小二乘解。(若 A=0A=0,则秩为 0,任意 x^\hat{\mathbf{x}} 都是解。)

与前后课程的关系

上一讲只说明行空间与零空间交集为零;这一讲证明它们互相垂直、互为正交补。下一讲在此基础上构造正交基(Gram-Schmidt),并给出最小二乘的完整几何解释。

From orthogonal vectors to orthogonal subspaces

Orthogonal means perpendicular. Two vectors x,y∈Rn\mathbf{x},\mathbf{y}\in\mathbb{R}^n are orthogonal exactly when

x⊤y=x1y1+x2y2+⋯+xnyn=0.\mathbf{x}^\top\mathbf{y}=x_1y_1+x_2y_2+\cdots+x_ny_n=0.

That is the only test needed in this chapter. The zero vector is orthogonal to everything, since every dot product with it is zero.

Why a zero dot product means perpendicular

Let the legs of a right triangle be x\mathbf{x} and y\mathbf{y}, with hypotenuse x+y\mathbf{x}+\mathbf{y}. Pythagoras says

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

Expand the right side:

∥x+y∥2=(x+y)⊤(x+y)=x⊤x+x⊤y+y⊤x+y⊤y.\|\mathbf{x}+\mathbf{y}\|^2 =(\mathbf{x}+\mathbf{y})^\top(\mathbf{x}+\mathbf{y}) =\mathbf{x}^\top\mathbf{x}+\mathbf{x}^\top\mathbf{y}+\mathbf{y}^\top\mathbf{x}+\mathbf{y}^\top\mathbf{y}.

For real vectors x⊤y=y⊤x\mathbf{x}^\top\mathbf{y}=\mathbf{y}^\top\mathbf{x}, so

∥x+y∥2=∥x∥2+2x⊤y+∥y∥2.\|\mathbf{x}+\mathbf{y}\|^2=\|\mathbf{x}\|^2+2\mathbf{x}^\top\mathbf{y}+\|\mathbf{y}\|^2.

The Pythagorean identity holds exactly when

2x⊤y=0.2\mathbf{x}^\top\mathbf{y}=0.

Pythagoras and the dot-product test are the same statement in two forms.

A numerical example

Take x=(1,2,3)⊤\mathbf{x}=(1,2,3)^\top. First try y=(1,2,−1)⊤\mathbf{y}=(1,2,-1)^\top:

x⊤y=1+4−3=2≠0,\mathbf{x}^\top\mathbf{y}=1+4-3=2\neq0,

so they are not orthogonal. Now take y=(2,−1,0)⊤\mathbf{y}=(2,-1,0)^\top:

x⊤y=2−2+0=0,\mathbf{x}^\top\mathbf{y}=2-2+0=0,

so they are orthogonal. Then

∥x∥2=14,∥y∥2=5,∥x+y∥2=∥(3,1,3)∥2=9+1+9=19,\|\mathbf{x}\|^2=14,\qquad \|\mathbf{y}\|^2=5,\qquad \|\mathbf{x}+\mathbf{y}\|^2=\|(3,1,3)\|^2=9+1+9=19,

and 14+5=1914+5=19, confirming Pythagoras.

Timeline

TimeTopic
0:11Orthogonal vectors and the dot product
3:42Right angles and a zero inner product
5:33Pythagoras
7:19Length squared as xTx\mathbf{x}^{T}\mathbf{x}
10:55The zero vector is orthogonal to everything
16:30Orthogonal subspaces: every pair of vectors
23:31Orthogonal complements
25:34Row space and null space are orthogonal complements
27:15Their dimensions add to nn
30:46Normal vectors and planes
34:16Least squares: the main problem of the chapter
36:00The satellite example
44:26When the system is solvable
46:09Is ATAA^{T}A always invertible
48:01ATAA^{T}A is invertible when the columns are independent

Orthogonal subspaces

Two subspaces SS and TT are orthogonal when

every vector in SS is orthogonal to every vector in TT.

This is stronger than "the intersection is zero". Two planes through the origin in R3\mathbb{R}^3 (a blackboard and the floor, say) intersect in a line, so they are not orthogonal: a vector on that line cannot be orthogonal to itself.

In R2\mathbb{R}^2 the only subspaces are the zero space, lines through the origin, and the whole plane. Two lines are orthogonal exactly when they meet at 90 degrees; a line is always orthogonal to the zero subspace and never to the whole plane.

Orthogonality of the four subspaces

Row space and null space

Let x∈N(A)\mathbf{x}\in N(A), so Ax=0A\mathbf{x}=\mathbf{0}. Writing AA row by row,

Ax=[row1⋮rowm]x=[row1⋅x⋮rowm⋅x]=[0⋮0].A\mathbf{x}= \begin{bmatrix} \text{row}_1\\ \vdots\\ \text{row}_m \end{bmatrix}\mathbf{x} = \begin{bmatrix} \text{row}_1\cdot\mathbf{x}\\ \vdots\\ \text{row}_m\cdot\mathbf{x} \end{bmatrix} = \begin{bmatrix}0\\\vdots\\0\end{bmatrix}.

Thus x\mathbf{x} is orthogonal to every row of AA.

Any vector in the row space is a combination ∑ci rowi\sum c_i\,\text{row}_i, and

(∑ici rowi)⋅x=∑ici(rowi⋅x)=0.\left(\sum_i c_i\,\text{row}_i\right)\cdot\mathbf{x} =\sum_i c_i(\text{row}_i\cdot\mathbf{x})=0.

Therefore every null-space vector is orthogonal to every row-space vector:

C(A⊤)⊥N(A).C(A^\top)\perp N(A).

Column space and left null space

Apply the same argument to A⊤A^\top:

C(A)⊥N(A⊤).C(A)\perp N(A^\top).

Complementary dimensions

From the previous lecture,

dim⁡C(A⊤)+dim⁡N(A)=r+(n−r)=n,\dim C(A^\top)+\dim N(A)=r+(n-r)=n, dim⁡C(A)+dim⁡N(A⊤)=r+(m−r)=m.\dim C(A)+\dim N(A^\top)=r+(m-r)=m.

Two orthogonal subspaces whose dimensions add to the whole space are orthogonal complements:

N(A)=C(A⊤)⊥,N(A⊤)=C(A)⊥.N(A)=C(A^\top)^\perp,\qquad N(A^\top)=C(A)^\perp.

"Complement" means more than "contains some orthogonal vectors": the null space consists of all vectors orthogonal to the row space, no more and no fewer.

This is part two of the fundamental theorem of linear algebra. Part one is dimensions; part two is orthogonality; part three, next lecture, is orthogonal bases.

Example: a rank-one matrix

Take the single-row matrix

A=[125].A=\begin{bmatrix}1&2&5\end{bmatrix}.
  • The row space is the line through (1,2,5)(1,2,5).
  • The null space is the solution set of x1+2x2+5x3=0x_1+2x_2+5x_3=0, a plane perpendicular to that line.
  • The dimensions are 1+2=31+2=3.

In R3\mathbb{R}^3 a line and a plane can be perpendicular with dimensions summing to 3. Two perpendicular lines have dimensions summing only to 2, so they are not orthogonal complements.

Least squares: the main problem of the chapter

When Ax=bA\mathbf{x}=\mathbf{b} has no solution, a best approximation is still required.

The typical setting: m>nm>n, more equations than unknowns, and noise in b\mathbf{b}. A satellite position estimated from a thousand measurements, or a pulse rate measured repeatedly. Discarding equations is unsatisfying because every measurement carries information.

The right move is to multiply both sides by A⊤A^\top:

A⊤A x^=A⊤b.A^\top A\,\hat{\mathbf{x}}=A^\top\mathbf{b}.

These are the normal equations, and x^\hat{\mathbf{x}} is the least-squares solution. They always have a solution, and the solution is unique when the columns of AA are independent.

Properties of A⊤AA^\top A

PropertyReason
SquareAA is m×nm\times n, so A⊤AA^\top A is n×nn\times n
Symmetric(A⊤A)⊤=A⊤A(A^\top A)^\top=A^\top A
Rank equals rank⁡(A)\operatorname{rank}(A)See below
Null space equals N(A)N(A)See below
Invertible   ⟺  \iff columns of AA are independentFollows from the previous two

The key step: if A⊤Ax=0A^\top A\mathbf{x}=\mathbf{0}, multiply on the left by x⊤\mathbf{x}^\top:

x⊤A⊤Ax=(Ax)⊤(Ax)=∥Ax∥2=0.\mathbf{x}^\top A^\top A\mathbf{x} =(A\mathbf{x})^\top(A\mathbf{x}) =\|A\mathbf{x}\|^2=0.

A zero norm means Ax=0A\mathbf{x}=\mathbf{0}. Hence

N(A⊤A)=N(A),N(A^\top A)=N(A),

and the ranks agree. Therefore A⊤AA^\top A is invertible exactly when N(A)={0}N(A)=\{\mathbf{0}\}, that is, when the columns of AA are independent.

A numerical example

A=[111215].A=\begin{bmatrix}1&1\\1&2\\1&5\end{bmatrix}.

Then

A⊤A=[111125][111215]=[38830].A^\top A= \begin{bmatrix} 1&1&1\\ 1&2&5 \end{bmatrix} \begin{bmatrix}1&1\\1&2\\1&5\end{bmatrix} = \begin{bmatrix}3&8\\8&30\end{bmatrix}.

Its determinant is 3⋅30−8⋅8=90−64=26≠03\cdot30-8\cdot8=90-64=26\neq0, so it is invertible, as expected for independent columns.

If the second column is made a multiple of the first, for instance

A=[112233],A⊤A=[14141414],A=\begin{bmatrix}1&1\\2&2\\3&3\end{bmatrix}, \qquad A^\top A= \begin{bmatrix}14&14\\14&14\end{bmatrix},

the rank is 1 and A⊤AA^\top A is singular. The columns are dependent and the normal equations have infinitely many solutions.

Takeaways

  • Vectors are orthogonal iff their dot product is zero; Pythagoras and the dot-product test are equivalent.
  • Subspace orthogonality requires every pair of vectors to be orthogonal, which is stronger than a zero intersection.
  • Row space ⊥\perp null space and column space ⊥\perp left null space, each pair an orthogonal complement.
  • When no solution exists, solve A⊤Ax^=A⊤bA^\top A\hat{\mathbf{x}}=A^\top\mathbf{b}.
  • A⊤AA^\top A is symmetric, has the same null space and rank as AA, and is invertible when the columns of AA are independent.

Check your understanding

1. Why is the zero vector orthogonal to everything, and how does that relate to every subspace containing zero?

Reference answer: For any y\mathbf{y}, 0⊤y=0\mathbf{0}^\top\mathbf{y}=0, so the dot product always vanishes and the zero vector is orthogonal to every vector.

Every subspace contains zero, so zero is orthogonal to every vector in every subspace. That does not make arbitrary subspaces orthogonal: subspace orthogonality requires every vector of SS to be orthogonal to every vector of TT, and if S∩TS\cap T contains a nonzero v\mathbf{v} then v⊤v=∥v∥2>0\mathbf{v}^\top\mathbf{v}=\|\mathbf{v}\|^2>0, so orthogonality fails at once. "The intersection is only zero" is therefore necessary for orthogonal subspaces — exactly because zero is orthogonal to everything — but not sufficient: two planes through the origin in three dimensions meet in a line and are not orthogonal.

2. If two planes through the origin share a nonzero line, why can they not be orthogonal?

Reference answer: Let the shared direction be v≠0\mathbf{v}\ne\mathbf{0}. Then v\mathbf{v} lies in both planes, so take v\mathbf{v} from SS and v\mathbf{v} from TT; their dot product is

v⊤v=∥v∥2>0.\mathbf{v}^\top\mathbf{v}=\|\mathbf{v}\|^2>0 .

Subspace orthogonality demands that every vector of SS be orthogonal to every vector of TT, and here is a pair that is not. In short, a nonzero vector can never be orthogonal to itself.

3. Prove from Ax=0A\mathbf{x}=\mathbf{0} that the null space is orthogonal to the row space, including combinations of rows.

Reference answer: Let x∈N(A)\mathbf{x}\in N(A), so Ax=0A\mathbf{x}=\mathbf{0}. Writing AA by rows, each component of the product is a dot product of a row with x\mathbf{x}:

Ax=[row1⋅x⋮rowm⋅x]=0,A\mathbf{x}= \begin{bmatrix} \text{row}_1\cdot\mathbf{x}\\ \vdots\\ \text{row}_m\cdot\mathbf{x} \end{bmatrix} =\mathbf{0},

so every row is orthogonal to x\mathbf{x}.

Any vector of the row space is ∑ici rowi\sum_i c_i\,\text{row}_i, and bilinearity of the dot product gives

(∑ici rowi)⋅x=∑ici(rowi⋅x)=∑ici⋅0=0.\left(\sum_i c_i\,\text{row}_i\right)\cdot\mathbf{x} =\sum_i c_i(\text{row}_i\cdot\mathbf{x})=\sum_i c_i\cdot 0=0 .

So every row-space vector is orthogonal to x\mathbf{x}; since x\mathbf{x} was arbitrary in N(A)N(A), we get C(A⊤)⊥N(A)C(A^\top)\perp N(A).

4. Why do A⊤AA^\top A and AA have the same null space? Write the crucial step.

Reference answer: Two directions.

If Ax=0A\mathbf{x}=\mathbf{0}, then A⊤Ax=A⊤0=0A^\top A\mathbf{x}=A^\top\mathbf{0}=\mathbf{0}, so N(A)⊆N(A⊤A)N(A)\subseteq N(A^\top A).

Conversely, if A⊤Ax=0A^\top A\mathbf{x}=\mathbf{0}, multiply on the left by x⊤\mathbf{x}^\top:

0=x⊤A⊤Ax=(Ax)⊤(Ax)=∥Ax∥2.0=\mathbf{x}^\top A^\top A\mathbf{x}=(A\mathbf{x})^\top(A\mathbf{x})=\|A\mathbf{x}\|^2 .

The crucial step: a squared norm is zero only when the vector itself is zero, so Ax=0A\mathbf{x}=\mathbf{0} and N(A⊤A)⊆N(A)N(A^\top A)\subseteq N(A).

Hence N(A⊤A)=N(A)N(A^\top A)=N(A), with equal dimensions and equal ranks. Therefore A⊤AA^\top A is invertible exactly when N(A)={0}N(A)=\{\mathbf{0}\}, i.e. when the columns of AA are independent.

5. If a 5×25\times2 matrix has dependent columns, what is the rank of A⊤AA^\top A, and how many least-squares solutions are there?

Reference answer: With AA of size 5×25\times2 and dependent columns, rank⁡(A)≤1\operatorname{rank}(A)\le1. If A≠0A\ne0 then rank⁡(A)=1\operatorname{rank}(A)=1, and since rank⁡(A⊤A)=rank⁡(A)\operatorname{rank}(A^\top A)=\operatorname{rank}(A),

rank⁡(A⊤A)=1.\operatorname{rank}(A^\top A)=1 .

So the 2×22\times2 matrix A⊤AA^\top A is singular, and N(A⊤A)=N(A)N(A^\top A)=N(A) has dimension 2−1=12-1=1.

The normal equations A⊤Ax^=A⊤bA^\top A\hat{\mathbf{x}}=A^\top\mathbf{b} are always consistent (A⊤bA^\top\mathbf{b} lies in the column space of A⊤AA^\top A), but here the solution is not unique:

x^=x^p+c v,\hat{\mathbf{x}}=\hat{\mathbf{x}}_p+c\,\mathbf{v},

where v\mathbf{v} spans N(A)N(A) and cc is arbitrary — infinitely many least-squares solutions. (If A=0A=0, the rank is 0 and every x^\hat{\mathbf{x}} is a solution.)

How this connects to the course

The previous lecture showed only that the row and null spaces intersect at zero. This one proves they are perpendicular orthogonal complements. The next lecture constructs orthogonal bases with Gram-Schmidt and gives the full geometry of least squares.

来源