Consider the follow equation
$$f(\vec{x}) = c(\vec{x})B\vec{x}$$
where $c(\vec{x})$ is given by the generalized Rayleigh quotient
$$c(\vec{x}) = \frac{\vec{x}^{T}A\vec{x}}{\vec{x}^{T}B\vec{x}}$$
$\vec{x}$ is a vector, and A and B are square matrices. I want to take the derivative of this equation with respect to $\vec{x}$. My intuition is to use the product rule to obtain
$$\frac{\partial f(\vec{x})}{\partial \vec{x}} = c'(\vec{x})A \vec{x} + c(\vec{x})B.$$
I know that the derivative of $c(\vec{x})$ is given by
$$c'(\vec{x}) = \frac{2(\vec{x}^{T}B\vec{x})A\vec{x} - 2(\vec{x}^{T}A\vec{x})B\vec{x}}{(\vec{x}^{T}B\vec{x})^{2}}$$
which is a vector. However, I do not believe the product of this derivative and the matrix, $c'(\vec{x})A\vec{x}$, to be valid since this would be a scalar and I would be adding it to a matrix. How does one compute this derivative? Any references would be welcomed.