Distance formula calculator
A distance formula calculator finds how far apart two points are on a coordinate grid. The distance formula is d = √((x₂ − x₁)² + (y₂ − y₁)²): Pythagoras on the horizontal and vertical gaps between the points. Type two points into our Midpoint and Distance Calculator and it gives the distance exactly, such as √85, with the decimal and every step.
The distance is always in the answer, labelled Distance, so there is nothing to switch. The same two points also give the midpoint, the slope and the equation of the line.
Midpoint and Distance Calculator
Find the midpoint, distance and gradient between two points
How to use the distance formula calculator
- In the Points section, type the x and y coordinates of point A, then of point B. Negatives and decimals both work.
- Or drag A and B on the coordinate plot. They snap to the grid.
- Read Distance in the answer. If the distance is not a whole number, it is written as a simplified surd with a decimal alongside, such as 6√2 ≈ 8.48528.
- Follow the working: find the run and the rise, square, add and take the square root, then simplify the surd.
The plot draws the right triangle between the two points, with the run and the rise labelled, which is exactly what the distance formula uses. For practice, Practice and help sets random distance, midpoint and slope questions with worked solutions.
The distance formula
For two points (x₁, y₁) and (x₂, y₂):
It is the Pythagorean theorem in disguise. The horizontal gap x₂ − x₁ and the vertical gap y₂ − y₁ are the two legs of a right triangle, and the distance is its hypotenuse.
Worked examples you can check in the calculator
Example 1: a whole-number distance
Find the distance between A(2, 1) and B(8, 9), the points in the diagram.
Type 2 and 1 for A and 8 and 9 for B: the calculator shows Distance 10.
Example 2: negative coordinates
Find the distance between (−3, 5) and (4, −1). Put brackets round the negatives:
85 has no square factor, so √85 is already simplified, about 9.22. The calculator gives √85 ≈ 9.21954.
Example 3: simplifying the surd
Find the distance between (−2, −3) and (4, 3). The run and rise are both 6:
The calculator gives 6√2 ≈ 8.48528. Exact answers matter in many tests, so leave the surd unless the question asks for a decimal.
Example 4: decimal coordinates
Find the distance between (1.5, −2) and (4, 4). The run is 2.5 and the rise is 6, so d = √(6.25 + 36) = √42.25 = 6.5. The calculator works in exact fractions and shows it as 13/2.
Now try one yourself:
Using the distance formula in geometry
Example 5: what kind of triangle?
A triangle has corners P(1, 1), Q(4, 5) and R(8, 2). Find the length of each side by running each pair of points through the calculator:
- PQ = √(3² + 4²) = √25 = 5
- QR = √(4² + (−3)²) = √25 = 5
- PR = √(7² + 1²) = √50 = 5√2, about 7.07
Two sides are equal, so the triangle is isosceles. And 5² + 5² = 50 = PR², so by the converse of Pythagoras it also has a right angle at Q. Checking side lengths like this is a common way to prove what shape a set of points makes.
Example 6: distance on a map grid
On a map grid where each square is 2 km, a town is at (−3, 4) and a lighthouse at (9, −1). The gaps are 12 squares across and 5 down, so the distance is √(144 + 25) = 13 squares, which is 13 × 2 = 26 km in a straight line. Work in grid squares first, then convert to real units at the end.
3D distance formula
In three dimensions, add the z gap as well:
This calculator works in 2D. For a 3D distance, find the three gaps and use the Vector Calculator in 3D mode: type the gaps as one vector and its magnitude is the distance. For (1, 2, 3) to (3, 5, 9), the gaps are 2, 3 and 6, so the distance is √(4 + 9 + 36) = 7.
Distance, midpoint and slope
The same two points give three different things, and the calculator shows all of them:
| Measure | Formula | For (2, 1) and (8, 9) |
|---|---|---|
| Distance | √((x₂ − x₁)² + (y₂ − y₁)²) | 10 |
| Midpoint | ((x₁ + x₂)/2, (y₁ + y₂)/2) | (5, 5) |
| Slope | (y₂ − y₁)/(x₂ − x₁) | 4/3 |
Our midpoint calculator guide and slope calculator guide cover the other two, and the Pythagorean theorem calculator guide explains the theorem behind the distance formula.
Common mistakes
- Adding the gaps instead of using Pythagoras. The distance from (2, 1) to (8, 9) is 10, not 6 + 8 = 14.
- Losing a negative. 4 − (−3) is 7. Put brackets round negative coordinates before subtracting.
- Squaring a negative wrongly. (−6)² is 36, never −36. A squared gap is always positive.
- Forgetting the square root. √(36 + 64) is 10, not 100.
- Taking the root of each part. √(36 + 64) is not √36 + √64 = 14.
Practise coordinate geometry in a short timed paper
The distance formula comes up in Geometry, Algebra 2 & SAT Math and Pre-Algebra & Algebra 1 practice, and in GCSE Maths Higher in the UK. Each daily paper is a short timed paper of 8 questions worth 25 to 35 marks, and the papers mix topics.
Common questions
What is the distance formula?
How do you find the distance between two points?
Is the distance formula the same as the Pythagorean theorem?
Does it matter which point is first?
Can the distance be negative?
Can the calculator find the distance between latitude and longitude points?
Revision cards
Say the answer first, then flip the card to check it.
Where to go next
- Solve it
Midpoint and Distance Calculator
Find the midpoint, distance and gradient between two points
Open the tool - Learn it
Graphing Functions
Graphing made easier: the patterns in numbers and functions used across STEM
Start the course - Test it
Geometry, Algebra 2 & SAT Math
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper