Verifying matrix product rule example Suppose $f(x) = \textbf{x}^TA\textbf{x}$. I want to verify the product rule using this. So I decided to try a set up like $\mathcal{F}(\textbf{x}) = f(\textbf{x})g(\textbf{x})$ where $f(\textbf{x}) = \textbf{x}^T$ and $g(\textbf{x}) = A\textbf{x}$. So I would want to show $\frac{\partial \mathcal{F}}{\partial x_i} = \frac{\partial f}{\partial x_i}g(\textbf{x}) + f(\textbf{x})\frac{\partial g}{\partial x_i} = 2\textbf{x}^Ta_i$ for $a_i \in \mathbb{R}^n$ i-th row of $A$. If I show this, then it is easy to get the full case for $\textbf{x}$
My attempt is below:
$$\frac{\partial f}{\partial x_i} = [0 0 ... 1 ... 0]$$
$$\frac{\partial g}{\partial x_i} = \begin{bmatrix} 
a_{1i} \\
a_{2i} \\
\dots \\
a_{ni}
\end{bmatrix}
= a_i \in \mathbb{R}^n
$$
And so we see that $$\frac{\partial f}{\partial x_i} g(x) = [0 0 ... 1 ... 0] \begin{bmatrix}
                                                                            a_{11}x_1+...+a_{1n}x_n \\
                                                                            \dots \\
                                                                            a_{i1}x_1+...+a_{ii}x_i+...+ a_{in}x_n\\
                                                                            \dots
                                                                            \end{bmatrix}   
= \sum_{j=1}^{n} a_{ij}x_j$$
And similarly, $$f(x) \frac{\partial g}{\partial x_i} = [x_1 x_2 ... x_n] \begin{bmatrix} 
                                                                        a_{1i} \\
                                                                        a_{2i} \\
                                                                        \dots \\
                                                                        a_{ni}
                                                                        \end{bmatrix}
 = \sum_{j=1}^{n}a_{ji}x_j$$
Hence, $\frac{\partial \mathcal{F}}{\partial x_i} = \frac{\partial f}{\partial x_i} g(x) + f(x) \frac{\partial g}{\partial x_i} = \sum_{j=1}^{n} a_{ij}x_j + \sum_{j=1}^{n}a_{ji}x_j$.
Now this is where I am stuck, as the answer seems to be close, but instead I have the i-th column sum with the i-th row sum, and so I get something slightly different. Where did I go wrong? Is my setup incorrect?

Note that $f(x)=x^T$ and $g(x) = Ax$ are both linear hence they are their own derivatives. Then the chain rule gives
$D(f \circ g)(x)h = Df(x)h f(x) + f(x)Dg(x)h = f(h)g(x)+f(x)g(h) = x^T(A+A^T) h$.
I have been a little sloppy by not distinguishing function application and matrix multiplication.
