10.1: Basics
10.1.1: Terminology and basic concepts
a rule which assigns to each input element from a set \(A\) a single output element from a set \(B\)
the set of all possible input elements for a function
a set containing all possible output elements for a function
\(f\) is a function with domain \(A\) and codomain \(B\)
the process/algorithm/rule/formula that describes how each input element from the domain will be transformed into an output element in the codomain
function \(f: A \rightarrow B\) associates the codomain element \(b\in B\) to the domain element \(a\in A\)
alternative notation for \(f(a) = b\)
when \(f(a) = b\) we say that \(b\) is the image of \(a\) under \(f\text{,}\) or that \(f\) maps \(a\) to \(b\)
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.
10.1.2: Defining functions
Defining a function is a two-step process , in which we need to specify three pieces of information :
- the domain ,
- the codomain , and
- the input-output rule .
The first two pieces of information are specified in one step, when we write
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.
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 \(f: \mathbb{R}_{\geq 0} \rightarrow \mathbb{R} \text{,}\) where \(\mathbb{R}_{\geq 0}\) represents the set of nonnegative real numbers.
In the function definition
\begin{align*} f\colon \mathbb{R} & \to \mathbb{R}, \\ x & \mapsto \dfrac{1}{x^2}, \end{align*}
the first line of the definition tells us the
domain
(\(\mathbb{R}\)),
codomain
(again \(\mathbb{R}\)), and a name for the function (\(f\)). The second line tells us the
input-output rule
, so that
\begin{equation*} f(x) = \dfrac{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*} f: \mathbb{R} \setminus \{0\}\rightarrow \mathbb{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*} f: \mathbb{R} \setminus \{0\} \rightarrow \mathbb{R}_{>0}, \end{equation*}
where \(\mathbb{R}_{>0}\) represents the set of positive real numbers, but it is not necessary to do so.
Consider the function \(\mathscr{P}(\mathbb{Z}) \to \mathbb{N}\) where outputs are computed according to the following algorithm.
Given an input element \(X \in \mathscr{P}(\mathbb{Z})\) (which, by definition, is a set of integers), carry out the following.
- Compute the absolute value of each element in \(X\text{.}\) (If \(X\) is empty, skip this step.)
- 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.)
- 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.4 .
For \(\mathscr{N} = \{1,2,3\}\) and \(\mathscr{A} = \{a,b,c,d\}\text{,}\) one way to define a function \(f: \mathscr{N}\rightarrow \mathscr{A}\) is
\begin{align*} f(1) & = d, & f(2) & = a, & f(3) & = d. \end{align*}
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((x,y)) = x^2 + y^2 \text{,} \end{equation*}
as the proper definition of \(f\) is \(f: \mathbb{R}^2 \rightarrow \mathbb{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, \(g: \mathbb{R}\rightarrow\mathbb{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 \(\varphi: \mathbb{R}^2 \rightarrow \mathbb{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 & = s - t, & y & = s + t. \end{align*}
A logical statement \(S\) involving statement variables \(p_1, p_2, \ldots , p_m\) is essentially a multi-variable function
\begin{equation*} S: \Lambda^m \rightarrow \Lambda \text{,} \end{equation*}
where \(\Lambda = \{ T,\, F \}\text{.}\) For example, the statement
\begin{equation*} S(p_1,p_2) = (p_1 \rightarrow p_2) \end{equation*}
is a function \(S: \Lambda \times \Lambda \rightarrow \Lambda \text{,}\) where
\begin{align*} S(T,T) & = T, & S(T,F) & = F, & S(F,T) & = T, & S(F,F) & = T. \end{align*}
10.1.3: Graph of a function
the set of all input-output pairs for the function
the graph of function \(f: A \rightarrow B\text{,}\) so that
\begin{equation*} \Delta (f) = \{(a,f(a)) \vert a \in A\} \subseteq A \times B \end{equation*}
To describe the graph of the function \(f: \mathscr{N} \rightarrow \mathscr{A}\) defined in Example \(\PageIndex{4}\), we just need to collect the defined input-output pairs into Cartesian product elements:
This graph can most simply be represented by a table:
| \(x\) | \(1\) | \(2\) | \(3\) |
| \(f(x)\) | \(d\) | \(a\) | \(d\) |
The graph of a function \(f: \mathbb{R} \rightarrow \mathbb{R}\) is a subset of \(\mathbb{R} \times \mathbb{R} = \mathbb{R}^2\text{.}\) We usually represent \(\mathbb{R}^2\) visually as the \(xy\)-plane and the graph \(\Delta (f) \subseteq \mathbb{R}^2\) as a curve in the plane.
In the graph of \(f(x) = x^2\) above, each point on the curve represents an element of \(\mathbb{R}^2\) which is in the subset \(\Delta (f)\text{.}\) For example, \((-1,1) \in \Delta (f)\) but \((-1,\pi) \notin \Delta (f)\text{.}\)
The graph of a function \(f: \mathbb{R}^2 \rightarrow \mathbb{R}\) is technically a subset of \(\mathbb{R}^2 \times \mathbb{R}\text{,}\) but usually we just think of this as \(\mathbb{R}^3\text{,}\) or \(3\)-space. Instead of a curve, such a graph defines a surface in \(\mathbb{R}^3\text{.}\) For example, the graph of the function \(f(x,y) = x^2 + y^2\) from Example \(\PageIndex{5}\) is a parabolic cone, i.e. a (non-solid) cone-like surface with parabolic sides.
We've already encountered the graph of a logical statement: it is usually represented as a truth table. For example, the graph \(\Delta (S)\) of the logical statement
where \(\Lambda = \{ T, F \}\) as usual, can be represented as below.
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.
a subset \(F \subseteq A \times 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 .
We are now defining a function \(f: \mathbb{R} \rightarrow \mathbb{R}\) to be the subset of the Cartesian plane \(\mathbb{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.)
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.
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} \times \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 \(f: \mathscr{N} \rightarrow \mathscr{A}\) such that \(F = \Delta (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 \(\Delta (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 \(f: \mathscr{N}' \rightarrow \mathscr{A}\) with \(F = \Delta (f)\text{.}\)
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} \times \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 \(f: \mathscr{N} \rightarrow \mathscr{A}\) such that \(F = \Delta (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 \(\Delta (f) = F\) is not
well-defined
, because we have no way to tell whether \(f(3)\) should be \(a\) or \(d\text{.}\)
Recall that
\begin{equation*} \mathbb{Q} = \{\dfrac{m}{n}\vert m,n\in \mathbb{Z},\, n\ne 0\}\text{.} \end{equation*}
Suppose we attempt to define \(f: \mathbb{Q} \rightarrow \mathbb{Z}\) by \(f(\dfrac{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(\dfrac{1}{2}\right) & = 1 + 2 = 3, & f\left(\dfrac{2}{4}\right) & = 2 + 4 = 6. \end{align*}
This is nonsense, because \(\dfrac{1}{2}\) and \(\dfrac{2}{4}\) represent the same element of \(\mathbb{Q}\text{.}\) Thus, rule \(f\) is not well-defined as a function, since to each element of the domain \(\mathbb{Q}\) it associates more than one element of the codomain \(\mathbb{Z}\text{.}\)
10.1.5: Equality of functions
for \(f: A \rightarrow B\) and \(g: A\rightarrow B \text{,}\) write \(f = g\) if \(f(a) = g(a)\) for all \(a\in A\)
The functions \(f: \mathbb{R}\rightarrow \mathbb{R}\text{,}\) \(f(x) = \vert x \vert\text{,}\) and \(g: \mathbb{R}\rightarrow \mathbb{R}\text{,}\) \(g(x) = \sqrt{x^2}\text{,}\) are equal.
10.1.6: Image of a function
the set of all possible outputs of the function
the image of function \(f: A \rightarrow B\text{,}\) so that
\begin{equation*} f(A) = \{f(a) \vert a \in A\} \subseteq B \end{equation*}
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 \(f: A \rightarrow 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{.}\)
Consider \(f: \mathbb{R} \rightarrow \mathbb{R}\text{,}\) \(f(x) = x^2\text{.}\) Prove \(f(\mathbb{R}) = \mathbb{R}_{\geq 0}\text{,}\) where \(\mathbb{R}_{\geq 0}\) is the set of nonnegative real numbers.
Solution
Following the Test for Set Equality, we need to show both
\begin{align*} f(\mathbb{R}) & \subseteq \mathbb{R}_{\geq 0}, & f(\mathbb{R}) & \supseteq \mathbb{R}_{\geq 0} \text{.} \end{align*}
To be more explicit about the second set \(\mathbb{R}_{\geq 0}\text{,}\) we can write
\begin{equation*} \mathbb{R}_{\geq 0} = \{x\in \mathbb{R} \vert x \ge 0 \} \text{.} \end{equation*}
Show \(f(\mathbb{R}) \subseteq \mathbb{R}_{\geq 0}\).
Let \(y\) represent an arbitrary element of \(f(\mathbb{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 \mathbb{R}\) such that
Therefore, since square numbers are always positive, we have \(y \ge 0\text{,}\) and hence \(y \in \mathbb{R}_{\geq 0}\text{.}\)
Show \(f(\mathbb{R}) \supseteq \mathbb{R}_{\geq 0}\).
Let \(y\) represent an arbitrary element of \(\mathbb{R}_{\geq 0}\text{.}\) To show \(y \in f(\mathbb{R})\text{,}\) we need to find \(x \in \mathbb{R}\) such that \(f(x) = y\text{.}\) Let \(x = \sqrt{y}\text{,}\) which is defined since \(y \in \mathbb{R}_{\geq 0}\) implies \(y\ge 0\text{.}\) Then
as desired.
the set of all outputs of a function when only fed inputs from a given subset
the image of the subset \(A' \subseteq A\) under a function \(f: A \rightarrow B\text{,}\) so that
\begin{equation*} f(A') = \{f(a) \vert a \in A' \} \subseteq B \end{equation*}
We saw in Worked Example \(\PageIndex{16}\) that for \(f: \mathbb{R}\rightarrow \mathbb{R} \text{,}\) \(f(x) = x^2\text{,}\) we have \(f(\mathbb{R}) = \mathbb{R}_{\geq 0}\text{.}\) Now, the set of integers \(\mathbb{Z}\) is a subset of the domain \(\mathbb{R}\text{,}\) so we can compute
\begin{equation*} f(\mathbb{Z}) = \{0,1,4,9,16,\ldots ,n^2,\ldots \} \subseteq \mathbb{R}_{\geq 0} \text{.} \end{equation*}