# How to derive the formula for the second covariant derivative?

If the first covariant derivative is derived by taking the partial derivative of a vector and applying the product rule to the vector components and the vector bases, couldn't the same thing be done to take the second covariant derivative (i.e. use the product rule to the components and bases of the covariant derivative already taken)? Why is it that the formula for the covariant derivative of a rank two tensor must instead be used instead of just taking the second partial derivative of the vector using the product rule as mentioned above?

If $\nabla_X= X^\mu D_\mu$ is the covariant derivative on any tensor, then the usual definition of the "second covariant derivative" is
$$\nabla^2_{U,V} = \nabla_U \nabla_V -\nabla_{\nabla_U V}.$$
The second term in gets rid of the derivative of $V$ so that $$\nabla^2_{U,V} = U^\mu V^\nu D_\mu D_\nu$$ with an extra connection term tacitly understood in $D_\mu$: Making the extra term explicit gives
$$\nabla^2_{\mu\nu}= D_\mu D _\nu- {\Gamma^\lambda}_{\nu\mu}D_\lambda.$$
In general it is safer to use $\nabla_X$'s rather than $\nabla_\mu$'s because $\nabla_X$ takes in a tensor and returns a tensor of the same type (i.e.with the same number of indices). Then no "tacit" extra connection terms are needed. Expressions like $$[\nabla_\mu,\nabla_\nu]$$ can lead to confusion --- especially when there is torsion --- as $\nabla_\mu$ is acting on different tensor spaces when it is to right than when it is to the left. Thus, strictly, $[\nabla_\mu,\nabla_\nu]$ is not a commutator of operators.
That is why the curvature is defined as $$[\nabla_U,\nabla_V] W -\nabla_{[U,V]} W= R(U,V)W$$ rather than as $$[\nabla_\mu,\nabla_\nu] W^\rho = {R^\rho}_{\lambda\mu\nu}W^\lambda.$$ The latter is incorrect (or ambiguous) when there is torsion, whereas the first def holds with or without torsion.
Fo example, with a torsion-free connection, so $\nabla_UV-\nabla_VU= [U,V]$, we can obtain the curvature from $$(\nabla^2_{U,V} - \nabla^2_{V,U}) W =[\nabla_U,\nabla_V] W -(\nabla_{\nabla_UV}- \nabla_{\nabla_VU})W\nonumber\\ = [\nabla_U,\nabla_V] W -\nabla_{[U,V]} W= R(U,V)W.\nonumber$$ We have used that $\nabla_X$ is linear in $X$.