1.3: Functions
Like sets, functions are ubiquitous in mathematics.
Let \(X\) and \(Y\) be sets. A function \(f\) from \(X\) to \(Y\) , denoted by \(f: X \rightarrow Y\) , is an assignment of exactly one element of \(Y\) to each element of \(X\) .
For each element \(x \in X\) , the function \(f\) associates or selects a unique element \(y \in Y\) . The uniqueness condition does not allow \(x\) to be assigned to distinct elements of \(Y\) . It does allow different elements of \(X\) to be assigned to the same element of \(Y\) however. It is important to your understanding of functions that you consider this point carefully. The following examples may help illustrate this.
Let \(f: \mathbb{Z} \rightarrow \mathbb{R}\) be given by \[f(x)=x^{2} .\] Then \(f\) is a function in which the element of \(\mathbb{R}\) assigned to the element \(x\) of \(\mathbb{Z}\) is specified by the expression \(x^{2}\) . For instance \(f\) assigns 9 to the integer 3 . We express this by writing \[f(3)=9 \text {. }\] Observe that not every real number is assigned to a number from \(\mathbb{Z}\) . Furthermore, observe that 4 is assigned to both 2 and \(-2\) . Check that \(f\) does satisfy the definition of a function.
Let \(g: \mathbb{R} \rightarrow \mathbb{R}\) be defined by \(g(x)=\tan (x)\) . Then \(g\) is not a function, because it is not defined when \(x=\pi / 2\) (or whenever \(x-\pi / 2\) is an integer multiple of \(\pi\) ). This can be fixed by defining \[X=\mathbb{R} \backslash\{\pi / 2+k \pi \mid k \in \mathbb{Z}\} .\] Then \(\tan : X \rightarrow \mathbb{R}\) is a function from \(X\) to \(\mathbb{R}\) . ExAMPLE 1.11. Consider two rules, \(f, g: \mathbb{R} \rightarrow \mathbb{R}\) , defined by \[\begin{array}{ll} f(x)=y & \text { if } 3 x=2-y \\ g(x)=y & \text { if } x=y^{4} . \end{array}\] Then \(f\) is a function, and can be given explicitly as \(f(x)=2-3 x\) . But \(g\) does not define a function, because \(e . g\) . when \(x=16\) , then \(g(x)\) could be either 2 or \(-2\) .
Let \(f: X \rightarrow Y\) . If \(a \in X\) , then the element of \(Y\) that \(f\) assigns to \(a\) is denoted by \(f(a)\) , and is called the image of \(a\) under \(f\) .
The notation \(f: X \rightarrow Y\) is a statement that \(f\) is a function from \(X\) to \(Y\) . This statement has as a consequence that for every \(a \in X\) , \(f(a)\) is a specific element of \(Y\) . We give an alternative characterization of functions based on Cartesian products.
Let \(f: X \rightarrow Y\) . The graph of \(f, \operatorname{graph}(f)\) , is \[\{(x, y) \mid x \in X \text { and } f(x)=y\} .\] ExAmPLE 1.12. Let \(X \subseteq \mathbb{R}\) and \(f: X \rightarrow \mathbb{R}\) be defined by \(f(x)=\) \(-x\) . Then the graph of \(f\) is \[\{(x,-x) \mid x \in X\} .\] ExAmPLE 1.13. The empty function \(f\) is the function with empty graph (that is the graph of \(f\) is the empty set). This means \(f: \emptyset \rightarrow Y\) for some set \(Y\) .
If \(f: X \rightarrow Y\) , then, \[\operatorname{graph}(f) \subseteq X \times Y \text {. }\] Let \(Z \subseteq X \times Y\) . Then \(Z\) is the graph of a function from \(X\) to \(Y\) if
(i) for any \(x \in X\) , there is some \(y\) in \(Y\) such that \((x, y) \in Z\)
(ii) if \((x, y)\) is in \(Z\) and \((x, z)\) is in \(Z\) , then \(y=z\) . Suppose \(X\) and \(Y\) are subsets of \(\mathbb{R}\) . Then Condition (i) is the condition that every vertical line through a point of \(X\) cuts the graph at least once. Condition (ii) is the condition that every vertical line through a point of \(X\) cuts the graph at most once.
Let \(f: X \rightarrow Y\) . The set \(X\) is called the domain of \(f\) , and is written \(\operatorname{Dom}(f)\) . The set \(Y\) is called the codomain of \(f\) .
The domain of a function is a necessary component of the definition of a function. The codomain is a bit more subtle. If you think of functions as sets of ordered pairs, i.e. if you identified the function with its graph, then every function would have many possible codomains (take any superset of the original codomain). Set theorists think of functions this way, and if functions are considered as sets, extensionality requires that functions with the same graph are identical. However, this convention would make a discussion of surjections clumsy (see below), so we shall not adopt it.
When you write \[f: X \rightarrow Y\] you are explicitly naming the intended codomain, and this makes the codomain a crucial part of the definition of the function. You are indicating to the reader that your definition includes more than just the graph of the function. The definition of a function includes three pieces: the domain, the codomain, and the graph.
Let \(f: \mathbb{N} \rightarrow \mathbb{N}\) be defined by \[f(n)=n^{2} .\] Let \(g: \mathbb{N} \rightarrow \mathbb{R}\) be defined by \[g(x)=x^{2} .\] Then \(\operatorname{graph}(f)=\operatorname{graph}(g)\) . If \(h: \mathbb{R} \rightarrow \mathbb{R}\) is defined by \[h(x)=x^{2}\] then \(\operatorname{graph}(f) \subsetneq \operatorname{graph}(h)\) , so \(f \neq h\) and \(g \neq h\) . Although \(\operatorname{graph}(f)=\) \(\operatorname{graph}(g)\) , we consider \(f\) and \(g\) to be different functions because they have different codomains.
Let \(f: X \rightarrow Y\) . The range of \(f, \operatorname{Ran}(f)\) , is \[\{y \in Y \mid \text { for some } x \in X, f(x)=y\} \text {. }\] So if \(f: X \rightarrow Y\) , then \(\operatorname{Ran}(f) \subseteq Y\) , and is precisely the set of images under \(f\) of elements in \(X\) . That is \[\operatorname{Ran}(f)=\{f(x) \mid x \in X\} .\] No proper subset of \(\operatorname{Ran}(f)\) can serve as a codomain for a function that has the same graph as \(f\) .
With the same notation as in Example 1.14, we have \(\operatorname{Ran}(f)=\operatorname{Ran}(g)=\left\{n \in \mathbb{N} \mid n=k^{2}\right.\) for some \(\left.k \in \mathbb{N}\right\}\) . The range of \(h\) is \([0, \infty)\) .
Let \(f: X \rightarrow Y\) . If \(\operatorname{Ran}(f) \subseteq \mathbb{R}\) , we say that \(f\) is real-valued. If \(X \subseteq \mathbb{R}\) and \(f\) is a real-valued function, then we call \(f\) a real function.
It is sometimes said that a function is a rule that assigns, to each element of a given set, some element from another set. If, by a rule, one means an instruction of some sort, you will see in Chapter 6 that there are "more" functions that cannot be characterized by rules than there are functions that can be. In practice, however, most of the functions we use are defined by rules.
If a function is given by a rule, it is common to write it in the form \[\begin{aligned} f: X & \rightarrow Y \\ x & \mapsto f(x) . \end{aligned}\] The symbol \(\mapsto\) is read "is mapped to". For example, the function \(g\) in the previous example could be defined by \[\begin{aligned} g: \mathbb{N} & \rightarrow \mathbb{R} \\ n & \mapsto n^{2} . \end{aligned}\] ExAMPLE 1.16. The function \[\begin{aligned} f: \mathbb{R} & \rightarrow \mathbb{R} \\ x & \mapsto \begin{cases}0 & x<0 \\ x+1 & x \geq 0\end{cases} \end{aligned}\] is defined by a rule, even though to apply the rule to a given \(x\) you must first check where in the domain \(x\) lies.
When a real function is defined by a rule and the domain is not explicitly stated, it is taken to be the largest set for which the rule is defined. This is the usual convention in calculus: real functions are defined by mathematical expressions and it is understood that the implicit domain of a function is the largest subset of \(\mathbb{R}\) for which the expression makes sense. The codomain of a real function is assumed to be \(\mathbb{R}\) unless explicitly stated otherwise.
Let \(f(x)=\sqrt{x}\) be a real function. The domain of the function is assumed to be \[\{x \in \mathbb{R} \mid x \geq 0\} .\] DEFINITION. Operation Let \(X\) be a set, and \(n \in \mathbb{N}^{+}\) . An operation on \(X\) is a function from \(X^{n}\) to \(X\) .
Operations may be thought of as means of combining elements of a set to produce new elements of the set. The most common operations are binary operations (when \(n=2\) ).
\(+\) and \(\cdot\) are binary operations on \(\mathbb{N}\) .
\(-\)and \(\div\) are not operations on \(\mathbb{N}\) .
Let \(X=\mathbb{R}^{3}\) , thought of as the set of 3 -vectors. The function \(x \mapsto-x\) is a unary operation on \(X\) , the function \((x, y) \mapsto x+y\) is a binary operation, and the function \((x, y, z) \mapsto x \times y \times z\) is a ternary operation. If \(f: X \rightarrow Y, g: X \rightarrow Y\) , and \(\star\) is a binary operation on \(Y\) , then there is a natural way to define a new function on \(X\) using \(\star\) . Define \(f \star g\) by \[\begin{aligned} f \star g: X & \rightarrow Y \\ (f \star g)(x) &=f(x) \star g(x) . \end{aligned}\] ExAMPLE 1.20. Suppose \(f\) is the real function \(f(x)=x^{3}\) , and \(g\) is the real function \(g(x)=3 x^{2}-1\) . Then \(f+g\) is the real function \(x \mapsto x^{3}+3 x^{2}-1\) , and \(f \cdot g\) is the real function \(x \mapsto x^{3}\left(3 x^{2}-1\right)\) .
Another way to build new functions is by composition.
Let \(f: X \rightarrow Y\) and \(g: Y \rightarrow Z\) . Then the composition of \(g\) with \(f\) is the function, \[\begin{aligned} g \circ f: X & \rightarrow Z \\ x & \mapsto g(f(x)) . \end{aligned}\] ExAMPLE 1.21. Let \(f\) be the real function \[f(x)=x^{2} .\] Let \(g\) be the real function \[g(x)=\sqrt{x} .\] Then \[(g \circ f)(x)=|x| .\] What is \(f \circ g\) ? (Be careful about the domain).
Let \[\begin{aligned} f: \mathbb{R} & \rightarrow \mathbb{R} \\ x & \mapsto 2 x+1 \end{aligned}\] and let \[\begin{aligned} g: \mathbb{R}^{2} & \rightarrow \mathbb{R} \\ (x, y) & \mapsto x^{2}+3 y^{2} . \end{aligned}\] Then \[\begin{aligned} f \circ g: \mathbb{R}^{2} & \rightarrow \mathbb{R} \\ (x, y) & \mapsto 2 x^{2}+6 y^{2}+1 . \end{aligned}\] The function \(g \circ f\) is not defined (why?).