### Functions between sets

In the Content sections of this module, we have dealt exclusively with real functions. In the 20th century, the concept of a function was generalised to functions from any set to any other set. This has turned out to be a very powerful idea.

###### Definition
Let $$A$$ and $$B$$ be any two sets. A function $$f$$ from $$A$$ to $$B$$ is a rule which maps each element $$x$$ in $$A$$ to an element $$f(x)$$ in $$B$$. A common notation is \begin{align*} f &\colon A\to B \\ f &\colon x\mapsto f(x) \end{align*}
###### Notes.
1. A function from $$A$$ to $$B$$ is often called a map from $$A$$ to $$B$$.
2. The set $$A$$ is called the domain of the function, and the set $$B$$ is called the codomain.
3. The range of a function $$f\colon A \to B$$ is the set $$\{\, y\in B : y=f(x) \text{ for some } x\in A \,\}$$. Another notation for the range is $$f(A) = \{\, f(x) : x\in A \,\}$$.
4. There is a difficulty with domains. For example, consider the real function $f(x) = \dfrac{1}{x-2}.$ One approach is define $$A = \{\, x\in\mathbb{R} : x\neq 2\,\}$$, and then define $f\colon A\to \mathbb{R}, \quad f(x)=\dfrac{1}{x-2}.$ A difficulty with this approach is that the precise domain must be known for the function to be properly specified.

In the next example, we use $$\mathbb{N}$$ to denote the set of all positive integers (also called the set of natural numbers). That is, $$\mathbb{N} = \{1, 2, 3, \dots \}$$.

#### Example

An infinite sequence $$a_1, a_2, a_3, a_4, \dots$$ of real numbers can be thought of as a function $$S\colon \mathbb{N} \to \mathbb{R}$$ given by $$S(n) = a_n$$. For example:
• An arithmetic sequence is of the form $a,\ a+d,\ a+2d,\ a+3d,\ \dots$ for some $$a,d \in \mathbb{R}$$. The associated function $$S\colon \mathbb{N} \to \mathbb{R}$$ is given by $$S(n) = a+(n-1)d$$.
• A geometric sequence is of the form $a,\ ar,\ ar^2,\ ar^3,\ \dots$ for some $$a,r \in \mathbb{R}$$. The associated function $$S\colon \mathbb{N} \to \mathbb{R}$$ is given by $$S(n) = ar^{n-1}$$.
##### Exercise 6

Classify each of the following sequences as arithmetic, geometric or neither.

1. $$2,\ 5,\ 8,\ 11,\ 14,\ \dots$$
2. $$3,\ -6,\ 12,\ -24,\ 48,\ \dots$$
3. $$1,\ 0.1,\ 0.01,\ 0.001,\ 0.0001,\ \dots$$
4. $$1,\ 1,\ 2,\ 3,\ 5,\ 8,\ 13,\ \dots$$
5. The sequence of decimal approximations to $$\pi$$: $3,\ 3.1,\ 3.14,\ 3.142,\ 3.1416,\ 3.14159,\ \dots\,.$

#### Example

Consider the function $$f\colon \mathbb{R}\to \mathbb{R}$$ given by $$f(x)=\lfloor x \rfloor$$. The range of $$f$$ is $$\mathbb{Z}$$. Hence $$f$$ is also a function from $$\mathbb{R}$$ to $$\mathbb{Z}$$.

##### Exercise 7

Determine the domain, codomain and range of $$f\colon \mathbb{N} \to \mathbb{N}$$ given by $$f(n) = 2n+1$$.

Next page - Links forward - Functions between finite sets