#####
Definition7.1.1Function

A function from a set \(A\) into a set \(B\) is a relation from \(A\) into \(B\) such that each element of \(A\) is related to exactly one element of the set \(B\text{.}\) The set \(A\) is called *domain* of the function and the set \(B\) is called the *codomain*.

The reader should note that a function \(f\) is a relation from \(A\) into \(B\) with two important restrictions:

Each element in the set \(A\text{,}\) the domain of \(f\text{,}\) must be related to some element of \(B\text{,}\) the codomain.

The phrase “is related to exactly one element of the set \(B\)” means that if \((a, b)\in f\) and \((a, c)\in f\), then \(b = c\).

#####
Example7.1.2A function as a list of ordered pairs

Let \(A = \{-2, -1,0, 1, 2\}\) and \(B = \{0, 1, 2, 3, 4\}\), and if \(s = \{(-2, 4), (-1, 1), (0, 0), (1, 1), (2, 4)\}\), then \(s\) is a function from \(A\) into \(B\text{.}\)

#####
Example7.1.3A function as a set of ordered pairs in set-builder notation

Let \(\mathbb{R}\) be the real numbers. Then \(L = \{(x, 3x) \mid x \in \mathbb{R}\}\) is a function from \(\mathbb{R}\) into \(\mathbb{R}\text{,}\) or, more simply, \(L\) is a function on \(\mathbb{R}\text{.}\)

It is customary to use a different system of notation for functions than the one we used for relations. If \(f\) is a function from the set \(A\) into the set \(B\text{,}\) we will write \(f:A \rightarrow B\).

The reader is probably more familiar with the notation for describing functions that is used in basic algebra or calculus courses. For example, \(y =\frac{1}{x}\) or \(f(x) =\frac{1}{x}\) both define the function \(\left\{\left.\left(x,\frac{1}{x}\right)\right| x\in \mathbb{R}, x\neq 0\right\}\). Here the domain was assumed to be those elements of \(\mathbb{R}\) whose substitutions for \(x\) make sense, the nonzero real numbers, and the codomain was assumed to be \(\mathbb{R}\text{.}\) In most cases, we will make a point of listing the domain and codomain in addition to describing what the function does in order to define a function.

The terms *mapping*, *map*, and *transformation* are also used for functions.

One way to imagine a function and what it does is to think of it as a machine. The machine could be mechanical, electronic, hydraulic, or abstract. Imagine that the machine only accepts certain objects as raw materials or input. The possible raw materials make up the domain. Given some input, the machine produces a finished product that depends on the input. The possible finished products that we imagine could come out of this process make up the codomain.

#####
Example7.1.4A definition based on images

We can define a function based on specifying the codomain element to which each domain element is related. For example, \(f: \mathbb{R} \rightarrow \mathbb{R}\) defined by \(f(x) = x^2\) is an alternate description of \(f= \left\{\left.\left(x, x ^2\right)\right|x \in \mathbb{R}\right\}\).

#####
Definition7.1.5Image of an element under a function

Let \(f:A \rightarrow B\), read “Let \(f\) be a function from the set \(A\) into the set \(B\text{.}\)” If \(a \in A\), then \(f(a)\) is used to denote that element of \(B\) to which \(a\) is related. \(f(a)\) is called the *image* of \(a\text{,}\) or, more precisely, the image of \(a\) under \(f\text{.}\) We write \(f(a) = b\) to indicate that the image of \(a\) is \(b\text{.}\)

In Example 7.1.4, the image of 2 under \(f\) is 4; that is, \(f(2) = 4\). In Example 7.1.2, the image of \(-1\) under \(s\) is 1; that is, \(s(-1) = 1\).

#####
Definition7.1.6Range of a Function

The range of a function is the set of images of its domain. If \(f:X \rightarrow Y\text{,}\) then the range of \(f\) is denoted \(f(X)\), and
\begin{equation*}
f(X) = \{f(a) \mid a \in X\} = \{b \in Y \mid \exists a \in X\textrm{ such that } f(a) = b\}\text{.}
\end{equation*}

Note that the range of a function is a subset of its codomain. \(f(X)\) is also read as “the image of the set \(X\) under the function \(f\)” or simply “the image of \(f\text{.}\)”

In Example 7.1.2, \(s(A)= \{0, 1, 4\}\). Notice that 2 and 3 are not images of any element of \(A\text{.}\) In addition, note that both 1 and 4 are related to more than one element of the domain: \(s(1) = s(-1) = 1\) and \(s(2) = s(-2) = 4\). This does not violate the definition of a function. Go back and read the definition if this isn't clear to you.

In Example 7.1.3, the range of \(L\) is equal to its codomain, \(\mathbb{R}\text{.}\) If \(b\) is any real number, we can demonstrate that it belongs to \(L(\mathbb{R})\) by finding a real number \(x\) for which \(L(x) = b\). By the definition of \(L\text{,}\) \(L(x) = 3x\), which leads us to the equation \(3x = b\). This equation always has a solution, \(\frac{b}{3}\); thus \(L(\mathbb{R}) = \mathbb{R}\).

The formula that we used to describe the image of a real number under \(L\text{,}\) \(L(x) = 3x\), is preferred over the set notation for \(L\) due to its brevity. Any time a function can be described with a rule or formula, we will use this form of description. In Example 7.1.2, the image of each element of \(A\) is its square. To describe that fact, we write \(s(a) = a^2\) (\(a \in A\)), or \(S:A \rightarrow B\) defined by \(S(a) = a^2\).

There are many ways that a function can be described. Many factors, such as the complexity of the function, dictate its representation.

#####
Example7.1.7Data as a function

Suppose a survey of 1,000 persons is done asking how many hours of television each watches per day. Consider the function \(W: \{0,1,\ldots , 24\} \rightarrow \{0,1,2,\ldots ,1000\}\) defined by \[W(t) = \textrm{the number of persons who gave a response of } t \textrm{ hours}\] This function will probably have no formula such as the ones for \(s\) and \(L\) above.

#####
Example7.1.8Conditional definiton of a function

Consider the function \(m:\mathbb{P} \rightarrow \mathbb{Q}\) defined by the set
\begin{equation*}
m = \{(1, 1), (2, 1/2), (3, 9), (4, 1/4), (5, 25), . . . \}
\end{equation*}
No simple single formula could describe \(m\text{,}\) but if we assume that the pattern given continues, we can write
\begin{equation*}
m(x) =\left\{
\begin{array}{cc}
x^2 & \textrm{if } x \textrm{ is odd} \\
1/x & \textrm{if } x \textrm{ is even} \\
\end{array}
\right.
\end{equation*}