Distance Formula (3D)

In two-dimensional geometry, you learned how to find the distance between two points on a flat plane using the familiar distance formula derived from the Pythagorean theorem. When we move into three-dimensional space — the kind of space we actually live in — we need to extend that formula to account for a third direction. The 3D distance formula does exactly this, giving us a precise way to measure the straight-line (or 'Euclidean') distance between any two points in space. Every point in 3D space is described by three coordinates (x, y, z), representing its position along three mutually perpendicular axes. The x-axis points left and right, the y-axis points forward and backward, and the z-axis points up and down. When you want to know how far apart two such points are — for example, the positions of two aircraft, two atoms in a molecule, or two vertices of a 3D object — the 3D distance formula gives you the answer in one calculation. The derivation of this formula is a beautiful application of the Pythagorean theorem applied twice in succession: first in a horizontal plane, and then lifting the result into full 3D space. Understanding this formula is foundational for all further study in three-dimensional geometry, vectors, and physics, including topics like finding the length of a 3D vector, the equation of a sphere, and calculating work done by a force.

Key takeaways
  • Start with Two Points in Space
  • Find the Horizontal Distance (xy-plane)
  • Build a Right Triangle in 3D
  • Substitute and Simplify
  • Key Properties to Remember

Start with Two Points in Space

Let the two points be P₁ = (x₁, y₁, z₁) and P₂ = (x₂, y₂, z₂). We want to find the length of the straight line segment connecting them, which we call d.

Find the Horizontal Distance (xy-plane)

First, project both points onto the xy-plane, ignoring their z-coordinates. By the 2D Pythagorean theorem, the horizontal distance between these projections is d_xy = √((x₂ − x₁)² + (y₂ − y₁)²). This is just the familiar 2D distance formula applied to the base of a right triangle.

Build a Right Triangle in 3D

Now consider the right triangle whose horizontal leg has length d_xy and whose vertical leg has length |z₂ − z₁| (the difference in heights). The hypotenuse of THIS triangle is the true 3D distance d we are seeking. Applying the Pythagorean theorem again: d² = d_xy² + (z₂ − z₁)².

Substitute and Simplify

Substituting d_xy² = (x₂ − x₁)² + (y₂ − y₁)² into the equation from Step 3 gives: d² = (x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)². Taking the square root of both sides yields the 3D distance formula: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). Notice that this is a direct generalization — if both points lie in the same plane (z₁ = z₂), the z-term disappears and we recover the 2D formula exactly.

Key Properties to Remember

The formula is symmetric: d(P₁, P₂) = d(P₂, P₁), because squaring removes any sign. The distance is always non-negative, and equals zero only when the two points are identical (x₁ = x₂, y₁ = y₂, z₁ = z₂). The formula generalizes naturally — in n dimensions, you simply add n squared-difference terms under the radical.

The Key Equation

d=(x2−x1)2+(y2−y1)2+(z2−z1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}
  • d — Distance (same as coordinate units (e.g., metres)): The straight-line (Euclidean) distance between the two points P₁ and P₂.
  • x_1, x_2 — x-coordinates of P₁ and P₂ (length units): The positions of each point along the horizontal x-axis.
  • y_1, y_2 — y-coordinates of P₁ and P₂ (length units): The positions of each point along the y-axis (depth or second horizontal direction).
  • z_1, z_2 — z-coordinates of P₁ and P₂ (length units): The positions of each point along the vertical z-axis (height).

Worked Example

Problem. Find the distance between the points A = (1, −2, 4) and B = (5, 2, −1) in 3D space.

d=(5−1)2+(2−(−2))2+(−1−4)2=16+16+25=57≈7.55d = \sqrt{(5-1)^2 + (2-(-2))^2 + (-1-4)^2} = \sqrt{16+16+25} = \sqrt{57} \approx 7.55

Answer. The distance between A and B is √57 ≈ 7.55 units.

Figure
Diagram
3D Distance Between Two PointsxzyP₁(x₁,y₁,z₁)P₂(x₂,y₂,z₂)dΔx = x₂−x₁Δz = z₂−z₁Δy = y₂−y₁d = √( (x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)² )Apply Pythagorean theorem twice in perpendicular planes
Origins · 1 minRené Descartes and how this was discovered
RD
René Descartes
1596–1650 · French

Descartes invented the Cartesian coordinate system — the very framework of x, y, and z axes that makes the 3D distance formula possible. By linking algebra and geometry, his work in 'La Géométrie' (1637) founded the field of analytic geometry. Every time you write a point as (x, y, z), you are using his idea. Descartes reportedly came up with the idea of coordinate geometry while lying in bed watching a fly on the ceiling — he realized he could describe the fly's position with just two numbers (its distances from two walls). Whether this story is literally true or not, it beautifully captures how abstract mathematics can arise from everyday observation.

  • Introduction to the 3D Coordinate System — Understanding the x, y, z axes and how coordinates are assigned to points in space is the essential prerequisite for the distance formula.
  • Distance Formula (2D) — The 3D distance formula is a direct extension of the 2D version; mastering the 2D case first makes the 3D derivation straightforward.
  • Midpoint Formula (3D) — The midpoint formula is the natural companion to the distance formula — both rely on coordinate arithmetic between two points in 3D space.
  • Equation of a Sphere — A sphere is defined as the set of all points at a fixed distance (radius) from a centre point — which is exactly the 3D distance formula set equal to a constant.
  • Magnitude of a 3D Vector — The magnitude (length) of a vector with components (a, b, c) is √(a² + b² + c²) — structurally identical to the 3D distance formula when one point is at the origin.