What Does It Mean to Specify a Function?
A formula such as \(x\mapsto x^2\) does not by itself describe every part of a function. We also need to know which inputs are allowed and which set is designated to contain the outputs. These choices matter: the formula may fail for some proposed inputs, or it may produce values outside the proposed codomain. A reliable description therefore records the domain, the codomain, and the rule together.
We work with sets \(X\) and \(Y\). The notation \(f:X\to Y\) says that \(f\) is a function from \(X\) to \(Y\). The set \(X\) is its domain, and \(Y\) is its codomain. The rule must assign to each input in \(X\) exactly one output in \(Y\).
In this definition, “one and only one” has two requirements. Existence: every input \(x\in X\) receives an output. Uniqueness: it does not receive two different outputs. Also, each assigned output must belong to \(Y\). A formula that is defined for most, but not all, elements of \(X\) does not specify a function on all of \(X\).
The graph records the input-output pairs: $$ G_f=\{(x,f(x)):x\in X\}\subseteq X\times Y. $$ It is useful for representing the rule, but the graph alone need not record the domain and codomain. We will treat a map \(f:X\to Y\) as specified with its source \(X\), target \(Y\), and rule, or equivalently as this graph together with its source and target.
A Test Using Ordered Pairs
The graph gives a precise way to test an assignment. A subset \(G\subseteq X\times Y\) can serve as the graph of a function from \(X\) to \(Y\) exactly when every \(x\in X\) appears as the first coordinate of exactly one pair in \(G\). The requirement that \(G\subseteq X\times Y\) ensures that the second coordinates belong to \(Y\).
Proof. Suppose first that \(G\) is the graph of a function \(f:X\to Y\). For each \(x\in X\), the function assigns the value \(f(x)\in Y\), so \((x,f(x))\in G\). If also \((x,y)\in G\), then the definition of the graph means \(y=f(x)\). Hence exactly one \(y\in Y\) is paired with \(x\). Conversely, suppose that for each \(x\in X\) there is exactly one \(y\in Y\) with \((x,y)\in G\). Define \(f(x)\) to be this unique \(y\). Existence makes \(f(x)\) defined for every \(x\in X\), uniqueness makes the value unambiguous, and \(y\in Y\) ensures that the output lies in the codomain. The resulting function has graph \(G\). \(\square\)
This test includes both possible ways an assignment can fail: an input may have no paired output, or it may have more than one. When \(X\) is empty, there are no inputs to check. In that case the condition holds vacuously, provided \(G\subseteq X\times Y\); since \(X\times Y=\varnothing\), necessarily \(G=\varnothing\).
Worked Example: Checking a Finite Assignment
Let \(X=\{1,2,3\}\), \(Y=\{a,b\}\), and \(G=\{(1,a),(2,a),(3,b)\}\). Determine whether \(G\) defines a function from \(X\) to \(Y\), and find its range.
Every pair in \(G\) belongs to \(X\times Y\): its first coordinate is in \(X\), and its second coordinate is in \(Y\). Now check the inputs one at a time. The only pair with first coordinate \(1\) is \((1,a)\), so \(1\) has exactly one output, \(a\). The only pair with first coordinate \(2\) is \((2,a)\), so \(2\) has exactly one output, \(a\). The only pair with first coordinate \(3\) is \((3,b)\), so \(3\) has exactly one output, \(b\). All inputs have exactly one output, and therefore \(G\) defines a function \(f:X\to Y\).
The values assigned are \(f(1)=a\), \(f(2)=a\), and \(f(3)=b\). Consequently the range is \(\{a,b\}\), which in this example happens to equal the codomain \(Y\).
Check: The graph of the stated rule is \(\{(1,f(1)),(2,f(2)),(3,f(3))\}=\{(1,a),(2,a),(3,b)\}=G\). Each output is in \(Y=\{a,b\}\), and no input has been omitted or assigned two different values.
Range and Codomain Are Different Roles
For every function \(f:X\to Y\), each value \(f(x)\) belongs to \(Y\). Therefore the range is always a subset of the codomain. It need not be the whole codomain. The codomain is part of how the function is specified; the range is determined by the outputs the rule actually produces.
Proof. Let \(y\in f(X)\). By the definition of the range, there is some \(x\in X\) such that \(y=f(x)\). Because \(f\) is a function from \(X\) to \(Y\), every value \(f(x)\) belongs to \(Y\). Thus \(y\in Y\), proving \(f(X)\subseteq Y\). Equality holds precisely when there are no elements of \(Y\) missing from the range; equivalently, every element of \(Y\) is an output of the rule. \(\square\)
Worked Example: A Rule with a Larger Codomain
Define \(f:X\to Y\) by \(f(x)=x^2\), where \(X=\{-2,-1,0,1,2\}\) and \(Y=\mathbb{R}\). Find the range and compare it with the codomain.
Evaluate the rule at every element of \(X\): \(f(-2)=(-2)^2=4\), \(f(-1)=(-1)^2=1\), \(f(0)=0^2=0\), \(f(1)=1^2=1\), and \(f(2)=2^2=4\). Each input has exactly one assigned value, and each value is a real number, so this is a function from \(X\) to \(\mathbb{R}\). Listing the distinct outputs gives \(f(X)=\{0,1,4\}\). The codomain remains \(\mathbb{R}\), so \(f(X)\) is a proper subset of the codomain.
Check: Substituting the five domain elements into the rule gives, in order, \(4,1,0,1,4\). The set of these outputs is exactly \(\{0,1,4\}\); in particular, the calculation does not make the codomain equal to the range.
The domain and codomain are not redundant labels. In this course, when we compare maps \(f:X\to Y\) and \(g:U\to V\), they are the same specified map only if they have the same domain, the same codomain, and the same output for each input in that domain. A graph records the input-output pairs, but it may fail to record either set.
Worked Example: The Same Formula with Different Specifications
Consider the rule \(x\mapsto x^2\) on \(X=\mathbb{R}\). It can be specified as a map \(f:\mathbb{R}\to\mathbb{R}\), or as a map \(g:\mathbb{R}\to[0,\infty)\). Check that both specifications are valid, and compare their graphs and ranges.
For every real \(x\), the square \(x^2\) is real and satisfies \(x^2\geq 0\). Therefore the rule gives an allowed output in \(\mathbb{R}\), and also an allowed output in \([0,\infty)\). Each input is assigned one value, so both are functions.
In either specification the graph consists of exactly the pairs \((x,x^2)\) with \(x\in\mathbb{R}\). Thus the two graphs are equal. Their ranges are also both \([0,\infty)\): every output is nonnegative, and for each \(y\geq 0\), the real input \(x=\sqrt{y}\) satisfies \(x^2=y\). But their codomains differ, so they are different specified maps under the convention just stated.
Check: At the input \(x=2\), both maps give \(2^2=4\); \(4\) belongs to both codomains. The graphs therefore agree at this input, as they do for every real input, while the codomains \(\mathbb{R}\) and \([0,\infty)\) remain distinct.
Checking Proposed Rules, Including Empty Sets
For a proposed formula \(f(x)\), check three things in order: the expression is defined for every \(x\) in the stated domain; it gives only one value for each such \(x\); and every value belongs to the stated codomain. A formula may be perfectly usable after restricting its domain, but that restriction changes the map being specified.
Worked Example: A Rule Undefined at One Input
Test the proposal \(h:\mathbb{R}\to\mathbb{R}\), \(h(x)=1/x\). Then test the rule on the restricted domain \(X=\mathbb{R}\setminus\{0\}\) with the same codomain \(\mathbb{R}\).
The real number \(0\) belongs to the proposed domain \(\mathbb{R}\), but \(1/0\) is undefined. Thus the proposal does not assign an output to every domain element and is not a function \(\mathbb{R}\to\mathbb{R}\).
Now take \(X=\mathbb{R}\setminus\{0\}\). For each \(x\in X\), \(x\ne 0\), so division gives exactly one real number \(1/x\). Hence the rule does define a function from \(X\) to \(\mathbb{R}\).
Check: The input \(x=2\) is in the restricted domain and gives \(1/2\in\mathbb{R}\). The input \(x=0\) is not in the restricted domain, so the corrected specification does not require a value there.
Proof. A function from \(\varnothing\) to \(Y\) must assign one output to each element of \(\varnothing\). There are no such elements, so the empty assignment satisfies the requirement. Any function with empty domain has no input-output pairs, so its graph is \(\varnothing\); consequently there is exactly one such assignment. Next suppose a function \(f:X\to\varnothing\) exists. If \(x\in X\), the function must assign an output \(f(x)\in\varnothing\), which is impossible because the empty set has no elements. Therefore \(X\) must be empty. Conversely, when \(X=\varnothing\), the empty assignment is a function \(\varnothing\to\varnothing\), as already shown. \(\square\)
This also illustrates why a graph alone may not recover the domain: every function with empty domain has the empty graph, whatever its codomain. Even when the graph is nonempty, it need not determine the codomain, as the two square maps above demonstrate. Retaining the domain and codomain alongside the graph avoids both ambiguities.
A Common Mistake and a Reliable Checklist
Common mistake. It is incorrect to say that a function’s range must equal its codomain. For the finite square map \(f:\{-2,-1,0,1,2\}\to\mathbb{R}\), \(f(x)=x^2\), the calculation gives \(f(X)=\{0,1,4\}\), not \(\mathbb{R}\). The correction is to keep the roles separate: \(\mathbb{R}\) is the specified target, while \(\{0,1,4\}\) is the set of actual values. The general guarantee is inclusion of the range in the codomain, not equality.
When deciding whether an assignment is a function, use the following checklist:
- Is the domain stated?
- Does every domain element receive an output?
- Does each input receive only one output?
- Does every assigned output lie in the stated codomain?
- Have the range and codomain been kept distinct?
These checks make function notation precise before later work considers how functions act on subsets or how different functions can be compared. They also handle edge cases: if the domain is empty there are no inputs to check, while a nonempty domain cannot map to an empty codomain.
Check Your Understanding
For each question, state the domain and codomain explicitly when they are part of the data.
- Let \(X=\{0,1,2\}\), \(Y=\{0,1,4\}\), and \(G=\{(0,0),(1,1),(2,4)\}\). Does \(G\) define a function \(X\to Y\)? What is its range?
- Let \(X=\{1,2\}\), \(Y=\{a,b\}\), and \(G=\{(1,a),(1,b),(2,a)\}\). Which function condition fails?
- For \(f:\mathbb{R}\to\mathbb{R}\), \(f(x)=x^2\), identify the domain, codomain, and range.
- Does the rule \(x\mapsto\sqrt{x}\) define a function \(\mathbb{R}\to\mathbb{R}\)? What domain restriction makes the usual real-valued rule defined everywhere?
- Why does the empty graph not by itself specify a unique map when the domain and codomain have not been recorded?