TITLE: How to calculate the gradient of $x^T A x$?
QUESTION [27 upvotes]: I am watching the following video lecture:
https://www.youtube.com/watch?v=G_p4QJrjdOw
In there, he talks about calculating gradient of $ x^{T}Ax $ and he does that using the concept of exterior derivative. The proof goes as follows:

$ y = x^{T}Ax$
$ dy = dx^{T}Ax + x^{T}Adx = x^{T}(A+A^{T})dx$ (using trace property of matrices)
$ dy = (\nabla y)^{T} dx $ and because the rule is true for all $dx$
$ \nabla y = x^{T}(A+A^{T})$

It seems that in step 2, some form of product rule for differentials is applied. I am familiar with product rule for single variable calculus, but I am not understanding how product rule was applied to a multi-variate function expressed in matrix form.
It would be great if somebody could point me to a mathematical theorem that allows Step 2 in the above proof.
Thanks!
Ajay

REPLY [2 votes]: I think it's pretty straightforward. First consider $x^TAx = (x^T)(Ax)$, so that you now have $x^TAx$ as product of two functions.
And it's easy to see that $\dot{(x^T)} = \dot x^T$, and $\dot{(Ax)} = A\dot x$
So now you have $d(x^TAx) = (dx)^TAx + x^TA(dx)$, which is essentially what you want.