Sine, cosine, and tangent — we do love our trigonometric functions! So imagine our bliss when we recently came across a function we had never even heard of before. It's called the *haversine* and it's defined in terms of the sine function:

The dotted yellow line is an arc of a great circle. It gives the shortest distance between the two yellow points. Image courtesy USGS.

The term "haversine" apparently comes from "half versed sine". To see why this function is useful, put yourself in the shoes of an intrepid traveller setting out on a sea voyage from Liverpool to New York. The first thing you'd want to know is how far you will have to travel. Ignoring islands, rocks, currents and other inconvenient factors, let's say that you will travel along the shortest path between the two cities. We know that the shortest path between two points is along a straight line, but that fact doesn't help you here. The straight line that connects Liverpool and New York cuts right through the Earth and you are not about to dig a tunnel.

You need the shortest path on the surface of the Earth, which is roughly spherical. On a sphere the shortest path between two points is along an arc of a *great circle*: that's a circle drawn on the surface of the sphere which is centred on the same point as the sphere and has the same radius. Any two points lie on a unique great circle, which they divide up into two arcs. The shortest path between the points is along the shorter of these two arcs.

So how do you calculate this *great circle distance* between two points and on the Earth? First, recall that the locations of the two points are given by their latitudes, for which we will write and and their longitudes, which we will denote by and Write for the radius of the Earth, which is roughly km. The great circle distance between and comes from the formula

(1) |

(where the angles are measured in radians).

Solving for gives

(2) |

You’ll admit that this isn’t the simplest of formulae. If you were are a seafarer hundreds of years ago, armed only with sine and cosine tables to help you, working out the distance would prove pretty cumbersome. There’s a square root to take, as well as the inverse of the sine function .... argh!

But now let’s replace any expressions of the form by the haversine function. Expression (1) above becomes

The distance is now

Working out the great circle distance between two points is so important in navigation that people in the old days produced tables giving the values of the haversine function and also of the inverse of the haversine function. This made seafarers’ lives a lot easier. Working out the distance only involved looking up two cosine values and two haversine values, adding and multiplying them in the correct way, looking up the inverse of the haversine function and multiplying by — done!

The reason why the haversine function has come out of fashion is that with the help of calculators and computers it’s easy enough to work out the distance straight from formula (2). That’s why you don’t find a haversine button on your average calculator.

Let’s give it a go. Liverpool has latitude and longitude , and New York has latitude and longitude . These are measured in degrees. Converting them into radians (multiplying by ) gives and for Liverpool, and and for New York (rounded to three decimal places) Plugging these into expression (2), with the radius of the Earth , gives a great circle distance of around 5313 km. Quite a way to go!