Distance Between Two Points Calculator
Compute the straight-line distance between two points using the distance formula. Works in 2D and 3D, shows step-by-step working, gives the exact radical form when possible, and reports the midpoint, Δx, Δy, slope and angle. Up to 5 point pairs can be solved at once.
What Is the Distance Formula?
The distance formula gives the straight-line distance between two points in a coordinate plane. If P₁ = (x₁, y₁) and P₂ = (x₂, y₂), the distance between them is:
It's a direct consequence of the Pythagorean theorem. The horizontal change Δx = x₂ − x₁ and the vertical change Δy = y₂ − y₁ form the two legs of a right triangle, and the distance d is the hypotenuse.
The 3D Distance Formula
In three-dimensional space, the formula gains a third term:
The logic is identical — add the square of the third difference and take the square root. This is the Euclidean distance between two points in ℝ³.
Worked Example
Find the distance between P₁ = (0, 0) and P₂ = (3, 4).
- Compute the differences: Δx = 3 − 0 = 3 and Δy = 4 − 0 = 4.
- Square each: Δx² = 9 and Δy² = 16.
- Add: d² = 9 + 16 = 25.
- Take the square root: d = √25 = 5.
This is the classic 3-4-5 right triangle — the simplest Pythagorean triple.
Exact Radical Form
Many distances come out as square roots that do not simplify to a whole number. The exact form pulls out perfect-square factors. For example, the distance between (0, 0) and (1, 1) is √2 ≈ 1.4142; between (0, 0) and (2, 2) it is √8 = 2√2 ≈ 2.8284. The calculator shows both the exact radical and a decimal rounded to your chosen precision.
Midpoint of a Segment
The midpoint of the segment connecting P₁ and P₂ is simply the average of the coordinates:
M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2)
In 3D, also average the z-coordinates. The midpoint is exactly halfway along the distance you just computed, so it is a useful cross-check.
Slope and Angle
In 2D, the same Δx and Δy that appear in the distance formula also define the slope of the line through the two points:
m = Δy / Δx (undefined when Δx = 0)
The angle the segment makes with the positive x-axis is θ = atan2(Δy, Δx), reported here in degrees between −180° and 180°.
Real-World Uses
- Navigation and GPS: straight-line distance between two coordinates.
- Computer graphics: distance between pixels, vertices, or objects.
- Architecture and construction: diagonal measurements and layout.
- Physics: magnitude of displacement between two positions.
- Data science: Euclidean distance in clustering and nearest-neighbour search.
Assumptions and Limitations
- Coordinates must be real numbers. Both coordinates of each point are required.
- The diagram is drawn only in 2D mode; 3D results show a table instead.
- Exact radical form is shown when the squared distance simplifies to a rational number with a manageable denominator; otherwise only the decimal is shown.
- Up to 5 point pairs can be solved in one batch.
❓ Distance Formula FAQ
What is the distance formula between two points?
In a plane, d = √((x₂−x₁)² + (y₂−y₁)²). In 3D space, add the square of the z-difference: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²).
How do you find the distance between (0,0) and (3,4)?
d = √((3−0)² + (4−0)²) = √(9 + 16) = √25 = 5. This is the 3-4-5 right triangle.
What is the midpoint formula?
M = ((x₁+x₂)/2, (y₁+y₂)/2). In 3D, also average the z-coordinates. The midpoint is halfway along the segment.
How does the distance formula relate to the Pythagorean theorem?
The horizontal and vertical differences Δx and Δy form the legs of a right triangle, and the distance d is the hypotenuse. So d² = Δx² + Δy² — exactly the Pythagorean theorem applied to the coordinate plane.
Can the distance be zero?
Yes — when the two points are identical, all coordinate differences are zero and so is the distance. Two distinct points always have a positive distance.
Can coordinates be negative or decimal?
Yes. The formula works with any real-number coordinates. Only the differences are squared, so signs cancel out automatically.
What is the 3D distance formula?
d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). It's the same as the 2D formula with a third squared difference added.
How is the distance formula used in real life?
In navigation and GPS for straight-line distances, in architecture for diagonals, in computer graphics for pixel distances, in physics for displacement magnitudes, and in machine learning for Euclidean-distance algorithms.