Three Sets with Different Roles
In the previous tutorial, a function \(f:A\to B\) was described as a mapping that assigns each input in \(A\) exactly one output in \(B\). The notation already contains two sets: \(A\), the set from which inputs are taken, and \(B\), the set in which outputs are required to lie. A third set, the range, records which elements of \(B\) are actually assigned to inputs. Keeping these three roles distinct prevents a common source of confusion.
The domain of \(f:A\to B\) is \(A\). It is the set of all inputs for which the function must assign a value. The codomain of \(f:A\to B\) is \(B\). It is the specified target set: each value \(f(a)\) must belong to \(B\). The range (also called the image) of \(f\) is the set of outputs \(f(a)\) obtained as \(a\) varies over the domain.
Using the set-builder notation introduced earlier in this course, the range is $$ \operatorname{ran}(f)=\{f(a):a\in A\} =\{b\in B:\text{ there exists }a\in A\text{ such that }f(a)=b\}. $$ The two descriptions express the same idea in different ways. The first collects the values of the function at all inputs. The second asks which elements of the codomain are achieved by at least one input.
The Range Is Contained in the Codomain
The mapping requirement in the definition of a function guarantees that \(f(a)\in B\) for every \(a\in A\). Every member of the range is one of these values, so the range must be a subset of \(B\). This fact is simple, but it is important: it gives the basic relationship between the target set named in \(f:A\to B\) and the set of values attained.
Theorem (Range Is a Subset of the Codomain). If \(f:A\to B\), then $$ \operatorname{ran}(f)\subseteq B. $$
Proof. Let \(y\in\operatorname{ran}(f)\) be arbitrary. By the definition of the range, there is some \(a\in A\) such that \(y=f(a)\). Since \(f\) is a function from \(A\) to \(B\), its output at every input in \(A\) belongs to \(B\). In particular, \(f(a)\in B\). Because \(y=f(a)\), it follows that \(y\in B\). Thus every element of \(\operatorname{ran}(f)\) belongs to \(B\), which proves \(\operatorname{ran}(f)\subseteq B\). \(\square\)
The theorem gives inclusion, not necessarily equality. To prove that the range equals the codomain, it is not enough to verify that each output lies in the codomain. One must also show that every element of the codomain is attained. The next criterion makes the additional requirement precise.
Theorem (Codomain–Range Equality Criterion). If \(f:A\to B\), then $$ \operatorname{ran}(f)=B \quad\Longleftrightarrow\quad \text{for every }b\in B\text{ there exists }a\in A \text{ such that }f(a)=b. $$
Proof. Suppose first that \(\operatorname{ran}(f)=B\). Let \(b\in B\) be arbitrary. Then \(b\in\operatorname{ran}(f)\), so the definition of the range gives an \(a\in A\) such that \(b=f(a)\). Therefore every \(b\in B\) is attained by some input.
Conversely, suppose that for every \(b\in B\) there exists \(a\in A\) such that \(f(a)=b\). We already know from the Range Is a Subset of the Codomain Theorem that \(\operatorname{ran}(f)\subseteq B\). To prove the reverse inclusion, let \(b\in B\) be arbitrary. By the assumption, there exists \(a\in A\) with \(f(a)=b\). Thus \(b\) is an attained output, so \(b\in\operatorname{ran}(f)\). We have proved \(B\subseteq\operatorname{ran}(f)\). Equality by double inclusion now gives \(\operatorname{ran}(f)=B\). \(\square\)
This criterion also clarifies what it means for a function to use its entire codomain: every target value needs at least one input that maps to it. The quantifier “for every \(b\in B\)” matters. Checking several outputs, or even many outputs, does not establish equality unless the argument covers every element of \(B\).
Finding a Range in Finite Examples
When a domain is finite, one can determine the range by listing the output assigned to each input and then collecting the distinct outputs. Repeated values appear only once in the range because a set records membership, not the number of times an element occurs. The codomain, however, remains the set stated in the definition of the mapping.
Worked Example: A Range Smaller Than the Codomain
Let \(A=\{1,2,3\}\), \(B=\{2,4,6,8\}\), and define \(f:A\to B\) by \(f(k)=2k\). Evaluating the rule at every input gives $$ f(1)=2,\qquad f(2)=4,\qquad f(3)=6. $$ Each output belongs to \(B\), so the rule does define a function from \(A\) to \(B\). The values attained are \(2\), \(4\), and \(6\), and hence $$ \operatorname{ran}(f)=\{2,4,6\}. $$ The element \(8\) belongs to the codomain but is not the value \(f(k)\) for any \(k\in A\). Therefore \(8\notin\operatorname{ran}(f)\), and the range is a proper subset of the codomain. In particular, the codomain should not be replaced by the range when reporting the function as originally specified.
Worked Example: Several Inputs Can Give One Range Element
Let \(A=\{r,s,t,u\}\), \(B=\{0,1,2\}\), and define a function by $$ f(r)=1,\qquad f(s)=1,\qquad f(t)=0,\qquad f(u)=1. $$ The outputs assigned to the four inputs are \(1,1,0,1\). The distinct attained values are \(0\) and \(1\), so $$ \operatorname{ran}(f)=\{0,1\}. $$ Although \(1\) occurs as the output for three inputs, it is one element of the range, not three elements. The value \(2\) lies in the codomain but is not attained. Thus the range is again a proper subset of the codomain. The function condition requires one output for each fixed input; it does not require different inputs to have different outputs.
Worked Example: A Range Equal to the Codomain
Let \(A=\{a,b,c\}\), \(B=\{x,y\}\), and define $$ f(a)=x,\qquad f(b)=y,\qquad f(c)=x. $$ The only elements of \(B\) are \(x\) and \(y\). The element \(x\) is attained because \(f(a)=x\), and \(y\) is attained because \(f(b)=y\). Consequently, every element of \(B\) is attained, and the Codomain–Range Equality Criterion gives $$ \operatorname{ran}(f)=B=\{x,y\}. $$ The input \(c\) also maps to \(x\), but that does not change the range. To establish equality, we needed to find at least one input for each codomain element, not exactly one input for each.
Reading the Mapping Notation Carefully
In the notation \(f:A\to B\), the domain and codomain are part of the stated function. They cannot be inferred solely from a formula. A rule such as \(k\mapsto 2k\) gives an assignment pattern, but the complete mapping also identifies which \(k\)'s are inputs and what set is designated as the codomain. The range can then be found from those assignments.
For instance, the same assignments on the same domain can be described with a larger codomain. Let \(A=\{1,2\}\). The mapping \(p:A\to\{2,4\}\) defined by \(p(k)=2k\) has range \(\{2,4\}\), equal to its codomain. If instead the mapping is specified as \(q:A\to\{2,4,6\}\) with \(q(k)=2k\), then its range is still \(\{2,4\}\), but its codomain is \(\{2,4,6\}\). The output assignments agree on every input, while the stated target sets differ.
The range also depends on which inputs are in the domain. For a finite example, consider the rule \(x\mapsto x+1\). On \(A_1=\{0,1\}\), the attained values are \(\{1,2\}\). On \(A_2=\{0,1,2\}\), the attained values are \(\{1,2,3\}\). The assignment rule has not changed, but an additional input is now included, so an additional output is attained. A range calculation must therefore use the full specified domain.
Two Useful Boundary Cases
If the domain is empty, there are no inputs and therefore no attained outputs. In that case the range is empty: $$ A=\varnothing\quad\Longrightarrow\quad\operatorname{ran}(f)=\varnothing. $$ This is consistent with the definition: an element belongs to the range only if it is \(f(a)\) for some \(a\in A\), and there is no such input. For an empty domain, the range equals the codomain only when the codomain is also empty.
At the other extreme, a function with a nonempty domain can have a range containing just one element. For example, if \(A\) is nonempty, \(b_0\in B\), and every \(a\in A\) is assigned the value \(b_0\), then the set of attained outputs is \(\{b_0\}\). The domain may have many elements, while the range has only one. This again illustrates why domain size and range size answer different questions.
The distinction among domain, codomain, and range will be used whenever functions are compared or their properties are studied. First identify the specified inputs and target set; then determine which target elements actually appear as outputs. This order keeps the definition of the mapping separate from a calculation of its attained values.
Check Your Understanding
- For a mapping \(f:A\to B\), which set is the domain, and which set is the codomain?
- Give the set-builder definition of \(\operatorname{ran}(f)\) in terms of the values \(f(a)\).
- Why does the Range Is a Subset of the Codomain Theorem give \(\operatorname{ran}(f)\subseteq B\), rather than necessarily \(\operatorname{ran}(f)=B\)?
- Let \(A=\{1,2,3\}\), \(B=\{0,1,2,3\}\), and let \(f(k)=k-1\). Find the range and state whether it equals the codomain.
- What must be proved, in addition to \(\operatorname{ran}(f)\subseteq B\), to conclude that \(\operatorname{ran}(f)=B\)?