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 a function f if it is defined as described in 1954 by Bourbaki, namely a triple (X, Y, F), with F a functional subset of the Cartesian product X × Y and X is the set of first components of the pairs in F (the domain). The set F is called the graph of the function. 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 alternative definition of function by Bourbaki, namely as just a functional graph, does not include a codomain and 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.
Read more about Codomain: Examples