# Gradient of the Frobenius Norm (or matrix trace) of an expression involving a matrix and its inverse

For real, positive definite (square) matrices $\mathbf{A}$, $\mathbf{X}$, and $\mathbf{C}$, I would like to find an expression for the following gradient:

$\nabla_\mathbf{X} || \mathbf{AX}+\mathbf{X}^{-1}\mathbf{C} ||_F$

where $|| \cdot ||_F$ represents the Frobenius norm (although if another choice of norm makes this easier, I'd be interested to know). I know that this corresponds to the trace as

$\nabla_\mathbf{X} \mathrm{Trace}\left[ \left(\mathbf{AX}+\mathbf{X}^{-1}\mathbf{C}\right)^T \left(\mathbf{AX}+\mathbf{X}^{-1}\mathbf{C}\right) \right]$

which expands to

$\nabla_\mathbf{X} \mathrm{Trace}\left[ \mathbf{XAAX} + \mathbf{CX}^{-1}\mathbf{AX} + \mathbf{XAX}^{-1}\mathbf{C}+\mathbf{C}\mathbf{X}^{-1}\mathbf{X}^{-1}\mathbf{C}\right]$

And I believe the trace of the sum is the sum of the traces, so each of these terms may be considered separately. The first and last terms seem like they could probably be evaluated in terms of (111) and (119) in the matrix cookbook, but I'm not sure about the middle two, which have both $\mathbf{X}$ and $\mathbf{X}^{-1}$. Any guidance would be appreciated.

For convenience, define the variable \eqalign{ M &= AX+X^{-1}C \cr dM &= A\,dX - X^{-1}\,dX\,X^{-1}C \cr } and the function \eqalign{ f &= \|M\|_F^2 \,=\, M:M \cr\cr df &= 2M:dM \cr &= 2M:A\,dX - 2M:X^{-1}\,dX\,X^{-1}C \cr &= 2(A^TM - X^{-T}MC^TX^{-T}) : dX \cr } where a colon is used to denote the Frobenius Inner Product.
Your question was about a slightly different, but related function \eqalign{ h &= f^\frac{1}{2} \cr h^2 &= f \cr 2hdh &= df \,=\, 2(A^TM - X^{-T}MC^TX^{-T}) : dX \cr\cr \frac{\partial h}{\partial X} &= \frac{A^TM - X^{-T}MC^TX^{-T}}{h} \cr }
• Thank you so much. Could you clarify how you go between these two lines? \eqalign{ df &= 2M:A\,dX - 2M:X^{-1}\,dX\,X^{-1}C \cr &= 2(A^TM - X^{-T}MC^TX^{-T}) : dX \cr } – Nick Mar 23 '16 at 15:47
• The Frobenius mixed product rules are\eqalign{A:BC&=B^TA:C\cr &=AC^T:B\cr (A\otimes B):(X\otimes Y)&=(A:X)\otimes(B:Y)\cr A:B\circ C&=A\circ B:C}where $\otimes$ is the Kronecker product, $\circ$ is the Hadamard product, and juxtaposition is the standard matrix product. It is also worth noting that the Hadamard and Frobenius products are commutative.$$.$$These rules can be derived from the Frobenius-trace equivalence$$A:B={\rm tr}(A^TB)$$ – lynn Mar 24 '16 at 15:26