Domain vs. Range vs. Codomain vs. Image vs. Preimage
A function comes with several sets that describe its inputs and outputs. The domain is where inputs come from, and the codomain is where outputs are allowed to land. The range is the set of outputs that actually occur. For a set $A$ of inputs, the image $f(A)$ is the set of outputs for inputs in $A$, so the range is the image of the whole domain. For a set $B$ of outputs, the preimage $f^{-1}(B)$ is the set of inputs that land in $B$.
Definitions
Think of a function as a machine that takes inputs and gives outputs. The domain of the function is the set of inputs that it accepts.
Consider a function $f$ given by a rule, such as a formula. The domain of $f$ is the set of inputs $x$ for which $f(x)$ is defined.
Consider a function $f : X \to Y$. The domain of $f$ is the set $X$.
Worked examples
-
Value:
$\reals$
This is the same rule as $x \mapsto x^2$ on $\reals$, but with the smaller codomain $[0, \infty)$, which equals the range. -
Value:
$\reals$
$f$ is declared as a function $\reals \to \reals$. -
Value:
$[0, \infty)$
-
Value:
$\reals^3$
The matrix \(A = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 3 \end{bmatrix}\) has $3$ columns, so the domain of $x \mapsto A x$ is $\reals^3$.
Think of a function as a machine that turns inputs into outputs. The range of the function is the set of all of the outputs that the function produces.
Consider a function $f$ and all of the inputs in its domain. The range of $f$ is the set of all of outputs that are produced by one or more of the inputs in the domain of $f$.
Worked examples
-
Value:
$f(\reals) = [0, \infty)$
This is the same rule as $x \mapsto x^2$ on $\reals$, but with the smaller codomain $[0, \infty)$, which equals the range. -
Value:
$f(\reals) = [0, \infty)$
The range of $f$ is $[0, \infty)$, because squares of real numbers are exactly the nonnegative numbers.
Consider a function. The codomain of the function is the set of values that its outputs are allowed to be. It can be larger than the set of outputs that actually occur: for $f(x) = x^2$ with real outputs, the codomain is all real numbers, but only nonnegative numbers occur.
Consider a function $f : X \to Y$. The codomain of $f$ is the set $Y$. Every output is in $Y$, but not every element of $Y$ needs to be an output.
Worked examples
-
Value:
$[0, \infty)$
The codomain of $f$ is $[0, \infty)$, because $f$ is declared as a function from $\reals$ to $[0, \infty)$. -
Value:
$\reals$
$f$ is declared as a function $\reals \to \reals$. -
Value:
$\reals^2$
The matrix \(A = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 3 \end{bmatrix}\) has $2$ rows, so the codomain of $x \mapsto A x$ is $\reals^2$.
Think of a function as a machine that turns inputs into outputs, and pick a group of inputs. The image of that group is the set of outputs that the machine gives for those inputs.
Consider a function and a set $A$ of inputs in its domain. The image of $A$ is the set of all outputs of the function for inputs in $A$.
Consider a function $f : X \to Y$ and a set $A \subseteq X$. The image of $A$ under $f$ is
\[f(A) = \setdef{f(x) \suchthat x \in A}.\]Worked examples
-
Value:
$f([-1, 2]) = [0, 4]$
This is the same rule as $x \mapsto x^2$ on $\reals$, but with the smaller codomain $[0, \infty)$, which equals the range. -
Value:
$f([-1, 2]) = [0, 4]$
The squares of the numbers in $[-1, 2]$ are exactly the numbers in $[0, 4]$: the smallest is $0^2 = 0$, and the largest is $2^2 = 4$.
Properties
- The image $f(X)$ of the whole domain is the range of $f$.
- If $f$ is a linear map between vector spaces, then the image of every subspace is a subspace. In particular, the range of $f$ is a subspace of the codomain, and its dimension is the rank of $f$.
Consider a function $f$ and a set $B$ of possible outputs. The preimage of $B$ under $f$ is the set of all inputs $x$ whose output $f(x)$ is in $B$.
Consider a function $f : X \to Y$ and a set $B \subseteq Y$. The preimage of $B$ is
\[f^{-1}(B) = \setdef{x \in X \suchthat f(x) \in B}.\]Worked examples
-
Value:
$f^{-1}(\setdef{4}) = \setdef{-2, 2}$
This is the same rule as $x \mapsto x^2$ on $\reals$, but with the smaller codomain $[0, \infty)$, which equals the range. -
Value:
$f^{-1}(\setdef{4}) = \setdef{-2, 2}$ and $f^{-1}(\setdef{-1}) = \emptyset$
The preimage $f^{-1}(\setdef{4})$ exists even though $f$ has no inverse. No real number squares to $-1$, so $f^{-1}(\setdef{-1})$ is empty.
Properties
- For a function $f : X \to \reals$, the $c$-level set of $f$ is the preimage $f^{-1}(\setdef{c})$ of a single point, and the $c$-sublevel set of $f$ is the preimage $f^{-1}((-\infty, c])$ of an interval.
- Preimages preserve unions, intersections, and complements: $f^{-1}(A \cup B) = f^{-1}(A) \cup f^{-1}(B)$, $f^{-1}(A \cap B) = f^{-1}(A) \cap f^{-1}(B)$, and $f^{-1}(Y \setdiff B) = X \setdiff f^{-1}(B)$. Images preserve unions, but not always intersections or complements.
Examples
Each cell is the ___ of the function in that row.
$f(x) = x^2$ on $\reals$
| domain | $\reals$ |
|---|---|
| range (image) | $f(\reals) = [0, \infty)$ |
| codomain | $\reals$ |
| image | $f([-1, 2]) = [0, 4]$ |
| preimage | $f^{-1}(\setdef{4}) = \setdef{-2, 2}$ and $f^{-1}(\setdef{-1}) = \emptyset$ |
$f(x) = x^2$, as a function $f : \reals \to [0, \infty)$
| domain | $\reals$ |
|---|---|
| range (image) | $f(\reals) = [0, \infty)$ |
| codomain | $[0, \infty)$ |
| image | $f([-1, 2]) = [0, 4]$ |
| preimage | $f^{-1}(\setdef{4}) = \setdef{-2, 2}$ |
Notes
- The notation $f^{-1}(B)$ for a preimage does not mean $f$ has an inverse.
- Some texts use “range” for the codomain instead. See the meanings of “range”.