About this calculator
Enter the coordinates of two points and this calculator finds the distance between them, their midpoint, the slope (gradient) and the equation of the line through them.
Vertical lines are handled properly: the slope is reported as undefined and the equation is x = a number.
Worked examples
Real numbers, worked out by the same calculator. Press “Use these numbers” to try one above.
(1, 2) to (4, 6)
- Distance between the points
- 5
- Midpoint
- (2.5, 4)
- Slope (gradient)
- 1.333333
- Equation of the line
- y = 1.333333x + 0.666667
- Angle of the line
- 53.130102° from the x-axis
The distance from (1, 2) to (4, 6) is 5, and the midpoint is (2.5, 4).
Show the working
- Differences: Δx = 4 − 1 = 3 and Δy = 6 − 2 = 4.
- Distance = √(Δx² + Δy²) = √(9 + 16) = 5.
- Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2) = (2.5, 4).
- Slope = Δy ÷ Δx = 4 ÷ 3 = 1.333333.
(−3, 5) to (3, −1)
- Distance between the points
- 8.485281
- Midpoint
- (0, 2)
- Slope (gradient)
- -1
- Equation of the line
- y = -1x + 2
- Angle of the line
- -45° from the x-axis
The distance from (-3, 5) to (3, -1) is 8.485281, and the midpoint is (0, 2).
Show the working
- Differences: Δx = 3 − -3 = 6 and Δy = -1 − 5 = -6.
- Distance = √(Δx² + Δy²) = √(36 + 36) = 8.485281.
- Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2) = (0, 2).
- Slope = Δy ÷ Δx = -6 ÷ 6 = -1.
A vertical line: (2, 1) to (2, 9)
- Distance between the points
- 8
- Midpoint
- (2, 5)
- Slope (gradient)
- undefined (a vertical line)
- Equation of the line
- x = 2
- Angle of the line
- 90° from the x-axis
The distance from (2, 1) to (2, 9) is 8, and the midpoint is (2, 5).
Show the working
- Differences: Δx = 2 − 2 = 0 and Δy = 9 − 1 = 8.
- Distance = √(Δx² + Δy²) = √(0 + 64) = 8.
- Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2) = (2, 5).
- Δx is 0, so the line is vertical and its slope is undefined.
The formulas
- Distance: √((x₂ − x₁)² + (y₂ − y₁)²), which is Pythagoras' theorem
- Midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
- Slope: (y₂ − y₁) ÷ (x₂ − x₁)
- Line: y = mx + c, where c = y₁ − m × x₁
What the slope means
The slope (or gradient) says how steep a line is: how far it rises for each step along. A slope of 2 rises 2 for every 1 across. Positive slopes go up to the right, negative slopes go down, zero is flat, and a vertical line has no defined slope.
Where it is used
Distance between two points is used in maps, games and engineering, midpoints in finding centres, and slope in road gradients, roof pitches and graph work.
Frequently asked questions
How do I find the distance between two points?
Take the differences in x and y, square them, add them and take the square root.
What is the midpoint formula?
Average the x values and average the y values.
What is the slope of a vertical line?
It is undefined, because the change in x is zero and you can't divide by zero.
How do I get the equation of a line from two points?
Find the slope m, then c = y₁ − m × x₁, giving y = mx + c.
Formulas tested against hand-worked answers. Last reviewed 29 September 2026. These calculators do arithmetic only; they are not financial, tax or legal advice.