# a function must have to consider about its domain and codomain?

From the book principle of mathematical analysis define 2.1:

Consider two sets $$A$$ and $$B$$, whose elements may be any objects whatsoever, and suppose that with each element $$x$$ of $$A$$ there is associated, in some manner, an element of $$B$$, which we denote by $$f(x)$$. $$f$$ is said to be a function from A to B(or a mapping of A into B )

My understanding: when we talk about a function, formally, we have to specify the domain $$A$$ and the codomain $$B$$.

Example:

1. the function $$f(x)=2x$$, with the domain A=[1,2] and codomain B=[2,4]
2. the function $$f(x)=2x$$, with the domain A=[1,2] and codomain B=[0,100].
3. Strictly, formally, that is two different functions, right?
4. Actually the former one is a surjective function, and the latter is not, right?
• See this discussion Basically, there are two ways of thinking about a function, leading to slightly different issues. – Arturo Magidin May 23 '19 at 17:47
• In your example, isn't $A$ the domain and $B$ the codomain? As for your examples, your assertions are correct. – John Douma May 23 '19 at 19:03
• See also math.stackexchange.com/q/60365. – Paul Frost May 23 '19 at 23:18

Your example is surjective to $$[2,4]$$ but not to any other set.
Anther term is the image of a function $$f$$, which is $$\{y: \exists x\,(\,(x,y)\in f\}$$. Note that "$$\in f \,$$" means "in the graph of $$f$$ ".
• Concerning the set-theoretic concept of a function you are right - unfortunately ;-) I would prefer to define a function as triple $(X,Y,f)$, where $X,Y$ are sets and $f \subset X \times Y$ is a subset with suitable properties. – Paul Frost May 23 '19 at 23:24
• so, if we define a function as a triple $(X, Y, f)$, then $X$ is the domain, $Y$ is the image, and the $f$ is the rule? In this case, we don't care about the codomain that much, and think it as an additional thing of the function. – dawen May 24 '19 at 16:04
• @dawen: No, generally in that formulation, $Y$ is the codomain, a set that contains (but need not be equal to) the image. – Arturo Magidin May 24 '19 at 17:31
• Don't use math mode for italics; math italic is different from regular italic, and hard to read. To get italics, use *: e.g., writing *this* will produce *italics*, and two asterisks yields **boldface** gives: writing this will produce italics, and two asterisks yields boldface. – Arturo Magidin May 24 '19 at 17:40
• OK, so, actually, the domain\codomain\image(which is implicitly in the $f$)\ everything is inside that triple formulation $(X, Y, f)$. And if we just consider the $f$, my example is actually the same function, but if we use the triple formulation, it is not the same function. – dawen May 24 '19 at 18:35