I'm new to matrix calculus and I have a problem with my assignment. Following is a function of trace of matrices: $$ f = \mathrm{tr}[\mathbf{X} \mathbf{X^T}] - \mathrm{tr}[\mathbf{X} \mathbf{H^T} \mathbf{W}^T] - \mathrm{tr}[\mathbf{W} \mathbf{H} \mathbf{X}^T] + \mathrm{tr}[\mathbf{W} \mathbf{H} \mathbf{H}^T \mathbf{W}^T]. $$
And I have to prove that: $$ \frac {\partial \mathrm{tr}[ (\mathbf{X}-\mathbf{W}\mathbf{H}) (\mathbf{X}-\mathbf{W}\mathbf{H})^T ] } {\partial W} = -2 \mathbf{X} \mathbf{H}^T + 2 \mathbf{W} \mathbf{H} \mathbf{H}^T. $$
In the second equation, the numerator is f in the fist equation. Can you help me solve this? Thank you.

$f(W)=\mathrm{Constant}-2\mathrm{tr}(XH^TW^T)+\mathrm{tr}(WHH^TW^T)$.
The derivative is $$ \begin{align*} Df_W:Z\rightarrow &-2\mathrm{tr}(XH^TZ^T)+\mathrm{tr}(ZHH^TW^T)+\mathrm{tr}(WHH^TZ^T)\\ &=-2\mathrm{tr}(XH^TZ^T)+2\mathrm{tr}(ZHH^TW^T)\\ &=-2\langle XH^T,Z\rangle+2\langle WHH^T,Z\rangle. \end{align*}$$
Thus the gradient is $\nabla(f)(W)=-2XH^T+2WHH^T$.