# Proof for $df(X)/dX$ $f(X)=\operatorname{trace}{(AX^TB+C)^{-1}D}$

Denote $f(X)=\operatorname{trace}{(AX^TB+C)^{-1}D}$ and A,B,C,D are the constant matrix, X is the $R^{m*n}$ matrix.

How to prove $df(X)/dX=-B(AX^TB+C)^{-1}D(AX^TB+C)^{-1}A$

I don't know the method when X in the block of inverse operator.

-
I find it best to resort to indexes, adopting Einstein's notation. First, using $$( A X^\top B +C)^{-1} ( A X^\top B +C) = 1$$ and differentiating with respect to $X_{ij}$:
$$0= \left( \frac{\mathrm{d}}{\mathrm{d} X_{i j}} \left( A X^\top B +C\right)^{-1}_{pq} \right) ( A X^\top B +C)_{qr} + \left( A X^\top B +C\right)^{-1}_{pq} \underbrace{\frac{\mathrm{d}}{\mathrm{d} X_{i j}} ( A X^\top B +C)_{qr}}_{A_{qj} B_{ir}}$$ Hence: $$\left( \frac{\mathrm{d}}{\mathrm{d} X_{i j}} \left( A X^\top B +C\right)^{-1}_{pq} \right) = -\left(\left( A X^\top B +C\right)^{-1} A\right)_{pj} \left(B \left( A X^\top B +C\right)^{-1} \right)_{iq}$$ Therefore: $$\begin{eqnarray} \frac{\mathrm{d} f(X)}{\mathrm{d} X_{ij}} &=& \frac{\mathrm{d} }{\mathrm{d} X_{ij}} \left( A X^\top B +C\right)^{-1}_{pq} D_{qp} \\ &=& -\left(\left( A X^\top B +C\right)^{-1} A\right)_{pj} \left(B \left( A X^\top B +C\right)^{-1} \right)_{iq} D_{qp} \\ &=& -\left(\left( A X^\top B +C\right)^{-1} A\right)_{pj} \left(B \left( A X^\top B +C\right)^{-1} D \right)_{ip} \\ &=& - \left(B \left( A X^\top B +C\right)^{-1} D \left( A X^\top B +C\right)^{-1} A\right)_{ij} \end{eqnarray}$$ In other words: $$\frac{\mathrm{d} f(X)}{\mathrm{d} X} = -B \left( A X^\top B +C\right)^{-1} D \left( A X^\top B +C\right)^{-1} A$$