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 functionf 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:
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.
Note Function: LaTeX
The LaTeX command f:\mathcal{A} \to \mathcal{B} is for the following function notation f:\mathcal{A} \to \mathcal{B}.
Note Function: Python
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.
Note Domain, Codomain and Range: Concept Check
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:
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.
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.
Note Injective, Surjective and Bijective Functions: Concept Check
Given the following function f:\mathcal{A} \to \mathcal{B} with:
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}
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: