Quick answer: The distance from (1, 2) to (4, 6) is √((4 − 1)² + (6 − 2)²) = √(9 + 16) = √25 = 5.
How it's calculated
The distance formula comes from the Pythagorean theorem: the differences Δx and Δy are the legs of a right triangle and the distance is its hypotenuse, d = √(Δx² + Δy²).
In three dimensions one more term is added: d = √(Δx² + Δy² + Δz²). The midpoint is the average of each coordinate, M = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2, …).
The answer is in the same unit as the coordinates. For map coordinates in latitude and longitude this flat formula is only an approximation over short distances.
Worked examples
- (1, 2) to (4, 6): √(3² + 4²) = 5, midpoint (2.5, 4)
- (1, 2, 3) to (4, 6, 15): √(3² + 4² + 12²) = √169 = 13
- (−2, 1) to (3, −11): √(5² + (−12)²) = 13
Frequently asked questions
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²) in 2D; in 3D add (z₂ − z₁)² under the root.
Can the distance be negative?
No. The squares make every term positive, so the distance is always 0 or more; it is 0 only when the points are the same.
How do I get the slope of the line too?
The slope calculator gives the slope, the line equation and the angle from the same two points.
What is the distance between (1, 2) and (4, 6)?
Exactly 5. The gaps are 3 across and 4 up, the classic 3-4-5 triangle.
What is the midpoint of (1, 2) and (4, 6)?
(2.5, 4). Just average the x values and the y values.
Can I use this for map coordinates?
Only as a rough guide over short distances. For latitude and longitude, use the great-circle (haversine) formula, which accounts for the Earth being round.