The distance between two points is the length of the straight line segment connecting their Cartesian coordinates. Enter two ordered pairs above to calculate the Euclidean distance, see the coordinates substituted into the formula and check the answer on a coordinate graph.
This calculator supports positive values, negative values, decimals and fractions in both 2D and 3D. Coordinate values are treated as abstract units; the tool does not calculate road routes or distances across the curved surface of the Earth.
How to Use the Distance Calculator
- Enter the x- and y-coordinates for Point A and Point B.
- If both points include a z-coordinate, select Enable 3D and enter zā and zā.
- Select Calculate or press Enter to see the exact value, decimal approximation and complete working.
- Use Copy to copy the full solution, or Reset to start again.
Distance Between Two Points Formula
For Point A (xā, yā) and Point B (xā, yā) in a two-dimensional Cartesian plane, the distance formula is:
First find the horizontal difference Īx = xā ā xā and vertical difference Īy = yā ā yā. Square both differences, add them and take the square root. Squaring removes the direction sign, so the final distance is always zero or positive.
Why the Formula Works
The coordinate differences form the two perpendicular legs of a right triangle. The segment joining the points is the hypotenuse. Applying the Pythagorean theorem gives d² = Īx² + Īy², and taking the square root gives the distance. You can explore this relationship further with the Pythagorean Theorem Calculator.
Worked Examples
Example 1: Positive Coordinates
Find the distance between A(1, 2) and B(4, 6).
d = ā[(4 ā 1)² + (6 ā 2)²]
d = ā[3² + 4²] = ā[9 + 16] = ā25 = 5
The two points are 5 units apart.
Example 2: Negative Coordinates
Find the distance between A(ā2, 4) and B(4, ā6).
d = ā[(4 ā (ā2))² + (ā6 ā 4)²]
d = ā[6² + (ā10)²] = ā136 = 2ā34
The exact distance is 2ā34 units, or approximately 11.661904 units.
Example 3: Distance in 3D
Find the distance between A(1, 2, 3) and B(4, 6, 3).
d = ā[(4 ā 1)² + (6 ā 2)² + (3 ā 3)²]
d = ā[3² + 4² + 0²] = ā25 = 5
The two points are 5 units apart.
2D and 3D Distance
| Coordinate space | Formula |
|---|---|
| 2D: (x, y) | d = ā[(xāāxā)² + (yāāyā)²] |
| 3D: (x, y, z) | d = ā[(xāāxā)² + (yāāyā)² + (zāāzā)²] |
The 3D formula adds the squared difference between the z-coordinates. It is useful for points in 3D models, game spaces, engineering drawings and other Cartesian coordinate systems with width, height and depth.
Exact and Decimal Answers
An exact answer keeps a square root when it cannot be simplified to a rational number. For example, ā136 = 2ā34 is exact, while 11.661904 is a rounded decimal approximation. Keeping the exact form prevents rounding errors during later calculations.
Fractions: Enter a fraction with a slash, such as 3/4, or a mixed number such as 1 1/2. The calculator validates the denominator and preserves the exact squared-distance expression.
Distance vs. Midpoint
Distance tells you how far apart two points are, while the midpoint gives the coordinate exactly halfway between them. For points (xā, yā) and (xā, yā), the midpoint is ((xā + xā) Ć· 2, (yā + yā) Ć· 2). In 3D, the z-coordinates are averaged in the same way.
The calculator displays both values so you can analyze the same line segment without entering the coordinates again.
Common Distance Formula Mistakes
- Mixing coordinate types: subtract x from x, y from y and z from z.
- Dropping a negative sign: use parentheses when substituting a negative value, such as 4 ā (ā2).
- Forgetting to square: the formula adds squared coordinate differences, not the raw differences.
- Forgetting the square root: Īx² + Īy² is the squared distance, not the final distance.
- Rounding too early: keep exact values through the working and round only the final decimal approximation.
- Using geographic coordinates: latitude and longitude over the Earth require a geodesic formula, not this flat Cartesian formula.
How to Verify the Answer
- Reverse Point A and Point B. The distance should remain unchanged.
- Square the final distance and check that it equals the sum of the squared coordinate differences.
- Confirm the distance is non-negative and visually reasonable on the graph.
Frequently Asked Questions
Subtract the x-coordinates and y-coordinates, square both differences, add the squared values and take the square root. In 2D, the formula is d = ā[(xāāxā)² + (yāāyā)²].
No. Reversing the points changes the signs of the coordinate differences, but their squares stay the same. The distance from A to B equals the distance from B to A.
No. Distance is always zero or positive. Individual coordinate differences may be negative, but squaring them makes their contribution non-negative.
Yes. You can enter values such as ā3, 2.5, 3/4 or 1 1/2. Fractions must use a slash, and the denominator cannot be zero.
For A(xā,yā,zā) and B(xā,yā,zā), use d = ā[(xāāxā)² + (yāāyā)² + (zāāzā)²]. Select Enable 3D in the calculator to add both z-coordinates.
Not for accurate large-scale geographic distances. Latitude and longitude lie on the Earth's curved surface, so they require a Haversine or geodesic distance calculator rather than this Cartesian formula.
How we calculate: The calculator subtracts corresponding coordinates, squares each difference, adds the squared values and takes the square root. Exact rational arithmetic is preserved for supported inputs, while the decimal result is calculated separately with Math.hypot() for numerical stability.
Last reviewed: July 22, 2026
Enter another pair of coordinates above, copy the complete solution or use the Pythagorean Theorem Calculator to explore the right-triangle relationship behind the formula.