I'm a little confused between the difference between the range & co-domain of a function. Are they not the same thing (i.e. all possible outputs of the function)?
-
I'am always confused too regarding domain and range of a function because of the fancy notations anad symbols used. – alok Aug 25 '11 at 09:24
-
In the context of partial bijections $\subset X\times Y$, "Codomain" is not universally used for the the whole $Y$ and sometimes denotes the range. This is the case in the book "Semigroups: An Introduction to the Structure Theory" (p228) by Grillet and in http://www.maths.usyd.edu.au/u/jamese/talks/epx.pdf. I have to admit that when taking of a bijection $D_f\to D'_f$ with $D_f\subset X$ and $D'_f\subset Y$, calling $D_f$ the domain and $Y$ the codomain is quite not intuitive! – YCor Mar 06 '18 at 08:18
5 Answers
I think your confusion may stem from differing uses of terminology.
For a function $f: X \rightarrow Y$, the codomain is just the set $Y$. For instance, if $f: \mathbb{R} \rightarrow \mathbb{R}$ is $x \mapsto x^2$, then the codomain is $\mathbb{R}$. This terminology is agreed upon by all who use it: i.e., I have never seen anyone use the term "codomain" to mean anything else.
Unfortunately the term range is ambiguous. It is sometimes used exactly as codomain is used above, so some say that $\mathbb{R}$ is the range of the squaring function defined above. However, those who use the term codomain at all usually reserve the term "range" for the subset $\{y \in Y \ | \exists x \in X \text{ such that } f(x) = y\}$, i.e., the subset of values which are actually mapped to by some element in the domain. (Some others use the term image for this instead.) So in the above example the image of the function is $[0,\infty)$. Whether the range is $\mathbb{R}$ (i.e., the codomain) or $[0,\infty)$ (i.e., the image) depends upon your convention, and both are rather prevalent.
In practice, this means that it would be safest never to use the term range, instead using codomain and image. (But most people don't do that either...)

- 97,892
-
1
-
4One important reason for the use of codomain is if discussing properties of functions. $f:\mathbb{R}\to \mathbb{R}$, with $f(x)= x^2$ as above is not 'onto', whilst $f:\mathbb{R}\to [0,\infty)$, with $f(x)= x^2$ is. These two functions have different properties so must be different functions.:-), and the use of language where this point is not taken into account leads to a mess. It is also the case, of course, that domain and codomain then play roles that are nearer being dual to each other. – Tim Porter Aug 24 '11 at 17:41
-
1You get to define the codomain when you define the function yourself, just like the domain, right? So can you define the codomain as $[0,\infty)$? If not, can you provide a more specific definition of codomain that explains why? – Kyle Delaney Oct 17 '15 at 03:07
-
1@Kyle: In the context of my example, we have agreed that the function is $f: \mathbb{R} \rightarrow \mathbb{R}, \ x \mapsto x^2$ and then we are just illustrating the terminology. One could also consider the function $g: \mathbb{R} \rightarrow [0,\infty), \ x \mapsto x^2$, but since the codomain is different, $g$ is a different function from $f$. (E.g. $g$ is surjective but $f$ is not.) – Pete L. Clark Oct 17 '15 at 04:08
To add a bit to Pete's and lhf's answer: assuming we are talking about functions from one set to another, there are two common ways of viewing functions:
As sets $f$ such that:
- Every element of $f$ is an ordered pair; and
- If $(x,y)$ and $(x,y')$ are both elements of $f$, then $y=y'$.
When viewing functions this way, the domain is the set: $\{x\mid\text{there exists }y\text{ such that }(x,y)\in f\}$.
We write $f(x)=y$ to mean $(x,y)\in f$. And two functions are equal if and only if they are equal as sets. In this case, when we write $f\colon A\to B$, we mean that $A$ is the domain, and that $B$ is any set such that $\{y\mid \text{there exists }x\text{ such that }(x,y)\in f\}\subseteq B$. Note that the function $f\colon \mathbb{R}\to\mathbb{R}$ and the function $g\colon\mathbb{R}\to\{1,-1\}$ given by $f(x)=g(x)=1$ if $x\geq 0$, $f(x)=g(x)=-1$ if $x\lt 0$ are equal functions, because they are equal as sets.
One problem with this definition is that it makes no real sense to ask if a given function is "surjective", because there is no understood "target set". You have to ask about "surjective onto $B$".
As ordered triples $(A,B,f)$, where $A$ and $B$ are sets, and $f\subseteq A\times B$ is a function in the sense above. $A$ is called the domain, $B$ is called the codomain, and two functions are equal if and only if they have the same domain, the same codomain, and the same value at each element of the domain. This is, I believe, the Bourbaki approach. In this case, the two functions $f$ and $g$ I mentioned above are different, because they have different codomains.
Here, the notion of surjective does make sense, and it provides good duality with the notion of one-to-one (though not complete duality; e.g., "a one-to-one function has a left inverse" only requires you to assume the domain is nonempty, but "an onto function has a right inverse" requires, and in fact is equivalent to, the Axiom of Choice).
This is what leads to the problems of the meaning of "codomain", I think. The codomain of a function only makes sense (in the singular definite article way) in the second definition. The similar set that can be defined uniquely and precisely in the first definition is the image, which would be the dual of the domain: the set $\{y\mid\text{there exists }z\text{ such that }(z,y)\in f\}$. But, being the dual definition, there is a temptation of calling it the "codomain", which clashes with the definition in the second instance.

- 398,050
-
7This is a nice answer. Of course mathematics uses both notions of functions in many places, despite the fact that in certain circumstances one definition or the other will get you in trouble. The idea that two functions which are the same except one of them has a larger codomain are not the same function is at times fishy and at times essential. It is also interesting to note that the "codomain" concept does not really appear in the popular description of a function as a "black box" or as an algorithm. – Pete L. Clark Aug 24 '11 at 17:49
-
-
In the sentence that begins "One problem with this definition is ...", you meant to say it makes no real sense to ask if a function is surjective. – N. F. Taussig Mar 13 '19 at 13:02
-
Enjoyed reading this, thanks. Puts to rest ambiguities that've bothered my subconscious for too long. – Kaj Hansen Aug 05 '19 at 05:20
-
Were it up to me, I actually would have chosen this as the best answer, as it clarifies every possible doubt. I would like to clarify, though, that the term image is even more general than the answer seems to make. One may talk about the image of the domain under a function, which is what people often call the range, but one can talk about the image of subsets of the domain under the function as well. – Angel Nov 04 '21 at 13:32
A function $f: X \to Y$ has $X$ as domain and $Y$ as co-domain. The image of $f$ is the subset of $Y$ given by $F(X)=\{ f(x) : x\in X \} \subseteq Y$, that is, the set of values taken by $f$. When $F(X)=Y$, we say that $f$ is surjective. In general, $F(X)\ne Y$. For example, $\sin: \mathbb R \to \mathbb R$ is not surjective but $\sin: \mathbb R \to \mathbb [-1,1]$ is.
As mentioned in wikipedia, some people use range for co-domain, others for image. I think it's best to avoid range altogether.

- 216,483
Example: a codomain could be as big as all real numbers, but the range is the exact set of numbers that are given by the domain.
If there was a domain {1,2,3} with a formula 2x, the range would be every number to each input, so {2,4,6}. it is the exact number of outputs given by the formula and inputs. the codomain of that problem I just gave, however, could be Natural numbers, real numbers, whole numbers, any set that contains those elements 2, 4, 6 inside them.

- 83
- 8
The term codomain is mostly used in an unsound way. Indeed, the majority of mathematics texts define a function as a functional relation, that is: a relation (set of ordered pairs) in which no two pairs have the same first member. Given a function f, the set of the first elements of all pairs in f is uniformly called the domain of f; for the set of second elements, various names coexist, including codomain, range, image. By the ISO standard, the notation f : A -> B declares a function f with domain A and range included in B. Many texts call B the codomain of f, which is unsound because B is not uniquely defined by f. In any case, the term codomain is not used by Bourbaki (see Theorie des Ensembles). Bourbaki defines a function in two ways, (i) as a triple (F, A, B) where F is a functional relation with domain A and range included in B, (ii) simply as a functional relation (page 77). He disambiguates (p. 76) by calling (F, A, B) an application from A in B. The terms surjective and bijective originate from Bourbaki and make sense only for applications. For functions, one must specify a set, e.g., bijective on B (see Exner, An Accompaniment to Higher Mathematics).

- 105
-
2I completely disagree. The majority of mathematics texts don't include any definition of the word "function", and either (1) implicitly use the letter $f$ to refer to the triple $(f,A,B)$, where $A$ and $B$ have been specified, or (2) simply move back and forth between the two definitions as convenient. Absolutely nothing about this is unsound. By way of analogy, when books say "Let $G$ be a group", it is understood that the underlying set $G$ is being used as a shorthand for the pair $(G,,\cdot,)$ where ${\cdot},:G\times G\to G$ is the operation of the group. – Zev Chonoles Aug 28 '15 at 13:45
-
Before being so hasty, look at the literature. I'll send you an annotated bibliography based on a random sample of about 50 texts. Since we're on the "implicit" tour, obviously I implicitly meant: the majority of contemporary math texts providing a definition for function at all (otherwise, they can always weasel out precisely in the manner you described). The texts defining function and codomain as described cause definite unsoundness. – Raymond Aug 29 '15 at 17:20
-
(addendum) (a) Googling "codomain" yields a huge number of sources essentially defining "function" as a functional set of pairs, and "codomain" as the set B in f : A -> B. This is unsound since B is not fully determined by f. As in the ISO standard, all that f : A -> B says about B is that it includes the range/image of f. (b) item (1) in Zev's note is up to interpretation, and hence not amenable to clear discussion. (c) Re. item (2): no one ever gave an example showing that the (unnecessarily complex) triples definition yields any convenience beyond what the ISO definition already implies. – Raymond Aug 30 '15 at 07:13
-
Raymond, they will not know that you replied to them because they won't get any notification at all. You have to "tag" them as @ZevChonoles: sth. – ultralegend5385 Apr 09 '21 at 10:08
-
@ZevChonoles Well, I believe you need to get more acquainted with the mathematical literature, then. – Angel Nov 04 '21 at 13:34
-
1@Angel: Raymond apparently prefers to use only the word application to describe a function whose codomain has been specified. Anyone acquainted with the mathematical literature (including you, me, and Raymond) knows that it does not follow that preference, and uses the word function in two slightly different senses (as Arturo explains elegantly in his answer on this question: https://math.stackexchange.com/a/59503/264). The problem here is that Raymond decided that everyone else's mathematical work is "unsound" because they're using the word function in a way Raymond doesn't like. – Zev Chonoles Nov 04 '21 at 15:31
-
1Incidentally, the neologism application (as opposed to function) is not the only thing created by Bourbaki that never caught on (e.g. https://math.stackexchange.com/q/25761/264, https://mathoverflow.net/q/16971/1916). If Raymond wants one thing to take away from Bourbaki, I would suggest: "As far as possible we have drawn attention in the text to abuse of language, without which any mathematical text runs the risk of pedantry not to say unreadability." – Zev Chonoles Nov 04 '21 at 15:51
-
@ZevChonoles The answer by Pete L. Clark shows in https://mathoverflow.net/questions/16971/compact-and-quasi-compact why the terminology used by Bourbaki is not as unpopular as you say it is. So this is a bit disingenuous on your part. But it gets worse, because bringing up terminology that Bourbaki invented that never caught on is irrelevant: it proves nothing. Raymond never said the mathematical literature utilizes the term "application" as a standard convention. He specifically attributed it to Bourbaki, and he acknowledged this is not conventional terminology. – Angel Nov 04 '21 at 16:43
-
1@Angel: I wonder if you find anything disingenuous about
The term codomain is mostly used in an unsound way.
– Zev Chonoles Nov 04 '21 at 18:23 -
1Let's take a look at
By the ISO standard, the notation f : A -> B declares a function f with domain A and range included in B. Many texts call B the codomain of f, which is unsound because B is not uniquely defined by f.
It is quite clear that $B$ is not uniquely defined by $f$, but it is uniquely defined by the notation $f:A\to B$, and people who say this are correctly using the words function and codomain, just in the way Raymond doesn't like. But apparently this isunsound
. – Zev Chonoles Nov 04 '21 at 18:26 -
@ZevChonoles I wonder if you find anything disingenuous about... Disingenuous and inaccurate are far from the same thing. – Angel Nov 04 '21 at 18:42
-
It is quite clear that $B$ is not uniquely defined by $f$, but it is uniquely defined by the notation $f:A→B$, and people who say this are correctly using the words function and codomain, just in the way Raymond doesn't like. I am not sure what your objection even is. It sounds to me like you are antagonizing for the sake of. And frankly, if you want a full-blown conversation on this, you should just move this to the chat. – Angel Nov 04 '21 at 18:45