Functions


15 min.   |   Beginner   |   (Hammack 2013)

Function

Functions are foundational since they represent the mathematical description of relationships between two (or more) quantities.

Suppose \mathcal{A} and \mathcal{B} are sets.

A function f from \mathcal{A} to \mathcal{B} (denoted as f:\mathcal{A} \to \mathcal{B}) is a relation f \subseteq \mathcal{A} \times \mathcal{B} from \mathcal{A} to \mathcal{B}, satisfying the property that for each a \in \mathcal{A} the relation f contains exactly one ordered pair of form (a,b). The statement (a,b) \in f is abbreviated f(a) = b.

CautionFunction: Example

Suppose the function of a parabola

f(x) = x^2 \tag{1}

from \mathbb{R} to \mathbb{R}, denoted as f:\mathbb{R} \to \mathbb{R}

The relationship \mathcal{R} between the input and output of the function f can also be described in set-builder notation:

\begin{align*} \mathcal{R} &= \{(x,x^2):x \in \mathbb{R}\} \\ &\subseteq \mathbb{R} \times \mathbb{R} \end{align*}

Suppose we have the following function f:\mathcal{A} \to \mathcal{B} defined as follows:

\mathcal{A} = \{ 0, 1, 2 \}, \ \mathcal{B} = \{ 2, 3, 4, 5 \}, \ f = \{ (0, 2), (1, 2), (2, 3) \}

Find f(2).

To find f(2), we need to look at the pairs in the function definition where the first element is 2. From the given function f, we see that the only pair with 2 as the first element is (2, 3). Therefore, f(2) = 3.

The LaTeX command f:\mathcal{A} \to \mathcal{B} is for the following function notation f:\mathcal{A} \to \mathcal{B}.

In Python, you can define functions def func(args) to represent relationships from one set of inputs to a set of outputs.

Domain, Codomain and Range

Suppose a function f:\mathcal{A} \to \mathcal{B}.

The set \mathcal{A} is called the domain of f, or the set of all possible input values for the function.

The set \mathcal{B} is called the codomain of f, or the set of all possible “target” values for the outputs.

The range of f is the set \{f(a): a \in \mathcal{A} \} = \{b: (a,b) \in f \}, or the set of all possible “output values” for the function.

CautionDomain, Codomain and Range: Example 1

Suppose the function:

f(x) = x^2 - 4; \tag{2}

from \mathbb{Z} to \mathbb{R}, denoted as f:\mathbb{Z} \to \mathbb{R}

Its domain is the set of integers \mathbb{Z}, its codomain is the set of real numbers \mathbb{R}, and its range are the set of values that are outputs in the codomain, such as f(1) = -3 or the ordered pair (1,-3) \in f.

Also, notice that by subtracting 4 units to f(x) in equation (1), we vertically shift the graph to the down by 4 units.

CautionDomain, Codomain and Range: Example 2

Suppose the function:

f(x) = (x - 4)^2; \tag{3}

from \mathbb{Z} to \mathbb{R}, denoted as f:\mathbb{Z} \to \mathbb{R}

Its domain is the set of integers \mathbb{Z}, its codomain is the set of real numbers \mathbb{R}, and its range are the set of values that are outputs in the codomain, such as f(5) = 1 or the ordered pair (5,1) \in f.

Also, notice that by subtracting 4 units to x in equation (1), we horizontally shift the graph to the right by 4 units.

Suppose we have the following function f:\mathbb{N} \to \mathbb{Z}. What is the domain, codomain and range of this function?

The correct answer is domain: \mathbb{N}, codomain: \mathbb{Z}, range: \mathbb{N}. The function f is defined as:

f:\underbrace{\mathbb{N}}_{\text{domain}} \to \underbrace{\mathbb{Z}}_{\text{codomain}};

The range is the set of all actual outputs of the function. Since f maps natural numbers to natural numbers, the range is \mathbb{N}.

Equal Functions

Two functions f:\mathcal{A} \to \mathcal{B} and g:\mathcal{A} \to \mathcal{D} are equal if f=g as sets. Equivalently, f=g if and only if f(x) = g(x) for every x \in \mathcal{A}.

CautionEqual Functions: Example

Suppose the function:

g(x) = x^2 - 4;

from \mathbb{Z} to \mathbb{Z}, denoted as g:\mathbb{Z} \to \mathbb{Z}

The function g is the same as the function f in equation (2), since they produce the same output x^2 - 4 for every integer input x.

Suppose the following functions are defined:

f:\mathbb{N} \to \mathbb{Z}, \ \ g:\mathbb{R} \to \mathbb{Z}

Is f=g?

The answer is False, since the domains of f and g are different. Two functions are equal if they have the same domain, codomain, and output for every input in the domain.

Injective, Surjective and Bijective Functions

Suppose a function f:\mathcal{A} \to \mathcal{B} is:

Injective (one-to-one) if for all a, a^{'} \in \mathcal{A}, a \neq a^{'} implies f(a) \neq f(a^{'}).

Surjective (onto \mathcal{B}) if for every b \in \mathcal{B} there is an a \in \mathcal{A} with f(a) = b.

Bijective if f is both injective or surjective.

CautionInjective, Surjective and Bijective Functions: Example 1

Suppose the function f:\mathbb{R} \to \mathbb{R} defined as:

f(x) = x

The function is injective and surjective (bijective) since each input maps to a unique output and every element of the codomain is achieved.

CautionInjective, Surjective and Bijective Functions: Example 2

Suppose the function f:\mathbb{N} \to \mathbb{R} defined as:

f(x) = x

The function is injective and not surjective given that every input and output pair is one-to-one but not every input maps onto the space of \mathbb{R}.

This can be quickly assessed using The Pigeonhole Principle which states that a function is not surjective, or maps onto the codomain, for any function f:\mathcal{A} \to \mathcal{B} if \lvert \mathcal{A} \rvert < \lvert \mathcal{B} \rvert.

CautionInjective, Surjective and Bijective Functions: Example 3

Suppose the function f:\mathbb{R} \to \mathbb{N} defined as:

f(x) = \lvert x \rvert

The function is surjective and not injective since there exists two inputs for one output (e.g., f(-1) = f(1) = 1), and all elements of \mathbb{N} are outputs of f.

This can be quickly assesed using The Pigenhole Principle which states that a function is not injective, or one-to-one, for any function f:\mathcal{A} \to \mathcal{B} if \lvert \mathcal{A} \rvert > \lvert \mathcal{B} \rvert.

CautionInjective, Surjective and Bijective Functions: Example 4

The function f defined above in equation (3) is neither injective nor surjective since there exists two inputs for one output (e.g., f(3) = f(5) = 1), and not all elements of \mathbb{R} are outputs of f.

Given the following function f:\mathcal{A} \to \mathcal{B} with:

\mathcal{A} = \{1, 2, 3\}, \ \ \mathcal{B} = \{a, b, c, d\}

Which of the following sets represents a function f that is neither injective nor surjective?

The correct answer is the second option f = \{(1, a), (2, a), (3, b)\} because it is not injective (both 1 and 2 map to ‘a’) and not surjective (elements ‘c’ and ‘d’ in \mathcal{B} are not mapped to by any element in \mathcal{A}).

Composite Functions

Suppose f:\mathcal{A} \to \mathcal{B} and g:\mathcal{B} \to \mathcal{C} are functions where the codomain of f equals the domain of g.

The composition of f with g is another function, denoted as g \circ f and defined as follows:

If x \in \mathcal{A}, then g \circ f(x)= g(f(x)).

Therefore g \circ f sends elements of \mathcal{A} to elements of \mathcal{C}, so g \circ f(x):\mathcal{A} \to \mathcal{C}

CautionComposite Functions: Example

Suppose the following sets:

\mathcal{A} = \{a,b,c\}, \ \ \mathcal{B} = \{0,1\}, \ \ \mathcal{C} = \{1,2,3\};

and let the functions f:\mathcal{A} \to \mathcal{B} and g:\mathcal{B} \to \mathcal{C}:

f = \{(a,0),(b,1),(c,0)\}, \ \ g = \{(0,3),(1,1)\}

Their composite g \circ f is the set:

g \circ f = \{(a,3),(b,1),(c,3)\}

Suppose the following functions:

f: \mathbb{R} \to \mathbb{Z}, \ \ g: \mathbb{Z} \to \mathbb{N};

What is the composite function g \circ f?

The correct answer is g \circ f: \mathbb{R} \to \mathbb{N} because the output of f (which is in \mathbb{Z}) becomes the input of g (which takes inputs from \mathbb{Z}), and the output of g is in \mathbb{N}. Therefore, the composite function g \circ f takes inputs from \mathbb{R} and produces outputs in \mathbb{N}.

Inverse Functions

The identity function on \mathcal{A} is the function i_{\mathcal{A}}:\mathcal{A} \to \mathcal{A} defined as i_{\mathcal{A}}(x) = x for every x \in \mathcal{A}.

For a relationship, denoted by the set \mathcal{R} from \mathcal{A} to \mathcal{B}, the inverse relationship is the set \mathcal{R}^{-1} from \mathcal{B} to \mathcal{A} defined as:

\mathcal{R}^{-1} = \{(y,x): (x,y) \in \mathcal{R} \};

or the set obtained by exchanging the positions of every ordered pair in \mathcal{R}

If the function f: \mathcal{A} \to \mathcal{B} is bijective then its inverse is the function f^{-1}: \mathcal{B} \to \mathcal{A}, which result in:

f \circ f^{-1} = i_{\mathcal{A}} \ \ \text{and} \ \ f^{-1} \circ f = i_{\mathcal{B}}

CautionInverse Functions: Example

Suppose the function:

f:\mathbb{R} \to \mathbb{R}, \quad f(x) = x^3 + 1.

Since the function is bijective, we can find its inverse by following these steps:

  1. Write the expression in terms of a variable y:

y = x^3 + 1 \quad \Rightarrow \quad x = y^3 + 1

  1. Solve for y:

y = \sqrt[3]{x - 1}

  1. Replace the y variable with x to get the inverse:

f^{-1}(x) = \sqrt[3]{x - 1}

This can be verified by checking the composition f^{-1} \circ f:

\begin{align*} f^{-1}(f(x)) &= \sqrt[3]{(x^3 + 1) - 1} \\ &= \sqrt[3]{x^3} \\ &= x \end{align*}

The function f:\mathbb{Z} \times \mathbb{Z} \to \mathbb{Z} \times \mathbb{Z} defined by f(a,b) = (a + b, a + 2b) is bijective. Find f^{-1}(a,b)

The correct answer is f^{-1}(a,b) = (2a - b, b - a). This can be found by solving the following system of equations:

\begin{align*} x + y &= a \\ x + 2y &= b \end{align*}

Subtracting the first equation from the second gives:

\begin{align*} x + y &= a \\ y &= b - a \end{align*}

Substituting this value of y into the first equation gives:

\begin{align*} x &= 2a - b \\ y &= b - a \end{align*}

Thus, the inverse function is given by:

f^{-1}(a,b) = (2a - b, b - a)

You can confirm by checking the composite function f(f^{-1}(a,b)) = (a,b).

\begin{align*} f(f^{-1}(a,b)) &= f(2a - b, b - a) \\ &= ((2a - b) + (b - a), (2a - b) + 2(b - a)) \\ &= (a, b) \end{align*}

Functions: Exercises

Tip Functions: Exercise 1

Suppose the following set:

f = \{(x^2,x): x \in \mathbb{R} \}

Is f a function from \mathbb{R} \to \mathbb{R}?

Tip Functions: Exercise 2

Suppose the following set:

f = \{(x^3,x): x \in \mathbb{R} \}

Is f a function from \mathbb{R} \to \mathbb{R}?

Tip Functions: Exercise 3-5

Given the following functions f:\mathbb{Z} \to \mathbb{N} and g:\mathbb{N} \to \mathbb{R} defined as:

f(x) = \lvert x \rvert, \ \ g(x) = x^2

  1. State the domain, codomain and range of f.
  2. State the domain, codomain and range of g.
  3. Is f = g?
Tip Functions: Exercises 6-9

Suppose the following set:

\mathcal{A} = \{1,2,3\}, \ \ \mathcal{B} = \{4,5\};

Given the following functions defined as:

f:\mathcal{A} \to \mathcal{A}, \ \ g:\mathcal{A} \to \mathcal{B}, \\ h:\mathcal{B} \to \mathcal{A};

list the functions that can be:

  1. Injective and Surjective (Bijective).
  2. Injective but not surjective.
  3. Surjective but not Injective.
  4. Neither injective or surjective.
Tip Functions: Exercises 10-11

Suppose the following set:

\mathcal{A} = \{1,2,3\};

consider the following functions defined as f:\mathcal{A} \to \mathcal{A} and g:\mathcal{A} \to \mathcal{A} with

f = \{(1,2),(2,2),(3,1)\}, \ \ g = \{(1,3),(2,1),(3,2)\}

  1. Find g \circ f
  2. Find f \circ g
Tip Functions: Exercises 12

The function f:\mathbb{R}^2 \to \mathbb{R}^2 defined by f(x,y) = ((x^2 + 1)y, x^3) is bijective. Find f^{-1}(x,y)