get_max_dist function

Get the maximum distance