The haversine formula solves a problem that seems like it should be trivial but genuinely isn't: finding the distance between two points when those points sit on the surface of a sphere rather than a flat plane. On a flat plane, distance between two points is straightforward Pythagorean geometry. On a sphere, that same approach breaks down — a 'straight line' on a curved surface isn't actually straight in three-dimensional space, and using flat-plane distance math on latitude/longitude coordinates produces increasingly wrong answers as the distance between points grows, because it ignores the curvature that becomes significant at scale.
The haversine formula gets around this by working with the actual great-circle distance — the shortest path between two points along the surface of a sphere, which is always an arc of the circle formed by slicing through the sphere along a plane that passes through both points and the sphere's center. This is genuinely the shortest possible surface distance between two points on a perfect sphere, which is why long-haul flight paths follow curved-looking routes on a flat map: the curve represents the great-circle path, and it's shorter in real distance than the visually 'straight' line the flat map projection would suggest.
It's worth being precise about what 'great-circle distance' does and doesn't capture. It models Earth as a perfect sphere using a mean radius (6,371 km), which is an excellent approximation for the vast majority of practical purposes — the actual error from treating Earth as a perfect sphere rather than its true, very slightly flattened shape (an oblate spheroid, very slightly wider at the equator than pole-to-pole) is small enough to be irrelevant for navigation, trip planning, or general distance estimation. Only for very high-precision surveying, geodesy, or scientific applications does the distinction between a spherical model and a full ellipsoidal model become meaningful enough to require more sophisticated formulas.
The more consequential limitation for everyday use is that great-circle distance is pure straight-line distance across the surface — it has no awareness of roads, terrain, or any real path a traveler would actually take. This is precisely why it's most useful as either a starting reference point (comparing straight-line distance against actual travel distance to gauge how direct a route is) or for the categories of travel — flights, ocean voyages — where the real path genuinely does approximate a great circle rather than being constrained to follow a winding network of roads.



