# 跡

${\displaystyle \mathbf {A} ={\begin{bmatrix}1&2\\3&4\end{bmatrix}}}$

${\displaystyle \operatorname {tr} (\mathbf {A} )=\mathbf {A} _{1,1}+\mathbf {A} _{2,2}+\cdots +\mathbf {A} _{n,n}}$

## 例子

${\displaystyle \mathbf {A} ={\begin{bmatrix}3&5&1\\0&9&2\\7&6&4\end{bmatrix}}}$

${\displaystyle \operatorname {tr} (\mathbf {A} )=\operatorname {tr} {\begin{bmatrix}3&5&1\\0&9&2\\7&6&4\end{bmatrix}}}$ = 3 + 9 + 4 = 16

## 性質

### 线性函数

${\displaystyle \mathrm {tr} (\mathbf {A} +\mathbf {B} )=\mathrm {tr} (\mathbf {A} )+\mathrm {tr} (\mathbf {B} )}$
${\displaystyle \mathrm {tr} (r\cdot \mathbf {A} )=r\cdot \mathrm {tr} (\mathbf {A} )}$[2]

${\displaystyle \mathrm {tr} (\mathbf {A} )=\mathrm {tr} \left(\mathbf {A} ^{T}\right)}$

### 矩阵乘积的迹数

A是一個${\displaystyle n\times m}$矩陣，B是個${\displaystyle m\times n}$矩陣，則：

${\displaystyle \mathrm {tr} (\mathbf {AB} )=\mathrm {tr} (\mathbf {BA} )}$[2]

${\displaystyle \mathrm {tr} (\mathbf {AB} )=\sum _{i=1}^{n}(\mathbf {AB} )_{ii}=\sum _{i=1}^{n}\sum _{j=1}^{m}\mathbf {A} _{ij}\mathbf {B} _{ji}=\sum _{j=1}^{m}\sum _{i=1}^{n}\mathbf {B} _{ji}\mathbf {A} _{ij}=\sum _{j=1}^{m}(\mathbf {BA} )_{jj}=\mathrm {tr} (\mathbf {BA} )}$

${\displaystyle \mathrm {tr} (\mathbf {ABC} )=\mathrm {tr} (\mathbf {BCA} )=\mathrm {tr} (\mathbf {CAB} )}$[3]

${\displaystyle \mathrm {tr} (\mathbf {ABC} )\neq \mathrm {tr} (\mathbf {ACB} )}$[3]

${\displaystyle \mathrm {tr} (\mathbf {ABC} )=\mathrm {tr} (\mathbf {BCA} )=\mathrm {tr} (\mathbf {CAB} )=\mathrm {tr} (\mathbf {ACB} )=\mathrm {tr} (\mathbf {CBA} )=\mathrm {tr} (\mathbf {BAC} )}$

### 矩阵迹数和特征多项式

${\displaystyle P_{A}(\lambda )=\det(\mathbf {A} -\lambda \mathbf {I} )}$

${\displaystyle P_{A}(\lambda )=(-1)^{n}\lambda ^{n}+(-1)^{n-1}\mathrm {tr} (\mathbf {A} )\lambda ^{n-1}+\cdots +\det(\mathbf {A} )}$

### 矩阵迹数与特征值

${\displaystyle P_{A}(\lambda )=(-1)^{n}(\lambda -r_{1})^{\alpha _{1}}(\lambda -r_{2})^{\alpha _{2}}\cdots (\lambda -r_{k})^{\alpha _{k}}}$

${\displaystyle \mathrm {tr} (\mathbf {A} )=\alpha _{1}r_{1}+\alpha _{2}r_{2}+\cdots +\alpha _{k}r_{k}}$

${\displaystyle \mathrm {tr} (\mathbf {A} )=\lambda _{1}+\lambda _{2}+\cdots +\lambda _{n}}$

${\displaystyle \forall m\in \mathbb {N} ,\mathrm {tr} (\mathbf {A} ^{m})=\lambda _{1}^{m}+\lambda _{2}^{m}+\cdots +\lambda _{n}^{m}}$

## 線性映射的跡數

${\displaystyle Sp:\;\;\;\quad \mathbb {V} ^{n}\qquad \;\quad \longrightarrow \quad \qquad \qquad \qquad \mathbb {K} \qquad \qquad \qquad ,}$
${\displaystyle Sp:(x_{1},x_{2},\cdots ,x_{n})\longmapsto \sum _{i=1}^{n}\det(x_{1},x_{2},\cdots ,f(x_{i}),\cdots ,x_{n})}$

${\displaystyle Sp(x_{1},x_{2},\cdots ,x_{n})=\mathrm {Sp} (f)\cdot \det(x_{1},x_{2},\cdots ,x_{n})}$[5]

## 迹的梯度

### 单个矩阵

• A是m×m矩阵时，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} )}{\partial \mathbf {A} }}={\mathbf {I} }_{m}}$
• m×m矩阵A可逆时，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} ^{-1})}{\partial \mathbf {A} }}=-(\mathbf {A} ^{-2})^{T}}$
• 对于两个向量xy的外积，有${\displaystyle {\frac {\partial \mathrm {tr} ({\boldsymbol {xy}}^{T})}{\partial {\boldsymbol {x}}}}={\frac {\partial \mathrm {tr} ({\boldsymbol {yx}}^{T})}{\partial {\boldsymbol {x}}}}={\boldsymbol {y}}}$

### 两个矩阵

• A为m×n矩阵，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} \mathbf {A} ^{T})}{\partial \mathbf {A} }}={\frac {\partial \mathrm {tr} (\mathbf {A} ^{T}\mathbf {A} )}{\partial \mathbf {A} }}=2\mathbf {A} }$
• A为m×m矩阵，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} ^{2})}{\partial \mathbf {A} }}={\frac {\partial \mathrm {tr} (\mathbf {A} \mathbf {A} )}{\partial \mathbf {A} }}=2\mathbf {A} ^{T}}$
• A为m×n矩阵，B是m×n矩阵，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} ^{T}\mathbf {B} )}{\partial \mathbf {A} }}={\frac {\partial \mathrm {tr} (\mathbf {B} \mathbf {A} ^{T})}{\partial \mathbf {A} }}=\mathbf {B} }$
• A为m×n矩阵，B是n×m矩阵，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} \mathbf {B} )}{\partial \mathbf {A} }}={\frac {\partial \mathrm {tr} (\mathbf {B} \mathbf {A} )}{\partial \mathbf {A} }}=\mathbf {B} ^{T}}$
• AB均为对称矩阵时，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {A} \mathbf {B} )}{\partial \mathbf {A} }}={\frac {\partial \mathrm {tr} (\mathbf {B} \mathbf {A} )}{\partial \mathbf {A} }}=\mathbf {B} +\mathbf {B} ^{T}-diag(\mathbf {B} )}$
• AB都是m×m矩阵，并且A是非奇异矩阵，有${\displaystyle {\frac {\partial \mathrm {tr} (\mathbf {B} \mathbf {A} ^{-1})}{\partial \mathbf {A} }}=-(\mathbf {A} ^{-1}\mathbf {B} ^{T}\mathbf {A} ^{-1})^{T}}$

## 参考来源

1. ^ 张贤达，《矩阵分析与应用》，第54页
2. 张贤达，《矩阵分析与应用》，第55页
3. Carl Dean Meyer, Matrix Analysis and Applied Linear Algebra，第110页
4. ^ Karim M. Abadir,Jan R. Magnus, Matrix algebra，第168页
5. ^ Werner, Linear Algebra，第126页
6. ^ Werner, Linear Algebra，第127-128页

## 参考书籍

• （英文）Karim M. Abadir,Jan R. Magnus. Matrix algebra. Cambridge University Press. 2005. ISBN 978-0521537469.