proof of a fluid dynamics identity using index notation I need to prove $$\underline{q}\times (\underline{\nabla}\times \underline{q}) = \nabla\left(\frac{q^2}{2}\right)-(\underline{q}\cdot\underline{\nabla})\underline{q}$$ using index notation, so here's my work:
$$(\underline{q}\times (\underline{\nabla}\times \underline{q}))_i = \varepsilon_{ijk}q_j\varepsilon_{klm}\partial_lq_m = \varepsilon_{kij}\varepsilon_{klm}q_j\partial_lq_m = (\delta_{il}\delta_{jm}-\delta_{im}\delta_{jl})q_j\partial_lq_m $$
which then gives $$q_m\partial_iq_m-q_l\partial_lq_i = q_m\partial_iq_m-((\underline{q}\cdot \underline{\nabla})\underline{q})_i$$
But I cant figure out how $q_m\partial_iq_m$ becomes $\left(\nabla\left(\frac{q^2}{2}\right)\right)_i$ how do I show it?

We have
$$ \left( \nabla \left( \frac{q^2}{2} \right) \right)_i = \left( \nabla \left( \frac{\sum_{m=1}^n q_m^2}{2} \right) \right)_i = \sum_{m=1}^n \left( \nabla \left( \frac{q_m^2}{2} \right) \right)_i = \sum_{m=1}^n q_m \partial_i (q_m).$$
In the latter equality, I used $\nabla(fg) = f \nabla g + \nabla f g$ for scalar $f,g$ which can be proved by nothing that
$$ (\nabla(fg))_i = \partial_i(fg) = f (\partial_i g) + (\partial_i f)g. $$
In particular, this implies that $\nabla \left( \frac{f^2}{2} \right)_i = \frac{1}{2} \nabla(f^2)_i =  f \partial_i f$.
