矩阵迹的有关公式
1. 迹的定义
设矩阵
A
=
[
a
i
j
]
A=[ a_{ij}]
A=[aij]为大小为
n
×
n
n\times n
n×n的矩阵,矩阵
A
A
A的迹定义如下:
t
r
(
A
)
=
∑
i
=
1
n
a
i
i
tr(A)=\sum_{i=1}^{n} a_{ii}
tr(A)=i=1∑naii
2. 常用公式
公式1:两个矩阵乘积的迹: t r ( A B ) = t r ( B A ) tr(AB) = tr(BA) tr(AB)=tr(BA)
公式2:三个矩阵乘积的迹:
t r ( A B C ) = t r ( C A B ) = t r ( B C A ) tr(ABC) = tr(CAB) = tr(BCA) tr(ABC)=tr(CAB)=tr(BCA)
公式3: t r ( A ) = t r ( A T ) tr(A) = tr(A^T) tr(A)=tr(AT)
3. 迹的求导
公式4 矩阵乘积的迹的求导:
∂ t r ( A B ) ∂ A = ∂ t r ( B A ) ∂ A = B T \frac{\partial tr(AB)}{\partial A} = \frac{\partial tr(BA)}{\partial A} = B^T ∂A∂tr(AB)=∂A∂tr(BA)=BT
公式5 矩阵转置乘积的求导:
∂ t r ( A T B ) ∂ A = ∂ t r ( B A T ) ∂ A = B \frac{\partial tr(A^TB)}{\partial A} = \frac{\partial tr(BA^T)}{\partial A} = B ∂A∂tr(ATB)=∂A∂tr(BAT)=B
公式6 包含两个变量矩阵的求导(自身及转置):
∂
t
r
(
A
B
A
T
C
)
∂
A
=
C
A
B
+
C
T
A
B
T
\frac{\partial tr(ABA^TC)}{\partial A} = CAB + C^TAB^T
∂A∂tr(ABATC)=CAB+CTABT
证明:
分布求导,可得:
∂
t
r
(
A
B
A
T
C
)
∂
A
=
∂
t
r
(
A
B
A
T
C
)
∂
A
+
∂
t
r
(
A
T
C
A
B
)
∂
A
\frac{\partial tr(ABA^TC)}{\partial A} =\frac{\partial {tr(ABA^TC)}}{\partial{A}} + \frac{\partial{tr(A^TCAB)}}{\partial{A}}
∂A∂tr(ABATC)=∂A∂tr(ABATC)+∂A∂tr(ATCAB)
又
∂
t
r
(
A
B
A
T
C
)
∂
A
=
(
B
A
T
C
)
T
=
C
T
A
B
T
\frac{\partial {tr(ABA^TC)}}{\partial{A}} = (BA^TC)^T=C^TAB^T
∂A∂tr(ABATC)=(BATC)T=CTABT
且
∂
t
r
(
A
T
C
A
B
)
∂
A
=
C
A
B
\frac{\partial{tr(A^TCAB)}}{\partial{A}} = CAB
∂A∂tr(ATCAB)=CAB
所以,
∂
t
r
(
A
B
A
T
C
)
∂
A
=
C
A
B
+
C
T
A
B
T
\frac{\partial tr(ABA^TC)}{\partial A} = CAB + C^TAB^T
∂A∂tr(ABATC)=CAB+CTABT