Given $F, L \in \mathbb{R}^{n \times n}$, consider
$$ \mathcal{L}:= tr(F^TLF)$$
Now I would like to compute $\frac{\partial \mathcal{L}}{\partial F}$ but I'm always a bit stuck computing derivatives when dealing with matrices.
ATTEMPT:
we can write $tr(F^TLF) = \sum_{i=1}^n F_i^TLF_i$, then
$$\frac{\partial tr(F^TLF)}{\partial F} =\sum_{i=1}^n \frac{\partial F_i^TLF_i}{\partial F_i} = \sum_{i=1}^n2F_iL = 2FL$$
Suggestion:
I would suggest not to go for elementwise derivatives, as it is prone to error.
Solution:
Let us define the Frobenius product by a colon and use it's cyclic property \begin{align} {\rm Tr}\left( A^T B C \right) &:= A: BC \\ &= AC^T: B \\ &= B^TA:C \end{align}
Let \begin{align} \phi(F) := {\rm Tr}\left( F^T L F \right) \equiv F: LF. \end{align}
Now, we can use differentials and then obtain gradient. \begin{align} d\phi &= dF: LF + F:LdF \\ &= LF: dF + L^T F:dF \\ &= \left( L + L^T \right) F: dF \end{align}
The gradient is \begin{align} \frac{\partial \phi}{\partial F} = \left( L + L^T \right) F. \end{align}