Now that we have reviewed basic ideas about sets we can start doing more interesting things with them — functions.
When we are introduced to functions in mathematics, it is almost always as formulas. We take a number \(x\) and do some things to it to get a new number \(y\text{.}\) For example,
\begin{align*}
y = f(x) &= 3x-7
\end{align*}
Here, we take a number \(x\text{,}\) multiply it by 3 and then subtract seven to get the result.
This view of functions — a function is a formula — was how mathematicians defined them up until the 19th century. As basic ideas of sets became better defined, people revised ideas surrounding functions. The more modern definition of a function between two sets is that it is a rule which assigns to each element of the first set a unique element of the second set.
Consider the set of days of the week, and the set containing the alphabet
\begin{align*}
A &= \set{\text{Sunday, Monday}, \text{Tuesday, Wednesday}, \text{Thursday, Friday}, \text{Saturday}, \text{Sunday}}\\
B &= \set{\text{a,b,c,d,e}, \dots,\text{x,y,z}}
\end{align*}
We can define a function \(f\) that takes a day (that is, an element of \(A\)) and turns it into the first letter of that day (that is, an element of \(B\)). This is a valid function, though there is no formula. We can draw a picture of the function as
Clearly such pictures will work for small sets, but will get very messy for big ones. When we shift back to talking about functions on real numbers, then we will switch to using graphs of functions on the Cartesian plane.
This example is pretty simple, but this serves to illustrate some important points. If our function gives us a rule for taking elements in \(A\) and turning them into elements from \(B\) then
the function must be defined for all elements of \(A\) — that is, no matter which element of \(A\) we choose, the function must be able to give us an answer. Every function must have this property.
on the other hand, we don’t have to “hit” every element from \(B\text{.}\) In the above example, we miss almost all the letters in \(B\text{.}\) A function that does reach every element of \(B\) is said to be “surjective” or “onto”.
a given element of \(B\) may be reached by more than one element of \(A\text{.}\) In the above example, the days “Tuesday” and “Thursday” both map to the letter \(T\) and similarly the letters \(S\) is mapped to by both “Sunday” and “Saturday”. A function which does not do this, that is, every element in \(A\) maps to a different element in \(B\) is called “injective” or “one-to-one” — again we will come back to this later when we discuss inverse function in Section 0.6.
Summarising this more formally, we have
Definition0.4.1.
Let \(A, B\) be non-empty sets. A function \(f\) from \(A\) to \(B\text{,}\) is a rule or formula that takes elements of \(A\) as inputs and returns elements of \(B\) as outputs. We write this as
\begin{gather*}
f: A \to B
\end{gather*}
and if \(f\) takes \(a \in A\) as an input and returns \(b\in B\) then we write this as \(f(a) = b\text{.}\) Every function must satisfy the following two conditions
The function must be defined on every possible input from the set \(A\text{.}\) That is, no matter which element \(a \in A\) we choose, the function must return an element \(b \in B\) so that \(f(a)=b\text{.}\)
The function is only allowed to return one result for each input 1
You may have learned this in the context of plotting functions on the Cartesian plane, as “the vertical line test”. If the graph intersects a vertical line twice, then the same \(x\)-value will give two \(y\)-values and so the graph does not represent a function.
. So if we find that \(f(a)=b_1\) and \(f(a)=b_2\) then the only way that \(f\) can be a function is if \(b_1\) is exactly the same as \(b_2\text{.}\)
We must include the input and output sets \(A\) and \(B\) in the definition of the function. This is one of the reasons that we should not think of functions as just formulas. The input and output sets have proper mathematical names, which we give below:
Definition0.4.2.
Let \(f:A \to B\) be a function. Then
the set \(A\) of inputs to our function is the “domain” of \(f\text{,}\)
the set \(B\) which contains all the results is called the codomain,
We read “\(f(a) = b\)” as “\(f\) of \(a\) is \(b\)”, but sometimes we might say “\(f\) maps \(a\) to \(b\)” or “\(b\) is the image of \(a\)”.
The codomain must contain all the possible results of the function, but it might also contain a few other elements. The subset of \(B\) that is exactly the outputs of \(A\) is called the “range” of \(f\text{.}\) We define it more formally by
\begin{align*}
\text{range of } f &= \set{b \in B \;|\; \text{there is some } a \in
A \text{ so that } f(a) = b}\\
&= \set{f(a) \in B \;|\; a \in A}
\end{align*}
The only elements allowed in that set are those elements of \(B\) that are the images of elements in \(A\text{.}\)
Example0.4.3.domains and ranges.
Let us go back to the “days of the week” function example that we worked on above, we can define the domain, codomain and range:
The domain, \(A\text{,}\) is the set of days of the week.
The codomain, \(B\text{,}\) is the 26 letters of the alphabet.
The range is the set \(\set{F,M,T,S,W}\) — no other elements of \(B\) are images of inputs from \(A\text{.}\)
Example0.4.4.more domains and ranges.
A more numerical example — let \(g: \mathbb{R} \to \mathbb{R}\) be defined by the formula \(g(x) = x^2\text{.}\) Then
the domain and codomain are both the set of all real numbers, but
the range is the set \([0, \infty)\text{.}\)
Now — let \(h:[0,\infty) \to [0,\infty)\) be defined by the formula \(h(x) = \sqrt{x}\text{.}\) Then
the domain and codomain are both the set \([0,\infty)\text{,}\) that is all non-negative real numbers, and
in this case the range is equal to the codomain, namely \([0, \infty)\text{.}\)
This is an example of a “piece-wise” function — that is, one that is not defined by a single formula, but instead defined piece-by-piece. This function has domain \([-1,1]\) and its range is \(\set{0,120}\text{.}\) We could interpret this function as measuring the voltage across a switch that is flipped on at time \(t=0\text{.}\)
Almost all the functions we look at from here on will be formulas. However it is important to note, that we have to include the domain and codomain when we describe the function. If the domain and codomain are not stated explicitly then we should assume that both are \(\mathbb{R}\text{.}\)