By now a function is a machine: you feed it an input, it hands back an output, every time the same. The leap of precalculus is to stop treating each function as a fixed object and start building new functions from old ones — sliding them around the plane, feeding one machine into another, and even running a machine backwards to recover what you started with.
Three moves do almost all the work, and the rest of your mathematical life leans on them. You can transform a graph (move, stretch, flip it), compose two functions into one, and invert a function to undo it. Master these and you stop memorising a hundred separate curves — you learn a handful of parent shapes and a grammar for reshaping them.
Moving a graph around: \( y = a\,f(x - h) + k \)
Here is the master transformation. Take any function \( f \) — call it the parent — and wrap it in three knobs:
\[ y = a\,f(x - h) + k. \]Each knob does exactly one thing to the picture, and once you see what, you can read any transformed graph at a glance.
- \( k \) — vertical shift. It is added to every output, so it lifts the entire graph up by \( k \) (or down, if \( k \) is negative). Nothing about the shape changes; the whole curve just rides higher or lower.
- \( h \) — horizontal shift. Replacing \( x \) by \( x - h \) slides the graph right by \( h \). This catches everyone out the first time: a subtraction moves the curve in the positive direction. The reason is honest bookkeeping — to get the same output the parent gave at some input, the new input has to be \( h \) larger, because the function only "sees" \( x - h \). Make the input bigger by \( h \) and the picture shifts right by \( h \).
- \( a \) — vertical stretch (and flip). It multiplies every output, so the graph is stretched away from the \( x \)-axis by a factor of \( |a| \) — tall and thin for \( |a| > 1 \), short and squat for \( |a| < 1 \). And if \( a < 0 \), every output changes sign, which reflects the whole graph across the \( x \)-axis, turning a valley into a hill.
That is the entire vocabulary. The best way to feel it is to turn the knobs yourself, so play with the widget below — drag \( a \), \( h \) and \( k \) and watch the curve answer.
Two curves, one idea. The faint dashed curve is the untouched parent \( f(x) \); the bold dawn-coloured one is the transformed \( a\,f(x-h)+k \). Try switching the parent with the tabs — between \( x^2 \), \( |x| \), \( \sqrt{x} \), \( x^3 \) and \( 1/x \) — and you'll find the same three knobs behave identically on every shape. The grammar of shifting, stretching and flipping doesn't care which curve it acts on; that's exactly what makes it worth learning once.
Composition: a function inside a function
Sometimes you want to run two machines back to back: take an input, push it through \( g \), then feed that result straight into \( f \). Bolting the two together gives a single new function, the composition, written with a small circle:
\[ (f \circ g)(x) = f\big(g(x)\big). \]Read it inside-out: do \( g \) first, then \( f \). The notation looks backwards because \( f \) is written on the left but acts last — the parentheses tell the true order. It helps to picture an assembly line: the raw \( x \) enters \( g \), the half-finished \( g(x) \) rolls into \( f \), and \( f(g(x)) \) comes off the end.
Order matters. In general \( f \circ g \neq g \circ f \) — swapping which machine runs first usually gives a different result, just as putting on socks then shoes is not the same as shoes then socks. There is also a quiet domain caveat: for \( f(g(x)) \) to make sense, \( g(x) \) must itself be a legal input to \( f \). If \( g \) ever outputs a value that \( f \) can't accept, that \( x \) is simply not in the domain of the composition.
Inverse functions: pressing undo
If a function is a machine, its inverse is the same machine run in reverse. Where \( f \) sends \( x \) to some output, the inverse \( f^{-1} \) takes that output and hands you back the original \( x \). The two cancel perfectly:
\[ f^{-1}\big(f(x)\big) = x. \]Geometrically there is a beautiful picture for this. Reversing a machine swaps the roles of input and output, which on a graph means swapping the \( x \)- and \( y \)-axes — so the graph of \( f^{-1} \) is simply the reflection of \( f \) across the line \( y = x \). Hold a mirror along that diagonal and the two curves fall onto each other.
Not every function can be undone. If two different inputs ever produce the same output, the reverse machine wouldn't know which one to return. So a function has an inverse only when it is one-to-one — each output comes from exactly one input. The quick test is visual: a function is one-to-one when it passes the horizontal line test, meaning no horizontal line crosses its graph more than once.
To actually find an inverse, the recipe is three short steps:
- Write \( y = f(x) \).
- Swap \( x \) and \( y \) everywhere — this is the algebraic version of reflecting across \( y = x \).
- Solve the new equation for \( y \). That \( y \) is \( f^{-1}(x) \).
Piecewise functions
Not every function follows one rule across its whole domain. A piecewise function is stitched together from several rules, each governing its own interval of inputs — the function checks where \( x \) lands and applies the matching rule. The most familiar example is the absolute value: it leaves nonnegative numbers alone and flips negatives to positive, which is really two rules in disguise:
\[ |x| = \begin{cases} \;\;x, & x \ge 0, \\[2pt] -x, & x < 0. \end{cases} \]The brace says "pick the line that matches your input." For \( x \ge 0 \) the graph is the ray \( y = x \); for \( x < 0 \) it is the ray \( y = -x \); together they make the familiar \( \mathrm{V} \). Many real-world functions — tax brackets, shipping costs, anything with thresholds — are piecewise at heart.
- Match the form \( y = a\,f(x - h) + k \). Reading off: \( a = -2 \), \( h = 3 \), \( k = 1 \), with parent \( f(x) = x^2 \).
- \( h = 3 \): the \( (x - 3) \) slides the parabola right by 3.
- \( a = -2 \): the factor of \( 2 \) stretches it vertically by ×2 (steeper, narrower), and the minus sign flips it so it opens downward instead of up.
- \( k = 1 \): finally the whole thing lifts up by 1.
The result is a downward-opening parabola, twice as steep as \( y = x^2 \), with its vertex at \( (\mathbf{3}, \mathbf{1}) \).
- For \( (f \circ g)(x) \), do \( g \) first: feed \( g(x) = x^2 \) into \( f \). So \( (f \circ g)(x) = f(x^2) = 2x^2 + 1 \).
- For \( (g \circ f)(x) \), do \( f \) first: feed \( f(x) = 2x + 1 \) into \( g \). So \( (g \circ f)(x) = (2x + 1)^2 = 4x^2 + 4x + 1 \).
The two answers, \( 2x^2 + 1 \) and \( 4x^2 + 4x + 1 \), are plainly different — a clean demonstration that \( f \circ g \neq g \circ f \). Order really does matter.
Practice
Try each one yourself, then reveal the full solution.
1. Describe \( y = \sqrt{x + 4} - 2 \) as a transformation of \( f(x) = \sqrt{x} \).
Write it in master form. Since \( x + 4 = x - (-4) \), we have \( h = -4 \) and \( k = -2 \), with \( a = 1 \).
So the square-root curve shifts left by 4 (because \( h \) is negative) and down by 2. There is no stretch or flip.
The shift left also drags the domain along: \( \sqrt{\;\cdot\;} \) needs a nonnegative inside, so we require \( x + 4 \ge 0 \), giving the domain \( x \ge \mathbf{-4} \). The graph now starts at the point \( (-4, -2) \) and rises to the right.
2. Find the inverse of \( f(x) = 3x - 6 \).
Follow the recipe. Start with \( y = 3x - 6 \).
Swap \( x \) and \( y \): \( x = 3y - 6 \).
Solve for \( y \): add \( 6 \) to get \( x + 6 = 3y \), then divide by \( 3 \): \( y = \dfrac{x + 6}{3} \). So \( f^{-1}(x) = \dfrac{x + 6}{3} \).
Verify they cancel: \( f\big(f^{-1}(x)\big) = 3 \cdot \dfrac{x + 6}{3} - 6 = (x + 6) - 6 = x \). ✓
3. With \( f(x) = \dfrac{1}{x} \) and \( g(x) = x - 2 \), find \( (f \circ g)(x) \) and its domain.
Do \( g \) first, then \( f \): \( (f \circ g)(x) = f\big(g(x)\big) = f(x - 2) = \dfrac{1}{x - 2} \).
Now the domain. The only thing \( f \) forbids is dividing by zero, so we need \( x - 2 \neq 0 \), i.e. \( x \neq 2 \).
So \( (f \circ g)(x) = \dfrac{1}{x - 2} \), with domain all real \( x \) except \( x = 2 \).