实对称矩阵的谱分解·

实对称矩阵的特征值分解成为谱分解。给定一个 n×nn\times n 的实对称矩阵 AA,其特征值分解可以写成

A=VΛV1=VΛVA = V \Lambda V^{-1} = V \Lambda V^{\top}

其中 VV 为正交矩阵,每一列对应一个特征向量,Λ\Lambda 为对角矩阵,对角元素为特征值。

将矩阵 AA 作用于二维向量 xx,对应运算

Ax=yAx = y

将其拆解为三个连续变换

Ax=VΛVx=yAx = V \Lambda V^{\top}x = y

参考资料 中的例子,A=[54343454]A = \begin{bmatrix} \dfrac{5}{4} & -\dfrac{3}{4}\\-\dfrac{3}{4} & \dfrac{5}{4}\end{bmatrix}

A=[54343454]VΛV=[22222222][20012][22222222]\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}

对两个标准正交基做几何变换

Ae1=[54343454][10]=[5434]Ae1=[54343454][01]=[3454]\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}

首先 VV^{\top} 先做旋转变换,

Ve1=[22222222][10]=[2222]Ve2=[22222222][01]=[2222]\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}

Λ\Lambda 做缩放,

Λ(Ve1)=[20012][2222]=[2224]Λ(Ve2)=[20012][2222]=[2224]\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}

最后 VV 做旋转变换,

V(ΛVe1)=[22222222][2224]=[5434]V(ΛVe2)=[22222222][2224]=[3454]\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}


矩阵 AA 的特征向量为

v1=[2222], v2=[2222]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ΛVV\Lambda V^{\top} 对特征向量 v1,v2v_1, v_2 的作用为

V[v1v2]=[22222222][22222222]=[1001]ΛV[v1v2]=[20012][1001]=[20012]VΛV=[22222222][20012]=[2v112v2]\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}

可视化的 Python 程序见附录。

瑞利商·

给定实数矩阵 AA,定义其瑞利商为

R(x)=xAxxxR(x) = \dfrac{x^{\top}Ax}{x^{\top}x}

当向量 xx 为矩阵特征向量时,R(x)R(x) 为对应的特征值

v1Av1=v1λv1λ=v1Av1v1v1v_1^{\top}Av_1 = v_1^{\top}\lambda v_1\Rightarrow \lambda = \dfrac{v_1^{\top}Av_1}{v_1^{\top} v_1}

对于实对称矩阵 AA,瑞利商的最大值为最大特征值,最小值为最小特征值,驻点对应所有特征向量。

圆锥曲线——椭圆·

设椭圆半长轴的长度为 λ1\lambda_1,半短轴的长度为 λ2\lambda_2,椭圆的解析式为

x12λ12+x22λ22=1\dfrac{x_1^2}{\lambda_1^2} + \dfrac{x_2^2}{\lambda_2^2} = 1

写成矩阵乘法的形式

[x1x2][1λ12001λ22][x1x2]=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

设单位向量 z=[z1z2]z = \begin{bmatrix} z_1 \\ z_2 \end{bmatrix},满足 zz=z12=z22=1z^{\top}z = z_1^2 = z_2^2 = 1

矩阵 AA 作用与 zz 后得到椭圆上的向量 xxAz=xAz=x,则 z=A1xz=A^{-1}x

(A1x)A1x=1x(A1)A1x=1x(VΛ1V)VΛ1Vx=1xVΛ1VVΛ1Vx=1(Vx)Λ2(Vx)=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}

y=Vxy = V^{\top}x,则

yΛ2y=1y^{\top} \Lambda^{-2}y = 1

[y1y2][1λ12001λ22][y1y2]=1y12λ12+y22λ22=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}

非对称方阵的特征分解·

Gram 矩阵·

设矩阵 AAm×pm\times p 的矩阵,AA 的 Gram 矩阵为

G=AA=[a0,a0a0,a1a0,ap1a1,a0a1,a1a1,ap1am1,a0am1,a1am1,ap1]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}

形状为 p×pp\times p,是实对称矩阵,并且 Gram 矩阵是半正定矩阵,对于任意 pp 维非零列向量 xx

xGx=xAAx=(Ax)(Ax)=Ax20x^{\top}Gx = x^{\top}A^{\top}Ax = (Ax)^{\top}(Ax) = ||Ax||^2 \geq 0

非对称方阵的 EVD·

设矩阵 A=[2101]A=\begin{bmatrix} 2 & 1\\0 & 1\\ \end{bmatrix},分解为

A=VΛV1=[122022][2001][1102]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}

下面考查非对称矩阵 AA 对标准正交基的作用,与对称矩阵不同的是 VVV1V^{-1} 的几何变换

VV 拆成两个矩阵相乘的形式

V=[122022]=[1101][10022]=SKV = \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

分别对应了 缩放剪切 的几何变换,同理

V1=[1102]=[1002][1101]=K1S1V^{-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}

因为 det(V)det(V1)=1\det{(V)}\det{(V^{-1})}=1,因此 V,V1V, V^{-1} 对于面积的影响可以相互抵消。因此矩阵 AA 对于面积的影响全来自于 Λ\Lambda

det(A)=det(Λ)\det{(A)} = \det{(\Lambda)}

总得来说,非对称矩阵 AA 表示为

A=VΛV1==SKVΛK1S1V1A = V\Lambda V^{-1}= = \underbrace{SK}_V \Lambda \underbrace{K^{-1}S^{-1}}_{V^{-1}}

对应的几何变换为 剪切 → 缩放 → 缩放 → 缩放 → 剪切


A=VΛV1=[122022][2001][1102]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}

矩阵 AA 的特征向量为

[v1,v2]=[122022][v_1, v_2] = \begin{bmatrix} 1 & -\dfrac{\sqrt{2}}{2}\\ 0 & \dfrac{\sqrt{2}}{2}\\ \end{bmatrix}

矩阵 AA 对特征向量 [v1,v2][v_1, v_2] 的作用为

A[v1,v2]=[2101][122022]=[222022]=[2v1,v2]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]

参考资料·

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 np
import matplotlib.pyplot as plt


# Standard basis
e1 = np.array([1, 0])
e2 = np.array([0, 1])
# Specify eigenvectors and eigenvalues
v1 = np.array([np.sqrt(2)/2, -np.sqrt(2)/2]) # eigenvector for eigenvalue 2
v2 = np.array([np.sqrt(2)/2, np.sqrt(2)/2]) # eigenvector for eigenvalue 1/2

V = np.column_stack([v1, v2])
Lambda = np.diag([2, 0.5])
VT = V.T

# Construct A = V Λ V^T
A = V @ Lambda @ VT

# A acting on standard basis
Ae1 = A.dot(e1)
Ae2 = A.dot(e2)

# Unit circle
theta = np.linspace(0, 2*np.pi, 400)
circle = np.vstack([np.cos(theta), np.sin(theta)])
ellipse = A.dot(circle) # image of unit circle → ellipse

# A acting on eigenvectors (pure scaling)
Av1 = A.dot(v1)
Av2 = A.dot(v2)

# ------------------------------------------------------
# Visualization
# ------------------------------------------------------
fig, axes = plt.subplots(1, 2, figsize=(12, 6))

# ------------------------------------------------------
# Figure 1: Standard basis view
# ------------------------------------------------------
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')

# Unit circle
ax.plot(circle[0], circle[1], 'k--', label="Unit Circle")

# Ellipse
ax.plot(ellipse[0], ellipse[1], 'r', label="Ellipse = A(Unit Circle)")

# Standard basis
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')

# A acting on basis vectors
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")


# ------------------------------------------------------
# Figure 2: Eigenvector basis view
# ------------------------------------------------------
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')

# Unit circle
ax.plot(circle[0], circle[1], 'k--', label="Unit Circle")

# Ellipse
ax.plot(ellipse[0], ellipse[1], 'r', label="Ellipse = A(Unit Circle)")

# Eigenvectors
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')

# Eigenvalues scaling the eigenvectors → ellipse axes
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 np
import matplotlib.pyplot as plt

# Ellipse parameters: semi-major axis λ1, semi-minor axis λ2
lambda_1 = 3.0
lambda_2 = 1.5

# Construct the diagonal matrix Λ
Lambda = np.diag([lambda_1, lambda_2])

# A = V Λ V^T, with V taken as a rotation matrix (angle is arbitrary)
theta = np.deg2rad(30) # ellipse rotation angle: 30°
V = np.array([[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]])

A = V @ Lambda @ V.T

# Parametric form of the ellipse (unit circle → ellipse)
t = np.linspace(0, 2*np.pi, 400)
z = np.vstack([np.cos(t), np.sin(t)]) # points on the unit circle

# Apply A to z to get the ellipse: x = A z
x = A @ z

# Coordinate transformation y = V^T x (ellipse → axis-aligned ellipse)
y = V.T @ x

# ==== ==== ==== ==== ==== ====
# Visualization
# ==== ==== ==== ==== ==== ====
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='--')

# Unit circle
plt.plot(z[0, :], z[1, :], label='Unit Circle z', linestyle=':')

# Draw axes
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()