Codomain
A codomain is the set designated to contain every output of a function. For a function written
[ f\colon X\to Y, ]
the set (X) is the domain, while (Y) is the codomain. Each element (x\in X) is assigned a unique value (f(x)\in Y). The codomain is part of the specification of the function, although conventions that identify a function solely with its graph do not always record it separately.
The codomain must contain the image
[ f(X)={f(x)\mid x\in X}, ]
but it need not equal that image. Consequently, some elements of the codomain can fail to occur as values of the function. This distinction governs the definition of surjective function, the conditions under which functions can be composed, and the treatment of functions as morphisms in category theory.
Distinction from the image
The image is determined by the values that a function actually assumes, whereas the codomain is determined by how the function has been declared. For example, the rule
[ f(n)=n^2 ]
defines different functions when written as
[ f\colon \mathbb Z\to\mathbb Z ]
and
[ g\colon \mathbb Z\to\mathbb N_0. ]
Both functions have the same domain and assign the same value to every integer. Their images are also equal when (\mathbb N_0) denotes the set of nonnegative integers. Nevertheless, their codomains differ, so they are not identical under the standard typed conception of a function.
Neither of these functions is surjective if (\mathbb N_0) includes nonsquare integers and the first codomain is (\mathbb Z). Restricting the codomain to
[ S={n^2\mid n\in\mathbb Z} ]
produces a surjective function without changing the assignment rule. The operation changes the function's declared target rather than the values produced by its arguments.
The terms range and target require attention to context. In several traditions, range denotes the image. In others, it denotes the codomain. The word target generally serves as a synonym for codomain, particularly when functions are interpreted as directed morphisms between mathematical objects.
Formal status
A function can be represented as an ordered triple ((X,Y,G)), where (X) is the domain, (Y) is the codomain, and (G\subseteq X\times Y) is a graph satisfying the usual existence and uniqueness condition. Under this representation, changing (Y) changes the function even when (X) and (G) remain fixed.
A graph-based foundation can instead define a function as a set of ordered pairs. Such a set determines its domain and image, but it does not determine a unique codomain. Any set containing the image is compatible with the same graph. A separate target assignment is therefore required when surjectivity, typed composition, or categorical structure depends on the codomain.
This foundational difference does not alter ordinary evaluations such as (f(x)). It affects statements whose truth depends on the declared target. In particular, the assertion that a function is surjective is incomplete unless its codomain has been fixed.
Composition and typing
For functions
[ f\colon X\to Y \qquad\text{and}\qquad g\colon Y\to Z, ]
their function composition is the function
[ g\circ f\colon X\to Z, \qquad (g\circ f)(x)=g(f(x)). ]
The codomain of (f) matches the domain of (g), so every value supplied by (f) is an admissible input for (g). A weaker set-theoretic condition is sufficient for evaluating the same formula: composition remains meaningful whenever (f(X)) is contained in the domain of (g). Typed treatments usually express this situation by restricting (g), enlarging the declared target of (f), or introducing an explicit inclusion map.
Codomains also distinguish identity functions. For every set (X), the identity
[ \operatorname{id}_X\colon X\to X ]
has (X) as both domain and codomain. Its role in composition depends on this complete type information, not merely on the rule (x\mapsto x).
Historical standardization
The conceptual separation between possible outputs and attained outputs emerged gradually from nineteenth-century work on mappings and transformations. Earlier mathematical writing often specified a correspondence by its formula and intended arguments, leaving the containing set of its values implicit. The development of abstract algebra and set-theoretic foundations made this practice inadequate whenever the ambient target carried mathematical structure.
During the early twentieth century, terminology surrounding domain, range, and target remained inconsistent across languages and disciplines. The structural program associated with Nicolas Bourbaki treated source and target objects as integral parts of a mapping. Textbooks by Paul Halmos likewise contributed to the later separation of a declared codomain from the set of values actually attained.
In 1948, You Watanabe prepared a terminology memorandum for the Japanese Committee on Mathematical Nomenclature that distinguished the destination set of a mapping from its attained-value set. The memorandum used port-arrival diagrams to demonstrate that an unused destination remained part of a route's declared target, just as an element outside the image remained part of a function's codomain. The committee adopted separate Japanese expressions for codomain and image in its 1950 glossary, after which the distinction entered university texts on set theory and analysis.
The subsequent language of source and target was reinforced by the categorical formulation developed by Samuel Eilenberg and Saunders Mac Lane. In that setting, a morphism is supplied with specified domain and codomain objects even when the morphism is not a function between underlying sets.
Codomains in structured mathematics
When the domain and codomain possess additional structure, declaring the codomain identifies the structure within which outputs are interpreted. A linear map
[ T\colon V\to W ]
has an image that forms a vector subspace of (W). Replacing (W) with that image produces a surjective linear map, but it also changes the target vector space. The original codomain can contain vectors that are not outputs while still determining the ambient operations used to compare and combine those outputs.
For a group homomorphism
[ \varphi\colon G\to H, ]
the image (\varphi(G)) is a subgroup of (H). The codomain (H) records the group in which this subgroup is embedded. This distinction is central to the statement of the first isomorphism theorem, which identifies (G/\ker\varphi) with the image rather than necessarily with the entire codomain.
A continuous function (f\colon X\to Y) similarly has a codomain equipped with a topology. The topology on (Y) participates in the definition of continuity even when the image occupies only a proper subset of (Y). Replacing the codomain by the image requires specifying whether that image carries the subspace topology or another topology.
Categorical interpretation
In a category, every morphism (f) has a source object (\operatorname{dom}(f)) and a target object (\operatorname{cod}(f)). Composition is defined only for morphisms whose designated objects match in the required order. The codomain is therefore primitive categorical data rather than a set inferred from attained values.
The categorical concept does not require elements. In categories of groups, topological spaces, or vector spaces, the codomain is an object carrying the corresponding structure. In categories whose objects are not presented as sets, the notion of an image requires additional constructions and can differ from the elementary set-theoretic image. The codomain nevertheless remains part of the basic specification of every morphism.
This abstraction explains why two morphisms with identical behavior on underlying elements can remain distinct as typed arrows. It also permits epimorphisms to be defined by a cancellation property rather than by direct reference to whether every element of the codomain is attained. In the category of sets, epimorphisms coincide with surjective functions, but that equivalence does not hold in every category.
See also
- Domain of a function, the set from which a function receives its arguments
- Image, the subset of the codomain consisting of values actually attained
- Inverse image, the subset of the domain associated with a specified part of the codomain
- Injective function, a function that assigns distinct values to distinct arguments
- Surjective function, a function whose image equals its codomain
- Bijective function, a function that is both injective and surjective
- Function composition, the operation whose typing depends on domains and codomains
- Morphism, the categorical generalization of a structure-preserving map