great-circle distance
The great-circle distance, orthodromic distance, or spherical distance is the distance between two points on a sphere, measured along the great-circle arc between them. This arc is the shortest path between the two points on the surface of the ...
between two points on a
sphere
A sphere (from Ancient Greek, Greek , ) is a surface (mathematics), surface analogous to the circle, a curve. In solid geometry, a sphere is the Locus (mathematics), set of points that are all at the same distance from a given point in three ...
given their
longitude
Longitude (, ) is a geographic coordinate that specifies the east- west position of a point on the surface of the Earth, or another celestial body. It is an angular measurement, usually expressed in degrees and denoted by the Greek lett ...
s and
latitude
In geography, latitude is a geographic coordinate system, geographic coordinate that specifies the north-south position of a point on the surface of the Earth or another celestial body. Latitude is given as an angle that ranges from −90° at t ...
s. Important in
navigation
Navigation is a field of study that focuses on the process of monitoring and controlling the motion, movement of a craft or vehicle from one place to another.Bowditch, 2003:799. The field of navigation includes four general categories: land navig ...
, it is a special case of a more general formula in
spherical trigonometry
Spherical trigonometry is the branch of spherical geometry that deals with the metrical relationships between the edge (geometry), sides and angles of spherical triangles, traditionally expressed using trigonometric functions. On the sphere, ge ...
, the law of haversines, that relates the sides and angles of spherical triangles.
The first table of haversines in English was published by James Andrew in 1805, but
Florian Cajori
Florian Cajori (February 28, 1859 – August 14 or 15, 1930) was a Swiss-American historian of mathematics.
Biography
Florian Cajori was born in Zillis, Switzerland, as the son of Georg Cajori and Catherine Camenisch. He attended schools firs ...
credits an earlier use by José de Mendoza y Ríos in 1801. (NB. ISBN and link for reprint of second edition by Cosimo, Inc., New York, 2013.) The term ''
haversine
The versine or versed sine is a trigonometric function found in some of the earliest (Sanskrit ''Aryabhatia'',James Inman
James Inman (1776–1859), an English mathematician and astronomer, was professor of mathematics at the Royal Naval College, Portsmouth, and author of ''Inman's Nautical Tables''.
Early years
Inman was born at Tod Hole in Garsdale, then in th ...
. (Fourth edition )
These names follow from the fact that they are customarily written in terms of the haversine function, given by . The formulas could equally be written in terms of any multiple of the haversine, such as the older
versine
The versine or versed sine is a trigonometric function found in some of the earliest (Sanskrit ''Aryabhatia'',logarithm
In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
s were included in 19th- and early 20th-century navigation and trigonometric texts. These days, the haversine form is also convenient in that it has no coefficient in front of the function.
Formulation
Let the
central angle
A central angle is an angle whose apex (vertex) is the center O of a circle and whose legs (sides) are radii intersecting the circle in two distinct points A and B. Central angles are subtended by an arc between those two points, and the arc l ...
between any two points on a sphere be:
:
where
* is the distance between the two points along a
great circle
In mathematics, a great circle or orthodrome is the circular intersection of a sphere and a plane passing through the sphere's center point.
Discussion
Any arc of a great circle is a geodesic of the sphere, so that great circles in spher ...
of the sphere (see spherical distance),
* is the radius of the sphere.
The ''haversine formula'' allows the
haversine
The versine or versed sine is a trigonometric function found in some of the earliest (Sanskrit ''Aryabhatia'',haversine function , applied above to both the central angle and the differences in latitude and longitude, is
:
The haversine function computes half a
versine
The versine or versed sine is a trigonometric function found in some of the earliest (Sanskrit ''Aryabhatia'',chord of the angle on a unit circle (sphere).
To solve for the distance , apply the archaversine ( inverse haversine) to or use the
arcsine
In mathematics, the inverse trigonometric functions (occasionally also called ''antitrigonometric'', ''cyclometric'', or ''arcus'' functions) are the inverse functions of the trigonometric functions, under suitably restricted domains. Specific ...
(inverse sine) function:
:
or more explicitly:
:
where
.
When using these formulae, one must ensure that does not exceed 1 due to a
floating point
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a signed sequence of a fixed number of digits in some base) multiplied by an integer power of that base.
Numbers of this form ...
error ( is real only for ). only approaches 1 for ''antipodal'' points (on opposite sides of the sphere)—in this region, relatively large numerical errors tend to arise in the formula when finite precision is used. Because is then large (approaching , half the circumference) a small error is often not a major concern in this unusual case (although there are other
great-circle distance
The great-circle distance, orthodromic distance, or spherical distance is the distance between two points on a sphere, measured along the great-circle arc between them. This arc is the shortest path between the two points on the surface of the ...
formulas that avoid this problem). (The formula above is sometimes written in terms of the
arctangent
In mathematics, the inverse trigonometric functions (occasionally also called ''antitrigonometric'', ''cyclometric'', or ''arcus'' functions) are the inverse functions of the trigonometric functions, under suitably restricted domains. Specific ...
function, but this suffers from similar numerical problems near .)
As described below, a similar formula can be written using cosines (sometimes called the spherical law of cosines, not to be confused with the
law of cosines
In trigonometry, the law of cosines (also known as the cosine formula or cosine rule) relates the lengths of the sides of a triangle to the cosine of one of its angles. For a triangle with sides , , and , opposite respective angles , , and (see ...
for plane geometry) instead of haversines, but if the two points are close together (e.g. a kilometer apart, on the Earth) one might end up with , leading to an inaccurate answer. Since the haversine formula uses sines, it avoids that problem.
Either formula is only an approximation when applied to the
Earth
Earth is the third planet from the Sun and the only astronomical object known to Planetary habitability, harbor life. This is enabled by Earth being an ocean world, the only one in the Solar System sustaining liquid surface water. Almost all ...
, which is not a perfect sphere: the "
Earth radius
Earth radius (denoted as ''R''🜨 or ''R''E) is the distance from the center of Earth to a point on or near its surface. Approximating the figure of Earth by an Earth spheroid (an oblate ellipsoid), the radius ranges from a maximum (equato ...
" varies from 6356.752 km at the poles to 6378.137 km at the equator. More importantly, the
radius of curvature
In differential geometry, the radius of curvature, , is the reciprocal of the curvature. For a curve, it equals the radius of the circular arc which best approximates the curve at that point. For surfaces, the radius of curvature is the radius ...
of a north-south line on the earth's surface is 1% greater at the poles (≈6399.594 km) than at the equator (≈6335.439 km)—so the haversine formula and law of cosines cannot be guaranteed correct to better than 0.5%. More accurate methods that consider the Earth's ellipticity are given by
Vincenty's formulae
Vincenty's formulae are two related iterative methods used in geodesy to calculate the distance between two points on the surface of a spheroid, developed by Thaddeus Vincenty (1975a). They are based on the assumption that the figure of the Eart ...
and the other formulas in the
geographical distance
Geographical distance or geodetic distance is the distance measured along the surface of the Earth, or the shortest arch length.
The formulae in this article calculate distances between points which are defined by geographical coordinates in t ...
article.
The law of haversines
Given a unit sphere, a "triangle" on the surface of the sphere is defined by the
great circle
In mathematics, a great circle or orthodrome is the circular intersection of a sphere and a plane passing through the sphere's center point.
Discussion
Any arc of a great circle is a geodesic of the sphere, so that great circles in spher ...
s connecting three points , , and on the sphere. If the lengths of these three sides are (from to ), (from to ), and (from to ), and the angle of the corner opposite is , then the law of haversines states:
:
Since this is a unit sphere, the lengths , , and are simply equal to the angles (in
radian
The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. It is defined such that one radian is the angle subtended at ...
s) subtended by those sides from the center of the sphere (for a non-unit sphere, each of these arc lengths is equal to its
central angle
A central angle is an angle whose apex (vertex) is the center O of a circle and whose legs (sides) are radii intersecting the circle in two distinct points A and B. Central angles are subtended by an arc between those two points, and the arc l ...
multiplied by the radius of the sphere).
In order to obtain the haversine formula of the previous section from this law, one simply considers the special case where is the
north pole
The North Pole, also known as the Geographic North Pole or Terrestrial North Pole, is the point in the Northern Hemisphere where the Earth's rotation, Earth's axis of rotation meets its surface. It is called the True North Pole to distingu ...
, while and are the two points whose separation is to be determined. In that case, and are (that is, the, co-latitudes), is the longitude separation , and is the desired . Noting that , the haversine formula immediately follows.
To derive the law of haversines, one starts with the spherical law of cosines:
:
As mentioned above, this formula is an ill-conditioned way of solving for when is small. Instead, we substitute the identity that , and also employ the addition identity , to obtain the law of haversines, above.
Proof
One can prove the formula:
:
by transforming the points given by their latitude and longitude into
cartesian coordinates
In geometry, a Cartesian coordinate system (, ) in a plane is a coordinate system that specifies each point uniquely by a pair of real numbers called ''coordinates'', which are the signed distances to the point from two fixed perpendicular o ...
, then taking their
dot product
In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
.
Consider two points on the
unit sphere
In mathematics, a unit sphere is a sphere of unit radius: the locus (mathematics), set of points at Euclidean distance 1 from some center (geometry), center point in three-dimensional space. More generally, the ''unit -sphere'' is an n-sphere, -s ...
, given by their latitude and longitude :
:
These representations are very similar to
spherical coordinates
In mathematics, a spherical coordinate system specifies a given point in three-dimensional space by using a distance and two angles as its three coordinates. These are
* the radial distance along the line connecting the point to a fixed point ...
, however latitude is measured as angle from the equator and not the north pole. These points have the following representations in cartesian coordinates:
:
From here we could directly attempt to calculate the dot product and proceed, however the formulas become significantly simpler when we consider the following fact: the distance between the two points will not change if we rotate the sphere along the z-axis. This will in effect add a constant to . Note that similar considerations do not apply to transforming the latitudes - adding a constant to the latitudes may change the distance between the points. By choosing our constant to be , and setting , our new points become:
:
With denoting the angle between and , we now have that:
:
Example
The haversine formula can be used to find the approximate distance between the
White House
The White House is the official residence and workplace of the president of the United States. Located at 1600 Pennsylvania Avenue Northwest (Washington, D.C.), NW in Washington, D.C., it has served as the residence of every U.S. president ...
in
Washington, D.C.
Washington, D.C., formally the District of Columbia and commonly known as Washington or D.C., is the capital city and federal district of the United States. The city is on the Potomac River, across from Virginia, and shares land borders with ...
(latitude 38.898° N, longitude 77.037° W) and the
Eiffel Tower
The Eiffel Tower ( ; ) is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is named after the engineer Gustave Eiffel, whose company designed and built the tower from 1887 to 1889.
Locally nicknamed "''La dame de fe ...
in
Paris
Paris () is the Capital city, capital and List of communes in France with over 20,000 inhabitants, largest city of France. With an estimated population of 2,048,472 residents in January 2025 in an area of more than , Paris is the List of ci ...
(latitude 48.858° N, longitude 2.294° E). The difference in latitudes is 9.960° and the difference in longitudes is 79.331°. Inputting these into the haversine formula,
The great-circle distance is this central angle, in
radian
The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. It is defined such that one radian is the angle subtended at ...
s (55.411 degrees is 0.96710 radians), multiplied by the average radius of the Earth,
By comparison, using a more accurate ellipsoidal model of the earth, the geodesic distance between these landmarks can be computed as approximately 6177.45 km.This calculation was made using the open-source geodesic calculation softwar GeographicLib assuming the WGS84 ellipsoid. See
See also
*
Sight reduction In astronavigation, sight reduction is the process of deriving from a Sight (device), sight (in celestial navigation usually obtained using a sextant) the information needed for establishing a line of position, generally by intercept method.
Sight ...
*
Vincenty's formulae
Vincenty's formulae are two related iterative methods used in geodesy to calculate the distance between two points on the surface of a spheroid, developed by Thaddeus Vincenty (1975a). They are based on the assumption that the figure of the Eart ...
* U. S. Census Bureau Geographic Information Systems FAQ, (content has been moved t What is the best way to calculate the distance between 2 points?
* R. W. Sinnott, "Virtues of the Haversine", ''Sky and Telescope'' 68 (2), 159 (1984).
*
* W. Gellert, S. Gottwald, M. Hellwich, H. Kästner, and H. Küstner, ''The VNR Concise Encyclopedia of Mathematics'', 2nd ed., ch. 12 (Van Nostrand Reinhold: New York, 1989).