Matrix differential of a trace with Hadamard product I'm encountering difficulties taking the differential of the following matrix expression with respect to $S$:
$\text{logdet}(S) + \text{Tr}[C(D\odot((AS^{-1/2}B)(AS^{-1/2}B)^{T}))]$
$C$ and $D$ are symmetric and $S$ is diagonal so I mean taking the element-wise inverse of the element-wise square-root by the notation $S^{-1/2}$.
From Matrix CookBook, I know that the first term leads to $\text{Tr}(S^{-1}dS)$ and I know that I can apply the differential of the expression inside the trace term but I'm struggle with the computation of the differential because of the quadratic form coupled with the Hadamard product. I have tried to rewrite the expression by means of Hadamard and Frobenius products (that are commutative)...without success.
Then, my goal is to find the "roots" of the derivative with respect to $S$. Given the form of the expression, my intuition is that I will obtain a fixed-point expression (in the sense that it is not possible to obtain a closed-form expression in the form $\hat{S}=$ something that doesn't depend on $S$), but it's not a problem, I will solve it numerically.
Can you help me ? Thank you in advance.
 A: For convenience, define the auxiliary variables
$$\eqalign{
E & = C\odot D \;=\; E^T \\
X &= AS^{-1/2}B \\
dX &= A\,dS^{-1/2}\,B \;= -\tfrac{1}{2}A(S^{-3/2}dS)\,B \\
s &= {\rm diag}(S) \quad\implies\quad S = {\rm Diag}(s) \\
}$$
Analyze the following scalar function,
written using the Frobenius product instead of the trace.
$$\eqalign{
\psi &= C:D\odot XX^T \\&= E:XX^T \\
d\psi &= E:(dX\,X^T+X\,dX^T) \\
 &= (E+E^T):dX\,X^T \\
 &= 2EX:dX \\
 &= -EX:AS^{-3/2}dS\,B \\
 &= -S^{-3/2}A^TEXB^T:dS \\
}$$
Add this to the logdet function and calculate
the gradient of the combined function.
$$\eqalign{
\phi &= \log\det S + \psi \\
d\phi &= \big(S^{-1} -S^{-3/2}A^TEXB^T\big):dS \\
 &= {\rm diag}\big(S^{-1} -S^{-3/2}A^TEXB^T\big):ds \\
\frac{\partial\phi}{\partial s}
  &= {\rm diag}\big(S^{-1} -S^{-3/2}A^TEXB^T\big) \\
}$$
The remaining task is to find the vector $s$ which produces a zero gradient.
Update
The identities
$$\eqalign{
{\rm diag}\big(A\;{\rm Diag}(p)\,B\big) &= (B^T\odot A)\,p \\
{\rm diag}\big(A\;{\rm Diag}(p)\big) &= {\rm diag}(A)\odot p \\
}$$
can be used to develop a fixed-point iteration from the zero-gradient
condition.
$$\eqalign{
P &= S^{-1/2} \\
p &= {\rm diag}(P) \\
M &= BB^T\odot A^TEA \\
\\
{\rm diag}\big(P^2) &= {\rm diag}\big(P^3A^TEAPBB^T\big) \\
p^{\odot 2} &= p^{\odot 3}\odot{\rm diag}\big(A^TEAPBB^T\big) \\
p^{\odot-1} &= Mp \\
}$$
So a fixed-point formula is
$$\eqalign{
q_{k+1} &= M \bigg[\frac{{\tt1}}{q_k}\bigg],\qquad s=q\odot q \\
}$$
Unfortunately, this iteration diverges. However, if a constraint like $\|q\|=1$ is imposed, then it will converge.
