Function theory: codomain and image, difference between them

Solution 1:

You cannot read off the codomain from the formula $f(x)=x^2$.

Domain and codomain really are part of the data which comes with a function. This means that you cannot just say

"Let $f$ be the function $x\mapsto x^2$."

Instead, you always have to specify domain and codomain first, as in

"Let $f$ be the function from $\mathbb R$ to $\mathbb R$ mapping $x$ to $x^2$."

Or, as you mentioned, it could be

"Let $f$ be the function from $\mathbb R$ to $\mathbb C$ mapping $x$ to $x^2$."

or

"Let $f$ be the function from $\mathbb C$ to $\mathbb C$ mapping $x$ to $x^2$."

This will really be different functions.

Of course, if you want to define a function $f\colon X\to Y$ you have to make sure that $f(x)$ actually is an element in $Y$. Therefore,

"Let $f$ be the function from $\mathbb C$ to $\mathbb R$ mapping $x$ to $x^2$."

does not define a function.

The image of a function $f\colon X\to Y$ is, by the way, the subset of $Y$ consisting of all element $y\in Y$ for which there exists an element $x\in X$ with $f(x)=y$.