Precalculus

Distance Formula and Midpoint Formula with Examples

Distance Formula and Midpoint Formula with Examples

The distance formula gives the distance between ( (x_1, y_1) ) and ( (x_2, y_2) ): ( d = sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2} ). The midpoint formula gives the point halfway between them: ( M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2} right) ). For ( (1, 2) ) and ( (7, 10) ), ( d = 10 ) and ( M = (4, 6) ).

Two of the most-used formulas in coordinate geometry answer two simple questions about a pair of points ( (x_1, y_1) ) and ( (x_2, y_2) ): how far apart are they, and what point is exactly halfway between them?

$$d = sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$

$$M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2} right)$$

The first is the distance formula; the second is the midpoint formula.

Distance and midpoint formula

Coordinate geometry uses the distance and midpoint formula pair to calculate spatial relationships on a two-dimensional grid. The distance formula calculates a scalar value: the total straight-line distance separating two ordered pairs. In contrast, the midpoint formula yields an ordered pair: the exact center coordinate between those two endpoints.

Although both formulas take two points ( (x_1, y_1) ) and ( (x_2, y_2) ) as inputs, they perform different algebraic operations. Distance relies on subtraction and squaring to find side lengths of an implicit right triangle. Midpoint relies on addition and division by 2 to find the arithmetic mean of each coordinate.

Feature Distance Formula Midpoint Formula
Mathematical Formula ( d = sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2} ) ( M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2} right) )
Result Type Single positive number (scalar distance) Ordered pair (x, y coordinate)
Core Operation Subtract coordinates, square, sum, take square root Add coordinates, divide by 2
Geometric Basis Pythagorean theorem ((a^2 + b^2 = c^2)) Arithmetic mean (averaging endpoints)

Where the distance formula comes from

Plot the two points and draw a horizontal line from one and a vertical line from the other. They meet at a right angle, forming a right triangle whose hypotenuse is the segment you want to measure.

Distance formula: A student writing in a notebook while holding a calculator
  • The horizontal leg has length ( |x_2 – x_1| ).
  • The vertical leg has length ( |y_2 – y_1| ).

The Pythagorean theorem, ( a^2 + b^2 = c^2 ), then gives ( d^2 = (x_2 – x_1)^2 + (y_2 – y_1)^2 ). Taking the square root gives you the distance formula. Squaring removes the need for absolute values, since ( (-5)^2 = 5^2 ).

Where the midpoint formula comes from

The midpoint represents the exact center of a line segment. To find the point halfway between two horizontal positions, you calculate their numerical average: ( frac{x_1 + x_2}{2} ). Similarly, to find the point halfway between two vertical positions, you calculate their numerical average: ( frac{y_1 + y_2}{2} ). Combining these two averages creates the coordinate pair for the midpoint ( M ).

How to use the distance formula

  1. Label the points ( (x_1, y_1) ) and ( (x_2, y_2) ). Either point can serve as point 1.
  2. First, subtract the x-coordinates: ( x_2 – x_1 ). Next, subtract the y-coordinates: ( y_2 – y_1 ).
  3. Square both differences: ( (x_2 – x_1)^2 ) and ( (y_2 – y_1)^2 ).
  4. Add the two squared values together.
  5. Take the square root of the sum, and simplify the radical if necessary.

How to use the midpoint formula

Average the x-coordinates, then average the y-coordinates.

A pencil and a ruler lying on architectural blueprints
  1. Identify the coordinates ( (x_1, y_1) ) and ( (x_2, y_2) ).
  2. Add the two x-coordinates together and divide by 2: ( frac{x_1 + x_2}{2} ).
  3. Add the two y-coordinates together and divide by 2: ( frac{y_1 + y_2}{2} ).
  4. Write the two results as an ordered pair: ( left( x_M, y_M right) ).

Distance formula and midpoint formula example

You can analyze the same pair of coordinates using both formulas in sequence. For example, consider the endpoints ( A(2, -4) ) and ( B(8, 4) ).

Step 1: Calculate the distance

$$d = sqrt{(8 - 2)^2 + (4 - (-4))^2}$$

$$d = sqrt{(6)^2 + (8)^2} = sqrt{36 + 64} = sqrt{100} = 10$$

The straight-line distance between points A and B equals 10 units.

Step 2: Calculate the midpoint

$$M = left( frac{2 + 8}{2}, frac{-4 + 4}{2} right) = left( frac{10}{2}, frac{0}{2} right) = (5, 0)$$

The midpoint coordinate between points A and B sits precisely at ( (5, 0) ).

Distance and midpoint formula examples

Example 1: a whole-number answer

Find the distance between ( (1, 2) ) and ( (7, 10) ).

A close-up of a tape measure with distance markings

$$d = sqrt{(7 - 1)^2 + (10 - 2)^2} = sqrt{36 + 64} = sqrt{100} = 10$$

Example 2: negative coordinates

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

$$d = sqrt{big(2 - (-3)big)^2 + (-7 - 5)^2} = sqrt{5^2 + (-12)^2} = sqrt{25 + 144} = 13$$

Watch the double negative: ( 2 – (-3) = 5 ).

Example 3: simplifying the radical

Find the distance between ( (-1, 4) ) and ( (3, 0) ).

$$d = sqrt{4^2 + (-4)^2} = sqrt{32} = sqrt{16 cdot 2} = 4sqrt{2} approx 5.657$$

Equal legs mean a ( 45^circ )-( 45^circ )-( 90^circ ) triangle, so the hypotenuse is a leg times ( sqrt{2} ) (see special right triangles).

Example 4: midpoint with negative values

Find the midpoint of ( (-3, 5) ) and ( (2, -7) ).

$$M = left( frac{-3 + 2}{2}, frac{5 + (-7)}{2} right) = left( -frac{1}{2}, -1 right)$$

Example 5: finding a missing endpoint

The midpoint of a segment is ( (4, 6) ) and one endpoint is ( (1, 2) ). Find the other endpoint.

Call it ( (x, y) ). Then ( frac{1 + x}{2} = 4 ) gives ( x = 7 ), and ( frac{2 + y}{2} = 6 ) gives ( y = 10 ). The other endpoint is ( (7, 10) ).

Shortcut: the step from the endpoint to the midpoint is ( (+3, +4) ); take the same step again from the midpoint.

Example 6: fraction and decimal coordinates

Find the distance and midpoint between ( (1.5, -2.5) ) and ( (-2.5, 3.5) ).

Distance calculation:

$$d = sqrt{(-2.5 - 1.5)^2 + (3.5 - (-2.5))^2} = sqrt{(-4)^2 + (6)^2} = sqrt{16 + 36} = sqrt{52} = 2sqrt{13} approx 7.211$$

Midpoint calculation:

$$M = left( frac{1.5 + (-2.5)}{2}, frac{-2.5 + 3.5}{2} right) = left( frac{-1}{2}, frac{1}{2} right) = (-0.5, 0.5)$$

Distance and midpoint calculator

Enter two points to get the distance (in simplified radical form), the midpoint and the slope.

Algebra & Trig#30

Distance & Midpoint

\(d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}\) in simplified radical form, and the midpoint of the segment.

The full-page distance and midpoint calculator has more worked examples.

When these formulas do not apply

The standard distance and midpoint formulas assume a flat, two-dimensional Euclidean plane with Cartesian coordinates ((x, y)). Do not use these standard formulas directly in the following scenarios:

  • Spherical or geographical surfaces: Global positioning system (GPS) calculations use spherical trigonometry (the Haversine formula) because shortest distances on Earth follow curved great-circle paths.
  • Non-Cartesian coordinate systems: Polar coordinates ((r, theta)) or spherical coordinates ((r, theta, phi)) require trigonometric conversion to Cartesian form before applying Euclidean formulas.
  • Grid-constrained paths: City-block navigation or taxicab geometry measures distance as ( |x_2 – x_1| + |y_2 – y_1| ) rather than straight diagonal lines.

Common mistakes and how to fix them

  • Mixing subtraction and addition. Students often add coordinates in the distance formula or subtract coordinates in the midpoint formula. Remember: distance measures coordinate differences (subtraction), while midpoint measures coordinate averages (addition).
  • Distributing the square root across addition. Writing ( sqrt{a^2 + b^2} = a + b ) is algebraically incorrect. For example, ( sqrt{36 + 64} = sqrt{100} = 10 ), but ( sqrt{36} + sqrt{64} = 6 + 8 = 14 ). Always sum the squared terms before taking the square root.
  • Sign errors with negative numbers. When subtracting negative coordinates, convert double negatives to positives: ( x_2 – (-3) = x_2 + 3 ). Wrap negative values in parentheses when substituting.
  • Mixing x- and y-coordinates. Pair x-values with x-values and y-values with y-values. Never subtract or add an x-coordinate to a y-coordinate.
  • Forgetting to divide by 2 in the midpoint formula. Summing coordinates without dividing gives the vector sum, not the average halfway point.

Applications

Is the triangle right-angled?

Points ( A(0, 0) ), ( B(4, 0) ), ( C(4, 3) ). The side lengths are ( AB = 4 ), ( BC = 3 ) and ( AC = sqrt{16 + 9} = 5 ). Since ( 3^2 + 4^2 = 5^2 ), the triangle has a right angle at B.

Two hands holding a yellow measuring tape to measure distance

The equation of a circle

A circle is every point at distance r from a center ( (h, k) ). Write that with the distance formula and square both sides:

$$(x - h)^2 + (y - k)^2 = r^2$$

With center ( (0, 0) ) and ( r = 1 ), that’s ( x^2 + y^2 = 1 ), the unit circle.

Perpendicular bisectors

The perpendicular bisector of a segment passes through its midpoint with slope equal to the negative reciprocal of the segment’s slope. For the segment from ( (1, 2) ) to ( (7, 10) ), the midpoint is ( (4, 6) ) and the slope is ( frac{4}{3} ), so the bisector is ( y – 6 = -frac{3}{4}(x – 4) ). See the slope formula for the line equations.

Distance in three dimensions

Add the z-difference under the root:

$$d = sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

From ( (1, 2, 3) ) to ( (3, 5, 9) ): ( d = sqrt{4 + 9 + 36} = sqrt{49} = 7 ). This is the length of a vector in multivariable calculus. Also, the 3D midpoint averages all three coordinates: ( M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2}, frac{z_1 + z_2}{2} right) ).

Distance in calculus

To measure a curved path, chop it into tiny straight pieces, measure each with the distance formula, and add them up. As the pieces shrink, the sum becomes an integral:

$$L = int_a^b sqrt{1 + left(f'(x)right)^2},dx$$

That’s the arc length formula, and you can evaluate it with the arc length calculator.

Practice problems

  1. Find the distance between ( (2, 3) ) and ( (5, 7) ).
  2. Find the distance between ( (-4, -1) ) and ( (2, 7) ).
  3. Find the distance between ( (0, 0) ) and ( (3, 3) ) in simplest radical form.
  4. Find the midpoint of ( (-6, 2) ) and ( (4, 8) ).
  5. M is the midpoint of AB. If ( A = (-2, 5) ) and ( M = (1, 1) ), find B.
  6. Find the distance between ( (0, 0, 0) ) and ( (2, 3, 6) ).

Step-by-step solutions:

1. ( d = sqrt{(5 – 2)^2 + (7 – 3)^2} = sqrt{3^2 + 4^2} = sqrt{9 + 16} = sqrt{25} = 5 ).

2. ( d = sqrt{(2 – (-4))^2 + (7 – (-1))^2} = sqrt{6^2 + 8^2} = sqrt{36 + 64} = sqrt{100} = 10 ).

3. ( d = sqrt{(3 – 0)^2 + (3 – 0)^2} = sqrt{9 + 9} = sqrt{18} = 3sqrt{2} ).

4. ( M = left( frac{-6 + 4}{2}, frac{2 + 8}{2} right) = left( frac{-2}{2}, frac{10}{2} right) = (-1, 5) ).

5. Set up endpoint equations: ( frac{-2 + x_B}{2} = 1 implies -2 + x_B = 2 implies x_B = 4 ). Next, ( frac{5 + y_B}{2} = 1 implies 5 + y_B = 2 implies y_B = -3 ). Point B is ( (4, -3) ).

6. ( d = sqrt{(2 – 0)^2 + (3 – 0)^2 + (6 – 0)^2} = sqrt{4 + 9 + 36} = sqrt{49} = 7 ).

Frequently asked questions

What is the distance formula?

( d = sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2} ), the distance between two points in the plane.

What is the midpoint formula?

( M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2} right) ), the point halfway between two points.

Is the distance formula the Pythagorean theorem?

Yes. It’s the Pythagorean theorem with the horizontal and vertical differences as the two legs.

Can distance be negative?

No. It’s a square root of a sum of squares, so it’s always zero or positive.

How do you find the midpoint of a line segment?

Add the two x-coordinates and divide by 2, then do the same for the y-coordinates.

Further reading

Calculators for this topic

Leave a comment

Your email address will not be published. Required fields are marked *