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.
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)$:
- Subtract the x-coordinates: $x_2 - x_1$
- Subtract the y-coordinates: $y_2 - y_1$
- Square both results
- Add the squared values together
- 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}$.