At high school we were told that a function has a domain and a range, the function maps from the domain to the range. Such that the domain contains all and only the possible inputs and the range contains all and only the possible outputs.
Now at University I'm told a function has a domain and a codomain, and that the codomain contains all the possible outputs but may also include other numbers. What is the point of having values in the codomain that can not be output by the function, how does that aid in describing the function? Does this also mean that the domain can include numbers that the are not inputs to the function?
Surely this means you could say the codomain of any function (that outputs numbers) is the complex set (so all numbers)?
EDIT: Wikipedia says the function $f : x \rightarrow x^2$ has codomain $\mathbb{R}$ but it's image (what I guess I knew as range in high school) is $\mathbb{R}^+_0$, so why not just say the codomain is $\mathbb{R}^+_0$.
EDIT2: And is it also then true that is a function is "onto" the codomain is the same as the image? So surely any function can be "onto" if you just change the what the codomain is?
What I'm really trying to ask I guess is the range/image of a function is defined by the function, what defines the codomain?
The codomain is a set which the function maps into. For example if $f:N \rightarrow R$ by $f(n) = n$ then R is the codomain.The range of the function is the subset of the codomain whose elements correspond to the mapping of some element from the domain. So with $f(n) = n$ the range in $R$ is the subset $N \subset R$.
If the range is equal to the codomain, then the function is called onto, or a surjection..