Lost in the indices! I'm trying to derive from the Lagrangian
$$L=\frac{1}{2}\sum_{i,j}g_{ij}\,\dot{x}^i\dot{x}^j,$$
the geodesic equations
$$\ddot{x}^k+\sum_{i,j}\left(\frac{1}{2}\sum_lg^{kl}\left(\frac{\partial g_{lj}}{\partial x^i}+\frac{\partial g_{il}}{\partial x^j}-\frac{\partial g_{ij}}{\partial x^l}\right)\right)\dot{x}^i\dot{x}^j=0.\tag{1}$$
So,
$$\frac{\partial L}{\partial x^l}=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j,$$
and
$$\begin{align*}\frac{\partial L}{\partial \dot{x}^l}&=
\frac{1}{2}\sum_{i,j}\Big(g_{lj}\dot{x}^j+g_{il}\dot{x}^i\Big)\\
&=\frac{1}{2}\sum_k\left(g_{lk}\dot{x}^k+g_{kl}\dot{x}^k\right)\\
&=\sum_k g_{kl}\dot{x}^k,\end{align*}$$
since $g_{ij}=g_{ji}$. Then substituting these into the Euler-Lagrange equation gives (where a dot indicates a derivative with respect to $\tau$)
$$\begin{align*}
\frac{\mathrm{d}}{\mathrm{d}\tau}\left(\frac{\partial L}{\partial \dot{x}^l}\right)
&=\frac{\partial L}{\partial x^l}\\
\frac{\mathrm{d}}{\mathrm{d}\tau}\left(\sum_k g_{kl}\dot{x}^k\right)
&=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j.
\end{align*}$$
This is where my problems begin! Evaluating the derivative gives
$$
\sum_k\left(\frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k+g_{kl}\ddot{x}^k\right)
=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j
$$
Now, was it appropriate here to take the partial derivative with respect to $x^i$ or could/should I have chosen another free index; i.e. $j$ or $l$? (I don't think that I can choose $l$ as that is being used in the metric - or can I?!)
Moving along, I tried splitting up the LHS in a similar way to something I saw in another post:
$$
\sum_i \frac{1}{2}\frac{\partial g_{il}}{\partial x^k}\dot{x}^k\dot{x}^i + \sum_k\left(\frac{1}{2}\frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k+g_{kl}\ddot{x}^k\right)
=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j,
$$
and multiplying by the inverse metric gives
$$
\sum_i \frac{1}{2} g^{lk} \frac{\partial g_{il}}{\partial x^k}\dot{x}^k\dot{x}^i + \sum_k\left(\frac{1}{2} g^{lk} \frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k+g^{lk} g_{kl}\ddot{x}^k\right)
=\frac{1}{2}\sum_{i,j} g^{lk} \frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j.
$$
I'm not sure how to proceed from here in order to obtain the form of $(1)$. Also, is this even correct?
$$
\sum_k g^{lk} g_{kl}\ddot{x}^k
$$
I'm sure that I've read somewhere that you can't have the dummy index repeated more than twice in a term.
Any help will be appreciated!
 A: Note that in
$$\sum_k\left(\frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k+g_{kl}\ddot{x}^k\right)
=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j$$
you have missed a sum over $i$. It should be
$$\sum_k\left(\sum_i \frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k+g_{kl}\ddot{x}^k\right)
=\frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j$$
i.e.
$$\sum_{i,k} \frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k + \sum_k g_{kl}\ddot{x}^k = \frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j$$
Here, because of symmetry of $i$ and $k$ in $\dot{x}^i\dot{x}^k$, the partial derivative of $g$ can be symmetrized:
$$
\sum_{i,k} \frac{\partial g_{kl}}{\partial x^i}\dot{x}^i\dot{x}^k
= \frac12 \sum_{i,k} \left( \frac{\partial g_{kl}}{\partial x^i} + \frac{\partial g_{il}}{\partial x^k} \right) \dot{x}^i\dot{x}^k
$$
Thus we have
$$
\frac12 \sum_{i,k} \left( \frac{\partial g_{kl}}{\partial x^i} + \frac{\partial g_{il}}{\partial x^k} \right) \dot{x}^i\dot{x}^k
+ \sum_k g_{kl}\ddot{x}^k
= \frac{1}{2}\sum_{i,j}\frac{\partial g_{ij}}{\partial x^l}\,\dot{x}^i\dot{x}^j$$
which can be rewritten as
$$
\sum_k g_{kl}\ddot{x}^k + \frac12 \sum_{i,j} \left( \frac{\partial g_{jl}}{\partial x^i} + \frac{\partial g_{il}}{\partial x^j} - \frac{\partial g_{ij}}{\partial x^l} \right) \dot x^i \dot x^j = 0
$$
