TITLE: Vector Matrix Differentiation (to maximize function)
QUESTION [8 upvotes]: how would I calculate the derivative of the following. I want to know the derivative so that I can maximise it.
$$
    \frac{x^TAx}{x^TBx}
$$
Both the matricies A and B are symmetric. I know the derivative of $\frac{d}{dx}x^TAx = 2Ax$. Haven't been very successful applying the quotient rule to the above though. Appreciate the help. Thanks!
EDIT: In response to "What goes wrong when applying the chain rule". We know that:
$$
    \frac{d}{dx}\frac{u}{v} = \frac{vu' - uv'}{v^2}
$$
Which would give me: 
$$
   \frac{2x^TBxAx - 2x^TAxBx}{x^TBx^2} \, or \, \frac{2Axx^TBx - 2Bxx^TAx}{(x^TBx)^2}
$$
In the first case the dimensions don't agree. In the second they do, but I don't want to assume that it's correct just because the dimensions agree. If it is correct then please do let me know!

REPLY [2 votes]: Use hypoograph/Epigraph Technique to maximize/minimize the ratio. For example
$\min_x \frac{x^T A x}{x^T B x}$
$ \equiv \min_{x,t} t$
$ \text{ subject to }$
$ {x^T A x}\leq t(x^T B x),t>0$. 
Then form a Lagrangain to solve for the optimum.