What is the derivative of $f: \mathbb R^n \to \mathbb R, f(x) = x^\top A x$, where $A$ is an $n \times n$ real matrix?
My answer is below. Is it correct? And is there a simpler way to derive this (one that doesn't need to use sums over indexes)?
Notation: $\sum_i$ means $\sum_{1 \leq i \leq n}$.
$$\begin{align*}f(x) &= x^\top A x \\ &= \sum_i x_i [Ax]_i \\ &= \sum_i x_i [\sum_j A_{ij} x_j] \\ &= \sum_{i,j} A_{ij} x_i x_j. \\ \end{align*}$$
Therefore $$[Df(x)]_k = \sum_{i,j}A_{ij}d_{ij}(x_i, x_j)$$ where $$d_{ij}(u,v) = \begin{cases} 0 & \text{if } i \neq k, j \neq k \\ v & \text{if } i = k, j \neq k \\ u & \text{if } i \neq k, j = k \\ u + v & \text{if } i = k, j = k. \\ \end{cases}$$ Simplifying, we get $$\begin{align*}[Df(x)]_k &= \sum_i[A_{ik} + A_{ki}]x_i\\ Df(x) &= (A + A^\top)x.\end{align*}$$