TITLE: Derivative of Hadamard product
QUESTION [5 upvotes]: What is the derivative of Hadamard product of two matrices with respect to one of them?
I.e. what is $D(AB)$ with respect to $A$?

REPLY [4 votes]: Consider the 6th-order tensor ${\mathbb M}$, whose components ${\mathbb M}_{ijklmn}$ are unity if $\,(i=k=m)$ and $(j=l=n),\,$ but zero otherwise.
This tensor can be used, along with the Frobenius Product (:), to rewrite the Hadamard Product ($\circ$) between two matrices as
$$\eqalign{
 B\circ A &= B:{\mathbb M}:A \cr\cr
}$$
This makes the finding the gradient (a 4th-order tensor) especially simple
$$\eqalign{
 F &= A\circ B = B\circ A = B:{\mathbb M}:A \cr\cr
dF &= B:{\mathbb M}:dA \cr\cr
\frac{\partial F}{\partial A} &= B:{\mathbb M} \cr
}$$