TITLE: Why is the concept of a codomain useful?
QUESTION [6 upvotes]: I don't understand what the point is of specifying the codomain of a function. For example, if I ask, "Given the function f: $\Bbb R$ $\to$ $\Bbb R$, where $f(x) = x^2$, what is the image of f?", how is that any different from asking, "Given the function $f(x) = x^2$ whose domain is $\Bbb R$, what is the image of f?" In both cases, the answer can only be "The set of all real numbers greater than or equal to $\theta$". Supplying the codomain in the first question doesn't add any more useful information.
Maybe a more precise way to phrase my question would be: What's the use of distinguishing between a number that's a part of a function's codomain but not its image, and a number that is neither part of the function's codomain nor its image?

REPLY [5 votes]: Because a function $f\colon X\to Y$ is formally defined as a subset of $X\times Y$.  It is, in fact, defined as its graph (contrary to what you were likely told in Calculus and earlier).  You can't ignore $Y$, and changing it changes the function.  There are many ways in which we can work around those issues, but that's the technical reason why.  
In many cases, it is not immediately clear if the range is equal to the entire codomain, and we often wish to prove or disprove this.