Skip to main content

Discrete Mathematical Structures

Subsection 2.3.1 Basic terminology

We have seen examples of functions in previous math classes. Most were likely given by formulas, such as \(f(x) = x^2 + 2\text{.}\) Functions can given in other ways and are not always given by formulas. The key property of a function is that it accepts inputs and provides a corresponding output value for each possible input.

Definition 2.3.1.1.

Let \(A\) and \(B\) be nonempty sets. A function or mapping or transformation from \(A\) to \(B\text{,}\) denoted \(f \colon A \to B\) is an assignment of exactly one element of \(B\) to each element of \(A\text{.}\)
The set \(A\) is called the domain and \(B\) is called the codomain of \(f\text{.}\)
Two sets A and B are represented each by an oval.  The ovals do not overlap. An arrow labeled f goes from A to B.
Figure 2.3.1.2. Function from \(A\) to \(B\text{.}\)

Definition 2.3.1.3.

Let \(f \colon A \to B\) be a function, and let \(a\) be an element in \(A\text{.}\) The image of \(a\) is the unique element of \(B\) that is assigned by the function \(f\) to the element \(a\text{.}\)
In this case, write \(f(a) = b\text{,}\) where \(b\) is the image of \(a\text{.}\) We say \(a\) is a preimage of \(b\text{.}\)
By DefinitionΒ 2.3.1.1 each element of the domain of a function can only have one image. But an element of the codomain of a function can have several preimages.

Example 2.3.1.4. More than one preimage.

Under the function \(f:A\to B\) where \(A=\set{1,2,3,4}\) and \(B=\set{1,2,3}\) in FigureΒ 2.3.5.7 the element \(2\) of the codomain \(\set{1,2,3}\) has the preimages \(2\) and \(4\text{.}\)
A function must output a value for every input from the domain. Not every element in the codomain needs to be an image, though.

Example 2.3.1.5. Square and square root functions.

Consider \(f(x) = x^2 + 3\text{.}\) Then \(f\) defines a function from \(\RR\) to \(\RR\text{.}\) We write \(f \colon \RR \to \RR\text{.}\) The domain is \(\RR\text{.}\) The codomain is \(\RR\text{.}\)
On the other hand, the square rootΒ 0.1.6.3 function \(g(x) = \sqrt{x}\) is not a function from \(\RR\) to \(\RR\text{.}\) This is because, for example, \(-2\) is an element of \(\RR\text{,}\) but the formula does not define a value for \(g(-2)\text{.}\) We can view \(g\) as a function from \(\RR_{\geq 0}\) to \(\RR\text{.}\)
Functions do not have to be given by formulas, They do not have to be from sets of numbers to sets of numbers.

Example 2.3.1.6. Temperature function.

Each point on the surface of the earth has a particular temperature right now, and the temperature (in degrees Celsius) is a real number. Thus, temperature defines a function \(T\) from the surface of the earth to \(\RR\text{,}\) where \(T(x)\) is the temperature at the point \(x\text{.}\)

Definition 2.3.1.7.

Let \(f \colon A \to B\) be a function. The image of \(f\text{,}\) denoted \(\im(f)\) or \(f(A)\text{,}\) is the set of all images of elements of \(A\text{,}\)
\begin{equation*} \im(f) = \set{f(a) \given a \in A}. \end{equation*}
More generally, if \(S\) is a subset of \(A\text{,}\) the image of \(S\) under \(f\text{,}\) denoted \(f(S)\) is the set
\begin{equation*} f(S) = \set{f(s) \given s \in S}. \end{equation*}
The image of a function \(f\) is also called the range of \(f\text{.}\)
Functions are often given by a table of values.

Example 2.3.1.8. Gem stones.

Consider the prices of some expensive gem stones.
Gem stone price per carat
Blue Diamond $3930000
Pink Star Diamond $1200000
Musgravite $35000
Jadeite $20000
Alexandrite $12000
Red Beryl $10000
Padparadscha Sapphire $8000
This table describes a function \(p\) which gives the price per carat of these gem stones. The domain of \(p\) is \(\{\) Blue Diamond, Pink Star Diamond, Musgravite, Jadeite, Alexandrite, Red Beryl, Padparadscha Sapphire\(\}\text{.}\) We have that \(p(\text{Jadeite}) = \${20000}\text{,}\) but \(p(\text{Opal})\) does not exist, since Opal is not in the domain of \(p\text{.}\)
For a function \(f \colon A \to B\text{,}\) we need each element \(a\) in \(A\) to be assigned to a unique element \(f(a)\) in \(B\text{.}\) We do not require every element \(b\) in \(B\) to have a corresponding element in \(A\text{.}\) Specifically, an element of \(B\) may be the image of one, none, or several elements of \(A\text{.}\)

Example 2.3.1.9. Father function.

Let \(P\) denote the set of all people (alive or dead). Let \(F \colon P \to P\) be the function defined by the rule \(F(x)\) is the father of \(x\text{.}\) For example, \(F(\text{Ben Stiller}) = \text{Jerry Stiller}\text{,}\) since Jerry is Ben’s dad.
On the other hand, if we would run into trouble if we tried to define a function \(G\) for grandfathers. This is because people have two grandfathers (a paternal grandfather and a maternal grandfather), so \(G(\text{Ben Stiller})\) is ambiguous. Functions are not allowed to have this ambiguity. Thus \(G\) does not define a function from \(P\) to \(P\text{,}\) though it does define a relation that we discuss in SectionΒ 6.1.

Example 2.3.1.10. A function with domain \(\set{1, 2, 3}\).

Let \(A = \set{1, 2, 3}\text{,}\) and let \(B = \set{1, 2, 3, 4}\text{.}\) Let \(f\colon A \to B\) be the function defined by \(f(1) = 4\text{,}\) \(f(2) = 3\text{,}\) and \(f(3) = 1\text{.}\) Let’s see what some of the terms mean for this function.
  • The domain is \(\set{1, 2, 3}\text{.}\)
  • The codomain} is \(\set{1, 2, 3, 4}\text{.}\)
  • The image of \(3\) is \(1\text{,}\) since \(f(3) = 1\text{.}\)
  • A preimage of \(3\) is \(2\text{,}\) since \(f(2) = 3\text{.}\)
  • The element \(2\) has no preimage, since there is no element in the domain that \(f\) sends to \(2\text{.}\)
  • The image of \(\set{1,2}\) under \(f\) is \(\set{3, 4}\text{,}\) since
    \begin{equation*} f(\set{1,2}) = \set{f(1), f(2)} = \set{4, 3} = \set{3,4}. \end{equation*}
  • The image of the function \(f\) the same as the image of the domain \(A\) under \(f\text{.}\) This is \(\set{1, 3, 4}\text{,}\) since
    \begin{equation*} f(A) = f(\set{1,2,3}) = \set{f(1), f(2), f(3)} = \set{4, 3, 1} = \set{1, 3, 4}. \end{equation*}
We can think about functions in terms of objects and arrows, where each arrow joins an element \(a\) in \(A\) to the corresponding element \(f(a)\) in \(B\) as show in the next example.
Two sets A and B are represented each by an oval.  The ovals do not overlap. Inside A are the numbers 1, 2, and 3. Inside B are the numbers 1, 2, 3, and 4. An arrow labeled f goes from 1 in A to to 4 in B. An arrow labeled f goes from 2 in A to to 3 in B. An arrow labeled f goes from 3 in A to to 1 in B.
Figure 2.3.1.11. We represent the function \(f:A\to B\) where \(A=\set{1,2,3}\) and \(B=\set{1,2,3,4}\) from ExampleΒ 2.3.1.10 graphically using objects and arrows.

Example 2.3.1.12. Volume.

The volume of a box is a function of its length, width, and height. Let’s break this example down and recognize the components described above.
What is the domain ?
Consider the the set of triples of numbers representing the length, width, and height of a box. Then each number must be nonnegative (if we allow degenerate boxes). For concreteness, let’s consider ordered triples \((\ell, w, h)\) for length, width, and height. The set of all such triples is the domain of the volume function.
The volume of a box is a real number, so we can take the codomain to be \(\RR\text{.}\)
If \(V\) is the name of our volume function, then we have \(V \colon \RR_{\geq 0}^3 \to \RR\text{.}\) The image of \(V\) is the set of realizable outputs of the function \(V\text{.}\) Thus the image is the set of nonnegative real numbers,
\begin{equation*} \im(V) = \RR_{\geq 0}. \end{equation*}