Haversine Calculator - Great Circle Distance

Free online haversine calculator to compute great-circle distance between two coordinates. Calculate shortest distance on Earth's surface with step-by-step explanation.

° °
° °
km

What is the Haversine Formula?

The haversine formula is a mathematical equation used to calculate the shortest distance between two points on the surface of a sphere, such as Earth. It determines the great-circle distance, which is the shortest path between two points on a sphere's surface.

The haversine formula is particularly useful in navigation, geography, and GPS applications where you need to find the distance between two geographical coordinates (latitude and longitude). It accounts for the Earth's spherical shape, providing more accurate results than simple Euclidean distance calculations.

The formula is derived from the law of haversines, which relates the sides and angles of spherical triangles. The haversine function itself is defined as:

hav(θ) = sin²(θ/2) = (1 - cos(θ))/2

Key properties and applications of the haversine formula include:

  • Spherical Geometry: Works with Earth's curved surface rather than flat maps.
  • Navigation: Essential for calculating flight paths, shipping routes, and GPS navigation.
  • Accuracy: Provides precise distance calculations for locations worldwide.
  • Programming: Widely used in web applications, mobile apps, and geographic information systems.
  • Range: Works for any two points on Earth, regardless of distance.

The haversine formula is especially important in modern applications like ride-sharing services, delivery optimization, weather forecasting, and any system that needs to determine proximity or calculate travel distances between geographical locations.

How does the Haversine Formula work?

The haversine formula calculates the great-circle distance between two points on a sphere using their latitude and longitude coordinates. The formula involves several trigonometric functions and accounts for the Earth's radius.

The complete haversine formula is:

d = 2r × arcsin(√(sin²(Δφ/2) + cos(φ₁) × cos(φ₂) × sin²(Δλ/2)))

Where:

  • d = great-circle distance between the two points
  • r = radius of the Earth (approximately 6,371 km or 3,959 miles)
  • φ₁, φ₂ = latitude of point 1 and point 2 (in radians)
  • Δφ = φ₂ - φ₁ (difference in latitude)
  • Δλ = λ₂ - λ₁ (difference in longitude)
  • λ₁, λ₂ = longitude of point 1 and point 2 (in radians)

The formula works by:

  • Converting latitude and longitude from degrees to radians
  • Calculating the differences in coordinates
  • Applying the haversine function to these differences
  • Using the inverse haversine (arcsine) to get the central angle
  • Multiplying by Earth's radius to get the actual distance

This approach ensures that the calculated distance follows the curvature of the Earth, providing the shortest possible path between two points on the planet's surface.

Common Haversine Distance Examples

Here are some typical distances calculated using the haversine formula:

  • New York to Los Angeles: ~3,944 km (2,451 miles)
  • London to Tokyo: ~9,560 km (5,940 miles)
  • Sydney to Melbourne: ~713 km (443 miles)
  • Paris to Rome: ~1,103 km (685 miles)
  • Hanoi to Ho Chi Minh City: ~1,130 km (702 miles)