How to use the slope calculator
- Choose the mode. “Two points” finds the slope and the line through (x₁, y₁) and (x₂, y₂). “Point and slope” starts from one point and a known slope and gives the equation of the line.
- Enter the coordinates. Negative numbers and decimals are fine. The order of the points doesn’t matter: swapping them flips the signs of both the rise and the run, so the slope stays the same.
- Read the results. The large figure is the slope, shown as a reduced fraction when the inputs allow it, with the rise and run underneath. The cards give the equation, the y-intercept, the angle the line makes with the x-axis, the percent grade, and, in two-point mode, the distance and midpoint.
The small graph redraws as you type, with the rise and run drawn as a dashed step between the points.
The slope formula
Slope measures how steep a line is: how much it goes up or down (the rise) for each step to the right (the run). OpenStax’s Elementary Algebra 2e (section 4.4) writes it as:
Two textbook examples show how it works:
- (1, 2) and (4, 5). Rise 5 − 2 = 3, run 4 − 1 = 3, so m = 3 ÷ 3 = 1.
- (−2, −3) and (−7, 4). Rise 4 − (−3) = 7, run −7 − (−2) = −5, so m = 7 ÷ −5 = −7/5, or −1.4. This is the calculator’s opening example.
The most common error is mixing the order: subtracting y₁ from y₂ on top but x₂ from x₁ on the bottom. That flips the sign. Keep the same point first in both the numerator and the denominator.
Positive, negative, zero and undefined
- Positive slope: the line rises from left to right.
- Negative slope: the line falls from left to right.
- Zero slope: a horizontal line such as y = −5. The rise is 0 for any run.
- Undefined slope: a vertical line such as x = 8. The run is 0, and dividing by zero has no answer, so the textbook calls the slope undefined. The calculator shows the equation as x = 8 instead of y = mx + b.
A bigger absolute value means a steeper line: a slope of 3 is steeper than 1, and −3 is steeper than −1, just in the downhill direction.
From slope to the equation of the line
Once you know the slope, the y-intercept follows from either point. Section 4.5 of the same textbook uses the slope-intercept form:
For (−2, −3) and (−7, 4): b = −3 − (−7/5)(−2) = −3 − 14/5 = −29/5. The line is y = −7/5 x − 29/5. Check with the other point: −7/5 × (−7) − 29/5 = 49/5 − 29/5 = 20/5 = 4. It works.
The x-intercept is where y = 0, at x = −b ÷ m. A horizontal line that isn’t the x-axis does not cross it, so the calculator shows no x-intercept in that case.
The calculator keeps fractions exact when your inputs are whole numbers or short decimals, so you can copy the equation straight into homework. If you prefer decimals, the decimal slope is shown alongside.
Slope in the real world: pitch, grade and ramps
The same rise-over-run idea goes by different names outside the classroom.
- Roof pitch. Builders give pitch as inches of rise per 12 inches of run. The textbook’s roof rises 9 feet over an 18-foot run, a slope of 1/2, which is a 6-in-12 pitch. Enter the rise and run as two points, (0, 0) and (18, 9), to check it.
- Road grade. Highway signs give grade as a percentage: 100 × rise ÷ run. A road that climbs 6 feet over 100 feet has a 6% grade, a slope of 0.06, and an angle of only about 3.4°.
- Drains and pipes. The textbook’s sewer pipe drops 1/4 inch per foot. With both measured in inches, that is −1/4 ÷ 12 = −1/48.
- Ramps. Ramps are often described as a ratio such as 1:12, one unit of rise for every 12 units of run, which is a slope of about 0.083 or an 8.3% grade.
Percent grade and angle aren’t the same thing. A 100% grade is a 45° angle, not a vertical wall. The calculator shows both so you can compare them.
Distance, midpoint and angle
The rise and run are the legs of a right triangle whose hypotenuse joins the two points, so the distance between the points is √(run² + rise²), the Pythagorean theorem. For (1, 2) and (7, 10) the run is 6 and the rise 8, so the distance is 10.
The midpoint averages the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). The angle of the line is arctan(m), measured from the positive x-axis; it runs from −90° to 90°, and a slope of 1 is exactly 45°.
Slope as a rate of change
Slope is not only a property of a line on a graph. Whenever one quantity changes at a steady rate compared with another, the slope is that rate, in units of y per unit of x. If a car has 300 miles on the odometer at 1 p.m. and 420 at 3 p.m., the slope between those two points is (420 − 300) ÷ (3 − 1) = 60 miles per hour. If a plant is 4 inches tall in week 2 and 10 inches in week 5, it grew (10 − 4) ÷ (5 − 2) = 2 inches per week.
Reading slope this way makes the sign meaningful too. A negative slope in a cost table means the price falls as quantity rises; a zero slope means nothing changes.
Parallel and perpendicular lines
Parallel lines have the same slope. Perpendicular lines have slopes that are negative reciprocals of each other, so their product is −1. The calculator’s opening example has a slope of −7/5, so any line parallel to it also has slope −7/5, and any line perpendicular to it has slope 5/7. Vertical and horizontal lines are the exception: they are perpendicular, but a vertical line has no numerical slope.
Common mistakes are subtracting the coordinates in a different order on the top and bottom, and dividing run by rise instead of rise by run. Either one gives a wrong sign or the reciprocal of the right answer.
Sources & assumptions
How this calculator gets its numbers. Full method: our methodology.
- Slope m = (y₂ − y₁) ÷ (x₂ − x₁); a vertical line (same x) has undefined slope and a horizontal line has slope 0.
- The y-intercept is b = y₁ − m·x₁, so the line is y = mx + b. Exact fractions are shown when the inputs have up to nine decimal places.
- Angle = arctan(m) in degrees; grade = 100 × m percent; distance = √(run² + rise²).
Sources
- OpenStax (Rice University), Elementary Algebra 2e, 4.4 Understand Slope of a Line. m = (y₂ − y₁) ÷ (x₂ − x₁) = rise ÷ run, with Example 4.32 (a vertical line has undefined slope, a horizontal line slope 0), Example 4.33 ((1, 2) and (4, 5) → 1), Example 4.34 ((−2, −3) and (−7, 4) → −7/5), Example 4.38 (roof pitch 9/18 = 1/2) and Example 4.39 (a drain pipe falling 1/4 inch per foot, −1/48).
- OpenStax (Rice University), Elementary Algebra 2e, 4.5 Use the Slope-Intercept Form of an Equation of a Line. y = mx + b, where m is the slope and (0, b) the y-intercept, with Example 4.41 (y = −3x + 5) and Example 4.42 (x + 2y = 6).
Last reviewed . Building codes and accessibility rules set their own slope limits for roofs, ramps and drains; check the code that applies to your project.
Frequently asked questions
How do I find the slope between two points?
Subtract the y-values and divide by the difference of the x-values in the same order: m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 2) and (4, 5), m = 3 ÷ 3 = 1.
What does a negative slope mean?
The line goes down as you move to the right. For (−2, −3) and (−7, 4) the slope is −7/5: the line falls 7 units for every 5 units to the right.
What is the slope of a vertical line?
Undefined. Every point has the same x-value, so the run is 0 and the division has no answer. A horizontal line has slope 0.
How do I write the equation of a line from two points?
Find the slope m, then the y-intercept b = y₁ − m × x₁, and write y = mx + b. Through (1, 2) and (4, 5), m = 1 and b = 1, so y = x + 1.
How do I convert slope to percent grade?
Multiply the slope by 100. A slope of 0.06 is a 6% grade; a slope of 1/2 is a 50% grade.
How do I convert slope to an angle?
Take the inverse tangent: angle = arctan(m). A slope of 1 is 45°, and a slope of 0.5 is about 26.57°.