Mathematics · Geometry
Great-Circle Distance Calculator
Calculate spherical surface distance between two latitude-longitude points.
Inputs and results stay in this browser. Change one value at a time to explore the relationship.
Change an input to reshape this diagram.
Calculation steps
- Haversine term=0.00007615242180438042.
- Central angle=0.017453292519943295; distance=6371×0.017453292519943295=111.19492664455873.
Understand Great-circle distance
One idea, three depths
Choose how deeply to explain Great-circle distance
Great-circle distance: Calculate spherical surface distance between two latitude-longitude points.
Age 5Explain it to a 5-year-oldStart with a picture
Imagine using Great-circle distance to answer this question: calculate spherical surface distance between two latitude-longitude points? Enter Latitude 1, Longitude 1, Latitude 2, and 2 other inputs; the calculator shows Great-circle distance. For example: Along the equator, one degree of longitude is about 111.2 km on Earth. The answer tells you Great-circle distance.
Age 15Explain it to a 15-year-oldConnect it to the formula
The haversine formula measures the central angle between points on a sphere. The rule is d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]. Its input values are Latitude 1 (°), Longitude 1 (°), Latitude 2 (°), Longitude 2 (°), Sphere radius R (km), and the main result is Great-circle distance. For example: Along the equator, one degree of longitude is about 111.2 km on Earth.
CollegeExplain it at college levelState the model precisely
This calculator evaluates the stated great-circle distance relation over the valid real-number domain stated below. The implemented relation is d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)], evaluated from Latitude 1 (°), Longitude 1 (°), Latitude 2 (°), Longitude 2 (°), Sphere radius R (km) to produce Great-circle distance. The haversine formula measures the central angle between points on a sphere. Earth is not a perfect sphere; high-precision geodesy uses an ellipsoid.
Inputs and valid domain
- Latitude 1 must be a finite real number in °.
- Longitude 1 must be a finite real number in °.
- Latitude 2 must be a finite real number in °.
- Longitude 2 must be a finite real number in °.
- Sphere radius R must be a finite real number, at least 0 in km.
Important boundary: Earth is not a perfect sphere; high-precision geodesy uses an ellipsoid.
The formula
d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]
How the calculator works through it
It substitutes Latitude 1, Longitude 1, Latitude 2, Longitude 2, Sphere radius R into the formula and exposes every numerical step above. The main output is Great-circle distance, accompanied by Central angle radians, Central angle degrees.
Read the result correctly
The Great-circle distance is the direct answer to “calculate spherical surface distance between two latitude-longitude points.” Read it with the units shown beside the inputs; a sign, angle, percentage or rate changes what the number means.
A worked check
Along the equator, one degree of longitude is about 111.2 km on Earth.
Where this model stops being reliable
Earth is not a perfect sphere; high-precision geodesy uses an ellipsoid.
Learn it by changing one value
Begin with the worked example, then change one value while keeping the others fixed. Compare the new result and calculation steps to identify which part of the formula changed.
Dictionary terms behind this calculator
Before studying the codeWhat you should know firstUse the calculator immediately, or check the foundations before reading the implementation.
These foundations help you understand why Great-circle distance works. They never block the calculator, and “optional” means useful context rather than a hidden requirement.
Hard requirements
- Reading formulas and substituting values
Great-circle distance uses d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]. You need to recognise what each side represents before substituting the stated inputs or rearranging the relationship.
Review this foundation about 4 min
Strong support
- Ratios between measured quantities
Ratios help you check the scale, units and proportional meaning of Great-circle distance.
Review this foundation about 4 min
Optional enrichment
- Angles and geometric relationships
Angle language provides useful geometric context for extending Great-circle distance to related shapes and constructions.
Review this foundation about 4 min
Mathematics → algorithm → program
Implement this calculation in code
These are direct reference implementations of the calculator's principal relationship and first output. They run locally and include a small known-answer check where the language supports it.
Algorithm
- Read Latitude 1, Longitude 1, Latitude 2, Longitude 2, Sphere radius R.
- Evaluate the principal relationship: d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)].
- Return Great-circle distance and check the domain conditions described above.
Python
from math import *
def great_circle_distance(a1, b1, a2, b2, r) -> float:
return (r * (2.0 * asin(sqrt(((sin(((((a2 * pi) / 180.0) - ((a1 * pi) / 180.0)) / 2.0)) * sin(((((a2 * pi) / 180.0) - ((a1 * pi) / 180.0)) / 2.0))) + ((cos(((a1 * pi) / 180.0)) * cos(((a2 * pi) / 180.0))) * (sin(((((b2 * pi) / 180.0) - ((b1 * pi) / 180.0)) / 2.0)) * sin(((((b2 * pi) / 180.0) - ((b1 * pi) / 180.0)) / 2.0)))))))))
assert abs(great_circle_distance(0, 0, 0, 1, 6371) - 111.19492664455873) < 1e-6 * max(1.0, abs(111.19492664455873))
C
#include <assert.h>
#include <math.h>
double great_circle_distance(double a1, double b1, double a2, double b2, double r) {
return (r * (2.0 * asin(sqrt(((sin(((((a2 * 3.141592653589793) / 180.0) - ((a1 * 3.141592653589793) / 180.0)) / 2.0)) * sin(((((a2 * 3.141592653589793) / 180.0) - ((a1 * 3.141592653589793) / 180.0)) / 2.0))) + ((cos(((a1 * 3.141592653589793) / 180.0)) * cos(((a2 * 3.141592653589793) / 180.0))) * (sin(((((b2 * 3.141592653589793) / 180.0) - ((b1 * 3.141592653589793) / 180.0)) / 2.0)) * sin(((((b2 * 3.141592653589793) / 180.0) - ((b1 * 3.141592653589793) / 180.0)) / 2.0)))))))));
}
int main(void) {
const double expected = 111.19492664455873;
const double actual = great_circle_distance(0, 0, 0, 1, 6371);
assert(fabs(actual - expected) < 1e-6 * fmax(1.0, fabs(expected)));
}
C++
#include <cassert>
#include <cmath>
#include <numbers>
double great_circle_distance(double a1, double b1, double a2, double b2, double r) {
return (r * (2.0 * std::asin(std::sqrt(((std::sin(((((a2 * std::numbers::pi) / 180.0) - ((a1 * std::numbers::pi) / 180.0)) / 2.0)) * std::sin(((((a2 * std::numbers::pi) / 180.0) - ((a1 * std::numbers::pi) / 180.0)) / 2.0))) + ((std::cos(((a1 * std::numbers::pi) / 180.0)) * std::cos(((a2 * std::numbers::pi) / 180.0))) * (std::sin(((((b2 * std::numbers::pi) / 180.0) - ((b1 * std::numbers::pi) / 180.0)) / 2.0)) * std::sin(((((b2 * std::numbers::pi) / 180.0) - ((b1 * std::numbers::pi) / 180.0)) / 2.0)))))))));
}
int main() {
constexpr double expected = 111.19492664455873;
const double actual = great_circle_distance(0, 0, 0, 1, 6371);
assert(std::fabs(actual - expected) < 1e-6 * std::fmax(1.0, std::fabs(expected)));
}
Linux x86-64 assembly
x86-64 NASM · System V ABI · Linux · SSE2 with libm where required
; double great_circle_distance(double a1, double b1, double a2, double b2, double r)
; Linux x86-64 NASM · System V ABI · first eight doubles in xmm0–xmm7
extern sin
extern cos
extern asin
global great_circle_distance
section .text
great_circle_distance:
push rbp
mov rbp, rsp
sub rsp, 592
movsd [rbp-8], xmm0
movsd [rbp-16], xmm1
movsd [rbp-24], xmm2
movsd [rbp-32], xmm3
movsd [rbp-40], xmm4
mov rax, 0x4000000000000000
movq xmm0, rax
movsd [rbp-64], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-144], xmm0
movsd xmm0, [rbp-24]
mulsd xmm0, [rbp-144]
movsd [rbp-136], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-152], xmm0
movsd xmm0, [rbp-136]
divsd xmm0, [rbp-152]
movsd [rbp-128], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-176], xmm0
movsd xmm0, [rbp-8]
mulsd xmm0, [rbp-176]
movsd [rbp-168], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-184], xmm0
movsd xmm0, [rbp-168]
divsd xmm0, [rbp-184]
movsd [rbp-160], xmm0
movsd xmm0, [rbp-128]
subsd xmm0, [rbp-160]
movsd [rbp-120], xmm0
mov rax, 0x4000000000000000
movq xmm0, rax
movsd [rbp-192], xmm0
movsd xmm0, [rbp-120]
divsd xmm0, [rbp-192]
movsd [rbp-112], xmm0
movsd xmm0, [rbp-112]
call sin wrt ..plt
movsd [rbp-104], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-240], xmm0
movsd xmm0, [rbp-24]
mulsd xmm0, [rbp-240]
movsd [rbp-232], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-248], xmm0
movsd xmm0, [rbp-232]
divsd xmm0, [rbp-248]
movsd [rbp-224], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-272], xmm0
movsd xmm0, [rbp-8]
mulsd xmm0, [rbp-272]
movsd [rbp-264], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-280], xmm0
movsd xmm0, [rbp-264]
divsd xmm0, [rbp-280]
movsd [rbp-256], xmm0
movsd xmm0, [rbp-224]
subsd xmm0, [rbp-256]
movsd [rbp-216], xmm0
mov rax, 0x4000000000000000
movq xmm0, rax
movsd [rbp-288], xmm0
movsd xmm0, [rbp-216]
divsd xmm0, [rbp-288]
movsd [rbp-208], xmm0
movsd xmm0, [rbp-208]
call sin wrt ..plt
movsd [rbp-200], xmm0
movsd xmm0, [rbp-104]
mulsd xmm0, [rbp-200]
movsd [rbp-96], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-336], xmm0
movsd xmm0, [rbp-8]
mulsd xmm0, [rbp-336]
movsd [rbp-328], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-344], xmm0
movsd xmm0, [rbp-328]
divsd xmm0, [rbp-344]
movsd [rbp-320], xmm0
movsd xmm0, [rbp-320]
call cos wrt ..plt
movsd [rbp-312], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-376], xmm0
movsd xmm0, [rbp-24]
mulsd xmm0, [rbp-376]
movsd [rbp-368], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-384], xmm0
movsd xmm0, [rbp-368]
divsd xmm0, [rbp-384]
movsd [rbp-360], xmm0
movsd xmm0, [rbp-360]
call cos wrt ..plt
movsd [rbp-352], xmm0
movsd xmm0, [rbp-312]
mulsd xmm0, [rbp-352]
movsd [rbp-304], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-440], xmm0
movsd xmm0, [rbp-32]
mulsd xmm0, [rbp-440]
movsd [rbp-432], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-448], xmm0
movsd xmm0, [rbp-432]
divsd xmm0, [rbp-448]
movsd [rbp-424], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-472], xmm0
movsd xmm0, [rbp-16]
mulsd xmm0, [rbp-472]
movsd [rbp-464], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-480], xmm0
movsd xmm0, [rbp-464]
divsd xmm0, [rbp-480]
movsd [rbp-456], xmm0
movsd xmm0, [rbp-424]
subsd xmm0, [rbp-456]
movsd [rbp-416], xmm0
mov rax, 0x4000000000000000
movq xmm0, rax
movsd [rbp-488], xmm0
movsd xmm0, [rbp-416]
divsd xmm0, [rbp-488]
movsd [rbp-408], xmm0
movsd xmm0, [rbp-408]
call sin wrt ..plt
movsd [rbp-400], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-536], xmm0
movsd xmm0, [rbp-32]
mulsd xmm0, [rbp-536]
movsd [rbp-528], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-544], xmm0
movsd xmm0, [rbp-528]
divsd xmm0, [rbp-544]
movsd [rbp-520], xmm0
mov rax, 0x400921fb54442d18
movq xmm0, rax
movsd [rbp-568], xmm0
movsd xmm0, [rbp-16]
mulsd xmm0, [rbp-568]
movsd [rbp-560], xmm0
mov rax, 0x4066800000000000
movq xmm0, rax
movsd [rbp-576], xmm0
movsd xmm0, [rbp-560]
divsd xmm0, [rbp-576]
movsd [rbp-552], xmm0
movsd xmm0, [rbp-520]
subsd xmm0, [rbp-552]
movsd [rbp-512], xmm0
mov rax, 0x4000000000000000
movq xmm0, rax
movsd [rbp-584], xmm0
movsd xmm0, [rbp-512]
divsd xmm0, [rbp-584]
movsd [rbp-504], xmm0
movsd xmm0, [rbp-504]
call sin wrt ..plt
movsd [rbp-496], xmm0
movsd xmm0, [rbp-400]
mulsd xmm0, [rbp-496]
movsd [rbp-392], xmm0
movsd xmm0, [rbp-304]
mulsd xmm0, [rbp-392]
movsd [rbp-296], xmm0
movsd xmm0, [rbp-96]
addsd xmm0, [rbp-296]
movsd [rbp-88], xmm0
sqrtsd xmm0, [rbp-88]
movsd [rbp-80], xmm0
movsd xmm0, [rbp-80]
call asin wrt ..plt
movsd [rbp-72], xmm0
movsd xmm0, [rbp-64]
mulsd xmm0, [rbp-72]
movsd [rbp-56], xmm0
movsd xmm0, [rbp-40]
mulsd xmm0, [rbp-56]
movsd [rbp-48], xmm0
movsd xmm0, [rbp-48]
leave
ret
MATLAB
function result = great_circle_distance(a1, b1, a2, b2, r)
result = (r * (2.0 * asin(sqrt(((sin(((((a2 * pi) / 180.0) - ((a1 * pi) / 180.0)) / 2.0)) * sin(((((a2 * pi) / 180.0) - ((a1 * pi) / 180.0)) / 2.0))) + ((cos(((a1 * pi) / 180.0)) * cos(((a2 * pi) / 180.0))) * (sin(((((b2 * pi) / 180.0) - ((b1 * pi) / 180.0)) / 2.0)) * sin(((((b2 * pi) / 180.0) - ((b1 * pi) / 180.0)) / 2.0)))))))));
end
Wolfram Language
ClearAll[mwCalculate];
mwCalculate[a1_, b1_, a2_, b2_, r_] := (r * (2.0 * ArcSin[Sqrt[((Sin[((((a2 * Pi) / 180.0) - ((a1 * Pi) / 180.0)) / 2.0)] * Sin[((((a2 * Pi) / 180.0) - ((a1 * Pi) / 180.0)) / 2.0)]) + ((Cos[((a1 * Pi) / 180.0)] * Cos[((a2 * Pi) / 180.0)]) * (Sin[((((b2 * Pi) / 180.0) - ((b1 * Pi) / 180.0)) / 2.0)] * Sin[((((b2 * Pi) / 180.0) - ((b1 * Pi) / 180.0)) / 2.0)])))]]));
Continue in mathematical software
The downloaded file includes your current inputs and first calculated result. It is created locally.
Floating-point answers can differ slightly by language, compiler and processor. Compare within a suitable tolerance rather than assuming every decimal representation will be identical.
Supporting sourcesAcademic referencesPrimary standards, textbooks and complete citations
Standards, reading and academic references
Use the calculator as the worked interaction, then consult the primary standards and academic textbooks listed below. MW SysArc links to the original sources; the explanation on this page is original and does not reproduce them.
Algebra and Trigonometry 2e
Read the related free OpenStax mathematics chaptersCite this book
- APA 7
- Abramson, J. (2021). Algebra and trigonometry 2e. OpenStax. https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites
- MLA 9
- Abramson, Jay. Algebra and Trigonometry 2e. OpenStax, 2021, https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites.
- Chicago author-date
- Abramson, Jay. 2021. Algebra and Trigonometry 2e. Houston, TX: OpenStax. https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-introduction-to-prerequisites.
OpenStax entries are free to read online. Follow the licence shown on each linked source before redistributing or adapting its content.
Reuse the page responsiblyCite this pageAPA, MLA, Chicago, Harvard, BibTeX and RIS
These formats cite this calculator page itself. They are separate from the academic references above, which support the mathematical method and terminology.
APA 7
MW SysArc. (2026, July 21). Great-Circle Distance Calculator. MW SysArc Tools. https://math.mwsysarc.com/geometry/great-circle-distance
MLA 9
MW SysArc. “Great-Circle Distance Calculator.” MW SysArc Tools, 21 July 2026, https://math.mwsysarc.com/geometry/great-circle-distance. Accessed 31 Aug. 2026.
Chicago 17
MW SysArc. “Great-Circle Distance Calculator.” MW SysArc Tools. Published July 21, 2026. Accessed August 31, 2026. https://math.mwsysarc.com/geometry/great-circle-distance.
Harvard
MW SysArc (2026) ‘Great-Circle Distance Calculator’, MW SysArc Tools. Published 21 July 2026. Available at: https://math.mwsysarc.com/geometry/great-circle-distance (Accessed: 31 August 2026).
BibTeX and RIS records
BibTeX
@misc{mwsysarc_great_circle_distance_2026,
author = {{MW SysArc}},
title = {Great-Circle Distance Calculator},
howpublished = {MW SysArc Tools},
year = {2026},
url = {https://math.mwsysarc.com/geometry/great-circle-distance},
note = {Published July 21, 2026; accessed August 31, 2026}
}RIS
TY - ELEC
AU - MW SysArc
TI - Great-Circle Distance Calculator
T2 - MW SysArc Tools
PY - 2026
DA - 2026-07-21
Y2 - 2026-08-31
UR - https://math.mwsysarc.com/geometry/great-circle-distance
N1 - Published July 21, 2026
ER -Clear answers
Frequently asked questions
What does the Great-circle distance do?
Calculate spherical surface distance between two latitude-longitude points.
How does the Great-circle distance work?
The calculator applies d=R·2asin√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]. The haversine formula measures the central angle between points on a sphere.
What can I learn from the Great-circle distance?
It connects the mathematical rule to your chosen numbers and shows each calculation step. Change one input at a time to see how the result responds.
Does MW SysArc receive or store what I enter?
No. The calculation runs locally in your browser. MW SysArc does not receive or store your calculation inputs.
How should I use the result?
Use the steps to understand the method, then verify important school or professional work using the notation and rounding rules required in your setting.
Last reviewed . Calculations tested .