Distance Calculator

Find the distance between two points using the distance formula √((x2−x1)²+(y2−y1)²). Also computes midpoint and divides a segment in any given ratio.

Guides & Reference

How It Works

Distance FormulaLength of any line segment

Find the difference in x-coordinates (Δx) and y-coordinates (Δy). Square each. Add them. Take the square root. This is the Pythagorean theorem applied to coordinate geometry.

d = √((x2−x1)² + (y2−y1)²)(1,1) to (4,5): √(9+16) = √25 = 5
Pythagorean ConnectionWhy it works

Create a right triangle: horizontal side = |Δx|, vertical side = |Δy|, hypotenuse = distance. By Pythagorean theorem, hyp² = Δx²+Δy².

d² = Δx² + Δy²Δx=3, Δy=4: d=√(9+16)=5
Midpoint FormulaFinding the center

Average the x-values and average the y-values. The midpoint is equidistant from both endpoints.

M = ((x1+x2)/2, (y1+y2)/2)(2,4) and (8,10): midpoint=(5,7)
Section FormulaDividing in a ratio

To divide P1P2 in ratio m:n: x = (m·x2+n·x1)/(m+n). Used in geometry to find points that divide segments proportionally.

P = (m·P2 + n·P1)/(m+n)(0,0) to (6,9) in 2:1: (4,6)
3D DistanceExtending to 3 dimensions

d = √((x2−x1)²+(y2−y1)²+(z2−z1)²). Add the z-difference squared under the radical.

d = √(Δx²+Δy²+Δz²)(0,0,0) to (1,2,2): √(1+4+4)=3
Practical ApplicationGPS and mapping

GPS systems use the distance formula (adapted for spherical geometry) to calculate distances. In flat areas, the formula works directly.

d ≈ √(Δlat²+Δlon²) × scaleUsed in all navigation and mapping apps

Quick Reference

Common examples — verify instantly above.

Basic

(0,0) to (3,4)

5

Basic

(1,1) to (4,5)

5

Diagonal

(0,0) to (1,1)

1.414

Horizontal

(2,5) to (8,5)

6

Vertical

(3,1) to (3,7)

6

Midpoint

(0,0) and (6,4)

(3,2)

Midpoint

(1,3) and (5,7)

(3,5)

Section 1:2

(0,0) to (9,9)

(3,3)

Tips & Shortcuts

The distance formula is just the Pythagorean theorem. Draw the right triangle to visualize.

Distance is always non-negative. The squares in the formula ensure this regardless of which point is "first".

For points on the same horizontal line (same y), distance = |x2−x1|. For same vertical line, distance = |y2−y1|.

A common Pythagorean triple: 3-4-5. If Δx=3 and Δy=4 (or multiples), distance = 5 (or multiple).

The midpoint divides the segment in ratio 1:1. Section formula generalizes this to any ratio m:n.

For distance in 3D, add a third term under the radical: √(Δx²+Δy²+Δz²).

Common Mistakes

Computing distance as (x2−x1)+(y2−y1) instead of √(Δx²+Δy²)

The formula uses squares and a square root, not simple addition. Always square each difference.

Forgetting to take the square root at the end

Δx²+Δy² gives distance squared. Take √ to get the actual distance.

Getting a negative distance

Distance is always positive. If you get negative, you made a sign error — the squares eliminate sign issues.

Confusing midpoint with average of distances

Midpoint averages coordinates, not distances. ((x1+x2)/2, (y1+y2)/2), not (d1+d2)/2.

Applying section formula with wrong order

Section formula is (m·x2+n·x1)/(m+n). m applies to the SECOND point, n to the FIRST.

Using the formula in non-flat coordinate systems

Distance formula assumes Euclidean geometry. On a sphere (Earth), use the Haversine formula instead.

Frequently Asked Questions

d = √((x2−x1)²+(y2−y1)²). It applies the Pythagorean theorem to the horizontal and vertical distances between two points.

Draw a right triangle with the two points as corners. The horizontal leg is |x2−x1| and vertical leg is |y2−y1|. By Pythagorean theorem: d²=Δx²+Δy².

Midpoint = ((x1+x2)/2, (y1+y2)/2). Average the x-coordinates and average the y-coordinates.

The point dividing segment P1P2 in ratio m:n is ((m·x2+n·x1)/(m+n), (m·y2+n·y1)/(m+n)).

No. Distance is always positive. The formula uses squares which eliminate sign differences.

Only if both points are identical. If (x1,y1)=(x2,y2), then distance=0.

The 3D distance formula extends the 2D version: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). Example: from (1,2,3) to (4,6,3): d = √(9+16+0) = √25 = 5. The same logic applies in any number of dimensions — sum the squared differences of each coordinate pair, then take the square root. The 2D formula is just the 3D formula with z₁=z₂=0.

Related Calculators