Forgive me if this is
a bit extremely academic in nature, but I was wondering how Salesforce goes about determining the distance between two pairs of latitude and longitude?
When I've looked at this in the past it turned out not to be as straight forward as you might think. See Geographical distance and the second (inverse) geodetic problem. The earth is generally an ellipsoidal shape and there are discontinuities in the coordinate system. It's probably safe to assume changes in elevation aren't being taken into account in distance calculations.
Are they using a great-circle distance formula?
Why might this be important
How far is it from Wellington, New Zealand (41°19'S 174°49'E) to Salamanca, Spain(40°58'N 5°30'W)?
Depending on the model you use could be the difference between 19951 km,
and 19960 km.
Is that 0.04% difference important or even meaningful? Probably not for the majority of applications. Hence the statement at the start of the question that this is purely out of academic interest.
Using a Contact with a Location field set at -41.31666667 174.81666667 (Wellington) and the following SOQL query returned the Contact ID:
select Id from Contact WHERE DISTANCE(Location__c, GEOLOCATION(40.96666667, -5.50000000), 'km') > 19968.0
Increasing the distance to 19968.1 km did not.
Again, an 8 km difference wouldn't usually be considered significant on a ~20,000 km length where elevations are being ignored anyway.