赞
踩
已知方阵
A
A
A,求
A
−
1
2
A^{-\frac{1}{2}}
A−21。
从以下思路入手,假设存在对角矩阵
Λ
\Lambda
Λ 使得下式成立:
P
−
1
A
P
=
Λ
Λ
=
diag
[
μ
1
,
μ
2
,
⋯
,
μ
n
]
P^{-1}AP = \Lambda \\ \Lambda = \text{diag}[\mu_1, \mu_2, \cdots, \mu_n]
P−1AP=ΛΛ=diag[μ1,μ2,⋯,μn]
则:
A
−
1
2
=
P
P
−
1
A
−
1
2
P
P
−
1
=
P
Λ
−
1
2
P
−
1
A^{-\frac{1}{2}} = PP^{-1}A^{-\frac{1}{2}}PP^{-1} =P \Lambda^{-\frac{1}{2}} P^{-1}
A−21=PP−1A−21PP−1=PΛ−21P−1
Λ
−
1
2
=
diag
[
μ
1
−
1
2
,
μ
2
−
1
2
,
⋯
,
μ
n
−
1
2
]
\Lambda^{-\frac{1}{2}} = \text{diag}[\mu_1^{-\frac{1}{2}}, \mu_2^{-\frac{1}{2}}, \cdots, \mu_n^{-\frac{1}{2}}]
Λ−21=diag[μ1−21,μ2−21,⋯,μn−21]
import numpy as np
from numpy import linalg as la
# v 为特征值 Q 为特征向量
v, Q = la.eig(A)
# print(v)
V = np.diag(v**(-0.5))
# print(V)
T = Q * V * la.inv(Q)
之前写错了矩阵求逆的代码,已更正。不过有没有人试过下面这两种效果是不是一样的
T = Q * V * la.inv(Q)
T = Q * V * (Q**(-1))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。