Online Textbook Practice Tests 1500 Calculus Problems Solved About

0.4: Defining a Function

In mathematics, functions communicate relationships between numbers, enabling us to go from one number to another. How do we describe these functions' properties, and what are their applications? In this section we discuss the following topics:

Defining a Function

Figure 1

A function is a rule that maps one number to another. Formally, a function \(f\) assigns each element \(x\) in some set \(D\) (the domain) to exactly one element, \(f(x),\) in another set \(E\) (the range). We read \(f(x)\) as \(f\) of \(x\); it represents the value of \(f\) at \(x.\) Thus, a function works similarly to a machine: When we input a number \(x\) within \(D\) into the machine, the machine yields an output \(f(x)\) within \(E.\) (See Figure 1.) Accordingly, the domain is the set of all possible inputs and the range is the set of all possible outputs.

DEFINITION OF A FUNCTION
A function \(f\) is a rule that maps each element \(x\) in the domain \(D\) to exactly one element, \(f(x),\) in the range \(E.\)

We have four ways of conveying a function—verbally (through a description in words), visually (through a graph), numerically (through a table of values), and algebraically (through a formula). Graphs are the most common method of visualizing a function: if \(f\) is a function with domain \(D,\) then the graph of \(y = f(x)\) consists of all ordered pairs \[\{(x, f(x)) \mid x \in D\} \pd\] In words, the function \(f\) gives the \(y\)-value at a particular value of \(x\) in the domain.

EXAMPLE 1
If \(f(x) = 8x + 4,\) then find \(f(-2).\)
The function \(f\) maps any number \(x\) to the number \(8x + 4.\) Replacing \(x\) with \(-2\) shows \[f(-2) = 8(-2) + 4 = \boxed{-12}\]
EXAMPLE 2
The graph of \(y = f(x)\) is shown in Figure 2. Find \(f(-2),\) \(f(0),\) and \(f(4).\)
Figure 2
The graph of \(y = f(x)\) includes the points \((-2, -3),\) \((0, 1),\) and \((4, -3).\) [The point \((0, 3)\) is a hole, so it's not on the graph of \(f.\)] So \(\boxed{f(-2) = -3},\) \(\boxed{f(0) = 1},\) and \(\boxed{f(4) = -3}.\)
EXAMPLE 3
The following table shows a town's population at various years. Let \(P(t)\) be the population \(t\) years after 2020. Find and interpret \(P(3).\)
Year 2020 2021 2022 2023 2024
Population \(5600\) \(5750\) \(5900\) \(6200\) \(6600\)
The expression \(P(3)\) is the town's population \(3\) years after 2020—namely, in 2023. From the table, this population is \(6200,\) so \(\boxed{P(3) = 6200}.\)

Plotting a function in the \(xy\)-plane yields a graph. But do all graphs represent functions? The answer is no. A function assigns each \(x\) to exactly one \(y,\) so any vertical line must intersect the graph only once. Otherwise, the graph does not represent a function of \(x.\) This condition is called the Vertical Line Test.

VERTICAL LINE TEST
The Vertical Line Test states that a graph in the \(xy\)-plane represents a function of \(x\) if and only if no vertical line intersects the graph more than once.

In Figure 3A the graph of \(y = x^2 - 4\) represents \(y\) as a function of \(x\) because a vertical line drawn at any \(x = a\) strikes the curve only once at \((a, b).\) Conversely, the graph of \(x = y^2 - 3\) does not represent \(y\) as a function of \(x,\) since a vertical line shown in Figure 3B hits the curve at both \((a, b)\) and \((a, c),\) where \(b \ne c.\)

Figure 3A
Figure 3B

In the next examples, we plot a variety of essential mathematical functions. When we find domains of functions, it's easiest to consider what numbers the inputs cannot be. Then the domain is all real numbers excluding those values, as shown by the following examples.

EXAMPLE 4
Plot the graph of \(y = \sqrt x,\) and give the domain and range.
Figure 4
Let's make a table of values of \(\sqrt x.\) It is easiest to sample the function at perfect squares, as follows. (Note that \(\sqrt 0 = 0.\))
\(x\) \(0\) \(1\) \(4\) \(9\)
\(\sqrt x\) \(0\) \(1\) \(2\) \(3\)
Plotting and connecting these points, we get the graph in Figure 4. Because the square root of a negative number is undefined (as a real number), the domain is \[\{x \mid x \geq 0\} = \boxed{[0, \infty)}\] Since the square root returns nonnegative outputs, the range is \[\{y \mid y \geq 0\} = \boxed{[0, \infty)}\]
EXAMPLE 5
Plot the graph of \(y = 1/x,\) and find the domain and range.
Figure 5
We make a table of values with convenient values of \(x,\) as follows.
\(x\) \(-3\) \(-2\) \(-1\) \(-1/2\) \(1/2\) \(1\) \(2\) \(3\)
\(1/x\) \(-1/3\) \(-1/2\) \(-1\) \(-2\) \(2\) \(1\) \(1/2\) \(1/3\)
Plotting and connecting these points yield the graph in Figure 5. Because division by \(0\) is undefined, \(1/x\) is undefined at \(x = 0.\) Consequently, the domain is \[\{x \mid x \ne 0\} = \boxed{(-\infty, 0) \cup (0, \infty)}\] It's impossible to attain \(0\) through dividing \(1\) by any number \(x,\) so the range is \[\{y \mid y \ne 0\} = \boxed{(-\infty, 0) \cup (0, \infty)}\] The graph of \(y = 1/x\) has a vertical asymptote at \(x = 0,\) meaning the curve becomes unbounded on either side of the line \(x = 0.\) In addition, the graph has a horizontal asymptote at \(y = 0;\) the curve gets closer and closer to this line without crossing it. (We will formally define asymptotes in Chapter 1.)
EXAMPLE 6
Find the domain of each function.
  1. \(\ds f(x) = \sqrt{x - 5}\)
  2. \(\ds g(x) = \frac{1}{x^2 - 4x}\)
  1. The square root of a negative number is undefined (as a real number). Therefore, the domain of \(f\) is all \(x\)-values such that \(x - 5\) is nonnegative—namely, \[ \ba \{x \mid x - 5 \geq 0\} &= \{x \mid x \geq 5\} \nl &= \boxed{[5, \infty)} \ea \]

  2. Recall that division by \(0\) is undefined, so the domain of \(g\) is restricted to all \(x\) such that the denominator is nonzero. The denominator equals \(0\) when \[x^2 - 4x = x(x - 4) = 0 \cma\] whose solutions are \(x = 0\) and \(x = 4.\) Hence, the domain of \(g\) is \[\{x \mid x \ne 0 \text{ and } x \ne 4 \} = \boxed{(-\infty, 0) \cup (0, 4) \cup (4, \infty)}\]

Semicircles Recall, from Section 0.3, that the Cartesian equation of a circle of radius \(r\) centered at the origin is \begin{equation} x^2 + y^2 = r^2 \pd \label{eq:circle-r} \end{equation} (See Figure 6A.) Circles clearly fail the Vertical Line Test, but a function can represent either the top or bottom portion. Solving for \(y\) in \(\eqref{eq:circle-r}\) yields \(y^2 = r^2 - x^2.\) Taking the square root of both sides gives \[ \ba \abs y &= \sqrt{r^2 - x^2} \nl y &= \pm \sqrt{r^2 - x^2} \pd \ea \] Accordingly, we have two solutions: \[y = \sqrt{r^2 - x^2} \and y = -\sqrt{r^2 - x^2} \cma\] which each represent \(y\) as a function of \(x.\) The positive solution, \(y = \sqrt{r^2 - x^2},\) is the upper half of the circle—that is, a semicircle of radius \(r\) above the \(x\)-axis. Likewise, the negative solution, \(y = -\sqrt{r^2 - x^2},\) represents the bottom half of the circle—namely, a semicircle of radius \(r\) below the \(x\)-axis. (See Figure 6B.) Both functions have a domain of \([-r, r]\) to ensure that \(r^2 - x^2 \geq 0\) (otherwise, the argument of the square root is negative).

Figure 6A
Figure 6B
EXAMPLE 7
If \(f(x) = x^2 + x\) and \(h\) is a nonzero constant, then simplify \[\frac{f(x + h) - f(x)}{h} \pd\]
In \(f(x) = x^2 + x,\) replacing \(x\) with \(x + h\) yields \[ \ba f(x + h) &= (x + h)^2 + (x + h) \nl &= x^2 + 2xh + h^2 + x + h \pd \ea \] Then we see \[ \ba \frac{f(x + h) - f(x)}{h} &= \frac{x^2 + 2xh + h^2 + x + h - \par{x^2 + x}}{h} \nl &= \frac{2xh + h^2 + h}{h} \nl &= \boxed{2x + h + 1} \ea \]

Piecewise Functions

A piecewise function is defined by different subfunctions for various parts of its domain. In the following examples, we graph these functions.

Figure 7

Absolute Value Function Recall, from Section 0.2, that taking the absolute value of a number \(a\) removes its negative sign. (For example, \(\abs{-4} = 4.\)) Therefore, the absolute value function \(\abs x\) makes any input \(x\) nonnegative. As discussed in Section , we can define the following piecewise function: \begin{equation} \abs x = \bc x \; \; &x \geq 0 \nl -x \; \; &x \lt 0 \pd \ec \label{eq:abs-cases} \end{equation} Starting in the second quadrant, we graph \(y = -x\) until we reach \(x = 0;\) then we graph \(y = x.\) Doing so yields the graph in Figure 7.

EXAMPLE 8
Graph the piecewise function \[f(x) = \bc 2 \; \; &-6 \leq x \lt -3 \nl x \; \; &-3 \leq x \leq 2 \nl -3 \; \; &\phantom{-} 2 \lt x \lt 5 \pd \ec \]
From \(x = -6\) to \(x = -3,\) the graph of \(f\) is the horizontal line \(y = 2.\) Then from \(x = -3\) to \(x = 2,\) the graph is the oblique line \(y = x.\) Lastly, from \(x = 2\) to \(x = 5,\) the graph is the horizontal line \(y = -3.\) We draw open circles at \((-3, 2),\) \((2, -3),\) and \((5, -3)\) because they are not on the graph of \(f.\) (See Figure 8.)
Figure 8

Even and Odd Functions

Functions can be categorized as even, odd, or neither. A function \(f\) is called even if and only if \(f(-x) = f(x)\) is true for all \(x\) and \(-x\) in the domain. If so, then the graph of \(y = f(x)\) is symmetric about the \(y\)-axis (Figure 9A). In words, the function becomes unchanged if \(x\) is replaced with \(-x.\) Conversely, \(f\) is called odd if and only if \(f(-x) = -f(x)\) is true for all \(x\) and \(-x\) in the domain. Then the graph of \(y = f(x)\) is symmetric about the origin, meaning the point \((x, f(x))\) can be rotated \(180 \degree\) about the origin to attain the point \((-x, f(-x)).\) (See Figure 9B.) Hence, if we already know the graph of \(f\) for \(x \geq 0,\) then the entire graph is acquired by rotating this portion about the origin by \(180 \degree.\)

Figure 9A
Figure 9B
EVEN AND ODD FUNCTIONS
A function \(f\) is
  1. even if and only if \(f(-x) = f(x)\) for all \(x\) and \(-x\) in its domain.
  2. odd if and only if \(f(-x) = -f(x)\) for all \(x\) and \(-x\) in its domain.

For example, the function \(f(x) = x^2\) is even because for all \(x,\) \[f(-x) = (-x)^2 = x^2 = f(x) \pd\] The graph of \(y = x^2\) is called a parabola, a symmetrical U-shaped curve (Figure 10A), which we will study further in Section 0.7. In contrast, the cubic function \(g(x) = x^3\) is odd since for all \(x,\) \[g(-x) = (-x)^3 = -x^3 = -g(x) \pd\] (See Figure 10B.)

Figure 10A
Figure 10B
EXAMPLE 9
Determine whether each function is even, odd, or neither.
  1. \(f(x) = x^4 - 1\)
  2. \(g(x) = x^7 + 4x\)
  3. \(h(x) = x^2 + 6x\)
In each function, let's replace \(x\) with \(-x\) and observe any connections to the original function.
  1. Note that \[ \ba f(-x) &= (-x)^4 - 1 \nl &= x^4 - 1 = f(x) \pd \ea \] Since \(f(-x) = f(x),\) \(f\) is even.

  2. We see \[ \ba g(-x) &= (-x)^7 + 4(-x) \nl &= -x^7 - 4x \nl &= - (x^7 + 4x) = -g(x) \pd \ea \] Because \(g(-x) = -g(x),\) \(g\) is odd.

  3. We observe that \[ \ba h(-x) &= (-x)^2 + 6(-x) \nl &= x^2 - 6x \pd \ea \] But \(h(-x) \ne h(x)\) and \(h(-x) \ne -h(x),\) so \(h\) is neither even nor odd.

Defining a Function A function \(f\) is a mathematical rule that maps each element \(x\) in the domain \(D\) to exactly one element, \(f(x),\) in the range \(E.\) We can describe functions verbally, visually, numerically, or algebraically. The most common way of communicating a function is through a graph, which consists of all ordered pairs \[\{(x, f(x)) \mid x \in D\} \pd\] The Vertical Line Test says that a curve in the \(xy\)-plane represents a function of \(x\) if and only if no vertical line intersects the curve multiple times.

Piecewise Functions A piecewise function is defined by different subfunctions for various parts of its domain. For example, the absolute value function can be defined by \begin{equation} \abs x = \bc x \; \; &x \geq 0 \nl -x \; \; &x \lt 0 \pd \ec \eqlabel{eq:abs-cases} \end{equation}

Even and Odd Functions A function \(f\) is

  1. even if and only if \(f(-x) = f(x)\) for all \(x\) and \(-x\) in its domain.
  2. odd if and only if \(f(-x) = -f(x)\) for all \(x\) and \(-x\) in its domain.

Graphs of even functions are symmetric about the \(y\)-axis. In contrast, graphs of odd functions are symmetric about the origin, meaning \((x, f(x))\) can be rotated \(180 \degree\) about the origin to obtain \((-x, f(-x)).\)