Press B4 on a vending machine. One specific drink comes out — not a random choice, not two drinks. One input, one output, every time.
Type 100 into a Celsius-to-Fahrenheit converter. You get 212. Type 100 again tomorrow and you still get 212. The relationship doesn’t change. The output is determined entirely by the input.
A tip calculator takes one number — the bill total — and produces one number: the suggested tip. It doesn’t need to know anything else. One input, one output, every time.
These are all the same structure: a rule that takes an input and produces exactly one output. Mathematicians call that a function. This chapter is about what that means precisely — and why the restriction matters.
20.1 What the notation is saying
Here is a function:
\[f(x) = 2x + 3\]
Read it aloud: “f of x equals 2x plus 3.” The letter \(f\) is the name of the function — you could call it \(g\) or \(T\) or anything, but \(f\) is the default. The \(x\) inside the parentheses is the input. The right-hand side, \(2x + 3\), is the rule: whatever you put in, double it and add 3.
The notation \(f(x)\) does not mean \(f\) multiplied by \(x\). It means “the output of \(f\) when the input is \(x\).” That’s an easy thing to misread the first time you see it. Say it in words every time until it’s automatic.
You may also see function notation written as \(f: A \to B\), which says “\(f\) maps from set \(A\) to set \(B\)” — every element of \(A\) gets sent to exactly one element of \(B\). For example, the temperature converter maps the set of Celsius values to the set of Fahrenheit values.
One thing the definition requires: every input produces exactly one output. That’s what separates a function from a general relation. A relation might pair one input with two or more outputs — but then it’s not a function. The vending machine analogy holds: if pressing B4 sometimes gave you a cola and sometimes gave you nothing, or randomly gave you two things, you wouldn’t call it a reliable machine. A function is a reliable machine.
To evaluate \(f(x)\) at a specific input, replace every \(x\) in the rule with that value and simplify.
If \(f(x) = 2x + 3\), then \(f(5)\) means: put 5 in place of \(x\).
\[f(5) = 2(5) + 3 = 10 + 3 = 13\]
The input was 5, the output is 13.
If the input is negative or a fraction, the same substitution applies:
\[f(-4) = 2(-4) + 3 = -8 + 3 = -5\]
The parentheses around \(-4\) are there to keep the sign attached to the number. Leave them out and \(2-4+3\) is ambiguous. Keep them in and it’s clear.
20.2.2 Part 2: Domain and range
The domain of a function is the set of all valid inputs — the values of \(x\) you’re allowed to use.
The range is the set of all possible outputs — every value \(f(x)\) can produce when you run through the domain.
For \(f(x) = 2x + 3\), any real number is a valid input and any real number is a possible output. The domain and range are both all real numbers, written \((-\infty, \infty)\) in interval notation.
Domain restrictions come in two situations:
Division by zero is not allowed. For \(g(x) = \dfrac{1}{x-2}\), the input \(x = 2\) makes the denominator zero, which is undefined. The domain is all real numbers except 2, written \((-\infty, 2) \cup (2, \infty)\). The \(\cup\) symbol means “or” — the domain includes numbers from the first interval or the second.
Square roots of negative numbers don’t produce real outputs. For \(h(x) = \sqrt{x - 1}\), the expression under the root must be non-negative: \(x - 1 \geq 0\), so \(x \geq 1\). The domain is \([1, \infty)\). Why does the square root require this? No real number multiplied by itself gives a negative result — so the square root of a negative number doesn’t land on the number line.
Interval notation in brief: - \([a, b]\) — includes both endpoints (\(a \leq x \leq b\)) - \((a, b)\) — excludes both endpoints (\(a < x < b\)) - \([a, \infty)\) — from \(a\) upward, including \(a\) - \((-\infty, b)\) — everything below \(b\), not including \(b\)
The domain can also be restricted by context — a function describing something you can only sell in whole numbers, or a physical measurement that can’t be negative. That kind of restriction comes from the situation, not the algebra.
20.2.3 Part 3: Composition
You can chain functions together. If \(g\) converts one thing and \(f\) converts another, you can run an input through \(g\) first, then feed \(g\)’s output into \(f\).
The notation for this is \(f(g(x))\), read as “f of g of x.” You may also see it written \(f \circ g\), read as “f composed with g.” Both mean the same thing: apply \(g\) first, then apply \(f\) to the result.
The inverse of a function undoes it. If \(f\) takes 5 to 13, then \(f^{-1}\) — read as “f inverse” — takes 13 back to 5.
The notation \(f^{-1}(x)\) does not mean \(\dfrac{1}{f(x)}\). That’s another thing that looks like it should mean one thing but means another. The superscript \(-1\) on a function name means “the inverse function,” not “one over.”
Not every function has an inverse. For an inverse to exist, each output must have come from exactly one input — otherwise, when you try to go backwards, you don’t know which input to return to. A function with this property is called one-to-one: different inputs produce different outputs.
To find the inverse algebraically: write \(y = f(x)\), swap \(x\) and \(y\), then solve for \(y\).
Draw the graph of a relation. Draw a vertical line anywhere on the graph.
If any vertical line crosses the graph more than once, the relation is not a function — because that input \(x\) (the horizontal position of your line) maps to two or more outputs (the two crossing points).
If every vertical line crosses the graph at most once, the relation is a function. The test is visual and immediate: one crossing means one output for that input. That is the requirement.
20.3 Worked examples
Example 1 (Science) — Temperature conversion and its inverse.
The formula for converting Celsius to Fahrenheit is:
\[F(c) = \frac{9}{5}c + 32\]
Here \(c\) is the input (temperature in °C) and \(F(c)\) is the output (temperature in °F).
Evaluate at the boiling point of water, \(c = 100\):
So \(F^{-1}(T) = \dfrac{5}{9}(T - 32)\), where \(T\) is a temperature in °F.
Verify: \(F^{-1}(212) = \dfrac{5}{9}(212 - 32) = \dfrac{5}{9}(180) = 100\). Back to 100°C. Correct.
Example 2 (Computing) — Songs downloaded and storage used.
Every song downloaded takes up space on a device. For a particular music format, the storage used \(S\) in megabytes as a function of songs downloaded \(n\) is:
\[S(n) = 4.5n + 20\]
The 20 MB is the app’s base footprint; each song adds 4.5 MB.
The domain has a physical restriction: \(n \geq 0\) and \(n\) must be a whole number. The maximum \(n\) depends on the device’s storage limit — the model stops being useful beyond that point.
Example 3 (Computing) — Function composition in a data pipeline.
A data pipeline applies two transformations to a raw temperature reading from a sensor.
Step 1: the sensor outputs a raw voltage \(v\). The first function converts voltage to Celsius:
\[g(v) = 25v - 10\]
Step 2: the second function converts Celsius to Fahrenheit (from Example 1):
\[f(c) = \frac{9}{5}c + 32\]
The pipeline composes them: given a raw voltage, produce a Fahrenheit reading.
Exponents and logarithms (Volume 4, Chapter 1) are specific function families with their own shapes and properties. Once you know what a function is and how to evaluate one, invert one, and compose two, you can work with any family — exponential, logarithmic, trigonometric — using the same framework from this chapter. The function concept doesn’t change; only the rule inside changes.
Calculus (Volume 5) asks a new question about functions: not “what is the output?” but “how fast is the output changing?” That question — the derivative — only makes sense if you have a function to begin with. Limits (Volume 5, Chapter 1) ask what a function’s output approaches as the input gets close to a particular value, which requires the same precise notion of function you now have. Everything in analysis builds on this chapter.
Where this shows up
A structural engineer’s load-deflection formula is a function: given load, compute displacement.
Every physics formula (\(F = ma\), \(E = mc^2\), \(v = u + at\)) is a function expressing one quantity in terms of others.
A pricing algorithm that takes customer behaviour and outputs a price is a function — ideally a deterministic one.
A compiler transforms source code (input) into machine code (output): a function from programs to programs.
A chemist using Beer–Lambert law computes absorbance as a function of concentration. The inverse gives concentration from a measured absorbance.
20.5 Exercises
These are puzzles. Each one has a clean answer. The interesting part is reading the situation carefully before reaching for algebra.
2. State the domain of each function, using interval notation.
\(g(x) = \sqrt{x + 4}\)
\(h(x) = \dfrac{x}{x^2 - 9}\)
\(k(x) = x^2 + 5\)
Code
makeStepperHTML(2, [ { op:"For g(x): the expression under the root must be non-negative",eq:"x + 4 \\geq 0",note:null }, { op:"Solve the inequality",eq:"x \\geq -4",note:null }, { op:"Write domain of g in interval notation",eq:"[-4, \\infty)",note:null }, { op:"For h(x): the denominator cannot be zero",eq:"x^2 - 9 \\neq 0 \\implies x \\neq 3 \\text{ and } x \\neq -3",note:"Factor as (x-3)(x+3) to find the excluded values." }, { op:"Write domain of h in interval notation",eq:"(-\\infty, -3) \\cup (-3, 3) \\cup (3, \\infty)",note:null }, { op:"For k(x): any real input is valid (squaring never causes division by zero or square roots of negatives)",eq:"(-\\infty, \\infty)",note:null }, { op:"Check g at x = -4 (boundary)",eq:"g(-4) = \\sqrt{-4 + 4} = \\sqrt{0} = 0 \\checkmark",note:null }])
3. Let \(f(x) = x^2\) and \(g(x) = x - 5\).
Find \(f(g(x))\) and simplify.
Find \(g(f(x))\) and simplify.
Evaluate both \(f(g(x))\) and \(g(f(x))\) at \(x = 3\). Are they equal or different? Then try \(x = 2\) — are they still the same?
Code
makeStepperHTML(3, [ { op:"Write both functions",eq:"f(x) = x^2, \\quad g(x) = x - 5",note:null }, { op:"Find f(g(x)): substitute g(x) into f",eq:"f(g(x)) = f(x - 5) = (x - 5)^2",note:"Replace every x in f(x) = x^2 with the expression (x - 5)." }, { op:"Expand f(g(x))",eq:"(x - 5)^2 = x^2 - 10x + 25",note:null }, { op:"Find g(f(x)): substitute f(x) into g",eq:"g(f(x)) = g(x^2) = x^2 - 5",note:"Replace every x in g(x) = x - 5 with x^2." }, { op:"Evaluate both at x = 3",eq:"f(g(3)) = (3-5)^2 = 4, \\quad g(f(3)) = 9 - 5 = 4",note:"They are equal at x = 3 — but that is a coincidence for this specific value." }, { op:"Evaluate both at x = 2",eq:"f(g(2)) = (2-5)^2 = 9, \\quad g(f(2)) = 4 - 5 = -1",note:"Different at x = 2. The functions are genuinely distinct — x = 3 was a coincidence." }])
4. A company’s profit \(P\) in dollars from selling \(n\) units is:
\[P(n) = 8n - 150\]
The factory can produce between 0 and 200 units per day.
State the domain given the physical context.
At what number of units does the company break even (profit = 0)?
What is the range of \(P\) over this domain?
Code
makeStepperHTML(4, [ { op:"Write the function and note the context",eq:"P(n) = 8n - 150, \\quad n \\in \\{0, 1, 2, \\ldots, 200\\}",note:"n must be a non-negative integer since you can't sell a fraction of a unit." }, { op:"Find break-even: set P(n) = 0 and solve for n",eq:"8n - 150 = 0",note:null }, { op:"Add 150 to both sides",eq:"8n = 150",note:null }, { op:"Divide both sides by 8",eq:"n = 18.75",note:"Since n must be a whole number, the company needs at least 19 units to be in profit." }, { op:"Find the range: evaluate P at n = 0 and n = 200",eq:"P(0) = -150, \\quad P(200) = 8(200) - 150 = 1450",note:null }, { op:"State the range",eq:"P \\in \\{-150, -142, -134, \\ldots, 1450\\}",note:"Multiples of 8 offset by -150, from -150 to 1450." }, { op:"Check break-even at n = 19",eq:"P(19) = 8(19) - 150 = 152 - 150 = 2 \\checkmark",note:"Positive profit at n = 19, confirming 19 units is past break-even." }])
5. Find the inverse of \(h(x) = \dfrac{x + 4}{3}\).
Then verify that \(h(h^{-1}(x)) = x\).
Code
makeStepperHTML(5, [ { op:"Write as y = h(x)",eq:"y = \\frac{x + 4}{3}",note:null }, { op:"Swap x and y to begin finding the inverse",eq:"x = \\frac{y + 4}{3}",note:"Swapping the roles of input and output is what finding an inverse means." }, { op:"Multiply both sides by 3",eq:"3x = y + 4",note:null }, { op:"Subtract 4 from both sides",eq:"y = 3x - 4",note:null }, { op:"Write the inverse function",eq:"h^{-1}(x) = 3x - 4",note:null }, { op:"Verify: compute h(h⁻¹(x))",eq:"h(h^{-1}(x)) = h(3x - 4) = \\frac{(3x - 4) + 4}{3} = \\frac{3x}{3} = x \\checkmark",note:null }])
6. The temperature inside a greenhouse over the course of a morning is modelled by:
\[T(t) = 0.5t^2 + 2t + 15\]
where \(T\) is in °C and \(t\) is time in hours after 6 am, with domain \(0 \leq t \leq 6\).
What is the temperature at 6 am (\(t = 0\))?
What is the temperature at 9 am (\(t = 3\))?
What is the temperature at noon (\(t = 6\))?
Is this function one-to-one over this domain? If so, briefly explain why.
Code
makeStepperHTML(6, [ { op:"Write the function",eq:"T(t) = 0.5t^2 + 2t + 15",note:null }, { op:"Evaluate at t = 0 (6 am)",eq:"T(0) = 0.5(0)^2 + 2(0) + 15 = 15 \\text{ °C}",note:null }, { op:"Evaluate at t = 3 (9 am)",eq:"T(3) = 0.5(9) + 2(3) + 15 = 4.5 + 6 + 15 = 25.5 \\text{ °C}",note:null }, { op:"Evaluate at t = 6 (noon)",eq:"T(6) = 0.5(36) + 2(6) + 15 = 18 + 12 + 15 = 45 \\text{ °C}",note:null }, { op:"Assess whether T is one-to-one on [0, 6]",eq:"x_v = -\\frac{b}{2a} = -\\frac{2}{2 \\times 0.5} = -2",note:"The vertex of T(t) = 0.5t² + 2t + 15 is at t = −2, which is outside the domain [0, 6]. The parabola opens upward (a = 0.5 > 0) and its vertex is to the left of the domain, so T is strictly increasing on [0, 6] — each input gives a different output." }, { op:"Check: T is increasing throughout",eq:"T(0) = 15 < T(3) = 25.5 < T(6) = 45 \\checkmark",note:null }])