This page is essentially an annotated transcription of this post by Stathis Kamperis, including Mathematica code, also reflected in here.
This is the derivation of the Christoffel symbols for spherical coordinates.
Given the metric tensor of the sphere
\[\begin{pmatrix} g_{\theta \theta} & g_{\theta \phi} \\ g_{\phi \theta} & g_{\phi \phi} \end{pmatrix}= \begin{pmatrix} R^2 & 0 \\ 0 & R^2\sin^2\theta \end{pmatrix}\]
with the inverse
\[\begin{pmatrix} g^{\theta \theta} & g^{\theta \phi} \\ g^{\phi \theta} & g^{\phi \phi} \end{pmatrix}= \begin{pmatrix} \frac 1{R^2} & 0 \\ 0 & \frac{\csc^2\theta}{R^2} \end{pmatrix}\]
and the Christoffel symbols
\[\Gamma_{\mu\nu}^\theta = \left( \begin{array}{cc} 0 & 0 \\ 0 & -\sin \theta \cos \theta \\ \end{array} \right)\qquad \Gamma_{\mu\nu}^\phi = \left( \begin{array}{cc} 0 & \cot \theta \\ \cot \theta & 0 \\ \end{array} \right)\]
calculated via
\[\Gamma_{\mu\nu}^\lambda = \frac{1}{2}g^{\lambda\sigma} \left( \frac{\partial g_{\sigma\nu}}{\partial x^\mu} + \frac{\partial g_{\sigma\mu}}{\partial x^\nu} - \frac{\partial g_{\mu\nu}}{\partial x^\sigma}\right)= \frac{1}{2}g^{\lambda\sigma} \left( \partial_\mu g_{\sigma\nu} + \partial_\nu g_{\sigma\mu} - \partial_\sigma g_{\mu\nu}\right)\]
This teddy bear of an equation is directly derived from the fact that we are using the Levy-Civita connection, which is torsion-free, and metric compatible. What follows is explained in here:
Torsion-free implies that the Lie bracket of the basis vectors is zero because the vectors are partial derivative operators, which are the same in both directions. Hence,
\[[\partial_i, \partial_j]= \partial_i \partial_j - \partial_j\partial_i = \frac{\partial^2}{\partial u^i \partial u^j} - \frac{\partial^2}{\partial u^j \partial u^i} = 0\] But then the difference in covariant derivatives
\[\nabla_{\vec w} \vec v - \nabla_{\vec v} \vec w=[\vec v, \vec w]=0 \]
And hence,
\[\nabla_{\vec e_i} \vec e_j =\nabla_{\vec e_j} \vec e_i \]
and since \(\nabla_{\vec e_i} \vec e_j= \Gamma^k_{~ij} \vec e_k\) and \(\nabla_{\vec e_j} \vec e_i= \Gamma^k_{~ji} \vec e_k\),
\[\Gamma^k_{~ij} \vec e_k = \Gamma^k_{~ji} \vec e_k\]
In other words we can swap the lower indices of the Christoffel symbols.
On the other hand, the metric compatibility property implies that
\[\nabla_{\vec w}(\vec v \cdot\vec u)= \nabla_{\vec w} \cdot \vec u + \vec v \cdot (\nabla_{\vec w}\cdot \vec u)\]
which means that the dot product stays the same when vectors are transported, and, therefore, also angles and lengths (just consider a vector with itself). This is true since in parallel transport the covariant derivative is zero \(\nabla_{\vec w} \vec v = \nabla_{\vec w}\vec u=\vec 0,\) the equation above is simplified to $_{w}(v u)=$ constant dot product. Also, since the dot product is a scalar, \(\nabla_{\partial_i}(\vec v \cdot \vec u)=\partial_i(\vec v \cdot \vec u)=0.\)
Looking at the basis vectors,
\[\begin{align} \nabla_{\vec e_k}(\vec e_i \cdot \vec e_j) &= (\nabla_{\vec e_k} \vec e_i ) \cdot \vec e_j + \vec e_i \cdot (\nabla_{\vec e_k} \vec e_j) \\ \partial_k(\vec e_i \cdot \vec e_j) &=(\Gamma^l_{~ik} \vec e_l) \cdot \vec e_j + \vec e_i\cdot(\Gamma^l_{~jk}\vec e_l)\\ \partial_k(g_{ij}) &= \Gamma^l_{~ik}g_{jl} + \Gamma^l_{~jk}g_{il} \end{align}\]
Following this equality we can permute the indices as in:
\[\begin{align} \partial_k(g_{ij}) &= \Gamma^l_{~ik}g_{jl} + \Gamma^l_{~jk}g_{il}\\ \partial_j(g_{ki}) &= \Gamma^l_{~kj}g_{il} + \Gamma^l_{~ij}g_{kl}\\ \partial_i(g_{jk}) &= \Gamma^l_{~ji}g_{kl} + \Gamma^l_{~ki}g_{jl} \end{align}\]
Taking into account the fact that swapping the lower indices of the Christoffel symbols does not alter them, we can perform the following operation
\[\partial_k g_{ij}+ \partial_j g_{ki}- \partial_i g_{jk}\] and see a lot of cancellations, resulting in
\[\partial_k g_{ij}+ \partial_j g_{ki}- \partial_i g_{jk} = 2\Gamma^l_{jk}g_{il}\] or
\[\Gamma^m{}_{jk}=\frac 1 2 g^{\color{red}im}(\partial_k g_{\color{red}ij}+ \partial_j g_{k\color{red}i }- \partial_\color{red}i g_{jk})\]
Notice the implied summation for each Christoffel symbol in the dummy index \(i\) (sometimes labelled \(\sigma\)):
\[\Gamma^\lambda{}_{\mu\nu}= \frac 1 2 g^{\color{red}\sigma\lambda}(\partial_\nu \, g_{\color{red}\sigma \mu} + \partial_\mu \, g_{\nu\color{red}\sigma } - \partial_\color{red}\sigma\,g_{\mu\nu})\]
\(\mu\) is the basis vector being parallel transported
\(\nu\) is the direction in which the basis vector is being transported.
\(\lambda\) indicates the component of the transported vector in the new basis.
\(\sigma\) is summed over and it is there to capture the contributions from different directions in the coordinate space.
So for instance, in the sphere, and for \(\lambda=1=\theta, \mu=2=\phi,\nu=2=\phi\)
\[\begin{align}\Gamma^{\theta}_{\mu\nu}=\Gamma^{\theta}_{\phi\phi}=\Gamma^1{}_{22}&=\frac 1 2\sum_{σ=1}^n g^{λσ} (∂_μ g_{σν} + ∂_ν g_{σμ} - ∂_σ g_{μν})\\ &=\frac 1 2 \left(g^{λ\theta} \left( ∂_μ g_{\theta ν} + ∂_ν g_{\theta μ} - ∂_\theta g_{μν}\right) + g^{λ\phi} \left( ∂_μ g_{\phi ν} + ∂_ν g_{\phi μ} - ∂_\phi g_{μν}\right)\right)\\ &=\frac 1 2 \left(g^{\theta\theta} \left( ∂_\phi g_{\theta \phi} + ∂_\phi g_{\theta \phi} - ∂_\theta g_{\phi\phi}\right) + g^{\theta\phi} \left( ∂_\phi g_{\phi \phi} + ∂_\phi g_{\phi \phi} - ∂_\phi g_{\phi\phi}\right)\right)\\ &=\frac 1 2 \left(\frac{1}{r^2}(0+0-2r^2\sin\theta\cos\theta) + 0(0+0-0) \right)\\ &=-\sin\theta\cos\theta \end{align}\]
For \(\lambda=2=\phi, \mu=1=\theta,\nu=2=\phi\)
\[\begin{align}\Gamma^{\phi}_{\mu\nu}=\Gamma^{\phi}_{\theta\phi}=\Gamma^2{}_{12}&=\frac 1 2\sum_{σ=1}^n g^{λσ} (∂_μ g_{σν} + ∂_ν g_{σμ} - ∂_σ g_{μν})\\ &=\frac 1 2 \left(g^{λ\theta} \left( ∂_μ g_{\theta ν} + ∂_ν g_{\theta μ} - ∂_\theta g_{μν}\right) + g^{λ\phi} \left( ∂_μ g_{\phi ν} + ∂_ν g_{\phi μ} - ∂_\phi g_{μν}\right)\right)\\ &=\frac 1 2 \left(g^{\phi\theta} \left( ∂_\theta g_{\theta \phi} + ∂_\phi g_{\theta \theta} - ∂_\theta g_{\theta\phi}\right) + g^{\phi\phi} \left( ∂_\theta g_{\phi \phi} + ∂_\phi g_{\phi \theta} - ∂_\phi g_{\theta\phi}\right)\right)\\ &=\frac 1 2 \left( \frac{\csc^2\theta}{R^2}\left(2R^2\sin\theta\cos\theta+0-0\right) \right)\\ &=\cot\theta \end{align}\]
ChristoffelSymbol[111]=0
Indices:θ/φ=1,μ=1,ν=1
ChristoffelSymbol[112]=0
Indices:θ/φ=1,μ=1,ν=2
ChristoffelSymbol[121]=0
Indices:θ/φ=1,μ=2,ν=1
ChristoffelSymbol[122]=-Cos[θ]Sin[θ]
Indices:θ/φ=1,μ=2,ν=2
ChristoffelSymbol[211]=0
Indices:θ/φ=2,μ=1,ν=1
ChristoffelSymbol[212]=Cot[θ]
Indices:θ/φ=2,μ=1,ν=2
ChristoffelSymbol[221]=Cot[θ]
Indices:θ/φ=2,μ=2,ν=1
ChristoffelSymbol[222]=0
Indices:θ/φ=2,μ=2,ν=2
the Riemann curvature tensor components can be calculated as
\[R^i_{~rkj}= \frac{\partial\Gamma^i_{~jr}}{\partial u^k} -\frac{\partial\Gamma^i_{~kr}}{\partial u^j} +\Gamma^i_{~ks}\Gamma^s_{~jr} -\Gamma^i_{~js}\Gamma^s_{~kr} \]
Notice the implied summation, so that
\[R^\rho{}_{\sigma\mu\nu}= \partial_\mu\Gamma^\rho{}_{\nu\sigma} -\partial_\nu\Gamma^\rho_{\mu\sigma} +\Gamma^\rho{}_{\mu\lambda}\Gamma^\lambda{}_{~\nu\sigma} -\Gamma^\rho{}_{\nu\lambda}\Gamma^\lambda{}_{\mu\sigma}\\=\partial_\mu\Gamma^\rho{}_{\nu\sigma} -\partial_\nu\Gamma^\rho_{\mu\sigma} +\sum_{\lambda=1}^2 \left(\Gamma^\rho{}_{\mu\lambda}\Gamma^\lambda{}_{~\nu\sigma} -\Gamma^\rho{}_{\nu\lambda}\Gamma^\lambda{}_{\mu\sigma} \right)\]
Example:
\[R^\theta{}_{\phi\theta\phi}=\partial_\theta\Gamma^{\theta}{}_{\phi\phi}-\partial_\phi \Gamma^\theta{}_{\theta\phi}+\sum_{\lambda=1}^2\left(\Gamma^\theta{}_{\theta\lambda}\Gamma^\lambda_{\phi\phi} - \Gamma^\theta{}_{\phi\lambda}\Gamma^\lambda_{\theta\phi}\right)=\sin^2\theta\]
The rest of the Riemann tensor coefficients are:
\[R = \left( \begin{array}{cc} \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & \sin^2 \theta \\ -\sin^2 \theta & 0 \\ \end{array} \right) \\ \left( \begin{array}{cc} 0 & -1 \\ 1 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) \\ \end{array} \right)\]
which corresponds to
\[R =\left( \begin{array}{cc} \left( \begin{array}{cc} R^\theta{}_{\theta\theta\theta} & R^\theta{}_{\theta\theta\phi} \\ R^\theta{}_{\theta\phi\theta} & R^\theta{}_{\theta\phi\phi} \\ \end{array} \right) & \left( \begin{array}{cc} R^\theta{}_{\phi\theta\theta} & \ R^\theta{}_{\phi\theta\phi} \\ R^\theta{}_{\phi\phi\theta} & R^\theta{}_{\phi\phi\phi} \\ \end{array} \right) \\ \left( \begin{array}{cc} R^\phi{}_{\theta\theta\theta} & R^\phi{}_{\theta\theta\phi}\\ R^\phi{}_{\theta\phi\theta} & R^\phi{}_{\theta\phi\phi} \\ \end{array} \right) & \left( \begin{array}{cc} R^\phi{}_{\phi\theta\theta} & R^\phi{}_{\phi\theta\phi}\\ R^\phi{}_{\phi\phi\theta}& R^\phi{}_{\phi\phi\phi} \\ \end{array} \right) \\ \end{array} \right)\]
References online here and here, and the code for the Riemann curvature tensor, the Ricci tensor and the curvature is here.
This post contains the code of the main functions.
The metric tensor is
\[g_{mn} = \begin{pmatrix} -(1-2M/r) & 0 & 0 & 0 \\ 0 & (1-2M/r)^{-1} & 0 & 0 \\ 0 & 0 & r^2 & 0 \\ 0 & 0 & 0 & r^2\sin^2{\theta} \end{pmatrix}\]
The Christoffel symbols are calculated as
ChristoffelSymbol[g_, xx_] :=
Block[{n, ig, res},
n = 4;
ig = InverseMetric[g];
res = Table[
(1/2) Sum[ig[[\[Lambda], \[Sigma]]]*
(*\[Sigma] is the summation dummy variable.
\[Lambda] indicates the component of the transported vector
in the new basis.*)
(-D[g[[\[Mu], \[Nu]]], xx[[\[Sigma]]]] +
D[g[[\[Sigma], \[Nu]]], xx[[\[Mu]]]] +
D[g[[\[Sigma], \[Mu]]], xx[[\[Nu]]]]),
{\[Sigma], 1, n}],
{\[Lambda], 1, n}, {\[Mu], 1, n}, {\[Nu], 1, n}];
Simplify[res]]
(* Compute Christoffel symbols *)
christoffelSymbols = ChristoffelSymbol[gmn, {t, r,\[Theta],\[Phi]}];
MatrixForm[christoffelSymbols]
yielding
\[\begin{pmatrix} \begin{pmatrix} \Gamma^t{}_{tt}=0\\ \Gamma^t{}_{tr}=-\frac M{2Mr-r^2}\\ \Gamma^t{}_{t\theta}=0\\ \Gamma^t{}_{t\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^t{}_{rt}=-\frac M{2Mr-r^2}\\ \Gamma^t{}_{rr}=0\\ \Gamma^t{}_{r\theta}\\ \Gamma^t{}_{r\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^t{}_{\theta t}=0\\ \Gamma^t{}_{\theta r}=0\\ \Gamma^t{}_{\theta \theta}\\ \Gamma^t{}_{\theta\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^t{}_{\phi t}=0\\ \Gamma^t{}_{\phi r}=0\\ \Gamma^t{}_{\phi\theta}\\ \Gamma^t{}_{\phi\phi}=0 \end{pmatrix} \\ \begin{pmatrix} \Gamma^r{}_{tt}=\frac{M(-2M+r)}{r^3}\\ \Gamma^r{}_{tr}=0\\ \Gamma^r{}_{t\theta}\\ \Gamma^r{}_{t\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^r{}_{rt}=0\\ \Gamma^r{}_{rr}=\frac{M}{2Mr-r^2}\\ \Gamma^r{}_{r\theta}=0\\ \Gamma^r{}_{r\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^r{}_{\theta t}=0\\ \Gamma^r{}_{\theta r}=0\\ \Gamma^r{}_{\theta \theta}=2M - r\\ \Gamma^r{}_{\theta\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^r{}_{\phi t}=0\\ \Gamma^r{}_{\phi r}=0\\ \Gamma^r{}_{\phi\theta}=0\\ \Gamma^r{}_{\phi\phi} = (2M - r)\sin^2\theta \end{pmatrix} \\ \begin{pmatrix} \Gamma^\theta{}_{tt}=0\\ \Gamma^\theta{}_{tr}=0\\ \Gamma^\theta{}_{t\theta}=0\\ \Gamma^\theta{}_{t\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^\theta{}_{rt}=0\\ \Gamma^\theta{}_{rr}=0\\ \Gamma^\theta{}_{r\theta}=1/r\\ \Gamma^\theta{}_{r\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^\theta{}_{\theta t}=0\\ \Gamma^\theta{}_{\theta r}=1/r\\ \Gamma^\theta{}_{\theta \theta}=0\\ \Gamma^\theta{}_{\theta\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^\theta{}_{\phi t}=0\\ \Gamma^\theta{}_{\phi r}=0\\ \Gamma^\theta{}_{\phi\theta}=0\\ \Gamma^\theta{}_{\phi\phi}=-\cos\theta\sin\theta \end{pmatrix} \\ \begin{pmatrix} \Gamma^\phi{}_{tt}=0\\ \Gamma^\phi{}_{tr}=0\\ \Gamma^\phi{}_{t\theta}=0\\ \Gamma^\phi{}_{t\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^\phi{}_{rt}=0\\ \Gamma^\phi{}_{rr}=0\\ \Gamma^\phi{}_{r\theta}=0\\ \Gamma^\phi{}_{r\phi}=1/r \end{pmatrix} & \begin{pmatrix} \Gamma^\phi{}_{\theta t}=0\\ \Gamma^\phi{}_{\theta r}=0\\ \Gamma^\phi{}_{\theta \theta}=\cot\theta\\ \Gamma^\phi{}_{\theta\phi}=0 \end{pmatrix} & \begin{pmatrix} \Gamma^\phi{}_{\phi t}=0\\ \Gamma^\phi{}_{\phi r}=1/r\\ \Gamma^\phi{}_{\phi\theta}=\cot\theta\\ \Gamma^\phi{}_{\phi\phi}=0 \end{pmatrix} \end{pmatrix}\]
The following are the unique values:
\[\begin{equation} \begin{matrix} \Gamma^r_{tt}=\dfrac{M(r-2M)}{r^3}\,\text{,} & ~ & \Gamma^r_{rr}=-\dfrac{M}{r(r-2M)}\,\text{,} & ~ & \Gamma^r_{\theta \theta}=-(r-2M)\,\text{,}\\ ~ & ~ & ~ & ~ & ~\\ \Gamma^r_{\phi \phi}=-(r-2M)\sin^2{\theta}\,\text{,} & ~ & \Gamma^t_{rt} = \dfrac{M}{r(r-2M)}\,\text{,} & ~ & \Gamma^\theta_{r\theta}=\dfrac{1}{r}\,\text{,}\\ ~ & ~ & ~ & ~ & ~\\ \Gamma^\theta_{\phi\phi}=-\sin{\theta}\cos{\theta}\,\text{,} & ~ & \Gamma^\phi_{r\phi}=\dfrac{1}{r}\,\text{,} & ~ & \Gamma^\phi_{\theta\phi} = \dfrac{\cos{\theta}}{\sin{\theta}}\,\text{.}\\ ~ & ~ & \end{matrix} \end{equation}\]
NOTE: These are tentative notes on different topics for personal use - expect mistakes and misunderstandings.