Equation of a Straight Line

The equation of a straight line is usually written this way:

y = mx + b

(or "y = mx + c" in the UK see below)


What does it stand for?

y=mx+b graph

Equation of a Straight Line y=mx+b
Slope or
y value when x=0
(see Y Intercept)

y = how far up

x = how far along

m = Slope or Gradient (how steep the line is)

b = value of y when x=0

y=mx+b intercept

How do you find "m" and "b"?

m =  Change in Y Change in X

Knowing this we can work out the equation of a straight line:

Example 1

y=2x+1 graph

m = 2 1 = 2

b = 1 (value of y when x=0)

Putting that into y = mx + b gets us:

y = 2x + 1

With that equation we can now ...

... choose any value for x and find the matching value for y

For example, when x is 1:

y = 2×1 + 1 = 3

Check for yourself that x=1 and y=3 is actually on the line.

Or we could choose another value for x, such as 7:

y = 2×7 + 1 = 15

And so when x=7 you will have y=15

Positive or Negative Slope?

Going from left-to-right, the cyclist has to Push on a Positive Slope:

negative slope   zero slope   positive slope

Example 2

y=-3x graph

m = −3 1 = −3

b = 0

This gives us:

y = −3x + 0

We do not need the zero! So:

y = −3x


Example 3: Vertical Line

graph x=2

What is the equation for a vertical line?
The slope is undefined ... and where does it cross the Y-Axis?

In fact, this is a special case, and we use a different equation, not "y=...", but instead we use "x=...".

Like this:

x = 1.5

Every point on the line has x coordinate 1.5,
that is why its equation is x = 1.5

Rise and Run

rise and run

Sometimes the words "rise" and "run" are used.

And so the slope "m" is:

m = rise run

You might find that easier to remember.


Now Play With The Graph !

You can see the effect of different values of m (the slope) and b (the y intercept) at Explore the Straight Line Graph


Other Forms

We have been looking at the "slope-intercept" form. The equation of a straight line can be written in many other ways.

Another popular form is the Point-Slope Equation of a Straight Line.


358,359,517,518, 1156, 1157, 3204, 3205, 3206, 3207



Country Note:

Different Countries teach different "notation" (as sent to me by kind readers):

In the US, Australia, Canada, Eritrea, Iran, Mexico, Portugal, Philippines and Saudi Arabia the notation is: y = mx + b
In the UK, Australia (also), Bahamas, Bangladesh, Belgium, Brunei, Bulgaria, Cyprus, Egypt, Germany, Ghana, India, Indonesia, Ireland, Jamaica, Kenya, Kuwait, Malaysia, Malawi, Malta, Nepal, New Zealand, Nigeria, Oman, Pakistan, Peru, Singapore, Solomon Islands, South Africa, Sri Lanka, Turkey, UAE, Zambia and Zimbabwe y = mx + c
In Afghanistan, Albania, Algeria, Brazil, China, Czech Republic, Denmark, Ethiopia, France, Lebanon, Netherlands, Kosovo, Kyrgyzstan, Norway, Poland, Romania, South Korea, Surinam, Spain, Tunisia and Viet Nam: y = ax + b
In Azerbaijan, China, Finland, Russia and Ukraine: y = kx + b
In Greece: ψ = αχ + β
In Italy: y = mx + q
In Japan: y = mx + d
In Cuba and Israel: y = mx + n
In Romania: y = gA + C
In Latvia and Sweden: y = kx + m
In Serbia and Slovenia: y = kx + n
In your country: let us know!

... but it all means the same thing, just different letters.