## 跡數與行列式的導數

$X=[x_{ij}]$ 為一 $m\times n$ 階矩陣。若 $y(X)$ 是一可導函數，我們定義純量─矩陣導數 $\partial y/\partial X$$m\times n$ 階矩陣 (見“矩陣導數”)：

$\displaystyle \left(\frac{\partial y}{\partial X}\right)_{ij}=\frac{\partial y}{x_{ij}},~~i=1,\ldots,m,~~j=1,\ldots,n$

$Y=[y_{ij}]$ 為一 $m\times n$ 階矩陣，其中每一元 $y_{ij}(x)$ 是可導函數。矩陣─純量導數 $\partial Y/\partial x$ 定義為 $m\times n$ 階矩陣：

$\displaystyle \left(\frac{\partial Y}{\partial x}\right)_{ij}=\frac{\partial y_{ij}}{x},~~i=1,\ldots,m,~~j=1,\ldots,n$

(b-1) $\displaystyle \frac{\partial X}{\partial x_{ij}}=\mathbf{e}_i\mathbf{e}_j^T$

$\displaystyle \left(\frac{\partial X}{\partial x_{ij}}\right)_{kl}=\frac{\partial x_{kl}}{\partial x_{ij}}=\delta_{ik}\delta_{jl}=\left\{\begin{array}{cl} 1,&\hbox{if~} k=i,~l=j\\ 0,&\hbox{otherwise}. \end{array}\right.$

(b-2) $\displaystyle dX^{-1}=-X^{-1}(dX)X^{-1}$

$\displaystyle 0=dI=d(XX^{-1})=(dX)X^{-1}+X(dX^{-1})$

$\displaystyle \frac{\partial Y^{-1}}{\partial x}=-Y^{-1}\frac{\partial Y}{\partial x}Y^{-1}$

(b-3) $\displaystyle \frac{\partial X^{-1}}{\partial x_{ij}}=-X^{-1}\mathbf{e}_i\mathbf{e}_j^TX^{-1}$

$\displaystyle \frac{\partial X^{-1}}{\partial x_{ij}}=-X^{-1}\frac{\partial X}{\partial x_{ij}}X^{-1}=-X^{-1}\mathbf{e}_i\mathbf{e}_j^TX^{-1}$

(b-4) $\displaystyle \frac{\partial X^TAX}{\partial x_{ij}}=X^TA\mathbf{e}_i\mathbf{e}_j^T+\mathbf{e}_j\mathbf{e}_i^TAX$

\displaystyle\begin{aligned} \frac{\partial X^TAX}{\partial x_{ij}}&=X^TA\frac{\partial X}{\partial x_{ij}}+\frac{\partial X^T}{\partial x_{ij}}AX\\ &=X^TA\mathbf{e}_i\mathbf{e}_j^T+(\mathbf{e}_i\mathbf{e}_j^T)^TAX\\ &=X^TA\mathbf{e}_i\mathbf{e}_j^T+\mathbf{e}_j\mathbf{e}_i^TAX .\end{aligned}

$\displaystyle \frac{\partial f(U)}{\partial X}=\frac{\partial f(g(X))}{\partial X}$

$\displaystyle \left(\frac{\partial f(U)}{\partial X}\right)_{ij}=\frac{\partial f(U)}{\partial x_{ij}}=\sum_k\sum_l\frac{\partial f(U)}{\partial u_{kl}}\frac{\partial u_{kl}}{\partial x_{ij}}$

$\displaystyle \left(\frac{\partial f(U)}{\partial X}\right)_{ij}=\hbox{tr}\left(\left(\frac{\partial f(U)}{\partial U}\right)^T\frac{\partial U}{\partial x_{ij}}\right)$

$A=[a_{ij}]$ 為一 $n\times n$ 階矩陣。我們定義 $A$ 的跡數為

$\displaystyle \hbox{tr}A=\sum_{i=1}^na_{ii}$

$B=[b_{ij}]$ 是一 $m\times n$ 階矩陣且 $C=[c_{ij}]$ 是一 $n\times m$ 階矩陣，則

$\displaystyle \hbox{tr}(BC)=\sum_{i=1}^m\sum_{j=1}^nb_{ij}c_{ji}$

1. 跡數是線性函數，$\displaystyle \hbox{tr}(A+B)=\hbox{tr}A+\hbox{tr}B$$\hbox{tr}(cA)=c\hbox{tr}A$，其中 $A, B$ 是同階方陣，$c$ 是一純量。
2. 跡數具有轉置不變性，$\hbox{tr}A^T=\hbox{tr}A$
3. 跡數具有循環不變性，$\hbox{tr}(AB)=\hbox{tr}(BA)$，其中 $AB$$BA$ 是方陣，但尺寸可以不同。推廣至三個矩陣乘積，即有 $\hbox{tr}(ABC)=\hbox{tr}(BCA)=\hbox{tr}(CAB)$

(tr-1) $\displaystyle \frac{\partial\hbox{tr}X}{\partial X}=\frac{\partial\hbox{tr}X^T}{\partial X}=I$

$\displaystyle \left(\frac{\partial\hbox{tr}X}{\partial X}\right)_{ij}=\frac{\partial\hbox{tr}X}{\partial x_{ij}}=\frac{\partial\sum_k x_{kk}}{\partial x_{ij}}=\sum_k\delta_{ik}\delta_{jk}=\delta_{ij}=(I)_{ij}$

(tr-2) $\displaystyle \frac{\partial\hbox{tr}(aU)}{\partial X}=a\frac{\partial\hbox{tr}U}{\partial X}$

(tr-3) $\displaystyle \frac{\partial\hbox{tr}(U+V)}{\partial X}=\frac{\partial\hbox{tr}U}{\partial X}+\frac{\partial\hbox{tr}V}{\partial X}$

(tr-4) $\displaystyle \frac{\partial\hbox{tr}(UV)}{\partial X}=\frac{\partial\hbox{tr}(U_cV)}{\partial X}+\frac{\partial\hbox{tr}(UV_c)}{\partial X}$

$\displaystyle \frac{\partial\hbox{tr}(UV)}{\partial x_{ij}}=\frac{\partial\hbox{tr}(U_cV)}{\partial x_{ij}}+\frac{\partial\hbox{tr}(UV_c)}{\partial x_{ij}}=\hbox{tr}\left(U\frac{\partial V}{\partial x_{ij}}\right)+\hbox{tr}\left(\frac{\partial U}{\partial x_{ij}}V\right)$

\displaystyle\begin{aligned} \left(\frac{\partial\hbox{tr}(UV)}{\partial X}\right)_{ij}&=\frac{\partial\hbox{tr}(UV)}{\partial x_{ij}}=\frac{\partial\sum_k\sum_l u_{kl}v_{lk}}{\partial x_{ij}}\\ &=\sum_k\sum_l\frac{\partial u_{kl}v_{lk}}{\partial x_{ij}}=\sum_k\sum_l\left(u_{kl}\frac{\partial v_{lk}}{\partial x_{ij}}+v_{lk}\frac{\partial u_{kl}}{\partial x_{ij}}\right)\\ &=\sum_k\sum_lu_{kl}\frac{\partial v_{lk}}{\partial x_{ij}}+\sum_k\sum_l\frac{\partial u_{kl}}{\partial x_{ij}}v_{lk}\\ &=\frac{\partial\hbox{tr}(U_cV)}{\partial x_{ij}}+\frac{\partial\hbox{tr}(UV_c)}{\partial x_{ij}}\\ &=\left(\frac{\partial\hbox{tr}(U_cV)}{\partial X}+\frac{\partial\hbox{tr}(UV_c)}{\partial X}\right)_{ij}. \end{aligned}

(tr-5) $\displaystyle \frac{\partial\hbox{tr}(AX)}{\partial X}=\frac{\partial\hbox{tr}(XA)}{\partial X}=A^T$

\displaystyle\begin{aligned} \left(\frac{\partial\hbox{tr}(AX)}{\partial X}\right)_{ij}&=\frac{\partial\hbox{tr}(AX)}{\partial x_{ij}} =\frac{\partial\sum_k\sum_l a_{kl}x_{lk}}{\partial x_{ij}}\\ &=\sum_{k}\sum_{l}a_{kl}\frac{\partial x_{lk}}{\partial x_{ij}}=\sum_k\sum_la_{kl}\delta_{il}\delta_{jk}\\ &=a_{ji}=(A^T)_{ij}.\end{aligned}

\displaystyle\begin{aligned} \left(\frac{\partial\hbox{tr}(AX)}{\partial X}\right)_{ij}&=\frac{\partial\hbox{tr}(AX)}{\partial x_{ij}}=\hbox{tr}\left(A\frac{\partial X}{\partial x_{ij}}\right)\\ &=\hbox{tr}\left(A\mathbf{e}_i\mathbf{e}_j^T\right)=\hbox{tr}\left(\mathbf{e}_j^TA\mathbf{e}_i\right)\\ &=a_{ji}=(A^T)_{ij}.\end{aligned}

(tr-6) $\displaystyle \frac{\partial\hbox{tr}(AX^T)}{\partial X}=\frac{\partial\hbox{tr}(X^TA)}{\partial X}=A$

$\displaystyle \frac{\partial\hbox{tr}(AX^T)}{\partial X}=\frac{\partial\hbox{tr}((AX^T)^T)}{\partial X} =\frac{\partial\hbox{tr}(XA^T)}{\partial X}=(A^T)^T=A$

(tr-7) $\displaystyle \frac{\partial\hbox{tr}(X^2)}{\partial X}=2X^T$

$\displaystyle \frac{\partial\hbox{tr}(X^2)}{\partial X}=\frac{\partial\hbox{tr}(X_cX)}{\partial X}+\frac{\partial\hbox{tr}(XX_c)}{\partial X}=X_c^T+X_c^T=2X^T$

(tr-8) $\displaystyle \frac{\partial\hbox{tr}(AX^k)}{\partial X}=\sum_{i=0}^{k-1}(X^iAX^{k-i-1})^T$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}(AX^{k+1})}{\partial X}&=\frac{\partial\hbox{tr}(AX^{k}X)}{\partial X}\\ &=\frac{\partial\hbox{tr}(AX_c^kX)}{\partial X}+\frac{\partial\hbox{tr}(AX^kX_c)}{\partial X}\\ &=(AX_c^k)^T+\frac{\partial\hbox{tr}(X_cAX^k)}{\partial X}\\ &=(AX^k)^T+\sum_{i=0}^{k-1}(X^iX_cAX^{k-i-1})^T\\ &=\sum_{i=0}^{k}(X^iAX^{k-i})^T .\end{aligned}

(tr-9) $\displaystyle \frac{\partial\hbox{tr}(X^k)}{\partial X}=k(X^{k-1})^T$

$\displaystyle \frac{\partial\hbox{tr}(X^k)}{\partial X}=\sum_{i=0}^{k-1}(X^iX^{k-i-1})^T=k(X^{k-1})^T$

(tr-10) $\displaystyle \frac{\partial\hbox{tr}e^X}{\partial X}=\left(e^X\right)^T$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}e^X}{\partial X}&=\frac{\partial\hbox{tr}\left(\sum_{k=0}^\infty(k!)^{-1}X^k\right)}{\partial X}=\sum_{k=0}^\infty\frac{1}{k!}\frac{\partial\hbox{tr}X^k}{\partial X}\\ &=\sum_{k=0}^\infty\frac{1}{k!}k(X^{k-1})^T=\left(\sum_{k=1}^\infty\frac{1}{(k-1)!}X^{k-1}\right)^T=\left(e^X\right)^T .\end{aligned}

(tr-11) $\displaystyle \frac{\partial\hbox{tr}(AXB)}{\partial X}=A^TB^T$

$\displaystyle \frac{\partial\hbox{tr}(AXB)}{\partial X}=\frac{\partial\hbox{tr}(XBA)}{\partial X}=(BA)^T=A^TB^T$

(tr-12) $\displaystyle \frac{\partial\hbox{tr}(AX^TB)}{\partial X}=BA$

$\displaystyle \frac{\partial\hbox{tr}(AX^TB)}{\partial X}=\frac{\partial\hbox{tr}(X^TBA)}{\partial X}=BA$

(tr-13) $\displaystyle \frac{\partial\hbox{tr}(X^TAX)}{\partial X}=(A+A^T)X$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}(X^TAX)}{\partial X}&=\frac{\partial X_c^TAX}{\partial X}+\frac{\partial X^TAX_c}{\partial X}=(X_c^TA)^T+AX_c\\ &=A^TX_c+AX_c=(A^T+A)X.\end{aligned}

(tr-14) $\displaystyle \frac{\partial\hbox{tr}(XAX^T)}{\partial X}=X(A+A^T)$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}(XAX^T)}{\partial X}&=\frac{\partial X_cAX^T}{\partial X}+\frac{\partial XAX_c^T}{\partial X}=X_cA+(AX_c^T)^T\\ &=X_cA+X_cA^T=X(A+A^T).\end{aligned}

(tr-15) $\displaystyle \frac{\partial\hbox{tr}(X^TX)}{\partial X}=2X$

(tr-16) $\displaystyle \frac{\partial\hbox{tr}(AXBX)}{\partial X}=(AXB+BXA)^T$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}(AXBX)}{\partial X}&=\frac{\partial\hbox{tr}(AX_cBX)}{\partial X}+\frac{\partial\hbox{tr}(AXBX_c)}{\partial X}\\ &=\frac{\partial\hbox{tr}(AX_cBX)}{\partial X}+\frac{\partial\hbox{tr}(XBX_cA)}{\partial X}\\ &=(AX_cB)^T+(BX_cA)^T\\ &=(AXB+BXA)^T.\end{aligned}

(tr-17) $\displaystyle \frac{\partial\hbox{tr}(AXBX^TC)}{\partial X}=A^TC^TXB^T+CAXB$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}(AXBX^TC)}{\partial X}&=\frac{\partial\hbox{tr}(AX_cBX^TC)}{\partial X}+\frac{\partial\hbox{tr}(AXBX_c^TC)}{\partial X}\\ &=\frac{\partial\hbox{tr}(CAX_cBX^T)}{\partial X}+\frac{\partial\hbox{tr}(XBX_c^TCA)}{\partial X}\\ &=CAX_cB+(BX_c^TCA)^T\\ &=CAXB+A^TC^TXB^T.\end{aligned}

(tr-18) $\displaystyle \frac{\partial\hbox{tr}(AX^{-1}B)}{\partial X}=-(X^{-1}BAX^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial\hbox{tr}(AX^{-1}B)}{\partial X}\right)_{ij}&=\frac{\partial\hbox{tr}(X^{-1}BA)}{\partial x_{ij}}=\hbox{tr}\left(\frac{\partial X^{-1}}{\partial x_{ij}}BA\right)\\ &=\hbox{tr}\left(-X^{-1}\mathbf{e}_i\mathbf{e}_j^TX^{-1}BA\right)=\hbox{tr}\left(-\mathbf{e}_j^TX^{-1}BAX^{-1}\mathbf{e}_i\right)\\ &=-\mathbf{e}_j^TX^{-1}BAX^{-1}\mathbf{e}_i=-\left(X^{-1}BAX^{-1}\right)_{ji}\\ &=\left(-(X^{-1}BAX^{-1})^T\right)_{ij}.\end{aligned}

(tr-19) $\displaystyle \frac{\partial\hbox{tr}\left((X^TAX)^{-1}B\right)}{\partial X}=-AX(X^TAX)^{-1}(B+B^T)(X^TAX)^{-1}$ ($A^T=A$)

\displaystyle\begin{aligned} \left(\frac{\partial\hbox{tr}\left((X^TAX)^{-1}B\right)}{\partial X}\right)_{ij}&=\frac{\partial\hbox{tr}\left((X^TAX)^{-1}B\right)}{\partial x_{ij}}=\hbox{tr}\left(\frac{\partial (X^TAX)^{-1}}{\partial x_{ij}}B\right)\\ &=\hbox{tr}\left(-(X^TAX)^{-1}\frac{\partial(X^TAX)}{\partial x_{ij}}(X^TAX)^{-1}B\right)\\ &=-\hbox{tr}\left((X^TAX)^{-1}(X^TA\mathbf{e}_i\mathbf{e}_j^T+\mathbf{e}_j\mathbf{e}_i^TAX)(X^TAX)^{-1}B\right)\\ &=-\hbox{tr}\left((X^TAX)^{-1}X^TA\mathbf{e}_i\mathbf{e}_j^T(X^TAX)^{-1}B\right)\\ &~~~~~~-\hbox{tr}\left((X^TAX)^{-1}\mathbf{e}_j\mathbf{e}_i^TAX(X^TAX)^{-1}B\right)\\ &=-\hbox{tr}\left(\mathbf{e}_j^T(X^TAX)^{-1}B(X^TAX)^{-1}X^TA\mathbf{e}_i\right)\\ &~~~~~~-\hbox{tr}\left(\mathbf{e}_i^TAX(X^TAX)^{-1}B(X^TAX)^{-1}\mathbf{e}_j\right)\\ &=-\mathbf{e}_j^T(X^TAX)^{-1}B(X^TAX)^{-1}X^TA\mathbf{e}_i\\ &~~~~~~-\mathbf{e}_i^TAX(X^TAX)^{-1}B(X^TAX)^{-1}\mathbf{e}_j\\ &=-\mathbf{e}_i^TAX(X^TAX)^{-1}(B^T+B)(X^TAX)^{-1}\mathbf{e}_j\\ &=\left(-AX(X^TAX)^{-1}(B^T+B)(X^TAX)^{-1}\right)_{ij} \end{aligned}

(tr-20) $\displaystyle \frac{\partial\hbox{tr}\left((X^TAX)^{-1}(X^TBX)\right)}{\partial X}=-2AX(X^TAX)^{-1}X^TBX(X^TAX)^{-1}+2BX(X^TAX)^{-1}$
($A^T=A$$B^T=B)$

\displaystyle\begin{aligned} \frac{\partial\hbox{tr}\left((X^TAX)^{-1}(X^TBX)\right)}{\partial X} &=\frac{\partial\hbox{tr}\left((X^TAX)^{-1}(X_c^TBX_c)\right)}{\partial X}+\frac{\partial\hbox{tr}\left((X_c^TAX_c)^{-1}(X^TBX)\right)}{\partial X}\\ &=\frac{\partial\hbox{tr}\left((X^TAX)^{-1}(X_c^TBX_c)\right)}{\partial X}+\frac{\partial\hbox{tr}\left(BX(X_c^TAX_c)^{-1}X^T\right)}{\partial X}\\ &=-2AX(X^TAX)^{-1}X_c^TBX_c(X^TAX)^{-1}+2BX(X_c^TAX_c)^{-1}\\ &=-2AX(X^TAX)^{-1}X^TBX(X^TAX)^{-1}+2BX(X^TAX)^{-1}. \end{aligned}

$\displaystyle \det X=\sum_{j=1}^nx_{ij}c_{ij}$

$\displaystyle X(\hbox{adj}X)=(\det X)I$

$X$ 可逆，則 $\displaystyle \hbox{adj}X=(\det X)X^{-1}$

(det-1) $\displaystyle \frac{\partial \det X}{\partial X}=\frac{\partial\det X^T}{\partial X}=(\det X)(X^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial \det X}{\partial X}\right)_{ij}&=\frac{\partial \det X}{\partial x_{ij}}=\frac{\partial\sum_{k}x_{ik}c_{ik}}{\partial x_{ij}}\\ &=\sum_k\delta_{jk}c_{ik}=c_{ij}=\left((\hbox{adj}X)^T\right)_{ij}\\ &=\left((\det X)(X^{-1})^T\right)_{ij}.\end{aligned}

(det-2) $\displaystyle \frac{\partial \ln\det X}{\partial X}=(X^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial \ln\det X}{\partial X}\right)_{ij}&=\frac{\partial \ln\det X}{\partial x_{ij}}=\frac{1}{\det X}\frac{\partial \det X}{\partial x_{ij}}\\ &=\frac{1}{\det X}\left((\det X)(X^{-1})^T\right)_{ij}=\left((X^{-1})^T\right)_{ij}.\end{aligned}

(det-3) $\displaystyle \frac{\partial \det(AXB)}{\partial X}=\det(AXB)(X^{-1})^T$

\displaystyle\begin{aligned} \frac{\partial \det(AXB)}{\partial X}&=\frac{(\det A)(\det X)(\det B)}{\partial X}\\ &=(\det A)\frac{\partial\det X}{\partial X}(\det B)\\ &=(\det A)(\det X)(X^{-1})^T(\det B)\\ &=(\det A)(\det X)(\det B)(X^{-1})^T\\ &=\det(AXB)(X^{-1})^T. \end{aligned}

(det-4) $\displaystyle \frac{\partial \det (X^{-1})}{\partial X}=-\det (X^{-1})(X^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial \det X^{-1}}{\partial X}\right)_{ij}&=\frac{\partial(\det X)^{-1}}{\partial x_{ij}}=-(\det X)^{-2}\frac{\partial\det X}{\partial x_{ij}}\\ &=-(\det X)^{-2}\left((\det X)(X^{-1})^T\right)_{ij}\\ &=-\left((\det X)^{-1}(X^{-1})^T\right)_{ij}\\ &=-\left(\det (X^{-1})(X^{-1})^T\right)_{ij}. \end{aligned}

(det-5) $\displaystyle \frac{\partial \det(X^TAX)}{\partial X}=2\det(X^TAX)(X^{-1})^T$ ($X$ 是可逆方陣)

\displaystyle\begin{aligned} \frac{\partial \det(X^TAX)}{\partial X}&=\frac{(\det X^T)(\det A)(\det X)}{\partial X}\\ &=(\det X^T)(\det A)\frac{\partial\det X}{\partial X}+\frac{\partial\det X^T}{\partial X}(\det A)(\det X)\\ &=(\det X^T)(\det A)(\det X)(X^{-1})^T+(\det X)(X^{-1})^T(\det A)(\det X)\\ &=(\det X^T)(\det A)(\det X)(X^{-1})^T+(\det X^T)(\det A)(\det X)(X^{-1})^T\\ &=2\det(X^TAX)(X^{-1})^T. \end{aligned}

(det-6) $\displaystyle \frac{\partial \det(X^TAX)}{\partial X}=\det(X^TAX)\left(AX(X^TAX)^{-1}+A^TX(X^TA^TX)^{-1}\right)$ ($X$ 不為方陣，$A^T\neq A$)

\displaystyle\begin{aligned} \left(\frac{\partial \det(X^TAX)}{\partial X}\right)_{ij}&=\frac{\partial \det(X^TAX)}{\partial x_{ij}}\\ &=\hbox{tr}\left(\left(\frac{\partial \det(X^TAX)}{\partial(X^TAX)}\right)^T\frac{\partial X^TAX}{\partial x_{ij}}\right)\\ &=\hbox{tr}\left(\det(X^TAX)(X^TAX)^{-1}(X^TA\mathbf{e}_i\mathbf{e}_j^T+\mathbf{e}_j\mathbf{e}_i^TAX)\right)\\ &=\det(X^TAX)\left(\hbox{tr}\left((X^TAX)^{-1}X^TA\mathbf{e}_i\mathbf{e}_j^T\right)+\hbox{tr}\left((X^TAX)^{-1}\mathbf{e}_j\mathbf{e}_i^TAX\right)\right)\\ &=\det(X^TAX)\left(\hbox{tr}\left(\mathbf{e}_j^T(X^TAX)^{-1}X^TA\mathbf{e}_i\right)+\hbox{tr}\left(\mathbf{e}_i^TAX(X^TAX)^{-1}\mathbf{e}_j\right)\right)\\ &=\det(X^TAX)\left(\hbox{tr}\left(\mathbf{e}_i^TA^TX(X^TA^TX)^{-1}\mathbf{e}_j\right)+\hbox{tr}\left(\mathbf{e}_i^TAX(X^TAX)^{-1}\mathbf{e}_j\right)\right)\\ &=\det(X^TAX)\left(\mathbf{e}_i^TA^TX(X^TA^TX)^{-1}\mathbf{e}_j+\mathbf{e}_i^TAX(X^TAX)^{-1}\mathbf{e}_j\right)\\ &=\det(X^TAX)\left(A^TX(X^TA^TX)^{-1}+AX(X^TAX)^{-1}\right)_{ij} .\end{aligned}

(det-7) $\displaystyle \frac{\partial \det(X^TAX)}{\partial X}=2\det(X^TAX)AX(X^TAX)^{-1}$ ($X$ 不為方陣，$A^T=A$)

(det-8) $\displaystyle \frac{\partial \det(X^k)}{\partial X}=k\det(X^k)(X^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial \det(X^k)}{\partial X}\right)_{ij}&=\frac{\partial(\det X)^k}{\partial x_{ij}}=k(\det X)^{k-1}\frac{\partial\det X}{\partial x_{ij}}\\ &=k(\det X)^{k-1}\left((\det X)(X^{-1})^T\right)_{ij}\\ &=\left(k(\det X)^k(X^{-1})^T\right)_{ij}\\ &=\left(k\det (X^k)(X^{-1})^T\right)_{ij}. \end{aligned}

(det-9) $\displaystyle \frac{\partial \ln\det(X^k)}{\partial X}=k(X^{-1})^T$

\displaystyle\begin{aligned} \left(\frac{\partial \ln\det (X^k)}{\partial X}\right)_{ij}&=\frac{\partial \ln\det (X^k)}{\partial x_{ij}}=\frac{1}{\det (X^k)}\frac{\partial \det (X^k)}{\partial x_{ij}}\\ &=\frac{1}{\det (X^k)}\left(k\det (X^k)(X^{-1})^T\right)_{ij}=\left(k(X^{-1})^T\right)_{ij}.\end{aligned}

(det-10) $\displaystyle \frac{\partial \ln\det(X^TAX)}{\partial X}=2AX(X^TAX)^{-1}$ ($X$ 不為方陣，$A^T=A$)

\displaystyle\begin{aligned} \left(\frac{\partial \ln\det (X^TAX)}{\partial X}\right)_{ij}&=\frac{\partial \ln\det (X^TAX)}{\partial x_{ij}}=\frac{1}{\det (X^TAX)}\frac{\partial \det (X^TAX)}{\partial x_{ij}}\\ &=\frac{1}{\det (X^TAX)}\left(2\det(X^TAX)AX(X^TAX)^{-1}\right)_{ij}\\ &=\left(2AX(X^TAX)^{-1}\right)_{ij}.\end{aligned}

[1] 本文列舉的跡數與行列式導數恆等式選自維基百科：Matrix CalculusThe Matrix CookbookThe Matrix Reference Manual

This entry was posted in 特別主題 and tagged , , , . Bookmark the permalink.

### 5 則回應給 跡數與行列式的導數

1. yangzx 說：

一直不會推導行列式的導數，原來是這樣的啊！

2. 張盛東 說：

周老師，請教一下是否存在求 ln det(I + X)關於X導數的公式？I 是單位矩陣。

• 張盛東 說：

不好意思，應該是是否存在求ln det(I + X^T X)關於X導數的公式.

• ccjou 說：

我沒看過這個公式，或許可以從下列一般公式開始推導：
$\frac{\partial \det(Y)}{\partial x}=\det(Y)\text{trace}(Y^{-1}\frac{\partial Y}{\partial x})$

但可能無法化簡成漂亮的代數式。

• 張盛東 說：

謝謝老師提點，我試試推導出來。