Differentiability of Functions of Distances