# Why is it important to have a discrepancy between image and codomain?

A function $f:\mathbb{R}\rightarrow \mathbb{R}$ given by $f(x)=x^2$ has $\mathbb{R}_{\geq0}$ as its image and $\mathbb{R}$ as its codomain.

What's the need for this discrepancy? Why don't we just write $f:\mathbb{R}\rightarrow \mathbb{R}_{\geq0}$?

I believe the reason for this is that there may be some functions in which stating the image this way may be impractical - if this hypothesis is true, what is this class of functions? If yes or no, is there any other reason for this?

• That's an odd choice of example. What is $f(0)$? – Ben Millwood May 19 '13 at 15:45
• What Ben is trying to tell you is that "you done goofed" when you wrote the domain. – kahen May 19 '13 at 15:47
• Please, edit you question. Remove zero from domain or define $f(0)$, as pointed out by @BenMillwood. – Sigur May 19 '13 at 16:10
• It's much easier to write down functions if you only have to know what their outputs can be rather than what their outputs are. If I define the function $f(n)$ which is equal to $1$ if $n$ encodes a proof of, say, P vs. NP in Peano arithmetic and equal to $0$ otherwise, what's the image? Is it $\{ 0 \}$ or $\{ 0, 1 \}$? – Qiaochu Yuan May 19 '13 at 19:39
• @BenMillwood I guess I employed a better example now. – Billy Rubina May 20 '13 at 13:40

The reason for this discrepancy is that for many functions it's not particularly important what its image is, while at the same time it would be tricky to figure this out. The codomain however is easy, it describes the type of value one can get. Is it a real number, a complex number, a fraction?

For example, $$f(x)=e^{x\bar{x}}+\frac{7}{3^{x\bar{x}+4}}$$

It's true that $f:\mathbb{C}\rightarrow\mathbb{C}$, but in fact $f:\mathbb{C}\rightarrow \mathbb{R}$. Hence the codomain gives useful information, but the image is difficult to determine.

• And of course, if the image is obvious, you're free to consider the restriction of the function to that image. – Jack M Jun 17 '13 at 11:33
• Its not clear what @vadim123 intends to say by, " Hence the codomain gives useful information, but the image is difficult to determine." Is the codomain $\mathbb{C}$ or $\mathbb{R}$? – Michael Levy Apr 16 at 22:40
• @MichaelLevy, you are commenting on a post from 6 years ago. I intended to say that the codomain is $\mathbb{C}$, and the image is some subset of $\mathbb{R}$. – vadim123 Apr 16 at 23:09

Codomain and Image of a function are two completely different concepts. The codomain of a function often has a structure, like being a topological space or something like this. It will be very inconvenient to put all that structure in the image, which is only a set, and often not such a nice one. Taking your example, one could say that for $x \to \infty$ the function converges to $0$; when you just look at the image of the function it can't converge to $0$ at all because $0$ is not in the image. And definitions like the pointwise addition of two functions will be much broader as it is sometimes hard to say what is the image of the sum of two functions.

• This is not so bad with statements like "the image is a subset of $X$" where $X$ is some set in which addition or convergence make sense. – Ben Millwood May 19 '13 at 17:08
• What kind of structure will the image of a set-function have in general? – Ittay Weiss May 19 '13 at 18:14

You cannot speak about surjectivity (that is, whether it is onto) otherwise. If we would define the codomain of every function to be its image, then every function would be surjective.

• I don't think this is a serious objection. Why do you care about surjectivity? – Ben Millwood May 19 '13 at 15:53
• @Ben I don't think this is a serious meta-objection. Why do you doubt that surjectivity is an important notion? – Trevor Wilson May 19 '13 at 15:59
• @BenMillwood: The objection is mostly cosmetic I suppose. One could rephrase every question "is this function surjective?" to "is the image of this function the following set?" and every question "is this function invertible?" to "is this function invertible and if so, is its domain the following set?". These are common questions to ask, and it would make formulations less elegant. – Samuel May 19 '13 at 16:02
• Right. I don't doubt that surjectivity is important, but I do doubt that it's obvious why it's important, or that it's clearly impossible to get its benefits just talking directly about images. Plus, I sort of think that most of the reason I like codomains is so that I don't have to worry about whether or not a function is surjective, so it's odd to cite surjectivity as a motivator here. – Ben Millwood May 19 '13 at 16:10
• @Ben Ok, that makes sense. I was thinking of surjectivity as one of a class of examples where codomains make statements simpler (as in my answer below.) – Trevor Wilson May 19 '13 at 16:12

What is a function? Informally, it is a process, or an assignment, from an input set to an output set. It is not just the process or assignment that forms a function, but specifying the input and output is part of what it is. Formally, a function is a triple $(A,B,f)$ where $A,B$ are sets and $f\subseteq A\times B$ is a subset of the cartesian product, i.e., a relation from $A$ $to$ $B$. If instead one wanted to view the function $(A,B,f)$ as equivalent to $(A,Im(f),f)$ then one needs to add a condition to an otherwise very clean definition. So, to force the codomain to be the range actually burdens the definition rather than simplify things. That is one reason not to force such things.

Another reason is so that one has no problems talking about composition when it's obvious one should be able to talk about composition (so actually this is a category theoretic reasoning). Suppose that $f:A\to B$ and $g:B\to C$. If I want to know if the composition $g\circ f$ exists I don't care what the actual range of the functions is. Just a glance as the domain of $g$ and the (ta ta ta taaaaaa) codomain of $f$. In other words, if the input type of $g$ matches the output type of $f$, then the composition is defined.

If we insisted that codomain=range, then the condition above will have to be replaced by "the range of $f$ is contained in the domain of $g$". And now I'll get into a bit of technical lingo from category theory. The resulting category from forcing codomain=range will be the category $Set_{Surj}$ of sets and surjections. It's a perfectly legit category, but it has far fewer nice properties when compared to $Set$, the category of sets and all functions. For instance, the empty set is characterized in $Set$ as an initial object (i.e., there is precisely one function from it to any other given set) and is dual to singletons, which are terminal. This is no longer the case in $Set_{Surj}$. The disjoint union of two (or more) sets is an example of a categorical product in $Set$, and is dual to the cartesian product. Disjoint unions are no longer coproducts in $Set_{Surj}$. Many other of the nice properties of $Set$ are lost if passing to $Set_{Surj}$.

In particular, many very convenient injections will no longer be allowed if we require all functions to be surjective. For instance, it is very convenient to be able to speak of the functions $f_y:\mathbb R \to \mathbb R^2$, given by $f(x)=(x,y)$, or various curves in the plane being parametrized by some function $\gamma:[a,b]\to \mathbb R^2$.

• Regarding the first paragraph, wouldn't the cleanest definition of all simply say "a function is a set of ordered pairs such that..."? – Trevor Wilson May 19 '13 at 20:07
• @TrevorWilson ordered pairs of what? (answer: of some domain set $A$ and codomain set $B$). – Ittay Weiss May 19 '13 at 20:13
• You have answered your own question, but allow me to give my own answer: ordered pairs of sets. – Trevor Wilson May 19 '13 at 20:17
• One definition goes in its entirety as follows: a function is a set $f$ of ordered pairs such that for all $x$, $y$, and $z$, if $(x,y) \in f$ and $(x,z) \in f$ then $y=z$. – Trevor Wilson May 19 '13 at 20:19
• @TrevorWilson It seems that you are working axiomatically. Then how do you define ordered pairs? I think that if you will make everything precise you'll end up with a somewhat more convoluted definition of function than what initially appears. – Ittay Weiss May 19 '13 at 20:47

The most obvious reason is just that it's impractical. The image may be difficult to write down. Say for example we consider $f(x) = \frac{x^3}{1+e^x}$.

In order to define the image I have to work out the maximum, which involves solving $f'(x) = 0$. But I can't differentiate $f(x)$ until I've defined it. So I need to define a co-domain before the image makes sense.

The other good reason is that we're often interested in sets of functions. So I might talk about $C^1(\mathbb R)$ which is the set of functions $\mathbb R\to\mathbb R$ with a continuous first derivative.

To construct the set I'm interested in we need to talk about the co-domain. My function $f\in C^1(\mathbb R)$ but it wouldn't be if I had to define $C^1(\mathbb R)$ as functions whose image was $\mathbb R$.

So although the image can be important the co-domain is necessary too.

• I like the other good reason the most. As well as sets of functions, we like to say things like "for any real-valued function $f$..." and "a function from $X$ to $Y$ is continuous if..." which would get awkward if we kept on talking about functions-to-subsets-of. – Ben Millwood May 19 '13 at 16:08

I think the point of a co-domain is so we can say things like

• $f : X \to Y$ is a surjection, as in Samuel's answer

• $j : V \to M$ is an elementary embedding (of structures)

• $f : X \to Y$ is an embedding (of topological spaces).

Considering a function as a statement about ordered pairs, these statements are not just statements about $f$, but also about the given codomains. If we wanted to say the same things without using the notion of co-domain, we could say things like

• $f$ is a function on $X$ whose range is $Y$

• $j$ is an embedding from $V$ to an elementary substructure of $M$

• $f$ is a homeomorphism from $X$ to a subspace of $Y$.

However, such statements are often more cumbersome than the natural formulations using co-domains.

As I see it, the codomain of a function $f$ sets up a context in which the function operates, and tells you what sort of operations you can use to build and inspect the value of $f(x)$. So if I have that $f : \mathbb{R} \to \mathbb{R}$, then I know I can use addition, multiplication, division, order structure, topological structure, etc. when producing the outputs of $f$.

It might help if you view $f : A \to B$ not as giving $A$ and $B$ as properties of the function $f$, but merely as a statement "$f$ is a function from $A$ to $B$", that is to say, if I know $x \in A$ I can deduce that $f(x) \in B$. Then I have that if $B \subset C$ then $f : A \to C$ is also true. In this sense there is no single codomain; what I will call the codomain depends on what statements of the form $x \in A \implies f(x) \in B$ I can prove or need to prove.

Think also of "$f$ is a group homomorphism from $A$ to $B$", where it's really necessary to specify $B$ to say what it even means for $f$ to be a group homomorphism, likewise "continuous map of topological spaces" and various other examples. Functions frequently have nice properties that are defined with reference to some set or structure, and then when we need to discuss that particular structure, that's the codomain we'll use.

The codomain tells us what possible values a function may take and the image tells us what actual values it takes. We can have many functions to the same codomain and we may distinguish them by their images.

For example, the codomain may represent the total set of names for all objects in some limited context while an individual map may be an assignment of names to a set of particular objects.