Codomain
From Wikipedia, the free encyclopedia
In mathematics, the codomain of a function f : X → Y is the set Y.
The domain of f is the set X.
The range of f is the set f(X) defined as {f(x) : x ∈ X}.
It follows from these definitions that the range of f is always a subset of the codomain of f.
[edit] Example
An illustration of the difference between the codomain and the range can be found by considering the matrix of a linear transformation. By convention, the domain of a linear transformation associated with a matrix is and the codomain is , where the matrix is (has m rows and n columns). But the range (the set of numbers obtained when the matrix is right-multiplied by every column vector of length n) could be much smaller. For example, if the matrix contains only 0s, then no matter how large it is, the range is just the vector 0. But the dimension of the resulting vector is m. This is important, because it is enough to change just one number in the matrix to make its range non-zero.
Another example: let the function f be a function on the real numbers:
defined by
The codomain of f is R, but clearly f(x) never outputs negative values, and thus the range is in fact the set R0+—non-negative reals, i.e. the interval [0,∞):
One could have defined the function g thus:
While f and g have the same effect on a given number, they are not, in the modern view, the same function since they have different codomains.
To see why, suppose we define a second function,
We must define the domain to be :
- .
Now let's define the compositions
- ,
- .
Which of these compositions make sense?
As it turns out, the first one doesn't. Suppose (as we must, unless we write down an explicit contradiction of this) we do not know what the range of f is; we only know that it can be . But then we're in trouble, because the square root is not defined for negative numbers! Now we have a possible contradiction.
This is unclear, and in formal work should be avoided. Function composition therefore requires by definition that the codomain (not the range, which is a consequence of the function and so said to be indeterminate at the level of the composition) of the function on the right be the same as the domain of the function on the left.
The codomain can affect whether the function is a surjection; in our example, g is a surjection while f is not. The codomain does not affect whether the function is an injection.