Codomain (of a function)

The codomain \(\operatorname{cod}(f)\) of a function \(f : X \to Y\) is \(Y\), the set of possible outputs for the function. For example, the codomain of concat is the set of all strings, and the codomain of the function \(+\) is the set of all numbers.

Visualizing a function as a map that takes every point in an input set to one point in an output set, the codomain is the output set (pictured on the right in blue in the image below).

The codomain of a function is not to be confused with the image of a function, which is the set of points in \(Y\) that can actually be reached by following \(f\), and which may not include the whole set \(Y\). For example, consider all the functions that take a real number as input and produce another real number. Many of those functions cannot be made to produce every possible real number: For example, the function \(\operatorname{square} : \mathbb R \to \mathbb R\) only produces non-negative numbers. For more on the distinction, see the page on codomain vs image.

Add a lens talking about how codomains are arbitrary but often natural/​useful. Use example like how we can consider \(+\) to have codomain \(\mathbb N\), \(\mathbb Z\), etc., and examples like Ackerman where the codomain “nat” makes by far the most sense (though “int” is fine too).

Children:

Parents: