6.4: Onto Functions
( \newcommand{\kernel}{\mathrm{null}\,}\)
One-to-one functions focus on the elements in the domain. We do not want any two of them sharing a common image. Onto functions focus on the codomain. We want to know if it contains elements not associated with any element in the domain.
Definition: surjection
A function f:A→B is onto if, for every element b∈B, there exists an element a∈A such that f(a)=b. An onto function is also called a surjection, and we say it is surjective.
Example 6.4.1
The graph of the piecewise-defined functions h:[1,3]→[2,5] defined by
h(x)={3x−1 if 1≤x≤2, −3x+11 if 2<x≤3,
is displayed on the left in Figure 6.4.1. It is clearly onto, because, given any y∈[2,5], we can find at least one x∈[1,3] such that h(x)=y. Likewise, the function k:[1,3]→[2,5] defined by
k(x)={3x−1 if 1≤x≤2, 5 if 2<x≤3,
is also onto. Its graph is displayed on the right of Figure 6.4.1.

exercise 6.4.1
The two functions in Example 6.4.1 are onto but not one-to-one. Construct a one-to-one and onto function f from [1,3] to [2,5].
exercise 6.4.2
Construct a function g:[1,3]→[2,5] that is one-to-one but not onto.
exercise 6.4.3
Find a subset B of R that would make the function s:R→B defined by s(x)=x2 an onto function.
Example 6.4.2
Construct a function g:(5,8)→R that is both one-to-one and onto
Remark
This is a challenging problem. Since the domain is an open interval, a straight line graph does not work, because it will not cover every number in the codomain.
- Solution
-
The solution is based on the observation that the function h:(−π→2,π2)R defined by h(x)=tanx is one-to-one and onto. For this to work in this problem, we need to shift and scale the interval (5,8) to the same size as (−π2,π2).
First, we have to shift the center of the interval (5,8) to the center of the interval (−π2,π2). The midpoint of the interval (5,8) is 5+82=132, and the midpoint of (−π2,π2) is 0. Hence, we need to shift the interval (5,8) to the left 132 units. This means we need to use the transformation x−132. The two endpoints 5 and 8 become −32 and 32, respectively:
x51328x−132−32032
After the transformation x−132, the original interval (5,8) becomes the interval (−32,32). Next, we want to stretch the interval (−32,32) into (−π2,π2). This calls for a scaling factor of π3.
x51328π3(x−132)−π20π2
Putting these transformations together, we conclude that g(x)=tan[π3(x−132)] gives a one-to-one and onto function from (5,8) to R.
exercise 6.4.4
Construct a function h:(2,9)→R that is both one-to-one and onto.
In general, how can we tell if a function f:A→B is onto? The key question is: given an element y in the codomain, is it the image of some element x in the domain? If it is, we must be able to find an element x in the domain such that f(x)=y. Mathematically, if the rule of assignment is in the form of a computation, then we need to solve the equation y=f(x) for x. If we can always express x in terms of y, and if the resulting x-value is in the domain, the function is onto.
Example 6.4.3
Is the function p:R→R defined by p(x)=3x2−4x+5 onto?
- Solution 1
-
Let y=3x2−4x+5, we want to know if we can always express x in terms of y. Rearranging the equation, we find 3x2−4x+(5−y)=0. We want this equation to be solvable over R, that is, we want its solutions to be real. This requires its discriminant to be nonnegative. So we need
(−4)2−4⋅3⋅(5−y)=12y−44≥0.
We have real solutions only when y≥113. This means, when y<113, we cannot find an x-value such that p(x)=y. Therefore, p is not onto.
- Solution 2
-
By completing the square, we find
p(x)=3x2−4x+5=3(x−23)2+113≥113.
Since p(x)≮113, it is clear that p is not onto.
exercise 6.4.5
The function g:R→R is defined as g(x)=3x+11. Prove that it is onto.
Example 6.4.4
Is the function p:R→R defined by
p(x)={4x+1 if x≤3 12x if x>3
p(x)={4x+1 if x≤3 12 if x>3
an onto function?
- Solution
-
The graphs y=4x+1 and y=12x are both increasing. For x≤3, the y-values cover the range (−∞,13), and for x>3, the y-values cover the range (32,∞). Since these two y-ranges overlap, all the y-values are being covered by the images. Therefore, p is onto.
exercise 6.4.6
Determine whether f(x)={3x+1 if x≤2 4x if x>2 is an onto function.
Example 6.4.5
Consider the function g:Z43→Z43 defined by
g(x) \equiv 11x-5 \pmod{43}.\nonumber
Let y = g(x) \equiv 11x-5 \pmod{43},\nonumber
then x \equiv 11^{-1}(y+5) \equiv 4(y+5) \pmod{43}.\nonumber
This shows that g is onto.
exercise \PageIndex{7}\label{he:ontofcn-07}
Show that the function h :{\mathbb{Z}_{23}}\to{\mathbb{Z}_{23}} defined by h(x) \equiv 5x+8 (mod 23) is onto.
Example \PageIndex{6}\label{eg:ontofcn-06}
Is the function {u}:{\mathbb{Z}}\to{\mathbb{Z}} defined by
u(n) = \cases{ 2n & if $n\geq0$ \cr -n & if $n < 0$ \cr} \nonumber
one-to-one? Is it onto?
- Solution
-
Since u(-2)=u(1)=2, the function u is not one-to-one. Since u(n)\geq0 for any n\in\mathbb{Z}, the function u is not onto.
exercise \PageIndex{8}\label{he:ontofcn-08}
Is the function v:{\mathbb{N}}\to{\mathbb{N}} defined by v(n)=n+1 onto? Explain.
Example \PageIndex{7}\label{eg:oneonefcn-07}
The function s in Example 6.4.10 is both one-to-one and onto. It provides a one-to-one correspondence between the elements of A by matching a married individual to his/her spouse.
exercise \PageIndex{9}\label{he:ontofcn-09}
Is the function h_1 in Exercises 1.2, Problem 6.4.8, an onto function? Explain.
Summary and Review
- A function f :{A}\to{B} is onto if, for every element b\in B, there exists an element a\in A such that f(a)=b.
- To show that f is an onto function, set y=f(x), and solve for x, or show that we can always express x in terms of y for any y\in B.
- To show that a function is not onto, all we need is to find an element y\in B, and show that no x-value from A would satisfy f(x)=y.
exercise \PageIndex{1}\label{ex:ontofcn-01}
Which of the following functions are onto? Explain!
- f :{\mathbb{R}}\to{\mathbb{R}}, f(x)=x^3-2x^2+1.
- g :{[\,2,\infty)}\to{\mathbb{R}}, g(x)=x^3-2x^2+1.
exercise \PageIndex{2}\label{ex:ontofcn-02}
Which of the following functions are onto? Explain!
- p :{\mathbb{R}}\to{\mathbb{R}}, p(x)=e^{1-2x}.
- q :{\mathbb{R}}\to{\mathbb{R}}, q(x)=|1-3x|.
exercise \PageIndex{3}\label{ex:ontofcn-03}
Construct a one-to-one function f :{[1,3]}\to{[2,5]} that is not onto.
exercise \PageIndex{4}\label{ex:ontofcn-04}
Construct an onto function g :{[\,2,5)}\to{(1,4\,]} that is not one-to-one.
exercise \PageIndex{5}\label{ex:ontofcn-05}
Determine which of the following are onto functions.
- f :{\mathbb{Z}}\to{\mathbb{Z}}; f(n)=n^3+1
- g :{\mathbb{Q}}\to{\mathbb{Q}}; g(x)=n^2
- h :{\mathbb{R}}\to{\mathbb{R}}; h(x)=x^3-x
- k :{\mathbb{R}}\to{\mathbb{R}}; k(x)=5^x
exercise \PageIndex{6}\label{ex:ontofcn-06}
Determine which of the following are onto functions.
- p :{\wp(\{1,2,3,\ldots,n\})}\to{\{0,1,2,\ldots,n\}}; p(S)=|S|
- q :{\wp(\{1,2,3,\ldots,n\})}\to{\wp(\{1,2,3,\ldots,n\})}; q(S)=\overline{S}
exercise \PageIndex{7}\label{ex:ontofcn-07}
Determine which of the following functions are onto.
- {f_1}:{\{1,2,3,4,5\}}\to{\{a,b,c,d\}}; f_1(1)=b, f_1(2)=c, f_1(3)=a, f_1(4)=a, f_1(5)=c
- {f_2}:{\{1,2,3,4\}}\to{\{a,b,c,d,e\}}; f_2(1)=c, f_2(2)=b, f_2(3)=a, f_2(4)=d
- {f_3}:{\mathbb{Z}}\to{\mathbb{Z}}; f_5(n)=-n
- {f_4}:{\mathbb{Z}}\to{\mathbb{Z}}; f_4(n) = \cases{ 2n & if $n < 0$, \cr -3n & if $n\geq0$,\cr}
exercise \PageIndex{8}\label{ex:ontofcn-08}
Determine which of the following functions are onto.
- {g_1}:{\{1,2,3,4,5\}}\to{\{a,b,c,d,e\}}; g_1(1)=b, g_1(2)=b, g_1(3)=b, g_1(4)=a, g_1(5)=d
- {g_2}:{\{1,2,3,4,5\}}\to{\{a,b,c,d,e\}}; g_2(1)=d, g_2(2)=b, g_2(3)=e, g_2(4)=a, g_2(5)=c
- g_3: \mathbb{N} \rightarrow \mathbb{N}; g_3 (n) = \cases{ \frac{n+1}{2} & if $n$ is odd \cr \frac{n}{2} & if $n$ is even \cr}
- g_4: \mathbb{N} \rightarrow \mathbb{N}; g_4 (n) = \cases{ n+1 & if $n$ is odd \cr n-1 & if $n$ is even \cr}
exercise \PageIndex{9}\label{ex:ontofcn-09}
Is it possible for a function from \{1,2\} to \{a,b,c,d\} to be onto? Explain.
exercise \PageIndex{10}\label{ex:ontofcn-10}
List all the onto functions from \{1,2,3,4\} to \{a,b\}?
- Hint
-
List the images of each function.
exercise \PageIndex{11}\label{ex:ontofcn-11}
Determine which of the following functions are onto.
- f :{\mathbb{Z}_{10}}\to{\mathbb{Z}_{10}}; h(n)\equiv 3n (mod 10).
- g :{\mathbb{Z}_{10}}\to{\mathbb{Z}_{10}}; g(n)\equiv 5n (mod 10).
- h :{\mathbb{Z}_{36}}\to{\mathbb{Z}_{36}}; h(n)\equiv 3n (mod 36).
exercise \PageIndex{12}\label{ex:ontofcn-12}
Determine which of the following functions are onto.
- r:{\mathbb{Z}_{36}}\to{\mathbb{Z}_{36}}; r(n)\equiv 5n (mod 36).
- s :{\mathbb{Z}_{10}}\to{\mathbb{Z}_{10}}; s(n)\equiv n+5 (mod 10).
- t :{\mathbb{Z}_{10}}\to{\mathbb{Z}_{10}}; t(n)\equiv 3n+5 (mod 10).
exercise \PageIndex{13}\label{ex:ontofcn-13}
Determine which of the following functions are onto.
- {\alpha}:{\mathbb{Z}_{12}}\to{\mathbb{Z}_{ 7}}; \alpha(n)\equiv 2n (mod 7).
- {\beta} :{\mathbb{Z}_{ 8}}\to{\mathbb{Z}_{12}}; \beta (n)\equiv 3n (mod 12).
- {\gamma}:{\mathbb{Z}_{ 6}}\to{\mathbb{Z}_{12}}; \gamma(n)\equiv 2n (mod 12).
- {\delta}:{\mathbb{Z}_{12}}\to{\mathbb{Z}_{36}}; \delta(n)\equiv 6n (mod 36).
exercise \PageIndex{14}\label{ex:ontofcn-14}
Give an example of a function f :{\mathbb{N}}{\mathbb{N}} that is
- neither one-to-one nor onto
- one-to-one but not onto
- onto but not one-to-one
- both one-to-one and onto