Math

Distance Between Two Points Calculator

Calculator Free · Private
Reviewed by: (política editorial ) · Last reviewed:
Was this calculator helpful?

The Distance Between Two Points Calculator computes the straight-line (Euclidean) distance between any two points on the Cartesian plane using coordinates (x₁, y₁) and (x₂, y₂). The core formula is the Euclidean distance: d = √[(x₂−x₁)² + (y₂−y₁)²], derived directly from the Pythagorean theorem. It is used in geometry, physics, engineering, computer graphics, GPS navigation, and data science whenever you need the shortest path between two known positions. For example, points P1(1, 2) and P2(4, 6) produce a horizontal leg of 3, a vertical leg of 4, and a hypotenuse (distance) of exactly 5 — a classic 3-4-5 right triangle. Enter any real-number coordinates, including negatives and decimals, and get the exact distance instantly.

Last reviewed: June 3, 2026 Verified by Source: Wikipedia — Euclidean distance, Wikipedia — Pythagorean theorem, Khan Academy — Distance formula 100% private

The distance between two points P₁(x₁, y₁) and P₂(x₂, y₂) is given by the Euclidean distance formula: **d = √[(x₂−x₁)² + (y₂−y₁)²]**. It applies the Pythagorean theorem to the right triangle formed by the two points. Classic example: P₁(1,2) and P₂(4,6) → Δx = 3, Δy = 4, d = √(9+16) = √25 = **5 units**.

When to use this calculator

  • Calculating the straight-line distance between two GPS coordinates projected onto a flat local plane (e.g., two buildings 300 m apart on a city map).
  • Finding the hypotenuse of a right triangle in a geometry class when the two legs are given as coordinate differences (e.g., the 3-4-5 or 5-12-13 Pythagorean triples).
  • Measuring pixel distance between two points in a digital image or game canvas to detect collisions or draw a scale bar in computer graphics.
  • Determining the Euclidean distance between two data points in a machine-learning feature space to apply k-nearest neighbors (KNN) or k-means clustering algorithms.
  • Checking whether a newly placed cell tower (x₂, y₂) is within a required service radius of an existing tower (x₁, y₁) in telecommunications network planning.
  • Solving analytic geometry problems such as verifying that four vertices form a square by confirming equal side lengths and equal diagonals.

Step-by-step example

  1. P1(1, 2) and P2(4, 6)
  2. Δx = 4 − 1 = 3 → Δx² = 9
  3. Δy = 6 − 2 = 4 → Δy² = 16
  4. d = √(9 + 16) = √25 = 5
Result: d = 5 units (classic 3-4-5 Pythagorean triple)

How it works

3 min read

How It's Calculated

The distance between two points in the Cartesian plane is the length of the line segment connecting them. This length is obtained by applying the Pythagorean theorem to the right triangle formed by the horizontal leg |x₂−x₁| and the vertical leg |y₂−y₁|.

Euclidean Distance Formula
──────────────────────────
d = √[ (x₂ − x₁)² + (y₂ − y₁)² ]

Where:
  (x₁, y₁)  = coordinates of the first point  (P1)
  (x₂, y₂)  = coordinates of the second point (P2)
  d          = straight-line distance (always ≥ 0)

Step-by-step for P1(1, 2) → P2(4, 6):
  Δx = 4 − 1 = 3       → Δx² = 9
  Δy = 6 − 2 = 4       → Δy² = 16
  d  = √(9 + 16)
     = √25
     = 5

> Note: Because both differences are squared, the formula is symmetric: d(P1→P2) = d(P2→P1). The order of the points never changes the result.

---

Reference Table — Common Values

The table below lists well-known Pythagorean triple point pairs and their exact distances. These are integer solutions to a² + b² = c² and are ideal for verifying your inputs.

P1 (x₁, y₁)P2 (x₂, y₂)ΔxΔyd (exact)Triple
(0, 0)(3, 4)3453-4-5
(0, 0)(5, 12)512135-12-13
(0, 0)(8, 15)815178-15-17
(0, 0)(7, 24)724257-24-25
(1, 1)(4, 5)3453-4-5 (shifted)
(−3, −4)(0, 0)345negative quadrant
(2, 3)(14, 8)125135-12-13 (shifted)
(0, 0)(1, 1)11√2 ≈ 1.4142unit diagonal
(0, 0)(1, 0)101horizontal unit
(−2, 5)(3, −7)51213mixed signs

---

Typical Cases

Case 1 — Classic 3-4-5 triangle (P1(1,2), P2(4,6))


This is the calculator's built-in example. Δx = 3, Δy = 4, so d = √(9+16) = 5. Because 3, 4, and 5 are integers, this is often used in carpentry and construction to verify a perfect right angle (the "3-4-5 rule").

Case 2 — Negative coordinates (P1(−3,−1), P2(2,4))


Δx = 2−(−3) = 5, Δy = 4−(−1) = 5. d = √(25+25) = √50 = 5√2 ≈ 7.071. The point lies exactly on a 45° diagonal, which often appears in isosceles right triangles.

Case 3 — Decimal/real-world coordinates (P1(1.5, 2.3), P2(4.8, 6.7))


Δx = 3.3, Δy = 4.4. d = √(10.89 + 19.36) = √30.25 = 5.5. This type of input occurs in GIS and CAD applications where coordinates are measured in meters or feet.

---

Common Errors

1. Forgetting to square the differences — Writing d = √(Δx + Δy) instead of √(Δx² + Δy²) gives a completely wrong result. Always square each component before summing.

2. Sign errors with negative coordinates — Students sometimes compute |x₂−x₁| incorrectly when one coordinate is negative. Example: x₁=−3, x₂=2 → Δx = 2−(−3) = 5, not 2−3 = −1. The squaring step eliminates sign issues if you keep the subtraction correct.

3. Confusing 2D distance with 3D distance — The 2D formula only applies when both points share the same plane. For 3D points (x, y, z), the formula extends to d = √[(x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)²].

4. Using the formula for non-Euclidean surfaces — On Earth's curved surface, the straight-line formula only approximates short distances (< ~10 km on a flat projection). For large geographic distances, the Haversine formula must be used instead.

Frequently asked questions

What is the formula for the distance between two points?

The distance formula is d = √[(x₂−x₁)² + (y₂−y₁)²]. To use it: compute Δx = x₂ − x₁ and Δy = y₂ − y₁, square each difference, add them, and take the square root. Example: P₁(1, 2) and P₂(4, 6) → Δx = 3, Δy = 4, d = √(9+16) = √25 = 5 units. This formula applies the Pythagorean theorem to the right triangle formed by the two points and their axis projections.

Where does the distance formula come from?

The distance formula d = √[(x₂−x₁)²+(y₂−y₁)²] is a direct application of the Pythagorean theorem (a²+b²=c²) to coordinate geometry. The horizontal difference Δx and vertical difference Δy form the two legs of a right triangle, and d is the hypotenuse. It was formalized as part of Cartesian (analytic) geometry introduced by René Descartes in his 1637 work La Géométrie.

Does the order of the two points (P1 first vs. P2 first) affect the result?

No. Because both differences are squared, (x₂−x₁)² = (x₁−x₂)² and (y₂−y₁)² = (y₁−y₂)². The distance is always non-negative and identical regardless of which point you label P1 or P2. This property is called symmetry and is one of the formal requirements for a metric in mathematics.

Can the distance between two points ever be zero or negative?

The distance is zero if and only if both points are identical, i.e., x₁=x₂ AND y₁=y₂. It can never be negative because the result is a square root of a sum of squares, which is always ≥ 0. A result of zero means the two 'points' are actually the same point.

How do I calculate distance in 3D space?

Add a third squared difference under the radical: d = √[(x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)²]. For example, P1(1,2,3) and P2(4,6,3) give d = √(9+16+0) = 5 (same as 2D since z is equal). For P1(0,0,0) and P2(1,1,1), d = √3 ≈ 1.732. The same Pythagorean logic generalizes to any number of dimensions.

What is the difference between Euclidean distance and Manhattan distance?

Euclidean distance is the straight-line 'as the crow flies' distance: d = √(Δx²+Δy²). Manhattan distance (also called taxicab or L1 distance) is the sum of absolute differences: d = |Δx|+|Δy|. For P1(1,2)→P2(4,6): Euclidean = 5, Manhattan = 3+4 = 7. Manhattan distance is used in city-grid navigation, computer vision, and some machine-learning algorithms where diagonal movement is not allowed.

How accurate is this formula for real-world GPS distances?

For short distances on a flat local projection (under ~10 km), the Cartesian formula is highly accurate when coordinates are in meters (e.g., UTM). For large geographic distances in latitude/longitude, you must use the Haversine formula, which accounts for Earth's spherical curvature (radius ≈ 6,371 km). Using the flat formula for very long distances introduces significant error because Earth's surface is curved.

Why does the 3-4-5 rule matter in construction and carpentry?

A triangle with sides 3, 4, and 5 (any consistent unit: inches, feet, meters) always contains a perfect 90° angle, confirmed by 3²+4²=5² (9+16=25). Builders use this to square up foundations, walls, and tile layouts: measure 3 units along one wall, 4 units along the adjacent wall, and if the diagonal is exactly 5 units, the corner is square. Multiples also work: 6-8-10, 9-12-15, etc.

How is the distance formula used in machine learning?

Euclidean distance is the default metric in k-nearest neighbors (KNN) and k-means clustering. Given two data points with n features each, d = √[Σᵢ(xᵢ−yᵢ)²] — a direct extension of the 2D formula to n dimensions. Feature scaling (normalization) is critical before applying the formula, because variables with large numerical ranges dominate the distance calculation and make other features irrelevant.

Sources and references