In this section we present a collection of 20 worked exercises on functions, designed to build a rigorous and gradual understanding of the foundational concepts surrounding the definition of a function, the domain, the codomain, and the image of a function.
The exercises are arranged in order of increasing difficulty and accompanied by a complete step-by-step solution, with detailed explanations and particular attention to the underlying theoretical reasoning.
In particular, we will learn to:
- determine whether a given correspondence actually defines a function;
- find the domain of a function;
- distinguish clearly between codomain and image;
- study the values actually attained by a function.
Recall that a function is a correspondence that assigns to every element of the domain exactly one element of the codomain.
It will also be essential to distinguish carefully between:
- the domain, that is, the set of elements for which the function is defined;
- the codomain, that is, the set in which the function takes its values;
- the image, that is, the set of values actually attained by the function.
Exercise 1 — level ★☆☆☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=2x-1. \]
Determine:
- the domain;
- the codomain;
- the image of the function.
Answer
\[ \mathrm{Dom}(f)=\mathbb{R} \]
\[ \mathrm{Cod}(f)=\mathbb{R} \]
\[ \mathrm{Im}(f)=\mathbb{R} \]
Solution
The given function is:
\[ f(x)=2x-1. \]
This is a polynomial function of degree one. Polynomial functions are defined for every real number, since no denominators, radicals, or logarithms appear that could impose any restrictions.
Therefore:
\[ \mathrm{Dom}(f)=\mathbb{R}. \]
From the notation:
\[ f:\mathbb{R}\to\mathbb{R} \]
we see that the chosen codomain is:
\[ \mathrm{Cod}(f)=\mathbb{R}. \]
We now determine the image of the function.
Set:
\[ y=2x-1. \]
Solving for \(x\) gives:
\[ x=\frac{y+1}{2}. \]
This expression is defined for every \(y\in\mathbb{R}\), which means every real number is attained by the function.
Therefore:
\[ \mathrm{Im}(f)=\mathbb{R}. \]
Exercise 2 — level ★☆☆☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^2. \]
Determine:
- the domain;
- the codomain;
- the image of the function.
Answer
\[ \mathrm{Dom}(f)=\mathbb{R} \]
\[ \mathrm{Cod}(f)=\mathbb{R} \]
\[ \mathrm{Im}(f)=[0,+\infty) \]
Solution
The function:
\[ f(x)=x^2 \]
is a polynomial function, so it is defined for every real number.
Therefore:
\[ \mathrm{Dom}(f)=\mathbb{R}. \]
From the notation:
\[ f:\mathbb{R}\to\mathbb{R} \]
we see that the codomain is:
\[ \mathrm{Cod}(f)=\mathbb{R}. \]
We now determine the image of the function.
Since the square of any real number is always non-negative, we have:
\[ x^2\ge0 \qquad \forall x\in\mathbb{R}. \]
Moreover:
- the value \(0\) is attained at \(x=0\);
- every positive number \(y>0\) can be written as \[ y=x^2 \] by choosing \[ x=\sqrt{y}. \]
Hence the function attains precisely all non-negative values.
Therefore:
\[ \mathrm{Im}(f)=[0,+\infty). \]
Note in particular that:
\[ \mathrm{Im}(f)\subsetneq\mathrm{Cod}(f), \]
since the function never takes negative values.
Exercise 3 — level ★☆☆☆☆
Determine whether the following correspondence defines a function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=\pm\sqrt{x}. \]
Answer
The given correspondence does not define a function.
Solution
For a correspondence to be a function, it must assign to every element of the domain exactly one element of the codomain.
In our case:
\[ f(x)=\pm\sqrt{x}. \]
The symbol \(\pm\) indicates two possible values:
\[ +\sqrt{x} \qquad \text{and} \qquad -\sqrt{x}. \]
For instance, taking \(x=4\), we get:
\[ f(4)=\pm2. \]
Thus the single element \(4\) is assigned two distinct values:
\[ 2 \qquad \text{and} \qquad -2. \]
Moreover, since the domain is \(\mathbb{R}\), the expression \(\sqrt{x}\) is not defined over the reals for negative values of \(x\). Thus the correspondence also fails to assign a real value to every element of the stated domain.
This violates the definition of a function, since an element of the domain cannot have two different images.
Therefore the given correspondence is not a function.
Exercise 4 — level ★★☆☆☆
Consider the function:
\[ f:[0,+\infty)\to\mathbb{R} \qquad,\qquad f(x)=\sqrt{x}. \]
Determine:
- the domain;
- the codomain;
- the image of the function.
Answer
\[ \mathrm{Dom}(f)=[0,+\infty) \]
\[ \mathrm{Cod}(f)=\mathbb{R} \]
\[ \mathrm{Im}(f)=[0,+\infty) \]
Solution
The given function is:
\[ f(x)=\sqrt{x}. \]
For a square root to be defined over the reals, the radicand must be non-negative.
We therefore require:
\[ x\ge0. \]
Hence:
\[ \mathrm{Dom}(f)=[0,+\infty). \]
From the notation:
\[ f:[0,+\infty)\to\mathbb{R} \]
we see that the chosen codomain is:
\[ \mathrm{Cod}(f)=\mathbb{R}. \]
We now determine the image of the function.
Since the principal square root is always non-negative, we have:
\[ \sqrt{x}\ge0 \qquad \forall x\ge0. \]
So the function takes only non-negative values.
Conversely, every non-negative real number is actually attained.
Indeed, given any:
\[ y\ge0, \]
it suffices to choose:
\[ x=y^2. \]
Then:
\[ f(y^2)=\sqrt{y^2}=y. \]
Hence the function attains precisely all non-negative values.
Therefore:
\[ \mathrm{Im}(f)=[0,+\infty). \]
Exercise 5 — level ★★☆☆☆
Consider the function:
\[ f:\mathbb{R}\setminus\{0\}\to\mathbb{R} \qquad,\qquad f(x)=\frac{1}{x}. \]
Determine:
- the domain;
- the codomain;
- the image of the function.
Answer
\[ \mathrm{Dom}(f)=\mathbb{R}\setminus\{0\} \]
\[ \mathrm{Cod}(f)=\mathbb{R} \]
\[ \mathrm{Im}(f)=\mathbb{R}\setminus\{0\} \]
Solution
The given function is:
\[ f(x)=\frac{1}{x}. \]
The denominator of a fraction cannot be zero.
We therefore require:
\[ x\neq0. \]
Hence:
\[ \mathrm{Dom}(f)=\mathbb{R}\setminus\{0\}. \]
From the notation:
\[ f:\mathbb{R}\setminus\{0\}\to\mathbb{R} \]
we see that the chosen codomain is:
\[ \mathrm{Cod}(f)=\mathbb{R}. \]
We now study the image.
The function:
\[ f(x)=\frac{1}{x} \]
can never equal \(0\).
Indeed, the equation:
\[ \frac{1}{x}=0 \]
has no real solutions, since a fraction with a non-zero numerator cannot equal zero.
We now show that every nonzero real number is actually attained.
Let:
\[ y\in\mathbb{R}\setminus\{0\}. \]
We seek a real number \(x\neq0\) such that:
\[ \frac{1}{x}=y. \]
Solving for \(x\) gives:
\[ x=\frac{1}{y}. \]
Since \(y\neq0\), the value \(\dfrac{1}{y}\) is well defined and belongs to the domain.
Therefore every nonzero real number belongs to the image.
Hence:
\[ \mathrm{Im}(f)=\mathbb{R}\setminus\{0\}. \]
Exercise 6 — level ★★☆☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^3. \]
Determine whether the function is injective.
Answer
The function is injective.
Solution
A function is injective if distinct elements of the domain have distinct images.
Equivalently, we verify the implication:
\[ f(x_1)=f(x_2) \implies x_1=x_2. \]
Suppose:
\[ f(x_1)=f(x_2). \]
Since \(f(x)=x^3\), this gives:
\[ x_1^3=x_2^3. \]
Taking the cube root of both sides:
\[ x_1=x_2. \]
We have thus shown that:
\[ f(x_1)=f(x_2) \implies x_1=x_2. \]
Therefore the function is injective.
Exercise 7 — level ★★☆☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^2. \]
Determine whether the function is injective.
Answer
The function is not injective.
Solution
To show that a function is not injective, it suffices to exhibit two distinct elements of the domain that share the same image.
Consider:
\[ x_1=2 \qquad \text{and} \qquad x_2=-2. \]
Clearly:
\[ 2\neq-2. \]
Yet:
\[ f(2)=2^2=4 \]
and:
\[ f(-2)=(-2)^2=4. \]
So:
\[ f(2)=f(-2), \]
even though \(2\neq-2\).
We have found two distinct elements of the domain with the same image.
Therefore the function is not injective.
Exercise 8 — level ★★☆☆☆
Consider the function:
\[ f:[0,+\infty)\to\mathbb{R} \qquad,\qquad f(x)=x^2. \]
Determine whether the function is injective.
Answer
The function is injective.
Solution
The rule of the function is the same as in the previous exercise:
\[ f(x)=x^2. \]
However, the domain has changed.
The function is now defined only on:
\[ [0,+\infty). \]
We verify injectivity.
Suppose:
\[ f(x_1)=f(x_2). \]
Then:
\[ x_1^2=x_2^2. \]
From this equality it follows that:
\[ x_1=x_2 \qquad \text{or} \qquad x_1=-x_2. \]
However, both \(x_1\) and \(x_2\) belong to the interval \([0,+\infty)\), so they are both non-negative.
Two non-negative numbers with equal squares must be equal.
Therefore:
\[ x_1=x_2. \]
We have shown that:
\[ f(x_1)=f(x_2) \implies x_1=x_2. \]
Therefore the function is injective.
Exercise 9 — level ★★☆☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^2+1. \]
Determine whether the function is surjective.
Answer
The function is not surjective.
Solution
A function is surjective when every element of the codomain is the image of at least one element of the domain.
Here the codomain is \(\mathbb{R}\).
We study the values attained by:
\[ f(x)=x^2+1. \]
Since:
\[ x^2\ge0 \qquad \forall x\in\mathbb{R}, \]
it follows that:
\[ x^2+1\ge1. \]
So the function only takes values greater than or equal to \(1\).
For example, \(0\) belongs to the codomain \(\mathbb{R}\), but is never attained by the function.
Indeed, the equation:
\[ x^2+1=0 \]
is equivalent to:
\[ x^2=-1, \]
which has no real solutions.
There exists at least one element of the codomain that is not the image of any element of the domain.
Therefore the function is not surjective.
Exercise 10 — level ★★☆☆☆
Consider the function:
\[ f:\mathbb{R}\to[1,+\infty) \qquad,\qquad f(x)=x^2+1. \]
Determine whether the function is surjective.
Answer
The function is surjective.
Solution
The rule of the function is:
\[ f(x)=x^2+1. \]
Compared with the previous exercise, the codomain has changed.
We now have:
\[ f:\mathbb{R}\to[1,+\infty). \]
To verify surjectivity, we must show that every element of the codomain \([1,+\infty)\) is attained by the function.
Let:
\[ y\in[1,+\infty). \]
We seek a real number \(x\) such that:
\[ f(x)=y, \]
that is:
\[ x^2+1=y. \]
Subtracting \(1\) from both sides:
\[ x^2=y-1. \]
Since \(y\in[1,+\infty)\), we have:
\[ y-1\ge0. \]
We may therefore choose:
\[ x=\sqrt{y-1}. \]
This value belongs to \(\mathbb{R}\), i.e. to the domain of the function.
Moreover:
\[ f(\sqrt{y-1}) = (\sqrt{y-1})^2+1 = y-1+1 = y. \]
We have shown that every element of the codomain is the image of at least one element of the domain.
Therefore the function is surjective.
Exercise 11 — level ★★★☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=2x+3. \]
Determine whether the function is bijective.
Answer
The function is bijective.
Solution
A function is bijective if it is both injective and surjective.
We first verify injectivity.
Suppose:
\[ f(x_1)=f(x_2). \]
Then:
\[ 2x_1+3=2x_2+3. \]
Subtracting \(3\) from both sides:
\[ 2x_1=2x_2. \]
Dividing by \(2\):
\[ x_1=x_2. \]
The function is therefore injective.
We now verify surjectivity.
Let:
\[ y\in\mathbb{R}. \]
We seek \(x\in\mathbb{R}\) such that:
\[ 2x+3=y. \]
Solving:
\[ x=\frac{y-3}{2}. \]
This value is real for every \(y\in\mathbb{R}\).
Hence the function is surjective.
Being both injective and surjective, the function is bijective.
Exercise 12 — level ★★★☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^3. \]
Determine whether the function is bijective.
Answer
The function is bijective.
Solution
A function is bijective if it is simultaneously:
- injective;
- surjective.
We first verify injectivity.
Suppose:
\[ f(x_1)=f(x_2). \]
Then:
\[ x_1^3=x_2^3. \]
Taking the cube root of both sides:
\[ x_1=x_2. \]
The function is therefore injective.
We now verify surjectivity.
Let:
\[ y\in\mathbb{R}. \]
We seek a real number \(x\) such that:
\[ x^3=y. \]
It suffices to take:
\[ x=\sqrt[3]{y}. \]
Indeed:
\[ \left(\sqrt[3]{y}\right)^3=y. \]
Every real number is therefore attained by the function.
The function is surjective.
Being both injective and surjective, the function is bijective.
Exercise 13 — level ★★★☆☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^2. \]
Determine whether the function is bijective.
Answer
The function is not bijective.
Solution
A function is bijective if it is both injective and surjective.
We examine each property in turn.
The function \(f(x)=x^2\) is not injective.
Indeed:
\[ f(2)=4 \]
and:
\[ f(-2)=4. \]
So:
\[ f(2)=f(-2), \]
even though \(2\neq-2\).
The function is therefore not injective.
It is also not surjective onto \(\mathbb{R}\).
Indeed, since:
\[ x^2\ge0 \qquad \forall x\in\mathbb{R}, \]
the function never takes negative values.
For example:
\[ -1\in\mathbb{R} \]
is not the image of any element of the domain.
The function is therefore not surjective.
Since it is neither injective nor surjective, the function is not bijective.
Exercise 14 — level ★★★☆☆
Consider the function:
\[ f:(0,+\infty)\to\mathbb{R} \qquad,\qquad f(x)=\ln(x). \]
Determine whether the function is bijective.
Answer
The function is bijective.
Solution
We first study injectivity.
The natural logarithm is strictly increasing on:
\[ (0,+\infty). \]
A strictly increasing function always assigns distinct images to distinct elements of the domain.
The function is therefore injective.
We now verify surjectivity.
Let:
\[ y\in\mathbb{R}. \]
We seek a positive real number \(x\) such that:
\[ \ln(x)=y. \]
Exponentiating both sides:
\[ x=e^y. \]
Since:
\[ e^y>0 \qquad \forall y\in\mathbb{R}, \]
the value found belongs to the domain \((0,+\infty)\).
Moreover:
\[ \ln(e^y)=y. \]
Every real number therefore belongs to the image of the function.
The function is surjective.
Being both injective and surjective, the function is bijective.
Exercise 15 — level ★★★★☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=2x-5. \]
Find the inverse function.
Answer
\[ f^{-1}(x)=\frac{x+5}{2}. \]
Solution
To find the inverse function, we set:
\[ y=2x-5. \]
The goal is to express \(x\) in terms of \(y\).
Adding \(5\) to both sides:
\[ y+5=2x. \]
Dividing by \(2\):
\[ x=\frac{y+5}{2}. \]
Swapping the roles of the variables, we obtain:
\[ f^{-1}(x)=\frac{x+5}{2}. \]
We verify the result by computing \(f(f^{-1}(x))\):
\[ f\left(\frac{x+5}{2}\right) = 2\cdot\frac{x+5}{2}-5. \]
Simplifying:
\[ x+5-5=x. \]
Therefore:
\[ f(f^{-1}(x))=x. \]
The inverse function found is correct.
Exercise 16 — level ★★★★☆
Consider the function:
\[ f:[0,+\infty)\to[0,+\infty) \qquad,\qquad f(x)=x^2. \]
Find the inverse function.
Answer
\[ f^{-1}(x)=\sqrt{x}. \]
Solution
The function:
\[ f(x)=x^2 \]
is considered with domain:
\[ [0,+\infty) \]
and codomain:
\[ [0,+\infty). \]
This choice of domain is crucial: on all of \(\mathbb{R}\), the function \(x^2\) is not injective; restricted to \([0,+\infty)\), however, it becomes injective.
To find the inverse, we set:
\[ y=x^2. \]
Solving for \(x\) formally gives:
\[ x=\pm\sqrt{y}. \]
However, since the domain of the original function is \([0,+\infty)\), we must take only the non-negative value.
Therefore:
\[ x=\sqrt{y}. \]
Swapping the roles of the variables:
\[ f^{-1}(x)=\sqrt{x}. \]
Verification:
\[ f(f^{-1}(x))=f(\sqrt{x})=(\sqrt{x})^2=x, \qquad x\in[0,+\infty). \]
The inverse function is therefore correct.
Exercise 17 — level ★★★★☆
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=|x|. \]
Determine whether the function is injective and, if not, find a restriction of the domain that makes it injective.
Answer
The function is not injective on \(\mathbb{R}\).
One possible restriction of the domain is:
\[ [0,+\infty). \]
Solution
The function is the absolute value:
\[ f(x)=|x|. \]
To check whether it is injective on \(\mathbb{R}\), we look for two distinct elements of the domain with the same image.
Consider:
\[ x_1=2 \qquad \text{and} \qquad x_2=-2. \]
We have \(2\neq-2\).
Yet:
\[ f(2)=|2|=2 \]
and:
\[ f(-2)=|-2|=2. \]
So:
\[ f(2)=f(-2), \]
even though \(2\neq-2\).
The function is therefore not injective on all of \(\mathbb{R}\).
To make it injective, we can restrict the domain to:
\[ [0,+\infty). \]
On this interval we have:
\[ |x|=x, \]
so the function reduces to:
\[ f(x)=x, \]
which is clearly injective.
Exercise 18 — level ★★★★☆
Consider the function:
\[ f:\left(-\frac{\pi}{2},\frac{\pi}{2}\right)\to\mathbb{R} \qquad,\qquad f(x)=\tan(x). \]
Determine whether the function is bijective.
Answer
The function is bijective.
Solution
To establish bijectivity we must verify that the function is both injective and surjective.
We first study injectivity.
On the interval:
\[ \left(-\frac{\pi}{2},\frac{\pi}{2}\right) \]
the tangent function is strictly increasing.
A strictly increasing function is injective, since distinct elements of the domain yield distinct images.
Hence \(f\) is injective.
We now verify surjectivity.
The codomain of the function is \(\mathbb{R}\), so we must show that every real number is attained.
It is known that:
\[ \lim_{x\to-\frac{\pi}{2}^{+}}\tan(x)=-\infty \]
and:
\[ \lim_{x\to\frac{\pi}{2}^{-}}\tan(x)=+\infty. \]
Moreover, the tangent function is continuous on:
\[ \left(-\frac{\pi}{2},\frac{\pi}{2}\right). \]
Therefore, as \(x\) ranges over \(\left(-\frac{\pi}{2},\frac{\pi}{2}\right)\), the function \(\tan(x)\) takes every real value.
Consequently:
\[ \mathrm{Im}(f)=\mathbb{R}. \]
Since the image coincides with the codomain, the function is surjective.
Being both injective and surjective, the function is bijective.
Exercise 19 — level ★★★★★
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^3-1. \]
Determine whether the function is invertible and, if so, find its inverse.
Answer
The function is invertible.
Its inverse is:
\[ f^{-1}(x)=\sqrt[3]{x+1}. \]
Solution
A function is invertible if and only if it is bijective, that is, both injective and surjective.
We study the function:
\[ f(x)=x^3-1. \]
The function \(x^3\) is strictly increasing on all of \(\mathbb{R}\). Subtracting \(1\) shifts the graph downward but does not alter the monotonicity.
Therefore \(f(x)=x^3-1\) is strictly increasing on \(\mathbb{R}\), and hence injective.
We now verify surjectivity.
Let:
\[ y\in\mathbb{R}. \]
We seek a real number \(x\) such that:
\[ x^3-1=y. \]
Adding \(1\) to both sides:
\[ x^3=y+1. \]
Taking the cube root:
\[ x=\sqrt[3]{y+1}. \]
This value exists and is real for every \(y\in\mathbb{R}\).
Hence every real number \(y\) is the image of at least one element of the domain.
The function is therefore surjective.
Being both injective and surjective, the function is bijective and hence invertible.
We now find the inverse.
Starting from:
\[ y=x^3-1, \]
we solve for \(x\):
\[ y+1=x^3 \]
\[ x=\sqrt[3]{y+1}. \]
Swapping the roles of the variables:
\[ f^{-1}(x)=\sqrt[3]{x+1}. \]
Exercise 20 — level ★★★★★
Consider the function:
\[ f:\mathbb{R}\to\mathbb{R} \qquad,\qquad f(x)=x^2-4x+3. \]
Determine whether the function is invertible on \(\mathbb{R}\). If not, find a restriction of the domain that makes it invertible.
Answer
The function is not invertible on \(\mathbb{R}\).
One possible restriction of the domain that makes it invertible is:
\[ [2,+\infty). \]
Solution
The given function is:
\[ f(x)=x^2-4x+3. \]
This is a quadratic function. Quadratic functions defined on all of \(\mathbb{R}\) are never injective, since their graph is a parabola.
We verify explicitly that this function is not injective.
Compute:
\[ f(1)=1^2-4\cdot1+3=1-4+3=0. \]
Also:
\[ f(3)=3^2-4\cdot3+3=9-12+3=0. \]
So:
\[ f(1)=f(3), \]
yet \(1\neq3\).
We have found two distinct elements of the domain with the same image.
Therefore the function is not injective and hence not invertible on all of \(\mathbb{R}\).
We now find a restriction of the domain that makes it invertible.
Completing the square:
\[ x^2-4x+3=(x-2)^2-1. \]
From this form we see that the vertex of the parabola has \(x\)-coordinate:
\[ x=2. \]
The function is decreasing on \((-\infty, 2]\) and increasing on \([2,+\infty)\).
Restricting the domain to:
\[ [2,+\infty), \]
the function becomes strictly increasing and therefore injective.
On this interval the image is:
\[ [-1,+\infty). \]
Hence the function:
\[ f:[2,+\infty)\to[-1,+\infty), \qquad f(x)=x^2-4x+3 \]
is bijective and therefore invertible.