Geography & Earth
Advanced

Haversine Distance

Great-circle distance between two lat/long points.

Formula

d=2rarcsin⁡sin⁡2Δϕ2+cos⁡ϕ1cos⁡ϕ2sin⁡2Δλ2d = 2r\arcsin\sqrt{\sin^2\frac{\Delta\phi}{2} + \cos\phi_1\cos\phi_2\sin^2\frac{\Delta\lambda}{2}}

Variables

rEarth radius (6371 km)
\phiLatitudes
\lambdaLongitudes

Example

The haversine formula gives great-circle distances between latitude/longitude points on Earth.

How it works

This formula finds the shortest path between two points on a spherical Earth model, measured along the surface rather than through the air. It works by turning the two latitude/longitude pairs into an angular separation on the sphere and then converting that angle to a distance using the Earth’s radius. The square-rooted sine terms make the calculation numerically stable for small separations, which is why it is preferred over simpler approximations for precise geodesic work.

When to use it

Use it whenever you need a surface distance between two GPS coordinates, such as in navigation, mapping, logistics, aviation, or remote-sensing analysis. It is especially useful when the points may be far apart or when accuracy matters more than a quick planar approximation.

Worked example, step by step

Find the distance between Paris (48.8566° N, 2.3522° E) and Rome (41.9028° N, 12.4964° E). Step 1: Convert degrees to radians. φ1 = 48.8566 × π/180 ≈ 0.8527 rad φ2 = 41.9028 × π/180 ≈ 0.7310 rad λ1 = 2.3522 × π/180 ≈ 0.0411 rad λ2 = 12.4964 × π/180 ≈ 0.2181 rad Step 2: Compute differences. Δφ = φ2 − φ1 ≈ 0.7310 − 0.8527 = −0.1217 rad Δλ = λ2 − λ1 ≈ 0.2181 − 0.0411 = 0.1770 rad Step 3: Evaluate the haversine part. sin²(Δφ/2) = sin²(−0.06085) ≈ 0.00370 cos φ1 cos φ2 sin²(Δλ/2) = cos(0.8527)cos(0.7310)sin²(0.0885) ≈ 0.6590 × 0.6678 × 0.00782 ≈ 0.00344 Inside the square root: 0.00370 + 0.00344 = 0.00714 Step 4: Take the inverse sine and multiply by 2r. arcsin(√0.00714) ≈ arcsin(0.0845) ≈ 0.0846 d = 2 × 6371 × 0.0846 ≈ 1078 km Final answer: The great-circle distance from Paris to Rome is about 1,078 km.

Common mistakes to avoid

  • using degrees directly instead of converting all angles to radians first
  • swapping surface distance for straight-line distance through Earth’s interior
  • forgetting that Δφ and Δλ are differences in coordinates, not the coordinates themselves

Did You Know?

The haversine formula finds great-circle distances on a sphere — the math behind every flight-path map.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026