0.4: Functions
( \newcommand{\kernel}{\mathrm{null}\,}\)
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
Here, we take a number
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
We can define a function
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
- the function must be defined for all elements of
— that is, no matter which element of 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
In the above example, we miss almost all the letters in A function that does reach every element of is said to be “surjective” or “onto”. - a given element of
may be reached by more than one element of In the above example, the days “Tuesday” and “Thursday” both map to the letter and similarly the letters is mapped to by both “Sunday” and “Saturday”. A function which does not do this, that is, every element in maps to a different element in 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
Let
and if
- The function must be defined on every possible input from the set
That is, no matter which element we choose, the function must return an element so that - The function is only allowed to return one result for each input 1. So if we find that
and then the only way that can be a function is if is exactly the same as
We must include the input and output sets
Let
- the set
of inputs to our function is the “domain” of - the set
which contains all the results is called the codomain, - We read “
” as “ of is ”, but sometimes we might say “ maps to ” or “ is the image of ”. - The codomain must contain all the possible results of the function, but it might also contain a few other elements. The subset of
that is exactly the outputs of is called the “range” of We define it more formally by
The only elements allowed in that set are those elements of that are the images of elements in
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,
is the set of days of the week. - The codomain,
is the 26 letters of the alphabet. - The range is the set
— no other elements of are images of inputs from
A more numerical example — let
- the domain and codomain are both the set of all real numbers, but
- the range is the set
Now — let
- the domain and codomain are both the set
that is all non-negative real numbers, and - in this case the range is equal to the codomain, namely
Yet another numerical example.
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
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


