Inputs and Outputs Are Sets
A function can be described by a rule such as “square the input,” but the rule alone does not tell the whole story. We also need to know which inputs are allowed. And after applying the rule, we need to know which outputs actually occur.
These questions are answered by the function’s domain and range. Both are sets, but they describe different sides of the input-output relationship: the domain records the permitted inputs, while the range records the outputs the function produces from those inputs.
Domain, Codomain, and Range
A function is often written \(f:A\to B\). This notation says that \(f\) takes inputs from the set \(A\) and assigns an output in the set \(B\) to each input. The set \(A\) is the domain, and \(B\) is the codomain. The range consists only of the outputs that are actually attained.
The colon in \(\{f(x):x\in A\}\) means “such that”: this notation describes the set of values \(f(x)\) such that \(x\) belongs to \(A\). If the domain is finite, we can often find the range by evaluating the function at each allowed input and collecting the results.
The codomain and the range need not be equal. The codomain states where outputs are allowed to lie; the range states which of those outputs this particular function actually produces. For example, a function may have codomain \(\mathbb{R}\), the set of real numbers, even though it produces only a few values from that set.
Why the Range Is a Set of Actual Outputs
Suppose \(f:A\to B\). Each input \(x\in A\) has an assigned output \(f(x)\), and because the function maps into \(B\), that output belongs to \(B\). The range collects exactly these outputs, no more and no fewer.
Choose any \(x\in A\), where \(A\) is the domain.
The function assigns the output \(f(x)\), which belongs to \(B\).
Doing this for every \(x\in A\) gives \(\{f(x):x\in A\}\), the range.
This also justifies the inclusion \(\operatorname{Range}(f)\subseteq B\). If \(y\) belongs to the range, then \(y=f(x)\) for some \(x\in A\), by the definition of range. Since \(f:A\to B\), the output \(f(x)\) belongs to \(B\). Therefore \(y\in B\). This proves that every range value lies in the codomain, although the codomain may contain values that never occur.
Finding a Range from a Formula and a Finite Domain
When a function is given by a formula and its domain is a finite set, evaluate the formula once for each member of the domain. The resulting output values form the range. If two inputs produce the same output, that output is listed only once in the range set: a set records which values occur, not how many times they occur.
Worked Example: Squaring Each Allowed Input
Let \(A=\{-2,-1,0,1,2\}\), and define \(f:A\to\mathbb{R}\) by \(f(x)=x^2\). Find the domain and range.
The domain is the set specified for the function, so \(\operatorname{Domain}(f)=A=\{-2,-1,0,1,2\}\).
Now evaluate the formula at every input:
The outputs, in the order calculated, are \(4,1,0,1,4\). The range is the set of distinct outputs, so the repeated values \(1\) and \(4\) are each included only once:
Check: every listed range value occurs as an output, since \(0=f(0)\), \(1=f(-1)=f(1)\), and \(4=f(-2)=f(2)\). The domain has five inputs, while the range has three distinct outputs.
This example makes a useful distinction visible. The domain records inputs, so the negative and positive inputs remain separate members. The range records output values, so repeated outputs do not create additional members.
Another Formula, Another Set of Outputs
A formula does not determine a range by itself when the function is specified only on part of a larger set. The allowed inputs matter. In the next example, the domain is given explicitly, so only those inputs are used to find the range.
Worked Example: A Linear Rule on a Specified Domain
Let \(A=\{1,2,4\}\), and define \(g:A\to\mathbb{R}\) by \(g(x)=3x+2\). Find the domain and range.
The domain is exactly the stated input set:
Evaluate the formula at each allowed input:
Each of these outputs is different, so the range is:
Check: \(g(1)=5\), \(g(2)=8\), and \(g(4)=14\), so every member of the proposed range is attained. The codomain is \(\mathbb{R}\), which contains all three values, as required.
Finding Domain and Range in Finite Data
A finite set of input-output data can be represented by ordered pairs \((x,y)\), where \(x\) is an input and \(y\) is its corresponding output. For data that describe a function, the domain is the set of first coordinates and the range is the set of second coordinates that occur. Repeated coordinates are included only once in either set.
Worked Example: Extracting Sets from Ordered Pairs
Suppose a function is represented by the finite data \(\{(0,3),(1,5),(2,3),(3,7)\}\). Find its domain and range.
Read the first coordinate from each pair to identify the inputs. The inputs are \(0,1,2,3\), so:
Next, read the second coordinate from each pair. The outputs in order are \(3,5,3,7\). Since \(3\) occurs twice but a set contains each value only once, the range is:
Check: the data include \((0,3)\), \((1,5)\), \((2,3)\), and \((3,7)\), so every listed input appears and every listed range value is produced. In particular, the repeated output \(3\) does not add a second \(3\) to the range.
A Common Mistake: Confusing the Codomain with the Range
Suppose the function in the first worked example is written \(f:A\to\mathbb{R}\), where \(A=\{-2,-1,0,1,2\}\) and \(f(x)=x^2\). A common error is to say that its range is \(\mathbb{R}\) simply because \(\mathbb{R}\) is written after the arrow.
This confuses the codomain with the range. The codomain is \(\mathbb{R}\), but the actual outputs for the allowed inputs are \(4,1,0,1,4\). Thus the corrected range is:
The check is direct: every value in the range is produced by an input, and no other values are produced by the specified inputs. The distinction matters because a codomain can be larger than the set of values a function actually attains.
Why Domain and Range Matter
Domain and range give a compact description of the input-output possibilities of a function. The domain tells us which inputs belong to the function’s model; the range tells us what outputs result. In applications, this distinction can separate meaningful inputs from possible outcomes. In mathematical work, it prevents claims about a function that go beyond its specified inputs or actual outputs.
For a formula, always pay attention to the domain that accompanies it. For finite data, first identify the inputs and outputs from their roles in the pairs. In either case, the range is formed from outputs actually produced, not from every value that could belong to the codomain.
Check Your Understanding
Answer each question by identifying the relevant set and explaining how you know.
- If \(h:A\to B\), which set is the domain, and which set is the codomain?
- Let \(A=\{-1,0,1\}\) and \(p(x)=x+2\) for \(x\in A\). What are the domain and range?
- A function is represented by \(\{(2,4),(3,6),(5,4)\}\). What are its domain and range?
- Can a function’s range contain values that are not in its codomain? Explain using the definition of a function \(f:A\to B\).
- If two different inputs produce the same output, how should that output appear in the range set?