Math

Distance Formula Calculator

Calculate the straight-line distance between two points in 2D or 3D space using the Euclidean distance formula. Also shows the midpoint.

Point 1

Point 2

Enter coordinates for both points to calculate the distance.

Advertisement

Euclidean Distance Formula

The distance formula is derived from the Pythagorean theorem. Square the difference in each coordinate, sum them, then take the square root.

2D: d = √((x₂ − x₁)² + (y₂ − y₁)²)

3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

Midpoint 2D: ((x₁+x₂)/2, (y₁+y₂)/2)

Euclidean vs Other Distance Metrics

Euclidean distance is the most intuitive notion of distance — the length of the shortest path between two points through open space. It corresponds to what you would measure with a ruler. However, there are other distance metrics used in different contexts.

Manhattan distance (also called taxicab or L1 distance) sums the absolute differences of coordinates without squaring them. It represents the distance travelled on a grid where you can only move horizontally or vertically, like navigating a city block. It is used in some machine learning algorithms and urban planning calculations.

For geographic coordinates on Earth's curved surface, neither Euclidean nor Manhattan distance is appropriate for long distances. The Haversine formula calculates great-circle distance on a sphere, giving the shortest path across the globe's surface. GPS and aviation systems use this for navigation over large distances.

Frequently asked questions

What is the distance formula?
The distance formula calculates the straight-line (Euclidean) distance between two points in a coordinate system. In two dimensions it is derived from the Pythagorean theorem: d = √((x₂ − x₁)² + (y₂ − y₁)²). The difference in each coordinate is squared to eliminate the sign, the squared differences are summed, and the square root produces the actual distance. In three dimensions, a third squared difference for the z-coordinates is added under the square root.
How do I find the distance between two points step by step?
To find the distance between points (x₁, y₁) and (x₂, y₂): first subtract x₁ from x₂ to get the horizontal difference; then subtract y₁ from y₂ to get the vertical difference; square both differences; add the two squared values together; and finally take the square root of the sum. For example, the distance between (1, 2) and (4, 6) is √((4−1)² + (6−2)²) = √(9 + 16) = √25 = 5.
What is the 3D distance formula?
The three-dimensional distance formula extends the 2D formula by adding a z-axis component: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). It calculates the straight-line distance through 3D space between two points. This formula is used in physics, 3D computer graphics, engineering, and navigation systems where elevation or depth is a relevant dimension.
What is the midpoint formula?
The midpoint formula finds the exact centre of a line segment connecting two points. In 2D, the midpoint is ((x₁ + x₂) / 2, (y₁ + y₂) / 2) — the average of the x-coordinates and the average of the y-coordinates. In 3D, a third component (z₁ + z₂) / 2 is added. The midpoint is equidistant from both endpoints and lies exactly halfway along the segment.
How is the distance formula related to the Pythagorean theorem?
The distance formula is a direct application of the Pythagorean theorem. When you draw a horizontal and vertical line from one point to create a right triangle, the horizontal leg has length |x₂ − x₁|, the vertical leg has length |y₂ − y₁|, and the hypotenuse — the direct distance between the two points — has length √((x₂ − x₁)² + (y₂ − y₁)²). This is exactly the Pythagorean theorem a² + b² = c², solved for c.
Where is the distance formula used in real life?
The distance formula has practical applications in GPS and navigation systems, where it is used to calculate straight-line distances between geographic coordinates. Computer graphics and game development use it for collision detection, pathfinding algorithms, and rendering. Robotics and engineering use it for motion planning. Data science uses Euclidean distance in clustering algorithms like k-means and nearest-neighbour classifiers. Any system that needs to measure proximity or separation in spatial data relies on this formula.