The codomain of a function is , the set of possible outputs for the function. For example, the codomain of concat is the set of all strings, and the codomain of the function is the set of all numbers.
Visualizing a function as a map that takes every point in an input set to one point in an output set, the codomain is the output set (pictured on the right in blue in the image below).
The codomain of a function is not to be confused with the image of a function, which is the set of points in that can actually be reached by following , and which may not include the whole set . For example, consider all the functions that take a real number as input and produce another real number. Many of those functions cannot be made to produce every possible real number: For example, the function only produces non-negative numbers. For more on the distinction, see the page on codomain vs image.
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 R rather than C?
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.)
Fixed. (Would be nice to have a way to resolve these comments.)
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).
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)?
Narrowness is a virtue, especially in mathematics. The tighter and more precise you can make your statement, the more you could say about it.