Slope Calculator: Fraction, Line Equation, Angle & Midpoint
Two points are all it takes to pin down a straight line. Give the calculator any two points and it returns the slope as an exact fraction, the line’s equation in three forms, its angle and percent grade, and the distance and midpoint between the points. It also draws the graph. If you know one point and the slope instead, switch tabs and it builds the equation from those.
Numbers can be negative, decimals or fractions: −3, 2.5, 3/4.
Four Kinds of Slope, Read From the Sign
Slope measures how steep a line is and which way it goes as you read left to right:
| Slope | What the line does | Example points | m |
|---|---|---|---|
| Positive | Rises | (2, 1) and (10, 7) | 3/4 |
| Negative | Falls | (−3, 5) and (1, −7) | −3 |
| Zero | Flat (horizontal) | (−1, 3) and (5, 3) | 0 |
| Undefined | Straight up and down (vertical) | (4, −2) and (4, 6) | no value |
The last two rows get mixed up. A horizontal line has a slope of 0: it has run but no rise, and 0 divided by anything is 0. A vertical line has an undefined slope: it has rise but no run, and you can’t divide by 0. That isn’t “infinitely steep” as a number; there just isn’t a number. Some people call the horizontal case “no slope”, which only makes the confusion worse. “Zero slope” and “undefined slope” are the clear names.
The bigger the slope’s size (ignoring the sign), the steeper the line. A slope of −3 is steeper than a slope of 3/4, even though it’s the smaller number.
(2, 1) to (10, 7), Step by Step
The slope formula is rise over run:
m = (y₂ − y₁) ÷ (x₂ − x₁)
For the points (2, 1) and (10, 7):
- Rise: y₂ − y₁ = 7 − 1 = 6.
- Run: x₂ − x₁ = 10 − 2 = 8.
- Slope: m = 6/8 = 3/4, or 0.75.
Every 4 units to the right, the line climbs 3 units.
The order of the points doesn’t matter, as long as you keep it the same on top and bottom. Starting from (10, 7) gives (1 − 7) ÷ (2 − 10) = −6 ÷ −8 = 3/4, the same answer. Two slips give a wrong one:
- Run over rise. 8/6 = 4/3 is upside down. The y’s always go on top.
- Mixing the order. (7 − 1) ÷ (2 − 10) = 6 ÷ −8 = −3/4. Taking y₂ first on top but x₁ first on the bottom flips the sign.
Negative coordinates need brackets. For (−3, 5) and (1, −7), the run is 1 − (−3) = 4, not 1 − 3. The rise is −7 − 5 = −12, so m = −12/4 = −3. The calculator’s steps show the brackets for any negative number.
Finding the Slope From a Graph
On a grid you can count instead of subtracting. Pick two points where the line crosses grid corners exactly, then count squares: up or down for the rise, left to right for the run. Up is positive, down is negative, and the run is always counted left to right.
Two things go wrong with graphs:
- Points that aren’t on corners. Reading (3.4, 2.1) by eye adds guesswork to both numbers. Choose points that sit exactly on grid intersections, even if they’re far apart. Far apart is better anyway, because a small reading error matters less over a long run.
- Axes with different scales. If each square is 1 unit across but 5 units up, a line that looks like 45° actually has a slope of 5. Count in units, not squares. The angle on the page only matches the slope when both axes use the same scale.
That second point is why the calculator draws its graph with the same scale on both axes. A slope of 1 looks like 45°, a slope of 3/4 looks gentler, and the rise and run triangle is drawn to size. The grid label in the corner says how many units each square is worth.
Writing the Equation of the Line
Once you have the slope, the line has three common ways of being written down. For the line through (2, 1) and (10, 7):
Slope-intercept form, y = mx + b. You know m = 3/4. Put one point in to find b: 1 = (3/4)(2) + b, so b = 1 − 3/2 = −1/2. The line is y = (3/4)x − 1/2. The b tells you where the line crosses the y-axis, at (0, −1/2).
Point-slope form, y − y₁ = m(x − x₁). Drop the slope and one point straight in: y − 1 = (3/4)(x − 2). No b to work out, which makes it the quickest form to write.
Standard form, Ax + By = C. Clear the fractions and gather x and y on one side: 3x − 4y = 2. The usual rules are that A, B and C are whole numbers with no common factor, and A isn’t negative. The calculator follows those rules.
All three describe the same line. A quick check: put x = 10 into y = (3/4)x − 1/2 and you get 7.5 − 0.5 = 7, which is the second point.
Vertical lines are the exception. They can’t be written as y = mx + b, because there’s no m. The line through (4, −2) and (4, 6) is simply x = 4. A horizontal line through (−1, 3) and (5, 3) is y = 3.
Where the Line Crosses the Axes
The y-intercept is where the line crosses the y-axis, at x = 0. In y = mx + b it’s simply b. For y = (3/4)x − 1/2, that’s the point (0, −1/2).
The x-intercept is where the line crosses the x-axis, at y = 0. Set y to 0 and solve: 0 = (3/4)x − 1/2 gives x = 2/3, so the point is (2/3, 0). In general it’s x = −b ÷ m.
Two cases have no x-intercept or no y-intercept:
- A horizontal line such as y = 3 never reaches the x-axis. (The line y = 0 is the x-axis itself.)
- A vertical line such as x = 4 never reaches the y-axis, and it crosses the x-axis at (4, 0).
The calculator gives the x-intercept as a point beside the slope-intercept form, which already shows b.
Reading the Slope Off an Equation
You don’t always start with two points:
- y = mx + b: the number in front of x is the slope. In y = −2x + 9, m = −2.
- Ax + By = C: the slope is −A/B. For 2x − 5y = 10, m = −2/(−5) = 2/5. You can also solve for y: −5y = −2x + 10, so y = (2/5)x − 2.
- y − y₁ = m(x − x₁): the number in front of the bracket is the slope.
- y = 3 (no x): slope 0. x = −2 (no y): slope undefined.
To check any of these in the calculator, pick two points on the line and type them in. For 2x − 5y = 10, the points (0, −2) and (5, 0) give 2/5.
Missing Coordinates and Points on One Line
The slope formula works backwards as well. If you know the slope and one point, you can find any other point on the line.
Find a missing y. A line through (1, 2) has slope 3. Where is it at x = 5? The run from x = 1 to x = 5 is 4, so the rise is 3 × 4 = 12. The point is (5, 2 + 12) = (5, 14). You get the same result from the equation y − 2 = 3(x − 1).
Find a missing x. The same line reaches y = 20 when the rise is 18, which takes a run of 18 ÷ 3 = 6. That’s x = 1 + 6 = 7.
Are three points on one line? They are when the slope from the first to the second equals the slope from the second to the third. For (1, 2), (3, 8) and (6, 17): the slopes are 6/2 = 3 and 9/3 = 3, so yes, they’re collinear. Swap the last point for (6, 16) and the second slope becomes 8/3, so the three points bend.
To check any pair in the calculator, type it in and compare the slopes it reports. The calculator’s second tab, “One point and the slope”, gives the full equation straight from a point and a slope, which is the fastest route for missing-coordinate questions.
Parallel and Perpendicular Lines
Parallel lines never meet, so they rise at the same rate: they have the same slope. A line parallel to y = (3/4)x − 1/2 also has slope 3/4.
Perpendicular lines meet at a right angle. Their slopes are negative reciprocals: flip the fraction and change the sign. Multiplied together they give −1.
- Slope 3/4 → perpendicular slope −4/3. Check: (3/4) × (−4/3) = −1.
- Slope −3 → perpendicular slope 1/3.
- Slope 0 (horizontal) → perpendicular is vertical, slope undefined. This is the one pair the “multiply to −1” rule can’t cover.
Example. Find the line through (4, 1) perpendicular to y = (3/4)x − 1/2. The slope is −4/3. Then 1 = (−4/3)(4) + b, so b = 1 + 16/3 = 19/3. The line is y = (−4/3)x + 19/3. Put x = 4 back in: −16/3 + 19/3 = 3/3 = 1. ✓
The calculator lists the perpendicular slope with every result.
Slope, Angle and Percent Grade
The same steepness can be written three ways:
- Slope m: rise ÷ run.
- Angle θ with the x-axis: θ = tan⁻¹(m).
- Percent grade: m × 100, the rise for every 100 units of run.
They don’t scale together. Doubling the grade doesn’t double the angle, and a 100% grade is only 45°, not vertical:
| Grade | Slope | Angle |
|---|---|---|
| 1% | 0.01 | 0.57° |
| 5% (1 in 20) | 0.05 | 2.86° |
| 8.33% (1 in 12) | 0.0833 | 4.76° |
| 10% | 0.1 | 5.71° |
| 25% | 0.25 | 14.04° |
| 50% | 0.5 | 26.57° |
| 100% | 1 | 45° |
For a falling line, tan⁻¹ gives a negative angle. Measured counterclockwise from the positive x-axis, the calculator reports it as that angle plus 180°. The line through (−3, 5) and (1, −7) gives tan⁻¹(−3) ≈ −71.57°, so 108.43°.
Run is horizontal, not along the slope. A 1,000 m stretch of road measured along its surface that climbs 300 m is not a 30% grade. The 1,000 m is the sloped length, so 300 ÷ 1,000 is the sine of the angle, not the tangent. The horizontal run is √(1,000² − 300²) ≈ 953.9 m, and the grade is about 31.4%. On gentle slopes the difference is tiny (a 50 m climb in 1,000 m is 5.006% rather than 5%), but on steep ones it matters.
Distance and Midpoint From the Same Two Points
The run and rise also give the straight-line distance between the points. It’s the hypotenuse of the right triangle they make, so it comes from the Pythagorean theorem:
d = √((x₂ − x₁)² + (y₂ − y₁)²)
For (2, 1) and (10, 7): d = √(8² + 6²) = √100 = 10. For (−3, 5) and (1, −7): d = √(4² + (−12)²) = √160 = 4√10 ≈ 12.65. The calculator keeps the distance in simplest radical form, like 4√10, as well as giving the decimal. For simplifying roots like √160 by hand, see the Square Root Calculator.
The midpoint is halfway between the points: average the x’s and average the y’s.
- (2, 1) and (10, 7): ((2 + 10)/2, (1 + 7)/2) = (6, 4)
- (−3, 5) and (1, −7): ((−3 + 1)/2, (5 − 7)/2) = (−1, −1)
The graph marks the midpoint as a lime dot on the line.
Slope as a Rate of Change
When the axes measure real quantities, slope gets units: the y-unit per x-unit. That makes it a rate.
A water tank draining. At 0 hours the tank holds 12 liters; at 5 hours it holds 2. The points are (0, 12) and (5, 2), so m = (2 − 12) ÷ (5 − 0) = −2 liters per hour. The negative sign says the amount is going down. The y-intercept, 12, is the starting amount, and the line y = −2x + 12 predicts the tank is empty at x = 6 hours, its x-intercept.
Distance and time. On a graph of distance (y, in km) against time (x, in hours), the slope is the speed in km per hour. A steeper line means faster travel; a flat stretch means stopped.
The calculator doesn’t need units, but labeling them when you write down the answer keeps the slope meaningful: “−2” says little, “−2 liters per hour” says it all. Data that doesn’t sit exactly on one line needs a fitted trend line instead, but two clean readings work just like this.
Average rate of change on a curve. For a curve, the slope keeps changing. The slope between two points on it still means something: it’s the average rate of change over that stretch. If a car has gone 30 km after half an hour and 90 km after 1.5 hours, the points (0.5, 30) and (1.5, 90) give 60 km per hour, its average speed between those times, whatever it did in between.
Roofs, Ramps and Roads
Builders and engineers describe slope in their own ways, but it’s all rise over run.
Roof pitch is given as rise per 12 units of run. A 6/12 pitch rises 6 inches for every 12 inches across: slope 1/2, a 50% grade, about 26.57°. A 4/12 pitch is 18.43°, an 8/12 pitch is 33.69°, and a 12/12 pitch is exactly 45°. To use the calculator, enter (0, 0) and (12, 6) for a 6/12 roof.
Wheelchair ramps. The 2010 ADA Standards set the steepest running slope for a ramp at 1:12, meaning 1 unit of rise for every 12 of run. That’s a slope of 1/12, a grade of about 8.33% and an angle of about 4.76°. A 30-inch rise therefore needs at least 360 inches (30 feet) of run.
Road grades. A sign showing a 6% grade means the road rises or drops 6 m for every 100 m of horizontal distance: slope 0.06, about 3.43°. The grade on a sign is the slope written as a percent.
Ratios like “1 in 20”. This means 1 unit of rise per 20 of run: slope 1/20, a 5% grade, about 2.86°. Type (0, 0) and (20, 1) into the calculator to see all three at once.
