The distance between two points on a two-dimensional coordinate plane is the length of the straight line connecting them.
For two points:
Point 1 = (x₁, y₁)
Point 2 = (x₂, y₂)
the distance is:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
This is the Euclidean distance formula. It works for points on a flat Cartesian plane.
If your points are latitude and longitude coordinates on Earth, use the Distance Calculator instead because geographic coordinates require a curved-Earth calculation.
What Is the Distance Between Two Points?
The distance between two points is the length of the straight line segment joining them.
On a Cartesian coordinate plane, each point has an x-coordinate and a y-coordinate:
Point 1 = (x₁, y₁)
Point 2 = (x₂, y₂)
The horizontal difference is:
x₂ − x₁
The vertical difference is:
y₂ − y₁
These two differences form the perpendicular sides of a right triangle. The line connecting the original points is the hypotenuse.
That relationship produces the distance formula.
What Is the Formula for Distance Between Two Points?
The standard formula is:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
Where:
| Symbol | Meaning |
|---|---|
| Distance | Straight-line distance between the two points |
| x₁ | x-coordinate of Point 1 |
| y₁ | y-coordinate of Point 1 |
| x₂ | x-coordinate of Point 2 |
| y₂ | y-coordinate of Point 2 |
The formula measures Euclidean distance, which is the shortest straight-line distance between two points on a flat plane.
For a broader explanation of different mathematical distance methods, see our Distance Formula guide.
How Do You Calculate the Distance Between Two Points?
To calculate the distance:
- Subtract the x-coordinates.
- Subtract the y-coordinates.
- Square both differences.
- Add the squared values.
- Take the square root.
For example, calculate the distance between:
A = (1, 2)
B = (4, 6)
Step 1: Find the x-coordinate difference
4 − 1 = 3
Step 2: Find the y-coordinate difference
6 − 2 = 4
Step 3: Square both differences
3² = 9
4² = 16
Step 4: Add the squared values
9 + 16 = 25
Step 5: Take the square root
Distance = √25
Distance = 5 units
So, the distance between (1, 2) and (4, 6) is:
5 units
Why Does the Distance Formula Work?
The distance formula comes from the Pythagorean theorem.
For a right triangle:
c² = a² + b²
The horizontal difference between the coordinates acts as one side of the triangle:
a = x₂ − x₁
The vertical difference acts as the other side:
b = y₂ − y₁
The straight line connecting the two points is the hypotenuse:
c = Distance
Substituting those values gives:
Distance² = (x₂ − x₁)² + (y₂ − y₁)²
Taking the square root gives:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
Our Euclidean Distance Formula guide explains this relationship in more detail.
Example With Negative Coordinates
The same formula works when one or both points contain negative values.
Suppose:
A = (−3, −1)
B = (2, 3)
Use the formula:
Distance = √[(2 − (−3))² + (3 − (−1))²]
Simplify the differences:
Distance = √(5² + 4²)
Square the values:
Distance = √(25 + 16)
Add them:
Distance = √41
Final result:
Distance ≈ 6.40 units
The distance between (−3, −1) and (2, 3) is approximately 6.40 units.
A common mistake is forgetting that subtracting a negative value becomes addition:
2 − (−3) = 5
Example With Decimal Coordinates
Decimal coordinates use the same formula.
Suppose:
A = (1.5, 2.5)
B = (5.5, 5.5)
Calculate the differences:
5.5 − 1.5 = 4
5.5 − 2.5 = 3
Apply the formula:
Distance = √(4² + 3²)
Distance = √(16 + 9)
Distance = √25
Distance = 5 units
So, the points are exactly 5 units apart.
What Happens If Both Points Are the Same?
The distance is 0.
For example:
A = (4, 7)
B = (4, 7)
Then:
Distance = √[(4 − 4)² + (7 − 7)²]
Distance = √(0² + 0²)
Distance = √0
Distance = 0
Identical coordinates describe the same position, so there is no distance between them.
What If the Points Have the Same x-Coordinate?
If both points have the same x-coordinate, the distance is simply the vertical difference between the y-values.
For example:
A = (3, 2)
B = (3, 9)
Apply the formula:
Distance = √[(3 − 3)² + (9 − 2)²]
Distance = √(0 + 7²)
Distance = √49
Distance = 7 units
You can also write this special case as:
Distance = |y₂ − y₁|
What If the Points Have the Same y-Coordinate?
If both points have the same y-coordinate, the distance is simply the horizontal difference between the x-values.
For:
A = (2, 5)
B = (10, 5)
Calculate:
Distance = √[(10 − 2)² + (5 − 5)²]
Distance = √(8² + 0)
Distance = √64
Distance = 8 units
This special case can also be written as:
Distance = |x₂ − x₁|
Does the Order of the Two Points Matter?
No. Reversing the two points gives the same distance.
Suppose:
x₂ − x₁ = 5
If you reverse the order:
x₁ − x₂ = −5
But:
5² = 25
and:
(−5)² = 25
So both orders give the same result.
In mathematical form:
Distance(A, B) = Distance(B, A)
Distance has magnitude, not direction, so the order of the points does not change the answer.
Can the Distance Between Two Points Be Negative?
No. Distance cannot be negative.
The coordinate differences can be negative, but they are squared before they are added.
For example:
(−4)² = 16
The square root of a nonnegative value is also nonnegative.
Therefore:
- distance is greater than 0 when the points are different;
- distance is 0 when both points are identical.
A distance value cannot be less than 0.
What Units Does the Distance Formula Use?
The result uses the same underlying unit as the coordinate system.
If the x- and y-values are measured in meters, the result is in meters.
If the coordinate system uses feet, the result is in feet.
If no physical unit is specified, report the answer simply as:
units
For example:
Distance = 5 units
The x- and y-axes should use compatible units for an ordinary Euclidean distance calculation.
How Do You Calculate Distance Between Two Points in 3D?
For three-dimensional Cartesian coordinates, add the difference between the z-values.
For:
Point 1 = (x₁, y₁, z₁)
Point 2 = (x₂, y₂, z₂)
the formula is:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]
For example:
A = (1, 2, 3)
B = (4, 6, 3)
Calculate:
Distance = √[(4 − 1)² + (6 − 2)² + (3 − 3)²]
Distance = √(3² + 4² + 0²)
Distance = √(9 + 16)
Distance = √25
Distance = 5 units
This is the three-dimensional extension of the Euclidean distance formula.
Is the Distance Formula the Same for Latitude and Longitude?
No. Latitude and longitude should not normally be treated as ordinary x- and y-coordinates for geographic distance calculations.
The Euclidean formula assumes a flat plane:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
Latitude and longitude describe positions on Earth's curved surface.
For geographic coordinates, a method such as the Haversine formula is more appropriate because it accounts for the curvature of the Earth.
Our Distance Calculator uses latitude and longitude coordinates with a spherical Haversine calculation.
For example:
New York City: 40.7128, −74.0060
Los Angeles: 34.0522, −118.2437
Using the site's geographic calculator gives approximately:
2,445.56 miles
Do not enter those latitude and longitude values into the ordinary Euclidean distance formula and interpret the result as miles.
For a detailed explanation, read our Haversine Formula guide.
Euclidean Distance vs Geographic Distance
The correct method depends on what the coordinates represent.
| Coordinate type | Example | Best method |
|---|---|---|
| 2D Cartesian | (x, y) | Euclidean distance |
| 3D Cartesian | (x, y, z) | 3D Euclidean distance |
| Latitude and longitude | 40.7128, −74.0060 | Great-circle or geodesic calculation |
| Street addresses | Address text | Geocoding plus routing or geographic calculation |
| Map points | Clicked coordinates | Geographic distance calculation |
This distinction is important because a formula can be mathematically correct but still be the wrong model for the coordinates being measured.
What Is the Shortest Distance Between Two Points?
On a flat Cartesian plane, the shortest distance between two points is the straight line segment connecting them.
That is exactly what the Euclidean distance formula measures.
For geographic points on Earth's surface, the equivalent shortest surface route follows a great-circle path rather than a flat straight line.
Our guide to as-the-crow-flies distance explains how this applies to real geographic locations.
Common Mistakes When Calculating Distance Between Two Points
Several errors can produce the wrong result even when you know the correct formula.
1. Mixing x- and y-coordinates
Always compare:
x₁ with x₂
and:
y₁ with y₂
2. Mishandling negative coordinates
For example:
2 − (−3) = 5
not:
2 − 3 = −1
3. Forgetting to square both differences
The formula requires:
(x₂ − x₁)²
and:
(y₂ − y₁)²
4. Adding before squaring
Square each difference first, then add the results.
5. Forgetting the square root
If:
Distance² = 25
then:
Distance = √25 = 5
not 25.
6. Using Euclidean distance for latitude and longitude
Geographic coordinates describe a curved surface and require a geographic distance method.
7. Rounding too early
Keep intermediate values exact when practical and round the final result.
Distance Between Two Points Formula Summary
For:
Point 1 = (x₁, y₁)
and:
Point 2 = (x₂, y₂)
use:
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
The formula comes from the Pythagorean theorem and calculates straight-line Euclidean distance on a Cartesian plane.
If you want to calculate the result automatically, use the Distance Formula Calculator.
If your points are latitude and longitude coordinates, use the Distance Calculator instead.
Frequently Asked Questions
How do you find the distance between two points?
Subtract the x-coordinates and y-coordinates separately, square both differences, add them, and take the square root.
Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]
What is the distance between (0, 0) and (3, 4)?
The distance is 5 units.
Distance = √[(3 − 0)² + (4 − 0)²]
Distance = √(9 + 16)
Distance = √25
Distance = 5
What is the distance between (2, 4) and (5, 9)?
Calculate:
Distance = √[(5 − 2)² + (9 − 4)²]
Distance = √(3² + 5²)
Distance = √(9 + 25)
Distance = √34
Distance ≈ 5.83 units
Is the distance formula based on the Pythagorean theorem?
Yes. The horizontal and vertical coordinate differences form the two perpendicular sides of a right triangle, while the straight line between the two points forms the hypotenuse.
Is the distance between two points always positive?
Distance is always nonnegative. It is positive when the points are different and exactly 0 when both points are identical.
Can I use the distance formula for latitude and longitude?
Not for ordinary geographic distance across Earth's surface. Latitude and longitude require a geographic distance method such as the Haversine formula. Use the Distance Calculator for those coordinates.
