Great Circle Distance (Haversine)

Also known as haversine formula · great circle distance · distance between two coordinates · distance between two lat long points · orthodromic distance · spherical distance

d=2Rarcsin⁡sin⁡2φ2−φ12+cos⁡φ1cos⁡φ2sin⁡2λ2−λ12d = 2R\arcsin\sqrt{\sin^{2}\frac{\varphi_2-\varphi_1}{2} + \cos\varphi_1\cos\varphi_2\sin^{2}\frac{\lambda_2-\lambda_1}{2}}

Worked example: One minute of latitude → 1.000676 nautical miles on the mean sphere — press Try an example to run it live, then adjust anything.

Enter your known values, leave one input blank, and solves for the missing one. Tap a variable’s symbol to see what it means, with a typical value. Try different units for next level excitement!

Here the solver did the work — could you?

The great circle →

UniversityApplied Field Engineering

Test your skills in the Exam Room: new numbers every attempt — free lessons for students, no sign-up, just pure learning.

See your Report Card
Compete with your friends
share your results
Learning zone

Great Circle Distance (Haversine) explained

dφ1λ1φ2λ2

Two points on a sphere are joined by exactly one shortest path, and it is the arc of the great circle through them — the circle whose centre is the centre of the earth. Every meridian is a great circle. The equator is a great circle. No other parallel of latitude is, which is the first surprise the subject hands you: the 60th parallel looks like a perfectly good road on a school globe, and following it is not the shortest way anywhere.

The formula on this page is R. W. Sinnott's 1984 restatement of a very old identity, published in Sky & Telescope under the title "Virtues of the Haversine". The haversine itself is just hav⁡θ=sin⁡2(θ/2)\operatorname{hav}\theta = \sin^{2}(\theta/2), and the virtue Sinnott was defending is numerical. The older spherical law of cosines, cos⁡d=sin⁡φ1sin⁡φ2+cos⁡φ1cos⁡φ2cos⁡Δλ\cos d = \sin\varphi_1\sin\varphi_2 + \cos\varphi_1\cos\varphi_2\cos\Delta\lambda, is algebraically correct and quietly useless on short legs: when the two points are close the cosine is within a hair of 1, and a machine carrying seven digits has nothing left to work with. Sinnott's example was a calculator returning zero distance for two points a kilometre apart. The haversine form never forms that difference and holds its precision all the way down.

The radius used here is 6 371 008.8 m, the IUGG mean radius of the WGS-84 ellipsoid. Be honest with yourself about what that costs. The earth is flattened by about one part in 298, and a spherical distance can differ from a true geodesic on the ellipsoid by up to roughly half a percent depending on how the track lies. On a thirty-mile coastal passage that is a couple of hundred metres and it does not matter. On a five-thousand-mile ocean crossing it is twenty-five miles, which is a real fuel figure and a real arrival time. When it matters, the tool is Vincenty's iterative method or a modern geodesic library — not a bigger radius.

The classic mistake here is not in the formula at all; it is in the longitudes going into it. This shard takes east as positive and west as negative, without exception, and a west longitude entered as a positive number is the single most common error in every coordinate calculation ever written. A Halifax longitude is −63.6°, not 63.6°. The second most common is mixing degrees-minutes-seconds with decimal degrees: 40°38'23" is 40.6398°, not 40.3823°, and the two are close enough to look plausible and far enough apart to lose a ship.

Great Circle Distance (Haversine) formula

d=2Rarcsin⁡sin⁡2φ2−φ12+cos⁡φ1cos⁡φ2sin⁡2λ2−λ12d = 2R\arcsin\sqrt{\sin^{2}\frac{\varphi_2-\varphi_1}{2} + \cos\varphi_1\cos\varphi_2\sin^{2}\frac{\lambda_2-\lambda_1}{2}}
Where
  • dd= Great circle distance (nmi)
  • φ1\varphi_1= Latitude of the first point (°)
  • λ1\lambda_1= Longitude of the first point (°)
  • φ2\varphi_2= Latitude of the second point (°)
  • λ2\lambda_2= Longitude of the second point (°)

Missing one of these? Work it out first, then come back