19  Functions and relations

Given this, produce that

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.

19.1 What this chapter helps you do

Symbols to keep handy

These are the bits of notation you'll see a lot. If a line of symbols feels like a fence, read it out loud once, then keep going.

  • f(x): f of x — the output of function f when the input is x

  • f g: f composed with g — apply g first, then f

  • f: A B: f maps from set A to set B — every element of A gets sent to exactly one element of B

  • f^{-1}: f inverse — the function that undoes f

Here is the main move this chapter is making, in plain terms. You do not need to be fast. You just need to keep the thread.

  • Coming in: You already know that some quantities depend on others — speed determines how far you travel, temperature determines how a material expands. You’ve drawn graphs of those relationships.

  • Leaving with: A function is a relationship where every input produces exactly one output. That restriction — one in, one out — is what makes functions the right tool for building models. Once you name the relationship, you can evaluate it, reverse it, and chain it with other functions.

19.2 What the notation is saying

Start with the machine idea from the opening. A function takes an input, applies a rule, and returns one output.

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.

This means function notation is about evaluation, not multiplication.

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.

This means the key restriction is consistency: one input, one output. This reliability is what makes functions useful for modelling the real world. When you know an input, you can be certain of the output — no guessing, no multiple answers.

Domain and range (preview): When we look at the interactive below, you’ll see labels for “domain” and “range.” The domain is the set of all valid inputs — the x-values you’re allowed to use. The range is the set of all possible outputs — the y-values the function can produce. Try different functions and input values to see how the domain and range change.

19.3 The method

19.3.1 Part 1: Evaluating a function

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.

This means evaluating a function is careful substitution followed by simplification.

19.3.2 Part 2: Domain and range

Back to the vending machine: the domain is the set of valid buttons you can press. The range is the set of drinks the machine can deliver.

More formally: 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.

To phrase it the way the vending machine works: domain asks “which buttons work?” and range asks “which drinks are possible?”

Interval notation: We write sets of numbers using intervals. Here’s the shorthand: - [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 symbol \cup means “or” — union of two intervals

For example, (-\infty, 2) \cup (2, \infty) means “all numbers below 2, or all numbers above 2” — everything except 2.

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? Consider: 2 \times 2 = 4, and also (-2) \times (-2) = 4. Both positive and negative numbers squared give positive results. So there is no number, positive or negative, whose square is -1. Therefore \sqrt{-1} has nowhere to 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.

This means a complete answer often needs both algebraic rules and real-world sense.

19.3.3 Part 3: Composition

Sometimes you want to apply one rule, then feed its output into another rule. That process is called 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.

This means composition reads from the inside out.

If g(x) = x + 3 and f(x) = 2x + 1:

f(g(x)) = f(x + 3) = 2(x + 3) + 1 = 2x + 6 + 1 = 2x + 7

The order matters. f(g(x)) and g(f(x)) are generally different.

g(f(x)) = g(2x + 1) = (2x + 1) + 3 = 2x + 4

That is a different function. Get the order right by reading from the inside out: in f(g(x)), g acts first.

This means composition is not usually reversible by simply swapping the order.

19.3.4 Part 4: Inverses

⚠️ Notation alert: f^{-1}(x) means “the inverse function,” not \dfrac{1}{f(x)}. The superscript -1 on a function is not an exponent — it’s notation for reversal.

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. Inverse notation is about undoing a function, not taking a reciprocal.

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.

For f(x) = 2x + 3:

Write as: y = 2x + 3

Swap x and y: x = 2y + 3

Solve for y:

x - 3 = 2y y = \frac{x - 3}{2}

So f^{-1}(x) = \dfrac{x - 3}{2}.

Check: f(5) = 13, and f^{-1}(13) = \dfrac{13 - 3}{2} = \dfrac{10}{2} = 5. Yes.

This means the inverse reverses the original input-output pairing.

Why this works: the vertical line test

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.

19.4 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:

F(100) = \frac{9}{5}(100) + 32 = 180 + 32 = 212

Water boils at 212°F. Check: widely known to be correct.

Now find the inverse — the converter run backwards, converting °F to °C.

Write y = \dfrac{9}{5}c + 32, swap variables: c = \dfrac{9}{5}y + 32.

Solve for y:

c - 32 = \frac{9}{5}y y = \frac{5}{9}(c - 32)

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.

This means inverse functions are especially useful for unit conversions.


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.

At n = 10 songs: S(10) = 4.5(10) + 20 = 45 + 20 = 65 \text{ MB}

At n = 50 songs: S(50) = 4.5(50) + 20 = 225 + 20 = 245 \text{ MB}

At n = 100 songs: S(100) = 4.5(100) + 20 = 450 + 20 = 470 \text{ 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.

This means real functions often live on smaller domains than the algebra alone suggests.


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.

f(g(v)) = f(25v - 10) = \frac{9}{5}(25v - 10) + 32 = 45v - 18 + 32 = 45v + 14

So the combined function is h(v) = 45v + 14.

Test it: at v = 1.2 volts:

g(1.2) = 25(1.2) - 10 = 30 - 10 = 20 \text{°C} f(20) = \frac{9}{5}(20) + 32 = 36 + 32 = 68 \text{°F} h(1.2) = 45(1.2) + 14 = 54 + 14 = 68 \text{°F}

Both paths give the same answer. The composed function works.

This means composition can compress a multi-step process into one rule.


Example 4 (Business) — Revenue function with restricted domain.

A market stall sells handmade notebooks. The revenue R in dollars as a function of notebooks sold n is:

R(n) = 12n

But the domain is restricted: n must be a non-negative integer. You can’t sell −3 notebooks or 4.7 notebooks.

Revenue at n = 0: R(0) = 0. Nothing sold, nothing earned.

Revenue at n = 25: R(25) = 12(25) = 300.

Revenue at n = 50: R(50) = 12(50) = 600.

The range is \{0, 12, 24, 36, \ldots\} — multiples of 12, starting at 0. This is not a continuous range because the domain is discrete.

If the stall owner wants to know how many notebooks to sell to reach a revenue target of $180, that’s the inverse:

R^{-1}(180) = \frac{180}{12} = 15 \text{ notebooks}

This means a discrete domain creates a discrete set of outputs as well.

19.5 Where this goes

This chapter names the general structure behind many earlier formulas: input, rule, output.

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.

19.6 Exercises

These are puzzles. Each one has a clean answer. The interesting part is reading the situation carefully before reaching for algebra.


1. Let f(x) = 3x^2 - 2x + 1.

Evaluate: (a) f(0), (b) f(2), (c) f(-3).


2. State the domain of each function, using interval notation.

  1. g(x) = \sqrt{x + 4}

  2. h(x) = \dfrac{x}{x^2 - 9}

  3. k(x) = x^2 + 5


3. Let f(x) = x^2 and g(x) = x - 5.

  1. Find f(g(x)) and simplify.

  2. Find g(f(x)) and simplify.

  3. 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?


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.

  1. State the domain given the physical context.

  2. At what number of units does the company break even (profit = 0)?

  3. What is the range of P over this domain?


5. Find the inverse of h(x) = \dfrac{x + 4}{3}.

Then verify that h(h^{-1}(x)) = x.


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.

  1. What is the temperature at 6 am (t = 0)?

  2. What is the temperature at 9 am (t = 3)?

  3. What is the temperature at noon (t = 6)?

  4. Is this function one-to-one over this domain? If so, briefly explain why.