Codomain of a Function
The codomain of a function is the set of all possible output values that the dependent variable is allowed to take according to the definition of the function. The codomain of a function \(f\) is denoted by \(C_f.\)
Recall that a function is a rule that assigns to each element of a set \(A\) a unique element of a set \(B.\) The set \(A\) is the domain (\(D_f\)), while the set \(B\) is called the codomain (\(C_f\)). When a function is written in formal arrow notation as \(f: A \to B,\) the codomain is the set that appears to the right of the arrow.
For example, if we have the function \(f: \mathbb{R} \to [0, \infty)\) given by \(f(x) = x^2,\) the notation tells us directly that its domain is \(D_f = \mathbb{R}\) and its codomain is \(C_f = [0, \infty).\)
For real-valued functions of a real variable, the set of real numbers \(\mathbb{R}\) is taken as the codomain unless stated otherwise. Because of this convention, many calculus textbooks do not mention it explicitly and work directly with the domain and the range.
Table of Contents
Difference Between Codomain and Range
The main difference between the codomain and the range (or image) lies in which elements make up each set: while the codomain is the target set declared in the definition of the function, the range consists solely of the output values actually produced when evaluating every element of the domain.
Mathematically, the range is always a subset of the codomain (\(R_f \subseteq C_f\)), so the two sets are not necessarily equal. There may be elements inside the codomain that are not in the range of the function because no element of the domain maps to them.

Analyzing the arrow diagram above, we can identify the three sets of the function:
- The input set is the domain of the function: \(D_f = \{a, b, c, d\}.\)
- The target set is the codomain of the function: \(C_f = \{1, 2, 3, 4, 5, 7\}.\)
- The range of the function is contained within the codomain and is \(R_f = \{4, 5, 7\}.\)
As shown, the elements \(1,\) \(2,\) and \(3\) are part of the codomain \(C_f,\) but they do not belong to the range \(R_f.\) When both sets match (\(C_f = R_f\)), we say that the function is surjective (or onto).
On the Cartesian plane, both sets are interpreted along the vertical axis (the \(y\)-axis): the codomain represents the entire portion of the vertical axis allowed by the function's definition (for instance, the whole real line), whereas the range corresponds strictly to the projection of the graph onto that axis—that is, the heights that the curve actually reaches.
Restricting the Codomain
The primary usefulness of knowing the codomain lies in determining whether a function is surjective (which happens when \(C_f = R_f\)). Surjectivity, along with injectivity, is a required condition for a function to be bijective and, consequently, to have an inverse function.
When the codomain and the range of a function do not match, we can perform a codomain restriction. This operation consists of redefining the target set so that it equals the range (\(C_f = R_f\)), removing any elements that lack a preimage and thereby making the function surjective.
Example
Determine how to restrict the codomain (and the domain) of the quadratic function \(f: \mathbb{R} \to \mathbb{R}\) defined by \(f(x) = x^2\) so that it has an inverse function.
First, we examine the original sets of the function \(f(x) = x^2.\) By definition, its domain is \(D_f = \mathbb{R}\) and its codomain is \(C_f = \mathbb{R}.\) However, since squaring any real number yields a result greater than or equal to zero, its range is \(R_f = [0, \infty).\)
Under these original conditions, the function is not bijective for two reasons:
- It is not surjective (onto): the codomain \(\mathbb{R}\) differs from the range \([0, \infty),\) because negative numbers belong to the codomain yet are not the output of any real number.
- It is not injective (one-to-one): distinct domain values produce the same output; for instance, \(f(-2) = 4\) and \(f(2) = 4.\)
For the function to have an inverse, we must apply a two-part restriction:
- Restricting the codomain: we set the codomain equal to the range, defining \(C_f = [0, \infty).\) With this change, every element in the codomain has at least one preimage, making the function surjective.
- Restricting the domain: we limit the input set to the non-negative real numbers, setting \(D_f = [0, \infty).\) This prevents opposite values from sharing an output, making the function injective.
By redefining the function as \(f: [0, \infty) \to [0, \infty),\) both conditions are met: the function is now bijective and has the square root function \(f^{-1}(x) = \sqrt{x}\) as its inverse.
Examples of Codomain
When a real-valued function is written in formal arrow notation (\(f: A \to B\)), the codomain is not assumed by default; instead, it is read directly from the set \(B\) on the right side of the arrow.
Let us examine the following cases where the domain and codomain are explicitly defined:
- \(f: \mathbb{R} \to [0, \infty)\) given by \(f(x) = x^2\): the domain is \(D_f = \mathbb{R}\) and the stated codomain is \(C_f = [0, \infty).\) Since the range of the quadratic function is also \(R_f = [0, \infty),\) both sets coincide (\(C_f = R_f\)) and the function is surjective.
- \(f: [1, \infty) \to [0, \infty)\) given by \(f(x) = \sqrt{x - 1}\): the domain is restricted to \(D_f = [1, \infty)\) to avoid taking square roots of negative numbers, and the codomain is set to \(C_f = [0, \infty).\) Because the principal square root returns only values greater than or equal to zero, the range is \(R_f = [0, \infty),\) so the function is surjective.
- \(f: \mathbb{R} \to \mathbb{R}^+\) given by \(f(x) = e^x\): the domain is \(D_f = \mathbb{R}\) and the codomain is the set of positive real numbers \(C_f = \mathbb{R}^+ = (0, \infty).\) Since the exponential function takes strictly positive values only, its range matches the codomain (\(R_f = \mathbb{R}^+\)), making the function surjective.
- \(f: [0, \pi] \to [-1, 1]\) given by \(f(x) = \cos(x)\): both the domain \(D_f = [0, \pi]\) and the codomain \(C_f = [-1, 1]\) are bounded. Over this input interval, the cosine function spans every value from \(1\) down to \(-1,\) so \(R_f = [-1, 1] = C_f\) and the function is surjective.
Conversely, when a real-valued function is given solely by its algebraic formula without specifying input or target sets, its codomain is taken to be \(\mathbb{R}\) by convention.
The table below shows examples of real-valued functions written by their formulas, comparing their domain, default codomain, range, and whether they satisfy the surjectivity condition:
| Function | Domain (Df) | Codomain (Cf) | Range (Rf) | Surjective? |
|---|---|---|---|---|
| \(y = 2x + 1\) | ℝ | ℝ | ℝ | Yes |
| \(y = 3\) | ℝ | ℝ | {3} | No |
| \(y = \dfrac{1}{x}\) | ℝ \ {0} | ℝ | ℝ \ {0} | No |
| \(y = 2^x\) | ℝ | ℝ | (0, \(\infty\)) | No |
| \(y = \ln(x)\) | (0, \(\infty\)) | ℝ | ℝ | Yes |
| \(y = \sin(x)\) | ℝ | ℝ | [-1, 1] | No |
Did you find this useful? Rate it!
Leave a Reply

Related Articles