- Virtual Laboratories
- 0. Foundations
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9

Functions play a central role in probability and statistics, as they do in every other branch of mathematics.

Suppose that
$S$
and
$T$
are sets. Technically, a function
$f$
from
$S$ into
$T$
is a subset of the product set
$S\times T$
with the property that for each element
$x\in S$,
there exists a unique element
$y\in T$
such that
$\left(\begin{array}{c}x\\ y\end{array}\right)\in f$.
We then write
$y=f(x)$.
Less formally, a function
$f$
from
$S$
into
$T$
is a rule

(or procedure

or algorithm

) that assigns to each
$x\in S$
a unique element
$f(x)\in T$.
The definition of a function as a set of ordered pairs, is due to Kazamierz Kuratowski. When
$f$
is a function from
$S$
into
$T$,
we write
$(f, S, T)$

The set $S$ is the domain of $f$ and the set $T$ is the range space or co-domain of $f$. The actual range of $f$ is the set of function values:

$$\mathrm{range}(f)=\{y\in T\colon \exists x\in S\colon y=f(x)\}$$If the range of
$f$
is
$T$,
then
$f$
is said to map
$S$
onto
$T$
(instead of just *into*). Thus, if
$f$
maps
$S$ onto
$T$,
then for each
$y\in T$
there exists
$x\in S$
such that
$f(x)=y$.
By definition, any function maps its domain *onto* its range.

A function $f$ is said to be one-to-one if distinct elements in the domain are mapped to distinct elements in the range.

$$(f(u)=f(v))\implies (u=v)\text{,\hspace{1em}}u\in S\text{,\hspace{0.5em}}v\in S$$If $f$ is a one-to-one function from $S$ onto $T$, we can define the inverse of $f$ as the function $f^{(-1)}$ from $T$ onto $S$ given by

$$f^{(-1)}(y)=x\text{\hspace{0.5em}if and only if\hspace{0.5em}}f(x)=y$$If you like to think of a function as a set of ordered pairs, then $f^{(-1)}=\{\left(\begin{array}{c}y\\ x\end{array}\right)\colon \left(\begin{array}{c}x\\ y\end{array}\right)\in f\}$. The fact that $f$ is one-to-one and onto ensures that $f^{(-1)}$ is a valid function from $T$ onto $S$. Sets $S$ and $T$ are in one-to-one correspondence if there exists a one-to-one function from $S$ onto $T$; one-to-one correspondence plays an essential role in the study of cardinality.

Suppose that $(g, R, S)$ and $(f, S, T)$. The composition of $f$ with $g$ is the function $(f\circ g, R, T)$ defined by

$$(f\circ g)(x)=f(g(x))\text{,\hspace{1em}}x\in R$$Show that composition is not commutative:

- Give an example of functions $f$ and $g$ where $f\circ g$ is defined but $g\circ f$ is not.
- Give an example of functions $f$ and $g$ where $f\circ g$ and $g\circ f$ are defined, but the compositions have different domains and co-domains.
- Give an example of functions $f$ and $g$ where $f\circ g$ and $g\circ f$ are defined, have the same domain and co-domain, but are still different.

Suppose that $(h, R, S)$, $(g, S, T)$, and $(f, T, U)$. Show that composition is associative:

$$f\circ g\circ h=f\circ g\circ h$$Thus we can write $f\circ g\circ h$ without ambiguity.

Suppose that $(g, R, S)$ and $(f, S, T)$.

- Show that if $f$ and $g$ are one-to-one then $f\circ g$ is one-to-one.
- Show that if $f$ and $g$ are onto then $f\circ g$ is onto.

The identity function on a set $S$ is the function $\mathrm{id}_{S}$ from $S$ onto $S$ defined by $\mathrm{id}_{S}(x)=x\text{,\hspace{0.5em}}x\in S$

Show that the identity function acts like an identity with respect to the operation of composition. If $(f, S, T)$ then

- $f\circ \mathrm{id}_{S}=f$
- $\mathrm{id}_{T}\circ f=f$

The inverse of a function is really the inverse with respect to composition. Suppose that $f$ is a one-to-one function from $S$ onto $T$. Show that

- $f^{(-1)}\circ f=\mathrm{id}_{S}$.
- $f\circ f^{(-1)}=\mathrm{id}_{T}$

An element $s\in S^{n}$ can be thought of as a function from $\{1, 2, , n\}$ into $S$. Similarly, an element $s\in S^{\infty}$ can be thought of as a function from $\{1, 2, \}$ into $S$. For such a sequence $s$, of course, we usually write $s_{i}$ instead of $s(i)$. More generally, if $S$ and $T$ are sets, then the set of all functions from $S$ into $T$ is denoted by $T^{S}$.

Suppose that $g$ is a one-to-one function from $R$ onto $S$ and that $f$ is a one-to-one function form $S$ onto $T$. Show that $$f\circ g^{(-1)}=g^{(-1)}\circ f^{(-1)}$$.

Suppose that $f$ is a function from a set $S$ into a set $T$. If $A\subseteq T$, the inverse image of $A$ under $f$ is the subset of $S$ consisting of those elements that map into $B$:

$$f^{(-1)}(A)=\{x\in S\colon f(x)\in A\}$$Technically, the inverse images define a new function from $(T)$ into $(S)$. We use the same notation as for the inverse function, which is defined when $f$ is one-to-one and onto. Usually, no confusion results. The following important exercise shows that inverse images preserve all set operations.

Suppose that $f$ is a function from $S$ into $T$, and $A$ and $B$ are subsets of $T$. Show that

- $f^{(-1)}(A\cup B)=f^{(-1)}(A)\cup f^{(-1)}(B)$
- $f^{(-1)}(A\cap B)=f^{(-1)}(A)\cap f^{(-1)}(B)$
- $f^{(-1)}(B\setminus A)=f^{(-1)}(B)\setminus f^{(-1)}(A)$
- $(A\subseteq B)\implies (f^{(-1)}(A)\subseteq f^{(-1)}(B))$
- If $A$ and $B$ are disjoint, so are $f^{(-1)}(A)$ and $f^{(-1)}(B)$

The result in part (a) hold for arbitrary unions, and the results in part (b) hold for arbitrary intersections. No new ideas are involved; only the notation is more complicated.

Suppose again that $f$ is a function from a set $S$ into a set $T$. If $A\subseteq S$, the forward image of $A$ under $f$ is the subset of $T$ given by

$$f(A)=\{f(x)\colon x\in A\}$$Technically, the forward images define a new function from $(S)$ into $(T)$, but we use the same symbol $f$ for this new function as for the underlying function from $S$ into $T$ that we started with. Usually, no confusion results.

It might seem that forward images are more natural than inverse images, but in fact, the inverse images are much more important than the forward ones (at least in probability and measure theory). Fortunately, the inverse images are nicer as well--unlike the inverse images, the forward images do not preserve all of the set operations.

Suppose that $f$ is a function from $S$ into $T$, and $A$ and $B$ are subsets of $S$. Show that

- $f(A\cup B)=f(A)\cup f(B)$
- $f(A\cap B)\subseteq f(A)\cap f(B)$
- $f(B)\setminus f(A)\subseteq f(B\setminus A)$
- $(A\subseteq B)\implies (f(A)\subseteq f(B))$
- Equality holds in parts (b) and (c) if $f$ is one-to-one.

The result in part (a) hold for arbitrary unions, and the results in part (b) hold for arbitrary intersections. No new ideas are involved; only the notation is more complicated.

Suppose again that $(f, S, T)$, As noted earlier, the forward images of $f$ define a function from $(S)$ into $(T)$ and the inverse images define a function from $(T)$ into $(S)$ One might hope that these functions are inverses of one-another, but alas no.

Suppose that $(f, S, T)$.

- Show that $A\subseteq f^{(-1)}(f(A))$ for $A\subseteq S$
- Show that equality holds in (a) if $f$ is one-to-one, and give a counterexample to show that equality does not hold generally.
- Show that $f(f^{(-1)}(A))\subseteq A$ for $A\subseteq T$
- Show that equality holds in (c) if $f$ is onto, and give a counterexample to show that equality does not hold generally.

Suppose that $A$ is a subset of a universal set $S$. The indicator function of $A$ is the function $((A), S, \{0, 1\})$ defined as follows: $$(A)(x)=\begin{cases}1 & \text{if $x\in A$}\\ 0 & \text{if $x\notin A$}\end{cases}$$

Conversely, show that any function $(f, S, \{0, 1\})$ is the indicator function of the set

$$A=f^{(-1)}(\{1\})=\{x\in S\colon f(x)=1\}$$Thus, there is a one-to-one correspondence between
$(S)$,
the power set of
$S$,
and the collection of indicator functions
$\{0, 1\}^{S}$.
The next exercise shows how the *set algebra* of subsets corresponds to the *arithmetic algebra* of the indicator functions.

Suppose that $A$ and $B$ are subsets of $S$. Show that

- $(A\cap B)=(A)(B)=\min\{(A) , (B)\}$
- $(A\cup B)=1-(1-(A))(1-(B))=\max\{(A) , (B)\}$
- $(B\setminus A)=(B)(1-(A))$
- $((A))=1-(A)$
- $A\subseteq B$ if and only if $(A)\le (B)$

The results in part (a) extends to arbitrary intersections and the results in part (b) extends to arbitrary unions.

Suppose that $A$ and $B$ are subsets of $S$. Express, in terms of $(A)$ and $(B)$, the indicator function of each of the 16 sets that can be constructed from $A$ and $B$. Use the Venn diagram applet to help.

Suppose that $S$ and $T$ are sets and that $(f, S, T^{n})$ where $n\in \{2, 3, \}$. For $i\in \{1, 2, , n\}$, we define the $(i)$ coordinate function $(f_{i}, S, T)$ by the rule that $f_{i}(x)$ is the $(i)$ coordinate of $f(x)$ for each $x\in S$. Conversely, a sequence of functions $\left(\begin{array}{c}f_{1}\\ f_{2}\\ \\ f_{n}\end{array}\right)$, each mapping $S$ into $T$, defines a function $(f, S, T^{n})$ by the rule $f(x)=\left(\begin{array}{c}f_{1}(x)\\ f_{2}(x)\\ \\ f_{n}(x)\end{array}\right)$ for $x\in S$.

Suppose that
$S$ is a set. A function
$(f, S, S)$
is sometimes called an unary operation on
$S$. As the name suggests,
$f$ *operates* on an element
$x\in S$
to produce a new element
$f(x)\in S$.
Similarly, a function
$(g, S\times S, S)$
is sometimes called an binary operation on
$S$. As the name suggests,
$g$ *operates* on a pair of elements
$\left(\begin{array}{c}x\\ y\end{array}\right)\in (S\times S)$
to produce a new element
$g(x, y)\in S$.

The *arithmetic operations* are quintessential examples:

- $\mathrm{minus}(x)=-x$ is a unary operation on $\mathbb{R}$
- $\mathrm{plus}(x, y)=x+y$ is a binary operation on $\mathbb{R}$
- $\mathrm{times}(x, y)=xy$ is a binary operation on $\mathbb{R}$
- $\mathrm{difference}(x, y)=x-y$ is a binary operation on $\mathbb{R}$
- $\mathrm{reciprocal}(x)=\frac{1}{x}$ is a unary operation on $\mathbb{R}\setminus \{0\}$

The *set operations* on
$(S)$ were studied in the section on Sets:

- $\mathrm{complement}(A)=(A)$ is a unary operation.
- $\mathrm{union}(A, B)=A\cup B$ is a binary operation.
- $\mathrm{intersect}(A, B)=A\cap B$ is a binary operation.
- $\mathrm{difference}(A, B)=A\setminus B$ is a binary operation.

Suppose now that $f$ is a unary operation on $S$, $g$ is a binary operation on $S$, and that $A\subseteq S$. Then $A$ is said to be closed under $f$ if $x\in A\implies f(x)\in A$. Thus, $f$ restricted to $A$ is a unary operation on $A$. Similarly, $A$ is said to be closed under $g$ if $\left(\begin{array}{c}x\\ y\end{array}\right)\in (A\times A)\implies g(x, y)\in A$. Thus, $g$ restricted to $A\times A$ is a binary operation on $A$. Returning to our basic examples, note that

- $\mathbb{N}$ is closed under plus and times, but not under minus and difference.
- $\mathbb{Z}$ is closed under plus, times, minus, and difference.

Many properties that you are familiar with for special operations (such as the arithmetic and set operations) can now be formulated generally. Suppose that $f$ and $g$ are binary operations on $S$. In the following definitions, $x$, $y$, and $z$ are arbitrary elements of $S$.

- $f$ is commutative if $f(x, y)=f(y, x)$
- $f$ is associative if $f(x, f(y, z))=f(f(x, y), z)$
- $g$ distributes over $f$ (on the left) if $g(x, f(y, z))=f(g(x, y), g(x, z))$

Suppose that $S$ is a collection of nonempty subsets of a set $S$. The axiom of choice states that there exists a function $(f, S, S)$ with the property that $f(A)\in A$ for each $A\in S$. The function $f$ is known as a choice function.

Stripped of most of the mathematical jargon, the idea is very simple. Since each set
$A\in S$
is nonempty, we can select an element of
$A$; we will call the element we select
$f(A)$
and thus our selections define a function. In fact, you may wonder why we need an axiom at all. The problem is that we have not given a *rule* (or procedure or algorithm) for selecting the elements of the sets in the collection. Indeed, we may not know enough about the sets in the collection to define a specific rule, so in such a case, the axiom of choice simply guarantees the existence of a choice function. Some mathematicians, known as constructionists do not accept the axiom of choice, and insist on well defined rules for constructing functions.

A nice consequence of the axiom of choice is a type of duality between one-to-one functions and onto functions.

Suppose that $f$ is a function from a set $S$ onto a set $T$. Show that there exists a one-to-one function $g$ from $T$ into $S$.

- For each $y\in T$, the set $f^{(-1)}(\{y\})$ is non-empty, since $f$ is onto.
- Use the axiom of choice to select an element $g(y)$ from $f^{(-1)}(\{y\})$ for each $y\in T$.
- Show that the resulting function $g$ is one-to-one.

Suppose that $f$ is a one-to-one function from a set $S$ into a set $T$. Show that there exists a function $g$ from $T$ onto $S$.

- Fix a special element $s\in S$.
- If $y\in \mathrm{range}(f)$, there exists a unique $x\in S$ with $f(x)=y$. Define $g(y)=x$.
- If $y\notin \mathrm{range}(f)$, define $g(y)=s$.
- Show that the function $g$ is onto.

Each of the following rules defines a function from $\mathbb{R}$ into $\mathbb{R}$.

- $f(x)=x^{2}$
- $g(x)=\sin x$
- $h(x)=\lfloor x\rfloor $
- $F(x)=\frac{e^{x}}{1+e^{x}}$

Find the range of the function and determine if the function is one-to-one in each of the following cases:

- $f$
- $g$
- $h$
- $F$

Find the following inverse images:

- $f^{(-1)}(\left[4 , 9\right])$
- $g^{(-1)}(\{0\})$
- $h^{(-1)}(\{2, 3, 4\})$

You showed that the function $F$ is one-to-one. Find (that is, give the domain and rule for) the inverse function $F^{(-1)}$.

Give the rule and find the range for each of the following functions:

- $f\circ g$
- $g\circ f$
- $h\circ g\circ f$

Let $S=\{1, 2, 3, 4, 5, 6\}^{2}$. This is the set of possible outcomes when a pair of standard dice are thrown. Let $f$, $g$, and $h$ be the functions from $S$ into $$ defined by the following rules:

- $f(x, y)=x+y$
- $u(x, y)=\min\{x , y\}$
- $v(x, y)=\max\{x , y\}$

Find the range of each of the following functions:

- $f$
- $u$
- $v$
- $g=\left(\begin{array}{c}u\\ v\end{array}\right)$