Let $M$ be a Riemannian manifold and
$$f:M\times M \to \mathbb R$$
be a smooth function such that $f(x,y)$ only depends on the distance of $x,y$ in terms of the Riemannian metric $d$. I wonder if we can always find a smooth function $g:\mathbb R^+ \to \mathbb R$ such that $g(d(x,y))=f(x,y)$.
I am inclined to believe that this might be false but I find it hard to produce a counterexample for the case even when $M=\mathbb R$. The distance function is smooth "almost everywhere" for $M=\mathbb R$. A solution for this particular case is also appreciated!