# What is the shortest path between two points on Earth's surface?

Two points $A$ and $B$ on the surface of the Earth have the following latitude and longitude co-ordinates:

A: $30^\circ$ N , $45^\circ$ E

B: $30^\circ$ N , $135^\circ$ W

If $R$ is the radius of the Earth, what is the length of the shortest path from $A$ and $B$?

• This question was in "general aptitude" section. Is there is a simple way to calculate? I am wondering how a "maths student" can answer this question? – Learner Feb 10 '16 at 14:14
• It was asked before here....: stackoverflow.com/questions/365826/… Edit: Besides the obvious answer that the shortest distance is a straight line. :) (couldn't resist) – user5445 Feb 10 '16 at 16:30
• You could transform the locations to spherical coordinates, then solve for the distance. – haresfur Feb 11 '16 at 2:12

If you don't want to do the calculation yourself, you can use an online calculator like the one provided by NOAA.

Alternatively, if you do want to do the calculation yourself you can use the haversine formula.

This uses the ‘haversine’ formula to calculate the great-circle distance between two points – that is, the shortest distance over the earth’s surface – giving an ‘as-the-crow-flies’ distance between the points (ignoring any hills they fly over, of course!).

$$a = \sin^2\left(\frac{\Delta\phi}{2}\right) + \cos \phi_1 ⋅ \cos \phi_2 ⋅ \sin^2\left(\frac{\Delta\lambda}{2}\right)$$

$$c = 2 ⋅ \text{atan2}( \sqrt a, \sqrt {1−a} )$$

$$d = R ⋅ c$$

where $\phi$ is latitude, $\lambda$ is longitude, $R$ is earth’s radius (mean radius = 6,371km)

• This also ignores the earth's obliquity, right? For example, if you wanted to get from 0°E to 180°E on the equator, it would be shorter to go via the poles than via the equator, but this algorithm wouldn't tell you that. – naught101 Feb 11 '16 at 0:24
• @naught101 Yes, you're correct. The haversine formula treats the earth as a sphere, not an ellipsoid. – mkennedy Feb 11 '16 at 18:50

45E is directly opposite 135W. It's therefore obvious (hopefully) that the shortest path is straight over the North pole (which is at 90 degrees North). The path takes us round 120 degrees of the Earth's circumference, or 1/3rd of it.

• Nice. Not a general solution but probably why it was asked using those locations. – haresfur Feb 11 '16 at 2:13