Maths dictionary

Linear functions and straight-line graphs (y = mx + c)

By Viktor Lassen6 min readUpdated 3 September 2026

A linear function is a function whose graph is a straight line, y = mx + c. Here is what the gradient m and the y-intercept c mean, with a taxi ride as the example.

Functions grow in many different ways, and each way describes how something develops in real life. It could be how the money in a bank account grows with a certain interest rate, or how the price of a taxi ride grows for every kilometre you drive. Money in a bank account and a taxi ride are described by different types of function, but when we talk about linear functions, we mean things that grow linearly. That is, the graph of the function is a straight line. A lot of situations out in the real world are described by what we call a linear function.

The equation of a linear function

Every type of function has its own equation, a form the function has to fit before it counts as that type. A linear function has the equation

y=mx+cy = mx + c

This says that the function value, yy, is equal to the matching xx-value multiplied by a number mm, plus a constant cc. You will often see the same line written as f(x)=ax+bf(x) = ax + b in other books. The letters are different, the line is exactly the same. In the UK the gradient is called mm and the constant is called cc, so that is what we use here.

A straight line in a coordinate system, labelled y = mx + c

What m and c mean

In the equation there are two values we don't know to begin with, mm and cc.

mm is the gradient of the line. The gradient of a straight line is defined as how far we go up the y-axis when we go 1 along the x-axis. In the picture you can see the definition of what the gradient is.

The gradient m: how far the line goes up the y-axis when we go 1 along the x-axis

As you might guess, that means the bigger mm is, the steeper the line. The gradient mm tells us something about how much the function slopes. If the line went 4 up the y-axis every time it goes 1 along the x-axis, mm would be 4. We can also have gradients that are negative. Then the graph slopes downwards, and for every 1 we go along the x-axis, the line goes down instead of up.

cc is rather simpler. It describes where the function crosses the y-axis.

The y-intercept c: the point where the line crosses the y-axis

If the function hits the y-axis at 2, cc is 2. We call cc the y-intercept. The guide on gradient and y-intercept goes through both of them with more examples and pictures.

Why c is where the line crosses the y-axis

How do we know that cc describes the crossing with the y-axis? All the points on the y-axis have one thing in common: their xx-values are all 0. That is what it means to be on the y-axis. So if we want to find the place where the function is on the y-axis, we just put 0 in xx's place in the equation of the line:

y=mx+cy = mx + c

y=m×0+cy = m \times 0 + c

We can see that the term with mm disappears completely, because it is multiplied by 0, and so we only have cc left:

y=cy = c

We have now shown that the crossing point between the y-axis and our straight line is exactly what cc describes.

Setting up a linear function

Let's take an example with both mm and cc. Say a function goes 5 up the y-axis when it goes 1 along the x-axis, and the function crosses the y-axis at 3. Then we can set up the function:

y=5x+3y = 5x + 3

mm is 5 because the function goes 5 up the y-axis when it goes 1 along the x-axis. cc is 3 because the function crosses the y-axis at 3.

Linear functions in real life

When we work with linear functions in real life, a meaning like "crossing with the y-axis" can seem a bit odd. A taxi ride helps. Say a taxi costs £2 per km, and there is a start fee of £4. Every kilometre adds £2 to the price, and that is exactly what mm is: how much we go up the y-axis when we go 1 along the x-axis. The start fee is what we pay before we have driven anything at all, so that is where the price starts on the y-axis, our cc. The function for the price becomes

y=2x+4y = 2x + 4

That is also why GCSE calls the gradient a rate of change: here it is the £ per km. The whole example, with the graph, is in the guide on gradient and y-intercept.

Finding the equation from two points

Often we need the gradient of a linear function without being told it. Typically we have been given two points on the line instead. For that there is a formula, which funnily enough is called the two-point formula:

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

Once we have mm, we find cc by putting one of the points into the equation. The full walkthrough is in the guide on finding the equation of a straight line from two points.

Straight lines through data

Sometimes we don't have a neat line at all, just a lot of points from measurements, and we want the straight line that describes those points as well as possible. That is called linear regression, or at GCSE a line of best fit. It is not a different topic: it just finds the mm and cc of the line that fits best. See the guide on scatter graphs and the line of best fit.

Common misunderstandings

  • "m is just a number you multiply by." It is that, but it is also a picture. mm is how far the line goes up (or down) every time you move 1 to the right. If you can read that off a graph, you can read off mm.
  • "c is where the word problem starts, so it changes as you go." No. cc is where the line crosses the y-axis, the value when xx is 0. In the taxi example cc is the £4 start fee, and you pay it no matter how far you drive.
  • "£6 for 3 km means the gradient is 6." No. The gradient is how much we go up when we go exactly 1 along the x-axis, not 3. £6 for 3 km is £2 per km, so mm is 2. Always rewrite the information so it says how much yy grows for 1 step in xx.
  • "A line of best fit is a different kind of maths." It isn't. Linear regression just finds the mm and cc of the straight line that fits a set of points best.

Guides on this topic

Frequently asked questions

Read next

Want to get good at maths?

Mathara explains every topic step by step with videos, exercises and personal feedback.

👉 Get started for free