Distance Formula in Maths: Definition, Derivation, and Examples

#formula#math
TL;DR
The distance formula, d = √[(x₂ − x₁)² + (y₂ − y₁)²], gives the straight-line distance between two points on a coordinate plane. It is derived from the Pythagorean theorem and extends to 3D by adding a z-coordinate term.
BT
Bhanzu TeamLast updated on April 21, 20266 min read

The distance formula calculates the length of the straight line segment between two points on a coordinate plane. For two points (x₁, y₁) and (x₂, y₂), the distance d between them is given by d = √[(x₂ − x₁)² + (y₂ − y₁)²].

The Formula

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

The formula takes two points and returns a single positive number — the straight-line distance between them. It is also called the Euclidean distance, named after the Greek mathematician Euclid, whose geometric framework the formula is built on.

Variable Key

Variable

Meaning

d

The distance between the two points

x₁

x-coordinate of the first point

y₁

y-coordinate of the first point

x₂

x-coordinate of the second point

y₂

y-coordinate of the second point

Either point can be chosen as the "first" point. The result is the same because (x₂ − x₁)² = (x₁ − x₂)² and (y₂ − y₁)² = (y₁ − y₂)². Squaring removes the sign.

When to Use the Distance Formula

Use the distance formula when two points are known by their coordinates and the straight-line distance between them is needed. The formula returns Euclidean distance — the shortest possible line segment between the points, not a path distance.

It works in any quadrant. Differences between coordinates can be negative, but squaring converts every negative value to its positive counterpart, so the final result is always positive.

One terminology note: the word "distance" also appears in the equation d = st (speed × time), used in motion problems. That is a separate formula and unrelated to coordinate geometry.

Derivation from the Pythagorean Theorem

The distance formula is a direct application of the Pythagorean theorem.

Two points on a coordinate plane, together with the right angle formed by their coordinate differences, make a right triangle. The horizontal leg of this triangle has length |x₂ − x₁|. The vertical leg has length |y₂ − y₁|. The line segment connecting the two points is the hypotenuse.

Apply the Pythagorean theorem, a² + b² = c²:

(x₂ − x₁)² + (y₂ − y₁)² = d²

Take the square root of both sides:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

The absolute value signs on the leg lengths can be dropped once the differences are squared, because any negative value becomes positive after squaring.

Worked Examples of Distance Formula

Example 1: Integer coordinates

Find the distance between (3, 2) and (9, 7).

Let (x₁, y₁) = (3, 2) and (x₂, y₂) = (9, 7).

d = √[(9 − 3)² + (7 − 2)²] d = √[6² + 5²] d = √[36 + 25] d = √61

Answer: d = √61 ≈ 7.81 units

Example 2: Negative coordinate

Find the distance between (−2, 1) and (1, 5).

Let (x₁, y₁) = (−2, 1) and (x₂, y₂) = (1, 5).

d = √[(1 − (−2))² + (5 − 1)²] d = √[3² + 4²] d = √[9 + 16] d = √25

Answer: d = 5 units

Example 3: Distance from the origin

Find the distance between (6, 8) and the origin (0, 0).

Let (x₁, y₁) = (0, 0) and (x₂, y₂) = (6, 8).

d = √[(6 − 0)² + (8 − 0)²] d = √[36 + 64] d = √100

Answer: d = 10 units

When one of the two points is the origin, the formula simplifies to d = √(x² + y²).

Example 4: Points on the same horizontal line

Find the distance between (−3, 4) and (7, 4).

Let (x₁, y₁) = (−3, 4) and (x₂, y₂) = (7, 4).

d = √[(7 − (−3))² + (4 − 4)²] d = √[10² + 0²] d = √100

Answer: d = 10 units

When the y-coordinates are equal, the formula simplifies to d = |x₂ − x₁|. The same simplification applies to the x-coordinates when the two points lie on the same vertical line.

Distance Formula in 3D

For two points in three-dimensional space, the formula extends by adding a term for the z-coordinates:

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

Example: Find the distance between (1, 2, 3) and (4, 6, 9).

d = √[(4 − 1)² + (6 − 2)² + (9 − 3)²] d = √[9 + 16 + 36] d = √61 ≈ 7.81

The same pattern extends to any number of dimensions — one squared-difference term per coordinate axis.

Applications of the Distance Formula

In GPS and satellite navigation, devices calculate their position by measuring distances from multiple satellites. The 3D distance formula is the basis for these calculations.

In vector algebra, the magnitude of a vector v with components (x, y) is |v| = √(x² + y²) — the distance formula applied from the origin to the point (x, y).

For a complex number a + bi, the modulus |a + bi| = √(a² + b²) is the distance from the origin to the point (a, b) in the complex plane.

In engineering and architecture, the formula is used to calculate physical distances between points on technical drawings, blueprints, and CAD systems, where each point has known coordinates.

Formula

Expression

When to Use

Distance formula (2D)

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

Between two points on a plane

Distance formula (3D)

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

Between two points in space

Distance from origin

d = √(x² + y²)

From (x, y) to (0, 0)

Distance on the number line

|x₂ − x₁|

Between two points in 1D

Midpoint formula

((x₁+x₂)/2, (y₁+y₂)/2)

To find the middle of a segment, not its length

Section formula

Internal division in ratio m:n

To divide a segment in a given ratio

Distance between parallel lines

|c₂ − c₁| / √(a² + b²)

Between two parallel lines in 2D

Distance from point to line

|ax₀ + by₀ + c| / √(a² + b²)

From a point to a line in 2D

Shortest distance between skew lines

Vector cross-product formula

Between two skew lines in 3D

Common Mistakes in Distance Formula

  • Forgetting to square the coordinate differences before adding them. Squaring converts negative differences to positive values - skipping the step produces wrong results when the two points lie in different quadrants.

  • Confusing the distance formula with the midpoint formula. The distance formula returns a single number (the length of the segment). The midpoint formula returns a coordinate pair (the point at the center of the segment).

  • Assuming point order matters. It does not. (x₂ − x₁)² equals (x₁ − x₂)² because squaring removes the sign. Either point can be labelled "first" with no effect on the answer.

A Brief History

The distance formula as it is written today was first published in 1731 by French mathematician Alexis Clairaut. The Pythagorean theorem it is built on is much older — evidence suggests Babylonian mathematicians were using the relationship over 3,500 years ago, long before Pythagoras was born. The formula is also known as the Euclidean distance, named after the Greek mathematician Euclid, whose Elements established the geometric foundations it relies on.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the distance formula in math?
The distance formula gives the straight-line distance between two points on a coordinate plane. For points (x₁, y₁) and (x₂, y₂), the distance is d = √[(x₂ − x₁)² + (y₂ − y₁)²].
How is the distance formula derived?
The distance formula is derived from the Pythagorean theorem. Any two points on a coordinate plane form the hypotenuse of a right triangle whose legs are the horizontal and vertical differences between their coordinates. Applying a² + b² = c² to those legs and taking the square root produces the distance formula.
Is the distance formula the same as the Euclidean distance?
Yes. In two and three dimensions, the terms are interchangeable — both refer to the straight-line distance between two points.
What is the difference between the distance formula and the midpoint formula?
The distance formula gives the length of the segment between two points - a single positive number. The midpoint formula gives the coordinates of the point that lies exactly halfway between them - a coordinate pair, not a length. They are often confused because they use the same two points as input. If the question asks "how far apart," use the distance formula; if it asks "what is the point in the middle," use the midpoint formula.
Can the distance formula be used for three or more dimensions?
Yes. For three dimensions, add a squared-difference term for the z-coordinates: d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. The same pattern extends to any number of dimensions - one squared-difference term per coordinate axis.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →