Warning10.1.2.Domain elements are necessarily inputs, but codomain elements are not necessarily outputs.
When we define a function, the domain should either be implicitly clear from the input-output rule, or explicitly stated so that the precise collection of allowable input elements is known.
However, it would be too onerous to do the same for the precise collection of output elements β often when we create a function we wonβt initially know exactly what outputs it will produce. The purpose of stating a codomain is so that it is at least clear what type of output element is produced.
This notation indicates that \(A \) will be the domain and \(B \) will be the codomain for the function named \(f \text{.}\) Of course, the name of the function is an additional piece of information being specified with this notation, but naming a function is optional (though highly recommended!).
Example10.1.3.Defining a function by an input-output formula.
An input-output formula like \(f(x) = \sqrt{x} \) defines a function, but we here need to be careful about the domain. The domain and codomain for this function could be specified as \(\funcdef{f}{\nnegset{\R}}{\R} \text{,}\) where \(\nnegset{\R} \) represents the set of nonnegative real numbers.
Example10.1.4.Correctly stating a domain and codomain.
In the function definition
\begin{equation*}
f\colon \R \to \R,
\qquad
x \mapsto \frac{1}{x^2}\text{,}
\end{equation*}
the first part of the definition tells us the domain (\(\R \)), codomain (again \(\R \)), and a name for the function (\(f \)). The second part tells us the input-output rule, so that
However, on closer inspection we discover that the domain has been incorrectly specified, as \(x=0 \) is not a permissible input for the input-output rule. Instead, we should write
Even though this function will only ever produce positive real numbers as outputs, the codomain is acceptable as stated. It would be more precise to write
Determine the minimum result of the absolute value computations in the previous step. (If \(X \) is empty, there will not be any absolute value computation results to compare, so take \(0 \) as the βmininumβ instead.)
In a first course in calculus a student typically studies only single-variable functions; that is, functions with a single input variable and a single output variable. In subsequent calculus courses a student may study multi-variable functions with multiple input variables, such as
as the proper definition of \(f \) is \(\funcdef{f}{\R^2}{\R} \text{,}\) but the extra brackets convey no additional information and only clutter things up.
A logical statement \(S \) involving statement variables \(p_1, p_2, \dotsc, p_m \) is essentially a multi-variable function \(\funcdef{S}{\Lambda^m}{\Lambda} \) for \(\Lambda = \{ \lgctrue,\, \lgcfalse \} \text{.}\) For example, the statement
Example10.1.9.Graph of a single-variable, real-valued function.
The graph of a function \(\funcdef{f}{\R}{\R} \) is a subset of \(\R \cartprod \R = \R^2 \text{.}\) We usually represent \(\R^2 \) visually as the \(xy \)-plane and the graph \(\funcgraph{f} \subseteq \R^2 \) as a curve in the plane.
In the graph of \(f(x) = x^2 \) above, each point on the curve represents an element of \(\R^2 \) which is in the subset \(\funcgraph{f} \text{.}\) For example, \((-1,1) \in \funcgraph{f} \) but \((-1,\pi) \notin \funcgraph{f} \text{.}\)
Example10.1.11.Graph of a multi-variable, real-valued function.
The graph of a function \(\funcdef{f}{\R^2}{\R} \) is technically a subset of \(\R^2 \cartprod \R \text{,}\) but usually we just think of this as \(\R^3 \text{,}\) or \(3 \)-space. Instead of a curve, such a graph defines a surface in \(\R^3 \text{.}\) For example, the graph of the function \(f(x,y) = x^2 + y^2 \) from ExampleΒ 10.1.7 is a parabolic cone (a cone-like surface with parabolic sides).
Example10.1.12.Graph of a function defined by a list.
To describe the graph of the function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}} \) defined in ExampleΒ 10.1.6, we just need to collect the defined input-output pairs into Cartesian product elements:
Similarly to ExampleΒ 9.5.7, we can also visualize this graph as a set of βpointsβ relative to a set of perpendicular βaxes,β where the horizontal axis represents the domain set and the vertical axis represents the codomain set.
Notice that we have not joined the points in the above visualization with lines or a curve, since the three points pictured are the only points on the graph.
Weβve already encountered the graph of a logical statement: it is usually represented as a truth table. For example, the graph \(\funcgraph{S} \) of the logical statement
Unfortunately, our working definition for function is lacking: what is a βruleβ? Rather than chasing some circle of definitions, we can come up with a better definition by noticing that the graph of a function contains all the necessary information about the function.
Example10.1.15.Formal definition for a single-variable, real-valued function.
We are now defining a function \(\funcdef{f}{\R}{\R} \) to be the subset of the Cartesian plane \(\R^2 \) consisting of the graph of the function. In this case, you can think of the βexactly oneβ requirement as equivalent to the vertical line test: an input value may not produce more than one output value. (Though the βoneβ part of βexactly oneβ captures our requirement that a function be defined on every domain element.)
Does this subset define a function with domain \(\mathscr{N} \) and codomain \(\mathscr{A} \text{?}\) That is, does there exist a function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}} \) such that \(F = \funcgraph{f} \text{?}\) The answer is no, because there is no input-output pair in \(F \) with domain element \(2 \text{.}\) If we attempt to consider a function \(f \) with graph \(\funcgraph{f} = F \text{,}\) we have no way to tell what result \(f(2) \) should return. In other words, such an \(f \) will have been left undefined on element \(2 \text{,}\) which is supposed to be part of the domain.
The set \(F \)does define a function, just not one with domain \(\mathscr{N} \text{.}\) If we consider the smaller set \(\mathscr{N}' = \{1,3\} \text{,}\) then there is a function \(\funcdef{f}{\mathscr{N}'}{\mathscr{A}} \) with \(F = \funcgraph{f} \text{.}\)
Does this subset define a function with domain \(\mathscr{N} \) and codomain \(\mathscr{A} \text{?}\) That is, does there exist a function \(\funcdef{f}{\mathscr{N}}{\mathscr{A}} \) such that \(F = \funcgraph{f} \text{?}\) The answer is no, because there are more than one input-output pairs with domain element \(3 \text{.}\) In other words, a function \(f \) with graph \(\funcgraph{f} = F \) is not well-defined, because we have no way to tell whether \(f(3) \) should be \(a \) or \(d \text{.}\)
Suppose we attempt to define \(\funcdef{f}{\Q}{\Z} \) by \(f(\frac{m}{n}) = m+n \text{.}\) This seems like a valid way to define a function, until we realize that, for example,
This is nonsense, because \(\frac{1}{2} \) and \(\frac{2}{4} \) represent the same element of \(\Q \text{.}\) Thus, rule \(f \) is not well-defined as a function, since to each element of the domain \(\Q \) it associates more than one element of the codomain \(\Z \text{.}\)
Example10.1.19.Seemingly different input-output rules can define the same function.
The functions \(\funcdef{f}{\R}{\R} \text{,}\)\(f(x) = \abs{x} \text{,}\) and \(\funcdef{g}{\R}{\R} \text{,}\)\(g(x) = \sqrt{x^2} \text{,}\) are equal.
Warning10.1.21.Codomain elements are not necessarily image elements.
We have stated before that a codomain in a function definition may be βlargerβ than necessary because we do not always know precisely what output elements a given input-output rule will produce. Our idea of codomain is that it should at least tell us what βtypeβ of outputs will be produced, but not necessarily exactly what outputs will be produced.
With our new concept of function image, we can now repeat this more technically: a function image is always a subset of the codomain, but it might be a proper subset.
How do we know if a codomain element is an image element?
For function \(\funcdef{f}{A}{B} \) and codomain element \(b\in B \text{,}\) we have \(b \in f(A) \) if and only if there exists \(a\in A \) such that \(b = f(a) \text{.}\)
Worked Example10.1.22.Verifying a function image description.
Consider \(\funcdef{f}{\R}{\R} \text{,}\)\(f(x) = x^2 \text{.}\) Prove \(f(\R) = \nnegset{\R} \text{,}\) where \(\nnegset{\R} \) is the set of nonnegative real numbers.
Let \(y \) represent an arbitrary element of \(f(\R) \text{.}\) As an element of the image of \(f \text{,}\)\(y \) is an output corresponding to some input. That is, there exists some \(x \in \R \) such that
\begin{equation*}
y = f(x) = x^2 \text{.}
\end{equation*}
Therefore, since square numbers are always positive, we have \(y \ge 0 \text{,}\) and hence \(y \in \nnegset{\R} \text{.}\)
Let \(y \) represent an arbitrary element of \(\nnegset{\R} \text{.}\) To show \(y \in f(\R) \text{,}\) we need to find \(x \in \R \) such that \(f(x) = y \text{.}\) Let \(x = \sqrt{y} \text{,}\) which is defined since \(y \in \nnegset{\R} \) implies \(y\ge 0 \text{.}\) Then
\begin{equation*}
f(x) = x^2 = (\sqrt{y})^2 = y \text{,}
\end{equation*}
We saw in Worked ExampleΒ 10.1.22 that for \(\funcdef{f}{\R}{\R} \text{,}\)\(f(x) = x^2 \text{,}\) we have \(f(\R) = \nnegset{\R} \text{.}\) Now, the set of integers \(\Z \) is a subset of the domain \(\R \text{,}\) so we can compute