[Math] Partial derivative with respect to a vector x for $F(x) = x^TA(x)x$

derivativeslinear algebramatrices

I have the next function $F(x) = x^TA(x)x$, where $x$ is a real vector with dimension $n$, and $A$ is a square real matrix $n \times n$ depending on the components of $x$.

How can I compute the partial derivative of $F(x)$ with respect to $x$?

I know when $A$ is constant that $\frac{\partial F}{\partial x} = x^T(A+A^T)$. What I do not know how to deal when $A$ depends on elements of $x$.

Thanks in advance.

Best Answer

What you want is the gradient $\nabla F(x)$. In order to find it write $F$ as $$F(x)=\sum_{i,k} x_i a_{ik}(x_1,\ldots, x_n)x_k$$ and obtain $${\partial F\over\partial x_j}=\sum_k a_{jk} x_k+\sum_{i,k} x_i{\partial a_{ik}\over\partial x_j}x_k+\sum_i x_i a_{ij}\ .$$ It follows that for a tangent vector $Y$ at $x$ we have $$\nabla F(x)\cdot Y=Y^\top A\> x + x^\top(\nabla A\cdot Y)\>x + x^\top A\> Y\ .$$