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? 

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.
