关于迹的矩阵函数求导
秩的交换性,转置不影响
\begin{align*}
\frac{\partial\mathrm{tr} AX}{\partial X}&=A^T,&\frac{\partial\mathrm{tr} \left(AXB\right)}{\partial X}&=A^TB^T,\\
\frac{\partial\mathrm{tr} \left(X^TAX\right)}{\partial X}&=\left(A^T+A\right)X,&\frac{\partial\mathrm{tr} \left(X^TAXB\right)}{\partial X}&=AXB+A^TXB^T,
\end{align*}