# Example where values in codomain are not in image?

I am familiar with the formal definitions of codomain (or output space) and image, but I would like to better understand what it means when $$image(f)\ne Y$$ for some function $$f$$ from $$X$$ to $$Y$$ where $$f(x)=y$$.

I know that $$im(f)=Y$$ if and only if the function is invertible. That is because if the function is not invertible, some information is "lost" when moving between the input space and the output space, so it is possible to have values that are part of the output space $$Y$$ that are not in the image of $$f$$. This makes sense to me, but I cannot seem to come up with a specific example of when or why that would happen. Can anyone please help?

• Consider $f(x)=2x$. We have $f : \mathbb N \to \mathbb N$ but the image (or range) is not $\mathbb N$: it is the subset of even numbers. – Mauro ALLEGRANZA Oct 2 '18 at 15:42
• @MauroALLEGRANZA Thanks for your reply. I get what you are saying. However, I'm still confused, because my textbook say that if the function is invertible, then it follows that the image of $f$ is the same thing as the output space. In your example, $f(x)=2x$ is an invertible function, but we have that $im(f) \neq \mathbb{N}$. What am I missing? – Hee Jin Oct 2 '18 at 15:51
• $2x$ isn't invertible on naturals. If it were then $2x=3$ would have a natural number solution. – coffeemath Oct 2 '18 at 15:54
• I know that im(f)=Y if and only if the function is invertible No, $\,\operatorname{Im}(f)=Y\,$ if and only if the function is surjective. For example $\,f(x)=x^2\,$ defined as $\,f : \Bbb R \to [0,\infty)\,$ is surjective, and satisfies $\,\operatorname{Im}(\Bbb R)=[0,\infty)\,$, but is not invertible because it is not injective. – dxiv Oct 2 '18 at 16:01
• @coffeemath Thank you!! – Hee Jin Oct 2 '18 at 16:21

The codomain is the space that we are considering the output to "live" in. If we are considering the outputs to be a certain type of number, and not all numbers of that type are a possible output, then the image and codomain are different (other terms for the image and codomain being the same are "onto" and "surjective", so you're looking for functions that aren't onto). For instance, suppose we take the rounding function, where $$f(x)$$ is $$x$$ rounded to the nearest integer. If we consider the output space to be the set of integers, then the function is onto. But if we consider the output space to be real numbers, then it's not onto. This is why, strictly speaking, to know whether a function is onto, we need to know not only what the rule for producing the output is, but also what the codomain is. Other examples of functions that don't map the reals onto the reals are $$f(x)=x^2$$ and $$f(x)=e^x$$; the former maps reals onto the nonnegative real numbers, and the latter maps reals onto positive reals.

For a function to be invertible, the inverse of every element must be well-defined. "well-defined" means that a value exists, and there is only one value (if there were more than one, it wouldn't be well-defined because we wouldn't know which is meant). The condition that for each $$y$$, there exists an $$x$$ such that $$f(x) = y$$ is this onto property. The condition that for every $$y$$, there is at most $$x$$ such that $$f(x)=y$$ is called "into", "one-to-one" or "injective". So being invertible is not equivalent to being onto; a function has to be both onto and into. An example of a function that is onto but not into is $$f(x) = x^3-x = (x-1)x(x+1)$$. This has three roots of $$-1,0,1$$, so it's not it's not into (there are three different values of $$x$$ that give $$y=0$$), but it is onto. You can also have functions that are into but not onto, such as $$\arctan$$.

You put the tag linear-algebra, so you may be thinking of the fact that square matrices are invertible if and only if their columns space is the whole space (i.e., onto). However, this is due to square matrices representing linear transformations between vectors spaces of the same dimension. If a linear transformation goes to a smaller space, it will not be invertible regardless of whether it's onto.

Whether a linear transformation is onto depends, again, on what one considers the output space to be. For instance, consider the transformation $$P$$ that projects a three dimensional vector to the $$xy$$-plane. If we look in three dimensional space, the image is a plane, which is a subset of $$\mathbb{R}^3$$, so it's not onto from that perspective. However, if we consider the codomain to be the $$xy$$-plane, then it is onto. When a linear transformation is represented by a matrix, the number of rows tells you what dimension the codomain is considered to have. If the rows are independent, then the transformation is onto this space.

• For injective it should be "for every $y$ there is at most one $x$ such that $f(x)=y.$ [Unless it's already assumed $f$ is onto.] – coffeemath Oct 2 '18 at 19:26
• @coffeemath "only one" means "at most one", but I suppose the latter is less ambiguous. – Acccumulation Oct 2 '18 at 19:42
• Thank you so much for your detailed and thorough response! This helped me so much. There is a lot to sink my teeth into here and come back to. And yes, I was thinking about all this in the context of square matrices. – Hee Jin Oct 4 '18 at 18:19
• Side note, I am trying to change this to the accepted answer but I am having trouble with this. I cleared the browser's cache and everything...guess it's time to hit meta :) – Hee Jin Oct 4 '18 at 18:23

The codomain of a function $$f:X\to Y$$ is simply a set which includes the image of the domain, i.e. $$f(X)\subset Y$$. This may seem redundant: why do not impose always $$f(X)=Y$$? This is because sometimes it is useful to consider a larger set: for example, it could be useful to consider the function $$x\mapsto y=x^2$$ as a member the class of functions $$\{f:\mathbb{R}\to \mathbb{R}\}$$ even if $$x^2(\mathbb{R})=\mathbb{R}_+=\{x\in\mathbb{R}| x\ge 0\}.$$ Another, more interesting example, is the one given by Mauro Allegranza in his comment: his example is nice because it alludes to the extension of a function from smaller domain and codomain to larger ones. Finally, the condition you state for the equality $$\mathrm{image}(f)=Y$$ to be true is not correct: the real "necessary and sufficient" condition is that $$f$$ should be surjective, i.e. for any $$y\in Y$$ there is (at least one) $$x\in X$$ such that $$f(x)=y$$. This condition is fulfilled if $$f:X\to Y$$ is invertible since in this case $$f$$ is both injective (i.e. $$f(x_1)\neq f(x_2)$$ if $$x_1\neq x_2$$) and sujective.

• Thank you Daniele! This was immensely helpful. So basically, there are sometimes reasons for thinking of the codomain as part of a larger set. For example, maybe you want to make use of the values that aren't in the image of $f$, but are in the codomain. Also it's very helpful to know about the correct condition for $im(f)=Y$. The textbook doesn't say anything about this, but it probably should have, because everything makes much more sense to me now. – Hee Jin Oct 2 '18 at 16:42