矩阵的迹(Trace)及相关性质证明

时间:2024-03-31 11:53:58

1 定义

迹运算返回的是矩阵对角元素的和:
T r ( A ) = ∑ i A i i Tr(A)=\sum_iA_{ii} Tr(A)=iAii

若不使用求和符号,有些矩阵运算很难描述,而通过矩阵乘法和迹运算符号可以清楚地表示。例如,迹运算提供了另一种描述矩阵Frobenius范数的方式:
∣ ∣ A ∣ ∣ F = T r ( A A T ) ||A||_F=\sqrt{Tr(AA^T)} AF=Tr(AAT)

2 性质

用迹运算表示表达式,我们可以使用很多有用的等式巧妙地处理表达式。例如迹运算在转置运算下是不变的:
T r ( A ) = T r ( A T ) Tr(A)=Tr(A^T) Tr(A)=Tr(AT)

矩阵提出常数后,迹是不变的:
T r ( k A ) = k ∗ T r ( A ) Tr(kA)=k*Tr(A) Tr(kA)=kTr(A)

矩阵的迹的和等于矩阵和的迹:
T r ( A + B ) = T r ( A ) + T r ( B ) Tr(A+B)=Tr(A)+Tr(B) Tr(A+B)=Tr(A)+Tr(B)

多个矩阵相乘得到的方阵的迹,和将这些矩阵中的最后一个挪到最前面之后相乘的迹是相同的。当然,我们需要考虑挪动之后矩阵乘积依然定义良好:
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)

即使循环置换后矩阵乘积得到的矩阵形状变了,迹运算的结果依然不变:
T r ( A B ) = T r ( B A ) Tr(AB)=Tr(BA) Tr(AB)=Tr(BA)

证明: T r ( A B ) = T r ( B A ) Tr(AB)=Tr(BA) Tr(AB)=Tr(BA)

矩阵的迹(Trace)及相关性质证明
标量在迹运算后仍然是它自己:
a = T r ( a ) a=Tr(a) a=Tr(a)

有关偏导的性质

  1. ∂ T r ( A B ) ∂ A = B T \frac{\partial Tr(AB)}{\partial A}=B^T ATr(AB)=BT

证明:
∂ T r ( A B ) ∂ A = ∂ ∑ i = 1 m ∑ j = 1 n a i j b j i ∂ ∑ i = 1 m ∑ j = 1 n a i j = ∑ i = 1 m ∑ j = 1 n b j i = B T \frac{\partial Tr(AB)}{\partial A}=\frac{\partial \sum\limits_{i=1}^m\sum\limits_{j=1}^na_{ij}b_{ji}}{\partial\sum\limits_{i=1}^m\sum\limits_{j=1}^na_{ij}}=\sum\limits_{i=1}^m\sum\limits_{j=1}^nb_{ji}=B^T ATr(AB)=i=1mj=1naiji=1mj=1naijbji=i=1mj=1nbji=BT

  1. ∂ 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 ATr(ABATC)=CAB+CTABT

证明:
∂ T r ( A B A T C ) ∂ A = ∂ T r ( A T C A B ) ∂ A = ∂ T r ( A C T A T B T ) ∂ A = C A B + ( B A T C ) T = C A B + C T A B T \frac{\partial Tr(ABA^TC)}{\partial A}=\frac{\partial Tr(A^TCAB)}{\partial A}=\frac{\partial Tr(AC^TA^TB^T)}{\partial A}=CAB+(BA^TC)^T=CAB+C^TAB^T ATr(ABATC)=ATr(ATCAB)=ATr(ACTATBT)=CAB+(BATC)T=CAB+CTABT