Distance Formula Calculator

The distance formula d = sqrt((x2 - x1)^2 + (y2 - y1)^2) calculates the straight-line (Euclidean) distance between two points in 2D space. It extends to 3D with d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). Both formulas are direct applications of the Pythagorean theorem. For example, the distance between (1, 2) and (4, 6) is sqrt(9 + 16) = sqrt(25) = 5. Enter the coordinates of two points below, and toggle between 2D and 3D mode to see the distance, midpoint, and coordinate differences.

Quick Answer

The distance between points (1, 2) and (4, 6) is sqrt((4-1)^2 + (6-2)^2) = sqrt(9 + 16) = sqrt(25) = 5.

Point 1

Point 2

Common Examples

Input Result
(1, 2) to (4, 6) Distance: 5
(0, 0) to (3, 4) Distance: 5
(-2, 3) to (1, 7) Distance: 5
(1, 2, 3) to (4, 6, 3) Distance: 5 (3D)
(0, 0, 0) to (1, 2, 2) Distance: 3 (3D)

How It Works

The Distance Formula (2D)

The distance between two points (x1, y1) and (x2, y2) in a two-dimensional plane is:

d = sqrt((x2 - x1)^2 + (y2 - y1)^2)

This formula is derived from the Pythagorean theorem. The horizontal difference (x2 - x1) and vertical difference (y2 - y1) form the two legs of a right triangle, and the distance is the hypotenuse.

The Distance Formula (3D)

For three-dimensional space, with points (x1, y1, z1) and (x2, y2, z2):

d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)

This is a natural extension of the 2D formula, adding the squared difference in the z-coordinate. It applies the Pythagorean theorem twice: once in the xy-plane and once along the z-axis.

Midpoint Formula

The midpoint between two points is the average of their coordinates:

2D midpoint: ((x1 + x2)/2, (y1 + y2)/2)

3D midpoint: ((x1 + x2)/2, (y1 + y2)/2, (z1 + z2)/2)

The midpoint lies exactly halfway between the two points along the straight line connecting them.

Worked Example

Find the distance between (1, 2) and (4, 6).

Compute the differences: x2 - x1 = 4 - 1 = 3 and y2 - y1 = 6 - 2 = 4.

Square each difference: 3^2 = 9 and 4^2 = 16.

Sum: 9 + 16 = 25. Take the square root: sqrt(25) = 5.

The distance is 5 units. The midpoint is ((1+4)/2, (2+6)/2) = (2.5, 4).

For a 3D example, the distance from (0, 0, 0) to (1, 2, 2) is sqrt(1 + 4 + 4) = sqrt(9) = 3.

Related Calculators

Frequently Asked Questions

How is the distance formula related to the Pythagorean theorem?
The distance formula is a direct application of the Pythagorean theorem. The horizontal and vertical differences between two points form the legs of a right triangle, and the distance between the points is the hypotenuse. The formula d = sqrt(dx^2 + dy^2) is equivalent to c = sqrt(a^2 + b^2).
Can the distance be negative?
No. Distance is always non-negative because it involves squaring the differences (which removes any negative signs) and then taking the square root. The minimum distance between two points is 0, which occurs when the two points are identical.
What is the difference between distance and displacement?
Distance is a scalar (magnitude only), measuring the total length of the path between two points. Displacement is a vector with both magnitude and direction. The distance formula calculates the magnitude of the displacement vector between two points.
Does this calculator work for points with negative coordinates?
Yes. The formula works for any real-valued coordinates, including negative numbers. For instance, the distance from (-3, -4) to (0, 0) is sqrt(9 + 16) = 5.
What is the midpoint used for?
The midpoint is useful for finding the center of a line segment, constructing perpendicular bisectors, and dividing shapes into equal halves. In applied contexts, it can represent the average position between two locations.