I'm trying to apply the chain rule on a quadratic form:
$\frac{dx^TAx}{dx}=\frac{dx^T(Ax)}{dx}=\frac{dx^T(Ax)}{dAx}\frac{dAx}{dx}=\frac{dx^T(Ax)}{dAx} A$
But I'm stuck here. I think $\frac{dx^T(Ax)}{dAx}=x^T$ because $Ax$ is just a vector. But I already know that for symmetric $A$, $\frac{dx^TAx}{dx}=2Ax$. And that doesn't go together. What am I doing wrong here?
Update:
$\frac{dx^T(Ax)}{dAx}\neq x^T$ because $x^T$ and $Ax$ are not independent.
Instead $\frac{dx^T(Ax)}{dAx} = x^T\frac{dAx}{dAx} + (Ax)^T\frac{dx}{dAx} = x^T + (Ax)^T\frac{dx}{dAx}$
So my next problem is $\frac{dx}{dAx}$.
Hint.
Apply the chain rule with $f(x)=Ax$ and $g(x,y)=x^Ty$. You have $$h(x)=x^TAx=g(x,f(x))$$
$g^\prime(x,y).(h,k)=h^Ty+xk$ and $f^\prime(x).h=Ah$. Hence $$h^\prime(x).h=h^TAx+x^TAh$$