Formula: Haversine Distance Mathematical Identity
- lat1: Lat1 (deg)
- lon1: Lon1 (deg)
- lat2: Lat2 (deg)
- lon2: Lon2 (deg)
Apply the spherical Haversine formula across WGS-84 mean Earth radius (6,371 km).
It is the mean radius, a single value that best represents the slightly flattened Earth as a sphere. The equatorial radius is larger and the polar radius smaller, so using either would bias distances in one direction. With the mean value, the default New York to London route comes out at 5570.23 km, well within half a percent of the ellipsoidal answer.
No. It is the shortest possible surface path, the theoretical minimum. Real flights follow airways, avoid restricted airspace and use winds, so they cover more ground. Published flight distances usually quote the great-circle figure, though, so 3461.179 statute miles for New York to London will match many airline listings closely.
It is the angle between the two points as seen from the Earth's centre, 50.094 degrees in the default. It does not depend on the radius, so it is the quantity to keep if you want to rescale to another sphere. It also converts directly to nautical miles: multiply the degrees by 60 for a close approximation.
It gives the same result for most distances, but it loses precision when two points are very close, because the cosine of a tiny angle is almost exactly 1 and rounding swamps the difference. The haversine form avoids that problem, which is why it became the standard for short distances in navigation and software.
The formula stays numerically stable at short range, so it will return a sensible small number. The limit is your input precision: four decimal places of latitude resolve to about 11 metres, and the sphere itself can be off by a fraction of a percent. For site-level work, a projected local coordinate system is more practical.
At 61 degrees the starting point is north of London, and the longitude gap matters less because meridians are closer together at high latitudes. The arc drops to 39.795 degrees and the distance to 4,424.948 km. Moving toward the pole compresses east-west separation, which the cosine terms in the formula capture.
Divide minutes by 60, divide seconds by 60 twice, then add both to the whole degrees. Apply a minus sign for south or west. For example, 0 degrees 7 minutes 40 seconds west becomes about minus 0.1278, which is the London longitude in the default.
Not the distance. Swapping the points returns the same 5570.23 km and the same 50.094 degree arc. Direction does change: the initial bearing from New York is about 51 degrees, while the bearing from London back toward New York points roughly west-northwest, because the heading turns along the great circle.
Exactly opposite points, called antipodes, have a central angle of a half turn and a distance of half the Earth's circumference, about twenty thousand kilometres on this sphere. In that case every great circle through both points is equally short, so there is no unique route or initial bearing, even though the distance is well defined.
The nautical mile is defined as exactly 1.852 km, while one minute of arc on a sphere of radius 6,371 km is about 1.853 km. The tiny difference means 3007.684 nautical miles is a little more than 50.094 times 60. The gap is far smaller than the error from treating the Earth as a sphere.
It shrinks with the cosine of the latitude. On the equator one degree of longitude is 60.041 nautical miles in this calculator. At 60 degrees north, where the cosine is one half, the same one-degree step returns 30.02 nautical miles. That is why the formula multiplies the longitude term by the cosines of both latitudes.
The calculator fixes R at 6,371 km, so it always assumes Earth. You can still use the central subtended angle, which does not depend on radius. Convert that angle to radians and multiply by the radius of any other sphere. For the default coordinates, 50.094 degrees is about 0.8743 radians, which scales directly to whatever body you choose.
The preset coordinates are central New York, at 40.7128 north and 74.006 west, and central London, at 51.5074 north and 0.1278 west. West longitudes are entered as negative numbers, so the second value in each pair is minus 74.006 and minus 0.1278.
Between them the calculator finds a great-circle distance of 5570.23 km. The same path is 3461.179 statute miles and 3007.684 nautical miles. The fourth line, the central subtended angle, is 50.094 degrees.
That angle is the arc between the two points measured from the centre of the Earth. It is the core result; everything else is that angle converted to a length. Turn 50.094 degrees into radians, about 0.8743, multiply by the radius of 6,371 km, and you get back the 5570.23 figure.
The kilometre distance is the shortest path along the surface of a sphere. It is not the distance a plane flies, which adds departure and arrival routing, winds and airspace detours. But it is the right starting point for fuel estimates, flight time ballparks and any comparison of how far apart two places really are.
The page shows the formula in its standard form. With the default coordinates converted to radians, it runs in four steps.
First, take the differences. The latitude change is 51.5074 minus 40.7128, about 10.79 degrees. The longitude change is minus 0.1278 minus minus 74.006, about 73.88 degrees.
Second, compute a, the haversine of the central angle. It is the square of the sine of half the latitude change, plus the cosines of both latitudes multiplied by the square of the sine of half the longitude change. The cosine terms shrink the longitude part, because lines of longitude converge toward the poles.
Third, recover the angle with c = 2 atan2(square root of a, square root of 1 minus a). This form is used instead of a plain inverse sine because it stays accurate for points that are very close together or nearly opposite each other.
Fourth, multiply c by R. With R of 6,371 km the default returns 5570.23 km. Changing R is the only way to scale the answer, so a planet or a different Earth radius would simply rescale every distance in proportion.
The calculator reports distance only, but the direction of travel along the great circle is often the next question, and it can be found from the same coordinates.
The initial bearing from New York toward London is about 51.2 degrees, roughly northeast. The formula is atan2(sin of the longitude change times cos of the destination latitude, cos of the start latitude times sin of the destination latitude minus sin of the start latitude times cos of the destination latitude times cos of the longitude change).
Going the other way, the initial bearing from London toward New York is about 18 degrees north of due west. The two bearings are not opposites. On a great circle the heading changes continuously along the route, so a flight that leaves New York heading northeast arrives over London heading closer to east-southeast.
That changing heading is why great-circle routes look curved on flat maps. The path from New York to London bows north toward Newfoundland and Ireland, even though London is at a higher latitude only by about 11 degrees. The curve is the straight line; the map is what bends it.
The page's scenarios change only the first latitude and leave London fixed. They show how strongly the starting latitude drives the answer.
Moving the start south to 24 degrees, around the latitude of the Bahamas, raises the distance to 6,845.171 km, or 4,253.391 statute miles. The central angle grows to 61.56 degrees.
Moving it north to 61 degrees, on the same meridian, cuts the distance to 4,424.948 km and 2,749.535 miles, with a central angle of 39.795 degrees. That point is north of London, so the route no longer has to climb in latitude at all.
The asymmetry is worth noticing. Moving 16.7 degrees south adds close to thirteen hundred kilometres, while moving 20.3 degrees north removes a little over eleven hundred. The relationship is not linear, because the east-west part of the separation shrinks as both points move toward the pole.
Flipping the sign of a longitude is a common slip and a good test of input care. Enter 74.006 instead of minus 74.006 and the start point moves to Central Asia; the distance changes by only about 17 km, which makes the mistake easy to miss.
The page describes the radius as the WGS-84 mean Earth radius of 6,371 km. The calculation itself, though, treats the Earth as a perfect sphere. WGS-84 is an ellipsoid, slightly flattened at the poles, and the true shortest path on it is a geodesic rather than a circle.
On a sphere the error of the haversine distance compared with the ellipsoid is usually a few tenths of a percent and stays under about half a percent. For the default route, half a percent is roughly 28 km. That is negligible for a travel estimate and too much for surveying.
The sphere is more accurate for some routes than others. Paths running mostly north-south are affected more by the flattening than paths running mostly east-west near the equator.
If you need metre-level accuracy, for a boundary, a cable route or a legal distance, use an ellipsoidal method such as Vincenty or Karney's geodesic algorithm. For travel planning, rough fuel, radio range and nearest-store lookups, the sphere at 6,371 km is the standard choice and is what most mapping code uses for quick distance estimates.
The three distance lines are the same arc in different units. The miles figure divides the kilometres by 1.609344. The nautical miles figure divides by 1.852, the internationally defined length of a nautical mile.
A nautical mile was originally one minute of arc along a meridian. On this calculator's sphere, one minute of arc is 6,371 km times pi divided by ten thousand eight hundred, about 1.853 km, very close to 1.852. That is why the default's 3007.684 nautical miles is almost exactly the central angle of 50.094 degrees multiplied by 60.
The small gap between the two is the difference between the defined nautical mile and the arc length on a sphere of radius 6,371 km. It is under a tenth of a percent.
Pilots and ship navigators use nautical miles because they map so neatly onto angles. One degree of latitude is roughly 60 nautical miles anywhere on Earth, which the calculator confirms: a one-degree step along the equator or along a meridian returns 60.041 nautical miles.
Coordinates must be decimal degrees. A position written as 40 degrees 42 minutes 46 seconds needs converting first: divide the minutes by 60, divide the seconds by 60 and then by 60 again, and add both to the degrees. Typing 40.4246 instead of 40.7128 puts the point about 32 km too far south.
South latitudes and west longitudes are negative. Many copied coordinates use N, S, E or W letters instead of signs, and dropping the letter flips the point to the wrong hemisphere.
Latitude must stay between minus 90 and 90, and longitude between minus and plus a half turn of the globe. The engine rejects anything outside those ranges, so a latitude of 91 returns a request to check the inputs. A common cause is pasting latitude and longitude into each other's boxes; New York's minus 74.006 is a valid longitude but an impossible latitude.
Longitudes on either side of the antimeridian work correctly. Two points on the equator, one degree either side of it, come back as a two-degree arc, twice the 60.041 nautical miles of a single degree, not as most of the way around the world.
Order does not matter. Swapping the two points returns the same 5570.23 km, since distance is symmetric even though bearing is not.
Precision is the last thing to check. Four decimal places, as in the defaults, locate a point to about 11 metres. Two decimal places only locate it to about a kilometre, which is fine for city-to-city distances but not for anything at street scale.
A great-circle distance is a lower bound on any real journey between two points. Road and rail distances are longer, often by a fifth or more, because they follow terrain and networks. Air routes are longer than the great circle by tens to hundreds of kilometres depending on airways and wind.
Elevation is ignored. Both points are treated as sitting on the surface of a sphere of radius 6,371 km, so the height of a mountain or an aircraft has no effect. For an aircraft at cruising altitude the extra distance is tiny compared with the route.
The calculator also gives one segment only. A multi-leg route needs each leg computed separately and added. Remember that summing legs through intermediate waypoints will always give at least the direct distance, and usually more.
For radio, line-of-sight and visibility problems, the arc length is only part of the answer. Those depend on the curvature drop between the points, which grows quickly with distance, and on antenna or observer height.