Longhand

Slope, Distance and Midpoint Calculator

Shaheer Bin RamzanBy Shaheer Bin Ramzan
Reviewed November 2026 · Formula sources

Enter two points (x₁, y₁) and (x₂, y₂). You get the slope, the distance between them, the midpoint and the equation of the line through them.

The three formulas

MeasureFormula
Slopem = (y₂ − y₁) ÷ (x₂ − x₁)
Distanced = √((x₂ − x₁)² + (y₂ − y₁)²)
Midpoint((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
Line equationy = mx + b, where b = y₁ − m × x₁

Worked example: (1, 2) and (4, 6)

The differences are Δx = 4 − 1 = 3 and Δy = 6 − 2 = 4. The slope is 4 ÷ 3 ≈ 1.333. The distance is √(9 + 16) = √25 = 5, which is the familiar 3-4-5 right triangle. The midpoint is (2.5, 4). The intercept is b = 2 − (4 ÷ 3)(1) = 2 ÷ 3, so the line is y ≈ 1.333x + 0.667.

What the slope tells you

A positive slope rises from left to right, a negative slope falls, a slope of zero is a horizontal line, and an undefined slope is a vertical line. The larger the absolute value, the steeper the line. Two lines are parallel when their slopes are equal, and perpendicular when their slopes multiply to −1, which means one is the negative reciprocal of the other.

Common mistakes

Subtracting in a different order for x and y flips the sign of the slope, so keep the same point first in both. Negative coordinates need brackets when squared: (−3)² is 9, not −9. Remember that the midpoint adds and halves, while the distance squares, adds and takes a root. For the right-triangle idea behind the distance formula, see the Pythagorean theorem calculator.

Frequently asked questions

How do you find the slope between two points?

Subtract the y-values and divide by the difference of the x-values: m = (y₂ − y₁) ÷ (x₂ − x₁). This is the rise over the run.

What does an undefined slope mean?

If both points have the same x-value, the line is vertical and the run is zero. Division by zero is undefined, so a vertical line has no slope value.

How is the distance formula related to the Pythagorean theorem?

The horizontal and vertical differences between two points are the legs of a right triangle, and the distance is its hypotenuse. That gives d = √((x₂ − x₁)² + (y₂ − y₁)²).

How do you find the midpoint of two points?

Average the x-values and average the y-values: M = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).

More Geometry calculators

Browse every geometry calculator.

Other calculators