The Equation of a Straight Line

Imagine you had to describe a straight line to a friend over the phone — no drawing allowed. You could read out point after point after point… and never finish, because a line has infinitely many. Yet it turns out you only ever need to say two numbers. Tell your friend how steep the line is and where it crosses the up-axis, and they can draw the exact same line you're looking at. Every straight line on Earth is captured by those two facts.

We bottle them in one tidy equation:

y = mx + c

The number m is the gradient — how steeply the line tilts — and c is the y-intercept — the height at which it crosses the y-axis. Read those two numbers off and you know the whole line. (The gradient is exactly the gradient you have already measured as rise over run.)

For a straight line written as y = mx + c:

Drive the line yourself

Pull the two sliders. Watch m tilt the line and c slide it up and down without changing its tilt. Notice that the line always crosses the y-axis at exactly the height c.

Worked example 1 — build the line, then use it

A line has gradient m = 2 and y-intercept c = 3. Write its equation, then find y when x = 4.

Slot the two numbers into y = mx + c:

y = 2x + 3.

That's the whole line. It climbs two units for every one across and crosses the axis at (0, 3). To find y at any x, just substitute. At x = 4:

y = 2(4) + 3 = 8 + 3 = 11.

Worked example 2 — from two points to the equation

Find the equation of the line through (1, 5) and (3, 11).

Step 1 — the gradient. Rise over run:

m = \frac{11 - 5}{3 - 1} = \frac{6}{2} = 3.

Step 2 — the intercept. We know y = 3x + c; we just need c. Substitute a point that's on the line — say (1, 5) — and solve:

5 = 3(1) + c \;\Rightarrow\; 5 = 3 + c \;\Rightarrow\; c = 2.

So the equation is y = 3x + 2. Check with the other point: 3(3) + 2 = 11 ✓. Either point works — that's a handy way to catch a slip.

Worked example 3 — a real straight-line story

A taxi charges a fixed \pounds 3 just to get in, then \pounds 2 for every mile you travel. Let y be the total fare and x the number of miles. The fare is

y = 2x + 3.

Look what the two numbers mean here. The gradient m = 2 is the rate — pounds per mile — and the intercept c = 3 is the starting cost before you've gone anywhere, the fare at x = 0. A 5-mile trip costs y = 2(5) + 3 = \pounds 13. Almost every "fixed charge plus a rate" situation — phone plans, gym membership, filling a pool — is secretly a y = mx + c line.

In y = mx + c the two letters have fixed jobs, and mixing them up is the classic slip:

This little equation is the quiet workhorse behind an astonishing amount of grown-up maths. In a science experiment you plot your measurements and draw the line of best fit — the straight line that threads closest through a cloud of scattered points. That line has an equation y = mx + c, and its m and c get chosen — fitted — to match the data as well as possible.

Statisticians call this a regression line, and it's the beating heart of the simplest machine-learning models: feed a computer a pile of examples, let it fit the best m and c, and now it can predict — tomorrow's temperature, a house price, a trend. The same two-number recipe that draws a school graph is quietly behind economic forecasts, trend lines, and the first models of artificial intelligence. Not bad for y = mx + c.

See it explained