Algebra

Slope Calculator

Enter two points to find their slope, line equation, midpoint, and distance. Keep exact answers alongside decimal values.

Enter two coordinate pairs

Enter each point as an x coordinate and a y coordinate. Include negative signs when a point lies left of or below the origin.

Point 1
Point 2

Signed numbers, including zero. Up to 15 integer digits and 10 decimal places. Grouped commas such as 1,000 are accepted.

Slope — exact

Enter all four coordinates, then select Calculate.

Your inputs are processed in your browser and are not sent to a server.

Formulas and worked examples

Slope and line

From (1, 2) to (4, 6)

m = (6 − 2) ÷ (4 − 1) = 4/3

The rise is 4 and the run is 3. Substituting the first point into b = y − mx gives b = 2/3, so y = (4/3)x + 2/3.

Midpoint and distance

The same two points

Midpoint (5/2, 4); distance 5

Average the two x coordinates and the two y coordinates to find the midpoint. The right triangle with legs 3 and 4 has distance √(3² + 4²) = 5.

Vertical and horizontal

Zero run or zero rise

x = −2 or y = 3

Points (−2, 1) and (−2, 7) form a vertical line: x = −2, with undefined slope. Points (−2, 3) and (5, 3) form a horizontal line: y = 3, with slope 0.

An irrational distance

From (0, 0) to (1, 1)

m = 1; distance = √2

The line is y = x and its midpoint is (1/2, 1/2). The exact distance is √2; at six decimal places, it is approximately 1.414214.

The general formulas

For points (x₁, y₁) and (x₂, y₂), Δx = x₂ − x₁ and Δy = y₂ − y₁. If Δx is nonzero, the slope is m = Δy ÷ Δx and the y-intercept is b = y₁ − mx₁. The resulting line is y = mx + b.

The midpoint is ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). Euclidean distance is √((Δx)² + (Δy)²), assuming a rectangular coordinate plane with compatible axis units.

Further reading: OpenStax, Linear Functions and The Rectangular Coordinate Systems and Graphs.

Common questions

Is a vertical slope infinite?

This calculator calls it undefined, because division by zero does not produce a real-number slope. Two distinct points with the same x coordinate give the line x = that coordinate. If x = 0, the line is the y-axis itself, so it has no single y-intercept.

What happens when both points are identical?

The distance is 0 and the midpoint is that same point. The slope formula becomes 0 ÷ 0, and infinitely many lines pass through the point. The result therefore says “No unique line” and leaves the slope undefined.

Does reversing the points change the result?

It reverses the signs of both rise and run, so their ratio stays the same. The line, midpoint, and distance are unchanged. Keep the same point order in both coordinate differences.

How are exact answers and decimals handled?

Entered decimals become exact fractions. Line classification, fractions, and midpoint calculations use integer arithmetic. Square distances remain exact; perfect rational square roots become fractions, and other distances remain radical expressions that are not necessarily simplified. Decimal displays use up to 0, 2, 4, 6, or 10 places, omit trailing zeros, and round halfway values away from zero. Irrational distances use an exact midpoint comparison for rounding. The ≈ sign marks every rounded value, even one displayed as 0.

Can I paste coordinates with commas or exponents?

Enter each coordinate in its own field. Correctly grouped thousands commas, such as −1,234.5, are accepted. Use a decimal point and a leading zero, such as 0.5. Fraction expressions such as 1/3, exponent notation, and whole coordinate pairs are not accepted. Each field allows up to 15 integer digits, 10 decimal places, and 64 characters.

Are these measurements or exact mathematical coordinates?

The tool treats every entered digit as exact. It does not estimate measurement uncertainty. A tiny nonzero run still produces a finite slope, even if a rounded display makes the points appear to share an x coordinate. Physical distance requires the same units and scale on both perpendicular axes.