CALCULATORCASTLE

Slope Calculator

Calculate slope, midpoint, and distance between two points.

About

Slope Calculator

The first calculator takes two points and returns the slope, the angle of incline, the horizontal and vertical change, the distance between them, and the equation of the line, with a plot that redraws itself from your numbers. The second works backwards: give it one point, a distance and either the slope or the angle, and it finds the other point. That one has two answers, since a distance runs both ways along a line.

What slope measures

Slope, called gradient in much of the world, is a single number for how steep a line is and which way it leans. It is written m. The larger the absolute value, the steeper the line, and the sign says which direction it runs.

  • A line rises from left to right when m > 0.
  • A line falls from left to right when m < 0.
  • A line is horizontal when m = 0.
  • A vertical line has no slope at all. The formula would divide by zero, so the slope is undefined rather than infinite.

The everyday phrasing is rise over run: how much the line climbs divided by how far it travels sideways. A slope of 0.75 climbs three units for every four across.

The formula

Take two points on the line and divide the change in y by the change in x:

m=y2y1x2x1=tan θ(x₂, y₂)(x₁, y₁)dΔyΔxθ

The numerator y2 − y1 is Δy, the vertical change, and the denominator x2 − x1 is Δx, the horizontal change. Which point you call the first makes no difference: swap them and both signs flip, leaving the ratio the same.

In the diagram, Δx and Δy are the two legs of a right triangle whose hypotenuse is d, the straight-line distance between the points. That is why the distance comes from the Pythagorean theorem:

d=(x2x1)2+(y2y1)2

And because the slope is the ratio of the opposite side to the adjacent side of that same triangle, it equals the tangent of the angle the line makes with the horizontal. The Right Triangle Calculator covers that triangle in its own right.

A worked example

Given the points (3, 4) and (6, 8), find the slope, the distance and the angle of incline. The slope first:

m=8463=43

Then the distance, which comes out a whole number because 3, 4 and 5 form a Pythagorean triple:

d=(63)2+(84)2=5

And the angle, from the inverse tangent of the slope:

θ=tan1(43)=53.13°

So the line climbs 4 units for every 3 across, the two points sit 5 units apart, and the line rises at just over 53 degrees.

Writing the line down

Once you have the slope, the line itself can be written three common ways. Slope-intercept form is the one most people meet first, where b is the y-intercept, the height at which the line crosses the y-axis:

y=mx+b

Point-slope form is more convenient when you have a slope and any point on the line, and it needs no rearranging to use:

yy1=m(xx1)

The calculator above reports the slope-intercept form along with both intercepts, so it gives you the crossing points on each axis as well as the equation.

Parallel and perpendicular

Two lines are parallel when their slopes are equal, which is the tidy consequence of slope being a pure measure of direction. Two lines are perpendicular when the product of their slopes is −1:

m1×m2=1

So a line perpendicular to one of slope 0.75 has slope −4/3. Flip the fraction and change the sign, which is why the pair is called the negative reciprocal. The exception is the horizontal and vertical pair: they are perpendicular, but one has slope 0 and the other has none, so the product rule cannot be applied to them.

Grades, ratios and angles

Outside mathematics the same quantity is quoted three different ways, and mixing them up is the usual source of error.

A percent grade is the slope multiplied by 100, so a 6% grade climbs 6 metres over 100 horizontally. That is a slope of 0.06 and an angle of only 3.43°, which is steeper than it sounds on a motorway. A ratio such as 1:12 means one unit up for twelve along, a slope of 0.0833 and an angle of 4.76°; that is the maximum ramp gradient allowed under the Americans with Disabilities Act. An angle in degrees is the θ this calculator reports.

The three only agree at small values. A 100% grade is not vertical, it is 45°, because rise equals run. Baldwin Street in Dunedin, New Zealand, is often cited as the world's steepest residential street at roughly 35%, which works out at 19.3° rather than the near-cliff the percentage suggests. Railways rarely exceed 2% on main lines, since steel wheels on steel rail have very little grip to spare.

Slope beyond straight lines

A straight line has one slope everywhere, which is what makes it straight. A curve does not: its steepness changes from point to point. Differential calculus handles that by taking the slope of the tangent line at a single point, and that value is the derivative of the function there.

The connection is direct. The slope formula is the change in y over the change in x between two points; shrink the gap between those points toward zero and the same ratio becomes the derivative. Everything on this page is the flat, finite case of that idea, which is why the topic is worth being comfortable with before calculus rather than during it.

Four mistakes that account for most wrong answers

The commonest is inverting the fraction. Slope is the change in y over the change in x, not the other way round, and run over rise gives the reciprocal, which is the slope of a perpendicular line rather than the one you wanted.

Second is subtracting inconsistently. If the y values are taken as second minus first, the x values have to be too. Mixing the order flips the sign and turns a rising line into a falling one.

Third is reading a graph without checking the axis scales. A line that looks like a 45-degree climb is only a slope of 1 when both axes use the same units per division; on a chart where the vertical axis counts thousands and the horizontal counts years, the visual angle means nothing at all and only the numbers do.

Fourth is treating a percent grade as an angle. They are different quantities that happen to look alike below about 10 degrees, and a 100% grade is 45 degrees rather than vertical.

Reading your result

Check the sign before anything else. A negative slope means the line falls from left to right, and if that does not match your data, two coordinates have probably been swapped between the points.

If the calculator reports the slope as undefined, the two x values are identical and the line is vertical. That is a real answer rather than an error: the line exists, it just has no slope, and its equation is x = a constant.

For the second calculator, remember that both answers are correct. A point 5 units from (1, 1) along a line of slope 0.75 can lie at (5, 4) or at (−3, −2), and only the context tells you which direction you meant. Both sit on the same line, which is why both share the equation y = 0.75x + 0.25.

Common questions

Frequently asked questions

Divide the change in y by the change in x: m = (y2 - y1) / (x2 - x1). For (3, 4) and (6, 8) that is 4 divided by 3. Which point you call the first does not matter, because swapping them flips the sign of both the top and the bottom.

The line falls from left to right. A positive slope rises, a slope of zero is horizontal, and a vertical line has no slope at all because the formula would divide by zero. The size of the number, ignoring the sign, is the steepness.

Because the change in x is zero, and dividing by zero has no answer. Infinity is not a number the division produces; there is simply no value that works. The line is still perfectly well defined and its equation is x equals a constant.

The slope is the tangent of the angle, so the angle is the inverse tangent of the slope. A slope of 4/3 gives an angle of 53.13 degrees, and a slope of 1 gives exactly 45 degrees because the rise equals the run.

A percent grade is the slope times 100, so a 6% grade is a slope of 0.06 and an angle of 3.43 degrees. They only look similar at shallow values: a 100% grade is 45 degrees, not vertical, because the rise equals the run.

Take the negative reciprocal: flip the fraction and change the sign, so that the two slopes multiply to -1. A line perpendicular to one of slope 0.75, which is 3/4, has slope -4/3. Parallel lines simply share the same slope.

Because a distance runs both ways along a line. A point 5 units from (1, 1) with a slope of 0.75 can be at (5, 4) or at (-3, -2). Both lie on the same line and share the same equation, so only your context decides which direction was meant.

The derivative of a function at a point is the slope of the line that just touches the curve there. The slope formula is the change in y over the change in x between two points, and shrinking the gap between them toward zero turns that ratio into the derivative.