The 2D distance formula d = √((x₂ − x₁)² + (y₂ − y₁)²) generalizes cleanly to any number of dimensions. The pattern is the same: square the differences, sum them, take the square root. Here's how that extension works and where you'll encounter it.
The pattern
For points in n-dimensional space P = (p₁, p₂, …, pₙ) and Q = (q₁, q₂, …, qₙ):
d = √[Σ(qᵢ − pᵢ)²]
That's it. Sum the squared coordinate differences across all n dimensions, then take the square root. The 2D and 3D formulas are special cases of this.
3D distance formula
For two points (x₁, y₁, z₁) and (x₂, y₂, z₂):
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
Worked example: distance from (1, 2, 3) to (4, 6, 8).
- Δx = 3, Δy = 4, Δz = 5
- d = √(9 + 16 + 25) = √50 ≈ 7.07
Why the formula extends so cleanly
Geometrically, the 3D distance formula comes from applying the Pythagorean theorem twice. In 3D space:
- The diagonal of the base rectangle (in the xy-plane) is √(Δx² + Δy²).
- The 3D diagonal connects this base diagonal to the height Δz.
- Apply Pythagoras again: d² = (base diagonal)² + Δz² = Δx² + Δy² + Δz².
Take the square root and you have the 3D formula. The same nested-Pythagoras logic extends to any number of dimensions.
Real-world 3D distances
Aircraft navigation: a plane at (lat, lon, altitude) computing distance to a destination uses 3D distance — though for long distances, the curved-Earth formula (great-circle distance) is more accurate.
Satellite orbits: distances between satellites and ground stations at any moment.
3D printing and CAD: distance between two points on a 3D model.
Architecture: the diagonal of a 12 ft × 16 ft × 8 ft room is √(144 + 256 + 64) = √464 ≈ 21.5 ft. Useful for "will this couch fit through the corner?" calculations.
Crystallography: the spacing between atoms in a crystal lattice along any direction.
Higher-dimensional distance
Distance generalizes to any number of dimensions, even when there's no physical "space" to point at. In machine learning, each feature of a data point is a dimension, and "distance" measures how similar two data points are.
Example: comparing two houses on (price, square feet, bedrooms, bathrooms, year built) — that's 5 dimensions. The "distance" between two houses in this feature space tells you how similar they are. House comparisons in real estate algorithms use this exact computation, often weighted to reflect that price matters more than year built.
The curse of dimensionality
An interesting quirk: as the number of dimensions grows, the geometry gets weird. In high dimensions, all points tend to be roughly the same distance from each other (there's not much variation). This phenomenon is called the "curse of dimensionality" and it's a serious challenge in machine learning — distance loses its discriminating power.
Mathematicians and ML researchers handle this by either reducing dimensionality first (PCA, t-SNE) or by using different distance measures (Mahalanobis, cosine similarity) that behave better in high dimensions.
Manhattan distance vs Euclidean distance
Euclidean distance is what we've been computing — straight-line distance "as the crow flies." There are other distance metrics:
Manhattan distance (or "taxicab distance") sums the absolute differences instead of squaring them: d = |x₂ − x₁| + |y₂ − y₁| + …. It models the path length on a city grid where you can only move along streets (no diagonals).
For (1, 2) to (4, 6): Manhattan = 3 + 4 = 7. Euclidean = 5. Manhattan is always ≥ Euclidean (the straight line is the shortest path).
GPS routing uses something between the two, depending on the road network.
Distance on a sphere
For points on the Earth's surface, plain 3D distance gives you the straight-line through-the-Earth distance — useless for travel. The relevant distance is the great-circle distance, computed with the haversine formula:
d = 2r × arcsin(√[sin²(Δφ/2) + cos(φ₁) cos(φ₂) sin²(Δλ/2)])
Where r ≈ 3,959 mi, φ are latitudes, λ are longitudes. This is what airlines, GPS, and shipping use — different math, same goal of "how far apart are these two points?"
Tools for hand calculation
Our distance formula calculator handles 2D distance with full precision. For 3D you can compute it manually as √(Δx² + Δy² + Δz²) — same approach, one extra term. Most calculators (including the TI-84) handle the formula directly with parentheses; just be careful not to confuse the squared sum with squared individual differences.