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.
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
|x₁ - x₂| = √((x₁-x₂)²)
√((x₁-x₂)² + (y₁-y₂)²)
√((x₁-x₂)² + (y₁-y₂)² + (z₁-z₂)²)
Formulas for Euclidean distance
Basic formula (L₂-norm)
Squared distance
2D formula (plane)
3D formula (space)
Vector norm
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:
Step 3 - Square root:
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:
Result: The hypotenuse length is 5 (classic 3-4-5 triangle).
Efficiency: distance vs. squared distance
When to use squared distance?
Normal distance:
For actual distance measurements
Squared distance:
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)
|3| + |4| = 7
L₂ (Euclidean)
√(3² + 4²) = 5
L₃ (Minkowski)
(3³ + 4³)^(1/3)
L∞ (Chebyshev)
max(3, 4) = 4
Observation: The Euclidean distance lies between Manhattan and Chebyshev and corresponds to the classic 3-4-5 triangle.