正交矩阵
一组标准正交向量Orthonormal vectors满足:
q i T q j = { 0 i ≠ j 1 i = j \mathbf{q}_{i}^{T} \mathbf{q}_{j}=\left\{\begin{array}{ll} 0 & i \neq j \\ 1 & i=j \end{array}\right.qiTqj={01i=ji=j
“标准”是指各个向量长度都为1,“正交”指任意两个向量正交;标准正交基础让问题变得简单可控
将一组标准正交向量作为列向量,得到的矩阵为Q \mathbf QQ
根据上面的性质,这个矩阵一定满足Q T Q = [ q 1 T q 2 T q 3 T ] [ q 1 q 2 q 3 ] = I \mathbf Q^T\mathbf Q=\begin{bmatrix}q_1^T\\q_2^T\\q_3^T\end{bmatrix}\begin{bmatrix}q_1&q_2&q_3\end{bmatrix}=\mathbf IQTQ=⎣⎡q1Tq2Tq3T⎦⎤[q1q2q3]=I(但是Q T Q ≠ I \mathbf Q^T\mathbf Q\neq \mathbf IQTQ=I,除非Q \mathbf QQ为方阵)
ps. Q \mathbf QQ不一定为方阵,例如三维空间中两个正交的基向量,也可以构成一个Q \mathbf QQ;
但是,如果Q \mathbf QQ为方阵,则其列向量就是R n \mathbf R^nRn空间的一组标准正交基(n nn个长度为1的n × 1 n \times 1n×1基向量)
当Q \mathbf QQ为方阵时,这样以一组标准正交基作为列向量的矩阵称为正交矩阵 Orthogonal matrix
正交矩阵满足Q T Q = Q Q T = I \mathbf Q^T\mathbf Q=\mathbf Q\mathbf Q^T=\mathbf IQTQ=QQT=I,Q − 1 = Q T \mathbf Q^{-1}=\mathbf Q^TQ−1=QT
正交矩阵特性
- 正交矩阵Q \mathbf QQ几何上对应单纯的旋转
进而,任意正交矩阵的乘积Q 1 Q 2 \mathbf Q_1\mathbf Q_2Q1Q2仍为正交矩阵 - 正交矩阵与向量相乘,不改变其长度
∥ Q x ∥ 2 = ( Q x ) T Q x = x T Q T Q x = ∥ x ∥ 2 \|\mathbf Q\mathbf x\|^2=(\mathbf Q\mathbf x)^T\mathbf Q\mathbf x=\mathbf x^T\mathbf Q^T\mathbf Q\mathbf x=\|\mathbf x\|^2∥Qx∥2=(Qx)TQx=xTQTQx=∥x∥2
或者说,Q \mathbf QQ对应的线性变换是单纯的旋转,不会拉伸基向量、不改变基向量之间的正交关系,从而该变换不会改变向量长度 - 正交矩阵Q \mathbf QQ特征值满足∣ λ ∣ = 1 |\lambda|=1∣λ∣=1(可能为复数)
证明:由Q x = λ x \mathbf Q\mathbf x=\lambda\mathbf xQx=λx得到∥ Q x ∥ 2 = λ 2 ∥ x ∥ 2 \|\mathbf Q\mathbf x\|^2=\lambda^2\|\mathbf x\|^2∥Qx∥2=λ2∥x∥2;根据上面,又有∥ Q x ∥ 2 = ∥ x ∥ 2 \|\mathbf Q\mathbf x\|^2=\|\mathbf x\|^2∥Qx∥2=∥x∥2
则λ 2 = 1 \lambda^2=1λ2=1,∣ λ ∣ = 1 |\lambda|=1∣λ∣=1
正交矩阵举例
- 置换矩阵Q = [ 0 0 1 1 0 0 0 1 0 ] \boldsymbol{Q}=\left[\begin{array}{lll} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{array}\right]Q=⎣⎡010001100⎦⎤
- Q = [ cos θ − sin θ sin θ cos θ ] \boldsymbol{Q}=\left[\begin{array}{rr} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{array}\right]Q=[cosθsinθ−sinθcosθ]
- Q = 1 2 [ 1 1 1 − 1 ] \boldsymbol{Q}=\frac{1}{\sqrt 2}\left[\begin{array}{rr} 1&1\\ 1&-1 \end{array}\right]Q=21[111−1],其中1 2 \frac{1}{\sqrt 2}21是为了保证每个列向量长度都是1 11
- 阿达玛Hadamard矩阵Q = 1 2 [ 1 1 1 1 1 − 1 1 − 1 1 1 − 1 − 1 1 − 1 − 1 1 ] \boldsymbol{Q}=\frac{1}{2}\left[\begin{array}{rrrr} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{array}\right]Q=21⎣⎡11111−11−111−1−11−1−11⎦⎤
- 三维空间中两个正交向量组成的矩阵,可以“补出”第三个基向量,得到正交矩阵
Q = 1 2 [ 1 − 2 2 − 1 2 2 ] \boldsymbol{Q}=\frac{1}{2}\left[\begin{array}{rr} 1&-2\\ 2&-1\\ 2&2 \end{array}\right]Q=21⎣⎡122−2−12⎦⎤变为Q = 1 2 [ 1 − 2 2 2 − 1 − 2 2 2 1 ] \boldsymbol{Q}=\frac{1}{2}\left[\begin{array}{rr} 1&-2&2\\ 2&-1&-2\\ 2&2&1 \end{array}\right]Q=21⎣⎡122−2−122−21⎦⎤
标准正交基/正交矩阵的优势
之前说过,如果想要将一个向量b \boldsymbol bb投影到矩阵A \mathbf AA的列空间内,做法是使用投影矩阵P \mathbf PP:
将向量b \boldsymbol bb投影到平面上得到的投影为p = P b \boldsymbol p=\mathbf P\boldsymbol bp=Pb,其中投影矩阵P = A ( A T A ) − 1 A T \mathbf P=\mathbf A(\mathbf A^T\mathbf A )^{-1}\mathbf A^TP=A(ATA)−1AT
对应这里,如果要将向量投影到正交矩阵Q \mathbf QQ的列空间内,对应的投影矩阵P = Q ( Q T Q ) − 1 Q T = Q Q T = I \mathbf P=\mathbf Q(\mathbf Q^T\mathbf Q )^{-1}\mathbf Q^T=\mathbf Q\mathbf Q^T=\mathbf IP=Q(QTQ)−1QT=QQT=I
这表明:正交矩阵这个方阵,其列空间就是整个R n \mathbf R^nRn空间(投影后仍在原点)
之前说过,A x = b \mathbf A \boldsymbol x=\boldsymbol bAx=b无解时,转而求解A T A x ^ = A T b \mathbf A^T\mathbf A \hat{\boldsymbol x}=\mathbf A^T\boldsymbol bATAx^=ATb,该方程的解x ~ \tilde{\boldsymbol x}x~会是“最优解”
对于正交矩阵Q \mathbf QQ(或者列向量都为标准正交向量的非方阵Q \mathbf QQ),直接得到Q T Q x ^ = x ^ = Q T b \mathbf Q^T\mathbf Q \hat{\boldsymbol x}=\hat{\boldsymbol x}=\mathbf Q^T\boldsymbol bQTQx^=x^=QTb
采用矩阵的QR分解(后面会介绍,即从列向量线性无关的矩阵A \mathbf AA施密特正交化,得到正交矩阵Q \mathbf QQ)来帮助求解A x = b \mathbf A \boldsymbol x=\boldsymbol bAx=b的问题,最大的优势是提高了数值的稳定性
线性无关向量组的标准正交化:施密特正交化Gram-Schmidt
已知一组线性无关的向量,希望用它们导出一组标准正交向量,
或者说,将满秩的矩阵,变为一个正交矩阵,
方法是施密特正交化Gram-Schmidt
例如,对于任意R n \mathbf R^nRn空间中的三个线性无关向量a \boldsymbol aa、b \boldsymbol bb和c \boldsymbol cc,对应构造的正交的向量为A \boldsymbol AA、B \boldsymbol BB和C \boldsymbol CC
- 对于a \boldsymbol aa,我们就采用其本身,得到正交化的向量A \boldsymbol AA
对于b \boldsymbol bb,我们只需要对A \boldsymbol AA做投影p \boldsymbol pp,然后取误差向量e = b − p \boldsymbol e=\boldsymbol b-\boldsymbol pe=b−p作为正交化的向量B \boldsymbol BB
(回忆之前的内容,求向量在另一向量上的投影,为p = a T b a T a a \boldsymbol p=\frac{\boldsymbol {a}^{T} \boldsymbol {b}}{\boldsymbol {a}^{T} \boldsymbol {a}}\boldsymbol ap=aTaaTba)
因此,B = b − A T b A T A A \boldsymbol B=\boldsymbol b-\frac{\boldsymbol {A}^{T} \boldsymbol {b}}{\boldsymbol {A}^{T} \boldsymbol {A}}\boldsymbol AB=b−ATAATbA
同理,对于第三个向量c \boldsymbol cc,也是“修剪掉”其“超出”已正交化的两个向量的那部分多余分量,得到
C = c − A T c A T A A − B T c B T B B \boldsymbol C=\boldsymbol c-\frac{\boldsymbol {A}^{T} \boldsymbol {c}}{\boldsymbol {A}^{T} \boldsymbol {A}}\boldsymbol A-\frac{\boldsymbol {B}^{T} \boldsymbol {c}}{\boldsymbol {B}^{T} \boldsymbol {B}}\boldsymbol BC=c−ATAATcA−BTBBTcB - 最后,所有正交化的向量,除以其长度,进行“标准化”,得到一组标准正交向量
q 1 = A ∥ A ∥ \boldsymbol q_1=\frac{\boldsymbol A}{\|\boldsymbol A\|}q1=∥A∥A,q 2 = B ∥ B ∥ \boldsymbol q_2=\frac{\boldsymbol B}{\|\boldsymbol B\|}q2=∥B∥B,q 3 = C ∥ C ∥ \boldsymbol q_3=\frac{\boldsymbol C}{\|\boldsymbol C\|}q3=∥C∥C
QR分解
在消元部分,学习了矩阵的LU分解得到A = L U \mathbf{A=LU}A=LU
列向量线性无关的矩阵A \mathbf AA的施密特正交化,也可表示为A = Q R \mathbf{A=QR}A=QR形式,并且R \mathbf RR必为上三角阵
另外注意:
- 正交化后列空间不变:C ( A ) = C ( Q ) C(\mathbf A)=C(\mathbf Q)C(A)=C(Q)(正交化只不过是调整了我们使用的“基向量”,使其正交)
- 矩阵R \mathbf RR必然为上三角阵:
原理:
若有A = Q R \mathbf{A=QR}A=QR,则R = Q − 1 A = Q T A \mathbf R=\mathbf Q^{-1}\mathbf A=\mathbf Q^{T}\mathbf AR=Q−1A=QTA(因为Q \mathbf QQ为正交矩阵),由此我们得到了矩阵R \mathbf RR的元素为a 1 T q 2 \boldsymbol a_1^T\boldsymbol q_2a1Tq2等,如图所示
其中,由于a 1 \boldsymbol a_1a1和q 2 \boldsymbol q_2q2必然正交(q 2 \boldsymbol q_2q2来自于a 2 \boldsymbol a_2a2的正交化),因此元素a 1 T q 2 = 0 \boldsymbol a_1^T\boldsymbol q_2=0a1Tq2=0
ps. 上面的矩阵R \mathbf RR中的元素本应为q 1 T a 1 \boldsymbol q_1^T\boldsymbol a_1q1Ta1等,但由于这是向量点积,结果是一个数字,因此下面写作a 1 T q 2 \boldsymbol a_1^T\boldsymbol q_2a1Tq2也可以
理解:
- 由于矩阵右乘对应于列的线性组合,A = Q R \mathbf{A=QR}A=QR可以视为:矩阵R \mathbf RR对于正交矩阵Q \mathbf QQ的列向量做操作
- 且Q \mathbf QQ的列向量为一组标准正交基,用R \mathbf RR中的元素对标准正交基加权组合,得到了另一组线性无关的向量,即A \mathbf AA的列向量
由此也能进一步理解为何R \mathbf RR为上三角矩阵:这样保证了一组标准正交基经过线性组合后,A \mathbf AA中不会出现线性相关的向量(每个向量仍然都贡献 / 张成一个新的维度)