Prefer to click through the interactive model?
Linear functions — study guide
The same fragments the interactive model serves, read in order. One source, two views.
A straight line and nothing but
A function is linear when its graph is a straight line, and f(x) = mx + b is the shape every one of them takes: m and b are just two numbers, and once you know them you know the whole function, not just at the input you happened to plug in.
What earns a function that straight-line shape is a constant rate of change: every time the input goes up by one unit, the output changes by the exact same amount, no matter where you start. Take a step early in the domain and a step late in it, and the size of the output's move is identical either time. That is not true of a curve, which bends because its own rate of change keeps changing; a straight line is the one shape where it never does.
Two numbers are the whole story. m sets how much the output moves per unit of input, and b sets where the line sits before any input is applied. The rest of this concept is just naming those two numbers precisely — slope and intercept — and learning to read a line, graph one, and write one down from whatever you're handed.
Slope — how fast the line moves
Slope measures how much a line's output changes for each unit its input changes, and it has an exact formula: pick any two points on the line, (x1, y1) and (x2, y2), and the slope is (y2 - y1) / (x2 - x1) — the change in output divided by the change in input, or rise over run. Any two points on the same line give the same answer; slope is a property of the whole line, not of wherever you happened to measure it.
The sign tells you the direction. A positive slope means the line rises as you move right — every step forward gains height. A negative slope means it falls — every step forward loses height. A slope of exactly 0 is a flat, horizontal line: the output never changes no matter how far the input moves, like the constant grade of a ramp, or walking at a steady pace: how much ground you cover per step never changes, whether it's the first step or the hundredth.
The size of the slope tells you how fast. A slope of 5 climbs five units of output for every one unit of input — a steep line. A slope of 0.1 barely rises at all over the same stretch — a shallow one. The bigger the number, ignoring its sign, the steeper the climb or the drop.
The y-intercept — where the line starts
The y-intercept is the value a linear function outputs when its input is exactly 0 — the one point where the line crosses the vertical axis. In f(x) = mx + b, that value has a name: it is b. Set x to 0 in the formula and the m term vanishes entirely, leaving f(0) = b outright.
Think of b as a starting balance rather than a location, like a savings account's opening balance before a single deposit or withdrawal happens: a value already on the books before any change starts counting: it is what the function is worth before any input has had a chance to change it. Change m and you change how steeply the line climbs or falls, but b alone decides where that climb or fall begins.
A function can have any b at all — positive, negative, or 0 — and none of those change what kind of function it is. Only the starting value moves; the underlying line is still exactly as straight.
Putting it together — y = mx + b
Slope and intercept are not independent decorations on a line — together they are the whole equation. Slope-intercept form writes it out plainly: y = mx + b, where m is the slope and b is the y-intercept, both readable straight off the equation without any rearranging. Any straight line, except a vertical one, which is not a function at all, can be written this way, and no two different (m, b) pairs describe the same line.
Reading the equation as instructions makes the mechanism concrete: start at the point (0, b), then take a step of m for every unit you move to the right, like tracing a path by repeating the exact same step over and over from a fixed starting spot: the size of each step never changes, only how many you've taken. Each step is identical to the last, which is exactly what a constant rate of change means in practice — not a rule you have to trust, but a walk you could actually take.
Change m and every step gets steeper or shallower, or flips direction if the sign flips. Change b and the whole walk starts somewhere else on the vertical axis, without touching how steep it is. The two numbers do two separate jobs, and slope-intercept form is what lets you read both jobs off a single line of algebra.
Graphing a line from its equation
Graphing a line from y = mx + b starts with the one point the equation hands you for free: the y-intercept, (0, b). Plot that point first, then use the slope as a set of directions — for a slope written as a fraction, rise over run, move right by the run and up, or down if the slope is negative, by the rise, and mark a second point. Two points are enough; a straight line drawn through them is the whole graph.
A slope that is not already a fraction, like 3, is still one — 3 is 3/1 — so the same rise-over-run instructions apply: move right 1 and up 3. Repeat the same step a few more times and the points line up exactly, which is the fastest check that a graph was plotted correctly: every new point should sit on the same line as the last.
The equation also hands you a graph any other way you'd rather build it: pick a few convenient input values, compute the matching outputs with f(x) = mx + b, and plot the resulting pairs. Both routes end at the identical line, because a linear function only has one graph — there's no version of it that looks different depending on how you got there.
Writing the equation of a line
Sometimes a line hands you two points instead of a ready-made equation, and the fix is to compute the slope first: m = (y2 - y1) / (x2 - x1) from whichever two points you have. Once m is known, one of the points plugs into the equation to solve for b — substitute that point's x and y into y = mx + b and solve for the one remaining unknown.
A faster route skips solving for b outright: point-slope form writes the equation directly from a single point (x1, y1) and a slope, as y - y1 = m(x - x1). It describes the same line as slope-intercept form; it's just built from different ingredients, and it's often less algebra when a slope and one point are all you were given.
Either method ends at the same equation, because a slope and one point pin down exactly one line — there is no second line through that point with that same slope. Two points, or a point and a slope: both are enough information, and neither leaves any ambiguity about which line is meant.
Where the line crosses zero
The x-intercept is the flip side of the y-intercept: instead of asking what the function outputs at input 0, it asks what input makes the function output 0. Algebraically that means setting f(x), or y, to 0 and solving 0 = mx + b for x, which gives x = -b/m whenever m is not 0.
A function's output hitting 0 is also called a zero, or a root, of the function, and for a line there is at most one — the constant slope means the line crosses the horizontal axis at exactly one point, or never at all if the line is flat and sitting anywhere but 0. A perfectly flat line, m = 0, either is the horizontal axis itself, when b = 0 too, or never touches it.
Zeros carry meaning beyond the algebra: if a linear function models a balance, a distance, or a count over time, its zero is the exact input where that quantity runs out or reaches nothing — the one number worth solving for even when nobody asked for the whole equation.
Where straight lines show up later
A constant rate of change is a strong assumption, and plenty of real systems are close enough to it that a linear function is the right first model to reach for. A pipeline whose latency grows by a fixed amount per added stage, or whose cost grows by a fixed amount per request, behaves linearly over the range that matters — the slope is the cost per unit, and the intercept is whatever the pipeline costs before a single request runs.
A moving vehicle gives an even more literal example: distance traveled at a constant speed is a linear function of time, with the speed as the slope and the starting position as the intercept. Reading a sensor's calibration curve, converting one unit to another, or predicting a simple trend all lean on exactly this shape.
Not every relationship holds still like this — plenty of them curve, and reading those curves is its own set of tools built on top of what a straight line already teaches. But the line comes first, because it's the one case simple enough to solve exactly, and the case every messier one gets compared against.