0

What would be $\nabla f(x)$ if $f(x) = x^tAx$ where A is a n by n matrix and x is a n by 1 matrix. I have gone till $x'Ax + x^tAx'$ (where x' represents derivative) to find the solution but can see how I can write this as $(A^t + A)x$?

  • 1
    If you're trying to find the derivative of a scalar with respect to a vector, the derivative must be a vector. So the expression you've arrived at is not correct, since it is a scalar. – Sean Lee Jan 27 '19 at 16:27
  • I just tried to apply the simple chain rule. Can you help me get to the right expression? – Usman Ashraf Jan 27 '19 at 17:35

1 Answers1

3

Before we start deriving the gradient, some facts and notations for brevity:

  • Trace and Frobenius product relation $$\left\langle A, B C\right\rangle={\rm tr}(A^TBC) := A : B C$$
  • Cyclic properties of Trace/Frobenius product \begin{align} A : B C &= BC : A \\ &= A C^T : B \\ &= {\text{etc.}} \cr \end{align}

Let $f(x) := x^T A x = x:Ax$.

Now, we can obtain the differential first, and then the gradient. \begin{align} df &= d\left( x:Ax \right) \\ &= \left(dx : Ax\right) + \left(x : A \ dx\right) \\ &= \left(Ax : dx\right) + \left(A^Tx : dx\right) \\ &= \left( A + A^T\right)x : dx\\ \end{align}

Thus, the gradient is \begin{align} \frac{\partial}{\partial x}f(x) = \frac{\partial}{\partial x} \left\{x^T A x\right\} = \left( A + A^T\right)x. \end{align}

user550103
  • 2,688
  • can you help figure it out using summations because I am not aware of frobenius norm properties? or some other method that would be recommended for beginners. – Usman Ashraf Jan 28 '19 at 23:02
  • see this https://math.stackexchange.com/questions/189434/derivative-of-quadratic-form – user550103 Jan 29 '19 at 06:48
  • Thanks man. The explanation by Copper.hat on that really helped! @MISC {189436, TITLE = {Derivative of Quadratic Form}, AUTHOR = {copper.hat (https://math.stackexchange.com/users/27978/copper-hat)}, HOWPUBLISHED = {Mathematics Stack Exchange}, NOTE = {URL:https://math.stackexchange.com/q/189436 (version: 2015-07-18)}, EPRINT = {https://math.stackexchange.com/q/189436}, URL = {https://math.stackexchange.com/q/189436} } – Usman Ashraf Jan 29 '19 at 20:59