Why co-domain of a function needs to be defined beyond the function’s range

functions

I've recently watched this video and struggle to wrap my mind around difference between codomain and range of a function. I understand that range is a subset of the codomain, but at the same time if there is no any restrictions on how the codomain is defined, why it needs to be defined beyond the range? Is it author of a function who defines the codomain? And if so, what makes him define the codomain beyond the range of a function (as the author, he is supposed to know all possible restrictions).

If it's not "authors" but rather for consumers of a function, who have to deduce the codomain, how can they even approximate the codomain without knowing entire range? And if they know the range, why again codomain needs to be defined beyond range?

Best Answer

Yes, it is the

author of a function who defines the codomain

but the author may not have a particular function with known range when starting the discussion.

For example, we often want to consider the set of all real valued functions of a real variable. Those functions all have domain and codomain $\mathbb{R}$. Some of them will have range $\mathbb{R}$, some not.

In computer programming languages you often have to specify the domain and codomain (the "types") without knowing the range.

Finding the range might actually be quite difficult, or even unknown. For example, no one knows whether there are any odd perfect numbers. What is the range of the function with domain the odd natural numbers and codomain $\{0,1\}$ such that $f(n) = 1$ if $n$ is a perfect number, $f(n) = 0$ otherwise?

The consumer of a properly defined function will never have to deduce the codomain, since the codomain is part of the definition of such a function. When the codomain is "obvious" it may not be explicitly specified, but it is part of the definition of the function.

Related Question