There are a number of approaches to solve the inverse geodesic problem, this post provides the IDL code to use Newton’s method as described by Karney (2012) in ‘Algorithms for geodesics‘.
Assuming the Earth is an ellipsoid, finding the shortest path between two points on the ellipsoid is called a geodesic. The inverse geodesic problem finds the shortest path between two points on the ellipsoid, while the direct geodesic problem finds the end point given the starting point, first azimuth and length.
One of the most common approaches to solve the inverse geodesic problem is using Vincenty’s formulae. However, this iterative method can get caught in infinite loops, or can be very slow in a number of cases. Karney’s 2012 paper, ‘Algorithms for geodesics‘ describes how to implement Newton’s Method, which at most takes 16 iterations (typically 2-4), resolves the problem of getting caught in infinite loops and works to a higher degree of accuracy.
Hope you find it useful!