# Stuck on matrix derivative

I am stuck with this (probably simple) derivatives:

$$\frac{\partial}{\partial X}Tr((A\odot(B^{T}XB))C)\;\;and \;\;\frac{\partial}{\partial X}Tr((A\odot(B^{T}XX^{T}B))C)$$

where $$A,B,C$$ are constant matrices and $$\odot$$ is the Hadamard product.

The trace/Frobenius product is defined as $$A:B = {\rm Tr}(AB^T)$$ The cyclic property of the trace allows terms in such a product to be rearranged, e.g. $$A:BC \;=\; AC^T:B \;=\; B^TA:C$$ The Frobenius and Hadamard products commute with themselves and each other. \eqalign{ A:B &= B:A \\ A\odot B &= B\odot A \\ C:A\odot B &= C\odot A:B \\ } Consider the following of function of the variable $$Y$$. \eqalign{ \phi &= {\rm Tr}\big((A\odot(B^TYB))C\big) \\ &= (A\odot(B^TYB)):C^T \\ &= (A\odot C^T):B^TYB \\ &= B(A\odot C^T)B^T:Y \\ &= M:Y \\ } where $$M,\,$$ being a combination of constant matrices, is itself a constant matrix.
In the first case, set $$Y=X\,$$ then calculate the differential and the gradient. \eqalign{ \phi_1 &= M:X \\ d\phi_1 &= M:dX \\ \frac{\partial\phi_1}{\partial X} &= M \\ } In the second case, set $$Y=XX^T\,$$ then \eqalign{ \phi_2 &= M:XX^T \\ d\phi_2 &= M:(dX\,X^T+X\,dX^T) \\ &= (M+M^T):dX\,X^T \\ &= (M+M^T)X:dX \\ \frac{\partial\phi_2}{\partial X} &= (M+M^T)X \\ }