The distance between two points (x1, y1) and (x2, y2) is d = √(x2 − x1)2 + (y2 − y1)2. Subtract the x-coordinates, subtract the y-coordinates, square both differences, add them and take the square root. This distance formula calculator does exactly that, shows each line of the working and plots both points on a coordinate grid.
How to use the distance calculator
- Choose 2D or 3D. Points on a flat graph have two coordinates, (x, y). Points in space, such as the corners of a box or positions in a video game, have three, (x, y, z).
- Type the coordinates of point A and point B. Negative numbers, decimals and fractions all work. It does not matter which point you call A.
- Read the distance. When the answer is a whole number you get it exactly. Otherwise you get the simplest radical form, such as 2√13, followed by the decimal.
- Check the extras. The tiles show the horizontal change Δx, the vertical change Δy, the midpoint of the segment and, in 2D, its slope. The graph rescales itself, so points far from the origin still fit.
The distance formula is the Pythagorean theorem
Draw a horizontal line from A and a vertical line from B. They meet at a right angle, so the segment AB is the hypotenuse of a right triangle. The horizontal leg has length |x2 − x1| and the vertical leg has length |y2 − y1|. The Pythagorean theorem, a2 + b2 = c2, then gives the distance directly.
The squares are why the formula never needs absolute-value bars: (−6)2 and 62 are both 36, so it makes no difference if you subtract A from B or B from A. In three dimensions you add one more squared difference:
d = √(x2 − x1)2 + (y2 − y1)2 + (z2 − z1)2That version comes from using the theorem twice, once across the floor of a box and once up to the opposite corner. The 3D Pythagorean theorem lesson draws it out, and the full derivation of the 2D formula is on the distance formula page.
Worked examples
Example 1: a whole-number answer
Find the distance between (1, 2) and (7, 10).
d= √(7 − 1)2 + (10 − 2)2= √62 + 82 = √36 + 64 = √100 = 10The distance is 10. The legs 6 and 8 are the 3-4-5 triangle doubled.
Example 2: negative coordinates
Find the distance between (−3, 4) and (2, −8).
d= √(2 − (−3))2 + (−8 − 4)2= √52 + (−12)2 = √25 + 144 = √169 = 13The distance is 13. Subtracting a negative means adding: 2 − (−3) = 5.
Example 3: a radical answer
Find the distance between (−2, 1) and (4, 5), the example loaded in the calculator.
d= √62 + 42 = √36 + 16 = √52= √4 · 13 = 2√13 ≈ 7.2111The exact distance is 2√13, about 7.21. The square root simplifier shows how √52 becomes 2√13.
Example 4: two points in 3D
Find the distance between (1, 2, 3) and (4, 6, 15).
d= √32 + 42 + 122 = √9 + 16 + 144 = √169 = 13The distance is 13. Switch the calculator to 3D to see this as the diagonal of a 3 × 4 × 12 box.
Example 5: decimals
Find the distance between (0.5, 1.5) and (2, 3.5).
d = √1.52 + 22 = √2.25 + 4 = √6.25 = 2.5The distance is exactly 2.5.
More practice, with answers, is on the distance formula worksheet.
Midpoint and slope
Two more facts about a segment come from the same subtraction, so the calculator shows them as well.
- Midpoint: average the coordinates, M = (x1 + x2 over 2, y1 + y2 over 2). For (1, 2) and (7, 10) the midpoint is (4, 6). It is marked with a small ring on the graph. In 3D you average the z-coordinates too.
- Slope: rise over run, m = y2 − y1 over x2 − x1 = Δy over Δx. For the same points it is 8 over 6 = 4 over 3. A horizontal segment has slope 0. A vertical one has an undefined slope, because Δx = 0 and you cannot divide by zero.
TipThe distance and the slope use the same two differences. Distance squares and adds them; slope divides one by the other. If you have already worked out Δx and Δy for one, you are halfway to the other.
Common mistakes
- Squaring a negative wrongly. (−12)2 = 144, not −144. A calculator typed as
-12^2gives −144, so use brackets. - Mixing coordinates. Subtract x from x and y from y. Writing x2 − y1 is the most common slip.
- Taking the root too early. √36 + 16 is not 6 + 4. Add first, then take one square root. The common mistakes page explains why √a2 + b2 ≠ a + b.
- Forgetting the root. d2 = 52 is not the distance. The distance is √52.
Straight-line distance versus walking distance
The distance formula measures the straight line between the points, often called the Euclidean distance or the distance "as the crow flies". On a street grid you usually cannot walk that line. You walk along the legs instead, which is always longer unless the points share a coordinate.
The walking route, |Δx| + |Δy|, is sometimes called the taxicab or Manhattan distance. Both measures are used in practice. Delivery routing on a grid of streets cares about the walking distance; a drone, a radio signal or a ship crossing open water cares about the straight line.
Where the distance formula is used
- Maps and navigation. On a local map with a square grid, the distance between two grid references is a direct application. Over long distances on the curved Earth, navigators use spherical formulas instead, as explained on the Pythagorean theorem on a sphere page.
- Video games and graphics. Games check whether a character is within range of an object by computing the distance between their coordinates, often many times a second. See the Pythagorean theorem in computer science.
- Physics. The size of a displacement or a velocity with components vx and vy is √vx2 + vy2, the same calculation. More on the physics page.
- Circles. Every point at distance r from the center (h, k) satisfies (x − h)2 + (y − k)2 = r2, which is the distance formula squared. That is the equation of a circle.
Frequently asked questions
What is the distance formula?
For points (x1, y1) and (x2, y2), the distance is d = √(x2 − x1)2 + (y2 − y1)2. It is the Pythagorean theorem applied to the right triangle whose legs are the horizontal and vertical gaps between the points.
Does it matter which point is first?
No. Swapping the points changes the sign of each difference, but squaring removes the sign, so you get the same distance. The slope is also unchanged, because both the rise and the run change sign.
Can a distance be negative?
No. You add two squares, which are never negative, and take the positive square root. The smallest possible distance is 0, which happens only when the two points are the same.
How do you find the distance between two points in 3D?
Add a third squared difference for the z-coordinates: d = √(Δx)2 + (Δy)2 + (Δz)2. For (0, 0, 0) and (2, 3, 6) that is √4 + 9 + 36 = √49 = 7. Choose 3D in the calculator to work in space.
Why is my answer a square root instead of a decimal?
When Δx2 + Δy2 is not a perfect square, the exact distance is irrational, so any decimal is only an approximation. Teachers usually want the exact form, such as 3√5. The calculator gives both, and you can choose how many decimal places to round to.
Can I use this for latitude and longitude?
Only roughly, and only for short distances. Degrees of longitude get shorter as you move away from the equator, and the Earth is curved, so for real map coordinates you need a spherical distance formula. For points on a flat grid or a scale drawing, the distance formula is exact.
Keep exploring
- LearnThe Distance FormulaThe distance formula explained: derive it from the Pythagorean theorem, use it with negative coordinates, avoid sign mistakes and extend it to 3D.
- Calculators3D Pythagorean Theorem CalculatorFind the space diagonal of a box from its length, width and height, or a missing side from the diagonal, with steps, exact answers and face diagonals.
- PracticeDistance Formula WorksheetPrintable distance formula worksheet: 12 Pythagorean theorem coordinate plane problems on grids, from whole numbers to radicals, with a worked answer key.
- LearnEquation of a Circle and the Pythagorean TheoremWhy the equation of a circle, x² + y² = r², is the Pythagorean theorem, plus the center-radius form, worked examples and the inside/outside test.
- Real-life usesThe Pythagorean Theorem in Navigation and GPSHow the Pythagorean theorem is used in navigation: map distances, ship and plane displacement, wind triangles, GPS trilateration and the limits of flat maps.
- CalculatorsSimplify Square Root CalculatorSimplify any square root to simplest radical form, with the prime factorization, a factor tree and every step. Works for √n and k√n and gives the decimal.