In mathematics, the codomain or target set of a function is the set Y into which all of the output of the function is constrained to fall. It is the set Y in the notation f: X → Y. The codomain is also sometimes referred to as the range but that term is ambiguous as it may also refer to the image.
The codomain is part of the modern definition of a function f as a triple (X, Y, F), with F a subset of the Cartesian product X × Y. The set of all elements of the form f(x), where x ranges over the elements of the domain X, is called the image of f. In general, the image of a function is a subset of its codomain. Thus, it may not coincide with its codomain. Namely, a function that is not surjective has elements y in its codomain for which the equation f(x) = y does not have a solution.
An older definition of functions which does not include a codomain is also widely used. For example in set theory it is desirable to permit the domain of a function to be a proper class X, in which case there is formally no such thing as a triple (X, Y, F). With such a definition functions do not have a codomain, although some authors still use it informally after introducing a function in the form f: X → Y.
For a function
the codomain of f is , but f does not map to any negative number. Thus the image of f is the set ,i.e., the interval [0,∞).
An alternative function g is defined thus:
While f and g map a given x to the same number, they are not, in the modern view, the same function because they have different codomains. A third function h can be defined to demonstrate why:
The domain of h must be defined to be :
The compositions are defined
On inspection, is not useful. It is true, unless defined otherwise, that the image of f is not known; it is only known that it is a subset of . For this reason, it is possible that h, when composed on f, might receive an argument for which no output is defined – negative numbers are not elements of the domain of h, which is the square root function.
Function composition therefore is a useful notation only when the codomain of the function on the right side of a composition (not its image, which is a consequence of the function and could be unknown at the level of the composition) is the same as the domain of the function on the left side.
Full article ▸