Distance Formula: Definition, Derivation and Worked Examples

The distance formula gives the straight-line distance between two points (x₁, y₁) and (x₂, y₂): d = √[(x₂ − x₁)² + (y₂ − y₁)²]. It is the Pythagorean theorem applied on a coordinate grid, and the answer is always zero or positive. For example, the distance from (1, 2) to (4, 6) is √(9 + 16) = 5 units.

Advertisement

What is the distance formula?

For two points A(x₁, y₁) and B(x₂, y₂) in a plane, the length of the segment AB is:

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

Here (x₂ − x₁) is the horizontal gap between the points and (y₂ − y₁) is the vertical gap. You square each gap, add them, and take the square root. The order of the points does not matter, because (x₁ − x₂)² is the same as (x₂ − x₁)².

Derivation of the distance formula from Pythagoras

  1. Plot A(x₁, y₁) and B(x₂, y₂).
  2. Draw a horizontal line through A and a vertical line through B. They meet at C(x₂, y₁), and angle ACB is 90°.
  3. The horizontal leg AC has length |x₂ − x₁|. The vertical leg BC has length |y₂ − y₁|.
  4. AB is the hypotenuse, so by the Pythagorean theorem: AB² = AC² + BC² = (x₂ − x₁)² + (y₂ − y₁)².
  5. Take the positive square root: d = √[(x₂ − x₁)² + (y₂ − y₁)²].

The absolute-value bars disappear once you square, which is why negative coordinates cause no trouble as long as you keep the signs straight inside the brackets.

Distance formula in 3D

For points A(x₁, y₁, z₁) and B(x₂, y₂, z₂) in space, apply Pythagoras twice (once across the base, once up the height):

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

Worked examples

Example 1: two positive points

Find the distance between (1, 2) and (4, 6).

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

Example 2: negative coordinates

Find the distance between P(−3, 4) and Q(5, −2).

x₂ − x₁ = 5 − (−3) = 8. y₂ − y₁ = −2 − 4 = −6.

d = √[8² + (−6)²] = √(64 + 36) = √100 = 10 units.

The trap here is writing 5 − 3 = 2 instead of 5 − (−3) = 8. Put every negative coordinate in brackets before subtracting.

Advertisement

Example 3: an answer that is not a whole number

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

d = √[(3 − (−2))² + (5 − (−1))²] = √(5² + 6²) = √(25 + 36) = √61 ≈ 7.81 units.

Example 4: 3D distance

Find the distance between (1, 2, 3) and (4, 6, 15).

d = √[3² + 4² + 12²] = √(9 + 16 + 144) = √169 = 13 units.

Example 5: a survey problem

Two survey stations have coordinates S1 (E 1250.0 m, N 830.0 m) and S2 (E 1410.0 m, N 710.0 m). The easting difference is 160.0 m and the northing difference is −120.0 m, so the horizontal distance is √(160² + 120²) = √(25,600 + 14,400) = √40,000 = 200.0 m.

Distance from a point to a line

A related result: the perpendicular (shortest) distance from a point (x₀, y₀) to the line ax + by + c = 0 is

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

Example: from (3, 4) to the line 3x + 4y − 5 = 0, d = |9 + 16 − 5| / √(9 + 16) = 20 / 5 = 4 units.

Distance formula summary table

CaseFormulaExample result
Two points in 2D√[(x₂ − x₁)² + (y₂ − y₁)²](1, 2) to (4, 6) = 5
Two points in 3D√[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²](1, 2, 3) to (4, 6, 15) = 13
Point to a line|ax₀ + by₀ + c| / √(a² + b²)(3, 4) to 3x + 4y − 5 = 0 gives 4
Point to the origin√(x² + y²)(6, 8) gives 10
Points on a horizontal line|x₂ − x₁|(2, 7) to (9, 7) = 7

Common mistakes

  • Sign errors with negatives: 5 − (−3) is 8, not 2. Use brackets.
  • Forgetting the square root: (x₂ − x₁)² + (y₂ − y₁)² is d², not d. In Example 2 that would give 100 instead of 10.
  • Mixing coordinates: subtracting an x from a y. Keep the pairs in the same order (both “second minus first”).
  • Splitting the root: √(a² + b²) is not a + b. √(9 + 16) = 5, not 3 + 4 = 7.
  • Dropping units: if the coordinates are in metres, the distance is in metres.

Where engineers use the distance formula

  • Surveying: horizontal distance between stations from their eastings and northings, as in Example 5.
  • CAD and CNC: lengths of members and tool paths between coordinate points.
  • Structural analysis: member lengths in a truss from joint coordinates, needed before finding stiffness or forces.
  • Proving the cosine rule: the cosine rule can be proved in one line by placing a triangle on axes and using the distance formula.
  • Coordinate geometry in the Class 11 and JEE syllabus: checking collinearity, the type of triangle, and the locus of a point.

FAQs

What is the distance formula?

It gives the straight-line distance between two points (x₁, y₁) and (x₂, y₂): d = √[(x₂ − x₁)² + (y₂ − y₁)²]. For (1, 2) and (4, 6) it gives 5 units.

How is the distance formula derived?

From the Pythagorean theorem. The horizontal gap (x₂ − x₁) and vertical gap (y₂ − y₁) form the two legs of a right triangle, and the distance between the points is its hypotenuse.

Can the distance between two points be negative?

No. The formula takes the positive square root of a sum of squares, so the distance is always zero or positive. It is zero only when the two points are the same.

What is the distance formula in 3D?

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. For (1, 2, 3) and (4, 6, 15) it gives √169 = 13 units.

Does the order of the points matter?

No. Swapping the points changes the sign of each difference, but squaring removes the sign, so the distance is the same.

Related Topics on EngineeringHulk

Advertisement