Distance Calculator
Calculate the straight-line distance between two points in 2D or 3D space. Instantly shows Euclidean distance, midpoint, slope, Manhattan distance, and the full formula applied.
Last updated: March 2026
Point 1 (x₁, y₁)
Point 2 (x₂, y₂)
How to Use the Distance Calculator
- Enter the coordinates of Point 1 (x₁, y₁) and Point 2 (x₂, y₂). Use any real numbers — negatives and decimals are fine.
- Enable 3D mode by checking the box to add z₁ and z₂ for three-dimensional distance calculations.
- Results update instantly — Euclidean distance, midpoint, slope (2D only), and Manhattan distance all appear as you type.
- Share or clear using the buttons below the form.
The Distance Formula: Derived from Pythagoras
The Euclidean distance formula is a direct application of the Pythagorean theorem to coordinate geometry. Given two points P₁ = (x₁, y₁) and P₂ = (x₂, y₂), imagine a right triangle formed by:
- A horizontal leg of length |x₂ − x₁|
- A vertical leg of length |y₂ − y₁|
- The hypotenuse — the direct distance between the two points
By the Pythagorean theorem (a² + b² = c²):
d = √[(x₂−x₁)² + (y₂−y₁)²]
This extends naturally to 3D by adding the z-dimension:
d = √[(x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²]
And to any number of dimensions: d = √[Σ(xᵢ₂ − xᵢ₁)²]. This generalization is fundamental in machine learning, where data points exist in hundreds or thousands of dimensions.
Euclidean vs Manhattan vs Chebyshev Distance
There are multiple ways to measure distance depending on the application:
Euclidean Distance (L2)
The straight-line distance — the shortest possible path between two points, as if you could fly directly. Formula: √[Σ(Δxᵢ)²]. Used in: geometry, physics, GPS, machine learning (k-NN, k-means).
Manhattan Distance (L1, Taxicab, City Block)
The sum of absolute differences in each dimension: Σ|Δxᵢ|. Named after Manhattan's grid street layout — the distance you walk if you can only move along grid lines (no diagonal movement). Manhattan distance ≥ Euclidean distance for the same pair of points. Used in: urban planning, image analysis, optimization algorithms, L1 regularization in machine learning.
Chebyshev Distance (L∞)
The maximum absolute difference in any single dimension: max(|Δx|, |Δy|, ...). Models the minimum number of moves a king needs on a chessboard. Chebyshev distance ≤ Euclidean ≤ Manhattan. The relationship between the three: Chebyshev ≤ Euclidean ≤ Manhattan ≤ n × Chebyshev (where n is the number of dimensions).
When to Use Each
- Euclidean: Physical distance, continuous features, isotropic space
- Manhattan: Grid movement, sparse data, computer vision, robust regression
- Chebyshev: Chessboard movement, warehouse robotics (can move diagonally), infinite-norm optimization
Real-World Applications of Distance Calculations
The distance formula appears across dozens of fields:
- GPS and navigation: GPS receivers compute their position by measuring the Euclidean distance to multiple satellites. The Haversine formula extends this to spherical (Earth-surface) distances, accounting for curvature.
- Computer graphics: Rendering engines constantly compute Euclidean distances to determine lighting, shadow casting, collision detection, and level-of-detail switching.
- Machine learning: K-nearest neighbors (k-NN) classification assigns a data point to the class of its nearest neighbors in feature space using Euclidean or Manhattan distance. K-means clustering groups points by minimizing within-cluster Euclidean distances.
- Physics: Coulomb's law, gravitational force, and wave propagation all depend on Euclidean distance between objects in 3D space.
- Robotics: Motion planning algorithms compute distances in configuration space to find collision-free paths. Manhattan distance is used in grid-based path planning (A* algorithm on a grid).
- Architecture: Structural engineers use 3D distance calculations for load paths, cable lengths, and material quantities in complex designs.
How to Calculate Distance If...
What is the distance between (1, 2) and (4, 6)?
The distance is exactly 5 units. d = √[(4−1)² + (6−2)²] = √[9 + 16] = √25 = 5. This is a classic 3-4-5 right triangle scaled by 1.
What is the distance between (0, 0) and (3, 4)?
The distance is 5 units. d = √[3² + 4²] = √[9 + 16] = √25 = 5. The origin to (3, 4) forms a classic 3-4-5 Pythagorean triple.
What is the distance between (−2, −3) and (4, 5)?
The distance is 10 units. d = √[(4−(−2))² + (5−(−3))²] = √[6² + 8²] = √[36 + 64] = √100 = 10.
What is the distance between two points with the same y-coordinate?
The distance equals |x₂ − x₁|. For (2, 5) and (8, 5): d = √[(8−2)² + 0²] = √36 = 6. Points sharing a y-coordinate lie on a horizontal line; distance is simply the horizontal gap.
What is the 3D distance between (1, 2, 3) and (4, 6, 3)?
The distance is 5 units. d = √[(4−1)² + (6−2)² + (3−3)²] = √[9+16+0] = √25 = 5. Since z₁ = z₂ = 3, the 3D distance equals the 2D distance.
What is the midpoint of (2, 4) and (8, 10)?
The midpoint is (5, 7). Midpoint = ((2+8)/2, (4+10)/2) = (10/2, 14/2) = (5, 7).
What is the slope of a line through (1, 3) and (4, 9)?
The slope is 2. m = (9−3)/(4−1) = 6/3 = 2. This means for every 1 unit increase in x, y increases by 2 units.
What is the Manhattan distance between (0, 0) and (3, 4)?
The Manhattan distance is 7. |3−0| + |4−0| = 3 + 4 = 7. Compare to Euclidean distance of 5 — Manhattan is always longer than or equal to Euclidean.
What is the distance between a point and the origin?
For point (x, y), distance to origin = √(x² + y²). This is called the magnitude or modulus of the position vector. For (5, 12): distance = √(25 + 144) = √169 = 13.
What does a distance of 0 mean?
A distance of 0 means both points are identical (same coordinates). If x₁ = x₂ and y₁ = y₂ (and z₁ = z₂ in 3D), then all differences are 0 and d = √0 = 0.
People Also Search For
Distance formula calculator with steps
This calculator shows the formula applied to your specific coordinates, making it easy to verify each step. The result panel displays the exact formula used (2D or 3D) alongside the numerical answer. For a full step-by-step derivation, see the "Derived from Pythagoras" section above, which walks through the geometric reasoning from first principles.
How to find distance between two points on a graph
Read off the x and y coordinates of both points from the graph, then apply d = √[(x₂−x₁)² + (y₂−y₁)²]. Make sure to include the correct sign for negative coordinates. If the graph has a scale other than 1:1, first convert grid units to the actual units before applying the formula.
Euclidean distance calculator for machine learning
In machine learning, Euclidean distance measures similarity between feature vectors in n-dimensional space. For vectors A = (a₁, a₂, ..., aₙ) and B = (b₁, b₂, ..., bₙ): d = √[Σ(aᵢ − bᵢ)²]. For 2D or 3D feature spaces, use this calculator directly. For higher dimensions, the same formula applies dimension by dimension.
Manhattan distance vs Euclidean distance — which is better?
Neither is universally better — the right choice depends on the application. Euclidean is best for continuous, isotropic spaces where diagonal movement is possible. Manhattan is better for grid-constrained movement, high-dimensional sparse data (Manhattan distance avoids the "curse of dimensionality"), and when you want to penalize large errors in any single dimension equally rather than emphasizing them quadratically.
How does the distance formula relate to the Pythagorean theorem
The distance formula is a direct algebraic restatement of the Pythagorean theorem. Form a right triangle between the two points using horizontal and vertical lines. The horizontal leg = |x₂−x₁|, the vertical leg = |y₂−y₁|, and the hypotenuse = the distance. a² + b² = c² becomes (Δx)² + (Δy)² = d², so d = √[(Δx)² + (Δy)²].
3D distance calculator for coordinates
Enable 3D mode on this calculator by checking the 3D checkbox, then enter z₁ and z₂ in addition to x and y coordinates. The formula is d = √[(x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²]. This is used in 3D CAD modeling, physics simulations, chemistry (atom distances), and spatial analysis.
Frequently Asked Questions
What is the distance between (1, 2) and (4, 6)?
The distance is 5 units. d = √[(4−1)² + (6−2)²] = √[9+16] = √25 = 5. This is a 3-4-5 right triangle.
What is the Euclidean distance formula?
2D: d = √[(x₂−x₁)² + (y₂−y₁)²]. 3D: d = √[(x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²]. Derived from the Pythagorean theorem applied to coordinate differences.
What is Manhattan distance?
Manhattan distance = |x₂−x₁| + |y₂−y₁|. It is the distance traveled along grid lines (no diagonal movement), like navigating city blocks. Always ≥ Euclidean distance.
How do I find the midpoint between two points?
Midpoint = ((x₁+x₂)/2, (y₁+y₂)/2). Average the x-coordinates and average the y-coordinates separately. The midpoint is equidistant from both points.
Can distance be negative?
No. Distance is always zero or positive. It represents a length, which cannot be negative. The distance formula uses squaring (which removes signs) and then a square root, guaranteeing a non-negative result.
What is slope and how is it calculated?
Slope (m) = (y₂−y₁) / (x₂−x₁). It measures the steepness of the line. Positive slope = rises left to right. Negative = falls. Zero = horizontal line. Undefined = vertical line (x₁ = x₂).
What does this calculator support?
2D Euclidean distance, 3D Euclidean distance, midpoint (2D and 3D), slope (2D), and Manhattan distance. Toggle 3D mode with the checkbox to add z-coordinate inputs.
How does GPS use the distance formula?
GPS receivers measure their distance to multiple satellites using signal travel time × speed of light. With distances to 4+ satellites, the receiver solves for its 3D position using the 3D distance formula. Earth-surface distances use the Haversine formula to account for curvature.
Is my data private?
Yes — all calculations run entirely in your browser. No coordinates or results are sent to any server or stored.
Can I use decimal and negative coordinates?
Yes. The calculator accepts any real number including negatives, decimals, and large values. For example, points (−3.5, 7.2) and (1.1, −4.8) work perfectly.
What is the distance from a point to the origin?
Enter (0, 0) as Point 1. For any point (x, y) as Point 2, the distance = √(x² + y²). This is also called the magnitude or norm of the vector from origin to that point.