Derivative of $\frac{\mathrm{trace}(A_1X)}{\mathrm{trace}(A_2X)}$ with respect to $X$?
What is the derivative of $\frac{\mathrm{trace}(A_1X)}{\mathrm{trace}(A_2X)}$ with respect to $X$, where $A_1, A_2$ and $X$ are all Hermitian matrices?
We know that $\frac{\partial(\mathrm{trace}(A_1X))}{\partial(X)}=A_1$ and $\frac{\partial(\mathrm{trace}(A_2X))}{\partial(X)}=A_2$.
Can we do the following:
$$\frac{\partial(\frac{\mathrm{trace}(A_1X)}{\mathrm{trace}(A_2X)})}{\partial(X)}=\frac{\frac{\partial(\mathrm{trace}(A_1X))}{\partial(X)}\mathrm{trace}(A_2X)-\mathrm{trace}(A_1X)\frac{\partial(\mathrm{trace}(A_2X))}{\partial(X)}}{\mathrm{trace}^2(A_2X)}=\frac{A_1\mathrm{trace}(A_2X)-\mathrm{trace}(A_1X)A_2}{\mathrm{trace}^2(A_2X)}?$$
Consider the real case so that all involved matrices are symmetric.
Let $\phi = \frac{\mathrm{tr}(\mathbf{A}_1 \mathbf{X})} {\mathrm{tr}(\mathbf{A}_2 \mathbf{X})} = \frac{N}{D} $. It follows $$ d\phi = \frac{D(dN)-N(dD)}{D^2} = \frac{D\mathbf{A}_1-N\mathbf{A}_2}{D^2}: d\mathbf{X} $$ where $:$ denotes the Frobenius inner product.
The symmetric gradient is $$ \frac{\partial \phi}{\partial \mathbf{X}} = \frac{D\mathbf{A}_1-N\mathbf{A}_2}{D^2} $$