Distance Formula

If you know the coordinates of two opposite corners of a rectangular park, how do you find the exact length of the diagonal path between them without a tape measure? The distance formula solves this by turning the x and y values into a straight-line length.

For any two points $A(x_1, y_1)$ and $B(x_2, y_2)$ on a coordinate plane, the distance formula is:

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

The result $d$ is the Euclidean distance – the shortest possible straight line between the points.

Mode
Point A
Point B
Step-by-step breakdown

The calculator above accepts the x and y coordinates for both points, squares the horizontal and vertical differences, adds them, and returns the square root. You can use it to check your manual calculations or to solve geometry problems quickly.

What Is the Distance Formula?

The distance formula is a coordinate geometry equation that calculates the length of a line segment connecting two points. It comes directly from the Pythagorean theorem. If you draw a right triangle using the segment as the hypotenuse, the horizontal leg equals $|x_2 - x_1|$ and the vertical leg equals $|y_2 - y_1|$.

Replacing $a$ and $b$ in $a^2 + b^2 = c^2$ with those coordinate differences gives the standard form.

How Do You Calculate the Distance Formula?

Follow these steps to find the distance between $(x_1, y_1)$ and $(x_2, y_2)$:

  1. Subtract the x-coordinates: $x_2 - x_1$
  2. Subtract the y-coordinates: $y_2 - y_1$
  3. Square both results
  4. Add the squared values together
  5. Take the square root of the sum

The final value is always zero or positive. Zero occurs only when both points share the exact same coordinates.

Example in 2D

Find the distance between $P(3, 4)$ and $Q(6, 8)$.

  • Difference in x: $6 - 3 = 3$
  • Difference in y: $8 - 4 = 4$
  • Sum of squares: $3^2 + 4^2 = 9 + 16 = 25$
  • Square root: $\sqrt{25} = 5$

The distance is 5 units.

Distance Formula in Three Dimensions

The same logic extends to 3D space. For points $A(x_1, y_1, z_1)$ and $B(x_2, y_2, z_2)$, add the z-difference squared:

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

3D Example

Calculate the distance between $(1, 2, 3)$ and $(4, 6, 8)$.

  • $\Delta x = 4 - 1 = 3$
  • $\Delta y = 6 - 2 = 4$
  • $\Delta z = 8 - 3 = 5$
  • $d = \sqrt{3^2 + 4^2 + 5^2} = \sqrt{9 + 16 + 25} = \sqrt{50} \approx 7.07$

The distance is roughly 7.07 units.

Special Cases

Horizontal line: If $y_1 = y_2$, the vertical drop is zero and the formula reduces to $d = |x_2 - x_1|$.

Vertical line: If $x_1 = x_2$, the horizontal run is zero and the formula reduces to $d = |y_2 - y_1|$.

Distance from origin: To find how far a point $(x, y)$ is from $(0, 0)$, simply set $(x_1, y_1) = (0, 0)$. The formula becomes $d = \sqrt{x^2 + y^2}$.

Frequently Asked Questions

Why is the distance formula important in geometry?
It gives an exact numeric value for the straight-line separation between any two points on a coordinate plane. Engineers, architects, and game developers use it to compute lengths without physical measurement.
Can the distance formula handle vertical or horizontal lines?
Yes. For a horizontal line the y-values are equal, so the vertical difference drops to zero. For a vertical line the x-values are equal, leaving only one squared term under the square root.
How is the distance formula different from the Pythagorean theorem?
The Pythagorean theorem relates the three sides of a right triangle. The distance formula is a direct application of that theorem to coordinate geometry, where the legs are the differences in x and y coordinates.
Does the order of points matter in the distance formula?
No. Because each coordinate difference is squared, subtracting point A from point B produces the same result as subtracting point B from point A.
What is the 3D version of the distance formula?
In three dimensions the formula adds a z-term: d equals the square root of x-difference squared plus y-difference squared plus z-difference squared. It extends the same logic into space.
Can the distance formula give a negative result?
No. A square root always returns a non-negative value, and the squared differences are always positive or zero. The smallest possible output is zero, which occurs only when both points are identical.
  1. Point Slope Form Calculator
  2. Pythagoras Rule Calculator
  3. Theorem Pythagoras Calculator
  4. Percentage Calculator: Free Online Percent Calculation Tool
  5. Algebra Calculator – Solve Equations Step by Step
  6. Square Footage Calculator