Module 0b — Functions (Rigorous Treatment)
Course: MAT1CJ101 — Differential Calculus (prerequisite refresher)
Status: Prerequisite background material — not part of the official 60 taught hours, not examined.
Builds on: Module 0a (Sets and Relations)
0. Why This Module Exists
Module I of the main notes introduces functions the way a calculus textbook does — a “rule” assigning outputs to inputs, with domain/range found by inspection. That’s enough to use functions in calculus. This module instead defines a function precisely as a special kind of relation, and uses that precision to answer questions Module I doesn’t: When exactly does an inverse function exist? What’s the difference between a function being “onto” and being “one-to-one,” and why do you need both to invert it? These distinctions matter the moment you meet inverse trig functions, logarithms, or invertibility arguments later in the course.
1. Functions as Special Relations
1.1 Formal Definition
Recall from Module 0a: a relation $R$ from $A$ to $B$ is any subset of $A \times B$. A function is a relation with two extra conditions:
Definition: $f$ is a function from $A$ to $B$ (written $f : A \to B$) if $f \subseteq A \times B$ such that:
- Existence: for every $a \in A$, there is at least one $b \in B$ with $(a,b) \in f$
- Uniqueness: if $(a,b_1) \in f$ and $(a,b_2) \in f$, then $b_1 = b_2$
Together, these say: every element of $A$ is paired with exactly one element of $B$. We write $f(a) = b$ instead of $(a,b) \in f$.
- Domain of $f$ is $A$ (every element of $A$ must be used — condition 1)
- Codomain of $f$ is $B$ (the set outputs are drawn from)
- Range (or image) of $f$ is ${f(a) : a \in A} \subseteq B$ — the outputs actually achieved
Worked Example 1: Let $A = {1,2,3}$, $B = {x,y}$. Which of the following subsets of $A \times B$ are functions from $A$ to $B$?
\[f_1 = \{(1,x), (2,x), (3,y)\} \qquad f_2 = \{(1,x), (2,y)\} \qquad f_3 = \{(1,x), (1,y), (2,x), (3,y)\}\]$f_1$: every element of $A$ ($1,2,3$) appears exactly once as a first coordinate. $\checkmark$ Function.
$f_2$: element $3 \in A$ never appears as a first coordinate — condition 1 (existence) fails. $\times$ Not a function (domain isn’t all of $A$).
$f_3$: element 1 appears twice, paired with both $x$ and $y$ — condition 2 (uniqueness) fails. $\times$ Not a function (“1” would have two outputs).
Connection to the vertical line test: for $f \subseteq \mathbb{R} \times \mathbb{R}$, existence + uniqueness together say “every vertical line $x = a$ meets the graph in exactly one point” — exactly the vertical line test from Module I, now stated as a logical condition on the relation itself.
1.2 Well-Definedness
When a function is given by a formula, “well-defined” means the formula genuinely satisfies uniqueness — it can’t accidentally produce two different outputs for the same input.
Worked Example 2: Is $f : \mathbb{Q} \to \mathbb{Z}$ defined by $f(p/q) = p$ (numerator) well-defined?
Test: $1/2$ and $2/4$ represent the same rational number ($1/2 = 2/4$ in $\mathbb{Q}$). \(\text{Using the rule on } 1/2: \ f(1/2) = 1 \qquad \text{Using the rule on } 2/4: \ f(2/4) = 2\)
Same input (as a rational number), two different outputs ($1 \neq 2$). $f$ is not well-defined — it fails the uniqueness condition, because the “rule” depends on how the rational number is written, not just on its value.
This is a classic trap: a formula that looks fine can still fail to be a genuine function if it isn’t computed consistently from the actual input value.
2. Injective, Surjective, Bijective
Let $f : A \to B$.
2.1 Injective (One-to-One)
Definition: $f$ is injective if distinct inputs always give distinct outputs: $a_1 \neq a_2 \implies f(a_1) \neq f(a_2)$. Equivalently (the contrapositive, usually easier to use in proofs): $f(a_1) = f(a_2) \implies a_1 = a_2$.
Geometric test (for $f : \mathbb{R} \to \mathbb{R}$): the horizontal line test — no horizontal line meets the graph more than once.
Worked Example 3: Is $f : \mathbb{R} \to \mathbb{R}$, $f(x) = 2x + 3$, injective? Is $g : \mathbb{R} \to \mathbb{R}$, $g(x) = x^2$, injective?
$f$: Suppose $f(a) = f(b)$. \(2a + 3 = 2b + 3 \implies 2a = 2b \implies a = b\) Injective $\checkmark$ (proved directly using the contrapositive form)
$g$: Try to find a counterexample instead — a single pair suffices to disprove injectivity. \(g(2) = 4 \text{ and } g(-2) = 4.\) Here $a = 2$, $b = -2$, $a \neq b$, but $g(a) = g(b)$. NOT injective $\times$
2.2 Surjective (Onto)
Definition: $f : A \to B$ is surjective if every element of the codomain is hit: for every $b \in B$, there exists $a \in A$ with $f(a) = b$. Equivalently: $\text{range}(f) = B$ (the whole codomain, not just part of it).
Worked Example 4: Is $f : \mathbb{R} \to \mathbb{R}$, $f(x) = x^2$, surjective? Is $g : \mathbb{R} \to [0, \infty)$, $g(x) = x^2$, surjective?
$f$: codomain is $\mathbb{R}$ (all reals, including negatives). Can we solve $x^2 = -1$ for real $x$? No — $x^2 \geq 0$ always. $-1 \in$ codomain is never hit. NOT surjective $\times$
$g$: codomain is $[0, \infty)$. Given any $y \geq 0$, does some $x$ satisfy $x^2 = y$? Yes: $x = \sqrt{y}$ works, and $\sqrt{y} \in \mathbb{R}$. Every element of $[0,\infty)$ is hit. Surjective $\checkmark$
Same formula, different codomain — surjectivity is NOT just a property of the formula, it depends on what codomain you declared.
Key lesson: injectivity depends only on the rule; surjectivity depends on the rule and the declared codomain. Shrinking the codomain down to exactly the range always makes a function surjective.
2.3 Bijective
Definition: $f$ is bijective if it is both injective and surjective — a perfect pairing between $A$ and $B$, with no input sharing an output (injective) and no output left unused (surjective).
Worked Example 5: Is $h : \mathbb{R} \to [0,\infty)$, $h(x) = x^2$, bijective?
Surjective: shown in Example 4 (as $g$). $\checkmark$
Injective: $h(2) = 4 = h(-2)$, but $2 \neq -2$. NOT injective. $\times$
Not both $\implies$ NOT bijective, even though it is surjective.
Worked Example 6: Is $h : [0,\infty) \to [0,\infty)$, $h(x) = x^2$, bijective? (Same formula, domain restricted to non-negative reals.)
Injective: suppose $h(a) = h(b)$ with $a, b \geq 0$. \(a^2 = b^2 \implies a^2 - b^2 = 0 \implies (a-b)(a+b) = 0 \implies a = b \text{ or } a = -b.\) Since $a, b \geq 0$, $a = -b$ forces $a = b = 0$ anyway. So $a = b$ in all cases. Injective $\checkmark$
Surjective: for $y \geq 0$, $x = \sqrt{y} \geq 0$ satisfies $h(x) = y$. Surjective $\checkmark$ (as before)
Both hold: $h$ is bijective on this restricted domain.
Moral: restricting the domain can turn a non-injective function into an injective one. This is exactly how $\sin, \cos, \tan$ get “inverse” versions in trigonometry (Module 0f) — their natural domains aren’t injective, so we restrict to a piece where they are.
2.4 Counting Consequence for Finite Sets
If $A, B$ are finite with $\lvert A \rvert = m$, $\lvert B \rvert = n$:
| Property | Requires |
|---|---|
| $f$ can be injective | $m \leq n$ |
| $f$ can be surjective | $m \geq n$ |
| $f$ can be bijective | $m = n$ |
This is the pigeonhole principle in disguise: if $m > n$, at least two of the $m$ inputs must share one of the only $n$ available outputs, so no injective function exists.
3. Composition of Functions
3.1 Definition
Given $f : A \to B$ and $g : B \to C$, the composite $g \circ f : A \to C$ is defined by $(g \circ f)(a) = g(f(a))$. Note the order: $g \circ f$ means “do $f$ first, then $g$” — read right to left.
Domain requirement: for $g \circ f$ to make sense at $a$, $f(a)$ must land inside the domain of $g$.
Worked Example 7: $f : \mathbb{R} \to \mathbb{R}$, $f(x) = x + 1$. $g : \mathbb{R} \to \mathbb{R}$, $g(x) = x^2$. Find $g \circ f$ and $f \circ g$, and show they differ.
\((g \circ f)(x) = g(f(x)) = g(x+1) = (x+1)^2\) \((f \circ g)(x) = f(g(x)) = f(x^2) = x^2 + 1\)
Check at $x = 2$: \((g \circ f)(2) = (2+1)^2 = 9 \qquad (f \circ g)(2) = 2^2 + 1 = 5\)
$9 \neq 5$. Confirms $g \circ f \neq f \circ g$ in general — composition is not commutative.
3.2 Composition Preserves Injectivity/Surjectivity
Fact: if $f$ and $g$ are both injective, $g \circ f$ is injective. If $f$ and $g$ are both surjective, $g \circ f$ is surjective. (Hence if both are bijective, so is $g \circ f$.)
Worked Example 8: Verify injectivity is preserved for $f(x) = x+1$, $g(x) = x^2$ restricted to domain $[0,\infty)$ (injective there, per Example 6).
$g \circ f$ on domain where $f(x) \geq 0$, i.e. $x \geq -1$: $(g \circ f)(x) = (x+1)^2$
Suppose $(g \circ f)(a) = (g \circ f)(b)$ for $a, b \geq -1$. \((a+1)^2 = (b+1)^2\) Since $a+1, b+1 \geq 0$ (as $a,b \geq -1$), taking square roots preserves the equation directly: \(a+1 = b+1 \implies a = b.\)
Injective, as predicted.
3.3 Associativity
Composition is associative: $(h \circ g) \circ f = h \circ (g \circ f)$, so $h \circ g \circ f$ is unambiguous without brackets. This is inherited directly from function application — both sides equal $h(g(f(x)))$.
4. Inverse Functions
4.1 When Does an Inverse Exist?
Definition: $g : B \to A$ is the inverse of $f : A \to B$ if $g \circ f = \text{id}_A$ (the identity on $A$: $\text{id}_A(a) = a$ for all $a$) and $f \circ g = \text{id}_B$. We write $g = f^{-1}$.
Theorem: $f : A \to B$ has an inverse if and only if $f$ is bijective.
Why bijectivity is exactly what’s needed:
- Injective is needed for $g$ to be well-defined. If $f$ were not injective, some $b \in B$ would have two preimages $a_1 \neq a_2$ with $f(a_1) = f(a_2) = b$, so $g(b)$ couldn’t decide whether to return $a_1$ or $a_2$ — $g$ would fail the uniqueness condition for being a function.
- Surjective is needed for $g$’s domain to be all of $B$. If $f$ were not surjective, some $b \in B$ would have no preimage, so $g(b)$ would have nothing to return — $g$ would fail the existence condition.
So: bijective $=$ exactly injective ($g$ well-defined) $+$ surjective ($g$ total on $B$) $=$ exactly what’s needed for $g$ to itself be a genuine function $B \to A$.
Worked Example 9: Find the inverse of $f : \mathbb{R} \to \mathbb{R}$, $f(x) = 3x - 2$ (first confirm it’s bijective).
Injective: $f(a)=f(b) \implies 3a-2 = 3b-2 \implies 3a=3b \implies a=b$. $\checkmark$
Surjective: given $y \in \mathbb{R}$, solve $3x - 2 = y$ for $x$: $x = (y+2)/3 \in \mathbb{R}$ exists. $\checkmark$
Bijective $\implies$ inverse exists.
To find the formula for $f^{-1}$, solve $y = 3x - 2$ for $x$ in terms of $y$: \(y = 3x - 2 \implies y + 2 = 3x \implies x = \frac{y+2}{3}\)
So $f^{-1}(y) = (y+2)/3$, or writing the input as $x$ again: $f^{-1}(x) = (x+2)/3$.
Check: $f(f^{-1}(x)) = 3 \cdot \frac{x+2}{3} - 2 = (x+2) - 2 = x$. $\checkmark$
$f^{-1}(f(x)) = \frac{(3x-2)+2}{3} = \frac{3x}{3} = x$. $\checkmark$
4.2 Restricting the Domain to Get an Inverse
When $f$ isn’t bijective on its natural domain, a “partial inverse” is obtained by restricting the domain to a piece where $f$ is bijective — this is exactly what Example 6 did for $x^2$.
Worked Example 10: $f(x) = x^2$ is not injective on $\mathbb{R}$ (Example 3). Restrict to $[0, \infty)$ and find the inverse there.
From Example 6: $h(x) = x^2$ is bijective on $[0,\infty) \to [0,\infty)$.
Solve $y = x^2$ for $x$, with $x \geq 0$: \(x = \sqrt{y} \quad \text{(taking the non-negative root, matching the restricted domain)}\)
$h^{-1}(x) = \sqrt{x}$, domain $[0,\infty)$, matching $h$’s range.
This is exactly why $\sqrt{x}$ is defined as the non-negative square root by convention — it’s the inverse of $x^2$ restricted to $x \geq 0$, not the “other half” $x \leq 0$.
4.3 Graph of the Inverse
If $f$ is bijective with inverse $f^{-1}$, the graph of $f^{-1}$ is the reflection of the graph of $f$ across the line $y = x$. This is because $(a,b) \in f$ exactly when $(b,a) \in f^{-1}$, and swapping coordinates is precisely reflection across $y = x$.
5. Piecewise Functions
A piecewise function is defined by different formulas on different parts of its domain. The three conditions for being a function (Section 1.1) still apply: the pieces must together cover the whole domain (existence) and never overlap in a way that assigns two different values to the same input (uniqueness).
Worked Example 11: Is the following a valid function?
\[f(x) = \begin{cases} x + 1, & x < 2 \\ 5, & x = 2 \\ x^2 - 1, & x > 2 \end{cases}\]Check existence: every real $x$ falls into exactly one of $x<2$, $x=2$, $x>2$ — domain is all of $\mathbb{R}$, covered. $\checkmark$
Check uniqueness: the three pieces apply to disjoint sets of inputs (strict inequalities plus one exact value), so no input gets two formulas. $\checkmark$ Valid function.
Evaluate: $f(0) = 0+1 = 1$. $f(2) = 5$. $f(3) = 3^2-1 = 8$.
Common error to avoid: writing overlapping conditions, e.g. “$x \leq 2$” in one piece and “$x \geq 2$” in another — this assigns two possibly-different values at $x = 2$ and violates uniqueness, so it is not a function unless both pieces happen to agree exactly at $x = 2$.
6. Summary
| Concept | Key Idea | Worked Example |
|---|---|---|
| Function | Relation with existence + uniqueness | $f_1={(1,x),(2,x),(3,y)}$ valid; $f_3$ invalid (repeats 1) |
| Well-defined | Output can’t depend on how the input is written | $f(p/q)=p$ on $\mathbb{Q}$ fails |
| Injective | $f(a)=f(b) \implies a=b$ | $2x+3$ injective; $x^2$ is not on $\mathbb{R}$ |
| Surjective | Every codomain element is hit | $x^2$ onto $[0,\infty)$ but not onto $\mathbb{R}$ |
| Bijective | Injective + surjective | $x^2$ on $[0,\infty)\to[0,\infty)$ is bijective |
| Composition | $(g \circ f)(x)=g(f(x))$, order matters | $(x+1)^2 \neq x^2+1$ |
| Inverse exists | Iff $f$ is bijective | $3x-2$ invertible; formula $(x+2)/3$ |
| Graph of inverse | Reflection across $y = x$ | — |
| Piecewise function | Must still satisfy existence + uniqueness | Domains must partition, not overlap |
7. Practice Problems
-
Let $A = {1,2,3}$, $B = {p,q}$. List all functions from $A$ to $B$ (as sets of ordered pairs). How many are there? Verify against the counting formula $\lvert B \rvert^{\lvert A \rvert}$.
-
Determine whether each subset of $\mathbb{R} \times \mathbb{R}$ is a function: (a) ${(x,y): y = x^3}$, (b) ${(x,y): x = y^2}$, (c) ${(x,y): y^2 = x^2}$.
-
Is $f : \mathbb{Z} \to \mathbb{Z}$, $f(n) = n$ if $n$ is even and $f(n) = n+1$ if $n$ is odd, well-defined? Is it a valid function? Explain.
-
Prove $f : \mathbb{R} \to \mathbb{R}$, $f(x) = 5 - 2x$, is injective, using the contrapositive definition.
-
Show $g : \mathbb{R} \to \mathbb{R}$, $g(x) = x^3$, is both injective and surjective (bijective), by direct proof (not just graph inspection).
-
Is $f : \mathbb{R} \to \mathbb{R}$, $f(x) = \lvert x \rvert$, injective? Surjective? What if the codomain is restricted to $[0, \infty)$? Justify each answer.
-
Let $f : \mathbb{R} \to \mathbb{R}$, $f(x) = x^2 - 4x + 3$. Find the largest domain containing $x = 5$ on which $f$ is injective. (Hint: complete the square first to see the vertex.)
-
For $f(x) = 2x + 1$ and $g(x) = x^2 - 3$, compute $(f \circ g)(x)$ and $(g \circ f)(x)$. Evaluate both at $x = 1$ and confirm they differ.
-
If $f : A \to B$ and $g : B \to C$ are both injective, prove $g \circ f$ is injective (general proof, not an example).
-
Find the inverse of $f : \mathbb{R} \to \mathbb{R}$, $f(x) = (2x - 1)/3$. Verify by checking $f(f^{-1}(x)) = x$ and $f^{-1}(f(x)) = x$.
-
$f(x) = x^2 + 2$ is not injective on $\mathbb{R}$. Restrict the domain to make it bijective onto its range, and find the formula for the inverse on that restricted domain.
-
Sketch (by hand, describing key points) the graph of $f(x) = x^3$ and its inverse $f^{-1}(x) = \sqrt[3]{x}$ on the same axes, and confirm they are mirror images across $y = x$.
-
Determine whether the following is a valid (well-defined) function, and if so evaluate it at $x = 2$ and $x = -1$: \(f(x) = \begin{cases} x^2, & x \leq 2 \\ 3x - 2, & x \geq 2 \end{cases}\) (Careful: check what happens exactly at $x = 2$.)
-
(Harder) Let $A, B$ be finite sets with $\lvert A \rvert = 4$, $\lvert B \rvert = 3$. Explain, using the pigeonhole principle, why no injective function $f : A \to B$ can exist. Can a surjective function $A \to B$ exist? Give an example.
-
(Harder) Prove that if $f : A \to B$ is bijective, then $(f^{-1})^{-1} = f$.