Skip to main content
CalcMax

Slope Intercept Form Calculator

Range: -1,000,000 – 1,000,000

Range: -1,000,000 – 1,000,000

Range: -1,000,000 – 1,000,000

Range: -1,000,000 – 1,000,000

Result

y = 4x - 2

Slope-intercept form

Slope
4.000000
y-intercept
-2.000000

The slope-intercept form is how a line is usually written down — y = mx + b — and two points are all you need to fill it in. The slope m is how much y moves per unit of x, the rise over run; the y-intercept b is where the line meets the vertical axis. This page takes the four coordinates, works out both numbers, and prints the linear equation they define. Both numbers stay visible beside it, so the arithmetic can be checked by hand: multiply the slope by either x and add the intercept, and you should land back on that point's y. Two points at the same x are the one case with no answer at all, because that line is vertical and never crosses the y-axis.

Eight pairs of points and the line each one defines

x1y1x2y2Equation
12310y = 4x - 2
0011y = x
0521y = -2x + 5
0122y = (1/2)x + 1
0322y = (-1/2)x + 3
1353y = 3
1224y = 2x
0716y = -x + 7

Every row is a pair of points and the slope-intercept equation through them, worked out by the same code that answers the form above. The rows are chosen to cover the shapes the equation can take: an ordinary slope, a slope of 1, a negative slope, a negative slope of exactly -1, a horizontal line whose equation has no x left in it, a line through the origin whose equation has no constant left in it, and the two fractional cases where the bracket around the coefficient is doing real work. Reading down the last column is also the quickest way to see what each shape looks like once it is written out.

Formula

points (x1, y1) and (x2, y2) → m = (y2 - y1) / (x2 - x1) → b = y1 - m * x1 → y = m * x + b

m
The slope: how far the line climbs for each step to the right. It is the rise divided by the run, and its sign is the direction — positive climbs, negative falls, zero is a horizontal line. A slope of 4 means y gains 4 for every 1 that x gains.
b
The y-intercept: the y value where the line crosses the vertical axis, which is the same as the y value at x = 0. It is what is left of a point once the slope's contribution is taken out, and it is the one number on this page that is read straight off the equation.
(x1, y1), (x2, y2)
The two points. Either one can be called the first: swapping them flips the sign of both the numerator and the denominator of the slope, and the two flips cancel. They must not share an x coordinate, since that division would be by zero.
x, y
The two variables of the finished equation. Any pair that satisfies it sits on the line, which is what makes the equation useful: put in any x and it returns the y of the point above it, without needing either of the original two points.

Use it when a straight line is described by two of its points and you want the line itself — the equation, the slope, and where it crosses the axis — rather than one number about it. A pair of readings from a table, two positions on a graph, a starting value and one later measurement: from those, the slope says how fast it changes and the intercept says where it started. If what you want is only the slope, or only a prediction partway between the points, the linked calculators below do exactly that and nothing else.

Worked examples

  1. (1, 2) and (3, 10) — the ordinary case

    1. Rise: 10 − 2 = 8. Run: 3 − 1 = 2
    2. Slope: m = 8 / 2 = 4
    3. Intercept: b = 2 − 4 × 1 = -2
    4. The equation: y = 4x - 2

    Check it against both points, which is the habit worth keeping: at x = 1, 4 × 1 − 2 = 2 ✓, and at x = 3, 4 × 3 − 2 = 10 ✓. The intercept being negative while both points are above the axis is not a mistake — the line is steep enough to cross the axis well to the left of the first point, at x = 0.5.

  2. (0, 1) and (2, 2) — a slope that is not a whole number

    1. Rise: 2 − 1 = 1. Run: 2 − 0 = 2
    2. Slope: m = 1 / 2 = 0.5
    3. The first point already sits on the axis, so b = 1 falls straight out of it: b = 1 − 0.5 × 0 = 1
    4. The equation: y = (1/2)x + 1

    The coefficient is bracketed because 1/2x would read as 1 divided by 2x. Notice the two printed numbers agree with the equation exactly: the slope line says 0.5 and the equation says (1/2), which is the same number written as a fraction — the page prints a terminating decimal as a fraction when the denominator is small enough to be worth reading.

  3. (1, 3) and (5, 3) — a horizontal line

    1. Rise: 3 − 3 = 0. Run: 5 − 1 = 4
    2. Slope: m = 0 / 4 = 0
    3. Intercept: b = 3 − 0 × 1 = 3
    4. The equation: y = 3, because the slope term contributes nothing at all

    A slope of zero collapses the equation: there is no x left in it, and writing y = 0x + 3 would only add a term that is always zero. This is the one place where the printed equation stops looking like y = mx + b, and that is correct rather than a shortcut — every point on the line has y = 3, whatever x is.

Limitations

Straight lines only, and only through two distinct points. If both points have the same x the line is vertical: it has no slope and never crosses the y-axis, so there is no slope-intercept form to give, and the page reports a failed calculation instead of printing one — the honest answer there is x = 3, which is not an equation this page can produce. Points that coincide are the same case, since infinitely many lines pass through a single point. The slope is rounded to six decimal places before the intercept is worked out from it, so the two printed numbers always agree with the printed equation, at the cost of the printed line differing from the exact one beyond the sixth decimal when the slope repeats — 1/3 becomes 0.333333 and the equation is built from that. The equation is printed, not solved: the page will not tell you where the line meets the x-axis, whether two lines are parallel, or what y is at some other x. Coordinates are limited to a million in either direction, and no units are involved anywhere, since a coordinate is a number and not a measurement.

Frequently asked questions

Which point should I enter first?
Either one — the answer does not change. Swapping the two points flips the sign of the numerator and of the denominator in (y2 - y1) / (x2 - x1), and the two flips cancel out. The same is true of the intercept, because it is worked out from a point and the slope. The only thing that matters is that both coordinates of a point are entered on the same row of the form.
What if both points have the same x?
Then the line is vertical and the page reports a failed calculation. A vertical line has no slope at all — the run is zero, so the division has no answer — and it never crosses the y-axis, so the equation y = mx + b cannot describe it however m and b are chosen. A vertical line's equation is x = 3, one that has no slope and no y-intercept in it, which is why it is outside what this page produces.
Why is the slope rounded, and what happens with a repeating decimal?
It is rounded to six decimal places, and the intercept is then worked out from the rounded value rather than the exact one. That is deliberate: it makes the two numbers on the results panel agree exactly with the equation printed below them, so the answer can be checked by hand. The cost is that with a repeating slope, such as the 1/3 that (1, 1) and (4, 2) produce, the printed line is the rounded line — 0.333333 rather than a third.
How is this different from the point-slope form calculator?
The inputs differ. This page takes two points, which is what you usually have; the point-slope page takes one point and a slope you already know, and prints the equation in a form that shows that point. They describe the same line, so the two pages can be used one after the other: take the slope this page reports, and the first of your two points, and the point-slope page will write the same line the other way round.
Why does the equation sometimes show a fraction and sometimes a decimal?
A decimal that ends within a few digits is printed as a fraction when the denominator is small — 0.5 comes out as (1/2), 0.25 as (1/4) — because that is how a slope is normally written by hand. Anything longer stays a decimal rounded to six places, so a third appears as 0.333333. The number is the same either way, and the slope line above the equation always agrees with it.
How do I check the answer by hand?
Put either of your x values into the printed equation and see whether you get that point's y. For (1, 2) and (3, 10) the equation is y = 4x - 2, and at x = 1 that is 2 while at x = 3 it is 10 — both points sit on the line. If one of them fails, the slope and the intercept printed above the equation are the two numbers to compare against your own arithmetic.

References

Related calculators