Derivative of a Matrix Expression with Hadamard

178 Views Asked by At

I have the following expression at hand:

$1_{nx1}^T (X_{nxk} \circ X_{nxk})(Y_{kx1} \circ Y_{kx1})$

$X$ is a matix, $Y$ is a vector, and $1$ is a vector of ones with indicated dimensions. $\circ$ is the element by element multiplication. Expression evaluates to a scalar.

I would like to take the derivative of the above expression with respect to $Y$.

I think the result should be a vector of same size as $Y$. Matrix cookbook doesn't seem to cover these kind of cases. I am a little stuck.

Thanks in advance

1

There are 1 best solutions below

3
On BEST ANSWER

Denoting the trace/Frobenius product with a colon, e.g. $\,A:B={\rm tr}(A^TB),\,$ allows you to write the scalar function in a form that's easy to reduce $$\eqalign{ \phi &= 1:(X\circ X)(y\circ y) \cr &= (X\circ X)^T1:(y\circ y) \cr }$$ Now calculate the differential and the gradient $$\eqalign{ d\phi &= 2(X\circ X)^T1:(y\circ dy) \cr &= 2(X\circ X)^T1:Y\,dy \cr &= 2\,Y(X\circ X)^T1:dy \cr \frac{\partial\phi}{\partial y} &= 2\,Y(X\circ X)^T1 \cr }$$ where $Y={\rm Diag}(y).$