Functions model deterministic mappings: each valid input has exactly one output. They are the central language for analysis, geometry, optimization, and applications.
Function as a Special Relation
Let \(A\) and \(B\) be sets. A function \(f:A\to B\) can be understood as a relation \(f\subseteq A\times B\) with two conditions:
- Existence: for every \(x\in A\), there exists \(y\in B\) with \((x,y)\in f\).
- Uniqueness: for every \(x\in A\), this \(y\) is unique.
The underlying mapping viewpoint comes directly from relations.
Domain, Codomain, Range
For \(f:A\to B\):
- \(A\) is the domain.
- \(B\) is the codomain.
- \(f(A)=\{f(x):x\in A\}\subseteq B\) is the range (also image).
Domain and codomain are part of the function definition. The range is determined by the mapping behavior.
Image and Preimage of Sets
For a subset \(M\subseteq A\), the image under \(f\) is
\[ f(M):=\{f(x):x\in M\}\subseteq B. \]
For a subset \(X\subseteq B\), the preimage is
\[ f^{-1}(X):=\{x\in A:f(x)\in X\}\subseteq A. \]
Important: this preimage notation is valid for every function, even if the function is not invertible.
Injective, Surjective, Bijective
Injective
\(f\) is injective if different inputs never share the same output:
\[ f(x_1)=f(x_2)\Rightarrow x_1=x_2. \]
Equivalent contrapositive form: \(x_1\ne x_2\Rightarrow f(x_1)\ne f(x_2)\).
Every element of \(A\) maps to a distinct element of \(B\), but the dashed element of \(B\) is never reached.
Surjective
\(f\) is surjective if every codomain value is reached:
\[ \forall y\in B\,\exists x\in A: f(x)=y. \]
Every element of \(B\) is reached, but two elements of \(A\) share the same image.
Bijective
\(f\) is bijective if it is injective and surjective. Then each \(y\in B\) is matched by exactly one \(x\in A\).
Every element of \(A\) maps to a distinct element of \(B\), and every element of \(B\) is reached exactly once.
Functions Between Finite Sets
When \(A\) and \(B\) are finite, injectivity, surjectivity, and bijectivity translate directly into statements about cardinality, i.e. the number of elements \(|A|\) and \(|B|\):
- If \(f:A\to B\) is injective, then \(|A|\le|B|\).
- If \(f:A\to B\) is surjective, then \(|A|\ge|B|\).
- If \(f:A\to B\) is bijective, then \(|A|=|B|\).
The converse is more subtle but very useful in practice: if \(|A|=|B|\), then for \(f:A\to B\), being injective, being surjective, and being bijective are all equivalent — once the sizes of domain and codomain match, checking just one of the two properties is enough to conclude the other holds too. This is a form of the pigeonhole principle: with equally many pigeons as pigeonholes, filling every hole with at most one pigeon (injective) is possible exactly when every hole ends up occupied (surjective).
Finite sets also make it possible to count functions rather than just classify individual ones. The number of all functions \(f:A\to B\) is
\[ |B|^{|A|}, \]
since each of the \(|A|\) elements of \(A\) can be mapped independently to any of the \(|B|\) elements of \(B\). If \(|A|=|B|\), the number of bijective functions \(f:A\to B\) is
\[ |A|! = 1\cdot 2\cdot 3\cdots|A|, \]
since the first element of \(A\) can be sent to any of the \(|A|\) elements of \(B\), the second to any of the remaining \(|A|-1\) elements, and so on, down to a single choice for the last element.
Inverse Functions
A function has an inverse function \(f^{-1}:B\to A\) exactly when it is bijective. Then
\[ f^{-1}(f(x))=x\quad\text{and}\quad f(f^{-1}(y))=y. \]
Typical examples:
- \(f(x)=x^2\) on \(\mathbb{R}\): not bijective, hence no global inverse function.
- \(f(x)=x^2\) on \([0,\infty)\): bijective onto \([0,\infty)\), inverse \(\sqrt{x}\).
- \(\sin(x)\) on \(\mathbb{R}\): not injective.
- \(\sin(x)\) on \([-\pi/2,\pi/2]\): bijective onto \([-1,1]\), inverse \(\arcsin(x)\).
When \(f\) is additionally continuous on a compact domain, its inverse comes for free: continuity of \(f^{-1}\) is proved in the chapter on continuity, alongside the closely related fact that a continuous injective function on an interval is automatically strictly monotone.
Solving for the Inverse
When \(f\) is given by an explicit formula and is already known to be bijective on its domain, \(f^{-1}\) can usually be found algebraically: write \(y=f(x)\), solve this equation for \(x\) in terms of \(y\), and then rename the independent variable back to \(x\), since it is customary to write every function of a single real variable with the same letter \(x\).
For example, let \(f(x)=2x-1\). Setting \(y=2x-1\) and solving for \(x\) gives \(x=\frac{y+1}{2}\), so after renaming \(y\) back to \(x\),
\[ f^{-1}(x)=\frac{x+1}{2}. \]
The same computation works for any linear function \(f(x)=a+bx\):
\[ y=a+bx \quad\Longrightarrow\quad x=\frac{y-a}{b}, \qquad\text{so}\qquad f^{-1}(x)=\frac{x-a}{b}. \]
This requires \(b\ne 0\), which is exactly the bijectivity condition on \(\mathbb{R}\): for \(b=0\), \(f\) would be constant and therefore not injective, and solving for \(x\) would be impossible in the first place.
Graph of an Inverse Function
The graph of \(f\) consists of the points \((x,f(x))\), while the graph of \(f^{-1}\) consists of the points \((f(x),x)\) — the same pairs with both coordinates swapped. Geometrically, swapping coordinates is exactly reflection across the line \(y=x\), so the graph of \(f^{-1}\) is the mirror image of the graph of \(f\) in that line.
The graph of \(\sqrt{x}\) is the graph of \(x^2\) (restricted to \([0,\infty)\)) reflected across \(y=x\).
The same picture applies to any inverse pair: \(\ln(x)\) is the reflection of \(e^x\) across \(y=x\), just as \(\sqrt{x}\) is the reflection of \(x^2\) restricted to \([0,\infty)\).
One-Sided Inverses
Injectivity and surjectivity each have their own characterization in terms of a partial inverse, without requiring bijectivity:
- \(f:A\to B\) is injective if and only if there exists a left inverse \(g:B\to A\) with \(g\circ f=\operatorname{id}_A\) (assuming \(A\ne\emptyset\)).
- \(f:A\to B\) is surjective if and only if there exists a right inverse \(h:B\to A\) with \(f\circ h=\operatorname{id}_B\).
A left inverse recovers \(x\) from \(f(x)\), since injectivity guarantees nothing is lost by \(f\); a right inverse only needs to hit some preimage for every \(y\in B\), which typically means picking one representative preimage per \(y\) when \(f\) is not injective. A function is bijective exactly when the same map works as both a left and a right inverse at once, i.e. when it has a genuine two-sided inverse.
Graph of a Function
For real-valued \(f:A\subseteq\mathbb{R}\to\mathbb{R}\), the graph is
\[ \Gamma_f:=\{(x,f(x)):x\in A\}\subseteq \mathbb{R}^2. \]
Vertical line test: a graph in \(\mathbb{R}^2\) represents a function exactly when each vertical line intersects it at most once.
Properties of Real-Valued Functions
For \(f:D\to\mathbb{R}\) with \(D\subseteq\mathbb{R}\), a few graph-level properties recur often enough to name.
Boundedness
\(f\) is bounded above if there is \(M\in\mathbb{R}\) with \(f(x)\le M\) for all \(x\in D\), and bounded below if there is \(m\in\mathbb{R}\) with \(f(x)\ge m\) for all \(x\in D\); it is bounded if both hold, equivalently if \(|f(x)|\le K\) for some \(K\ge0\) and all \(x\in D\). For example, \(x^2+1\) is bounded below (by \(1\)) but not above, \(-x^2\) is bounded above (by \(0\)) but not below, and \(\cos(x)\) is bounded in both directions since \(|\cos(x)|\le1\).
Symmetry
Assume \(D\) is symmetric about \(0\), i.e. \(x\in D\iff-x\in D\). Then \(f\) is even if \(f(-x)=f(x)\) for all \(x\in D\), and odd if \(f(-x)=-f(x)\) for all \(x\in D\). Geometrically, an even function's graph is symmetric about the \(y\)-axis, and an odd function's graph is symmetric about the origin (point symmetry). The two properties are algebraically well behaved: a product of two even or two odd functions is even, while a product of an even and an odd function is odd — each case following directly by substituting \(-x\) into the product and applying the definitions. Furthermore, every function on a symmetric domain splits uniquely into an even part and an odd part,
\[ f(x)=\underbrace{\frac{f(x)+f(-x)}{2}}_{\text{even}}+\underbrace{\frac{f(x)-f(-x)}{2}}_{\text{odd}}, \]
since the first summand is unchanged and the second negated under \(x\mapsto-x\), and adding them back together recovers \(f\).
Zeros and Intercepts
A zero (or root, or \(x\)-intercept) of \(f\) is a point \(x_0\in D\) with \(f(x_0)=0\); a function can have any number of zeros, including infinitely many (e.g. \(\sin\) has one at every integer multiple of \(\pi\)). The \(y\)-intercept, in contrast, is the single point \(f(0)\) whenever \(0\in D\) — there can never be more than one, which is not a coincidence but a direct restatement of the uniqueness condition from the definition of a function: a function assigns exactly one output to \(x=0\), so its graph meets the \(y\)-axis at most once.
Periodicity
\(f\) is periodic with period \(p>0\) if \(D+p=D\) and \(f(x+p)=f(x)\) for all \(x\in D\). If a smallest such \(p\) exists, it is called the minimal period; \(\sin\) and \(\cos\) have minimal period \(2\pi\), while a constant function is periodic with every \(p>0\) and has no minimal period. Once a function is known to be periodic with period \(p\), its entire graph is determined by its values on any interval of length \(p\), repeated indefinitely in both directions.
Transformations of Graphs
Given the graph of \(f\), four elementary operations produce new graphs without any new analysis of \(f\) itself, since each one only relabels which point of the old graph appears at a given position:
- Vertical shift. \(g(x)=f(x)+d\) moves every point of the graph up by \(d\) (down if \(d<0\)).
- Horizontal shift. \(g(x)=f(x-c)\) moves every point right by \(c\) (left if \(c<0\)), since \(g\) reaches at \(x=x_0+c\) the value \(f\) reached at \(x_0\).
- Vertical stretch. \(g(x)=a\,f(x)\) scales every \(y\)-coordinate by the factor \(a\) (a reflection across the \(x\)-axis if \(a<0\)).
- Horizontal stretch. \(g(x)=f(bx)\) scales every \(x\)-coordinate by the factor \(1/b\), since \(g\) reaches at \(x=x_0/b\) the value \(f\) reached at \(x_0\) (a reflection across the \(y\)-axis if \(b<0\)).
Combining all four in the order stretch-then-shift gives the general form
\[ g(x)=a\,f\bigl(b(x-c)\bigr)+d, \]
whose graph is that of \(f\), stretched by \(a\) vertically and \(1/b\) horizontally, then shifted to be centered at \((c,d)\) instead of \((0,0)\).
Applying this to \(f=\sin\) gives the general sine function
\[ y=a\sin(bx+c)+d=a\sin\bigl(b(x+c/b)\bigr)+d, \]
with amplitude \(|a|\), period \(2\pi/|b|\), horizontal phase shift \(-c/b\), and vertical shift \(d\). This form is exactly the displacement of a harmonic oscillator, \(x(t)=A\sin(\omega t+\varphi)\), where \(A\) is the amplitude, \(\varphi\) the phase, and the angular velocity \(\omega=2\pi/T=2\pi f\) fixes the period \(T\) and frequency \(f\) of the oscillation.
The transformed curve \(1.5\sin(x-1)+0.5\) has amplitude \(1.5\), the same period \(2\pi\) as \(\sin(x)\), and is shifted right by \(1\) and up by \(0.5\).
Composition of Functions
Definition, Associativity, and Identity
If \(f:A\to B\) and \(g:B\to C\), then
\[ (g\circ f)(x):=g(f(x)). \]
Composition is associative: \((h\circ g)\circ f=h\circ(g\circ f)\).
Identity mappings \(\operatorname{id}_A:A\to A\), \(\operatorname{id}_A(x)=x\), satisfy
\[ f\circ \operatorname{id}_A=f,\qquad \operatorname{id}_B\circ f=f. \]
Injectivity and Surjectivity under Composition
Injectivity, surjectivity, and bijectivity interact predictably under composition. For \(f:A\to B\) and \(g:B\to C\):
- If \(f\) and \(g\) are injective, then \(g\circ f\) is injective.
- If \(f\) and \(g\) are surjective, then \(g\circ f\) is surjective.
- If \(f\) and \(g\) are bijective, then \(g\circ f\) is bijective.
The converse only carries half of each property back to the individual maps:
- If \(g\circ f\) is injective, then \(f\) is injective — but \(g\) need not be.
- If \(g\circ f\) is surjective, then \(g\) is surjective — but \(f\) need not be.
- If \(g\circ f\) is bijective, then \(f\) is injective and \(g\) is surjective — but neither \(f\) nor \(g\) needs to be bijective on its own.
A small example shows the asymmetry: let \(f:\{1\}\to\{1,2\}\) with \(f(1)=1\), and \(g:\{1,2\}\to\{1\}\) with \(g(1)=g(2)=1\). Then \(g\circ f:\{1\}\to\{1\}\) is bijective, yet \(g\) is not injective and \(f\) is not surjective — exactly the two properties the theorem does not guarantee.
Common Pitfalls
- Confusing codomain and range.
- Assuming every formula defines a function on all real numbers.
- Using \(f^{-1}\) ambiguously for preimages and inverse functions.
- Ignoring domain restrictions required for invertibility.