Home/Math/Euclidean Distance Calculator
Math

Euclidean Distance Calculator

x
y
x
y
About this tool

Straight-line distance between two points in any dimension

The Euclidean Distance Calculator computes the straight-line ("as the crow flies") distance between two points in 1D, 2D, 3D, or 4D space. It is the most widely used distance metric in mathematics, physics, machine learning, and computer graphics — the default meaning of "distance" in everyday life.

Unlike Manhattan distance, which follows grid paths, Euclidean distance is the shortest possible path between two points — the length of the direct line segment connecting them. In 2D this is just the distance formula you learned in school: √((x₂−x₁)² + (y₂−y₁)²).

Key properties:

  • Always ≤ Manhattan distance — the straight line is never longer than a grid path.
  • Rotation invariant — rotating the coordinate system doesn't change the distance.
  • L2 norm — Euclidean distance is the L2 norm of the difference vector, making it foundational in linear algebra and ML.
  • Special case of Minkowski — it equals Minkowski distance with p=2.

Example

2D example: Points A=(1, 2) and B=(4, 6).

√((4−1)² + (6−2)²) = √(9 + 16) = √25 = 5.

The Manhattan distance between the same points is |4−1| + |6−2| = 3 + 4 = 7. The ratio 5/7 ≈ 0.71 — close to the theoretical minimum of 1/√2 ≈ 0.707 when moving at exactly 45°.

FAQ

Frequently Asked Questions

What is Euclidean distance?

Euclidean distance is the straight-line distance between two points in space. It is the length of the shortest path connecting them, computed as the square root of the sum of squared coordinate differences: √((x₂−x₁)² + (y₂−y₁)²) in 2D. It generalises to any number of dimensions using the same formula.

What is the Euclidean distance formula?

For two points A=(a₁, a₂, …, aₙ) and B=(b₁, b₂, …, bₙ): d = √(Σ(aᵢ−bᵢ)²). In 2D: d = √((x₂−x₁)² + (y₂−y₁)²). In 3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). This is also called the L2 norm of the difference vector.

What is the difference between Euclidean and Manhattan distance?

Euclidean distance is the straight-line ('as the crow flies') path. Manhattan distance follows axis-aligned grid paths — only horizontal and vertical moves. Euclidean is always ≤ Manhattan. For a 45° diagonal move, Manhattan distance is √2 ≈ 1.41× the Euclidean distance. Use our Manhattan distance calculator to compare both simultaneously.

When should I use Euclidean distance vs Manhattan distance?

Use Euclidean when: movement in any direction is equally possible (open space, physics, graphics). Use Manhattan when: movement is grid-constrained (city navigation, certain ML tasks). In machine learning, Manhattan distance can outperform Euclidean in high-dimensional spaces because it's less dominated by large individual differences. For high dimensions, also consider Chebyshev distance.

What is the Euclidean distance between (0,0) and (3,4)?

√(3² + 4²) = √(9+16) = √25 = 5. This is the classic 3-4-5 right triangle. The Manhattan distance between the same points is 3+4 = 7. The ratio is 5/7 ≈ 71.4%.

What is L2 distance?

L2 distance is another name for Euclidean distance. The 'L' refers to Lp norms: L1 is Manhattan (sum of absolute differences), L2 is Euclidean (square root of sum of squares), L∞ is Chebyshev (maximum absolute difference). In machine learning, L2 regularisation (Ridge regression) penalises the L2 norm of model weights.

How is Euclidean distance used in machine learning?

Euclidean distance is the default metric in k-nearest neighbours (KNN), k-means clustering, and many other algorithms. It measures how similar two data points are — closer points are more similar. It also underlies support vector machines (maximising margin is equivalent to minimising L2 norms) and PCA (which minimises L2 reconstruction error).

What is the Euclidean distance in 3D space?

For points A=(x₁,y₁,z₁) and B=(x₂,y₂,z₂): d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). Example: A=(1,2,3) and B=(4,6,3): d = √(9+16+0) = √25 = 5. In physics, this is simply the distance between two positions in 3D space.

How does Euclidean distance relate to Minkowski distance?

Euclidean distance is a special case of Minkowski distance with p=2. The Minkowski formula is (Σ|aᵢ−bᵢ|ᵖ)^(1/p). At p=1 this becomes Manhattan distance, at p=2 it becomes Euclidean, and as p→∞ it approaches Chebyshev distance. Minkowski generalises all three into a single parameterised family.