induwara.lk
induwara.lkAI · Machine learning

Euclidean Distance Calculator

Compute the Euclidean (L2) distance between two points or two vectors of any dimension, in your browser. See the squared distance, the Manhattan and Chebyshev comparisons, and the full per-dimension working behind every result. No signup, nothing uploaded.

By Induwara AshinsanaUpdated Jun 10, 2026
Euclidean distance calculator
Input mode

Any length ≥ 1 — A and B must match.

Same length as A. Commas, spaces, or new lines.

Examples
Euclidean distance
0.5477
L2 · 3-D
Squared (d²)
0.3000
Used by k-means
Manhattan (L1)
0.8000
Σ |aᵢ − bᵢ|
Chebyshev (L∞)
0.5000
max |aᵢ − bᵢ|
Decimals

Cross-check. The direct form √(Σ (aᵢ − bᵢ)²) gives 0.5477; the independent overflow-safe form Math.hypot(a − b) — how numpy.linalg.norm computes it — gives 0.5477. They reconcile, as they must.

Step-by-step working

Dimaᵢbᵢaᵢ − bᵢ(aᵢ − bᵢ)²|aᵢ − bᵢ|
#10.20000.10000.10000.01000.1000
#20.50000.7000-0.20000.04000.2000
#30.90000.40000.50000.25000.5000
Totals0.30000.8000
d = √((0.1000)² + (−0.2000)² + (0.5000)²) = √0.3000 = 0.5477

Method: d = √(Σ (aᵢ − bᵢ)²); d² = Σ (aᵢ − bᵢ)²; Manhattan = Σ |aᵢ − bᵢ|; Chebyshev = maxᵢ |aᵢ − bᵢ| — scikit-learn euclidean_distances and NumPy linalg.norm. Nothing leaves this page.

How it works

Euclidean distance is the straight-line distance between two points — the length of the segment joining them. For two equal-length vectors a = [a₁…aₙ] and b = [b₁…bₙ], it is the square root of the sum of the squared coordinate differences. It is the metric scikit-learn and NumPy use by default, and it generalises the Pythagorean theorem to any number of dimensions.

d(a, b) = √( Σ (aᵢ − bᵢ)² ) = √( (a₁ − b₁)² + … + (aₙ − bₙ)² )

The tool computes this in four steps:

  1. Per-dimension difference. Subtract the vectors coordinate by coordinate: dᵢ = aᵢ − bᵢ.
  2. Square and sum. Square each difference and add them up. This sum is the squared Euclidean distance d² = Σ dᵢ², which equals scikit-learn's euclidean_distances(…, squared=True).
  3. Square root. The Euclidean distance is d = √(d²), equivalent to numpy.linalg.norm(a − b).
  4. Comparison metrics. Over the same differences the tool also reports Manhattan Σ |dᵢ| and Chebyshev max |dᵢ|, the L1 and L∞ members of the same Minkowski family.

The 2D and 3D modes are just the n = 2 and n = 3 cases of the same sum: √((x₂ − x₁)² + (y₂ − y₁)²) and √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). All arithmetic is done in double-precision floating point and is rounded only for display, using the decimal places you pick. As a credibility check, the calculator computes the distance a second way — as the L2 norm of the difference vector via Math.hypot, the overflow-safe route NumPy relies on — and confirms the two agree, so even inputs around 10⁹ stay exact.

Worked examples

2D points — a = [1, 2], b = [4, 6] (the 3-4-5 triangle)

  1. Differences: 1 − 4 = −3, 2 − 6 = −4
  2. Squares: (−3)² = 9, (−4)² = 16, sum S = 25
  3. Euclidean: d = √25 = 5.0000, squared d² = 25
  4. Manhattan: |−3| + |−4| = 7, Chebyshev: max(3, 4) = 4
  5. hypot(−3, −4) = 5.0000 → cross-check agrees

n-D vectors — a = [1, 2, 3], b = [4, 0, 3]

  1. Differences: −3, 2, 0
  2. Squares: 9, 4, 0, sum S = 13
  3. Euclidean: d = √13 = 3.605551, squared d² = 13
  4. Manhattan: 3 + 2 + 0 = 5, Chebyshev: max(3, 2, 0) = 3
  5. numpy.linalg.norm([1,2,3] − [4,0,3]) = 3.605551 → agrees

Embedding vectors — p = [0.2, 0.5, 0.9], q = [0.1, 0.7, 0.4]

  1. Differences: 0.1, −0.2, 0.5
  2. Squares: 0.01, 0.04, 0.25, sum S = 0.30
  3. Euclidean: d = √0.30 = 0.547723, squared d² = 0.30
  4. Manhattan: 0.1 + 0.2 + 0.5 = 0.8, Chebyshev: max(0.1, 0.2, 0.5) = 0.5
  5. scipy.spatial.distance.euclidean(p, q) = 0.547722 → agrees

Frequently asked questions

Sources & references

The formulas on this page were last cross-checked against these sources on 2026-06-10. Euclidean distance is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.