The codomain of a function is not to be confused with the image of a function, which is the set of points in $~$Y$~$ that can actually be reached by following $~$f$~$, and which may not include the whole set $~$Y$~$\. For example, the function $~$\\operatorname{square} : \\mathbb R \\to \\mathbb R$~$ defined as $~$\\operatorname{square}(x)\=x^2$~$ has codomain $~$\\mathbb R$~$ but its image is the positive real numbers, a subset of $~$\\mathbb R$~$\.
Does this make the definition of the codomain somewhat arbitrary?
The squares of reals happen to be a subset of the reals, but they're also a subset of all complex numbers. Why say the codomain is $~$\mathbb R$~$ rather than $~$\mathbb C$~$?
Comments
Alexei Andreev
Narrowness is a virtue, especially in mathematics. The tighter and more precise you can make your statement, the more you could say about it.
Eric Rogstad
But wouldn't following that principle lead you to say the codomain is the positive reals, since that's the smallest set that contains the image (i.e. it is the image)?
Alexei Andreev
Yes, but the difference between reals and positive reals isn't that big. However, I might be confused on this whole topic (see the other comment I tagged you in).
Nate Soares
Fixed. (Would be nice to have a way to resolve these comments.)
Eric Rogstad
Yes, I think I should have used "question/objection" rather than comment. (But I'm trying do what feels natural rather than using my inside information on how the platform is supposed to work.)