# 跡

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

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

## 例子

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

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

## 性質

### 线性函数

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

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

### 矩阵乘积的迹数

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

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

$\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})$

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

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

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

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

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

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

### 矩阵迹数与特征值

$P_{A}(\lambda) = (-1)^n(\lambda - r_1)^{\alpha_1}(\lambda - r_2)^{\alpha_2} \cdots (\lambda - r_k)^{\alpha_k}$

$\mathrm{tr}( \mathbf{A}) = \alpha_1 r_1 + \alpha_2 r_2 + \cdots + \alpha_k r_k$

$\mathrm{tr}( \mathbf{A}) = \lambda_1 + \lambda_2 + \cdots + \lambda_n$

$\forall m \in \mathbb{N}, \mathrm{tr}( \mathbf{A}^m) = \lambda_1^m + \lambda_2^m + \cdots + \lambda_n^m$

## 線性映射的跡數

$Sp : \; \; \; \quad \mathbb{V}^n \qquad \; \quad \longrightarrow \quad \qquad \qquad \qquad \mathbb{K} \qquad \qquad \qquad,$
$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)$

$Sp(x_1, x_2, \cdots , x_n) = \mathrm{Sp} (f) \cdot \det(x_1, x_2,\cdots ,x_n)$[5]

## 迹的梯度

### 单个矩阵

• A是m×m矩阵时，有$\frac { \partial \mathrm{tr}(\mathbf{A}) }{ \partial \mathbf{A} } ={ \mathbf{I} }_{ m }$
• m×m矩阵A可逆时，有$\frac { \partial \mathrm{tr}(\mathbf{A}^{-1}) }{ \partial \mathbf{A} } =-( \mathbf{A}^{-2} )^T$
• 对于两个向量xy的外积，有$\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矩阵，有$\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矩阵，有$\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矩阵，有$\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矩阵，有$\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均为对称矩阵时，有$\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矩阵，并且B是非奇异矩阵，有$\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. ^ 2.0 2.1 2.2 2.3 2.4 张贤达，《矩阵分析与应用》，第55页
3. ^ 3.0 3.1 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页

## 参考书籍

• （中文）张贤达. 矩阵分析与应用. 清华大学出版社. 2008. ISBN 9787302092711.
• （英文）Strang Gilbert. Linear algebra and its applications. Thomson, Brooks/Cole, Belmont, CA. 2006. ISBN 9780534422004.
• （中文）居余马、林翠琴. 线性代数. 清华大学出版社. 2002. ISBN 978-7-302-06507-4.
• （英文）Werner Hildbert Greub. linear algebra. Springer Verlag. 1975. ISBN 978-0-387-90110-7.
• （英文）Steven Roman. Advanced Linear Algebra. Springer. 2005. ISBN 0-387-24766-1.
• （英文）Carl Dean Meyer. Matrix Analysis and Applied Linear Algebra Book and Solutions Manual. Society for Industrial and Applied Mathematics. 2001. ISBN 978-0898714548.
• （英文）Karim M. Abadir,Jan R. Magnus. Matrix algebra. Cambridge University Press. 2005. ISBN 978-0521537469.