# Taking matrix derivative with MATLAB or Wolfram Alpha [closed]

I want to take the derivate of a rather complicated matrix expression. Is it possible to do this in MATLAB or Wolfram Alpha? Here is what I am trying to calculate:

$$\frac{\partial}{ \partial {\bf X}} {\bf a}^T({\bf I}+\alpha {\bf X}^T{\bf A}^T{\bf A}{\bf X})^{-1}{\bf a}$$

Or if you know a cookbook where I can find this derivative, it would be highly appreciated! Thank you.

-

## closed as off-topic by abx, José Figueroa-O'Farrill, Will Jagy, Chris Godsil, SuvritSep 1 '14 at 17:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about research level mathematics within the scope defined in the help center." – abx, José Figueroa-O'Farrill, Will Jagy, Chris Godsil, Suvrit
If this question can be reworded to fit the rules in the help center, please edit the question.

Can you elaborate on what kind of an object you want the derivative to be? If you differentiate a scalar valued function $f(X)$ with respect to a matrix $X$, the derivative $Df(X)$ is the matrix satisfying $f(X+Y)=f(X)+\text{tr}(Y^TDf(X))+o(1)$ as $Y\to0$. Is this the kind of derivative you have in mind? If yes, then $Df(X)_{ij}=\partial f(X)/\partial x_{ij}$, and this matrix can be formed with Mathematica at least. – Joonas Ilmavirta Sep 1 '14 at 9:52

The derivative with respect to $X$ at $X$ in the direction $Y$ is $$-{\bf a}^T({\bf I}+\alpha {\bf X}^T{\bf A}^T{\bf A}{\bf X})^{-1} \alpha({\bf Y}^T{\bf A}^T{\bf A}{\bf X} + {\bf X}^T{\bf A}^T{\bf A}{\bf Y}) ({\bf I}+\alpha {\bf X}^T{\bf A}^T{\bf A}{\bf X})^{-1}{\bf a}.$$ Namely, $D_{X,Y}(X^{-1}) = -X^{-1}YX^{-1}$, and the inner expession is bilinear.

-

I presume by "taking the derivative" you mean that you want to know how this expression $\Omega(X)=a^TM(X)a$, with $M(X)=(I+\alpha X^TA^TAX)^{-1}$, changes when you change $X$ by a small amount $\delta X$. So just make a series expansion,

$$\Omega(X+\delta X)=a^TM(X)\sum_{n=0}^\infty(-1)^n\{(\alpha \delta X^TA^TAX+\alpha X^TA^TA\delta X)M(X)\}^na$$

To first order you find

$$\Omega(X+\delta X)=a^TM(X)a-\alpha a^TM(X)(\delta X^TA^TAX+X^TA^TA\delta X)M(X)a$$

If you wish, you can restrict yourselves to scalar perturbations, $\delta X=\epsilon I$, then

$$\frac{d\Omega}{d\epsilon}=-\alpha a^TM(X)(A^TAX+X^TA^TA)M(X)a$$

-