Euclidean Distance

Calculator for the L₂-norm (straight-line distance) with formulas and examples

Euclidean Distance Calculator

What is calculated?

The Euclidean distance is the shortest connection (straight-line) between two points. It corresponds to the L₂-norm of the difference and is based on the Pythagorean theorem.

Input points / vectors

Coordinates separated by spaces

Same number of coordinates as X

Result
Euclidean distance (L₂):
Shortest connection between the points (straight line)

Euclidean Info

Properties

Euclidean distance:

  • Also called the L₂-norm
  • Shortest connection between points
  • Based on the Pythagorean theorem
  • Corresponds to the straight-line distance

Intuition: The distance you would measure with a ruler between two points.

Dimensions
1D (number line):
|x₁ - x₂| = √((x₁-x₂)²)
2D (plane):
√((x₁-x₂)² + (y₁-y₂)²)
3D (space):
√((x₁-x₂)² + (y₁-y₂)² + (z₁-z₂)²)

Formulas for Euclidean distance

Basic formula (L₂-norm)
\[d_2(x,y) = \sqrt{\sum_{i=1}^n (x_i - y_i)^2}\] Standard Euclidean distance
Squared distance
\[d_2^2(x,y) = \sum_{i=1}^n (x_i - y_i)^2\] Without square root (more efficient)
2D formula (plane)
\[d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}\] Classic Pythagoras
3D formula (space)
\[d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}\] Extended Pythagoras
Vector norm
\[d_2(x,y) = \|x-y\|_2\] L₂-norm of the difference
Dot product
\[d_2(x,y) = \sqrt{(x-y) \cdot (x-y)}\] Using dot product

Detailed calculation example

Example: Euclidean distance([3,4,5], [2,3,6])

Given:

  • Point A = [3, 4, 5]
  • Point B = [2, 3, 6]

Step 1 - Differences:

  • Δx = 3 - 2 = 1
  • Δy = 4 - 3 = 1
  • Δz = 5 - 6 = -1

Step 2 - Squaring:

\[1^2 + 1^2 + (-1)^2 = 1 + 1 + 1 = 3\]

Step 3 - Square root:

\[d = \sqrt{3} \approx 1.732\]

Interpretation: The straight-line distance between the two 3D points is √3 ≈ 1.732 units.

Pythagorean theorem

Example: right triangle (2D)

Problem:

A right triangle has legs a = 3 and b = 4. What is the length of the hypotenuse c?

As a distance problem:

Point A = (0, 0)
Point B = (3, 4)
Find: Euclidean distance

Calculation:

\[c = \sqrt{(3-0)^2 + (4-0)^2} = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5\]

Result: The hypotenuse length is 5 (classic 3-4-5 triangle).

Efficiency: distance vs. squared distance

When to use squared distance?

Normal distance:

\[d = \sqrt{\sum (x_i - y_i)^2}\]

For actual distance measurements

Squared distance:

\[d^2 = \sum (x_i - y_i)^2\]

For comparisons (faster)

Use-cases for squared distance:
  • k-NN algorithm: Only ordering matters, not exact values
  • Clustering: Comparing distances is sufficient
  • Optimization: Minimizing d² equals minimizing d
  • Performance: Avoid expensive square root operation

Practical applications

Geography & Navigation
  • GPS distance calculation
  • Straight-line distances
  • Cartography
  • Route planning
Machine Learning
  • k-Nearest Neighbors (k-NN)
  • Clustering algorithms
  • Feature-space distances
  • Dimensionality reduction
Physics & Engineering
  • Force vectors
  • Center of mass calculations
  • Stress/strain analysis
  • Vibration analysis

Mathematical properties

Norm properties
  • Positivity: ‖x‖₂ ≥ 0, ‖x‖₂ = 0 ⟺ x = 0
  • Homogeneity: ‖αx‖₂ = |α|‖x‖₂
  • Triangle inequality: ‖x+y‖₂ ≤ ‖x‖₂ + ‖y‖₂
  • Parallelogram law: 2(‖x‖² + ‖y‖²) = ‖x+y‖² + ‖x-y‖²
Geometric properties
  • Unit ball: Circle (2D) or sphere (3D)
  • Rotation invariant: Invariant under rotations
  • Translation invariant: d(x+c, y+c) = d(x,y)
  • Strictly convex: Unit ball is strictly convex
Relations to other norms

To L₁-norm:
‖x‖₂ ≤ ‖x‖₁ ≤ √n ‖x‖₂

To L∞-norm:
‖x‖∞ ≤ ‖x‖₂ ≤ √n ‖x‖∞

Comparison of Lₚ norms

For points [0,0] and [3,4]
L₁ (Manhattan)
7.000

|3| + |4| = 7

L₂ (Euclidean)
5.000

√(3² + 4²) = 5

L₃ (Minkowski)
4.498

(3³ + 4³)^(1/3)

L∞ (Chebyshev)
4.000

max(3, 4) = 4

Observation: The Euclidean distance lies between Manhattan and Chebyshev and corresponds to the classic 3-4-5 triangle.