Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Given a matrix $A$ and column vector $x$, what is the derivative of $Ax$ with respect to $x^T$ i.e. $\frac{d(Ax)}{d(x^T)}$, where $x^T$ is the transpose of $x$?

Side note - my goal is to get the known derivative formula $\frac{d(x^TAx)}{dx} = x^T(A^T + A)$ from the above rule and the chain rule.

Thanks,
Asaf

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Let $f(x) = x^TAx$ and you want to evaluate $\frac{df(x)}{dx}$. This is nothing but the gradient of $f(x)$.

There are two ways to represent the gradient one as a row vector or as a column vector. From what you have written, your representation of the gradient is as a row vector.

First make sure to get the dimensions of all the vectors and matrices in place.

Here $x \in \mathbb{R}^{n \times 1}$, $A \in \mathbb{R}^{n \times n}$ and $f(x) \in \mathbb{R}$

This will help you to make sure that your arithmetic operations are performed on vectors of appropriate dimensions.

Now lets move on to the differentiation.

All you need to know are the following rules for vector differentiation.

$$\frac{d(x^Ta)}{dx} = \frac{d(a^Tx)}{dx} = a^T$$ where $x,a \in \mathbb{R}^{n \times 1}$.

Note that $x^Ta = a^Tx$ since it is a scalar and the equation above can be derived easily.

(Some people follow a different convention i.e. treating the derivative as a column vector instead of a row vector. Make sure to stick to your convention and you will end up with the same conclusion in the end)

Make use of the above results to get,

$$\frac{d(x^TAx)}{dx} = x^T A^T + x^T A$$ Use chain rule to get the above result i.e. first take $Ax$ as constant and then take $x^T A$ as constant.

So, $$\frac{df(x)}{dx} = x^T(A^T + A)$$

share|improve this answer
    
I think you've got an x too much at the end of your last line (and a superfluous pair of parentheses). Other than that, I agree with everything, but it's not an answer to the question as I understand it. –  joriki Feb 6 '11 at 18:57
    
@joriki: Thanks for pointing that out. –  user17762 Feb 6 '11 at 19:05
    
I think my problem was failing to notice that Ax is a vector. How small errors lead to a big waste of time... Thank you for the detailed answer. –  Asaf R Feb 8 '11 at 0:32

I think there is no such thing. $\mbox{d}(x^\mbox{T}Ax)/\mbox{d}x$ is something that, when multiplied by the change $\mbox{d}x$ in $x$, yields the change $\mbox{d}(x^\mbox{T}Ax)$ in $x^\mbox{T}Ax$. Such a thing exists and is given by the formula you quote. $\mbox{d}(Ax)/\mbox{d}(x^\mbox{T})$ would have to be something that, when multiplied by the change $\mbox{d}x^\mbox{T}$ in $x^\mbox{T}$, yields the change $\mbox{d}Ax$ in $Ax$. No such thing exists, since $x^\mbox{T}$ is a $1 \times n$ row vector and $Ax$ is an $n \times 1$ column vector.

If your main goal is to derive the derivative formula, here's a derivation:

$(x^\mbox{T} + \mbox{d}x^\mbox{T})A(x + \mbox{d}x) = x^\mbox{T}Ax + \mbox{d}x^\mbox{T}Ax + x^\mbox{T}A\mbox{d}x + \mbox{d}x^\mbox{T}A\mbox{d}x =$

$=x^\mbox{T}Ax + x^\mbox{T}A^\mbox{T}\mbox{d}x + x^\mbox{T}A\mbox{d}x + O (\lVert \mbox{d}x \rVert^2) = x^\mbox{T}Ax + x^\mbox{T}(A^\mbox{T} + A)\mbox{d}x + O (\lVert \mbox{d}x \rVert^2)$

share|improve this answer
    
@joriki : It is strong to say that there is no such thing. Usually this is interpreted as the gradient of a function. –  user17762 Feb 6 '11 at 18:23
    
I think one of us misunderstood the question. In your answer, you answered the question what df/dx = d(x^T A x)/dx is. Yes, this exists and is the gradient of f. But if I understand the question correctly, it asked what d(Ax)/d(x^T) is, where A is a matrix. I still think that no such thing exists. –  joriki Feb 6 '11 at 18:54
    
@joriki: The interpretation of $\frac{d(Ax)}{dx^T}$ is the Hessian right? which in this case is nothing but $A$. –  user17762 Feb 6 '11 at 19:10
    
One way to think of this is as the gradient of the vector function, where each row corresponds to the gradient of each component of this vector function. –  user17762 Feb 6 '11 at 19:19
    
I don't think so. $\mbox{d}(Ax)/\mbox{d}x$ is $A$, and I don't see how it could make sense to have $\mbox{d}(Ax)/\mbox{d}x = \mbox{d}(Ax)/\mbox{d}x^\mbox{T}$. See en.wikipedia.org/wiki/…. All formulas there are well-defined in the sense I discuss in my answer, and they have $\mbox{d}(Ax)/\mbox{d}x$ and $\mbox{d}(x^\mbox{T}A)/\mbox{d}x^\mbox{T}$, but not $\mbox{d}(Ax)/\mbox{d}x^\mbox{T}$. –  joriki Feb 6 '11 at 19:19

As Sivaram points out, you must define your convention about rows/colums derivatives and just be consistent.

For example, you could define the derivative of a column vector with respect to a row vector as (assuming the letters represent column vectors) as matrix:

$\displaystyle \frac{d(y)}{dx^T} = D$ with $d_{i,j} = \frac{d(y_i)}{dx^j}$

And that will work (it will be consistent). For example, you get $\displaystyle \frac{d(Ax)}{dx^T} = A$

But it's not so simple to apply this -and the product rule of derivation- to deduce your identity, because you get to different derivatives: a row with respect to a row and a column respect to row, and you can't (at least without further justification) mix them.

Of course, if the matrix is simmetric all is simpler.

share|improve this answer
    
OK, to make my point of view more precise, I should say: You are both right that if you want to define the notation this way you can do it; but in the notation that Asaf himself used for $\mbox{d}(x^\mbox{T}Ax)/\mbox{d}x$, and that is used on Wikipedia, it doesn't make sense to write $\mbox{d}(Ax)/\mbox{d}x^\mbox{T}$. Can we agree on that? –  joriki Feb 6 '11 at 20:28

Mathematicians kill each other about derivatives and gradients. Do not be surprised if the students do not understand one word about this subject. The previous havocs are partly caused by the Matrix Cookbook, a book that should be blacklisted. Everyone has their own definition. $\dfrac{d(f(x))}{dx}$ means either a derivative or a gradient (scandalous). We could write $D_xf$ as the derivative and $\nabla _xf$ as the gradient. The derivative is a linear application and the gradient is a vector if we accept the following definition: let $f:E\rightarrow \mathbb{R}$ where $E$ is an euclidean space. Then, for every $h\in E$, $D_xf(h)=<\nabla_x(f),h>$. In particular $x\rightarrow x^TAx$ has a gradient but $x\rightarrow Ax$ has not ! Using the previous definitions, one has (up to unintentional mistakes):

Let $f:x\rightarrow Ax$ where $A\in M_n$ ; then $D_xf=A$ (no problem). On the other hand $x\rightarrow x^T$ is a bijection (a simple change of variable !) ; then we can give meaning to the derivative of $Ax$ with respect to $x^T$: consider the function $g:x^T\rightarrow A(x^T)^T$ ; the required function is $D_{x^T}g:h^T\rightarrow Ah$ where $h$ is a vector ; note that $D_{x^T}g$ is a constant. EDIT: if we choose the bases $e_1^T,\cdots,e_n^T$ and $e_1,\cdots,e_n$ (the second one is the canonical basis), then the matrix associated to $D_{x^T}g$ is $A$ again.

Let $\phi:x\rightarrow x^TAx$ ; $D_x\phi:h\rightarrow h^TAx+x^TAh=x^T(A+A^T)h$. Moreover $<\nabla_x(f),h>=x^T(A+A^T)h$, that is ${\nabla_x(f)}^Th=x^T(A+A^T)h$. By identification, $\nabla_x(f)=(A+A^T)x$, a vector (formula (89) in the detestable matrix Cookbook !) ; in particular, the solution above $x^T(A+A^T)$ is not a vector !

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.