### Definition of a Function

Recall that a binary relation \(R\) from set \(A\) to set \(B\) is defined as a subset of the Cartesian product \(A \times B,\) which is the set of all possible ordered pairs \(\left( {a,b} \right),\) where \(a \in A\) and \(b \in B.\)

If \(R \subseteq A \times B\) is a binary relation and \(\left( {a,b} \right) \in R,\) we say that \(a\) is related to \(b\) by \(R.\) It is denoted as \(aRb.\)

A function, denoted by \(f,\) is a special type of binary relation. A function from set \(A\) to set \(B\) is a relation \(f \subseteq A \times B\) that satisfies the following two properties:

- Each element \(a \in A\) is mapped to some element \(b \in B.\)
- Each element \(a \in A\) is mapped to exactly one element \(b \in B.\)

As a counterexample, consider a relation \(R\) that contains pairs \(\left( {1,1} \right),\left( {1,2} \right).\) The relation \(R\) is not a function, because the element \(1\) is mapped to two elements, which violates the second requirement.

In the next example, the second relation (on the right) is also not a function since both conditions are not met. The input element \(11\) has no output value, and the element \(3\) has two values – \(6\) and \(7.\)

If \(f\) is a function from set \(A\) to set \(B,\) we write \(f : A \to B.\) The fact that a function \(f\) maps an element \(a \in A\) to an element \(b \in B\) is usually written as \(f\left( a \right) = b.\)

### Domain, Codomain, Range, Image, Preimage

We will introduce some more important notions. Consider a function \(f : A \to B.\)

The set \(A\) is called the domain of the function \(f,\) and the set \(B\) is the codomain. The domain and codomain of \(f\) are denoted, respectively, \(\text{dom}\left({f}\right)\) and \(\text{codom}\left({f}\right)\).

If \(f\left( a \right) = b,\) the element \(b\) is the image of \(a\) under \(f.\) Respectively, the element \(a\) is the preimage of \(b\) under \(f.\) The element \(a\) is also often called the argument or input of the function \(f,\) and the element \(b\) is called the value of the function \(f\) or its output.

The set of all images of elements of \(A\) is briefly referred to as the image of \(A.\) It is also known as the range of the function \(f,\) although this term may have different meanings. The range of \(f\) is denoted \(\text{rng}\left({f}\right)\). It follows from the definition that the range is a subset of the codomain.

## Solved Problems

Click or tap a problem to see the solution.

### Example 1

Let \(A = \left\{ {a,b,c,d} \right\}\) and \(B = \left\{ {1,2,3} \right\}.\) Determine which of the following relations from \(A\) to \(B\) are functions:- \(\left\{ {\left( {a,1} \right),\left( {b,2} \right),\left( {c,1} \right),\left( {d,3} \right)} \right\}\)
- \(\left\{ {\left( {a,1} \right),\left( {b,1} \right),\left( {b,2} \right),\left( {c,3} \right)} \right\}\)
- \(\left\{ {\left( {a,2} \right),\left( {b,2} \right),\left( {c,2} \right),\left( {d,2} \right)} \right\}\)
- \(\left\{ {\left( {a,1} \right),\left( {b,2} \right),\left( {c,3} \right),\left( {d,1} \right)} \right\}\)
- \(\left\{ {\left( {b,3} \right),\left( {c,2} \right),\left( {d,1} \right),\left( {c,3} \right)} \right\}\)

### Example 2

Find the domain and range of the following functions:- The function \(f_1\) assigns to each natural number the product of its digits.
- The function \(f_2\) assigns to each integer its last digit squared.
- The function \(f_3\) assigns to each pair of natural numbers the average value of these numbers.
- The function \(f_4\) is a Boolean function in three variables.

### Example 3

List all functions \(f:\left\{ {a,b,c} \right\} \to \left\{ {0,1} \right\}.\)### Example 4

List all functions \(g:\left\{ {0,1} \right\} \to \left\{ {a,b,c} \right\}.\)### Example 5

The function \(f : \mathbb{R} \to \mathbb{R}\) is defined by \(f\left( x \right) = 5{x^2} – {x^4}.\) Find all preimages of \(6.\)### Example 6

The function \(g : \mathbb{Z} \to \mathbb{Z}\) is defined by \(g\left( x \right) = 3{x^2} – {x^4} + 5.\) Find all preimages of \(7.\)### Example 7

The function \(f : \mathcal{P}\left(\left\{{a,b,c}\right\}\right) \to \left\{{0,1,2,3}\right\}\) is given by the formula \(f\left( x \right) = \left| x \right|,\) where \(\left| x \right|\) is the cardinality of the set \(x.\) Calculate the average value of the function \(f.\)### Example 8

The function \(g : \mathcal{P}\left({\mathcal{P}\left(\left\{{a,b,c}\right\}\right)}\right) \to \mathbb{N}\cup 0\) is given by the formula \(g\left( x \right) = \left| x \right|,\) where \(\left| x \right|\) is the cardinality of the set \(x.\) Calculate the maximum value of the function \(g.\)### Example 1.

Let \(A = \left\{ {a,b,c,d} \right\}\) and \(B = \left\{ {1,2,3} \right\}.\) Determine which of the following relations from \(A\) to \(B\) are functions:- \(\left\{ {\left( {a,1} \right),\left( {b,2} \right),\left( {c,1} \right),\left( {d,3} \right)} \right\}\)
- \(\left\{ {\left( {a,1} \right),\left( {b,1} \right),\left( {b,2} \right),\left( {c,3} \right)} \right\}\)
- \(\left\{ {\left( {a,2} \right),\left( {b,2} \right),\left( {c,2} \right),\left( {d,2} \right)} \right\}\)
- \(\left\{ {\left( {a,1} \right),\left( {b,2} \right),\left( {c,3} \right),\left( {d,1} \right)} \right\}\)
- \(\left\{ {\left( {b,3} \right),\left( {c,2} \right),\left( {d,1} \right),\left( {c,3} \right)} \right\}\)

Solution.

- A function.
- Not a function since the element \(b\) is related to two output values, \(1\) and \(2\), and the element \(d\) has no output value.
- A function.
- A function.
- Not a function because the element \(c\) has two output values, \(2\) and \(3\), and the element \(a\) has no output value.

### Example 2.

Find the domain and range of the following functions:- The function \(f_1\) assigns to each natural number the product of its digits.
- The function \(f_2\) assigns to each integer its last digit squared.
- The function \(f_3\) assigns to each pair of natural numbers the average value of these numbers.
- The function \(f_4\) is a Boolean function in three variables.

Solution.

- The domain of the function \(f_1\) is the set of natural numbers. The range of \(f_1\) is the set of nonnegative integers. We can write this in the form \[{\text{dom}\left( {{f_1}} \right) = \mathbb{N},\;\;}\kern0pt{\text{rng}\left( {{f_1}} \right) = \mathbb{N} \cup \left\{ 0 \right\}.}\] For example, \[{{f_1}\left( {135} \right) = 1 \times 3 \times 5 = 15;\;\;}\kern0pt{{f_1}\left( {140} \right) = 1 \times 4 \times 0 = 0.}\]
- The domain of the function \(f_2\) is the set of integers, and the range is the set of nonnegative integers: \[{\text{dom}\left( {{f_2}} \right) = \mathbb{Z},\;\;}\kern0pt{\text{rng}\left( {{f_2}} \right) = \mathbb{N} \cup \left\{ 0 \right\}.}\] Examples: \[{{f_2}\left( {-125} \right) = 5^2 = 25;\;\;}\kern0pt{{f_2}\left( {-150} \right) = 0^2 = 0.}\]
- The domain of the function \(f_3\) is the Cartesian Product \(\mathbb{N} \times \mathbb{N}.\) The range of \(f_3\) is the set of rational numbers \(\mathbb{Q}:\) \[{\text{dom}\left( {{f_3}} \right) = \mathbb{N} \times \mathbb{N},\;\;}\kern0pt{\text{rng}\left( {{f_3}} \right) = \mathbb{Q}.}\] Example: \[{{f_3}\left( {10,11} \right) = \frac{10+11}{2} = 10.5}\]
- The domain of the Boolean function \(f_4\) is \({\left\{ {0,1} \right\}^3},\) and the range is the two-element set \(\left\{ {0,1} \right\}.\) So \[{\text{dom}\left( {{f_4}} \right) = {\left\{ {0,1} \right\}^3},\;\;}\kern0pt{\text{rng}\left( {{f_4}} \right) = \left\{ {0,1} \right\}.}\] Examples: \[{{f_4}\left( {0,1,1} \right) = 1,\;\;}\kern0pt{{f_4}\left( {1,1,1} \right) = 0.}\]

### Example 3.

List all functions \(f:\left\{ {a,b,c} \right\} \to \left\{ {0,1} \right\}.\)Solution.

Total there are \(2^3 = 8\) different functions that are listed below:

\[{{f_1} = \left\{ {\left( {a,0} \right),\left( {b,0} \right),\left( {c,0} \right)} \right\},\;\;}\kern0pt{{f_2} = \left\{ {\left( {a,0} \right),\left( {b,0} \right),\left( {c,1} \right)} \right\},\;\;}\kern0pt{{f_3} = \left\{ {\left( {a,0} \right),\left( {b,1} \right),\left( {c,0} \right)} \right\},\;\;}\kern0pt{{f_4} = \left\{ {\left( {a,0} \right),\left( {b,1} \right),\left( {c,1} \right)} \right\},\;\;}\kern0pt{{f_5} = \left\{ {\left( {a,1} \right),\left( {b,0} \right),\left( {c,0} \right)} \right\},\;\;}\kern0pt{{f_6} = \left\{ {\left( {a,1} \right),\left( {b,0} \right),\left( {c,1} \right)} \right\},\;\;}\kern0pt{{f_7} = \left\{ {\left( {a,1} \right),\left( {b,1} \right),\left( {c,0} \right)} \right\},\;\;}\kern0pt{{f_8} = \left\{ {\left( {a,1} \right),\left( {b,1} \right),\left( {c,1} \right)} \right\}.}\]

### Example 4.

List all functions \(g:\left\{ {0,1} \right\} \to \left\{ {a,b,c} \right\}.\)Solution.

The mapping \(g\) between the sets \(\left\{ {0,1} \right\}\) and \(\left\{ {a,b,c} \right\}\) contains \(3^2 = 9\) different functions:

\[{{g_1} = \left\{ {\left( {0,a} \right),\left( {1,a} \right)} \right\},\;\;}\kern0pt{{g_2} = \left\{ {\left( {0,a} \right),\left( {1,b} \right)} \right\},\;\;}\kern0pt{{g_3} = \left\{ {\left( {0,a} \right),\left( {1,c} \right)} \right\},\;\;}\kern0pt{{g_4} = \left\{ {\left( {0,b} \right),\left( {1,a} \right)} \right\},\;\;}\kern0pt{{g_5} = \left\{ {\left( {0,b} \right),\left( {1,b} \right)} \right\},\;\;}\kern0pt{{g_6} = \left\{ {\left( {0,b} \right),\left( {1,c} \right)} \right\},\;\;}\kern0pt{{g_7} = \left\{ {\left( {0,c} \right),\left( {1,a} \right)} \right\},\;\;}\kern0pt{{g_8} = \left\{ {\left( {0,c} \right),\left( {1,b} \right)} \right\},\;\;}\kern0pt{{g_9} = \left\{ {\left( {0,c} \right),\left( {1,c} \right)} \right\}.}\]

### Example 5.

The function \(f : \mathbb{R} \to \mathbb{R}\) is defined by \(f\left( x \right) = 5{x^2} – {x^4}.\) Find all preimages of \(6.\)Solution.

To find the preimages of \(6\) we need to solve the equation

\[f\left( x \right) = 5{x^2} – {x^4} = 6.\]

Let \(u = x^2.\) Then we can write the original equation in terms of \(u:\)

\[{u^2} – 5u + 6 = 0.\]

The roots of the quadratic equation are \({u_1} = 2,\) \({u_2} = 3.\) So we see that either \({x^2} = 2\) or \({x^2} = 3.\) Undo the \(x^2\) by taking the square root:

\[{{x^2} = {u_1} = 2,}\;\; \Rightarrow {{x_{1,2}} = \pm\sqrt 2;}\]

\[{{x^2} = {u_2} = 3,}\;\; \Rightarrow {{x_{3,4}} = \pm\sqrt 3 .}\]

Hence, the set of all preimages of the number \(6\) is given by

\[x \in \left\{ { – \sqrt 3 , – \sqrt 2 ,\sqrt 2 ,\sqrt 3 } \right\}.\]

### Example 6.

The function \(g : \mathbb{Z} \to \mathbb{Z}\) is defined by \(g\left( x \right) = 3{x^2} – {x^4} + 5.\) Find all preimages of \(7.\)Solution.

The value of the function is equal to \(7.\) Hence, the preimages are defined by the biquadratic equation

\[g\left( x \right) = 3{x^2} – {x^4} + 5 = 7.\]

We substitute \(x^2 = t.\) This produces the quadratic equation

\[{t^2} – 3t + 2 = 0,\]

which has solutions \({t_1}= 1\) and \({t_2} = 2.\)

Now, since \(t = x^2,\) we obtain:

\[{{x_1} = – 1,\;\;}\kern0pt{{x_2} = 1,\;\;}\kern0pt{{x_3} = – \sqrt 2 ,\;\;}\kern0pt{{x_4} = \sqrt 2 .}\]

We see that only \({x_1}, {x_2} \in \mathbb{Z}.\) Hence, the set of preimages of \(7\) is given by

\[x \in \left\{ { – 1,1} \right\}.\]

### Example 7.

The function \(f : \mathcal{P}\left(\left\{{a,b,c}\right\}\right) \to \left\{{0,1,2,3}\right\}\) is given by the formula \(f\left( x \right) = \left| x \right|,\) where \(\left| x \right|\) is the cardinality of the set \(x.\) Calculate the average value of the function \(f.\)Solution.

The power set of \(\left\{ {a,b,c} \right\}\) includes \(8\) subsets, which are listed along with their cardinality in the table below.

\[\require{AMSsymbols}{\begin{array}{c|c} \text{Subset} & \text{Cardinality} \\ \hline \varnothing & 0 \\ \left\{ a \right\} & 1 \\ \left\{ b \right\} & 1 \\ \left\{ c \right\} & 1 \\ \left\{ {a,b} \right\} & 2 \\ \left\{ {a,c} \right\} & 2 \\ \left\{ {b,c} \right\} & 2 \\ \left\{ {a,b,c} \right\} & 3 \end{array}}\]

The average value of the function \(f\) is given by

\[{\overline f = \frac{{0 + 1 \cdot 3 + 2 \cdot 3 + 3}}{8} }={ \frac{{12}}{8} }={ 1.5}\]

### Example 8.

The function \(g : \mathcal{P}\left({\mathcal{P}\left(\left\{{a,b,c}\right\}\right)}\right) \to \mathbb{N}\cup 0\) is given by the formula \(g\left( x \right) = \left| x \right|,\) where \(\left| x \right|\) is the cardinality of the set \(x.\) Calculate the maximum value of the function \(g.\)Solution.

The power set \(\mathcal{P}\left( {\left\{ {a,b,c} \right\}} \right)\) consists of \(2^3 = 8\) subsets.

The power set of a set of \(8\) elements has \(2^8\) subsets. The subset with the greatest cardinality is the set itself. Hence, in our case the subset with the greatest cardinality is the power set \(\mathcal{P}\left( {\mathcal{P}\left( {\left\{ {a,b,c} \right\}} \right)} \right).\)

Thus, the maximum value of the function \(g\) is given by

\[{{g_{\max }} = \left| {\mathcal{P}\left( {\mathcal{P}\left( {\left\{ {a,b,c} \right\}} \right)} \right)} \right| }={ {2^{{2^3}}} }={ {2^8} }={ 256.}\]