0

$x, a$ in $\mathbb R^n$, $A$ in $\mathbb R^{n\times n}$. Compute $d(x^T a)/dx$ and $d(x^T A x)/dx$.

I'm not sure about how to think about these and how to do these. Can someone explain how to derive the expressions for the two?

Finally, what happens when we have $A$ and $X$, BOTH in $\mathbb R^{n\times n}$, and we want to find $dTrace(XA)/dX$?

John B
  • 16,854
ajfbiw.s
  • 375

2 Answers2

1

Let's use the convention that members of $\mathbb{R}^{n}$ are column vectors. Recall that $$ x^{T}a=\sum_{i=1}^{n}x_{i}a_{i} $$ and for a scalar $c$, $$ \frac{dc}{dx}\equiv\left(\begin{array}{c} \frac{dc}{dx_{1}}\\ \frac{dc}{dx_{2}}\\ \vdots\\ \frac{dc}{dx_{n}} \end{array}\right). $$ Therefore, $$ \frac{d\left(x^{T}a\right)}{dx}=\left(\begin{array}{c} a_{1}\\ a_{2}\\ \vdots\\ a_{n} \end{array}\right)=a. $$ You can follow the same arguments to get $$ \frac{d\left(x^{T}Ax\right)}{dx}=2Ax. $$ See a list of identities at https://en.wikipedia.org/wiki/Matrix_calculus#Scalar-by-matrix_identities.

parsiad
  • 25,154
  • I'm trying to follow the same arguments to get 2Ax. This is what I have: x^T A x = sum, j from 1 to n, xj, times sum, i from 1 to n, xi aij. So d(x^T A X)/dx =< d(double sum from the previous sentence)/dx1, d( double sum from prev)/dx2, ......d(double sum from prev sentence)/d(xn)>. Now what? – ajfbiw.s Feb 20 '16 at 21:29
0

Note that $x^ta=a^tx$ and so $$ \frac{d(x^tA)}{dx}=\frac{d}{dh}a^t(x+h)|_{h=0}=a^t. $$ Similarly, since $h^tAx=x^tA^th$, $$ \frac{d(x^tAx)}{dx}=\frac{d}{dh}(x+h)^tA(x+h)|_{h=0}=\frac{d}{dh}(x^tAh+h^tAx)|_{h=0}=x^t(A+A^t). $$ Finally, since $$ tr(XA)=\sum_{i=1}^n\sum_{j=1}^n X_{ij}A_{ji} $$ we have $$ \frac{d tr(XA)}{d X_{ij}}=A_{ji}, $$ which gives $$ \frac{d tr(XA)}{d X}=A^t. $$ All this must be interpreted properly if used to make other computations!

John B
  • 16,854