Compute Euclidean, Manhattan, and Chebyshev distances between two points in 2D or 3D space. Visualize the points and the distance segment on an interactive canvas. Perfect for geometry, data science, navigation, and engineering applications.
The distance between two coordinates is a fundamental concept in mathematics, physics, engineering, and data science. It quantifies how far apart two points are in space. The most familiar measure is the Euclidean distance, which represents the length of the straight line connecting the points — a direct application of the Pythagorean theorem.
However, depending on the context, other distance metrics may be more appropriate. The Manhattan distance (also called city-block or L₁ distance) measures the sum of absolute differences along each axis, useful in grid-based navigation and certain machine learning algorithms. The Chebyshev distance (L∞ or chessboard distance) measures the maximum absolute difference along any axis, applicable in game theory and optimization.
For two points A(x₁, y₁, …, z₁) and B(x₂, y₂, …, z₂) in n‑dimensional space:
Euclidean (L₂): d = √(∑ (xᵢ − yᵢ)²) | Manhattan (L₁): d = ∑ |xᵢ − yᵢ| | Chebyshev (L∞): d = max(|xᵢ − yᵢ|)
The Euclidean distance formula is derived from the Pythagorean theorem in two dimensions. For points (x₁, y₁) and (x₂, y₂), the horizontal difference is Δx = x₂ − x₁, and the vertical difference is Δy = y₂ − y₁. The straight-line distance is the hypotenuse of a right triangle with legs Δx and Δy:
d = √(Δx² + Δy²)
In three dimensions, we extend this to d = √(Δx² + Δy² + Δz²). For n dimensions, the formula generalizes to the square root of the sum of squared differences.
The Manhattan distance is the sum of the absolute differences: d = |Δx| + |Δy| (+ |Δz| in 3D). It represents the distance a taxi would drive along city blocks. The Chebyshev distance is the maximum of the absolute differences: d = max(|Δx|, |Δy|, …). It is the minimum number of king moves on a chessboard between two squares.
All three metrics satisfy the mathematical properties of a metric: non‑negativity, identity of indiscernibles, symmetry, and the triangle inequality. These properties ensure they behave intuitively as measures of distance.
All values are computed in real time and are consistent with standard mathematical definitions.
| Metric | Formula (2D) | Formula (3D) | Typical Use |
|---|---|---|---|
| Euclidean (L₂) | √(Δx² + Δy²) | √(Δx² + Δy² + Δz²) | Straight‑line distance, physics, geometry |
| Manhattan (L₁) | |Δx| + |Δy| | |Δx| + |Δy| + |Δz| | Grid navigation, LASSO regression, robust ML |
| Chebyshev (L∞) | max(|Δx|, |Δy|) | max(|Δx|, |Δy|, |Δz|) | Chessboard moves, minimax optimization |
A GPS receiver calculates its position using trilateration from satellite signals. The Euclidean distance between the receiver and each satellite is computed using the speed of light and signal travel time. By solving a system of distance equations, the receiver pinpoints its location on Earth's surface. The same principle applies in indoor positioning systems, robotics, and autonomous vehicle localization.
In this tool, you can simulate distances between any two points in a coordinate system, gaining intuition for how position and distance are interrelated in geospatial applications.
The k‑nearest neighbors (k‑NN) algorithm classifies a data point by computing the distance to every other point in the training set. The choice of distance metric — Euclidean, Manhattan, or Chebyshev — can significantly affect classification accuracy. For high‑dimensional data, Manhattan distance often performs better due to the "curse of dimensionality." This tool lets you experiment with different metrics on synthetic coordinates, illustrating how distance choices impact similarity judgments.
The concept of distance in a coordinate system traces back to René Descartes (1596–1650), who introduced the Cartesian coordinate system, enabling algebraic treatment of geometry. The Pythagorean theorem, known for over 2,500 years, provides the foundation for Euclidean distance in two dimensions. In the 19th century, Hermann Minkowski generalized the notion of distance to arbitrary dimensions, introducing the family of Lp metrics. Today, distance metrics are indispensable in fields ranging from cosmology (measuring distances to galaxies) to data mining (clustering and anomaly detection).