Derivative of abs(x'Ax) with respect to x

58 Views Asked by At

I would like to know how the derivative of $ f=\mathrm{abs}(x^\top \cdot A\cdot x) $ is derived, where $x$ is a vector and $A$ is a matrix.

Following the chain rule I would have expected it to be

$ \frac{\partial f}{\partial x} = -\mathrm{sign}(x^\top \cdot A\cdot x)(A \cdot x+A^\top \cdot x) $

However according to http://www.matrixcalculus.org/, the derivative is

$ \frac{\partial f}{\partial x} = \mathrm{sign}(x^\top \cdot A\cdot x)\cdot A\cdot x+\mathrm{sign}(x^\top \cdot A^\top \cdot x)\cdot A^\top \cdot x $

How is this derived? Thanks in advance.