Let $(M^n,g)$ be a smooth Riemannian manifold. Consider the square of the distance function
$$dist^2\colon M\times M\to \mathbb{R}$$
given by $(x,y)\mapsto dist^2(x,y)$. It is easy to see that this function is infinitely smooth near the diagonal.


Now fix a point $a\in M$. **Consider the Taylor series of $dist^2$ at $(a,a)$ in some coordinate system (say normal). Can one compute explicitly its coefficients up to the third order?**



Square of the distance function on a Riemannian manifold
Fix a point $x\_0 \in M$. Then let $x = \exp\_{x\_0}(t v)$ and $y=\exp\_{x\_0}(t w)$, with $v,w \in T\_{x\_0}M$.


Then we have the following formula for the distance squared between two geodesic emanating from $x\_0$


$$ d^2(\exp\_{x\_0}(t v),\exp\_{x\_0}(t w)) = |v-w|^2t^2-\frac{1}{3}R(v,w,w,v) t^4 + O(t^5)$$


whre $R$ is the Riemann curvature tensor. From here you can derive an expression where you follow the two geodesics for different times (just rescale $w \to s/t w$), that is


$$ d^2(\exp\_{x\_0}(t v),\exp\_{x\_0}(s w)) = |v|^2t^2 +|w|s^2 -2 g(v,w) ts -\frac{1}{3}R(v,w,w,v) s^2 t^2 + O(|t^2+s^2|^{5/2})$$


Take now $|v| = |w|=1$, then $(t,v)$ and $(s,w)$ (both $\in [0,\epsilon) \times \mathbb{S}\_{x\_0}^{n-1}$) are polar coordinates of $x,y$. More explicitly, setting $t = d(x\_0,x)$ and $s = d(x\_0,y)$, you have


$$ d^2(x,y) = t^2 + s^2 - 2\cos\theta t s - \tfrac{1}{3} K\_\sigma (1-\cos\theta^2)t^2 s^2 + O(|t^2+s^2|^{5/2})$$


where $\cos\theta = g(v,w)$ is the angle between the two vectors and $K\_\sigma$ is the sectional curvature of the plane $\sigma = \mathrm{span}(v,w)$.


As you can see, this can be used effectively as a purely metric definition of sectional curvature, with no connection or covariant derivative whatsoever.


