Partial Derivative of a double finite summation. How might i go about finding the derivative the following double sum 
$$\frac{\partial }{\partial x_i}\left(\sum _{k=1}^n\:\sum _{j=1}^n\:a_{kj}x_kx_j\right)\:$$
My inital idea was to end put the summation terms and $a_{kj}$ outside of the derivative, and then look for special cases where i=j i=k and i=j=k. However i'm quite stuck in the way of expressing it. Basically this is as far as i got.
$$\frac{\partial }{\partial x_i}\left(\sum _{k=1}^n\:\sum _{j=1}^n\:a_{kj}x_kx_j\right)\: = \sum _{k=1}^n\:\sum _{j=1}^n\:a_{kj}\frac{\partial \:}{\partial \:x_i}\left(x_kx_j\right)\:$$
 A: Visualize the double sum written out as follows
\begin{align}
a_{11}x_1x_1&+a_{12}x_1x_2&+a_{13}x_1x_3&+\cdots+a_{1i}x_1x_i&+\cdots&+a_{1n}x_1x_n\\
+a_{21}x_2x_1&+a_{22}x_2x_2&+a_{23}x_1x_3&+\cdots+a_{2i}x_2x_i&+\cdots&+a_{2n}x_2x_n\\
+a_{31}x_3x_1&+a_{32}x_3x_2&+a_{33}x_3x_3&+\cdots+a_{3i}x_3x_i&+\cdots&+a_{3n}x_3x_n\\
&\vdots&&\vdots&&\vdots\\
+a_{i1}x_ix_1&+a_{i2}x_ix_2&+a_{i3}x_3x_3&+\cdots+a_{ii}x_ix_i&+\cdots&+a_{in}x_ix_n\\
&\vdots&&\vdots&&\vdots\\
+a_{n1}x_nx_1&+a_{n2}x_nx_2&+a_{n3}x_3x_3&+\cdots+a_{ni}x_nx_i&+\cdots&+a_{nn}x_nx_n\\
\end{align}
The partial derivative of all terms except those in column $i$ and row $i$ will be zero.
You do not want to accidentally take the derivative of the term in row $i$ column $i$ twice. That said, you should obtain the result
$$ \frac{\partial \left(\sum _{k=1}^n\:\sum _{j=1}^n\:a_{kj}x_kx_j\right)}{\partial x_i}=\sum_{j=1}^n\left(a_{ji}+a_{ij}\right)x_j $$
A: Depending on the index $k$ we have to treat $x_k$ as constant if $k\ne i$ and as variable if $k=i$. The same holds for the index $l$. Consequently 
we partition the index range conveniently.

We obtain
  \begin{align*}
\color{blue}{\frac{\partial }{\partial x_i}}&\color{blue}{\sum _{k=1}^n\sum _{j=1}^na_{kj}x_kx_j}\\
&=\frac{\partial }{\partial x_i}\left(\sum _{{k=1}\atop{k\ne i}}^n\sum _{{j=1}\atop{j\ne i}}^na_{kj}x_kx_j
+x_i\sum _{{j=1}\atop{j\ne i}}^na_{ij}x_j
\right.\\
&\qquad\qquad\qquad+x_i\sum _{{k=1}\atop{k\ne i}}^na_{ki}x_k
+a_{ii}x_i^2\Bigg)\tag{1}\\
&=\left(\sum _{{k=1}\atop{k\ne i}}^n\sum _{{j=1}\atop{j\ne i}}^na_{kj}x_kx_j\right)\frac{\partial }{\partial x_i}(1)
+\left(\sum _{{j=1}\atop{j\ne i}}^na_{ij}x_j\right)\frac{\partial }{\partial x_i}(x_i)\\
&\qquad\quad+\left(\sum _{{k=1}\atop{k\ne i}}^na_{ki}x_k\right)\frac{\partial }{\partial x_i}(x_i)
+a_{ii}\frac{\partial }{\partial x_i}(x_i^2)\tag{2}\\
&=0+\sum _{{j=1}\atop{j\ne i}}^na_{ij}x_j+\sum _{{k=1}\atop{k\ne i}}^na_{ki}x_k+2a_{ii}\tag{3}\\
&\,\,\color{blue}{=\sum _{j=1}^n\left(a_{ij}+a_{ji}\right)x_j}\tag{4}
\end{align*}

Comment:


*

*In (1) we partition the double sum according to the factors $x_i$ in each summand.

*In (2) we use the linearity of the partial derivative.

*In (3) we do the partial differentiation.

*In (4) we do some final simplifications.
A: Note that $\frac{\partial (x_j x_k)}{\partial x_i}=x_j\delta
_{ik}+x_k \delta_{ij}$ where $\delta_{nm}=0$ for $n\ne m$ and $\delta_{nm}=1$ when $n=m$ is the Kronecker Delta. 
Now, apply the sifting property of the Kronecker Delta.
A: Following Mark Viola's observation, the derivative is$$\sum_{jk}a_{kj}\delta_{ik}x_j+\sum_{jk}a_{kj}x_k\delta_{ij}=\sum_{j}a_{ij}x_j+\sum_{k}x_ka_{ki}=\sum_j(a_{ij}+a_{ji})x_j.$$
