I have to find the derivative of $$||R - (P \circ \gamma \gamma^T)||_F^2$$ with respect to $\gamma$, where $||\cdot||_F$ is the Frobenius norm and $\circ$ is the Hadamard (elementwise) product. $R$ and $P$ are of dimension $n \times n$ and $\gamma$ of dimension $n \times r$.
I know that in general, the derivative of $||X||_F^2$ w.r.t. $X$ is $2X$, and I've tried to then use the chain rule, but I can't manage to find a coherent answer.
Let's define a new matrix variable $$M=P\circ\gamma\gamma^T-R$$ And let's use a colon to denote the trace/Frobenius product, i.e. $A:B={\rm tr}(A^TB)$.
Rules for rearranging the Frobenius product follow from the cyclic properties of the trace. Also note that the Frobenius and Hadamard products are mutually commutative $$\eqalign{ A:B &= B:A \cr A\circ B &= B\circ A \cr A:B\circ C &= A\circ B:C \cr\cr }$$
Now we're ready to write down the function, differential, and gradient $$\eqalign{ f &= \|M\|_F^2 = M:M \cr \cr df &= 2M:dM = 2M:P\circ d(\gamma\gamma^T) \cr &= 2P\circ M:(d\gamma\,\gamma^T+\gamma\,d\gamma^T) \cr &= 2(P\circ M+P^T\circ M^T):d\gamma\,\gamma^T \cr &= 2(P\circ M+P^T\circ M^T)\gamma:d\gamma \cr \cr \frac{\partial f}{\partial \gamma} &= 2(P\circ M+P^T\circ M^T)\gamma \cr\cr }$$