Ad Space — Top Banner

Haversine Formula

Calculate the great-circle distance between two points on Earth from their latitude and longitude coordinates.

The Formula

a = sin²(Δlat/2) + cos(lat₁) × cos(lat₂) × sin²(Δlon/2)

c = 2 × atan2(√a, √(1 − a))

d = R × c

The Haversine formula calculates the shortest distance between two points on a sphere (great-circle distance). It is widely used in navigation, aviation, and mapping applications.

The name comes from the mathematical function "half versed sine" (haversine), defined as hav(θ) = sin²(θ/2).

Variables

SymbolMeaning
lat₁, lon₁Latitude and longitude of point 1 (in radians)
lat₂, lon₂Latitude and longitude of point 2 (in radians)
Δlatlat₂ − lat₁
Δlonlon₂ − lon₁
REarth's radius: 6,371 km (3,959 miles)
dDistance between the two points

Example 1 — New York to London

New York (40.7128°N, 74.0060°W) to London (51.5074°N, 0.1278°W). Find the distance.

Convert to radians: lat₁ = 0.7102, lon₁ = −1.2918, lat₂ = 0.8988, lon₂ = −0.00223

Δlat = 0.1886, Δlon = 1.2896

a = sin²(0.0943) + cos(0.7102) × cos(0.8988) × sin²(0.6448)

a = 0.00889 + 0.7597 × 0.6272 × 0.3625 = 0.1816

c = 2 × atan2(√0.1816, √0.8184) = 2 × 0.4438 = 0.8876

d = 6,371 × 0.8876

d ≈ 5,653 km (3,513 miles)

Example 2 — Sydney to Tokyo

Sydney (33.8688°S, 151.2093°E) to Tokyo (35.6762°N, 139.6503°E). Find the distance.

Convert to radians: lat₁ = −0.5911, lon₁ = 2.6389, lat₂ = 0.6226, lon₂ = 2.4372

Δlat = 1.2137, Δlon = −0.2017

a = sin²(0.6069) + cos(−0.5911) × cos(0.6226) × sin²(−0.1009)

a = 0.3255 + 0.8305 × 0.8132 × 0.01017 = 0.3324

c = 2 × atan2(√0.3324, √0.6676) = 1.2298

d = 6,371 × 1.2298

d ≈ 7,835 km (4,868 miles)

When to Use It

  • GPS navigation and route planning
  • Finding the nearest store, restaurant, or point of interest
  • Aviation flight path calculations
  • Shipping and maritime navigation
  • Geofencing and location-based services

Important Notes

  • All angles must be converted to radians: radians = degrees × π / 180
  • The formula assumes a perfect sphere, so results have about 0.3% error compared to the actual ellipsoidal Earth
  • For higher accuracy, use the Vincenty formula (which accounts for Earth's flattening)

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.