# Does this matrix identity hold? (Left and right-product with diagonal matrix)

I have been attempting to prove the following identity:

$$\frac{\partial [W^{\frac{1}{2}} K W^{\frac{1}{2}}]}{\partial \hat{f_i}} = K \frac{\partial W}{\partial \hat{f_i}}$$

where $$W^{\frac{1}{2}}$$ is a diagonal matrix with all-positive elements (the matrix square-root of $$W$$) which is a function of $$\hat{f_i}$$, and $$K$$ is a symmetric positive-definite matrix that is not a function of $$\hat{f_i}$$.

If it does hold, I would appreciate a proof or a link to a reference. Thanks!

• In general it does not hold if $K$ does not commute with $W$ – lcv Oct 1 '18 at 9:00
• @lcv That is true, but since $W$ is diagonal, $K$ must be diagonal (or block diagonal) in order for it to commute with $W$. – greg Oct 2 '18 at 15:50

## 2 Answers

It does not hold. Here is a counter-example: $$W = \begin{bmatrix} f_1 & 0 \\ 0 & f_2\end{bmatrix}, K = \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$. Then, $$W^{1/2} K W^{1/2} = \begin{bmatrix} f_1 & -\sqrt{f_1f_2} \\ -\sqrt{f_1f_2} & f_2\end{bmatrix}$$ and hence $$\frac{\partial}{\partial f_1} W^{1/2} K W^{1/2} = \begin{bmatrix} 1 & -\frac 1 2 \sqrt{\frac{f_2}{f_1}} \\ -\frac 1 2 \sqrt{\frac{f_2}{f_1}} & 0\end{bmatrix}.$$ On the other hand, $$K \frac{\partial W}{\partial f_1} = \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ -1 & 0 \end{bmatrix}.$$

It does work if $$K$$ is diagonal (or $$W$$ is a scaled identity) since then $$W^{1/2} K W^{1/2} = K W$$.

Let \eqalign{ W &= A^2 \cr } where both $$(W,A)$$ are diagonal matrices.

Taking derivatives wrt $$f_i$$ \eqalign{ d_iW &= 2A\,\,d_iA \implies d_iA = \tfrac{1}{2}A^{-1}d_iW \cr } Write the function in terms of $$A$$ and calculate its derivative \eqalign{ Y &= AKA \cr d_iY &= AK\,d_iA + d_iA\,KA \cr &= \tfrac{1}{2}AKA^{-1}\,d_iW + \tfrac{1}{2}d_iW\,A^{-1}KA \cr } If we define the matrix \eqalign{ M &= AKA^{-1}\,d_iW \cr } then the symmetry of $$K$$ and commutivity of the diagonal matrices yields \eqalign{ d_iY &= \tfrac{1}{2}(M+M^T)\cr }