Given matrices $B$ and $C$, define the functional
$$f (A) := \|ABA^T-C\|_F^2$$
All matrices are $n \times n$ and $\| \cdot \|_F$ is the Frobenius norm. What is the gradient of $f$ with respect to $A$?
I calculated it as $\nabla_A f(A)=(ABA^T-C)AB$, but I'm not sure if it is right.
Let $g(A) = ABA^T -C$, then $Dg(A)H = ABH^T+HBA^T$.
Let $h(A) = \|A\|_F^2$, if the space is real then $Dh(A)H = 2 \langle A, H \rangle$.
Since $f = h \circ g$ we have
$Df(A) = Dh(g(A)) ( Dg(A)H) = 2 \langle ABA^T -C, ABH^T+HBA^T \rangle$
Then \begin{eqnarray} Df(A) &=& 2 \operatorname{tr} ((AB^TA^T-C^T) (ABH^T+HBA^T)) \\ &=& \langle 2(AB^TA^TAB+ABA^TAB^T-C^TAB-CAB^T), H \rangle \end{eqnarray}