Skip to main content
Logo image

Section 10.1 Basics

Subsection 10.1.1 Terminology and basic concepts

function (working definition)
a rule which assigns to each input element from a set \(A\) a single output element from a set \(B\)
domain
the set of all possible input elements for a function
codomain
a set containing all possible output elements for a function
\(\funcdef{f}{A}{B}\)
\(f\) is a function with domain \(A\) and codomain \(B\)
input-output rule
the process/algorithm/rule/formula that describes how each input element from the domain will be transformed into an output element in the codomain
\(f(a) = b\)
function \(\funcdef{f}{A}{B}\) associates the codomain element \(b\in B\) to the domain element \(a\in A\)
\(a \mapsto b\)
alternative notation for \(f(a) = b\)
image (of an domain element)
when \(f(a) = b\) we say that \(b\) is the image of \(a\) under \(f\text{,}\) or that \(f\) maps \(a\) to \(b\)
A Venn diagram of a function transforming a domain element into a codomain element.
Figure 10.1.1. A Venn diagram of a function transforming a domain element into a codomain element.

Warning 10.1.2. Domain elements are necessarily inputs, but codomain elements are not necessarily outputs.

When we define a function, the domain should either be implicitly clear from the input-output rule, or explicitly stated so that the precise collection of allowable input elements is known.
However, it would be too onerous to do the same for the precise collection of output elements — often when we create a function we won’t initially know exactly what outputs it will produce. The purpose of stating a codomain is so that it is at least clear what type of output element is produced.

Subsection 10.1.2 Defining functions

Defining a function is a two-step process, in which we need to specify three pieces of information:
  1. the domain,
  2. the codomain, and
The first two pieces of information are specified in one step, when we write
\begin{equation*} \funcdef{f}{A}{B} \text{.} \end{equation*}
This notation indicates that \(A\) will be the domain and \(B\) will be the codomain for the function named \(f\text{.}\) Of course, the name of the function is an additional piece of information being specified with this notation, but naming a function is optional (though highly recommended!).
Specifying the input-output rule may be done in many different ways, e.g. by a formula, table of values, a description of a step-by-step process or algorithm to determine or compute an output given an arbitrary input, etc.

Example 10.1.3. Defining a function by an input-output formula.

An input-output formula like \(f(x) = \sqrt{x}\) defines a function, but we here need to be careful about the domain. The domain and codomain for this function could be specified as \(\funcdef{f}{\nnegset{\R}}{\R}\text{,}\) where \(\nnegset{\R}\) represents the set of nonnegative real numbers.

Example 10.1.4. Correctly stating a domain and codomain.

In the function definition
\begin{align*} f\colon \R \amp \to \R, \\ x \amp \mapsto \frac{1}{x^2}, \end{align*}
the first line of the definition tells us the domain (\(\R\)), codomain (again \(\R\)), and a name for the function (\(f\)). The second line tells us the input-output rule, so that
\begin{equation*} f(x) = \frac{1}{x^2} \text{.} \end{equation*}
However, on closer inspection we discover that the domain has been incorrectly specified, as \(x=0\) is not a permissible input for the input-output rule. Instead, we should write
\begin{equation*} \funcdef{f}{\R \relcmplmnt \{0\}}{\R} \text{.} \end{equation*}
Even though this function will only ever produce positive real numbers as outputs, the codomain is acceptable as stated. It would be more precise to write
\begin{equation*} \funcdef{f}{\R \relcmplmnt \{0\}}{\posset{\R}}, \end{equation*}
where \(\posset{\R}\) represents the set of positive real numbers, but it is not necessary to do so.

Example 10.1.5. Defining a function by an input-output algorithm.

Consider the function \(\powset{\Z} \to \N\) where outputs are computed according to the following algorithm.
Given an input element \(X \in \powset{\Z}\) (which, by definition, is a set of integers), carry out the following.
  1. Compute the absolute value of each element in \(X\text{.}\) (If \(X\) is empty, skip this step.)
  2. Determine the minimum result of the absolute value computations in the previous step. (If \(X\) is empty, there will not be any absolute value computation results to compare, so take \(0\) as the “mininum” instead.)
  3. Multiply the minimum value found in the previous step by \(2\) and add \(1\text{.}\) Output this final result.
However, with the right notation, an algorithm like the above can often be converted into an input-output formula — see Example 10.4.7.

Example 10.1.6. Defining a function by listing input-ouput pairs.

For \(\mathscr{N} = \{1,2,3\}\) and \(\mathscr{A} = \{a,b,c,d\}\text{,}\) one way to define a function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}}\) is
\begin{align*} f(1) \amp = d, \amp f(2) \amp = a, \amp f(3) \amp = d. \end{align*}

Example 10.1.7. Multi-variable functions.

In a first course in calculus a student typically studies only single-variable functions, i.e. functions with a single input variable and a single output variable. In subsequent calculus courses a student may study multi-variable functions with multiple input variables, such as
\begin{equation*} f(x,y) = x^2 + y^2 \text{.} \end{equation*}
Technically, we should write
\begin{equation*} f\bbrac{(x,y)} = x^2 + y^2 \text{,} \end{equation*}
as the proper definition of \(f\) is \(\funcdef{f}{\R^2}{\R}\text{,}\) but the extra brackets convey no additional information and only clutter things up.
Functions with multiple real output variables are often called vector functions. For example, \(\funcdef{g}{\R}{\R^2}\) defined by
\begin{equation*} g(t) = (t,t^2) \end{equation*}
can be considered as a vector parametrization of a parabola in the plane.
And of course we could consider multi-variable vector functions as well. A function \(\funcdef{\varphi}{\R^2}{\R^2}\) like
\begin{equation*} \varphi(s,t) = (s-t,s+t) \end{equation*}
could be considered as a change of variables
\begin{align*} x \amp = s - t, \amp y \amp = s + t. \end{align*}

Example 10.1.8. Logical statements as functions.

A logical statement \(S\) involving statement variables \(p_1, p_2, \dotsc, p_m\) is essentially a multi-variable function
\begin{equation*} \funcdef{S}{\Lambda^m}{\Lambda} \text{,} \end{equation*}
where \(\Lambda = \{ \lgctrue,\, \lgcfalse \}\text{.}\) For example, the statement
\begin{equation*} S(p_1,p_2) = (p_1 \lgccond p_2) \end{equation*}
is a function \(\funcdef{S}{\Lambda \cartprod \Lambda}{\Lambda}\text{,}\) where
\begin{align*} S(\lgctrue,\lgctrue) \amp = \lgctrue, \amp S(\lgctrue,\lgcfalse) \amp = \lgcfalse, \amp S(\lgcfalse,\lgctrue) \amp = \lgctrue, \amp S(\lgcfalse,\lgcfalse) \amp = \lgctrue. \end{align*}

Subsection 10.1.3 Graph of a function

graph (of a function)
the set of all input-output pairs for the function
\(\funcgraph{f}\)
the graph of function \(\funcdef{f}{A}{B}\text{,}\) so that
\begin{equation*} \funcgraph{f} = \setdef{(a,f(a))}{a \in A} \subseteq A \cartprod B \end{equation*}

Example 10.1.9. Graph of a single-variable, real-valued function.

The graph of a function \(\funcdef{f}{\R}{\R}\) is a subset of \(\R \cartprod \R = \R^2\text{.}\) We usually represent \(\R^2\) visually as the \(xy\)-plane and the graph \(\funcgraph{f} \subseteq \R^2\) as a curve in the plane.
The graph \(\funcgraph{x \mapsto x^2}\) represented as a curve in the Cartesian plane.
Figure 10.1.10. The graph \(\funcgraph{x \mapsto x^2}\) represented as a curve in the Cartesian plane.
In the graph of \(f(x) = x^2\) above, each point on the curve represents an element of \(\R^2\) which is in the subset \(\funcgraph{f}\text{.}\) For example, \((-1,1) \in \funcgraph{f}\) but \((-1,\pi) \notin \funcgraph{f}\text{.}\)

Example 10.1.11. Graph of a multi-variable, real-valued function.

The graph of a function \(\funcdef{f}{\R^2}{\R}\) is technically a subset of \(\R^2 \cartprod \R\text{,}\) but usually we just think of this as \(\R^3\text{,}\) or \(3\)-space. Instead of a curve, such a graph defines a surface in \(\R^3\text{.}\) For example, the graph of the function \(f(x,y) = x^2 + y^2\) from Example 10.1.7 is a parabolic cone, i.e. a (non-solid) cone-like surface with parabolic sides.

Example 10.1.12. Graph of a function defined by a list.

To describe the graph of the function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}}\) defined in Example 10.1.6, we just need to collect the defined input-output pairs into Cartesian product elements:
\begin{equation*} \funcgraph{f} = \{ (1,d), (2,a), (3,d) \} \text{.} \end{equation*}
This graph can most simply be represented by a table:
\(x\) \(1\) \(2\) \(3\)
\(f(x)\) \(d\) \(a\) \(d\)
Similarly to Example 9.5.7, we can also visualize this graph as a set of “points” relative to a set of perpendicular “axes,” where the horizontal axis represents the domain set and the vertical axis represents the codomain set.
\(\mathscr{A}\)
\(d\) \(\bullet\) \(\bullet\)
\(c\)
\(b\)
\(a\) \(\bullet\)
\(1\) \(2\) \(3\) \(\mathscr{N}\)
Notice that we have not joined the points in the above visualization with lines or a curve, since the three points pictured are the only points on the graph.

Example 10.1.13. Graph of a logical statement.

We’ve already encountered the graph of a logical statement: it is usually represented as a truth table. For example, the graph \(\funcgraph{S}\) of the logical statement
\begin{align*} S \colon \Lambda \cartprod \Lambda \amp \to \Lambda, \amp S(p_1,p_2) \amp = p_1 \lgccond p_2, \end{align*}
where \(\Lambda = \{ \lgctrue, \lgcfalse \}\) as usual, can be represented as below.
\(p_1\) \(p_2\) \(S(p_1,p_2)\)
\(\lgctrue\) \(\lgctrue\) \(\lgctrue\)
\(\lgctrue\) \(\lgcfalse\) \(\lgcfalse\)
\(\lgcfalse\) \(\lgctrue\) \(\lgctrue\)
\(\lgcfalse\) \(\lgcfalse\) \(\lgctrue\)
Figure 10.1.14. The graph \(\funcgraph{S}\) of the logical statement \(S(p_1,p_2) = p_1 \lgccond p_2\text{.}\)
Unfortunately, our working definition for function is lacking: what is a “rule”? Rather than chasing some circle of definitions, we can come up with a better definition by noticing that the graph of a function contains all the necessary information about the function.
function (formal definition)
a subset \(F \subseteq A \cartprod B\) such that for every \(x\in A\) there is exactly one element \((a,b)\in F\) with \(a=x\)
In this formal definition, we are defining a function to be what we previously would have called its graph.

Example 10.1.15. Formal definition for a single-variable, real-valued function.

We are now defining a function \(\funcdef{f}{\R}{\R}\) to be the subset of the Cartesian plane \(\R^2\) consisting of the graph of the function. In this case, you can think of the “exactly one” requirement as equivalent to the vertical line test: an input value may not produce more than one output value. (Though the “one” part of “exactly one” captures our requirement that a function be defined on every domain element.)

Subsection 10.1.4 Undefined and well-defined

We have to be careful defining functions; sometimes what we think is a function turns out to not be a function.

Example 10.1.16. A function must be defined on the whole domain.

Again write \(\mathscr{N} = \{1,2,3\}\) and \(\mathscr{A} = \{a,b,c,d\}\text{,}\) and consider
\begin{equation*} F = \{ (1,a), (3,d) \} \subseteq \mathscr{N} \cartprod \mathscr{A} \text{.} \end{equation*}
Does this subset define a function with domain \(\mathscr{N}\) and codomain \(\mathscr{A}\text{?}\) That is, does there exist a function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}}\) such that \(F = \funcgraph{f}\text{?}\) The answer is no, because there is no input-output pair in \(F\) with domain element \(2\text{.}\) If we attempt to consider a function \(f\) with graph \(\funcgraph{f} = F\text{,}\) we have no way to tell what result \(f(2)\) should return. In other words, such an \(f\) will have been left undefined on element \(2\text{,}\) which is supposed to be part of the domain.
The set \(F\) does define a function, just not one with domain \(\mathscr{N}\text{.}\) If we consider the smaller set \(\mathscr{N}' = \{1,3\}\text{,}\) then there is a function \(\funcdef{f}{\mathscr{N}'}{\mathscr{A}}\) with \(F = \funcgraph{f}\text{.}\)

Example 10.1.17. A function must be well-defined.

Again write \(\mathscr{N} = \{1,2,3\}\) and \(\mathscr{A} = \{a,b,c,d\}\text{,}\) and consider
\begin{equation*} F = \{ (1,a), (3,a), (3,d) \} \subseteq \mathscr{N} \cartprod \mathscr{A} \text{.} \end{equation*}
Does this subset define a function with domain \(\mathscr{N}\) and codomain \(\mathscr{A}\text{?}\) That is, does there exist a function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}}\) such that \(F = \funcgraph{f}\text{?}\) The answer is no, because there are more than one input-output pairs with domain element \(3\text{.}\) In other words, a function \(f\) with graph \(\funcgraph{f} = F\) is not well-defined, because we have no way to tell whether \(f(3)\) should be \(a\) or \(d\text{.}\)

Example 10.1.18. An input-output rule does not necessarily define a function.

Recall that
\begin{equation*} \Q = \setdef{\frac{m}{n}}{ m,n\in \Z,\, n\ne 0}\text{.} \end{equation*}
Suppose we attempt to define \(\funcdef{f}{\Q}{\Z}\) by \(f(\frac{m}{n}) = m+n\text{.}\) This seems like a valid way to define a function, until we realize that, for example,
\begin{align*} f\left(\frac{1}{2}\right) \amp = 1 + 2 = 3, \amp f\left(\frac{2}{4}\right) \amp = 2 + 4 = 6. \end{align*}
This is nonsense, because \(\frac{1}{2}\) and \(\frac{2}{4}\) represent the same element of \(\Q\text{.}\) Thus, rule \(f\) is not well-defined as a function, since to each element of the domain \(\Q\) it associates more than one element of the codomain \(\Z\text{.}\)

Subsection 10.1.5 Equality of functions

equality of functions
for \(\funcdef{f}{A}{B}\) and \(\funcdef{g}{A}{B}\text{,}\) write \(f = g\) if \(f(a) = g(a)\) for all \(a\in A\)

Example 10.1.19. Seemingly different input-output rules can define the same function.

The functions \(\funcdef{f}{\R}{\R}\text{,}\) \(f(x) = \abs{x}\text{,}\) and \(\funcdef{g}{\R}{\R}\text{,}\) \(g(x) = \sqrt{x^2}\text{,}\) are equal.

Subsection 10.1.6 Image of a function

image of a function
the set of all possible outputs of the function
\(f(A)\)
the image of function \(\funcdef{f}{A}{B}\text{,}\) so that
\begin{equation*} f(A) = \setdef{f(a)}{a \in A} \subseteq B \end{equation*}
A Venn diagram of the image of a function.
Figure 10.1.20. A Venn diagram of the image of a function.

Warning 10.1.21. Codomain elements are not necessarily image elements.

We have stated before that a codomain in a function definition may be “larger” than necessary because we do not always know precisely what output elements a given input-output rule will produce. Our idea of codomain is that it should at least tell us what “type” of outputs will be produced, but not necessarily exactly what outputs will be produced.
With our new concept of function image, we can now repeat this more technically: a function image is always a subset of the codomain, but it might be a proper subset.

How do we know if a codomain element is an image element?

For function \(\funcdef{f}{A}{B}\) and codomain element \(b\in B\text{,}\) we have \(b \in f(A)\) if and only if there exists \(a\in A\) such that \(b = f(a)\text{.}\)

Worked Example 10.1.22. Verifying a function image description.

Consider \(\funcdef{f}{\R}{\R}\text{,}\) \(f(x) = x^2\text{.}\) Prove \(f(\R) = \nnegset{\R}\text{,}\) where \(\nnegset{\R}\) is the set of nonnegative real numbers.
Solution.
Following the Test for Set Equality, we need to show both
\begin{align*} f(\R) \amp \subseteq \nnegset{\R}, \amp f(\R) \amp \supseteq \nnegset{\R} \text{.} \end{align*}
To be more explicit about the second set \(\nnegset{\R}\text{,}\) we can write
\begin{equation*} \nnegset{\R} = \setdef{x\in \R}{x \ge 0} \text{.} \end{equation*}
Show \(f(\R) \subseteq \nnegset{\R}\).
Let \(y\) represent an arbitrary element of \(f(\R)\text{.}\) As an element of the image of \(f\text{,}\) \(y\) is an output corresponding to some input. That is, there exists some \(x \in \R\) such that
\begin{equation*} y = f(x) = x^2 \text{.} \end{equation*}
Therefore, since square numbers are always positive, we have \(y \ge 0\text{,}\) and hence \(y \in \nnegset{\R}\text{.}\)
Show \(f(\R) \supseteq \nnegset{\R}\).
Let \(y\) represent an arbitrary element of \(\nnegset{\R}\text{.}\) To show \(y \in f(\R)\text{,}\) we need to find \(x \in \R\) such that \(f(x) = y\text{.}\) Let \(x = \sqrt{y}\text{,}\) which is defined since \(y \in \nnegset{\R}\) implies \(y\ge 0\text{.}\) Then
\begin{equation*} f(x) = x^2 = (\sqrt{y})^2 = y \text{,} \end{equation*}
as desired.
image of a function on a subset
the set of all outputs of a function when only fed inputs from a given subset
\(f(A')\)
the image of the subset \(A' \subseteq A\) under a function \(\funcdef{f}{A}{B}\text{,}\) so that
\begin{equation*} f(A') = \setdef{f(a)}{a \in A'} \subseteq B \end{equation*}

Example 10.1.23.

We saw in Worked Example 10.1.22 that for \(\funcdef{f}{\R}{\R}\text{,}\) \(f(x) = x^2\text{,}\) we have \(f(\R) = \nnegset{\R}\text{.}\) Now, the set of integers \(\Z\) is a subset of the domain \(\R\text{,}\) so we can compute
\begin{equation*} f(\Z) = \{0,1,4,9,16,\dotsc,n^2,\dotsc\} \subseteq \nnegset{\R} \text{.} \end{equation*}