Solution (source code)

= Solution

An <affine connection> on $M$ is an operation $(Y,X)\mapsto\nabla_YX$ on smooth <vector fields> that is real-bilinear, linear over $C^\infty(M)$ in the differentiating field, and satisfies
$$
\nabla_{hY}X=h\nabla_YX,\qquad
\nabla_Y(hX)=Y(h)X+h\nabla_YX.
$$
It is a <connection on a vector bundle> for the bundle $TM$, also called a linear connection on the manifold. Its <curvature form of a connection> has the operator form
$$
\boxed{R(Y,Z)X=\nabla_Y\nabla_ZX-\nabla_Z\nabla_YX-\nabla_{[Y,Z]}X.}
$$
This convention fixes its sign. Expanding the two connection product rules shows that the extra derivatives of a scalar cancel, so $R$ is linear over <smooth functions> in all three fields. For a <Levi-Civita connection>, this is the <Riemann curvature tensor>.

The <torsion form> is $T(Y,Z)=\nabla_YZ-\nabla_ZY-[Y,Z]$. For a <Riemannian metric> $g$, its <Levi-Civita connection> is the unique <torsion-free connection> satisfying <metric compatibility>
$$
Y(g(X,Z))=g(\nabla_YX,Z)+g(X,\nabla_YZ).
$$
Existence and uniqueness follow from the <Koszul formula>. In coordinates its coefficients are
$$
\boxed{\Gamma^a{}_{bc}=\tfrac12g^{ad}(\partial_bg_{cd}+\partial_cg_{bd}-\partial_dg_{bc}).}
$$
Symmetry in $b,c$ gives zero torsion, and substitution verifies metric compatibility.