# Is codomain whatever we make? [duplicate]

This question already has an answer here:

For example, if I say $f(x) = \ln \left\{ x \right\}$ where $\{ \cdot \}$ denotes the fractional part function. Is there any way to know the codomain of this function?

And Now if I define $f : \mathbb{R} \to \mathbb{R}$, now the codomain is $\mathbb{R}$. So is it safe to say, codomain could be anything we want so long as it contains range, if there isn't a codomain already given?

So, $\sin : \mathbb{R} \to [-1,1]$ is as correct as writing $\sin : \mathbb{R} \to \mathbb{R}$?

So I take it that if domain and codomain aren't given, then I could also say Codomain $\equiv$ Range?

EDIT : What I'm trying to ask is, if it's only a matter of codomain, then every function can be called surjective and conversely every function can be called into function? Which makes it all ambiguous.

I have so many confusions with co-domain, but can anyone just explain me these for the time being? Help is appreciated :)

## marked as duplicate by José Carlos Santos, Matthew Towers, drhab, Mark S., user223391 Jul 29 '18 at 22:02

• Not anything we want, because a function is only well defined if the codomain contains the range. When functions are introduced the codomain is far from always explicit because it often doesn't matter whether it is taken to be the range or a superset of the range. – Oppenede Jul 29 '18 at 13:18
• @Oppenede Yes I meant, co domain could be anything so long as it contains range? – William Jul 29 '18 at 13:19
• Some people define a function $f \colon A \to B$ as a subset $R$ of $A \times B$ such that for any $x \in A$ there exists exactly one $y \in B$ such that $(x, y) \in R$. Then the function $\sin_1 \colon \mathbb R \to [-1, 1]$ is exactly the same thing as the function $\sin_2 \colon \mathbb R \to \mathbb R$, i.e., $\sin_1 = \sin_2$, because they are made of the same pairs. But sometimes it is useful to consider a function $f \colon A \to B$ as a triple $(A, B, R)$, so that we don't forget what the codomain is (actually, the domain could be left out since it can be recovered from $R$). – Luca Bressan Jul 29 '18 at 13:26
• @LucaBressan I think regarding a function as a triple $(A,B,R)$ is the adequate way. Frequently we consider the set $\mathcal{F}(A,B)$ of all functions $A \to B$ (i.e. the morphism set in the category of sets) or suitable subsets of $\mathcal{F}(A,B)$. If we ignore the codomain, this wouldn't make much sense. – Paul Frost Jul 29 '18 at 15:23

There are, unfortunately, two different (though closely related) notions of "function" in common use; I'll call them "function1" and "function2" in this answer, to keep the distinction straight.

A function1 is just a way of producing, from certain inputs, well-defined outputs. Formally, it is a set of ordered pairs $\langle\text{input, output}\rangle$ no two of which have the same first component. A function1 has a domain (the set of all its inputs) and a range (the set of all its outputs) but no codomain.

A function2 is a function1 together with specified (domain and) codomain. I put "domain" in parentheses here because a function1 already has a specific domain; only the codomain is new information in a function2.

There are many functions2 corresponding to any given function1, because we can specify, as the codomain, any superset of the range. I believe this is what you were getting at in the first part of your question.

A function2 is onto if and only if its codomain equals its range. So, given a function1, of the many ways to make it a function2 by specifying a codomain, just one way will make it an onto function2, namely specify the codomain to be the range of the given function1.

It makes no sense to speak of a function1 being onto. It does make sense to speak of a function1 being onto a specific set $S$; this means that the function1 has range $S$, or equivalently that the function1 becomes an onto function2 if we specify $S$ as its codomain.

(In this answer, I've sacrificed grammar in favor of brevity, using the preposition "onto" as if it were an adjective. People who prefer grammar should substitute "surjective" for all but one of my uses of "onto".)