TITLE: Square of the distance function on a Riemannian manifold
QUESTION [16 upvotes]: 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?

REPLY [10 votes]: The function $dist^2$ satisfies   a Hamilton-Jacobi equation. Using this  you can  find its Taylor expansion  at $(a,a)$ up to any order. In Appendix A of this paper I  use this approach  to find  the degree 4 Taylor expansion  of this function; see Eq. (A.17) in the paper. The procedure  used in this appendix can be used to find the degree $6$ expansion as well, though the formulas become increasingly more complicated.  I should mention that this approach is also used in
B. DeWitt: The Global Approach to Quantum Field Theory, Oxford University Press, 2003,
pages 281-282, though the physicists' notation may be a bit hard to follow.