The distance formula is the Pythagorean theorem applied to coordinates. It measures how far apart two locations are on a map grid, in 3D space or in data with several features.
How to use the Distance Between Two Points Calculator
- Dimensions
- x₁
- y₁
- z₁
- w₁
- x₂
- y₂
- z₂
- w₂
Results update as you type, and everything is calculated in your browser.
How it works
Subtract the coordinates, square the differences, add them and take the square root. In 1D this is simply |x₂ − x₁|.
Inputs explained
| Field | What to enter |
|---|---|
| Dimensions | Choose one: 1D, 2D, 3D, 4D |
| x₁ | A number |
| y₁ | A number |
| z₁ | A number |
| w₁ | A number |
| x₂ | A number |
| y₂ | A number |
| z₂ | A number |
| w₂ | A number |
Example values
How the main result changes when x₁ changes and everything else stays at the example values above:
| x₁ | Distance |
|---|---|
| 0.5 | 5.3151 |
| 0.75 | 5.1539 |
| 1 | 5 |
| 1.25 | 4.8541 |
| 1.5 | 4.717 |
| 2 | 4.4721 |
Formula
d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)² + (w₂ − w₁)²]
Worked example
Inputs: Dimensions: 2D; x₁: 1; y₁: 2; x₂: 4; y₂: 6.
Results: Distance = 5; Squared distance = 25; Manhattan distance (for comparison) = 7.
Key terms
- Euclidean distance
- The straight-line distance between two points.
Frequently asked questions
What is the distance between (1, 2) and (4, 6)?
√(3² + 4²) = 5.
Where does the formula come from?
The Pythagorean theorem on the right triangle formed by the coordinate differences.
Does the order of the points matter?
No. The differences are squared.
What is the distance on a sphere?
Use the great circle distance instead.