实对称矩阵的谱分解·
实对称矩阵的特征值分解成为谱分解。给定一个 n × n n\times n n × n 的实对称矩阵 A A A ,其特征值分解可以写成
A = V Λ V − 1 = V Λ V ⊤ A = V \Lambda V^{-1} = V \Lambda V^{\top}
A = V Λ V − 1 = V Λ V ⊤
其中 V V V 为正交矩阵,每一列对应一个特征向量,Λ \Lambda Λ 为对角矩阵,对角元素为特征值。
将矩阵 A A A 作用于二维向量 x x x ,对应运算
A x = y Ax = y
A x = y
将其拆解为三个连续变换
A x = V Λ V ⊤ x = y Ax = V \Lambda V^{\top}x = y
A x = V Λ V ⊤ x = y
用 参考资料 中的例子,A = [ 5 4 − 3 4 − 3 4 5 4 ] A = \begin{bmatrix} \dfrac{5}{4} & -\dfrac{3}{4}\\-\dfrac{3}{4} & \dfrac{5}{4}\end{bmatrix} A = 4 5 − 4 3 − 4 3 4 5
A = [ 5 4 − 3 4 − 3 4 5 4 ] V Λ V ⊤ = [ 2 2 2 2 − 2 2 2 2 ] [ 2 0 0 1 2 ] [ 2 2 − 2 2 2 2 2 2 ] \begin{aligned}
A &= \begin{bmatrix} \dfrac{5}{4} & -\dfrac{3}{4}\\-\dfrac{3}{4} & \dfrac{5}{4}\end{bmatrix}\\
V \Lambda V^{\top}&=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & -\dfrac{\sqrt{2}}{2}\\
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\end{aligned}
A V Λ V ⊤ = 4 5 − 4 3 − 4 3 4 5 = 2 2 − 2 2 2 2 2 2 [ 2 0 0 2 1 ] 2 2 2 2 − 2 2 2 2
对两个标准正交基做几何变换
A e 1 = [ 5 4 − 3 4 − 3 4 5 4 ] [ 1 0 ] = [ 5 4 − 3 4 ] A e 1 = [ 5 4 − 3 4 − 3 4 5 4 ] [ 0 1 ] = [ − 3 4 5 4 ] \begin{aligned}
Ae_1 &=
\begin{bmatrix} \dfrac{5}{4} & -\dfrac{3}{4}\\-\dfrac{3}{4} & \dfrac{5}{4}\end{bmatrix}
\begin{bmatrix} 1\\0 \end{bmatrix}
=
\begin{bmatrix} \dfrac{5}{4}\\-\dfrac{3}{4} \end{bmatrix}\\
Ae_1 &=
\begin{bmatrix} \dfrac{5}{4} & -\dfrac{3}{4}\\-\dfrac{3}{4} & \dfrac{5}{4}\end{bmatrix}
\begin{bmatrix} 0\\1 \end{bmatrix}
=
\begin{bmatrix} -\dfrac{3}{4}\\\dfrac{5}{4} \end{bmatrix}
\end{aligned}
A e 1 A e 1 = 4 5 − 4 3 − 4 3 4 5 [ 1 0 ] = 4 5 − 4 3 = 4 5 − 4 3 − 4 3 4 5 [ 0 1 ] = − 4 3 4 5
首先 V ⊤ V^{\top} V ⊤ 先做旋转变换,
V ⊤ e 1 = [ 2 2 − 2 2 2 2 2 2 ] [ 1 0 ] = [ 2 2 2 2 ] V ⊤ e 2 = [ 2 2 − 2 2 2 2 2 2 ] [ 0 1 ] = [ − 2 2 2 2 ] \begin{aligned}
V^{\top}e_1 &=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & -\dfrac{\sqrt{2}}{2}\\
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix} 1\\0 \end{bmatrix}
=
\begin{bmatrix} \dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{2} \end{bmatrix}\\
V^{\top}e_2 &=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & -\dfrac{\sqrt{2}}{2}\\
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix} 0\\1 \end{bmatrix}
=
\begin{bmatrix} -\dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{2} \end{bmatrix}\\
\end{aligned}
V ⊤ e 1 V ⊤ e 2 = 2 2 2 2 − 2 2 2 2 [ 1 0 ] = 2 2 2 2 = 2 2 2 2 − 2 2 2 2 [ 0 1 ] = − 2 2 2 2
Λ \Lambda Λ 做缩放,
Λ ( V ⊤ e 1 ) = [ 2 0 0 1 2 ] [ 2 2 2 2 ] = [ 2 2 2 4 ] Λ ( V ⊤ e 2 ) = [ 2 0 0 1 2 ] [ − 2 2 2 2 ] = [ − 2 2 2 4 ] \begin{aligned}
\Lambda(V^{\top}e_1) &=
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}
\begin{bmatrix} \dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{2} \end{bmatrix}
=
\begin{bmatrix} \dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{4} \end{bmatrix}\\
\Lambda(V^{\top}e_2) &=
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}
\begin{bmatrix} -\dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{2} \end{bmatrix}
=
\begin{bmatrix} -\dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{4} \end{bmatrix}\\
\end{aligned}
Λ ( V ⊤ e 1 ) Λ ( V ⊤ e 2 ) = [ 2 0 0 2 1 ] 2 2 2 2 = 2 2 4 2 = [ 2 0 0 2 1 ] − 2 2 2 2 = − 2 2 4 2
最后 V V V 做旋转变换,
V ( Λ V ⊤ e 1 ) = [ 2 2 2 2 − 2 2 2 2 ] [ 2 2 2 4 ] = [ 5 4 − 3 4 ] V ( Λ V ⊤ e 2 ) = [ 2 2 2 2 − 2 2 2 2 ] [ − 2 2 2 4 ] = [ − 3 4 5 4 ] \begin{aligned}
V(\Lambda V^{\top}e_1) &=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix} \dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{4} \end{bmatrix}
=
\begin{bmatrix} \dfrac{5}{4}\\-\dfrac{3}{4} \end{bmatrix}\\
V(\Lambda V^{\top}e_2) &=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix} -\dfrac{\sqrt{2}}{2}\\\dfrac{\sqrt{2}}{4} \end{bmatrix}
=
\begin{bmatrix} -\dfrac{3}{4}\\\dfrac{5}{4} \end{bmatrix}\\
\end{aligned}
V ( Λ V ⊤ e 1 ) V ( Λ V ⊤ e 2 ) = 2 2 − 2 2 2 2 2 2 2 2 4 2 = 4 5 − 4 3 = 2 2 − 2 2 2 2 2 2 − 2 2 4 2 = − 4 3 4 5
矩阵 A A A 的特征向量为
v 1 = [ 2 2 − 2 2 ] , v 2 = [ 2 2 2 2 ] v_1 = \begin{bmatrix}
\dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2}\\
\end{bmatrix},\space
v_2 = \begin{bmatrix}
\dfrac{\sqrt{2}}{2}\\
\dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
v 1 = 2 2 − 2 2 , v 2 = 2 2 2 2
变换 V Λ V ⊤ V\Lambda V^{\top} V Λ V ⊤ 对特征向量 v 1 , v 2 v_1, v_2 v 1 , v 2 的作用为
V ⊤ [ v 1 v 2 ] = [ 2 2 − 2 2 2 2 2 2 ] ⋅ [ 2 2 2 2 − 2 2 2 2 ] = [ 1 0 0 1 ] Λ V ⊤ [ v 1 v 2 ] = [ 2 0 0 1 2 ] ⋅ [ 1 0 0 1 ] = [ 2 0 0 1 2 ] V Λ V ⊤ = [ 2 2 2 2 − 2 2 2 2 ] ⋅ [ 2 0 0 1 2 ] = [ 2 v 1 1 2 v 2 ] \begin{aligned}
V^{\top} \begin{bmatrix} v_1 & v_2 \end{bmatrix}
&=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & -\dfrac{\sqrt{2}}{2}\\
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\cdot
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0\\
0 & 1\\
\end{bmatrix}\\
\Lambda V^{\top} \begin{bmatrix} v_1 & v_2 \end{bmatrix}
&=
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}
\cdot
\begin{bmatrix}
1 & 0\\
0 & 1\\
\end{bmatrix}
=
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}\\
V\Lambda V^{\top}
&=
\begin{bmatrix}
\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
-\dfrac{\sqrt{2}}{2} & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\cdot
\begin{bmatrix}
2 & 0\\
0 & \dfrac{1}{2}\\
\end{bmatrix}
=
\begin{bmatrix}
2v_1 & \dfrac{1}{2}v_2\\
\end{bmatrix}
\end{aligned}
V ⊤ [ v 1 v 2 ] Λ V ⊤ [ v 1 v 2 ] V Λ V ⊤ = 2 2 2 2 − 2 2 2 2 ⋅ 2 2 − 2 2 2 2 2 2 = [ 1 0 0 1 ] = [ 2 0 0 2 1 ] ⋅ [ 1 0 0 1 ] = [ 2 0 0 2 1 ] = 2 2 − 2 2 2 2 2 2 ⋅ [ 2 0 0 2 1 ] = [ 2 v 1 2 1 v 2 ]
可视化的 Python 程序见附录。
瑞利商·
给定实数矩阵 A A A ,定义其瑞利商为
R ( x ) = x ⊤ A x x ⊤ x R(x) = \dfrac{x^{\top}Ax}{x^{\top}x}
R ( x ) = x ⊤ x x ⊤ A x
当向量 x x x 为矩阵特征向量时,R ( x ) R(x) R ( x ) 为对应的特征值
v 1 ⊤ A v 1 = v 1 ⊤ λ v 1 ⇒ λ = v 1 ⊤ A v 1 v 1 ⊤ v 1 v_1^{\top}Av_1 = v_1^{\top}\lambda v_1\Rightarrow \lambda = \dfrac{v_1^{\top}Av_1}{v_1^{\top} v_1}
v 1 ⊤ A v 1 = v 1 ⊤ λ v 1 ⇒ λ = v 1 ⊤ v 1 v 1 ⊤ A v 1
对于实对称矩阵 A A A ,瑞利商的最大值为最大特征值,最小值为最小特征值,驻点对应所有特征向量。
圆锥曲线——椭圆·
设椭圆半长轴的长度为 λ 1 \lambda_1 λ 1 ,半短轴的长度为 λ 2 \lambda_2 λ 2 ,椭圆的解析式为
x 1 2 λ 1 2 + x 2 2 λ 2 2 = 1 \dfrac{x_1^2}{\lambda_1^2} + \dfrac{x_2^2}{\lambda_2^2} = 1
λ 1 2 x 1 2 + λ 2 2 x 2 2 = 1
写成矩阵乘法的形式
[ x 1 x 2 ] [ 1 λ 1 2 0 0 1 λ 2 2 ] [ x 1 x 2 ] = 1 \begin{bmatrix}
x_1 & x_2\\
\end{bmatrix}
\begin{bmatrix}
\dfrac{1}{\lambda_1^2} & 0\\
0 & \dfrac{1}{\lambda_2^2}\\
\end{bmatrix}
\begin{bmatrix}
x_1 \\ x_2\\
\end{bmatrix}
= 1
[ x 1 x 2 ] λ 1 2 1 0 0 λ 2 2 1 [ x 1 x 2 ] = 1
设单位向量 z = [ z 1 z 2 ] z = \begin{bmatrix} z_1 \\ z_2 \end{bmatrix} z = [ z 1 z 2 ] ,满足 z ⊤ z = z 1 2 = z 2 2 = 1 z^{\top}z = z_1^2 = z_2^2 = 1 z ⊤ z = z 1 2 = z 2 2 = 1 ,
矩阵 A A A 作用与 z z z 后得到椭圆上的向量 x x x ,A z = x Az=x A z = x ,则 z = A − 1 x z=A^{-1}x z = A − 1 x
则
( A − 1 x ) ⊤ A − 1 x = 1 x ⊤ ( A − 1 ) ⊤ A − 1 x = 1 x ⊤ ( V Λ − 1 V ⊤ ) ⊤ V Λ − 1 V ⊤ x = 1 x ⊤ V Λ − 1 V ⊤ V Λ − 1 V ⊤ x = 1 ( V ⊤ x ) ⊤ Λ − 2 ( V ⊤ x ) = 1 \begin{aligned}
(A^{-1}x)^{\top}A^{-1}x &= 1\\
x^{\top}(A^{-1})^{\top}A^{-1}x &= 1\\
x^{\top}(V\Lambda^{-1}V^{\top})^{\top}V\Lambda^{-1}V^{\top}x &= 1\\
x^{\top}V\Lambda^{-1}V^{\top}V\Lambda^{-1}V^{\top}x &= 1\\
(V^{\top}x)^{\top}\Lambda^{-2}(V^{\top}x) &= 1\\
\end{aligned}
( A − 1 x ) ⊤ A − 1 x x ⊤ ( A − 1 ) ⊤ A − 1 x x ⊤ ( V Λ − 1 V ⊤ ) ⊤ V Λ − 1 V ⊤ x x ⊤ V Λ − 1 V ⊤ V Λ − 1 V ⊤ x ( V ⊤ x ) ⊤ Λ − 2 ( V ⊤ x ) = 1 = 1 = 1 = 1 = 1
令 y = V ⊤ x y = V^{\top}x y = V ⊤ x ,则
y ⊤ Λ − 2 y = 1 y^{\top} \Lambda^{-2}y = 1
y ⊤ Λ − 2 y = 1
即
[ y 1 y 2 ] [ 1 λ 1 2 0 0 1 λ 2 2 ] [ y 1 y 2 ] = 1 y 1 2 λ 1 2 + y 2 2 λ 2 2 = 1 \begin{aligned}
\begin{bmatrix}
y_1 & y_2\\
\end{bmatrix}
\begin{bmatrix}
\dfrac{1}{\lambda_1^2} & 0\\
0 & \dfrac{1}{\lambda_2^2}\\
\end{bmatrix}
\begin{bmatrix}
y_1 \\ y_2\\
\end{bmatrix}
&= 1\\
\dfrac{y_1^2}{\lambda_1^2} + \dfrac{y_2^2}{\lambda_2^2} &= 1
\end{aligned}
[ y 1 y 2 ] λ 1 2 1 0 0 λ 2 2 1 [ y 1 y 2 ] λ 1 2 y 1 2 + λ 2 2 y 2 2 = 1 = 1
非对称方阵的特征分解·
Gram 矩阵·
设矩阵 A A A 为 m × p m\times p m × p 的矩阵,A A A 的 Gram 矩阵为
G = A ⊤ A = [ ⟨ a 0 , a 0 ⟩ ⟨ a 0 , a 1 ⟩ ⋯ ⟨ a 0 , a p − 1 ⟩ ⟨ a 1 , a 0 ⟩ ⟨ a 1 , a 1 ⟩ ⋯ ⟨ a 1 , a p − 1 ⟩ ⋮ ⋮ ⋱ ⋮ ⟨ a m − 1 , a 0 ⟩ ⟨ a m − 1 , a 1 ⟩ ⋯ ⟨ a m − 1 , a p − 1 ⟩ ] G = A^{\top}A = \begin{bmatrix}
\langle a_0, a_0 \rangle & \langle a_0, a_1 \rangle & \cdots & \langle a_0, a_{p-1} \rangle\\
\langle a_1, a_0 \rangle & \langle a_1, a_1 \rangle & \cdots & \langle a_1, a_{p-1} \rangle\\
\vdots & \vdots & \ddots & \vdots\\
\langle a_{m-1}, a_0 \rangle & \langle a_{m-1}, a_1 \rangle & \cdots & \langle a_{m-1}, a_{p-1} \rangle\\
\end{bmatrix}
G = A ⊤ A = ⟨ a 0 , a 0 ⟩ ⟨ a 1 , a 0 ⟩ ⋮ ⟨ a m − 1 , a 0 ⟩ ⟨ a 0 , a 1 ⟩ ⟨ a 1 , a 1 ⟩ ⋮ ⟨ a m − 1 , a 1 ⟩ ⋯ ⋯ ⋱ ⋯ ⟨ a 0 , a p − 1 ⟩ ⟨ a 1 , a p − 1 ⟩ ⋮ ⟨ a m − 1 , a p − 1 ⟩
形状为 p × p p\times p p × p ,是实对称矩阵,并且 Gram 矩阵是半正定矩阵,对于任意 p p p 维非零列向量 x x x 有
x ⊤ G x = x ⊤ A ⊤ A x = ( A x ) ⊤ ( A x ) = ∣ ∣ A x ∣ ∣ 2 ≥ 0 x^{\top}Gx = x^{\top}A^{\top}Ax = (Ax)^{\top}(Ax) = ||Ax||^2 \geq 0
x ⊤ G x = x ⊤ A ⊤ A x = ( A x ) ⊤ ( A x ) = ∣∣ A x ∣ ∣ 2 ≥ 0
非对称方阵的 EVD·
设矩阵 A = [ 2 1 0 1 ] A=\begin{bmatrix} 2 & 1\\0 & 1\\ \end{bmatrix} A = [ 2 0 1 1 ] ,分解为
A = V Λ V − 1 = [ 1 − 2 2 0 2 2 ] [ 2 0 0 1 ] [ 1 1 0 2 ] A = V\Lambda V^{-1}=
\begin{bmatrix}
1 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix}
2 & 0\\
0 & 1\\
\end{bmatrix}
\begin{bmatrix}
1 & 1\\
0 & \sqrt{2}\\
\end{bmatrix}
A = V Λ V − 1 = 1 0 − 2 2 2 2 [ 2 0 0 1 ] [ 1 0 1 2 ]
下面考查非对称矩阵 A A A 对标准正交基的作用,与对称矩阵不同的是 V V V 和 V − 1 V^{-1} V − 1 的几何变换
将 V V V 拆成两个矩阵相乘的形式
V = [ 1 − 2 2 0 2 2 ] = [ 1 − 1 0 1 ] [ 1 0 0 2 2 ] = S K V = \begin{bmatrix}
1 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
= \begin{bmatrix}
1 & -1\\
0 & 1\\
\end{bmatrix}
\begin{bmatrix}
1 & 0\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
= SK
V = 1 0 − 2 2 2 2 = [ 1 0 − 1 1 ] 1 0 0 2 2 = S K
分别对应了 缩放 和 剪切 的几何变换,同理
V − 1 = [ 1 1 0 2 ] = [ 1 0 0 2 ] [ 1 1 0 1 ] = K − 1 S − 1 V^{-1} = \begin{bmatrix}
1 & 1\\
0 & \sqrt{2}\\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0\\
0 & \sqrt{2}\\
\end{bmatrix}
\begin{bmatrix}
1 & 1\\
0 & 1\\
\end{bmatrix}
=
K^{-1}S^{-1}
V − 1 = [ 1 0 1 2 ] = [ 1 0 0 2 ] [ 1 0 1 1 ] = K − 1 S − 1
因为 det ( V ) det ( V − 1 ) = 1 \det{(V)}\det{(V^{-1})}=1 det ( V ) det ( V − 1 ) = 1 ,因此 V , V − 1 V, V^{-1} V , V − 1 对于面积的影响可以相互抵消。因此矩阵 A A A 对于面积的影响全来自于 Λ \Lambda Λ
det ( A ) = det ( Λ ) \det{(A)} = \det{(\Lambda)}
det ( A ) = det ( Λ )
总得来说,非对称矩阵 A A A 表示为
A = V Λ V − 1 = = S K ⏟ V Λ K − 1 S − 1 ⏟ V − 1 A = V\Lambda V^{-1}= = \underbrace{SK}_V \Lambda \underbrace{K^{-1}S^{-1}}_{V^{-1}}
A = V Λ V − 1 == V S K Λ V − 1 K − 1 S − 1
对应的几何变换为 剪切 → 缩放 → 缩放 → 缩放 → 剪切 。
A = V Λ V − 1 = [ 1 − 2 2 0 2 2 ] [ 2 0 0 1 ] [ 1 1 0 2 ] A = V\Lambda V^{-1}=
\begin{bmatrix}
1 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
\begin{bmatrix}
2 & 0\\
0 & 1\\
\end{bmatrix}
\begin{bmatrix}
1 & 1\\
0 & \sqrt{2}\\
\end{bmatrix}
A = V Λ V − 1 = 1 0 − 2 2 2 2 [ 2 0 0 1 ] [ 1 0 1 2 ]
矩阵 A A A 的特征向量为
[ v 1 , v 2 ] = [ 1 − 2 2 0 2 2 ] [v_1, v_2] = \begin{bmatrix}
1 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
[ v 1 , v 2 ] = 1 0 − 2 2 2 2
矩阵 A A A 对特征向量 [ v 1 , v 2 ] [v_1, v_2] [ v 1 , v 2 ] 的作用为
A [ v 1 , v 2 ] = [ 2 1 0 1 ] [ 1 − 2 2 0 2 2 ] = [ 2 − 2 2 0 2 2 ] = [ 2 v 1 , v 2 ] A [v_1, v_2] =
\begin{bmatrix}
2 & 1\\0 & 1\\
\end{bmatrix}
\begin{bmatrix}
1 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
=
\begin{bmatrix}
2 & -\dfrac{\sqrt{2}}{2}\\
0 & \dfrac{\sqrt{2}}{2}\\
\end{bmatrix}
=
[2v_1, v_2]
A [ v 1 , v 2 ] = [ 2 0 1 1 ] 1 0 − 2 2 2 2 = 2 0 − 2 2 2 2 = [ 2 v 1 , v 2 ]
参考资料·
Visualize-ML/Linear-Algebra-Made-Easy—Learn-with-Python-and-Visualization
可视化 :分别从标准正交基和特征向量的角度看谱分解(Python 代码由 GPT-5.1 参考正文内容生成,仅供参考)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 import numpy as npimport matplotlib.pyplot as plte1 = np.array([1 , 0 ]) e2 = np.array([0 , 1 ]) v1 = np.array([np.sqrt(2 )/2 , -np.sqrt(2 )/2 ]) v2 = np.array([np.sqrt(2 )/2 , np.sqrt(2 )/2 ]) V = np.column_stack([v1, v2]) Lambda = np.diag([2 , 0.5 ]) VT = V.T A = V @ Lambda @ VT Ae1 = A.dot(e1) Ae2 = A.dot(e2) theta = np.linspace(0 , 2 *np.pi, 400 ) circle = np.vstack([np.cos(theta), np.sin(theta)]) ellipse = A.dot(circle) Av1 = A.dot(v1) Av2 = A.dot(v2) fig, axes = plt.subplots(1 , 2 , figsize=(12 , 6 )) ax = axes[0 ] ax.set_title("Spectral Decomposition from Standard Basis" ) ax.set_xlim(-2 , 2 ) ax.set_ylim(-2 , 2 ) ax.axhline(0 , color='gray' ) ax.axvline(0 , color='gray' ) ax.set_aspect('equal' ) ax.plot(circle[0 ], circle[1 ], 'k--' , label="Unit Circle" ) ax.plot(ellipse[0 ], ellipse[1 ], 'r' , label="Ellipse = A(Unit Circle)" ) ax.arrow(0 , 0 , e1[0 ], e1[1 ], width=0.01 , color='black' , label='e1' ) ax.arrow(0 , 0 , e2[0 ], e2[1 ], width=0.01 , color='black' , label='e2' ) ax.arrow(0 , 0 , Ae1[0 ], Ae1[1 ], width=0.01 , color='red' , label='A e1' ) ax.arrow(0 , 0 , Ae2[0 ], Ae2[1 ], width=0.01 , color='blue' , label='A e2' ) ax.legend(loc="upper left" ) ax = axes[1 ] ax.set_title("Spectral Decomposition from Eigenvector Basis" ) ax.set_xlim(-2 , 2 ) ax.set_ylim(-2 , 2 ) ax.axhline(0 , color='gray' ) ax.axvline(0 , color='gray' ) ax.set_aspect('equal' ) ax.plot(circle[0 ], circle[1 ], 'k--' , label="Unit Circle" ) ax.plot(ellipse[0 ], ellipse[1 ], 'r' , label="Ellipse = A(Unit Circle)" ) ax.arrow(0 , 0 , v1[0 ], v1[1 ], width=0.01 , color='purple' , label='v1' ) ax.arrow(0 , 0 , v2[0 ], v2[1 ], width=0.01 , color='brown' , label='v2' ) ax.arrow(0 , 0 , Av1[0 ], Av1[1 ], width=0.01 , color='purple' , alpha=0.6 , label='lambda1 * v1' ) ax.arrow(0 , 0 , Av2[0 ], Av2[1 ], width=0.01 , color='brown' , alpha=0.6 , label='lambda2 * v2' ) ax.legend(loc="upper left" ) plt.tight_layout() plt.show()
可视化 :圆锥曲线——椭圆(Python 代码由 GPT-5.1 参考正文内容生成,仅供参考)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 import numpy as npimport matplotlib.pyplot as pltlambda_1 = 3.0 lambda_2 = 1.5 Lambda = np.diag([lambda_1, lambda_2]) theta = np.deg2rad(30 ) V = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]) A = V @ Lambda @ V.T t = np.linspace(0 , 2 *np.pi, 400 ) z = np.vstack([np.cos(t), np.sin(t)]) x = A @ z y = V.T @ x plt.figure(figsize=(7 ,7 )) plt.plot(x[0 , :], x[1 , :], label='Ellipse x = A z' , linewidth=2 ) plt.plot(y[0 , :], y[1 , :], label='y = V^T x (Axis-aligned ellipse)' , linestyle='--' ) plt.plot(z[0 , :], z[1 , :], label='Unit Circle z' , linestyle=':' ) plt.axhline(0 , color='black' , linewidth=0.5 ) plt.axvline(0 , color='black' , linewidth=0.5 ) plt.gca().set_aspect('equal' , 'box' ) plt.legend() plt.title("Ellipse Visualization by Matrix Transformations" ) plt.xlabel("x1 / y1" ) plt.ylabel("x2 / y2" ) plt.grid(True ) plt.show()
讨论
评论