Let $D$ be positive diagonal and $W$ be symmetric positive definite (spd). According to relation $124$ in matrix cookbook, the derivative of tr$(WD^{-1})$ with respect to $D$ is $-D^{-1}WD^{-1}$.
How do we solve for the derivative of tr$(WD^{-2})$ with respect to $D$? I tried the Frobenius product approach, but couldn't work the steps.
For convenience, define the diagonal matrix $\,V= {\rm Diag}(W) = I\odot W$
Diagonal matrices are easy to work with because they're symmetric and they commute with each other, e.g. $\,DV=VD=V^TD$
Write the function in terms of this new variable and the Frobenius product. Then find its differential and gradient. $$\eqalign{ \phi &= {\rm Tr}(VD^{-2}) \cr&= V:D^{-2} \cr d\phi &= V:(-2D^{-3}dD) \cr&= -2D^{-3}V:dD \cr \frac{\partial\phi}{\partial D} &= -2D^{-3}V \cr }$$ Note that ${\rm Tr}(VD^k) = {\rm Tr}(WD^k)$, i.e. the off-diagonal components of $W$ contribute nothing.