PennyPages

Slope Calculator

Enter the two points, (x1, y1) and (x2, y2). You get the slope, the angle in degrees, the percent grade, the distance between the points and the midpoint — all updating as you type.

About the Slope Calculator

The slope of a line through two points is the rise divided by the run: how much y changes divided by how much x changes. From (0, 0) to (4, 3), y rises 3 while x runs 4, so the slope is 3 / 4 = 0.75. The same pair of points gives more than the slope, and this page works out all of it together: the angle the line makes with the horizontal (0.75 is about 36.87 degrees), the percent grade used on roads and ramps (the slope times 100, so 75 percent here), the straight-line distance between the points (5, by Pythagoras), and the midpoint (2, 1.5), halfway between them.

A vertical line is the one case with no slope: x does not change, the run is zero, and dividing by zero is undefined — so the calculator says so plainly instead of printing a wrong number, while still giving the distance and midpoint. A horizontal line has slope 0, angle 0 and grade 0. Everything updates as you type, and nothing you enter leaves your browser.

Common questions

What is the slope of the line through (0, 0) and (4, 3)?

0.75: the rise is 3 (from y = 0 to y = 3) and the run is 4 (from x = 0 to x = 4), and slope is rise over run, 3 / 4. The line also sits at about 36.87 degrees, a 75 percent grade, and the points are 5 apart.

How do you calculate slope from two points?

Subtract the first y from the second y, subtract the first x from the second x, and divide: slope = (y2 - y1) / (x2 - x1). The order does not matter as long as both subtractions run the same way.

What is the slope of a vertical line?

Its slope is undefined: x never changes, so the run is zero and the rise divided by zero has no answer. The line still has a distance between its points and a midpoint, which the calculator above still gives you.

How do I turn a slope into a percent grade?

The slope times 100: a slope of 0.75 is a 75 percent grade. Grade is the same steepness expressed the way road signs and ramp specifications use it — rise as a percentage of the horizontal distance.

How do I get the angle of a line from its slope?

Take the angle whose tangent is the slope: a slope of 0.75 is arctan(0.75), about 36.87 degrees above horizontal. A slope of 1 is exactly 45 degrees, and a horizontal line (slope 0) is 0 degrees.

Put this tool on your site

Free to embed — your visitors use it without leaving your page.

PennyPages #059 · free forever · same input, same answer, every time