Slope Calculator

Slope (m)—
Y-intercept (b)—
Line equation—

How Slope Calculator is calculated: Slope = (y2 − y1) ÷ (x2 − x1); line equation y = mx + b

What is slope, and what does this calculator find?

Slope is a single number that describes how steep a straight line is. It tells you how much the line rises or falls for every step it takes to the right. A slope of 2 means the line climbs 2 units for every 1 unit it moves across, while a slope of −1 means it falls 1 unit for every step across. A slope of 0 means the line is flat.

This slope calculator takes two points on a line and returns the slope, the y-intercept, and the full equation of the line. You type in the two points, and the answer updates live. It is the same calculation students do by hand in algebra class, done instantly and without arithmetic slips.

Slope shows up far beyond school maths. Road builders use it for gradients, roofers use it for roof pitch, and data analysts use it to read trends on a chart. Anywhere a straight line connects two measurements, slope is the number that says how fast one thing changes against the other.

How the slope formula works

The formula is slope = (y2 − y1) ÷ (x2 − x1). Take the change in the y-values, divide it by the change in the x-values, and you have the slope. For the default points (1, 2) and (4, 8), the y-change is 8 − 2 = 6 and the x-change is 4 − 1 = 3, so the slope is 6 ÷ 3 = 2.

Once you know the slope, the y-intercept follows from the line equation y = mx + b. Put in one of your points and the slope, then solve for b. With slope 2 and the point (1, 2), the equation 2 = 2 × 1 + b gives b = 0, so the line passes through the origin and its equation is y = 2x + 0.

The sign of the slope is the quickest thing to read. A positive slope rises from left to right, a negative slope falls, and zero is horizontal. The size tells you the steepness: a slope of 5 is much steeper than a slope of 0.5. A scientific calculator helps with the division when the points are decimals.

The two points: the input people get wrong

The only input here is two points, and the common slip is mixing up the order. It does not matter which point you call first and which you call second — (y2 − y1) ÷ (x2 − x1) gives the same answer either way — but you must keep each x with its own y. Pairing x1 with y2 is the mistake that produces a wrong slope.

Coordinates can be negative, and that is where sign errors creep in. Take the points (−2, 3) and (2, −1): the y-change is −1 − 3 = −4 and the x-change is 2 − (−2) = 4, so the slope is −4 ÷ 4 = −1. Subtracting a negative number adds, and forgetting that step is the most common source of a wrong sign.

If the two points have the same x-value, the line is vertical and the slope does not exist as a number. The calculator shows a dash for the slope and gives the equation as x = 1, or whatever that shared x-value is. That is not an error — a vertical line really has no slope, because its x-change is zero and division by zero is undefined.

A worked example: from two points to a full equation

Start with the default points (1, 2) and (4, 8). The y-change is 8 − 2 = 6 and the x-change is 4 − 1 = 3. Divide 6 by 3 and the slope is 2. The line climbs two units for every unit it runs across, a fairly steep upward line.

Next, the y-intercept. Using the point (1, 2) and slope 2 in y = mx + b gives 2 = 2 × 1 + b, so b = 0. The line crosses the y-axis at the origin, and the full equation is y = 2x + 0. Check it against the second point: 2 × 4 + 0 = 8, which matches y2 exactly.

Try a second pair, (0, 1) and (4, 3). The y-change is 3 − 1 = 2, the x-change is 4 − 0 = 4, and the slope is 2 ÷ 4 = 0.5. The intercept is 1, since the line passes through (0, 1), so the equation is y = 0.5x + 1. A slope of 0.5 is a gentle rise, half as steep as the first example.

Where slope is used in real life

In school, slope is the core of straight-line graphs, and it is the first step toward calculus. Students use it to sketch lines, to find equations from graphs, and to check whether two lines are parallel — parallel lines share the same slope, while perpendicular lines have slopes that multiply to −1.

Outside school, slope is a gradient. A road sign that says 1 in 10 means the road rises 1 metre for every 10 metres forward, a slope of 0.1. Roof pitch, wheelchair ramps, and drainage pipes are all specified as slopes, because a slope is the simplest way to say how steep something is.

In data work, slope is the trend. If a shop's sales rise from 200 units in January to 260 in April, the slope is 20 units per month, and that number is the trend line on the chart. Paired with the distance between points calculator, slope covers the two most common questions you can ask about a pair of points.

Slope calculator vs midpoint and distance calculators

Slope, distance, and midpoint all start from the same two points, but they answer different questions. Slope asks how steep the line between the points is. The midpoint calculator asks where the exact middle of the segment sits. The distance calculator asks how far apart the points are.

Use slope when the direction and rate of change matter — the steepness of a line, the gradient of a road, the trend in a chart. Use distance when the length matters, such as the gap between two places on a map. Use the midpoint when you need the centre, such as splitting a line segment into two equal halves.

The three tools share their inputs, so the same pair of points can be run through all three. Together they describe a line segment completely: its steepness, its length, and its centre. A linear equation calculator goes one step further and solves equations built from the line you have just found. A slope is also the first step of a line of best fit: a linear regression calculator takes a whole set of points and finds the slope and intercept that describe them together.

Common slope mistakes

The first mistake is dividing the wrong way round: (x2 − x1) ÷ (y2 − y1) instead of (y2 − y1) ÷ (x2 − x1). That gives the reciprocal of the slope, not the slope. Remember the phrase rise over run — the y-change, the rise, always goes on top.

The second mistake is the sign. Subtracting a negative coordinate adds, so 3 − (−2) is 5, not 1. Write the subtraction out in full with brackets, or type the numbers into the calculator and let it handle the signs. A single missed minus flips a rising line into a falling one.

The third mistake is treating a vertical line as a slope of zero. A vertical line has an undefined slope, while a horizontal line has a slope of zero — they are opposites, not the same thing. And the fourth mistake is reading slope as an angle: a slope of 1 is a 45-degree line, but a slope of 2 is about 63 degrees, not 90.

How to use this slope calculator

Type the first point into the x1 and y1 boxes and the second point into x2 and y2. The slope, the y-intercept, and the line equation update live as you type, so you can watch the line change as you move a point. Decimals and negative numbers both work.

Check the equation against your points as a sanity test: put x2 into the equation and you should get y2 back. For the defaults, 2 × 4 + 0 = 8, which matches. If it does not match, one of the points was typed wrong.

Everything runs in your browser — no account, no upload, and your numbers never leave your device. Use it for homework, graph sketching, or gradient checks, and keep the distance and midpoint calculators nearby for the other half of coordinate geometry.

Frequently Asked Questions

Subtract the y-values, subtract the x-values, then divide: slope = (y2 − y1) ÷ (x2 − x1). For the points (1, 2) and (4, 8), that is (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. The order of the points does not matter as long as each x stays with its own y.

A vertical line has no slope — it is undefined, because the x-change is zero and you cannot divide by zero. This calculator shows a dash for the slope and gives the equation as x = the shared x-value, for example x = 1. A horizontal line is different: its slope is exactly 0.

First find the slope m, then use y = mx + b with one of your points to solve for the intercept b. For (1, 2) and (4, 8), the slope is 2 and b = 0, so the equation is y = 2x + 0. Check it by putting x = 4 in: 2 × 4 + 0 = 8, which is the second point's y-value.

A negative slope means the line falls as it moves to the right — y decreases while x increases. For example, the points (0, 5) and (2, 1) give a slope of (1 − 5) ÷ (2 − 0) = −2. A slope of −1 falls at 45 degrees, and a more negative number like −5 falls much more steeply.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.