Codomain of a Function
The codomain of a function or relation $$ f:X \rightarrow Y $$ is the set Y.
The set X is called the domain of the function.
The subset of the codomain consisting of the values actually produced by the function f is called the image of the function, denoted by Im(f).
$$ Im(f) \subseteq Y $$
In general, the image of a function does not have to coincide with its codomain.
A Practical Example
Consider two finite sets, X and Y:
$$ X = \{1,2,3,4,5 \} $$
$$ Y = \{1,2,3,4,5,6,7,8,9 \} $$
and the relation
$$ f: y = x^2 $$
The codomain of this relation is the set Y:
$$ Y = \{1,2,3,4,5,6,7,8,9 \} $$
The image of the function is a subset of the codomain:
$$ Im(f) = \{1,4,9 \} \subseteq X $$
These are the elements of Y that can be expressed as the square of some element in X.

$$ f: 1^2 \mapsto 1 $$
$$ f: 2^2 \mapsto 4 $$
$$ f: 3^2 \mapsto 9 $$
Example 2
Now consider the real-valued function
$$ f: y = \sin(x) $$
In this case, both the domain and the codomain are the set of real numbers:
$$ f: \mathbb{R} \rightarrow \mathbb{R} $$
Here the function is defined on all real numbers, so the domain of definition coincides with the entire set of real numbers.
However, the image does not coincide with the codomain, since all values of the sine function lie strictly within the interval [-1,1].
And so on.
