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:

  1. The diagonal of the base rectangle (in the xy-plane) is √(Δx² + Δy²).
  2. The 3D diagonal connects this base diagonal to the height Δz.
  3. 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: latitude and longitude are angles, not lengths, so they can’t go straight into the formula: a degree of longitude spans about 69 miles at the equator but only about 35 miles at 60° north. Convert each position to Earth-centered x, y, z coordinates first; the 3D formula then gives the straight-line distance, for example between two aircraft. For the distance a plane actually flies over the curved Earth, use the great-circle distance (see below).

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. In practice each feature is usually rescaled first; otherwise price, measured in hundreds of thousands of dollars, would swamp a difference of one bedroom.

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 reducing dimensionality first (for example with PCA) or by choosing distance measures that hold up better in high dimensions. One well-known study found Manhattan distance (below) consistently more useful than Euclidean distance for high-dimensional data, and “fractional” distances more useful still.

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. The formula treats the Earth as a perfect sphere, which is close enough for most purposes; systems that need more precision, such as GPS, work in the WGS 84 reference system, which models the Earth’s actual size and shape. 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.

Sources