y = mx + b
y = x + 1 (m = 1, b = 1)
y = mx + b is the equation of any straight line that is not vertical. m is the slope, how much y changes each time x goes up by 1. b is the y-intercept, the value of y when x is 0, where the line crosses the vertical axis. Fill in m and b and you have described one particular line.
What each letter in y = mx + b stands for
Four letters, and only two of them are numbers you fill in.
- m is the slope. The amount y changes every time x increases by 1. A slope of 3 climbs 3 for every 1 across. A slope of −0.5 drops half a unit for every 1 across.
- b is the y-intercept. The value of y when x is 0. On a graph it is the height at which the line crosses the vertical axis.
- x and y stay as letters. They are the two things that vary. Give x a value and the equation hands you the matching y.
So in y = 3x + 5, the slope is 3 and the intercept is 5. Feed in x = 4 and you get y = 17. That is the whole machine.
One thing worth fixing early: the sign belongs to the number. In y = 2x − 7 the intercept is −7, not 7. The equation only ever adds b, so a minus sign in front of it means b itself is negative.
How to find b in y = mx + b
Which method you use depends on what you were handed.
- From the equation. If it is already in this form, b is the number on its own. No work needed.
- From a graph. Find where the line crosses the vertical axis and read the value.
- From the slope and one point. Put the point’s x and y into the equation along with m, and solve for b. With m = 2 and the point (3, 11): 11 = 2(3) + b, so b = 5.
- From two points. Work out the slope first, then use method 3 with either point.
Method 2 has a trap in it that method 3 does not, and it bites hardest on real data rather than homework. b is the value of y when x is zero, not the height where the line meets the left edge of the picture. Those are the same thing only when the horizontal axis starts at zero.
On a chart whose x-axis runs from 20 to 60, reading the line’s height at the left edge gives you y at x = 20, which is not b and can be a long way from it. Textbook graphs commonly start at zero, so the habit forms without ever being tested. Charts from instruments and spreadsheets often do not. Check where the axis starts before you read anything off it, and if it does not start at zero, use method 3 instead.
How to graph y = mx + b
This form is built for graphing, because b hands you a point before you have done any arithmetic at all.
- Plot b on the vertical axis. For y = 2x + 3, that is the point (0, 3).
- From there, count the slope: along 1, then up by m. For a slope of 2, that is 1 right and 2 up, landing on (1, 5).
- Mark the second point and draw the line through both.
- For a fractional slope, use the fraction as it stands. A slope of 3/4 is 4 across and 3 up, which avoids counting three quarters of a square.
A negative slope counts downwards instead. For y = −2x + 3, from (0, 3) you go 1 right and 2 down.
Worked examples
Reading an equation
y = −4x + 9. The slope is −4, so the line falls 4 for every 1 across. The intercept is 9, so it crosses the vertical axis at (0, 9).
Building one from a slope and a point
Slope 5, through (2, 3). Substitute: 3 = 5(2) + b, so 3 = 10 + b, so b = −7. The equation is y = 5x − 7.
Building one from two points
Through (1, 4) and (3, 10). Slope first: (10 − 4) ÷ (3 − 1) = 3. Then use either point. With (1, 4): 4 = 3(1) + b, so b = 1. The equation is y = 3x + 1. Check it with the other point: 3(3) + 1 = 10. It fits.
If you would rather write the line straight from a point without solving for b at all, that is what the point slope form calculator does, and the two equations describe the same line.
Reading a whole equation off a graph
Two clear points are enough. Say the line passes through (0, 4) and (2, 10).
- Slope. (10 − 4) ÷ (2 − 0) = 6 ÷ 2 = 3, so m = 3.
- Intercept. One of the points has x = 0, so b is sitting there already: b = 4.
- Write it. y = 3x + 4.
When neither point sits on the vertical axis, work out m the same way, then put one point back into the equation and solve for b. Through (2, 10) with m = 3: 10 = 3(2) + b, so b = 4. The same answer, one step longer.
Rearranging an equation that arrives in another shape
An equation like 2x + 3y = 6 describes a line perfectly well, it just does not tell you m and b at a glance. Get y on its own:
2x + 3y = 6 → 3y = −2x + 6 → y = −2/3 x + 2
Now it is readable: the slope is −2/3 and the intercept is 2. The only step people trip on is the second one, where every term gets divided by 3, including the 6.
Why m and b, of all letters
This gets asked a lot, and the origin is usually explained with a story that has no historical evidence behind it.
The popular story is that m comes from a French word, usually given as montant or monter, meaning to climb, and credited to Descartes. Duke University’s page on the subject rejects this directly: there is no evidence for the connection, and Descartes did not use m at all.
What is actually known is narrower and more honest. The earliest known use of m for slope, in Duke’s account, is an 1844 British textbook, Matthew O’Brien’s A Treatise on Plane Co-Ordinate Geometry. The Irish mathematician George Salmon then used y = mx + b from 1848 onwards, and he cited O’Brien, so he may simply have copied the notation. Beyond that, in Duke’s words, it is not known why m was chosen and the choice may have been arbitrary. The historian Howard Eves put it more bluntly: it just happened.
There is no accepted origin story for b either. It follows m in the alphabet and it was already there in Salmon’s book. That is the whole of it.
Worth saying plainly: the letters carry no meaning. Nothing about the maths would change if they were called p and q, which is exactly what happens in some countries.
The version written with c, and the other letters
If you have seen y = mx + c and wondered whether it is a different equation, it is not. It is the same equation with a different letter for the intercept, and which one you were taught depends on where you were taught.
y = mx + c is standard in the United Kingdom. Third Space Learning, for instance, publishes the same lesson twice: b for its American readers, c for its GCSE ones, where m is called the gradient rather than the slope. The same convention is common across much of the Commonwealth.
It goes further than two letters. Duke’s page records several national habits:
| Where | What the letters are | Note |
|---|---|---|
| United States | y = mx + b | m is the slope |
| United Kingdom | y = mx + c | m is the gradient |
| Sweden | y = kx + m | k from koefficient; note m means the intercept here |
| Netherlands | y = ax + b, px + q or mx + n | slope called the direction coefficient |
| Austria | k for the slope, d for the intercept | Duke names the letters without giving the equation |
| France | y = ax + b, and y = sx + b is used | the s borrowed from the English word slope |
The Swedish one is the reason this matters rather than being trivia. There, m is the intercept, the opposite of what it means here. If you are reading a paper, a textbook or a piece of software from somewhere else, check which letter is doing which job before you trust a number.
None of this changes the maths. The line is the same line whatever the letters, and so is the form itself.
Where y = mx + b is actually used at work
“When will I ever use this” is a question this equation attracts more than most, and the honest answer is that most people who use it never write it down in these letters. It turns up wherever something has a starting amount and then changes at a steady rate.
- Calibrating an instrument. This is the big one. A scale, a pressure sensor, a thermocouple: the reading is converted to a real measurement with a straight line, where m is the gain and b is the zero offset. Taring a balance before you weigh something is setting b. Telling the two apart is how a bad reading gets fixed. If zero is right but the error grows as the reading grows, that points to a gain error in m. If the error stays about the same size right across the range, that points to an offset error in b.
- Anything billed at a rate. A standing charge plus a price per unit. b is what you owe before you have used anything, m is the cost of each unit after that.
- Estimating a job. A setup or mobilisation cost, then a cost per metre, per square foot or per hour. The same two numbers.
- Levels on site. A known height at a known chainage, plus a fall per metre. Given one, the equation gives you the height anywhere along the run.
In every one of those, b is the number people forget. It is easy to think about the rate and ignore the starting value, and a forecast built on m alone is wrong by exactly b at every single point.
Practice questions, with the answers
Five questions, one for each thing on this page that tends to go wrong. Work them before you look.
- What are m and b in y = −3x + 8?
- What are m and b in y = 5 − 2x?
- Write the equation of the line with slope 4 that passes through (2, 3).
- Rearrange 4x + 2y = 10 so that m and b can be read off it.
- A chart’s horizontal axis runs from 30 to 90. At x = 30 the line is at y = 12, and it climbs by 2 for every 1 across. What is b?
Show the answers
- m = −3, b = 8. The minus sign belongs to the 3.
- m = −2, b = 5. The order is reversed, so read which term carries the x rather than which number comes first.
- 3 = 4(2) + b, so b = −5. The equation is y = 4x − 5.
- 2y = −4x + 10, so y = −2x + 5. Slope −2, intercept 5.
- Not 12. That is y at x = 30, and the axis does not start at zero. Going back 30 units at 2 per unit removes 60, so b = 12 − 60 = −48.
Frequently asked questions
What is x in y = mx + b?
x is the input, the value you choose or measure. It is not solved for and it does not have one value. Every point on the line is a pair of an x you picked and the y the equation gives back. That is what makes the equation a line rather than a single point: x is allowed to be anything.
Why is it written y = mx + b and not y = b + mx?
Convention, nothing more. Addition works in any order, so y = b + mx is the same line and is not wrong. Writing the x term first matches how equations of higher degree are written, with the biggest power leading, and it keeps the slope in the same place on the page every time so it can be read at a glance.
It does create one trap. In y = 3 + 2x the slope is 2 and the intercept is 3, but the first number you see is the intercept. Read which term has the x attached rather than trusting the order.
What does it mean if b is 0?
The line passes through the origin, the point (0, 0), and the equation shortens to y = mx. This is the case where y is simply proportional to x: double the x and you double the y. That is only true when b is zero, which is why a rate on its own is not enough to describe most real situations.
Can every straight line be written as y = mx + b?
No, and there is exactly one exception. A vertical line has no slope, because moving between any two of its points changes y while x stays put, and the division that defines slope would need a zero on the bottom. With no value for m there is nothing to write. A vertical line is written x = a number instead, such as x = 4. Every other straight line fits the form.
How do you find m and b from a table of values?
Take any two rows and divide the change in y by the change in x to get m. Then put one row and that m back into the equation and solve for b. If the table happens to contain a row where x is 0, b is sitting there already and you can read it straight off. Check a third row against your finished equation: if it does not fit, the table is not a straight line and this form cannot describe it.