NEW
A trigonometric formula for great-circle distance between two points on a sphere from latitude and longitude.
DESCRIPTION
The haversine formula computes distances along a sphere’s surface using trigonometric functions of latitude and longitude differences. It is widely used to approximate Earth distances for analytics and proximity queries. Accuracy is good for many applications but limited by the spherical Earth assumption. For high-precision needs, ellipsoidal methods like Vincenty or geodesic libraries are preferred. Numerical stability is better at small distances than the naive spherical law of cosines.
ALTERNATIVE DEFINITIONS
Wolfram MathWorld
The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes.
Concise mathematical definition focusing on great-circle distance on a sphere.
Movable Type Scripts
The haversine formula gives great-circle distances between two points on a sphere from their longitudes and latitudes.
Practical engineering explanation with derivations and code examples.
RELATED TERMS
Great-circle Distance Geodesy WGS 84 Ellipsoid Bearing Equirectangular Approximation Spatial Analysis Coordinate System
COMPETING TERMS
Vincenty Formulae Spherical Law of Cosines
KNOWLEDGE AREAS
Mathematics Data Science AI Data Engineering
TARGET AUDIENCE
Data Scientist Data Engineer Software Developer AI Engineer
EXTERNAL SOURCES
- Wikipedia - Haversine formula
- GeographicLib - Accurate geodesic computations reference.
- PostGIS - Sphere distance function related to haversine.
TOP QUESTIONS
When is the Haversine formula accurate enough?
For many analytics tasks at regional scales, haversine is sufficiently accurate. For surveying or long distances, use ellipsoidal methods.
Category: Guidance
How does Haversine compare to Vincenty?
Haversine assumes a sphere, while Vincenty models the ellipsoid for higher accuracy, especially over long distances.
Category: Alternatives
Is Haversine numerically stable for small distances?
Yes, it’s generally more stable than the spherical law of cosines for small angular separations.
Category: Properties
What units does Haversine return?
It returns angular distance; convert by multiplying Earth’s radius to obtain meters or kilometers.
Category: How-To
What Earth radius should I use?
Use a mean Earth radius (≈6371 km) for approximation or select context-specific radii for improved accuracy.
Category: Best practices
Does Haversine handle coordinates crossing the anti-meridian?
Yes, if longitude differences are normalized to the range −π to π.
Category: Edge cases
Can Haversine be vectorized for big datasets?
Yes, libraries like NumPy or database functions allow efficient batch computation over large arrays.
Category: Performance
Is Haversine appropriate for air travel distances?
It provides a reasonable approximation to great-circle routes. For precision flight planning, use geodesic computations.
Category: Scope
What is the biggest misunderstanding about Haversine?
That it’s exact for Earth. Earth is not a perfect sphere, so ellipsoidal models are more precise.
Category: Misunderstanding