Distance and Midpoint Calculator

  • Free
  • No sign-up
  • Works on phones
  • Shows the working
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.

This distance and midpoint calculator uses two points. It returns the distance, midpoint, and slope. Our distance formula calculator provides exact distances. Square roots simplify; for example, ( sqrt{8} ) becomes ( 2sqrt2 ). A decimal approximation is also given.

It works as a distance formula calculator and a midpoint calculator in one, and it shows the set-up so you can copy the working into your notes. It’s free and needs no sign-up.

Distance formula calculator: The distance between (1, 2) and (4, 6) is 5 (a 3-4-5 right triangle), and the midpoint halfway…
The distance between (1, 2) and (4, 6) is 5 (a 3-4-5 right triangle), and the midpoint halfway between them is (2.5, 4).

How to use the distance formula calculator and midpoint tool

  1. Enter the first point as x₁ and y₁.
  2. Enter the second point as x₂ and y₂. Negative numbers, fractions such as 3/4 and decimals all work.
  3. Press Calculate.
  4. Read the set-up line, the distance ( d ), the midpoint ( M ) and the slope.

Formulas

The distance formula is the Pythagorean theorem applied to the horizontal and vertical gaps between the points:

A green pen on a spiral-bound graph paper notebook.

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

The midpoint formula averages the coordinates:

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

Worked example: a 6-8-10 triangle

Find the distance and midpoint for ( (1, 2) ) and ( (7, 10) ), as loaded above.

Gaps. ( Delta x = 7 – 1 = 6 ) and ( Delta y = 10 – 2 = 8 ).

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

Midpoint. ( M = left( frac{1 + 7}{2}, frac{2 + 10}{2} right) = (4, 6) ).

Slope. ( frac{8}{6} = frac43 ).

Worked example: negative coordinates

For ( (-3, 5) ) and ( (2, -7) ): ( Delta x = 2 – (-3) = 5 ) and ( Delta y = -7 – 5 = -12 ). Squaring removes the sign, so

A calculator, compass, and rulers on a green background.

$$d = sqrt{25 + 144} = sqrt{169} = 13$$

The midpoint is ( left( frac{-3 + 2}{2}, frac{5 + (-7)}{2} right) = left( -frac12, -1 right) ).

Worked example: a simplified root

From ( (0, 0) ) to ( (2, 2) ), ( d = sqrt{4 + 4} = sqrt8 = 2sqrt2 approx 2.828 ). That’s the diagonal of a square with side 2, the ( 45^circ )-( 45^circ )-( 90^circ ) pattern covered in special right triangles.

Tips and common mistakes

  • Adding instead of subtracting. Distance uses differences, ( x_2 – x_1 ). The midpoint uses sums, ( x_1 + x_2 ).
  • Taking the root of each term. ( sqrt{a^2 + b^2} neq a + b ). For the first example, ( 6 + 8 = 14 ), not 10.
  • Forgetting to halve. The midpoint divides each sum by 2.
  • Finding an endpoint from a midpoint. If ( M = (4, 6) ) and one end is ( (1, 2) ), then the other end is ( (2cdot4 – 1, 2cdot6 – 2) = (7, 10) ).

Distance in calculus

Arc length is the distance formula applied to tiny pieces of a curve: each piece has length ( sqrt{(Delta x)^2 + (Delta y)^2} ), and adding them up as the pieces shrink gives ( int_a^b sqrt{1 + f'(x)^2},dx ). See the arc length formula guide and the arc length calculator.

Architectural blueprints with a pencil and a ruler

Distance in three dimensions

Add a third squared difference:

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

From \( (1, 2, 3) \) to \( (4, 6, 15) \): \( \sqrt{9 + 16 + 144} = \sqrt{169} = 13 \).

Finding an endpoint from the midpoint

If \( M \) is the midpoint of \( AB \), then \( B = 2M - A \). With \( M = (3, 4) \) and \( A = (1, 1) \):

$$B = (2 \cdot 3 - 1,\; 2 \cdot 4 - 1) = (5, 7)$$

Check: the midpoint of \( (1, 1) \) and \( (5, 7) \) is \( (3, 4) \).

The perpendicular bisector

The line that cuts a segment in half at right angles passes through the midpoint and has slope \( -1/m \), where \( m \) is the slope of the segment. For \( A = (1, 2) \) and \( B = (5, 6) \): midpoint \( (3, 4) \), slope of \( AB \) = 1, so the bisector has slope −1 and equation \( y - 4 = -(x - 3) \), or \( y = -x + 7 \). Every point on it is equally far from \( A \) and \( B \). See the slope calculator.

Distance from a point to a line

For the line \( ax + by + c = 0 \) and the point \( (x_0, y_0) \):

$$d = \frac{|ax_0 + by_0 + c|}{\sqrt{a^2 + b^2}}$$

From \( (1, 2) \) to \( 3x + 4y - 1 = 0 \): \( |3 + 8 - 1| / 5 = 2 \).

Where it is used

  • Maps and games: straight-line distance between two locations on a grid.
  • Circles: a point is on the circle centred at \( (h, k) \) with radius \( r \) exactly when its distance from the centre is \( r \). See the circle calculator.
  • Statistics and machine learning: “Euclidean distance” between data points is the same formula with more coordinates.

Midpoint in three dimensions

First, average each coordinate. The midpoint of \( (1, 2, 3) \) and \( (5, 8, -1) \) is \( \left(\frac{1 + 5}{2}, \frac{2 + 8}{2}, \frac{3 + (-1)}{2}\right) = (3, 5, 1) \).

Common mistakes to avoid

  • Subtracting coordinates in different orders, for example \( x_2 - x_1 \) but \( y_1 - y_2 \). For the distance it does not matter after squaring, but for slopes and midpoints it does.
  • Forgetting to square negative differences: \( (-6)^2 = 36 \), not −36.
  • Averaging for the distance or subtracting for the midpoint: the midpoint averages the coordinates; the distance uses differences.

Practice problems

  1. Distance between \( (-2, 5) \) and \( (4, -3) \).
  2. Midpoint of \( (-2, 5) \) and \( (4, -3) \).
  3. The midpoint of \( PQ \) is \( (0, 0) \) and \( P = (3, -7) \). Find \( Q \).

Answers: 1. \( \sqrt{36 + 64} = 10 \). 2. \( (1, 1) \). 3. \( (-3, 7) \).

Interpreting Your Results

After entering your coordinates, the distance formula calculator shows three key results. First, you will see the 'Setup' line. This shows the numbers plugged into the distance formula. It helps you check your input and understand the calculation. Next, the 'Distance (d)' appears. This is the length of the straight line segment connecting your two points. It is often given in a simplified square root form. For example, sqrt(18) becomes 3sqrt(2). A decimal approximation is also provided for practical use. Finally, the 'Midpoint (M)' is displayed. This is the exact center point of the segment. Its coordinates are the averages of the x-values and y-values of your original points. Always double-check these values against your own manual calculations if you are learning.

When a Visual Check Helps

Sometimes, a quick sketch can reveal if your calculated distance or midpoint is reasonable. Imagine plotting your two points on a simple coordinate plane. If your points are (1, 1) and (5, 5), the distance should be positive. The midpoint should lie roughly in the middle, around (3, 3). If your points are very far apart, expect a large distance. If they are close, the distance will be small. Similarly, if both x-coordinates are positive, your midpoint's x-coordinate should also be positive. This visual check does not confirm exact answers. However, it quickly flags major errors like negative distances or midpoints far outside the segment.

Related guides

Further reading

FAQ

What is the distance formula?

( d = sqrt{(x_2 – x_1)^2 + (y_2 – y_1)^2} ). It’s the Pythagorean theorem with the horizontal and vertical gaps as the legs.

What is the midpoint formula?

( M = left( frac{x_1 + x_2}{2}, frac{y_1 + y_2}{2} right) ), the average of the x-coordinates and the average of the y-coordinates.

Does the order of the points matter?

No. Squaring removes the sign of each difference, and averaging gives the same midpoint either way.

How do I find distance in 3D?

Add the third gap under the root: ( d = sqrt{(Delta x)^2 + (Delta y)^2 + (Delta z)^2} ). This calculator handles 2D points.

Embed this calculator on your website

Teachers, tutors and bloggers are welcome to use this calculator for free. Copy the code below and paste it into any page (in WordPress, use a "Custom HTML" block). The small script makes the calculator grow to fit its answer; if your site removes scripts, it still works at a fixed height. Please keep the credit link.

More calculators

See all calculators