A function is a correspondence between two sets that assigns to each element of the first set (the domain) exactly one element of the second set (the codomain).
In this article we will study the formal definition of a function, the meaning of domain, codomain and image, and the fundamental properties of injectivity, surjectivity, bijectivity, the inverse function, and restriction.
Contents
- Definition of a Function
- Domain, Codomain and Image
- Injective Functions
- Exercises on Injective Functions
- Surjective Functions
- Exercises on Surjective Functions
- Bijective Functions
- Inverse Function
- Exercises on Bijective Functions
- Restriction of a Function
- Exercises on Restrictions
Definition of a Function
A function (or map) is a rule that assigns to each element of a set \(X\) exactly one element of a set \(Y\).
We write:
\[ f:X\to Y, \]
where \(X\) is the domain and \(Y\) is the codomain.
Given \(x\in X\), the element assigned to \(x\) by \(f\) is denoted \(f(x)\) and is called the image of \(x\) under \(f\).
The notation:
\[ x\mapsto f(x) \]
makes the assignment rule explicit.
The defining property of a function is the uniqueness of the image: every element of the domain must be assigned to exactly one element of the codomain.
For example:
\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2 \]
defines a function, since every real number is assigned a unique real number.
Domain, Codomain and Image
Given a function:
\[ f:X\to Y, \]
the set \(X\) is called the domain and \(Y\) the codomain. The set of values actually attained by \(f\) is called the image of \(f\).
In symbols:
\[ \operatorname{Im}(f)=f(X)=\{y\in Y \mid \exists\, x\in X:\ f(x)=y\}. \]
We always have:
\[ \operatorname{Im}(f)\subseteq Y, \]
that is, the image is a subset of the codomain.
Consider:
\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2. \]
Here both the domain and the codomain are \(\mathbb{R}\), whereas:
\[ \operatorname{Im}(f)=[0,+\infty), \]
since the square of a real number is never negative.
Injective Functions
A function:
\[ f:X\to Y \]
is said to be injective (or one-to-one) if distinct elements of the domain have distinct images:
\[ x_1\neq x_2 \quad \Longrightarrow \quad f(x_1)\neq f(x_2). \]
Equivalently:
\[ f(x_1)=f(x_2) \quad \Longrightarrow \quad x_1=x_2. \]
Intuitively, an injective function never โcollapsesโ two distinct elements of the domain to the same value.
Consider:
\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=2x+1. \]
Suppose:
\[ f(x_1)=f(x_2). \]
Then:
\[ 2x_1+1=2x_2+1 \quad \Longrightarrow \quad x_1=x_2. \]
Hence \(f\) is injective.
On the other hand, the function:
\[ f(x)=x^2 \]
is not injective, since:
\[ f(1)=f(-1)=1 \]
yet:
\[ 1\neq -1. \]
Geometrically, a function is injective if and only if every horizontal line meets its graph in at most one point. This criterion is known as the horizontal line test.
Exercises on Injective Functions
Exercise 1. Determine whether:
\[ f(x)=2x+3 \]
is injective on \(\mathbb{R}\).
Solution. Suppose:
\[ f(x_1)=f(x_2). \]
Then:
\[ 2x_1+3=2x_2+3 \quad \Longrightarrow \quad x_1=x_2. \]
Therefore \(f\) is injective.
Exercise 2. Determine whether:
\[ f(x)=x^2 \]
is injective on \(\mathbb{R}\).
Solution. We have:
\[ f(2)=4 \qquad \text{and} \qquad f(-2)=4, \]
yet:
\[ 2\neq -2. \]
Therefore \(f\) is not injective.
Surjective Functions
A function:
\[ f:X\to Y \]
is said to be surjective (or onto) if every element of the codomain is the image of at least one element of the domain:
\[ \forall\, y\in Y, \quad \exists\, x\in X \quad \text{such that} \quad f(x)=y. \]
Equivalently:
\[ \operatorname{Im}(f)=Y. \]
Intuitively, a surjective function โcoversโ the entire codomain.
Consider:
\[ f(x)=2x+1. \]
Let:
\[ y\in\mathbb{R}. \]
Solving:
\[ 2x+1=y \]
gives:
\[ x=\frac{y-1}{2}\in\mathbb{R}. \]
Hence \(f\) is surjective.
On the other hand, the function:
\[ f(x)=x^2 \]
is not surjective from \(\mathbb{R}\) to \(\mathbb{R}\), since:
\[ x^2\ge0 \qquad \forall\, x\in\mathbb{R}. \]
Exercises on Surjective Functions
Exercise 1. Determine whether:
\[ f(x)=2x+3 \]
is surjective from \(\mathbb{R}\) to \(\mathbb{R}\).
Solution. Let:
\[ y\in\mathbb{R}. \]
Solving:
\[ 2x+3=y \]
gives:
\[ x=\frac{y-3}{2}\in\mathbb{R}. \]
Hence \(f\) is surjective.
Exercise 2. Determine whether:
\[ f(x)=x^2 \]
is surjective from \(\mathbb{R}\) to \(\mathbb{R}\).
Solution. There is no:
\[ x\in\mathbb{R} \]
satisfying:
\[ x^2=-1. \]
Therefore \(f\) is not surjective.
Bijective Functions
A function:
\[ f:X\to Y \]
is said to be bijective (or a bijection) if it is both injective and surjective.
In a bijective function, every element of the codomain is the image of exactly one element of the domain.
Bijective functions therefore establish a perfect one-to-one correspondence between domain and codomain, and they are precisely the functions that admit an inverse.
The function:
\[ f(x)=2x+1 \]
is bijective from \(\mathbb{R}\) to \(\mathbb{R}\), whereas:
\[ f(x)=x^2 \]
is not bijective from \(\mathbb{R}\) to \(\mathbb{R}\), as it is neither injective nor surjective.
Inverse Function
Let:
\[ f:X\to Y. \]
A function:
\[ g:Y\to X \]
is called the inverse function of \(f\) if:
\[ g\circ f=\operatorname{Id}_X \qquad \text{and} \qquad f\circ g=\operatorname{Id}_Y. \]
In that case we write:
\[ g=f^{-1}. \]
Explicitly, this means:
\[ f^{-1}(f(x))=x \qquad \forall\, x\in X, \]
and:
\[ f(f^{-1}(y))=y \qquad \forall\, y\in Y. \]
A function admits an inverse if and only if it is bijective.
Left Inverse and Injectivity
Let:
\[ f:X\to Y \]
be an injective function with:
\[ X\neq\varnothing. \]
Then there exists a function:
\[ g:Y\to X \]
such that:
\[ g\circ f=\operatorname{Id}_X. \]
Such a function is called a left inverse of \(f\).
Indeed, for every:
\[ y\in f(X), \]
there exists a unique:
\[ x\in X \]
such that:
\[ f(x)=y. \]
For elements of:
\[ Y\setminus f(X), \]
the value of \(g\) may be defined arbitrarily.
Right Inverse and Surjectivity
Let:
\[ f:X\to Y \]
be a surjective function.
A function:
\[ h:Y\to X \]
satisfying:
\[ f\circ h=\operatorname{Id}_Y \]
is called a right inverse of \(f\).
To construct such a function one must choose, for each:
\[ y\in Y, \]
an element:
\[ x\in X \]
such that:
\[ f(x)=y. \]
In general, the existence of such a choice function for arbitrary families is guaranteed by the Axiom of Choice.
The Bijective Case
If a function is bijective, then it has a unique left inverse and a unique right inverse.
Moreover, these two inverses coincide, and their common value is the inverse function:
\[ f^{-1}:Y\to X. \]
Consider:
\[ f(x)=2x+1. \]
Solving:
\[ y=2x+1 \]
for \(x\) gives:
\[ x=\frac{y-1}{2}. \]
Hence the inverse is:
\[ f^{-1}(y)=\frac{y-1}{2}. \]
Exercises on Bijective Functions
Exercise 1. Determine whether:
\[ f(x)=3x-4 \]
is bijective from \(\mathbb{R}\) to \(\mathbb{R}\).
Solution. The function is both injective and surjective, hence bijective.
Solving:
\[ y=3x-4 \]
gives:
\[ f^{-1}(y)=\frac{y+4}{3}. \]
Exercise 2. Determine whether:
\[ f(x)=x^2 \]
is bijective from:
\[ [0,+\infty) \]
to:
\[ [0,+\infty). \]
Solution. On this interval the function is injective, and every non-negative real number has a non-negative real square root, so the function is surjective. Hence \(f\) is bijective.
Its inverse is:
\[ f^{-1}(y)=\sqrt{y}. \]
Restriction of a Function
The restriction of a function consists of restricting its domain to a subset.
This operation is often useful for turning a function into one that is injective or bijective.
For example:
\[ f(x)=x^2 \]
is not injective on \(\mathbb{R}\), but the restriction:
\[ f:[0,+\infty)\to[0,+\infty), \qquad f(x)=x^2 \]
is bijective.
When one simultaneously restricts the codomain in order to make the function surjective, the operation is more precisely referred to as a corestriction.
Exercises on Restrictions
Exercise 1. Restrict the domain of:
\[ f(x)=x^2 \]
so that the function becomes bijective.
Solution. Consider the restriction:
\[ f:[0,+\infty)\to[0,+\infty), \qquad f(x)=x^2. \]
On this domain the function is both injective and surjective, hence bijective.
Its inverse is:
\[ f^{-1}(y)=\sqrt{y}. \]