Commutation formula for covariant derivative Suppose $\nabla$ is the Levi-Civita connection on Riemannian manifold $M$. $X$ be a vector fields on $M$ defined by $X=\nabla r$ where $r$ is the distance function to a fixed point in $M$. $\{e_1, \cdots, e_n\}$ be local orthnormal frame fields. We want to calculate $(|\nabla r|^2)_{kk}=\nabla_{e_k}\nabla_{e_k}|\nabla r|^2$.
Let $$\nabla r=\sum r_i e_i$$
so $r_i=\nabla_{e_i}r$.
The standard calculation for tensor yields:
$$(|X|^2)_{kk}=(\sum r_i^2)_{kk}\\
=2(\sum r_i r_{ik})_{k} \\
=2\sum r_{ik}r_{ik}+2\sum r_i r_{ikk}
$$
My question is, how to switch the order of partial derivatives $r_{ikk}$ to $r_{kki}$. I know some curvature terms should apear, but I am very confused by this calculation.
My main concern is $r_i$ should be function, when exchange the partial derivatives Lie bracket will apear, how come the curvature term apears?
Anyone can help me with this basic calculations?
 A: I don't think curvature terms should appear since $\nabla_{e_i} \nabla_{e_i} f = e_i \cdot e_i f$, where you think of the $e_i$ as first order differential operators.  Then using your notation
$$
r_{ikk} = e_k e_k e_i r = (e_k [e_k,e_i] + e_ke_i e_k) r = (e_k[e_k,e_i] + [e_k,e_i] e_k + e_ie_ke_k)r = (e_k[e_k,e_i] + [e_k,e_i] e_k)r + r_{kki}.
$$
So $r_{ikk}$ differs from $r_{kki}$ by a second order term.
A: Commuting covariant derivatives leads to a term in the curvature tensor. Indeed, the Riemann curvature tensor is
$$
R(X,Y)T = \nabla_X\nabla_Y T - \nabla_Y\nabla_X T - \nabla_{[X,Y]} T
$$
Often, this is written for $T = Z$, a vector field, but $T$ can be any tensor. If $T= f$ is a function, the curvature is zero on $f$, (assuming a zero torsion connection). However, for other kinds of tensors, the curvature is nonzero. Let me give you an example. Assume $J$ is a Jacobi field :
$$
[\partial_r,J] = 0
$$
where $r$ is a distance function. Then, (here, the connection is Riemannian)
$$
[\partial_r,J] = \nabla_{\partial_r}J - \nabla_J \partial_r = 0
$$
Taking a second covariant derivative gives
$$
\nabla^2_{\partial_r} J - \nabla_{\partial_r} \nabla_J \partial_r = 0
$$
Now, commuting in terms of the curvature tensor, 
$$
\nabla^2_{\partial_r} J + R(J,\partial_r)\partial_r - \nabla_J\nabla_{\partial_r}\partial_r = 0
$$
The last term is zero because $\partial_r$ is self-parallel. So we have the Jacobi equation
$$
\nabla^2_{\partial_r} J + R(J,\partial_r)\partial_r  = 0
$$
...can you point out to me the example you would like to work out...I don't have the book in question, but is it about the Bochner method, by any chance? -- Salem
