Skip to content
ToolBoxGeniehome

Slope Calculator

Calculators · Added

Two points fix a line, and everything else about it follows: how steep it is, which way it leans, how far apart the points are, where the middle sits, where it crosses each axis and what its equation looks like in each of the three forms a textbook asks for. Enter four coordinates and this works all of it out, including the vertical case where the slope does not exist at all.

First point (x₁, y₁)
Second point (x₂, y₂)
Try:

How to use the slope calculator

  1. 1Enter the first point as x₁ and y₁. Negative numbers and decimals are both fine.
  2. 2Enter the second point as x₂ and y₂.
  3. 3Press Calculate.
  4. 4Read the slope at the top — shown as an exact fraction when the coordinates are whole numbers, because 3/4 is more useful than 0.75.
  5. 5The table underneath gives the equation in slope-intercept, point-slope and standard form; the rows below it give the intercepts and the slopes of any parallel or perpendicular line.

Examples

A rising line

Input
(1, 2) and (4, 8)
Result
Slope 2, angle 63.43°, distance 6.708, midpoint (2.5, 5), y = 2x

Rise 6 over run 3. The line happens to pass through the origin, so the y-intercept is zero and the equation loses its constant term.

A falling line with a fractional slope

Input
(-2, 5) and (3, -5)
Result
Slope -2, angle -63.43°, distance 11.18, standard form 2x + y = 1

A negative slope means the line falls as you read left to right. The angle is negative for the same reason.

The vertical case

Input
(3, -1) and (3, 6)
Result
Slope undefined, equation x = 3, distance 7, no y-intercept

The run is zero, so the division cannot be done. The line still has a length, a midpoint and an equation — which is why this returns them rather than an error.

About the slope calculator

What slope actually measures

Slope is a rate: how much the line climbs for each unit it travels sideways. A slope of 2 means two units up for every one along, and a slope of 0.02 means the same journey gains two hundredths of a unit — the difference between a staircase and a wheelchair ramp. Because it is a ratio rather than a length, it does not change when you slide along the line or scale the drawing, which is what makes it the natural way to describe steepness.

The sign carries the direction, and reading it is a matter of convention: lines are read left to right, so a positive slope rises and a negative slope falls. A slope of zero is a horizontal line — it runs without rising. The absent case is a vertical line, which rises without running, and which has no slope rather than an enormous one.

The same quantity appears under other names elsewhere on this site and in the world. A road sign showing 12% is a slope of 0.12 expressed as a percentage. A roof described as 6/12 is a slope of 0.5. The angle of inclination is the arctangent of the same number. All four are shown here together for that reason: which one you want depends entirely on who you are talking to.

The vertical line, and why it is the interesting case

Almost every slope calculator handles two points fine until the two share an x coordinate, at which point a good many of them display Infinity, NaN, or an empty box. None of those is the answer. The mathematics is unambiguous: the run is zero, division by zero is undefined, and so the slope is undefined.

What matters is that undefined slope does not mean undefined line. The line through (3, −1) and (3, 6) is perfectly well described — it is every point whose x coordinate is 3, its equation is x = 3, the distance between the two points is 7, the midpoint is (3, 2.5), and it crosses the x-axis at 3. All of that is computed and shown here, with only the slope, the point-slope form and the y-intercept reported as absent, because those are the only three things that genuinely do not exist.

This is also why the standard form is worth knowing. Ax + By = C can express a vertical line as 1x + 0y = 3, while y = mx + b cannot express it at all — there is no value of m that works. A form that covers every case is more useful than one that covers the common cases and fails silently on the rest, which is the same principle that governs how this page reports its results.

Frequently asked questions

Why is the slope undefined rather than infinite?
Because dividing by zero is not an operation that produces a number, and infinity is not one either. A vertical line rises without ever running, so the ratio rise over run has no value — not a very large one. Calling it infinite would also lose information: two vertical lines at different positions would appear to have the same slope, when what they actually have is no slope and different equations, x = 3 and x = 7.
What is the difference between the three equation forms?
They describe the same line and make different things easy to read off. Slope-intercept, y = mx + b, shows the slope and where the line crosses the y-axis, which is why it is the one people graph from. Point-slope is what you write immediately after finding a slope and a point, with no rearranging. Standard form, Ax + By = C, keeps whole-number coefficients, handles the vertical case that slope-intercept cannot, and is the form that generalises to systems of equations.
Why is the slope shown as a fraction sometimes and a decimal other times?
A fraction is offered only when both the rise and the run are whole numbers, because that is when it is genuinely simpler — 3/4 tells you more at a glance than 0.75, and it is what a marked answer usually expects. When the coordinates are decimals, the fraction would be something like 2.7183/1.4142, which is worse than the decimal it came from, so it is not shown.
How do I get the slope of a perpendicular line?
Take the negative reciprocal: flip the fraction and change the sign, so a slope of 2 gives −1/2 and a slope of −3/4 gives 4/3. The two exceptions are the ones people forget, and both are handled here — a horizontal line has slope 0 and its perpendicular is vertical with no slope at all, while a vertical line has no slope and its perpendicular is horizontal with slope 0.
Is the distance the same as the difference in the coordinates?
Only when the line is horizontal or vertical. Otherwise the two points are separated in both directions at once, and the straight-line distance is the hypotenuse of the right triangle they form — the square root of run squared plus rise squared. That is the Pythagorean theorem applied to coordinates, and it is why the distance is always at least as large as either individual difference and usually larger than both.