Drop a coin into a vending machine, press B4, and out comes the same snack every single time. That dependable in-out behaviour — feed it something, get back exactly one thing — is the whole idea of a function. Once you see functions as machines, the strange-looking notation and the graphs that come later stop being mysterious and start being useful.
A function is a machine
A function takes an input, does something to it, and hands you back an output. The one rule that makes it a function: each input gives exactly one output. Put the same thing in, and you always get the same thing out. A vending machine that sometimes gave you chips and sometimes gave you nothing for the same button would be useless — and it would not be a function.
Here is a machine that takes a number, doubles it, then adds one:
You feed in \(3\), it doubles to \(6\), adds one, and out comes \(7\). Feed in \(10\) and you get \(21\). The rule never changes; only the input does.
The notation \(f(x)\)
Writing "the machine that doubles and adds one" every time is tiring, so we give the machine a short name — usually \(f\) — and write the rule like this:
\[ f(x) = 2x + 1 \]Read it out loud as "f of x equals two x plus one". The letter \(x\) is a placeholder for whatever you feed in. To actually run the machine on a number, you replace \(x\) everywhere it appears. So \(f(3)\) means "feed in 3":
\[ f(3) = 2(3) + 1 = 6 + 1 = 7 \]That is all \(f(3)\) ever means: substitute, then simplify. The little number in the brackets is the input; the result is the output. Slide the input below and watch the same machine respond.
In words \(f(x)\) is not "f times x". The brackets do not mean multiply — they mean "the output of the machine \(f\) when you feed it \(x\)". Whatever sits inside the brackets is what goes into the machine.
Domain and range
Two everyday questions follow naturally. What are you allowed to put in? and What can possibly come out?
The set of allowed inputs is the domain. The set of outputs you actually get is the range. For \(f(x) = 2x + 1\) you can feed in any number you like — positive, negative, fractions — so the domain is "all real numbers". And since doubling and adding one can land you anywhere, the range is "all real numbers" too.
Domains start to matter when a machine has a forbidden button. The machine \(g(x) = \dfrac{1}{x}\) cannot accept \(0\), because dividing by zero is undefined — so \(0\) is shut out of its domain. For now, just hold the two words in mind: domain = what goes in, range = what comes out.
- Start from the rule: \(f(x) = 3x - 2\).
- Feeding in \(4\) means replacing every \(x\) with \(4\): \(f(4) = 3(4) - 2\).
- Multiply first: \(3(4) = 12\), so \(f(4) = 12 - 2\).
- Subtract: \(12 - 2 = 10\).
So \(f(4) = \mathbf{10}\). The machine \(3x - 2\), fed a \(4\), returns \(10\).
The coordinate plane
A function pairs each input with an output — and pairs of numbers love to be drawn. The coordinate plane is two number lines crossing at right angles: a horizontal \(x\)-axis and a vertical \(y\)-axis. Where they cross is the origin, the point \((0, 0)\).
Every point is named by an ordered pair \((x, y)\). The order is fixed and it matters: the first number tells you how far across (right is positive, left is negative), the second how far up or down (up positive, down negative). To plot \((3, 2)\), start at the origin, walk 3 to the right, then 2 up, and mark the spot.
If you feed many inputs into a function and plot each pair \((x,\, f(x))\), the dots trace out the graph of the function — a picture of everything the machine does, all at once.
Graphing a line: \(y = mx + b\)
The simplest, most important graphs are straight lines. Any function you can write in the form
\[ y = mx + b \]is called linear, and its graph is a perfectly straight line. The two letters \(m\) and \(b\) are the only things you need to draw it, and each has a clear meaning.
The number \(b\) is the y-intercept — the height at which the line crosses the \(y\)-axis. It is simply the output when the input is \(0\), since putting \(x = 0\) leaves \(y = b\). It is your starting point.
The number \(m\) is the slope: how steeply the line climbs or falls. Slope is a rate of change — how much \(y\) moves for each step in \(x\):
\[ m = \frac{\text{rise}}{\text{run}} = \frac{\text{change in } y}{\text{change in } x} \]A slope of \(2\) means "every 1 step right, go 2 up". A positive slope climbs left-to-right; a negative slope falls. The bigger the size of \(m\), the steeper the line.
Here is \(y = 2x + 1\): it crosses the \(y\)-axis at \(1\) (the intercept) and rises \(2\) for every \(1\) it runs (the slope). Watch the slope triangle as you adjust it.
To draw any line by hand: plant a dot at \((0, b)\), then use the slope as a set of directions — run across, rise up (or down, if \(m\) is negative) — to find a second dot. Connect them and extend. Two points are all a straight line ever needs.
Tip — read it straight off the equation. In \(y = mx + b\), the number multiplying \(x\) is always the slope, and the number standing alone is always the y-intercept. In \(y = -2x + 5\), the slope is \(-2\) and the intercept is \(5\) — no calculation needed.
Reading slope and intercept off a graph
Going the other way — from a picture back to the numbers — uses the same two ideas. Find where the line crosses the \(y\)-axis: that height is \(b\). Then pick any two points on the line and count: how far up did it go (rise), and how far across (run)? Their ratio is the slope.
- Match it to \(y = mx + b\): the coefficient of \(x\) is \(-2\), and the lone number is \(5\). So \(m = -2\) and \(b = 5\).
- Plot the intercept first: mark \((0, 5)\) on the \(y\)-axis. That is your starting dot.
- Use the slope \(m = -2 = \dfrac{-2}{1}\): from \((0, 5)\), run \(1\) right and rise \(-2\) (that is, drop \(2\)). You land on \((1, 3)\).
- Plot \((1, 3)\), draw the straight line through both dots, and extend it. Because the slope is negative, the line falls as you move right.
The line has slope \(-2\) and y-intercept \(5\). As a quick check, when \(x = 0\), \(y = -2(0) + 5 = 5\) — exactly where we crossed the axis.
In words A linear function is a story with a beginning and a pace. The y-intercept \(b\) is where the story starts; the slope \(m\) is how fast it changes from there. Know those two numbers and you know the whole line.
Practice
Try each one yourself, then reveal the full solution.
1. For \(f(x) = 3x - 2\), find \(f(4)\).
Replace every \(x\) in the rule with \(4\):
\[ f(4) = 3(4) - 2 = 12 - 2 = 10 \]So \(f(4) = \mathbf{10}\).
2. State the slope and y-intercept of \(y = -2x + 5\).
Compare with the standard form \(y = mx + b\). The number multiplying \(x\) is the slope, and the number on its own is the y-intercept:
\[ m = -2, \qquad b = 5 \]The line has slope \(-2\) (it falls 2 for every 1 step right) and crosses the \(y\)-axis at \(y = 5\).
3. Find the slope of the line through the points \((1, 2)\) and \((3, 8)\).
Slope is rise over run — the change in \(y\) divided by the change in \(x\):
\[ m = \frac{8 - 2}{3 - 1} = \frac{6}{2} = 3 \]The slope is \(\mathbf{3}\): for each step right, the line climbs 3. (Subtract the coordinates in the same order in both top and bottom and you get the same answer.)