# 跡

${\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矩陣，並且B是非奇異矩陣，有${\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頁

## 參考書籍

• （中文）張賢達. 矩陣分析與應用. 清華大學出版社. 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.