\chapter{The Integral} The subject of Differential Calculus starts with the ``simple'' geometrical idea of the slope of a tangent line to a curve, develops it into a combination of theory about derivatives and their properties, techniques for calculating derivatives, and applications of derivatives. This book begins the development of Integral Calculus and starts with the ``simple'' geometric idea of area. This idea will be developed into another combination of theory, techniques, and applications. The integral will be introduced in two (completely different) way: as a limit of ``Riemann sums'' and as an ``inverse'' of differentiation (``anti-derivative''). Conceptually, one is geometric, or numerical, and the other is somewhat more algebraic. One of the most important results in mathematics, The Fundamental Theorem of Calculus, appears in this chapter. It connects these two notions of the integral and also provides a relationship between differential and integral calculus. Historically, this theorem marked the beginning of modern mathematics, and it provided important tools for the growth and development of the sciences. The chapter begins with a look at area, some geometric properties of areas, and some applications. First we will see ways of approximating the areas of regions such as tree leaves that are bounded by curved edges and the areas of regions bounded by graphs of functions. Then we will find ways to calculate the areas of some of these regions exactly. Finally, we will explore more of the rich variety of uses of ``areas''. The primary purpose of this introductory section is to help develop your intuition about areas and your ability to reason using geometric arguments about area. This type of reasoning will appear often in the rest of this book and is very helpful for applying the ideas of calculus. \section{Area} We know from previous experience how to compute the areas of simple geometrical shapes, like triangles and circles and rectangles. Formulas for these have been known since the days of the ancient Greeks. But, how do you find the area under a ``more complicated'' curve, such as $y=x^2$, $-1 1$. \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3.5cm,width=12cm]{fig8.eps} \end{center} \end{minipage} \caption{The area as a function.} \label{fig:8} \end{figure} Sometimes it is useful to move regions around. The area of a parallelogram is obvious if we move the triangular region from one side of the parallelogram to fill the region on the other side and ending up with a rectangle (Figure \ref{fig:10}). \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=2cm,width=9cm]{fig10.eps} \end{center} \end{minipage} \caption{The area of a parallelogram.} \label{fig:10} \end{figure} At first glance, it is difficult to estimate the total area of the shaded regions in Figure \ref{fig:11}(a). However, if we slide all of them into a single column (Figure \ref{fig:11}(b)), then it is easy to determine that the shaded area is less than the area of the enclosing rectangle = (base)$\times$(height) $= (1)(2) = 2$. \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=8cm]{fig11.eps} \end{center} \end{minipage} \caption{An irregular area.} \label{fig:11} \end{figure} \section{Some applications of area} One reason ``areas'' are so useful is that they can represent quantities other than simple geometric shapes. For example, if the units of the base of a rectangle are ``hours'' and the units of the height are ``miles/hour'', then the units of the ``area'' of the rectangle are (hours)$\times$(miles/hour) = miles, a measure of distance. Similarly, if the base units are centimeters and the height units are grams, then the ``area'' units are gram$\times$centimeters, a measure of work. \begin{example} Distance as an ``area:'' In Figure \ref{fig:14}, $f(t)$ is the velocity of a car in ``miles per hour,'' and $t$ is the time in ``hours.'' Then the shaded ``area'' will be (base)$\times$(height) = (3 hours)$\times$(20 miles/hour ) = 60 miles, the distance traveled by the car in the 3 hours from 1 o'clock until 4 o'clock. \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=8cm]{fig14.eps} \end{center} \end{minipage} \caption{Distance as ``area''.} \label{fig:14} \end{figure} \end{example} Here is the general statement of the idea illustrated in the example above. \begin{theorem} (``Area'' as Distance) If $f(t)$ is the (positive) forward velocity of an object at time $t$, then the ``area'' between the graph of $f$ and the $t$-–axis and the vertical lines at times $t = a$ and $t = b$ will be the distance that the object has moved forward between times $a$ and $b$. \end{theorem} This ``area as distance'' fact can make some difficult distance problems much easier. \begin{example} A car starts from rest (velocity = 0) and steadily speeds up so that 20 seconds later it's speed is 88 feet per second (60 miles per hour). How far did the car travel during those 20 seconds? Solution: If ``steadily speeds up'' means that the velocity increases linearly, then the idea of ``area as distance'' is applicable. The ``area'' of the triangular region (Figure \ref{fig:15}) represents the distance traveled, so \[ \begin{array}{ll} {\rm distance} & = \frac{1}{2} ({\rm base}) \times({\rm height}) \\ & = \frac{1}{2} (20\ {\rm seconds}) \times(88\ {\rm feet/second})\\ & = 880\ {\rm feet}. \end{array} \] \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=8cm]{fig15.eps} \end{center} \end{minipage} \caption{Distance a car travels as ``area''.} \label{fig:15} \end{figure} \end{example} \begin{practice} A train traveling at 45 miles per hour (66 feet/second) takes 60 seconds to come to a complete stop. If the train slowed down at a steady rate (the velocity decreased linearly), how many feet did the train travel while coming to a stop? \end{practice} \begin{practice} \label{prac:16} You and a friend start off at noon and walk in the same direction along the same path at the rates shown in Figure \ref{fig:16}. \begin{itemize} \item Who is walking faster at 2 pm? Who is ahead at 2 pm? \item Who is walking faster at 3 pm? Who is ahead at 3 pm? \item When will you and your friend be together? (Answer in words.) \end{itemize} \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=4cm]{fig16.eps} \end{center} \end{minipage} \caption{Illustration for Practice \ref{prac:16}.} \label{fig:16} \end{figure} \end{practice} \subsection{Total Accumulation as ``Area''} In the previous examples, the function represented a rate of travel (miles per hour), and the area represented the total distance traveled. For functions representing other rates such as the production of a factory (bicycles per day), or the flow of water in a river (gallons per minute) or traffic over a bridge (cars per minute), or the spread of a disease (newly sick people per week), the area will still represent the total amount of something. \begin{theorem} (``Area'' as Total Accumulation) If $f(t)$ represents a positive rate (in units per time interval) at time $t$, then the ``area'' between the graph of $f$ and the $t$-–axis and the vertical lines at times $t=a$ and $t=b$ will be the total units which accumulate between times $a$ and $b$. \end{theorem} \begin{practice} \label{prac:19} Figure \ref{fig:19} shows the number of telephone calls made per hour on a Tuesday. Approximately how many calls were made between 9 am and 11 am? \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=4cm]{fig19.eps} \end{center} \end{minipage} \caption{Illustration for Practice \ref{prac:19}.} \label{fig:19} \end{figure} \end{practice} \subsection{Problems} \begin{enumerate} \item \begin{itemize} \item[(a)] Calculate the sum of the rectangular areas in Figure \ref{fig:24}(a). \item[(b)] From part (a), what can we say about the area of the shaded region in Figure \ref{fig:24}(b)? \end{itemize} \item \begin{itemize} \item[(a)] Calculate the sum of the areas of the shaded regions in Figure \ref{fig:24}(c). \item[(b)] From part (a), what can we say about the area of the shaded region in Figure \ref{fig:24}(b)? \end{itemize} \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3.5cm,width=8cm]{fig24.eps} \end{center} \end{minipage} \caption{Estimating areas.} \label{fig:24} \end{figure} \item Let $A(x)$ represent the area bounded by the graph and the horizontal axis and vertical lines at $t=0$ and $t=x$ for the graph in Fig. 25. Evaluate $A(x)$ for $x = 1$, $2$, $3$, $4$, and $5$. \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=2cm,width=5cm]{fig25.eps} \end{center} \end{minipage} \caption{Computing areas.} \label{fig:25} \end{figure} \item Police chase: A speeder traveling 45 miles per hour (in a 25 mph zone) passes a stopped police car which immediately takes off after the speeder. If the police car speeds up steadily to 60 miles/hour in 20 seconds and then travels at a steady 60 miles/hour, how long and how far before the police car catches the speeder who continued traveling at 45 miles/hour? (Figure \ref{fig:32}) \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=7.5cm]{fig32.eps} \end{center} \end{minipage} \caption{Computing areas.} \label{fig:32} \end{figure} \item What are the units for the ``area'' of a rectangle with the given base and height units? \begin{center} \begin{tabular}{|c|c|c|} \hline Base units & Height units & ``Area'' units\\ \hline miles per second & seconds & \\ hours & dollars per hour& \\ square feet & feet& \\ kilowatts & hours& \\ houses & people per house& \\ meals & meals& \\ \hline \end{tabular} \end{center} \end{enumerate} \section{Sigma notation and Riemann sums} One strategy for calculating the area of a region is to cut the region into simple shapes, calculate the area of each simple shape, and then add these smaller areas together to get the area of the whole region. We will use that approach, but it is useful to have a notation for adding a lot of values together: the sigma ($\Sigma$) notation. The function to the right of the sigma is called the {\bf summand}, and the numbers below and above the sigma are called the {\bf lower} and {\bf upper limits} of the summation. (Figure \ref{fig:4-1}) \index{summand} \index{Sigma notation} \index{summation notation} \begin{figure}[h] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=7cm,width=6cm]{fig4-1.eps} \end{center} \end{minipage} \caption{Summation notation.} \label{fig:4-1} \end{figure} \begin{center} \begin{tabular}{|c|c|c|} \hline Summation & A way to read & Sigma \\ notation & the sigma notation ¬ation \\ \hline $1^2+2^2+3^2+4^2+5^2$ & the sum of $k$ squared & $\sum_{k=1}^5 k^2$\\ & for $k$ equals $1$ to $k$ equals $5$ & \\ $\frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} + \frac{1}{7}$ & the sum of $1$ over $k$ & $\sum_{k=3}^7 k^{-1}$ \\ & for $k$ equals $3$ to $k$ equals $7$ & \\ $2^0+2^1+2^2+2^3+2^4+2^5$ & the sum of $2$ to the $j$-th power & $\sum_{j=0}^5 2^j$ \\ & for $j$ equals $0$ to $j$ equals $5$ & \\ $a_2+a_3+a_4+a_5+a_6+a_7$ & the sum of $a$ sub $i$ & $\sum_{i=2}^7 a_i$ \\ & for $i$ equals $2$ to $i$ equals $7$ & \\ \hline \end{tabular} \end{center} The variable (typically $i$, $j$, or $k$) used in the summation is called the {\bf counter} or {\bf index variable}. \index{index variable} \begin{practice} Write the summation denoted by each of the following: \begin{center} (a) \quad $\sum_{k=1}^5 k^3$,\quad (b) \quad $\sum_{j=2}^7 (-1)^j\frac{1}{j}$,\quad (c) \quad $\sum_{m=0}^4 (2m+1)$. \end{center} \end{practice} In practice, the sigma notation is frequently used with the standard function notation: \[ \sum_{k=1}^3 f(k+2) = f(1+2) + f(2+2) + f(3+2) = f(3) + f(4) + f(5) \] and \[ \sum_{k=1}^4 f(x_i) = f(x_1) + f(x_2) + f(x_3) + f(x_4). \] \begin{figure} \begin{center} \begin{tabular}{|c|c|c|c|} \hline $x$ & $f(x)$ & $g(x)$ & $h(x)$ \\ \hline 1 & 2 & 4 & 3 \\ 2 & 3 & 1 & 3 \\ 3 & 1 & –2 & 3 \\ 4 & 0 & 3 & 3 \\ 5 & 3 & 5 & 3 \\ \hline \end{tabular} \end{center} \caption{Table for Example \ref{ex:table1}.} \label{fig:table1} \end{figure} \begin{example} \label{ex:table1} Use the values in Table \ref{fig:table1} to evaluate $\sum_{k=2}^5 2f(k)$ and $\sum_{j=3}^5 (5+f(j-2))$. Solution: $\sum_{k=2}^5 2f(k) = 2f(2) + 2f(3) + 2f(4) + 2f(5) = 2(3) + 2(1) + 2 (0) + 2 (3) = 14$. $\sum_{j=3}^5 (5+f(j-2)) = (5+f(3–2)) + (5+f(4–2)) + (5+f(5–2)) = (5+f(1)) + (5+f(2)) + (5+f(3)) = (5+2) + (5+3) + (5+1) = 21$. \end{example} \begin{practice} Use the values of $f$, $g$ and $h$ in Table \ref{fig:table1} to evaluate the following: \[ (a)\quad \sum_{k=2}^5 g(k),\quad (b)\quad \sum_{j=1}^4 h(j),\quad (c)\quad \sum_{i=3}^5 [f(i-1)+g(i)]. \] \end{practice} Since the sigma notation is simply a notation for addition, it has all of the familiar properties of addition. \begin{theorem} \label{thrm:sum-prop} (Summation Properties) \begin{itemize} \item Sum of Constants: $\sum_{k=1}^n C = C + C + C + \dots + C$ ($n$ terms) $= nC$. \item Addition: $\sum_{k=1}^n (a_k + b_k) = \sum_{k=1}^n a_k + \sum_{k=1}^n b_k$. \item Subtraction: $\sum_{k=1}^n (a_k - b_k) = \sum_{k=1}^n a_k - \sum_{k=1}^n b_k$. \item Constant Multiple: $\sum_{k=1}^n Ca_k = C \sum_{k=1}^n a_k$. \item Preserves positivity: if $b_k\geq a_k$ for all $k$ then $\sum_{k=1}^n b_k \geq \sum_{k=1}^n a_k $. In particular, if $a_k\geq 0$ for all $k$ then $\sum_{k=1}^n a_k \geq 0$. \item Additivity of ranges: if $1\leq m\leq n$ then $\sum_{k=1}^m a_k + \sum_{k=m+1}^n a_k = \sum_{k=1}^n a_k$. \end{itemize} \end{theorem} \subsection{Sums of areas of rectangles} Later, we will approximate the areas under curves by building rectangles as high as the curve, calculating the area of each rectangle, and then adding the rectangular areas together. \begin{example} Evaluate the sum of the rectangular areas in Figure \ref{fig:4-2}, and write the sum using the sigma notation. Solution: We have \[ \begin{array}{ll} {\rm sum\ of\ the\ rectangular\ areas } &= {\rm sum\ of\ (base)}\times {\rm (height)\ for\ each\ rectangle }\\ & = (1)(1/3) + (1)(1/4) + (1)(1/5) = 47/60. \end{array} \] Using the sigma notation, \[ (1)(1/3) + (1)(1/4) + (1)(1/5) = \sum_{k=1}^3 \frac{1}{k}. \] \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=4cm]{fig4-2.eps} \end{center} \end{minipage} \caption{Area and summation notation.} \label{fig:4-2} \end{figure} \end{example} \begin{practice} Evaluate the sum of the rectangular areas in Figure \ref{fig:4-3}, and write the sum using the sigma notation. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=4cm]{fig4-3.eps} \end{center} \end{minipage} \caption{Area and summation notation.} \label{fig:4-3} \end{figure} \end{practice} \begin{example} Write the sum of the areas of the rectangles in Figure \ref{fig:4-5} using the sigma notation. Solution: The area of each rectangle is (base)$\times$(height). \begin{center} \begin{tabular}{|c|c|c|c|} \hline rectangle & base & height & area \\ \hline 1 & $x_1 - x_0$ & $f(x_1)$ & $(x_1 - x_0)f(x_1)$ \\ 2 & $x_2 - x_1$ & $f(x_2)$ & $(x_2 - x_1)f(x_2)$ \\ 3 & $x_3 - x_2$ & $f(x_3)$ & $ (x_3 - x_2)f(x_3)$ \\ \hline \end{tabular} \end{center} The area of the $k$-th rectangle is $(x_k - x_{k-1})f(x_k)$, and the total area of the rectangles is the sum $\sum_{k=1}^3 (x_k - x_{k-1})f(x_k)$. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=4cm]{fig4-5.eps} \end{center} \end{minipage} \caption{Area and summation notation.} \label{fig:4-5} \end{figure} \end{example} \subsection{Area under a curve –– Riemann sums} Suppose we want to calculate the area between the graph of a positive function $f$ and the interval $[a, b]$ on the $x$--axis (Fig. 7). The Riemann Sum method is to build several rectangles with $y = f(x)$ bases on the interval $[a, b]$ and sides that reach up to the graph of $f$ (Fig. 8). Then the areas of the rectangles can be calculated and added together to get a number called a {\bf Riemann sum of $f$ on $[a, b]$}. The area of the region formed by the rectangles is an {\it approximation} of the area we want. \index{Riemann sum} \begin{example} \label{ex:4-9} Approximate the area in Figure \ref{fig:4-9}(a) between the graph of $f$ and the interval $[2, 5]$ on the $x$--axis by summing the areas of the rectangles in Figure \ref{fig:4-9}(b). Solution: The total area of rectangles is $(2)(3) + (1)(5) = 11$ square units. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=5cm,width=10cm]{fig4-9.eps} \end{center} \end{minipage} \caption{Illustration for Example \ref{ex:4-9}.} \label{fig:4-9} \end{figure} \end{example} In order to effectively describe this process, some new vocabulary is helpful: a ``partition'' of an interval and the mesh of the partition. A {\bf partition} $P$ of a closed interval $[a,b]$ into $n$ subintervals is a set of $n+1$ points $\{ x_0 = a, x_1, x_2, x_3, . . . , x_{n-1}, x_n = b\}$ in increasing order, $a= x_0 < x_1 < x_2 < x_3 < . . . < x_n = b$. \index{partition} (A partition is a collection of points on the axis and it does not depend on the function in any way.) The points of the partition $P$ divide the interval into $n$ subintervals (Figure \ref{fig:4-10}): $[x_0 , x_1]$, $[x_1 , x_2]$, $[x_2 , x_3]$, \dots , and $[x_{n-1} , x_n]$ with lengths $\Delta x_1 = x_1 - x_0$, $\Delta x_2 = x_2 - x_1$, \dots, $\Delta x_n = x_n - x_{n-1}$. The points $x_k$ of the partition $P$ are the locations of the vertical lines for the sides of the rectangles, and the bases of the rectangles have lengths $\Delta x_k$ for $k = 1, 2, 3, . . . , n$. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=7cm]{fig4-10.eps} \end{center} \end{minipage} \caption{Partition of the interval $[a,b]$.} \label{fig:4-10} \end{figure} The {\bf mesh} or {\bf norm} of the partition is the length of the longest of the subintervals $[x_{k-1} ,x_k]$, or, equivalently, the maximum of the $\Delta x_k$ for $k = 1, 2, 3, . . . , n$. For example, the set $P = \{2, 3, 4.6, 5.1, 6\}$ is a partition of the interval $[2,6]$ and divides it into $4$ subintervals with lengths $\Delta x_1 = 1$, $\Delta x_2 = 1.6$, $\Delta x_3 = 0.5$ and $\Delta x_4 = 0.9$. The mesh of this partition is $1.6$, the maximum of the lengths of the subintervals. (If the mesh of a partition is ``small,'' then the length of each one of the subintervals is the same or smaller.) A function, a partition, and a point in each subinterval determine a Riemann sum. Suppose $f$ is a positive function on the interval $[a,b]$, $P =\{ x_0 = a, x_1, x_2, x_3, . . . , x_{n-1}, x_n = b\}$ is a partition of $[a,b]$, and $c_k$ is an $x$–value in the $k$-th subinterval $[x_{k-1} , x_k]$ : $x_{k-1} \leq c_k \leq x_k$. Then the area of the $k$-th rectangle is $f(c_k)\cdot ( x_k - x_{k-1}) = f(c_k )\Delta x_k$. (Figure \ref{fig:4-12}) \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=5cm]{fig4-12.eps} \end{center} \end{minipage} \caption{Part of a Riemann sum.} \label{fig:4-12} \end{figure} \begin{definition} A summation of the form $\sum_{k=1}^n f(c_k)\Delta x_k$ is called a {\bf Riemann sum} of $f$ for the partition $P$. \end{definition} This Riemann sum is the total of the areas of the rectangular regions and is an approximation of the area between the graph of $f$ and the $x$--axis. \begin{example} Find the Riemann sum for $f(x) = 1/x$ and the partition $\{1, 4, 5\}$ using the values $c_1 = 2$ and $c_2 = 5$. Solution: The two subintervals are $[1,4]$ and $[4,5]$ so $\Delta x_1 = 3$ and $\Delta x_2 = 1$. Then the Riemann sum for this partition is \[ \sum_{k=1}^n f(c_k)\Delta x_k = f(c_1)\Delta x_1 + f(c_2)\Delta x_2 = f(2) (3) + f(5) (1) = \frac{1}{2} (3) + \frac{1}{5}(1) = 1.7 . \] \end{example} \begin{practice} Calculate the Riemann sum for $f(x) = 1/x$ on the partition $\{1, 4, 5\}$ using the values $c_1 = 3$, $c_2 = 4$. \end{practice} \begin{practice} What is the smallest value a Riemann sum for $f(x) = 1/x$ and the partition $\{1, 4, 5\}$ can have? (You will need to select values for $c_1$ and $c_2$.) What is the largest value a Riemann sum can have for this function and partition? \end{practice} Here is a \sage example. \begin{example} Using \sage, we construct the Riemann sum of the function $y=x^2$ using a partition of $6$ equally spaced points, where the $c_k$'s are taken to be the midpoints. \vskip .1in \begin{Verbatim}[fontsize=\scriptsize,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: f1(x) = x^2 sage: f = Piecewise([[(-1,1),f1]]) sage: g = f.riemann_sum(6,mode="midpoint") sage: P = f.plot(rgbcolor=(0.7,0.1,0.5), plot_points=40) sage: Q = g.plot(rgbcolor=(0.7,0.6,0.6), plot_points=40) sage: L = add([line([[pf[0][0],0],[pf[0][0],pf[1](x=pf[0][0])]],\ rgbcolor=(0.7,0.6,0.6)) for pf in g.list()]) sage: show(P+Q+L) \end{Verbatim} \vskip .1in \noindent Here is the plot: \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=6cm,width=8cm]{sage-rs1.eps} \end{center} \end{minipage} \caption{Plot using \sage of a Riemann sum for $y=x^2$.} \label{fig:sage-rs1} \end{figure} \end{example} At the end of this section is a Python\footnote{Python is a cross-platform, free and open source computer language. It is widely used in industry and academicia, and is available for download at \url{http://www.python.org/}. Alternatively, you can download the mathematical software system \sage from \url{http://www.sagemath.org/}. It comes with Python pre-installed.} program listing for calculating Riemann sums of $f(x) = 1/x$ on the interval $[1,5]$ using $100$ subintervals. It can be modified easily to work for different functions, different endpoints, and different numbers of subintervals. Table \ref{fig:table2} shows the results of running the program with different numbers of subintervals and different ways of selecting the points $c_i$ in each subinterval. When the mesh of the partition is small (and the number of subintervals large), all of the ways of selecting the $c_i$ lead to approximately the same number for the Riemann sums. \newpage Here is a Python program to calculate Riemann sums of $f(x) = 1/x$ on $[1,5]$ using $100$ equal length subintervals, based on the ``lefthand'' endpoints. \vskip .1in \begin{Verbatim}[fontsize=\scriptsize,fontfamily=courier,fontshape=tt,frame=single,label=Python] f = lambda x: 1/x # define the function a = 1.0 # left endpoint of integral b = 5.0 # right endpoint of integral n = 100 # number of subintervals Dx = (b-a)/n # width of each subinterval rsum = sum([f(a+i*Dx)*Dx for i in range(n)]) # compute the Riemann sum print rsum # print the Riemann sum \end{Verbatim} \vskip .1in \noindent Other Riemann sums can be calculated by replacing the ``rsum'' line with one of: \verb#rsum = sum([f(a+(i+0.5)*Dx)*Dx for i in range(n)])# \ \ ``midpoint'' \verb#rsum = sum([f(a+(i+1)*Dx)*Dx for i in range(n)])# \ \ ``right-hand'' \vskip .1in \noindent Written as Python ``functions'', these three are written as below\footnote{If you have an electronic copy of this file, and ``copy-and-paste'' these into Python, keep in mind indenting is very important in Python syntax.\url{http://www.python.org/doc/essays/styleguide.html} } \begin{Verbatim}[fontsize=\scriptsize,fontfamily=courier,fontshape=tt,frame=single,label=Python] def rsum_lh(n): f = lambda x: 1/x a = 1.0 b = 5.0 Dx = (b-a)/n return sum([f(a+i*Dx)*Dx for i in range(n)]) def rsum_mid(n): f = lambda x: 1/x a = 1.0 b = 5.0 Dx = (b-a)/n return sum([f(a+(i+0.5)*Dx)*Dx for i in range(n)]) def rsum_rh(n): f = lambda x: 1/x a = 1.0 b = 5.0 Dx = (b-a)/n return sum([f(a+(i+1)*Dx)*Dx for i in range(n)]) \end{Verbatim} \vskip .1in \noindent The command \vskip .1in \noindent {\small{ \verb#sizes = [5, 10, 20, 100, 1000]# \noindent \verb# table = [[n, (b-a)/n, rsum_lh(n),rsum_mid(n), rsum_rh(n)] for n in sizes]# }} \noindent yields the following data: \vskip .1in \noindent \begin{figure} {\small{ \begin{tabular}{|l|l|c|c|c|} \hline & & left--hand & midpoint & right--hand \\ $n$ & $\Delta x_i$ & Riemann sum & Riemann sum & Riemann sum\\ \hline & & & & \\ 5 & 0.8 & 1.9779070602600015 & 1.5861709609993364 & 1.3379070602600014 \\ 10 & 0.4 & 1.7820390106296689 & 1.6032106782106783 & 1.462039010629669 \\ 20 & 0.2 & 1.6926248444201737 & 1.6078493243021688 & 1.5326248444201738 \\ 100 & 0.04 & 1.6255658911511259 & 1.6093739310551827 & 1.5935658911511259 \\ 1000 & 0.004 & 1.6110391924319691 & 1.6094372724359669 & 1.607839192431969 \\ \hline \end{tabular} }} \caption{Table for Python example.} \label{fig:table2} \end{figure} \vskip .1in \noindent In fact, the exact value is $\log(5) = 1.609437...$, so these last few lines yielded pretty good approximations. \begin{practice} Replace $1/x$ by $x^2$ and $[a,b] = [1,5]$ by $[a,b]=[-1,1]$ in the Python code above and find the Riemann sum for the new function and $n=100$. Use the midpoint approximation. (You may use \sage or Python, whichever you prefer.) \end{practice} \begin{example} Find the Riemann sum for the function $f(x) = \sin(x)$ on the interval $[0, \pi]$ using the partition $\{0, \pi/4, \pi/2, \pi\}$ with $c_1 = \pi/4$, $c_2 = \pi/2$, $c_3 = 3\pi/4$. Solution: The $3$ subintervals are $[0, \pi/4]$, $[\pi/4, \pi/2]$, and $[\pi/2,\pi]$ so $\Delta x_1 = \pi/4$, $\Delta x_2 = \pi/4$ and $\Delta x_3 = \pi/2$. The Riemann sum for this partition is \[ \begin{array}{ll} \sum_{k=1}^3 f(c_k)\Delta x_k &= \sin(\pi/4) (\pi/4) + \sin(\pi/2) (\pi/4) + \sin(3\pi/4) (\pi/2)\\ &= \frac{1}{\sqrt{2}}\frac{\pi}{4} + 1\cdot \frac{\pi}{4} + \frac{1}{\sqrt{2}}\frac{\pi}{2} \\ & = 2.45148...\ . \end{array} \] \end{example} \begin{practice} Find the Riemann sum for the function and partition in the previous example, but use $c_1 = 0$, $c_2 = \pi/2$, $c_3 = \pi/2$. \end{practice} \subsection{Two special Riemann sums: lower and upper sums} Two particular Riemann sums are of special interest because they represent the extreme possibilities for Riemann sums for a given partition. \begin{definition} Suppose $f$ is a positive function on $[a,b]$, and $P$ is a partition of $[a,b]$. Let $m_k$ be the $x$–value in the $k$-th subinterval so that $f(m_k)$ is the minimum value of $f$ in that interval, and let $M_k$ be the $x$–value in the $k$-th subinterval so that $f(M_k)$ is the maximum value of $f$ in that interval. {\bf lower sum}: $LS = \sum_{k=1}^n f(m_k)\Delta x_k$. {\bf upper sum}: $US = \sum_{k=1}^n f(M_k)\Delta x_k$. \end{definition} Geometrically, the lower sum comes from building rectangles under the graph of $f$ (Figure \ref{fig:4-15}(a)), and the lower sum (every lower sum) is less than or equal to the exact area $A$: $LS \leq A$ for every partition $P$. The upper sum comes from building rectangles over the graph of $f$ (Figure \ref{fig:4-15}(b)), and the upper sum (every upper sum) is greater than or equal to the exact area $A$: $US\geq A$ for every partition $P$. The lower and upper sums provide bounds on the size of the exact area: $LS\leq A\leq US$. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=8cm]{fig4-15.eps} \end{center} \end{minipage} \caption{Lower and upper Riemann sums.} \label{fig:4-15} \end{figure} Unfortunately, finding minimums and maximums can be a time–consuming business, and it is usually not practical to determine lower and upper sums for ``arbitrary'' functions. If $f$ is monotonic, however, then it is easy to find the values for $m_k$ and $M_k$ , and sometimes we can explicitly calculate the limits of the lower and upper sums. For a monotonic bounded function we can guarantee that a Riemann sum is within a certain distance of the exact value of the area it is approximating. \begin{theorem} If $f$ is a positive, montonically increasing, bounded function on $[a,b]$, then for any partition $P$ and any Riemann sum for $P$, distance between the Riemann sum and the exact area $\leq$ distance between the upper sum (US) and the lower sum (LS) $\leq (f(b) - f(a))\cdot ({\rm mesh\ of}\ P)$. \end{theorem} \pf The Riemann sum and the exact area are both between the upper and lower sums so the distance between the Riemann sum and the exact area is less than or equal to the distance between the upper and lower sums. Since $f$ is monotonically increasing, the areas representing the difference of the upper and lower sums can be slid into a rectangle whose height equals $f(b)-f(a)$ and whose base equals the mesh of $P$. Then the total difference of the upper and lower sums is less than or equal to the area of the rectangle, $(f(b) - f(a))\cdot ({\rm mesh\ of}\ P)$. \qed \subsection{Problems} For problems the next four problems, sketch the function and find the smallest possible value and the largest possible value for a Riemann sum of the given function and partition. \begin{enumerate} \item $f(x) = 1 + x^2$ (a) $P = \{ 1, 2, 4, 5 \}$ (b) $P = \{ 1, 2, 3, 4, 5 \}$ (c) $P = \{ 1, 1.5, 2, 3, 4, 5 \}$ \item $f(x) = 7 - 2x$ (a) $P = \{ 0, 2, 3 \}$ (b) $P = \{ 0, 1, 2, 3 \}$ (c) $P = \{ 0, .5, 1, 1.5, 2, 3 \}$ \item $f(x) = \sin(x)$ (a) $P = \{ 0, \pi/2, \pi \}$ (b) $P = \{ 0, \pi/4, \pi/2, \pi \}$ (c) $P = \{ 0, \pi/4, 3\pi/4, \pi \}$. \item $f(x) = x^2 - 2x + 3$ (a) $P = \{ 0, 2, 3\}$ (b) $P = \{ 0, 1, 2, 3 \}$ (c) $P = \{ 0, .5, 1, 2, 2.5, 3 \}$. \item Suppose we divide the interval $[ 1, 4]$ into $100$ equally wide subintervals and calculate a Riemann sum for $f(x) = 1 + x^2$ by randomly selecting a point $c_i$ in each subinterval. (a) We can be certain that the value of the Riemann sum is within what distance of the exact value of the area between the graph of $f$ and the interval $[ 1, 4]$ ? (b) What if we take 200 equally long subintervals? \item If $f$ is monotonic decreasing on $[a , b]$ and we divide the interval $[a, b]$ into $n$ equally wide subintervals, then we can be certain that the Riemann sum is within what distance of the exact value of the area between f and the interval $[a, b]$? \item Suppose $LS = 7.362$ and $US = 7.402$ for a positive function $f$ and a partition $P$ of the interval $[ 1, 5]$. (a) We can be certain that every Riemann sum for the partition $P$ is within what distance of the exact value of the area under the graph of $f$ over the interval $[ 1,5]$? (b) What if $LS = 7.372$ and $US = 7.390$? \end{enumerate} \subsection{The trapazoid rule} This section includes several techniques for getting approximate numerical values for definite integrals without using antiderivatives. Mathematically, exact answers are preferable and satisfying, but for most applications, a numerical answer with several digits of accuracy is just as useful. For instance, suppose you are a automotive or aircraft designer. You may wish to know how much metal is requred to build your design, created using a computer-aided design graphics program. Due to the fluctuations in the price for metal, you only need the approximate cost based on a piecewise-linear approximation to your design. Numerical techniques such as those discussed in this section can be used for that. The methods in this section approximate the definite integral of a function $f$ by building ``easy'' functions close to $f$ and then exactly evaluating the definite integrals of the ``easy'' functions. If the ``easy'' functions are close enough to $f$, then the sum of the definite integrals of the ``easy'' functions will be close to the definite integral of $f$. The Left, Right and Midpoint approximations fit horizontal lines to $f$ , the ``easy'' functions are piecewise constant functions, and the approximating regions are rectangles. The Trapezoidal Rule fits slanted lines to $f$ , the ``easy'' functions are piecewise linear, and the approximating regions are trapezoids. Finally, Simpson's Rule fits parabolas to $f$, and the ``easy'' functions are piecewise quadratic polynomials. All of the methods divide the interval $[a,b]$ into $n$ equally long subintervals. Each subinterval has length $h = \Delta x_i = \frac{b-a}{n}$, and the points of the partition are $x_0 = a$, $x_1 = a + h$, $x_2 = a + 2h$, \dots , $x_i = a + ih$, \dots , $x_n = a + nh = a + n(\frac{b-a}{n} ) = b$. If the graph of f is curved, then slanted lines typically come closer to the graph of f than horizontal ones do, and the slanted lines lead to trapezoidal regions. The area of a trapezoid is (base)$\times$(average height), so the area of the trapezoid with coordinates $(x_0,0)$, $(x_0,y_0)$, $(x_1,0)$, $(x_1,y_1)$, is (see Figure \ref{fig:sage-trap}), \[ (x_1-x_0)\frac{y_0+y_1}{2}. \] \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} \vspace{-1.0 cm} \hspace{-3.0 cm} \includegraphics[height=6cm,width=12cm]{sage-trap.eps} \end{center} \end{minipage} \caption{Trapazoid.} \label{fig:sage-trap} \end{figure} \begin{example} Here is how to create and plot a piecewise linear function describing the trapazoidal approximation to the area under $y=x^3-3x^2+2x$. \begin{Verbatim}[fontsize=\scriptsize,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: x = var("x") sage: f1 = lambda x: x^3-3*x^2+2*x sage: f = Piecewise([[(0,2),f1]]) sage: tf = f.trapezoid(4) sage: P3 = list_plot([(1/2,0),(0.5,f(0.5))],plotjoined=True,linestyle=":") sage: P4 = list_plot([(3/2,0),(1.5,f(1.5))],plotjoined=True,linestyle=":") sage: show(P1+P2+P3+P4) sage: f.trapezoid_integral_approximation(4) 0 sage: integrate(x^3-3*x^2+2*x, x, 0, 2) 0 \end{Verbatim} \vskip .1in \noindent Here is the plot: %\newpage \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=5cm,width=8cm]{sage-trap-rule.eps} \end{center} \end{minipage} \caption{Plot using \sage of a trapazoidal approximation to the integral $\int_0^2 x^3-3x^2+2x\, dx$.} \label{fig:sage-trap-rule} \end{figure} \vskip .1in \noindent We got lucky here since both the integral and its trapazoidal approximation actually have the same value. \end{example} \begin{theorem} (``Trapezoidal Approximation Rule'') If $f$ is integrable on $[a,b]$, and $[a,b]$ is partitioned into $n$ subintervals of length $h = \frac{b-a}{n}$, then the Trapezoidal approximation of $\int_a^b f(x)\, dx$ is \[ T_n = \frac{h}{2} [ f(x_0) + 2f(x_1) + 2f(x_2) + . . . + 2f(x_{n-1}) + f(x_n) ]. \] \end{theorem} \pf The area of the trapazoid with coordinates $(x_i,0)$, $(x_i,y_i)$, $(x_{i+1},0)$, $(x_{i+1},y_{i+1})$, where $y_i=f(x_i)$, is $(x_{i+1}-x_i)\frac{y_i+y_{i+1}}{2}=\frac{h}{2}\cdot (y_i+y_{i+1})$. Therefore, the sum of the trapezoidal areas approximating $\int_a^b f(x)\, dx$ is \[ \sum_{i=}^n (x_{i+1}-x_i)\frac{y_i+y_{i+1}}{2} =\frac{h}{2}\cdot \sum_{i=}^n (y_i+y_{i+1}) =\frac{h}{2}\cdot (y_0+2y_1+...+2y_{n-1}+y_n), \] as desired. \qed \begin{example} \label{ex:t4} Calculate $T_4$, the Trapezoidal approximation of $\int_1^3 f(x)\, dx$, for the function values tabulated in Figure \ref{fig:t4}. \begin{figure} \begin{center} \begin{tabular}{|c|c|} \hline $x$ & $f(x)$ \\ \hline 1.0& 4.2 \\ 1.5& 3.4 \\ 2.0& 2.8 \\ 2.5& 3.6 \\ 3.0& 3.2 \\ \hline \end{tabular} \end{center} \caption{Table for \ref{ex:t4}} \label{fig:t4} \end{figure} Solution: The step size is $h = (b-a)/n = (3-1)/4 = 1/2$. Then \[ \begin{array}{ll} T_4 & = \frac{h}{2} [ f(x_0) + 2f(x_1) + 2f(x_2) + 2f(x_3) + f(x_4)]\\ & = \frac{1}{4}[ 4.2 + 2(3.4) + 2(2.8) + 2(3.6) + (3.2) ]\\ & = (0.25)( 27 ) = 6.75 . \end{array} \] \end{example} \begin{example} Let's see how well the trapezoidal rule approximates an integral whose exact value we know, $\int_1^3 x^2\, dx = \frac{26}{3}$. Calculate $T_4$, the Trapezoidal approximation of $\int_1^3 x^2\, dx$. Solution: As in the example above, $h = 0.5$ and $x_0 = 1$, $x_1 = 1.5$, $x_2 = 2$, $x_3 = 2.5$, and $x_4 = 3$. Then \[ \begin{array}{ll} T_4 &= \frac{h}{2}[f(x_0) + 2f(x_1) + 2f(x_2) + 2f(x_3) + f(x_4)] \\ &= 0.5 [f(1) + 2f(1.5) + 2f(2) + 2f(2.5) + f(3)]\\ &= (0.25) [1 + 2(2.25) + 2(4) + 2(6.25) + 9] = 8.75 . \end{array} \] Using \sage, one can show that $T_{10} = 217/25=8.68$, $T_{100} = 21667/2500=8.6668$, and $T_{1000} = 2166667/250000=8.666668$. These trapazoidal approximations are indeed approaching the value $8.666...$ of the integral. \end{example} \begin{example} Here is a Python program illustrating Simpson's rule. \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=Python/\sage] f = lambda x: sin(x) def trapezoidal_rule(fcn,a,b,n): """ Does computation of the Trapazodal's rule approx of int_a^b fcn(x) dx using n steps. """ Deltax = (b-a)*1.0/n coeffs = [2]*(n-1) coeffs = [1]+coeffs+[1] valsf = [f(a+Deltax*i) for i in range(n+1)] return (Deltax/2)*sum([coeffs[i]*valsf[i] for i in range(n+1)]) \end{Verbatim} \vskip .1in \noindent Now we paste this into \sage (you may instead paste into Python if you wish) and see how it works. \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: f = lambda x: sin(x) sage: def trapezoidal_rule(fcn,a,b,n): ....: """ ....: Does computation of the Trapazodal's rule approx of int_a^b fcn(x) dx ....: using n steps. ....: ....: """ ....: Deltax = (b-a)*1.0/n ....: coeffs = [2]*(n-1) ....: coeffs = [1]+coeffs+[1] ....: valsf = [f(a+Deltax*i) for i in range(n+1)] ....: return (Deltax/2)*sum([coeffs[i]*valsf[i] for i in range(n+1)]) ....: sage: integral(f(x),x,0,1) 1 - cos(1) sage: RR(integral(f(x),x,0,1)) 0.459697694131860 sage: trapezoidal_rule(f(x),0,1,4) 0.457300937571502 \end{Verbatim} \vskip .1in \noindent You see $\int_0^1 \sin(x)\, dx = 1-\cos(1)=0.459...$, whereas the trapezoidal rule gives the approximation $T_4=0.457...$. \end{example} \subsection{Simpson's rule} If the graph of $f$ is curved, even the slanted lines may not fit the graph of $f$ as closely as we would like, and a large number of subintervals may still be needed with the Trapezoidal rule to get a good approximation of the definite integral. Curves typically fit the graph of $f$ better than straight lines, and the easiest nonlinear curves are parabolas. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} \vspace{-1.0 cm} %\hspace{-1.0 cm} \includegraphics[height=6cm,width=12cm]{sage-simp.eps} \end{center} \end{minipage} \caption{Piece of a parabola.} \label{fig:sage-simp} \end{figure} \begin{theorem} Three points $(x_0, y_0)$, $(x_1, y_1)$, $(x_2, y_2)$ are needed to determine the equation of a parabola, and the area under a parabolic region with evenly spaced $x_i$ values (Figure \ref{fig:sage-simp}) is \[ \frac{\Delta x}{3}( y_0 + 4y_1 + y_2). \] \end{theorem} \begin{theorem} (``Simpson's Rule'') If $f$ is integrable on $[a,b]$, and $[a,b]$ is partitioned into an even number $n$ of subintervals of length $h = \Delta x=\frac{b-a}{n}$, then the Parabolic approximation of $\int_a^b f(x)\, dx$ is \[ S_n = \frac{\Delta x}{3}[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + 2f(x_4) + ... + 4f(x_{n-1} ) + f(x_n ) ]. \] \end{theorem} \begin{example} \label{ex:s4} Calculate $S_4$, the Simpson's rule approximation of $\int_1^3 f(x)\, dx$, for the function values tabulated in Figure \ref{fig:t4}. Solution: The step size is $h = (b-a)/n = (3-1)/4 = 1/2$. Then \[ \begin{array}{ll} S_4 & = \frac{h}{3} [ f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + f(x_4)]\\ & = \frac{1}{6}[ 4.2 + 4(3.4) + 2(2.8) + 4(3.6) + (3.2) ]\\ & = \frac{41}{6} = 6.83...\, . \end{array} \] \end{example} \begin{example} Here is a Python program illustrating Simpson's rule. \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=Python/\sage] f = lambda x: sin(x) def simpsons_rule(fcn,a,b,n): """ Does computation of the Simpson's rule approx of int_a^b fcn(x) dx using n steps. Here n must be an even integer. """ Deltax = (b-a)*1.0/n n2 = int(n/2) coeffs = [4,2]*n2 coeffs = [1]+coeffs[:n-1]+[1] valsf = [f(a+Deltax*i) for i in range(n+1)] return (Deltax/3)*sum([coeffs[i]*valsf[i] for i in range(n+1)]) \end{Verbatim} \vskip .1in \noindent Now we paste this into \sage and see how it works: \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: f = lambda x: sin(x) sage: def simpsons_rule(fcn,a,b,n): ....: """ ....: Does computation of the Simpson's rule approx of int_a^b fcn(x) dx ....: using n steps. Here n must be an even integer. ....: ....: """ ....: Deltax = (b-a)*1.0/n ....: n2 = int(n/2) ....: coeffs = [4,2]*n2 ....: coeffs = [1]+coeffs[:n-1]+[1] ....: valsf = [f(a+Deltax*i) for i in range(n+1)] ....: return (Deltax/3)*sum([coeffs[i]*valsf[i] for i in range(n+1)]) ....: sage: integral(f(x),x,0,1) 1 - cos(1) sage: RR(integral(f(x),x,0,1)) 0.459697694131860 sage: simpsons_rule(f(x),0,1,4) (sin(1) + 4*sin(3/4) + 2*sin(1/2) + 4*sin(1/4))/12 sage: RR(simpsons_rule(f(x),0,1,4)) 0.459707744927311 sage: RR(simpsons_rule(f(x),0,1,10)) 0.459697949823821 \end{Verbatim} \vskip .1in \noindent To paste this into Python, you mus first import the sin function. \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=Python] >>> from math import sin >>> f = lambda x: sin(x) >>> def simpsons_rule(fcn,a,b,n): ... """ ... Does computation of the Simpson's rule approx of int_a^b fcn(x) dx ... using n steps. Here n must be an even integer. ... ... """ ... Deltax = (b-a)*1.0/n ... n2 = int(n/2) ... coeffs = [4,2]*n2 ... coeffs = [1]+coeffs[:n-1]+[1] ... valsf = [f(a+Deltax*i) for i in range(n+1)] ... return (Deltax/3)*sum([coeffs[i]*valsf[i] for i in range(n+1)]) ... >>> simpsons_rule(f,0,1,4) 0.45970774492731092 \end{Verbatim} \vskip .1in \noindent Using this and the trapezoidal approximation function, we can compare which is best in this example. \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: simpsons_rule(f(x),0,1,4) 0.459707744927311 sage: trapezoidal_rule(f(x),0,1,4) 0.457300937571502 sage: simpsons_rule(f(x),0,1,10) 0.459697949823821 sage: trapezoidal_rule(f(x),0,1,10) 0.459314548857976 sage: integral(f(x),x,0,1) 1 - cos(1) sage: integral(f(x),x,0,1)*1.0 1.00000000000000*(1 - cos(1)) sage: RR(integral(f(x),x,0,1)) 0.459697694131860 \end{Verbatim} \vskip .1in \noindent We see Simpson's rule wins every time. \end{example} \subsection{Trapazoidal vs. Simpson: Which Method Is Best?} The hardest and slowest part of these approximations, whether by hand or by computer, is the evaluation of the function at the $x_i$ values. For $n$ subintervals, all of the methods require about the same number of function evaluations. The rest of this section discusses "error bounds" of the approximations so we can know how close our approximation is to the exact value of the integral even if we don't know the exact value. \begin{theorem} (Error Bound for Trapezoidal Approximation) If the second derivative of $f$ is continuous on $[a,b]$ and $M_2 \geq \max_{x\in [a,b]} | f ''(x) |$, then the ``error of the $T_n$ approximation'' is \[ | \int_a^b f(x)\, dx - T_n | \leq \frac{(b–a)^3}{12n^2}M_2 . \] \end{theorem} The ``error bound'' formula $\frac{(b–a)^3}{12n^2}M_2$ for the Trapezoidal approximation is a ``guarantee'': the actual error is guaranteed to be no larger than the error bound. In fact, the actual error is usually much smaller than the error bound. The word ``error'' does not indicate a mistake, it means the deviation or distance from the exact answer. \begin{example} How large must $n$ be to be certain that $T_n$ is within $0.001$ of $\int_0^1 \sin( x )\, dx$? Solution: We want to pick $n$ so that $\frac{(b–a)^3}{12n^2}M_2\leq 1/1000$. We may take $M_2=1$, so $\frac{(b–a)^3}{12n^2}M_2= \frac{1}{12n^2}\leq 1/1000$, or $n^2\geq 1000/12$. Taking $n=10$ will work. \end{example} \begin{theorem} (Error Bound for Simpson's Rule Approximation) If the fourth derivative of $f$ is continuous on $[a,b]$ and $M_4 \geq \max_{x\in [a,b]} | f^{(4)}(x) |$, then the ``error of the $S_n$ approximation'' is \[ | \int_a^b f(x)\, dx - S_n | \leq \frac{(b–a)^5}{180n^4}M_4 . \] \end{theorem} \begin{example} How large must $n$ be to be certain that $S_n$ is within $0.001$ of $\int_0^1 \sin( x )\, dx$? Solution: We want to pick $n$ so that $\frac{(b–a)^5}{180n^4}M_2\leq 1/1000$. We may take $M_2=1$, so $\frac{(b–a)^5}{180n^4}M_4= \frac{1}{180n^4}\leq 1/1000$, or $n^4\geq 1000/180$. Taking $n=2$ will work. \end{example} \section{The definite integral} Each particular Riemann sum depends on several things: the function $f$, the interval $[a,b]$, the partition $P$ of the interval, and the values chosen for $c_k$ in each subinterval. Fortunately, for most of the functions needed for applications, as the approximating rectangles get thinner (as the mesh of $P$ approaches $0$ and the number of subintervals gets bigger) the values of the Riemann sums approach the same value independently of the particular partition $P$ and the points $c_k$. For these functions, the {\it limit} (as the mesh approaches $0$) of the Riemann sums is the same number no matter how the $c_k$'s are chosen. This limit of the Riemann sums is the next big topic in calculus, the definite integral. Integrals arise throughout the rest of this book and in applications in almost every field that uses mathematics. \begin{definition} \label{defn:int} If $\lim_{{\rm mesh}(P)\rightarrow 0} \sum_{k=1}^n f(c_k)\Delta x_k$ equals a finite number $I$ then $f$ is said to be {\bf (Riemann) integrable} on the interval $[a, b]$. The number $I$ is called the {\bf definite integral} of $f$ over $[a,b]$ and is written $\int_a^b f(x)\, dx$. \end{definition} The symbol $\int_a^b f(x)\, dx$ is read ``the integral from $a$ to $b$ of $f$ of $x$ dee $x$''or ``the integral from $a$ to $b$ of $f(x)$ with respect to $x$.'' The {\bf lower limit} is $a$, {\bf upper limit} is $b$, the {\bf integrand} is $f(x)$, and $x$ is sometimes called the {\bf dummy variable}. Note that $\int_a^b f(u)\, du$ numerically means exactly the same thing, but with a different dummy variable. The value of a definite integral $\int_a^b f(x)\, dx$ depends only on the function $f$ being integrated and on the endpoints $a$ and $b$. The following integrals each represent the integral of the function $f$ on the interval $[a,b]$, and they are all equal: \[ \int_a^b f(x)\, dx = \int_a^b f(t)\, dt = \int_a^b f(u)\, du = \int_a^b f(z)\, dz. \] Also, note that when the upper limit and the lower limit are the same then the integral is always $0$: \[ \int_{a}^a f(x) dx = 0. \] There are many other properties, as we will see later. %%starting to take from Stein now \begin{example} (Relation between velocity and area) Suppose you're reading a car magazine and there is an article about a new sports car that has this table in it: \begin{center} \begin{tabular}{|l|l|l|l|l|l|l|l||}\hline Time (seconds) & 0 & 1 & 2 & 3 & 4 & 5 & 6\\\hline Speed (mph) & 0 & 5 & 15 & 25 & 40 & 50 & 60\\\hline \end{tabular} \end{center} They claim the car drove $1/8$th of a mile after $6$ seconds, but this just ``feels'' wrong... Hmmm... Let's estimate the distance driven using the formula $$ \text{ distance }= \text{ rate }\times \text{ time}. $$ We overestimate by assuming the velocity is a constant equal to the max on each interval: $$ \text{estimate }=5 \cdot 1 + 15 \cdot 1 + 25 \cdot 1 + 40 \cdot 1 + 50 \cdot 1 + 60 \cdot 1 = \frac{195}{3600} \text{ miles } = 0.054... $$ (Note: there are $3600$ seconds in an hour.) But $1/8 \sim 0.125$, so the article is inconsistent. (Doesn't this sort of thing just bug you? By learning calculus you'll be able to double-check things like this much more easily.) {\bf Insight!} {\em The formula for the estimate of distance traveled above looks exactly like an approximation for the area under the graph of the speed of the car!} In fact, if an object has velocity $v(t)$ at time $t$, then the net change in position from time $a$ to $b$ is $$ \int_{a}^b v(t) dt. $$ \end{example} If $f$ is a velocity, then the integrals on the intervals where $f$ is positive measure the distances moved forward; the integrals on the intervals where $f$ is negative measure the distances moved backward; and the integral over the whole time interval is the total (net) change in position, the distance moved forward minus the distance moved backward. \begin{practice} A bug starts at the location $x = 12$ on the $x$--axis at $1$ pm and walks along the axis in the positive direction with the velocity shown in Figure \ref{fig:4-2-6}. How far does the bug travel between $1$ pm and $3$ pm, and where is the bug at $3$ pm? \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=6cm]{fig4-2-6.eps} \end{center} \end{minipage} \caption{Velocity of a bug on the $x$--axis.} \label{fig:4-2-6} \end{figure} \end{practice} \begin{practice} A car is driven with the velocity west shown in Figure \ref{fig:4-2-8}. (a) Between noon and $6$ pm how far does the car travel? (b) At $6$ pm, where is the car relative to its starting point (its position at noon)? \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=2.5cm,width=4.5cm]{fig4-2-8.eps} \end{center} \end{minipage} \caption{Velocity of a car on the $x$--axis.} \label{fig:4-2-8} \end{figure} \end{practice} Units For the Definite Integral We have already seen that the ``area'' under a graph can represent quantities whose units are not the usual geometric units of square meters or square feet. In general, the units for the definite integral $\int_a^b f(x) dx$ are (units for $f(x)$)$\times$(units for $x$). A quick check of the units can help avoid errors in setting up an applied problem. For example, if $x$ is a measure of time in seconds and $f(x)$ is a velocity with units feet/second, then $\Delta x$ has the units seconds and $f(x)\Delta x$ has the units (feet/second)(seconds) = feet, a measure of distance. Since each Riemann sum $\sum f(x_k)\Delta x_k$ is a sum of feet and the definite integral is the limit of the Riemann sums, the definite integral $\int_{a}^b f(x) dx$, has the same units, feet. If $f(x)$ is a force in grams, and $x$ is a distance in centimeters, then $\int_{a}^b f(x) dx$ is a number with the units "gram$\cdot $centimeters," a measure of work. \subsection{The Fundamental Theorem of Calculus} \begin{example} For the function $f(t) = 2$, define $A(x)$ to be the area of the region bounded by the graph of $f$, the $t$--axis, and vertical lines at $t = 1$ and $t = x$. \begin{itemize} \item[(a)] Evaluate $A(1)$, $A(2)$, $A(3)$, $A(4)$. \item[(b)] Find an algebraic formula for $A(x)$, for $x \geq 1$. \item[(c)] Calculate $\frac{d}{dx}A(x)$. \item[(d)] Describe $A(x)$ as a definite integral. \end{itemize} Solution : (a) $A(1) = 0$, $A(2) = 2$, $A(3) = 4$, $A(4) = 6$. (b) $A(x) =$ area of a rectangle $=$ (base)$\times$(height) $= (x - 1)\cdot ( 2 ) = 2x - 2$. (c) $\frac{d}{dx}A(x) = \frac{d}{dx}( 2x - 2 ) = 2$. (d) $A(x) = \int_1^x 2\, dt$. \end{example} \begin{practice} Answer the questions in the previous Example for $f(t) = 3$. \end{practice} A curious ``coincidence'' appeared in this Example and Practice problem: the derivative of the function defined by the integral was the same as the integrand, the function ``inside'' the integral. Stated another way, the function defined by the integral was an ``antiderivative'' of the function ``inside'' the integral. We will see that this is no coincidence: it is an important property called The Fundamental Theorem of Calculus. Let $f$ be a continuous function on the interval $[a,b]$. \begin{theorem} \label{thrm:ftc} (``Fundamental Theorem of Calculus'') If $F(x)$ is any differentiable function on $[a,b]$ such that $F'(x) = f(x)$, then $$ \int_{a}^{b} f(x) dx = F(b) - F(a). $$ \end{theorem} The above theorem is {\em incredibly} useful in mathematics, physics, biology, etc. One reason this is amazing, is because it says that the area under the entire curve is completely determined by the values of a (``magic'') auxiliary function {\em at only $2$ points}. It's hard to believe. It reduces computing (\ref{defn:int}) to finding a single function $F$, which one can often do algebraically, in practice. Whether or not one should use this theorem to evaluate an integral depends a lot on the application at hand, of course. One can also use a partial limit via a computer for certain applications (numerical integration). \begin{example} I've always wondered exactly what the area is under a ``hump'' of the graph of $\sin$. Let's figure it out, using $F(x) = -\cos(x)$. $$ \int_{0}^\pi \sin(x) dx = -\cos(\pi) - (-\cos(0)) = -(-1) - (-1) = 2. $$ In \sage, you can do this both ``algebraically'' and ``numerically'' as follows. \vskip .1in \begin{Verbatim}[fontsize=\small,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: f = lambda x: sin(x) sage: integral(f(x),x,0,pi) 2 sage: numerical_integral(f(x),0,pi) (1.9999999999999998, 2.2204460492503128e-14) \end{Verbatim} \vskip .1in \noindent For the ``algebraic'' computation, \sage knows how to integrate $\sin(x)$ exactly, so can compute $\int_{0}^\pi \sin(x) dx = 2$ using its \verb+integral+ command\footnote{In fact, \sage includes Maxima (\url{http://maxima.sf.net}) and calls Maxima to compute this integral.}. On the last line of output, the first entry is the approximation, and the second is the error bound. For the ``numerical'' computation, \sage obtains\footnote{In fact, \sage includes the GNU Scientific Library (\url{http://www.gnu.org/software/gsl/}) and calls it to approximate this integral.} the approximation $\int_{0}^\pi \sin(x) dx \approx 1.99999...$ by taking enough terms in a Riemann sum to achieve a very small error. (A lot of theory of numerical integration goes into why \verb+numerical_integral+ works correctly, but that would take us too far afield to explain here.) \end{example} \begin{example} Let $[...]$ denote the ``greatest integer'' (or ``floor'') function, so $[1/2]=[0.5]=0$ and $[3/2]=[1.5]=1$. Evaluate $\int_{1/2}^{3/2} [x]\, dx$. (The function of $y=[x]$ is sometimes called the ``staircase function'' because of the look of its discontinuous graph, Figure \ref{fig:sage-floor}.) \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=2.5cm,width=4.5cm]{sage-floor.eps} \end{center} \end{minipage} \caption{Plot of the ``greatest integer'' function.} \label{fig:sage-floor} \end{figure} Solution: $f(x) = [x]$ is not continuous at $x = 1$ in the interval $[1/2.3/2]$ so the Fundamental Theorem of Calculus can not be used. We can, however, use our understanding of the meaning of an integral as an area to get $\int_{1/2}^{3/2} [x]\, dx = (area under $y=0$ between $0.5$ and $1$) + (area under $y=1$ between $1$ and $1.5$)=0+1/2=1/2$. Now, let's try something illegal - using the Fundamental Theorem of Calculus to evaluate this. Pretend for the moment that the Fundamental Theorem of Calculus is valid for discontinuous functions too. Let \[ F(x) = \left\{ \begin{array}{ll} 1, & 1/2\leq x\leq 1,\\ x, & 1< x\leq 3/2. \end{array} \right. \] This function $F$ is continuous and satisfies $F'(x)=[x]$ for all $x$ in $[1/2,3/2]$ except $x=1$ (where $f(x)=[x]$ is discontinuous), so this $F$ could be called an ``antiderivative'' of $f$. If we use it to evaluate the integral we get $\int_{1/2}^{3/2} [x]\, dx = F(x)|_{1/2}^{3/2}=3/2-1=1/2$. This is correct. (Surprised?) Let's try another antiderivative. Let \[ F(x) = \left\{ \begin{array}{ll} 2, & 1/2\leq x\leq 1,\\ x, & 1< x\leq 3/2. \end{array} \right. \] This function $F$ also satisfies $F'(x)=[x]$ for all $x$ in $[1/2,3/2]$ except $x=1$. If we use it to evaluate the integral we get $\int_{1/2}^{3/2} [x]\, dx = F(x)|_{1/2}^{3/2}=3/2-2=-1/2$. This doesn't even have the right sign (the integral of a non-negative function must be non-negative!), so it must be wrong. Moral of the story: In general, the Fundamental Theorem of Calculus is false for discontinuous functions. \end{example} \vspace{2em} But does such an $F$ as in the fundamental theorem of calculus (Theorem \ref{thrm:ftc}) always exist? The surprising answer is ``yes''. \begin{theorem} \label{thrm:fexists} Let $F(x) = \int_{a}^{x} f(t) dt$. Then $F'(x) = f(x)$ for all $x \in [a,b]$. \end{theorem} Note that a ``nice formula'' for $F$ can be hard to find or even provably non-existent. The proof of Theorem~\ref{thrm:fexists} is somewhat complicated but is given in complete detail in many calculus books, and you should definitely (no pun intended) read and understand it. \pf [Sketch of Proof] We use the definition of derivative. \begin{align*} F'(x) &= \lim_{h\to 0} \frac{F(x+h) - F(x)}{h} \\ &= \lim_{h\to 0} \left(\int_{a}^{x+h} f(t)dt - \int_{a}^{x} f(t)dt\right)/h\\ &= \lim_{h\to 0} \left(\int_{x}^{x+h} f(t)dt\right)/h \end{align*} Intuitively, for $h$ sufficiently small $f$ is essentially constant, so $\int_{x}^{x+h} f(t)dt \sim hf(x)$ (this can be made precise using the extreme value theorem). Thus $$ \lim_{h\to 0} \left(\int_{x}^{x+h} f(t)dt\right)/h = f(x), $$ which proves the theorem. \qed \subsection{Problems} In problems 1 -- 4 , rewrite the limit of each Riemann sum as a definite integral. \begin{enumerate} \item $\lim_{{\rm mesh}(P)\to 0} \sum_{k=1}^n (2+3c_k) \Delta x_k$ on the interval $[ 0, 4]$. \item $\lim_{{\rm mesh}(P)\to 0} \sum_{k=1}^n \cos(5c_k) \Delta x_k$ on the interval $[ 0, 11]$. \item $\lim_{{\rm mesh}(P)\to 0} \sum_{k=1}^n c_k^3 \Delta x_k$ on the interval $[ 2, 5]$. \item $\lim_{{\rm mesh}(P)\to 0} \sum_{k=1}^n c_k \Delta x_k$ on the interval $[ 2, 5]$. \item Write as a definite integral (don't evaluate it though): The region bounded by $y = x^3$, the $x$--axis, the line $x = 1$, and $x = 5$. \item Write as a definite integral (don't evaluate it though): The region bounded by $y = \sqrt{x}$, the $x$--axis, and the line $x = 9$. \item Write as a definite integral ({\it do} evaluate it, using geometry formulas): The region bounded by $y = 2x$, the $x$--axis, the line $x = 1$, and $x = 3$. \item Write as a definite integral ({\it do} evaluate it, using geometry formulas): The region bounded by $y = | x |$, the $x$--axis, and the line $x = -1$. \item For $f(x) = 3 + x$, partition the interval $[0,2]$ into $n$ equally wide subintervals of length $\Delta x = 2/n$. (a) Write the lower sum for this function and partition, and calculate the limit of the lower sum as $n\to\infty$. (b) Write the upper sum for this function and partition and find the limit of the upper sum as $n\to\infty$. \item For $f(x) = x^3$, partition the interval $[0,2]$ into $n$ equally wide subintervals of length $\Delta x = 2/n$. (a) Write the lower sum for this function and partition, and calculate the limit of the lower sum as $n\to\infty$. (b) Write the upper sum for this function and partition and find the limit of the upper sum as $n\to\infty$. \end{enumerate} \subsection{Properties of the definite integral} Definite integrals are defined as limits of Riemann sums, and they can be interpreted as ``areas'' of geometric regions. This section continues to emphasize this geometric view of definite integrals and presents several properties of definite integrals. These properties are justified using the properties of summations and the definition of a definite integral as a Riemann sum, but they also have natural interpretations as properties of areas of regions. These properties are used in this section to help understand functions that are defined by integrals. They will be used in future sections to help calculate the values of definite integrals. Since integrals are a lot like sums (they are, after all, limits of them), their properties are similar too. Here is the integral analog of Theorem \ref{thrm:sum-prop}. \begin{theorem} \label{thrm:int-prop} (Integral Properties) \begin{itemize} \item Integral of a constant function: $\int_{a}^b c\, dx = c\cdot (b-a)$. \item Addition: $\int_{a}^b (f(x) + g(x))\, dx = \int_{a}^b f(x)\, dx + \int_{a}^b g(x)\, dx$. \item Subtraction: $\int_{a}^b (f(x) - g(x))\, dx = \int_{a}^b f(x)\, dx - \int_{a}^b g(x)\, dx$. \item Constant Multiple: $\int_{a}^b c\cdot f(x) \, dx = c \int_{a}^b f(x) \, dx$. \item Preserves positivity: If $f(x)\geq g(x)$ on for all $x\in [a,b]$, then \[ \int_{a}^b f(x)\, dx \geq \int_{a}^b g(x)\, dx. \] In particular, if $f(x)\geq 0$ on for all $x\in [a,b]$, then \[ \int_{a}^b f(x)\, dx \geq 0. \] \item Additivity of ranges: $\int_{a}^b f(x)\, dx + \int_b^c f(x)\, dx = \int_{a}^c f(x)\, dx$. \end{itemize} \end{theorem} Here are some other properties. \begin{theorem} \label{thrm:int-max-min} \[ (b-a)\cdot (\min_{x\in [a,b]} f(x)) \leq \int_{a}^b f(x)\, dx \leq (b-a)\cdot (\min_{x\in [a,b]} f(x)). \] \end{theorem} \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=7cm]{fig4-3-5.eps} \end{center} \end{minipage} \caption{Plot illustrating Theorem \ref{thrm:int-max-min}.} \label{fig:4-3-5} \end{figure} Which Functions Are Integrable? This important question was finally answered in the 1850s by Georg Riemann, a name that should be familiar by now. Riemann proved that a function must be badly discontinuous to not be integrable. \begin{theorem} Every continuous function is integrable. If $f$ is continuous on the interval $[a,b]$, then $\lim_{{\rm mesh}(P)\to 0} ( \sum_{k=1}^n f(c_k)\Delta x_k)$ is always the same finite number, namely, $\int_a^b f(x)\, dx$, so $f$ is integrable on $[a,b]$. \end{theorem} In fact, a function can even have any finite number of breaks and still be integrable. \begin{theorem} Every bounded, piecewise continuous function is integrable. If $f$ is defined and bounded ( for all $x$ in $[a,b]$, $–M \leq f(x) \leq M$ for some $M>0$), and continuous except at a finite number of points in $[a,b]$, then $\lim_{{\rm mesh}(P)\to 0} ( \sum_{k=1}^n f(c_k)\Delta x_k)$ is always the same finite number, namely, $\int_a^b f(x)\, dx$, so $f$ is integrable on $[a,b]$. \end{theorem} \begin{example} (A Nonintegrable Function) Though rarely encountered in ``everyday practice'', there are functions for which the limit of the Riemann sums does not exist, and those functions are not integrable. A nonintegrable function: The function \[ f(x) = \left\{ \begin{array}{ll} 1, & {\rm if}\ x\ {\rm is\ a\ rational\ number},\\ 0, & {\rm if}\ x\ {\rm is\ an\ irrational\ number} \end{array} \right. \] is not integrable on $[0,1]$. \pf For any partition $P$, suppose that you, a very rational (pun intended) person, always select values of $c_k$ which are rational numbers. (Every subinterval contains rational numbers and irrational numbers, so you can always pick $c_k$ to be a rational number.) Then $f(c_k) = 1$, and your Riemann sum is always \[ Y_P = \sum_{k=1}^n f(c_k)\Delta x_k =\sum_{k=1}^n \Delta x_k = x_n-x_0=1. \] Suppose your friend, however, always selects values of $c_k$ which are irrational numbers. Then $f(c_k) = 0$, and your friend's Riemann sum is always \[ F_P = \sum_{k=1}^n f(c_k)\Delta x_k =\sum_{k=1}^n 0\cdot \Delta x_k = 0. \] Now, take finer and finer partitions $P$ so that ${\rm mesh}(P)\to 0$. Keep in mind that, no matter how you refine $P$, you can always make ``rational choices'' for $c_k$ and your friend can always make ``irrational choices''. We have $\lim_{{\rm mesh}(P)\to 0} Y_P=1$ and $\lim_{{\rm mesh}(P)\to 0} F_P=0$, so the limit of the Riemann sums doesn't have a unique value. Therefore the limit \[ \lim_{{\rm mesh}(P)\to 0} ( \sum_{k=1}^n f(c_k)\Delta x_k) \] does not exist, so $f$ is not integrable. \end{example} \subsection{Problems} Problems 1 -- 20 refer to the graph of $f$ in Figure \ref{fig:4-3-13}. Use the graph to determine the values of the definite integrals. (The bold numbers represent the area of each region.) \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=7cm]{fig4-3-13.eps} \end{center} \end{minipage} \caption{Plot for problems.} \label{fig:4-3-13} \end{figure} \begin{enumerate} \item $\int_0^3 f(x)\, dx$ \item $\int_3^5 f(x)\, dx$ \item $\int_2^2 f(x)\, dx$ \item $\int_6^7 f(x)\, dx$ \item $\int_0^5 f(x)\, dx$ \item $\int_0^7 f(x)\, dx$ \item $\int_3^6 f(x)\, dx$ \item $\int_5^7 f(x)\, dx$ \item $\int_3^0 f(x)\, dx$ \item $\int_5^3 f(x)\, dx$ \item $\int_6^0 f(x)\, dx$ \item $\int_0^3 2f(x)\, dx$ \item $\int_4^4 f(x)^2\, dx$ \item $\int_0^3 1+f(t)\, dt$ \item $\int_0^3 x+f(x)\, dx$ \item $\int_3^5 3+f(x)\, dx$ \item $\int_0^5 2+f(x)\, dx$ \item $\int_3^5 |f(x)|\, dx$ \item $\int_7^3 1+|f(x)|\, dx$ \end{enumerate} For problems 21--28, sketch the graph of the integrand function and use it to help evaluate the integral. ($|...|$ denotes the absolute value and $[...]$ denotes the integer part.) \begin{enumerate} \addtocounter{enumi}{20} \item $\int_0^4 |x|\, dx$, \item $\int_0^4 1+|x|\, dx$, \item $\int_{-1}^2 |x|\, dx$, \item $\int_1^2 |x|-1\, dx$, \item $\int_1^3 [x]\, dx$, \item $\int_1^{3.5} [x]\, dx$, \item $\int_1^3 2+[x]\, dx$, \item $\int_3^1 [x]\, dx$. \end{enumerate} \section{Areas, integrals, and anti-derivatives} This section explores properties of functions defined as areas and examines some of the connections among areas, integrals and antiderivatives. In order to focus on the geometric meaning and connections, all of the functions in this section are nonnegative, but the results are generalized in the next section and proved true for all continuous functions. This section also introduces examples to illustrate how areas, integrals and antiderivatives can be used. When $f$ is a continuous, nonnegative function, then the ``area function'' $A(x)=\int_a^x f(t)\, dt$ represents the area between the graph of $f$, the $t$--axis, and between the vertical lines at $t=a$ and $t=x$ (Figure \ref{fig:4-4-1}), and the derivative of $A(x)$ represents the rate of change (growth) of $A(x)$. \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=3cm,width=5cm]{fig4-4-1.eps} \end{center} \end{minipage} \caption{Plot of an ``area function''.} \label{fig:4-4-1} \end{figure} Let $F(x)$ be a differentiable function. Call $F(x)$ an {\bf antiderivative} of $f(x)$ if $\frac{d}{dx}F(x)=f(x)$. \index{antiderivative} We have seen examples which showed that, at least for {\it some} functions $f$, the derivative of $A(x)$ was equal to $f$ so $A(x)$ was an antiderivative of $f$. The next theorem says the result is true for every continuous, nonnegative function $f$. \begin{theorem} (``The Area Function is an Antiderivative'') If $f$ is a continuous nonnegative function, $x\geq a$, and $A(x) = \int_a^x f(t)\, dt$ then $\frac{d}{dx}\int_a^x f(t)\, dt = \frac{d}{dx} A(x) = f(x)$, so $A(x)$ is an antiderivative of $f(x)$. \end{theorem} This result relating integrals and antiderivatives is a special case (for nonnegative functions $f$) of the Fundamental Theorem of Calculus. This result is important for two reasons: \begin{itemize} \item it says that a large collection of functions have antiderivatives, and \item it leads to an easy way of exactly evaluating definite integrals. \end{itemize} x \begin{example} Let $G(x) = \frac{d}{dx}\int_0^x \cos(t) dt$. Evaluate $G(x)$ for $x = \pi/4$, $\pi/2$, and $3\pi/4$. Solution: It is not hard to plot the graph of $A(x) = \int_0^x \cos(t) dt=\sin(x)$ (Figure \ref{fig:sage-area2}). By the theorem, $A'(x) = G(x) = \cos(x)$ so $A'(\pi/4) = \cos(\pi/4) = .707...$, $A'(\pi/2) = \cos(\pi/2) = 0$, and $A'(3\pi/4) = \cos(3π/4) = -0.707...$\ . \vskip .1in \noindent Here is the plot of $y=A(x)$ and $y=G(x)$: \begin{figure}[h!] \begin{minipage}{\textwidth} \begin{center} %\vspace{1.0 cm} \includegraphics[height=4cm,width=8cm]{sage-area2.eps} \end{center} \end{minipage} \caption{Plot of $y=\int_0^x G(t)\, dt$ and $y=G(x)$.} \label{fig:sage-area2} \end{figure} \vskip .1in \noindent Incidentally, this was created using the following \sage commands. \vskip .1in \begin{Verbatim}[fontsize=\scriptsize,fontfamily=courier,fontshape=tt,frame=single,label=\sage] sage: P = plot(cos(x),x,0,2*pi,linestyle="--") sage: Q = plot(sin(x),x,0,2*pi) sage: R = text("$y=A(x) = \sin(x)$",(3.1,1)) sage: S = text("$y=G(x) = \cos(x)$",(6.8,0.7)) sage: show(P+Q+R+S) \end{Verbatim} \end{example} \begin{theorem} (``Antiderivatives and Definite Integrals'') If $f$ is a continuous, nonnegative function and $F$ is any antiderivative of $f$ ($F '(x) = f(x)$) on the interval $[a,b]$, then \begin{center} \ \begin{tabular}{|c|} \hline area bounded between the graph\\ of $f$ and the $x$--axis and \\ vertical lines at $x = a$ and $x = b$\\ \hline \end{tabular} $ = \int_a^b f(x)\, dx = F(b) - F(a)$. \end{center} \end{theorem} The problem of finding the exact value of a definite integral reduces to finding some (any) antiderivative $F$ of the integrand and then evaluating $F(b) – F(a)$. Even finding one antiderivative can be difficult, and, for now, we will stick to functions which have easy antiderivatives. Later we will explore some methods for finding antiderivatives of more difficult functions. The evaluation $F(b) - F(a)$ is represented by the symbol $F(x)|_a^b$. \begin{example} Evaluate $\int_1^3 x\, dx$ in two ways: \begin{itemize} \item[(a)] By sketching the graph of $y = x$ and geometrically finding the area. \item[(b)] By finding an antiderivative of $F(x)$ of $f$ and evaluating $F(3)-F(1)$. \end{itemize} Solution: (a) The graph of $y = x$ is a straight line, so the area is a triangle which geometrical formulas (area=$\frac{1}{2}bh$) tell us has area $4$. (b) One antiderivative of $x$ is $F(x) = \frac{1}{2}x^2$ (check that $\frac{d}{dx}(\frac{1}{2}x^2) = x$), and \[ F(x)|_1^3= F(3)-F(1) = \frac{1}{2}3^2- \frac{1}{2}1^2 = 4, \] which agrees with (a). Suppose someone chose another antiderivative of $x$, say $F(x) = \frac{1}{2}x^2 + 7$ (check that $\frac{d}{dx}(\frac{1}{2}x^2+7) = x$), then \[ F(x)|_1^3= F(3)-F(1) = (\frac{1}{2}3^2+7)- (\frac{1}{2}1^2+7) = 4. \] No matter which antiderivative $F$ is chosen, $F(3) - F(1)$ equals $4$. \end{example} \begin{practice} Evaluate $\int_1^3 (x - 1)\, dx$ in the two ways of the previous example. \end{practice} \begin{practice} Find the area between the graph of $y = 3x^2$ and the horizontal axis for $x$ between $1$ and $2$. \end{practice} \subsection{Integrals, Antiderivatives, and Applications} The antiderivative method of evaluating definite integrals can also be used when we need to find an ``area,'' and it is useful for solving applied problems. \begin{example} Suppose that $t$ minutes after putting $1000$ bacteria on a petri plate the rate of growth of the population is $6t$ bacteria per minute. \begin{itemize} \item[(a)] How many new bacteria are added to the population during the first $7$ minutes? \item[(b)] What is the total population after $7$ minutes? \item[(c)] When will the total population be $2200$ bacteria? \end{itemize} Solution: (a) The number of new bacteria is the area under the rate of growth graph, and one antiderivative of $6t$ is $3t^2$ (check that $\frac{d}{dx}(3t^2) = 6t$) so new bacteria = $\int_0^7 6t\, dt = 3t^2|_0^7 = 147$. (b) The new population = (old population) + (new bacteria) $= 1000 + 147 = 1147$ bacteria. (c) If the total population is $2200$ bacteria, then there are $2200 - 1000 = 1200$ new bacteria, and we need to find the time $T$ needed for that many new bacteria to occur. $1200$ new bacteria $= \int_0^T 6t\, dt = 3t^2|_0^T = 3(T)^2 - 3(0)^2 = 3 T^2$ so $T^2 = 400$ and $T = 20$ minutes. After $20$ minutes, the total bacteria population will be $1000 + 1200 = 2200$. \end{example} \begin{practice} A robot has been programmed so that when it starts to move, its velocity after $t$ seconds will be $3t^2$ feet/second. \begin{itemize} \item[(a)] How far will the robot travel during its first 4 seconds of movement? \item[(b)] How far will the robot travel during its next 4 seconds of movement? \item[(c)] How many seconds before the robot is 729 feet from its starting place? \end{itemize} (Hint: an antiderivative of $3t^2$ is $t^3$.) \end{practice} \begin{practice} The velocity of a car after $t$ seconds is $2t$ feet per second. \begin{itemize} \item[(a)] How far does the car travel during its first $10$ seconds? \item[(b)] How many seconds does it take the car to travel half the distance in part (a)? \end{itemize} \end{practice} \section{Indefinite Integrals and Change} \subsection{Indefinite Integrals} The notation $\int f(x) dx = F(x)$ means that $F'(x) = f(x)$ on some (usually specified) domain of definition of $f(x)$. Recall, we call such an $F(x)$ an antiderivative of $f(x)$. \index{antiderivative} \begin{proposition} Suppose $f$ is a continuous function on an interval $(a,b)$. Then any two antiderivatives differ by a constant. \end{proposition} \pf If $F_1(x)$ and $F_2(x)$ are both antiderivatives of a function $f(x)$, then $$ (F_1(x) - F_2(x))' = F_1'(x) - F_2'(x) = f(x) - f(x) = 0. $$ Thus $F_1(x) - F_2(x) = c$ from some constant $c$ (since only constant functions have slope~$0$ everywhere). Thus $F_1(x) = F_2(x) + c$ as claimed. \qed We thus often write $$ \int f(x) dx = F(x) + C, $$ where $C$ is an (unspecified fixed) constant. Note that the proposition need not be true if $f$ is not defined on a whole interval. For example, $f(x) = 1/x$ is not defined at $0$. For any pair of constants $c_1$, $c_2$, the function $$ F(x) = \begin{cases} \ln(|x|) + c_1 & x < 0,\\ \ln(x) + c_2 & x > 0, \end{cases} $$ satisfies $F'(x) = f(x)$ for all $x\neq 0$. We often still just write $\int 1/x = \ln(|x|)+c$ anyways, meaning that this formula is supposed to hold only on one of the intervals on which $1/x$ is defined (e.g., on $(-\infty,0)$ or $(0,\infty)$). We pause to emphasize the notation difference between definite and indefinite integration. \begin{align*} \int_{a}^{b} f(x) dx &\,\,= \text{ a specific number}\\ \int f(x) dx &\,\,= \text{ a (family of) functions}\\ \end{align*} There are no small families in the world of antiderivatives: if $f$ has one antiderivative $F$ (as it always does, unless $f$ is a really unusual function), then $f$ has an infinite number of antiderivatives and every one of them has the form $F(x) + C$. \begin{example} There are many ways to write a particular indefinite integral and some of them may look very different. You can check that $F(x) = \sin (x)^2$, $G(x) = -\cos (x)^2$, and $H(x) = 2\sin (x)^2 + \cos (x)^2$ all have the same derivative $f(x) = 2\sin(x)\cos(x)$, so the indefinite integral of $2\sin(x)\cos(x)$, $\int 2\sin(x)\cos(x)\, dx$, can be written in several ways: $\sin (x)^2 + C$, or $-\cos (x)^2 + C$, or $2\sin (x)^2 + \cos (x)^2 + C$. \end{example} One of the \emph{main goals} of this course is to help you to get really good at computing $\int f(x)dx$ for various functions $f(x)$. It is useful to memorize a table of examples (see, e.g., page 406 of Stewart), since often the trick to integration is to relate a given integral to a known one. Integration is like solving a puzzle or playing a game, and often you win by moving into a position where you know how to defeat your opponent, e.g., relating your integral to integrals that you already know how to do. If you know how to do a basic collection of integrals, it will be easier for you to see how to get to a known integral from an unknown one. Whenever you successfully compute $F(x) = \int f(x) dx$, then you've constructed a \emph{mathematical gadget} that allows you to very quickly compute $\int_a^b f(x) dx$ for any $a,b$ (in the interval of definition of $f(x)$). The gadget is $F(b) - F(a)$. This is really powerful. \begin{example} \begin{align*} \int x^2 + 1 + \frac{1}{x^2 + 1} dx &= \int x^2dx + \int 1dx + \int \frac{1}{x^2+1} dx\\ &= \frac{1}{3} x^2 + x + \tan^{-1}(x) + c. \end{align*} \end{example} \begin{example} $$ \int \sqrt{\frac{5}{x}} dx = \int \sqrt{5} x^{-1/2} dx = 2\sqrt{5} x^{1/2} + c. $$ \end{example} \begin{example} $$ \int \frac{\sin(2x)}{\sin(x)} dx = \int \frac{2\sin(x)\cos(x)}{\sin(x)} = \int 2\cos(x) = 2\sin(x) + c $$ \end{example} {\it Particular Antiderivatives}: You can verify the following yourself. \begin{itemize} \item Constant Function: $\int k\, dx = kx+C$ \item Powers of $x$: $\int x^n\, dx = \frac{x^{n+1}}{n+1}+C$,\ \ \\ $n\not= -1$. $\int x^{-1}\, dx =\ln(x)+C$. Common special cases: $\int \sqrt{x}\, dx = \frac{2}{3}x^{3/2}+C$. $\int \frac{1}{\sqrt{x}}\, dx = 2x^{1/2}+C$. \item Trigonometric Functions: $\int \cos(x)\, dx = \sin(x) + C$. $\int \sin(x)\, dx = - \cos(x) + C$. $\int \sec(x)^2\, dx = \tan(x) + C$. $\int \csc(x)^2\, dx = -\cot(x) + C$. $\int \sec(x)\tan(x)\, dx = \sec(x) + C$. $\int \csc(x)\cot(x)\, dx = -\csc(x) + C$. \end{itemize} \subsection{Physical Intuition} In the previous lecture we mentioned a relation between velocity, distance, and the meaning of integration, which gave you a physical way of thinking about integration. In this section we generalize our previous observation. The following is a restatement of the fundamental theorem of calculus. \begin{theorem} (Net Change Theorem) The definite integral of the rate of change $F'(x)$ of some quantity $F(x)$ is the net change in that quantity: $$ \int_{a}^b f'(x) dx = f(b) - f(a). $$ \end{theorem} For example, if $p(t)$ is the population of students at UCSD at time $t$, then $p'(t)$ is the rate of change. Lately $p'(t)$ has been positive since $p(t)$ is growing (rapidly!). The net change interpretation of integration is that $$ \int_{t_1}^{t_2} p'(t) dt = p(t_2) - p(t_1) = \text{ change in number of students from time $t_1$ to $t_2$}. $$ Another very common example you'll seen in problems involves water flow into or out of something. If the volume of water in your bathtub is $V(t)$ gallons at time $t$ (in seconds), then the rate at which your tub is draining is $V'(t)$ gallons per second. If you have the geekiest drain imaginable, it prints out the drainage rate $V'(t)$. You can use that printout to determine how much water drained out from time $t_1$ to $t_2$: $$ \int_{t_1}^{t_2} V'(t) dt\,\, = \text { water that drained out from time $t_1$ to $t_2$ } $$ Some problems will try to confuse you with different notions of change. A standard example is that if a car has {\bf velocity} $v(t)$, and you drive forward, then slam it in reverse and drive backward to where you start (say 10 seconds total elapse), then $v(t)$ is positive some of the time and negative some of the time. The integral $\int_{0}^{10} v(t) dt$ is not the total distance registered on your odometer, since $v(t)$ is partly positive and partly negative. If you want to express how far you actually drove going back and forth, compute $\int_{0}^{10} |v(t)| dt$. The following example emphasizes this distinction: \begin{example} {\em A bug is pacing back and forth, and has velocity $v(t)=t^2-2t-8$. Find (1) the {\bf displacement} of the bug from time $t=1$ until time $t=6$ (i.e., how far the bug is at time $6$ from where it was at time $1$), and (2) the {\em total distance} the bug paced from time $t=1$ to $t=6$.} For (1), we compute \begin{align*} \int_{1}^6 (t^2 - 2t - 8) dt = \left[ \frac{1}{3} t^3 - t^2 - 8t \right]_{1}^6 = - \frac{10}{3}. \end{align*} For (2), we compute the integral of $|v(t)|$: \begin{align*} \int_{1}^6 |t^2 - 2t - 8| dt = \left[ -\left(\frac{1}{3} t^3 - t^2 - 8t\right) \right]_{1}^4 + \left[ \frac{1}{3} t^3 - t^2 - 8t \right]_{4}^6 = 18 + \frac{44}{3} = \frac{98}{3}. \end{align*} \end{example} \section{Substitution and Symmetry} Remarks: \begin{enumerate} \item The {\bf total distance traveled} is $\int_{t_1}^{t_2} |v(t)| dt$ since $|v(t)|$ is the rate of change of $F(t)=$ distance traveled (your speedometer displays the rate of change of your odometer). \item How to compute $\int_{a}^{b} |f(x)| dx$. \begin{enumerate} \item Find the zeros of $f(x)$ on $[a,b]$, and use these to break the interval up into subintervals on which $f(x)$ is always $\geq 0$ or always $\leq 0$. \item On the intervals where $f(x) \geq 0$, compute the integral of $f$, and on the intervals where $f(x)\leq 0$, compute the integral of $-f$. \item The sum of the above integrals on intervals is $\int |f(x)| dx$. \end{enumerate} \end{enumerate} This section is primarly about a powerful technique for computing definite and indefinite integrals. \subsection{The Substitution Rule} In first quarter calculus you learned numerous methods for computing derivatives of functions. For example, the {\bf power rule} asserts that $$ (x^a)' = a \cdot x^{a-1}. $$ We can turn this into a way to compute certain integrals: $$ \int x^a dx = \frac{1}{a+1} x^{a+1} \qquad \text{if $a\neq -1$}. $$ Just as with the power rule, many other rules and results that you already know yield \emph{techniques} for integration. In general integration is potentially much trickier than differentiation, because it is often not obvious which technique to use, or even how to use it. {\em Integration is a more exciting than differentiation!} Recall the {\bf chain rule}, which asserts that $$ \frac{d}{dx} f(g(x)) = f'(g(x)) g'(x). $$ We turn this into a technique for integration as follows: \begin{proposition} (Substitution Rule) \label{prop:subs} Let $u=g(x)$, we have $$ \int f(g(x)) g'(x) dx = \int f(u) du, $$ assuming that $g(x)$ is a function that is differentiable and whose range is an interval on which $f$ is continuous. \end{proposition} \pf Since $f$ is continuous on the range of $g$, Theorem~\ref{thrm:fexists} (the fundamental theorem of Calculus) implies that there is a function $F$ such that $F'= f$. Then \begin{align*} \int f(g(x)) g'(x) dx &= \int F'(g(x)) g'(x) dx\\ &= \int \left(\frac{d}{dx} F(g(x))\right) dx \\ &= F(g(x)) + C \\ &= F(u) + C = \int F'(u) du = \int f(u) du. \end{align*} \qed If $u=g(x)$ then $du = g'(x) dx$, and the substitution rule simply says if you let $u=g(x)$ formally in the integral everywhere, what you naturally would hope to be true based on the notation actually is true. The substitution rule illustrates how the notation Leibniz invented for Calculus is {\it incredibly brilliant}. It is said that Leibniz would often spend days just trying to find the right notation for a concept. He succeeded. As with all of Calculus, the best way to start to get your head around a new concept is to see severally clearly worked out examples. (And the best way to actually be able to use the new idea is to {\em do} lots of problems yourself!) In this section we present examples that illustrate how to apply the substituion rule to compute indefinite integrals. \begin{example} $$ \int x^2(x^3 + 5)^9 dx $$ Let $u=x^3 +5$. Then $du = 3x^2 dx$, hence $dx = du/(3x^2)$. Now substitute it all in: $$ \int x^2 (x^3 + 5)^9 dx = \int \frac{1}{3} u^9 = \frac{1}{30} u^{10} = \frac{1}{30}(x^3 + 5)^{10}. $$ There's no point in expanding this out: ``only simplify for a \emph{purpose}!'' \end{example} \begin{example} $$ \int \frac{e^x}{1+e^x} dx $$ Substitute $u=1+e^x$. Then $du = e^x dx$, and the integral above becomes $$ \int \frac{du}{u} = \ln|u| = \ln|1+e^x| = \ln(1+e^x). $$ Note that the absolute values are not needed, since $1+e^x>0$ for all $x$. \end{example} \begin{example} $$ \int \frac{x^2}{\sqrt{1-x}} dx $$ Keeping in mind the power rule, we make the substitution $u = 1-x$. Then $du = -dx$. Noting that $x=1-u$ by solving for $x$ in $u=1-x$, we see that the above integral becomes \begin{align*} \int - \frac{(1-u)^2}{\sqrt{u}} du &= -\int \frac{1 - 2u + u^2}{u^{1/2}} du\\ &= -\int u^{-1/2} - 2u^{1/2} + u^{3/2} du \\ &= -\left(2u^{1/2} - \frac{4}{3} u^{3/2} + \frac{2}{5} u^{5/2}\right)\\ &= -2(1-x)^{1/2} + \frac{4}{3}(1-x)^{3/2} - \frac{2}{5} (1-x)^{5/2}. \end{align*} \end{example} The steps of the ``change of variable'' method can be summarized as \begin{enumerate} \item set a new variable, say $u$ , equal to some function of the original variable $x$ (usually $u$ is set equal to some part of the original integrand function), \item calculate the differential $du$ as a function of $dx$, \item rewrite the original integral in terms of $u$ and $du$, \item integrate the new integral to get an answer in terms of $u$, \item replace the $u$ in the answer to get an answer in terms of the original variable. \end{enumerate} A ``Rule of thumb'' for changing the variable: If part of the integrand is a composition of functions, $f( g(x ) )$, then try setting $u = g(x )$, the ``inner'' function. \begin{example} elect a function for $u$ for each integral and rewrite the integral in terms of $u$ and $du$. (a)\quad $\int \cos(3x)\sqrt{2 + \sin(3x)}\, dx$, \quad (b)\quad $\int \frac{5e^x}{2+e^x}\, dx$, \quad (c)\quad $\int e^x\sin(e^x)\, dx$. Solution: (a) Put $u = 2+\sin(3x)$. Then $du = 3\cos(3x)\, dx$, and the integral becomes $\int \frac{1}{3}\sqrt{u}\, du$. (b) Put $u = 2 + e^x$. Then $du = e^x\, dx$, and the integral becomes $\int \frac{5}{u}\, du$. (c) Put $u = e^x$. Then $du = e^x\, dx$, and the integral becomes $\int \sin(u)\, du$. \end{example} \subsection{Changing the variable and definite integrals} Once an antiderivative in terms of $u$ is found, we have a choice of methods. We can \begin{itemize} \item[(a)] rewrite our antiderivative in terms of the original variable $x$, and then evaluate the antiderivative at the integration endpoints and subtract, or \item[(b)] change the integration endpoints to values of $u$, and evaluate the antiderivative in terms of $u$ before subtracting. \end{itemize} If the original integral had endpoints $x =a$ and $x =b$, and we make the substitution $u = g(x )$ and $du = g'(x )dx$, then the new integral will have endpoints $u= g(a)$ and $u=g(b)$: \[ \int_{x=a}^{x=b} \text{(original integrand)}\, dx \text{ becomes } \int_{u=g(a)}^{u=g(b)} \text{ (new integrand) }\, du. \] \begin{example} To evaluate \[ \int_0^1 (3x -1)^4\, dx, \] we can, in line with the ``Rule o thumb'' above, use the substitution $u = 3x -1$. Then $du = \frac{d}{dx}(3x -1)dx = 3 dx$, so the indefinite integral $\int (3x -1)^4\, dx$ becomes $\int \frac{1}{3}u^4\, du=\frac{1}{15}u^5+C$. (a) Converting our antiderivative back to the variable $x$ and evaluating with the original endpoints: \[ \int_0^1 (3x -1)^4\, dx=(\frac{1}{15}(3x-1)^5+C)|_0^1 =\frac{32}{15}-\frac{-1}{15}=\frac{11}{5}=2.2. \] (b) Converting the integration endpoints to values of $u$ : when $x = 0$, then $u = 3x -1 = 3\cdot 0 - 1 = - 1$, and when $x = 1$, then $u = 3x -1 = 3\cdot 1-1 = 2$ so \[ \int_0^1 (3x -1)^4\, dx = \int_{-1}^2 \frac{1}{3}u^4\, du = (\frac{1}{15}u^5+C)|_{-1}^2=\frac{11}{5}=2.2. \] Both approaches typically involve about the same amount of work and calculation. Of course, these approaches lead to the same numberical answer, by the ``substitution rule'' (Proposition \ref{prop:subs}). Here's how to do this using \sage. Note that the area under the two curves plotted below, $y=(3x-1)^4$, $0