Calculus

Keywords

Limits; Differential calculus; Integral calculus; Series calculus; Multi-variable calculus

3.1 Limits and Continuity

One of the first topics discussed in calculus is that of limits. Mathematica can be used to investigate limits graphically and numerically. In addition, the Mathematica command Limit[f[x],x->a] attempts to compute the limit of y=f(x)Image as x approaches a, limxaf(x)Image, where a can be a finite number, ∞ (Infinity), or −∞ (-Infinity). The arrow “->” is obtained by typing a minus sign “-” followed by a greater than sign “>”.

Remark 3.1

To define a function of a single variable, f(x)=expressioninxImage, enter f[x_]=expression in x. To generate a basic plot of y=f(x)Image for axbImage, enter Plot[f[x],{x,a,b}].

3.1.1 Using Graphs and Tables to Predict Limits

Example 3.1

Use a graph and table of values to investigate limx0sin3xxImage.

Solution

We clear all prior definitions of f, define f(x)=(sin3x)/xImage, and then graph y=f(x)Image on the interval [π,π]Image with Plot.

Clear[f] clears all prior definitions of f, if any. Clearing function definitions before defining new ones helps eliminate any possible confusion and/or ambiguities.

Clear [ f ] Image

f [ x _ ] = Sin [ 3 x ] x ; Image

Plot [ f [ x ] , { x , 2 π , 2 π } , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ { . 05 , . 26 , 1 , . 27 } ] } } , Image

PlotRange All ] Image

From the graph shown in Fig. 3.1, we might, correctly, conclude that limx0sin3xx=3Image. Further evidence that limx0sin3xx=3Image can be obtained by computing the values of f(x)Image for values of x “near” x=0Image. In the following, we use RandomReal. RandomReal[{a,b}] returns a “random” real number between a and b. Because we are generating “random” numbers, your results will differ from those obtained here, to define xvals to be a table of 6 “random” real numbers. The first number in xvals is between −1 and 1, the second between 1/10Image and 1/10, and so on.

Image
Figure 3.1 Graph of f(x)=(sin3x)/xImage on the interval [−2π,2π] in Wisconsin gold.

Remark 3.2

Throughout Mathematica by Example we illustrate how different options such as those that affect the coloring and labeling of a graphic are used, which include options such as PlotStyle, PlotLabel, and AxesLabel.

xvals=Table[RandomReal[{10n,10n}],{n,0,5}]Image

{ 0.710444 , 0.0134926 , 0.00161622 , 0.000546629 , 0.0000262461 , Image

3.6298466289834744 ` * 6 } Image

We then use Map to compute the value of f(x)Image for each x in xvals. Map[f,{x1,x2,...,xn}] returns the list {f(x1),f(x2),...,f(xn)}Image. We use Table to display the results in tabular form. Generally, list[[i]] returns the ith element of list while

Table[f[i],{i,start,finish,stepsize}]

computes each value of f(i)Image from start to finish in increments of stepsize. To create a table consisting of n equally spaced values, use stepsize=(finish-start)/(n-1). TableForm attempts to display a table form in a standard format such as the row-and-column format that follows.

pairs = Table [ { xvals [ [ i ] ] , fvals [ [ i ] ] } , { i , 1 , 6 } ] ; Image

TableForm [ pairs ] Image

0.710444 1.19217 0.0134926 2.99918 0.00161622 2.99999 0.000546629 3 . 0.0000262461 3 . 3.6298466289834744 ` * 6 3 . Image

From these values, we might again correctly deduce that limx0sin3xx=3Image. Of course, these results do not prove that limx0sin3xx=3Image but they are helpful in convincing us that limx0sin3xx=3Image. □

For piecewise-defined functions, you can either use Mathematica's conditional command (/;) to define the piecewise-defined function or use Piecewise.

Example 3.2

If h(x)={x2+x, if x01x, if 0<x<32x215x+25, if 3x5152x, if x>5Image, compute the following limits: (a) limx0h(x)Image, (b) limx3h(x)Image, (c) limx5h(x)Image.

Solution

We use Mathematica's conditional command, /; to define h. We must use delayed evaluation (:=) because h(x)Image cannot be computed unless Mathematica is given a particular value of x. The first line of the following defines h(x)Image to be x2+xImage for x0Image, the second line defines h(x)Image to be 1xImage for 0<x<3Image and so on. Notice that Mathematica accidentally connects (0,0)Image to (0,1)Image and then (5,0)Image to (5,5)Image. (See Fig. 3.2 (a).) The delayed evaluation is also incompatible with Mathematica's Limit function.

Image
Figure 3.2 (a) Plot does not catch the breaks in the piecewise defined function (Badger red). (b) If you use Piecewise, Plot can catch jumps (Illinois blue).

The plots p1 and p2 are not displayed because a semi-colon is included at the end of each Plot command.

Clear [ h ] Image

h [ x _ ] := x 2 + x /; x 0 Image

h [ x _ ] := 1 x /; 0 < x < 3 Image

h [ x _ ] := 2 x 2 15 x + 25 /; 3 x 5 Image

h [ x _ ] := 15 2 x /; x > 5 Image

p1 = Plot [ h [ x ] , { x , 0 , 6 } , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ { . 002 , 1 , . 85 , . 06 } ] } } ] Image

To avoid these problems and see the discontinuities in our plots, we redefine h using Mathematica's Piecewise function as follows.

Clear [ h ] Image

h [ x _ ] := Piecewise [ { { x 2 + x , x < 0 } , { 1 x , 0 < x < 3 } , { 2 x 2 15 x + 25 , 3 < = x 5 } , Image

{ 15 2 x , x > 5 } } ] ; Image

p2 = Plot [ h [ x ] , { x , 2 , 6 } , PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 1 , . 86 , . 24 , . 09 ] } } , Image

PlotRangeAll];Image

Show [ GraphicsRow [ { p1 , p2 } ] ] Image

Notice that when we execute the Plot command, Mathematica “catches” the breaks between (0,0)Image and (0,1)Image and then at (5,0)Image and (5,5)Image shown in Fig. 3.2 (b).

From Fig. 3.2, we see that limx0h(x)Image does not exist, limx3h(x)=2Image, and limx5h(x)Image does not exist. □

When limits exist, you can often use Limit[f[x],x->a] (where a may be ±Infinity) to compute limxaf(x)Image. Thus, for the previous example we see that

Limit [ h [ x ] , x 3 ] Image

2

is correct. On the other hand

Limit [ h [ x ] , x 5 ] Image

5

is incorrect. We check by computing the right hand limit, limx5+h(x)Image, using the Direction->-1 option in the Limit command and then the left limit, limx5h(x)Image, using the Direction->1 in the Limit command.

Limit [ h [ x ] , x 5 , Direction 1 ] Image

0

Limit [ h [ x ] , x 5 , Direction 1 ] Image

5

We follow the same procedure for x=0Image

Limit [ h [ x ] , x 0 ] Image

1

Limit [ h [ x ] , x 0 , Direction 1 ] Image

0

Limit [ h [ x ] , x 0 , Direction 1 ] Image

1

3.1.2 Computing Limits

Some limits involving rational functions can be computed by factoring the numerator and denominator.

Example 3.3

Compute limx9/22x2+25x+727247x14x2Image.

As stated previously, Limit[f[x],x->a] attempts to compute limxaf(x)Image,

Limit[f[x],x->a,Direction->1] attempts to compute limxaf(x)Image, and

Limit[f[x],x->a,Direction->-1] attempts to compute limxa+f(x)Image. Generally, a can be a number, ±Infinity (±∞), or another symbol.

Thus, entering

Limit [ 2 x 2 + 25 x + 72 72 47 x 14 x 2 , x 9 2 ] Image

7 79 Image

computes limx9/22x2+25x+727247x14x2=7/79Image.

Example 3.4

Calculate each limit: (a) limx5/33x27x2021x2+14x35Image; (b) limx0sinxxImage; (c) limx(1+zx)xImage; (d) limx0e3x1xImage; (e) limxe2xxImage; and (f) limx1+(1lnx1x1)Image.

Solution

In each case, we use Limit to evaluate the indicated limit. Entering

Limit [ 3 x 2 7 x 20 21 x 2 + 14 x 35 , x 5 3 ] Image

17 56 Image

computes limx5/33x27x2021x2+14x35=1756Image; and entering

Limit [ Sin [ x ] x , x 0 ] Image

1

computes limx0sinxx=1Image. Mathematica represents ∞ by Infinity. Thus, entering

Limit [ ( 1 + z / x ) x , x Infinity ] Image

e z Image

computes limx(1+zx)x=ezImage. Entering

Limit [ ( Exp [ 3 x ] 1 ) / x , x 0 ] Image

3

computes limx0e3x1x=3Image. Entering

Limit [ Exp [ 2 x ] Sqrt [ x ] , x Infinity ] Image

0

computes limxe2xx=0Image, and entering

Because lnxImage is undefined for x0Image, a right-hand limit is mathematically necessary, even though Mathematica's Limit function computes the limit correctly without the distinction.

Limit [ 1 / Log [ x ] 1 / ( x 1 ) , x 1 , Direction 1 ] Image

1 2 Image

computes limx1+(1lnx1x1)=12Image. □

3.1.3 One-Sided Limits

As illustrated previously, Mathematica can compute certain one-sided limits. The command Limit[f[x],x->a,Direction->1] attempts to compute limxaf(x)Image while Limit[f[x],x->a,Direction->-1] attempts to compute limxa+f(x)Image.

Example 3.5

Compute (a) limx0+|x|/xImage; (b) limx0|x|/xImage; (c) limx0+e1/xImage; and (d) limx0e1/xImage.

Solution

Even though limx0|x|/xImage does not exist, limx0+|x|/x=1Image and limx0|x|/x=1Image, as we see using Limit together with the Direction->-1 and Direction->1 options, respectively.

Limit [ Abs [ x ] x , x 0 , Direction 1 ] Image

Limit [ Abs [ x ] x , x 0 , Direction 1 ] Image

1

1

The Direction->-1 and Direction->1 options are used to calculate the correct values for (c) and (d), respectively. For (c), we have:

Limit [ 1 x , x 0 , Direction 1 ] Image

Technically, limx0e1/xImage does not exist (see Fig. 3.3 (a)) so the following is incorrect.

Image
Figure 3.3 (a) Graph of y = e−1/x (Army green). (b) Graph of y=e1/x2Image (Navy blue).

Limit [ Exp [ 1 / x ] , x 0 ] Image

0

However, using Limit together with the Direction option gives the correct left and right limits.

Limit [ Exp [ 1 / x ] , x 0 , Direction 1 ] Image

Limit [ Exp [ 1 / x ] , x 0 , Direction 1 ] Image

0

We confirm these results by graphing y=e1/xImage with Plot in Fig. 3.3 (a). In (b), we also show the graph of y=e1/x2Image in Fig. 3.3 (b), which is further discussed in the exercises.

p1 = Plot [ Exp [ 1 / x ] , { x , 5 , 5 } , PlotStyle CMYKColor [ . 64 , . 47 , 1 , . 4 ] , Image

PlotLabel “(a)” ] ; Image

p2 = Plot [ Exp [ 1 / x 2 ] , { x , 5 , 5 } , Image

PlotStyle CMYKColor [ 1 , . 38 , 0 , . 64 ] , Image

PlotLabel “(b)” ] ; Image

Show[GraphicsRow[{p1,p2}]]Image □

The Limit command together and its options (Direction->1 and Direction->-1) are “fragile” and should be used with caution because the results can be unpredictable. It is wise to check or confirm results using a different technique for nearly all problems encountered.

3.1.4 Continuity

Definition 3.1

The function y=f(x)Image is continuous at x=aImage if

1.  limxaf(x)Image exists;

2.  f(a)Image exists; and

3.  limxaf(x)=f(a)Image.

Note that the third item in the definition means that both (1) and (2) are satisfied. But, if either of (1) or (2) is not satisfied the function is not continuous at the number in question. The function y=f(x)Image is continuous on the open interval I if f(x)Image is continuous at each number a contained in the interval I. Loosely speaking, the “standard” set of functions (polynomials, rational, trigonometric, etc...) are continuous on their domains.

Remark 3.3

Be careful with regard to this. For example, since limx0xImage does not exist, many would say that f(x)=xImage is right continuous at x=0Image.

Example 3.6

For what value(s) of x, if any, are each of the following functions continuous? (a) f(x)=x38xImage; (b) f(x)=sin2xImage; (c) f(x)=(x1)/(x+1)Image; (d) f(x)=(x1)/(x+1)Image.

Solution

(a) Polynomial functions are continuous for all real numbers. In interval notation, f(x)Image is continuous on (,)Image. (b) Because the sine function is continuous for all real numbers, f(x)=sin2xImage is continuous for all real numbers. In interval notation, f(x)Image is continuous on (,)Image. (c) The rational function f(x)=(x1)/(x+1)Image is continuous for all x1Image. In interval notation, f(x)Image is continuous on (,1)(1,)Image. (d) f(x)=(x1)/(x+1)Image is continuous if the radicand is nonnegative. In interval notation, f(x)Image is strictly continuous on (,1)(1,)Image but some might say that f(x)Image is continuous on (,1)[1,)Image, where it is understood that f(x)Image is right continuous at x=1Image. We see this by graphing each function with the following commands. See Fig. 3.4. Note that in p3, the vertical line is not a part of the graph of the function—it is a vertical asymptote. If you were to redraw the figure by hand, the vertical line would not be a part of the graph.

Image
Figure 3.4 (a) Polynomials (Michigan State green), (b) trigonometric (Ohio State gray), (c) rational (Alabama crimson), and (d) root functions (Auburn orange) are usually continuous on their domains.

p1 = Plot [ x 3 8 x , { x , 5 , 5 } , PlotLabel “(a)” , Image

PlotStyle CMYKColor [ . 82 , 0 , . 64 , . 7 ] ] ; Image

p2 = Plot [ Sin [ 2 x ] , { x , 5 , 5 } , PlotLabel “(b)” , Image

PlotStyle CMYKColor [ . 56 , . 47 , . 47 , . 15 ] ] ; Image

p3 = Plot [ ( ( x 1 ) / ( x + 1 ) ) , { x , 5 , 5 } , PlotLabel “(c)” , Image

PlotStyle CMYKColor [ . 25 , . 97 , . 76 , . 18 ] ] ; Image

p4 = Plot [ Sqrt [ ( x 1 ) / ( x + 1 ) ] , { x , 5 , 5 } , PlotLabel “(d)” , Image

PlotStyle CMYKColor [ 0 , . 61 , . 97 , 0 ] ] ; Image

Show[GraphicsGrid[{{p1,p2},{p3,p4}}]]Image  □

Computers are finite state machines so handling “interesting” functions can be problematic, especially when one must distinguish between rational and irrational numbers. We assume that if x=p/qImage is a rational number (p and q integers), p/qImage is a reduced fraction. One way of tackling these sorts of problems is to view rational numbers as ordered pairs, {a,b}Image. If a and b are integers, Mathematica automatically reduces a/bImage so Denominator[a/b] or a/b//Denominator returns the denominator of the reduced fraction; Numerator[a/b] or a/b//Numerator returns the numerator of the reduced fraction. If you want to see the points (x,f(x))Image for which x is rational, we use ListPlot.

Example 3.7

Let f(x)={1/q, if x=p/q is rational0, if x is irrationalImage. Create a representative graph of f(x)Image.

Solution

You cannot see points: the measure of the rational numbers is 0, and the measure of the irrational numbers is the continuum, C. A true graph of f(x)Image would look like the graph of y=0Image. In the context of the example, we want to see how the graph of f(x)Image looks for rational values of x. We use a few points to illustrate the technique by using Table and Flatten to generate a set of ordered pairs.

Flatten[list,n] flattens list to level n.

In Mathematica, an ordered pair (a,b)Image is represented by {a,b}Image.

t1 = Flatten [ Table [ { n , m } , { n , 1 , 5 } , { m , 1 , 5 } ] , 1 ] Image

{ { 1 , 1 } , { 1 , 2 } , { 1 , 3 } , { 1 , 4 } , { 1 , 5 } , { 2 , 1 } , { 2 , 2 } , Image

{ 2 , 3 } , { 2 , 4 } , { 2 , 5 } , { 3 , 1 } , { 3 , 2 } , { 3 , 3 } , { 3 , 4 } , { 3 , 5 } , { 4 , 1 } , Image

{ 4 , 2 } , { 4 , 3 } , { 4 , 4 } , { 4 , 5 } , { 5 , 1 } , Image

{ 5 , 2 } , { 5 , 3 } , { 5 , 4 } , { 5 , 5 } } Image

Next, we defined a function f. Assuming that a and b are integers, given an ordered pair {a,b}Image, f({a,b})Image returns the point {a/b,1/(Reduced denominator of a/b)}Image

f [ { a _ , b _ } ] := { a / b , 1 / ( a / b // Denominator ) } Image

We use Map to compute the value of f for each ordered pair in t1. The resulting list is named t2.

t2 = Map [ f , t1 ] Image

{ { 1 , 1 } , { 1 2 , 1 2 } , { 1 3 , 1 3 } , { 1 4 , 1 4 } , { 1 5 , 1 5 } , { 2 , 1 } , { 1 , 1 } , Image

{ 2 3 , 1 3 } , { 1 2 , 1 2 } , { 2 5 , 1 5 } , { 3 , 1 } , { 3 2 , 1 2 } , { 1 , 1 } , Image

{ 3 4 , 1 4 } , { 3 5 , 1 5 } , { 4 , 1 } , { 2 , 1 } , { 4 3 , 1 3 } , { 1 , 1 } , Image

{ 4 5 , 1 5 } , { 5 , 1 } , { 5 2 , 1 2 } , { 5 3 , 1 3 } , { 5 4 , 1 4 } , { 1 , 1 } } Image

Notice that t2 contains duplicate entries. We can remove them using Flatten but doing so does not affect the plot shown in Fig. 3.5 (a).

Image
Figure 3.5 (a) After step 1 (Notre Dame gold). (b) After step 2 (USC cardinal). (c) Examining the numerator rather than the denominator (Oklahoma crimson). (d) The sine of the numerator (Texas burnt orange).

p1 = ListPlot [ t2 , PlotRange { { 0 , 3 } , { 0 , 1 } } , AspectRatio 1 , Image

PlotStyle - > CMYKColor [ . 06 , . 27 , 1 , . 12 ] , Image

PlotLabel “(a)” ] ; Image

To generate a “prettier” plot, we repeat the procedure using more points. After entering each command the results are not displayed because we include a semicolon (;) at the end of each. See Fig. 3.5 (b).

t3 = Flatten [ Table [ { n , m } , { n , 1 , 300 } , { m , 1 , 200 } ] , 1 ] ; Image

t4 = Map [ f , t3 ] ; Image

p2 = ListPlot [ t4 , PlotRange { { 0 , 3 } , { 0 , 1 } } , AspectRatio 1 , Image

PlotStyle - > CMYKColor [ . 07 , 1 , . 65 , . 32 ] , Image

PlotLabel“(b)”];Image

This function is interesting because it is continuous at the irrationals and discontinuous at the rationals.

We can consider other functions in similar contexts. In the following the y-coordinate is the numerator rather than the denominator. See Fig. 3.5 (c).

Clear [ f ] Image

f [ { a _ , b _ } ] := { a / b , a / b // Numerator } ; Image

t3 = Flatten [ Table [ { n , m } , { n , 1 , 100 } , { m , 1 , 100 } ] , 1 ] ; Image

t4 = Map [ f , t3 ] ; Image

p3 = ListPlot [ t4 , PlotRange { { 0 , 100 } , { 0 , 100 } } , AspectRatio 1 , Image

PlotStyle CMYKColor [ 0 , 1 , . 65 , . 34 ] , Image

PlotLabel “(c)” ] ; Image

With Mathematica, we can modify commands to investigate how changing parameters affect a given situation. In the following, we compute the sine of p if x=p/qImage. See Fig. 3.5 (d).

Clear [ f ] Image

f [ { a _ , b _ } ] := { a / b , Sin [ ( a / b // Numerator ) ] } ; Image

t5 = Flatten [ Table [ { n , m } , { n , 1 , 300 } , { m , 1 , 200 } ] , 1 ] ; Image

t6 = Map [ f , t5 ] ; Image

p4 = ListPlot [ t6 , PlotRange { { 0 , 3 } , { 0 , 1 } } , AspectRatio 1 , Image

PlotStyle CMYKColor [ 0 , . 65 , 1 , . 09 ] , Image

PlotLabel “(d)” ] ; Image

Show[GraphicsGrid[{{p1,p2},{p3,p4}}]]Image  □

3.2 Differential Calculus

3.2.1 Definition of the Derivative

Assuming the derivative exists, as h approaches 0 the secants approach the tangent. Hence, if the limit exists the derivative gives us the slope of a function at that particular value of x.

The Limit command can be used along with Simplify to compute the derivative of a function using the definition of the derivative.

Example 3.8

Use the definition of the derivative to compute the derivative of (a) f(x)=x+1/xImage, (b) g(x)=1/xImage and (c) f(x)=sin2xImage.

Solution

For (a), we first define f, compute the difference quotient, (f(x+h)f(x))/hImage, simplify the difference quotient with Simplify, and use Limit to calculate the derivative.

f [ x _ ] = x + 1 / x ; Image

step1 = ( f [ x + h ] f [ x ] ) / h Image

step2 = Simplify [ step1 ] Image

Limit [ step2 , h 0 ] Image

h 1 x + 1 h + x h Image

1 + h x + x 2 x ( h + x ) Image

1 1 x 2 Image

For (b), we use the same approach as in (a) but use Together rather than Simplify to reduce the complex fraction.

g [ x _ ] = 1 / Sqrt [ x ] ; Image

step1 = ( g [ x + h ] g [ x ] ) / h Image

step2 = Together [ step1 ] Image

Limit [ step2 , h 0 ] Image

1 x + 1 h + x h Image

x h + x h x h + x Image

1 2 x 3 / 2 Image

For (c), observe that Simplify instructs Mathematica to apply elementary trigonometric identities.

f [ x _ ] = Sin [ 2 x ] ; Image

step1 = ( f [ x + h ] f [ x ] ) / h Image

step2 = Simplify [ step1 ] Image

Limit [ step2 , h 0 ] Image

Sin[2x]+Sin[2(h+x)]hImage

2 Cos [ h + 2 x ] Sin [ h ] h Image

2Cos[2x]Image □

If the derivative of y=f(x)Image exists at x=aImage, a geometric interpretation of f(a)Image is that f(a)Image is the slope of the line tangent to the graph of y=f(x)Image at the point (a,f(a))Image.

To motivate the definition of the derivative, many calculus texts choose a value of x, x=aImage, and then draw the graph of the secant line passing through the points (a,f(a))Image and (a+h,f(a+h))Image for “small” values of h to show that as h approaches 0, the secant line approaches the tangent line. An equation of the secant line passing through the points (a,f(a))Image and (a+h,f(a+h))Image is given by

y f ( a ) = f ( a + h ) f ( a ) ( a + h ) a ( x a ) or y = f ( a + h ) f ( a ) h ( x a ) + f ( a ) .

Example 3.9

If f(x)=x24xImage, graph f(x)Image together with the secant line containing (1,f(1))Image and (1+h,f(1+h))Image for various values of h.

Solution

We begin by considering a particular h value. We choose h=0.4Image. We then define f(x)=x24xImage. In p1, we graph f(x)Image in black on the interval [1,5]Image, in p2 we place a blue point at (1,f(1))Image and a green point at (1.4,f(1.4)Image, in p3 we graph the tangent to y=f(x)Image at (1,f(1))Image in red, in p4 we graph the secant containing (1,f(1))Image and (1.4,f(1.4)Image in purple, and finally we show all four graphics together with Show in Fig. 3.6.

Image
Figure 3.6 Plots of y = x2 − 4x, the tangent at (1,f(1)), and the secant containing (1,f(1)) and (1 + h,f(1 + h)) if h = 0.4 (Georgia Tech colors).

Remember that when a semi-colon is placed at the end of a command, the resulting output is not displayed. The names of the colors that Mathematica knows are listed in the ColorSchemes palette followed by “Known” and then “System.”

f [ x _ ] = x 2 4 x ; Image

p1 = Plot [ f [ x ] , { x , 1 , 5 } , PlotStyle CMYKColor [ . 08 , . 3 , 1 , 0 ] ] ; Image

p2 = Graphics [ { PointSize [ . 03 ] , CMYKColor [ 1 , . 88 , . 39 , . 42 ] , Point [ { 1 , f [ 1 ] } ] , Image

CMYKColor [ . 04 , . 14 , . 67 , 0 ] , Point [ { 1 + . 4 , f [ 1 + . 4 ] } ] } ] ; Image

p3 = Plot [ f [ 1 ] ( x 1 ) + f [ 1 ] , { x , 1 , 5 } , PlotStyle CMYKColor [ 1 , . 88 , . 39 , . 42 ] ] ; Image

p4 = Plot [ ( f [ 1 + . 4 ] f [ 1 ] ) / . 4 ( x 1 ) + f [ 1 ] , { x , 1 , 5 } , Image

PlotStyle CMYKColor [ . 04 , . 14 , . 67 , 0 ] ] ; Image

Show [ p1 , p2 , p3 , p4 , PlotRange { { 1 , 5 } , { 6 , 6 } } , AspectRatio 1 ] Image

We now generalize the previous set of commands for arbitrary h0Image values. g(h)Image shows plots of y=x24xImage, the tangent at (1,f(1))Image, and the secant containing (1,f(1))Image and (1+h,f(1+h))Image.

Clear [ f , g ] ; Image

f [ x _ ] = x 2 4 x ; Image

g [ h _ ] := Module [ { p1 , p2 , p3 , p4 } , Image

p1 = Plot [ f [ x ] , { x , 1 , 5 } , PlotStyle CMYKColor [ . 08 , . 3 , 1 , 0 ] ] ; Image

p2 = Graphics [ { PointSize [ . 03 ] , CMYKColor [ 1 , . 88 , . 39 , . 42 ] , Point [ { 1 , f [ 1 ] } ] , Image

CMYKColor [ . 04 , . 14 , . 67 , 0 ] , Point [ { 1 + h , f [ 1 + h ] } ] } ] ; Image

p3 = Plot [ f [ 1 ] ( x 1 ) + f [ 1 ] , { x , 1 , 5 } , PlotStyle CMYKColor [ 1 , . 88 , . 39 , . 42 ] ] ; Image

p4 = Plot [ ( f [ 1 + h ] f [ 1 ] ) / h ( x 1 ) + f [ 1 ] , { x , 1 , 5 } , Image

PlotStyle - > CMYKColor [ . 04 , . 14 , . 67 , 0 ] ] ; Image

Show [ p1 , p2 , p3 , p4 , PlotRange { { 1 , 5 } , { 6 , 6 } } , AspectRatio 1 ] ] Image

Table[f[x],{x,start,stop,stepsize}] creates a table of f(x)Image values beginning with startImage and ending with stopImage using increments of stepsizeImage. Given a table, Partition[table,n] partitions the table into n element subgroups. Thus if a table, t1 has 9 elements, Partition[t1, 3] creates a 3×3Image grid; three sets of three elements each.

Using Table followed by GraphicsGrid, we can create an table of graphics for various values of h like that shown in Fig. 3.7. With Table, the dimensions of the grid displayed on your computer are based on the size of the active Mathematica window. To control the dimensions of the grid, we use GraphicsGrid together with Partition and Show.

Image
Figure 3.7 Plots of y = x2 − 4x, the tangent at (1,f(1)), and the secant containing (1,f(1)) and (1 + h,f(1 + h)) for various values of h.

t1 = Table [ g [ k ] , { k , 1 , . 0001 , ( 1 . 0001 ) / 8 } ] ; Image

Show [ GraphicsGrid [ Partition [ t1 , 3 ] ] ] Image

Animate works in the same way as Table and is very similar to Manipulate. Entering

Animate [ g [ k ] , { k , 1 , . 0001 , ( 1 . 0001 ) / 99 } ] Image

generates an animation of g(k)Image and 100 equally spaced values of k starting with k=1Image and ending with k=0.0001Image. To animate the result, use the toolbar in the animate graphic. To vary g continuously and not use a specific stepsize enter Animate[g[k],{k,1,.0001}].

Image

After animating the selection, you can control the animation (speed, direction, pause, and so on) with the buttons at the top of the animation window.

With Mathematica 11, you can use Manipulate to help generate animations and images that you can adjust based on changing parameter values.

To illustrate how to do so, we begin by redefining f and then defining m(a,h)Image. Given a and h values, m(a,h)Image plots f(x)Image for 10x10Image (p1), plots a blue point at (a,f(a))Image and a green point at (a+h,f(a+h))Image (p2), plots f(a)(xa)+f(a)Image (the tangent to the graph of f(x)Image at (a,f(a))Image) for 1x5Image in red (p3), the secant containing (a,f(a))Image and (a+h,f(a+h))Image for 10x10Image in purple (p4) and finally displays all four graphics together with Show. Using PlotRange, we indicate that horizontal axis displays x values between −10 and 10, the vertical axis displays y values between −10 and 10; AspectRatio->1 means that the ratio of the lengths of the x to y axes is 1. Thus, the plot scaling is correct. Note that when we use Module to define m, p1, p2, p3, and p4 are local to the function m. This means that if you have such objects defined elsewhere in your Mathematica notebook, those objects are not affected when you compute m.

Clear [ m , f ] ; Image

f [ x _ ] = x 2 4 x ; Image

m [ a _ , h _ ] := Module [ { p1 , p2 , p3 , p4 } , Image

p1 = Plot [ f [ x ] , { x , 10 , 10 } , PlotStyle CMYKColor [ . 08 , . 3 , 1 , 0 ] ] ; Image

p2 = Graphics [ { PointSize [ . 03 ] , CMYKColor [ 1 , . 88 , . 39 , . 42 ] , Point [ { a , f [ a ] } ] , Image

CMYKColor [ . 04 , . 14 , . 67 , 0 ] , Point [ { a + h , f [ a + h ] } ] } ] ; Image

p3 = Plot [ f [ a ] ( x a ) + f [ a ] , { x , 1 , 5 } , PlotStyle CMYKColor [ 1 , . 88 , . 39 , . 42 ] ] ; Image

p4 = Plot [ ( f [ a + h ] f [ a ] ) / h ( x a ) + f [ a ] , { x , 10 , 10 } , Image

PlotStyle CMYKColor [ . 04 , . 14 , . 67 , 0 ] ] ; Image

Show [ p1 , p2 , p3 , p4 , PlotRange { { 10 , 10 } , { 10 , 10 } } , AspectRatio 1 ] ] Image

Now we use Manipulate to create a “mini” program. The sliders (centered at a=0Image and h=.5Image with range from −10 to 10 an −1 to 1, respectively) allow you to see how changing a and h affects the plot. See Fig. 3.8.

Image
Figure 3.8 With Manipulate, we can perform animations and see how a function changes depending on parameter values. When you press the + button, the bar expands so that you can control the Manipulate object.

Manipulate [ m [ a , h ] , { { a , 0 } , 10 , 10 } , { { h , . 5 } , 1 , 1 } ] Image

Fig. 3.8 illustrates the special case when f(x)=x24xImage. To illustrate the same concept using a “standard” set of functions (polynomials, rational, root, and trig), we first define the functions

quad [ x _ ] = ( x + 2 ) 2 2 ; Image

cubic [ x _ ] = 1 / 10 x ( x 2 25 ) ; Image

rational [ x _ ] = 50 / ( ( x + 5 ) ( x 5 ) ) ; Image

root [ x _ ] = 3 Sqrt [ x + 5 ] ; Image

sin [ x _ ] = 5 Sin [ x ] ; Image

and then we adjust m by defining a few of these “standard” and then defining the function mmore, which performs the same actions as m but does so for the function selected. We then use Manipulate to create an object that shows the secant (in yellow), the tangent (in blue) for the selected function, a value, and h value. See Fig. 3.9.

Image
Figure 3.9 With this Manipulate object, we see how various functions, a values, and h values affect the secant to y = f(x) passing through (a,f(a)) and (a + h,f(a + h)) and the tangent to y = f(x) at (a,f(a)). (For interpretation of the colors in this figure, the reader is referred to the web version of this chapter.)

Clear [ mmore ] ; Image

mmore [ f _ , a _ , h _ ] := Module [ { p1 , p2 , p3 , p4 } , Image

p1 = Plot [ f [ x ] , { x , 10 , 10 } , PlotStyle CMYKColor [ . 08 , . 3 , 1 , 0 ] ] ; Image

p2 = Graphics [ { PointSize [ . 03 ] , CMYKColor [ 1 , . 88 , . 39 , . 42 ] , Point [ { a , f [ a ] } ] , Image

CMYKColor [ . 04 , . 14 , . 67 , 0 ] , Point [ { a + h , f [ a + h ] } ] } ] ; Image

p3 = Plot [ f [ a ] ( x a ) + f [ a ] , { x , 10 , 10 } , PlotStyle CMYKColor [ 1 , . 88 , . 39 , . 42 ] ] ; Image

p4 = Plot [ ( f [ a + h ] f [ a ] ) / h ( x a ) + f [ a ] , { x , 10 , 10 } , Image

PlotStyle CMYKColor [ . 04 , . 14 , . 67 , 0 ] ] ; Image

Show [ p1 , p2 , p3 , p4 , PlotRange { { 10 , 10 } , { 10 , 10 } } , AspectRatio 1 ] ] Image

Manipulate [ mmore [ f , a , h ] , { { f , quad } , { quad , cubic , rational , root , sin } } , Image

{{a,0},10,10},{{h,1},2,2}]Image  □

3.2.2 Calculating Derivatives

The functions D and ' are used to differentiate functions. Assuming that y=f(x)Image is differentiable,

1.  D[f[x],x] computes and returns f(x)=df/dxImage,

2.  f'[x] computes and returns f(x)=df/dxImage,

3.  f''[x] computes and returns f(2)(x)=d2f(x)/dx2Image, and

4.  D[f[x],{x,n}] computes and returns f(n)(x)=dnf(x)/dxnImage.

5.  You can use the Image button located on the Basic Math Assistant and Basic Math Input palettes to create templates to compute derivatives.

Fig. 3.10 illustrates various ways of computing derivatives using the ′ symbol, D, and the ∂ symbol.

Image
Figure 3.10 You can use ′, D, and ∂ to compute derivatives of functions.

Mathematica knows the numerous differentiation rules, including the product, quotient, and chain rules. Thus, entering

Clear [ f , g ] Image

D [ f [ x ] g [ x ] , x ] Image

g [ x ] f [ x ] + f [ x ] g [ x ] Image

shows us that ddx(f(x)g(x))=f(x)g(x)+f(x)g(x)Image; entering

Together [ D [ f [ x ] / g [ x ] , x ] ] Image

g [ x ] f [ x ] f [ x ] g [ x ] g [ x ] 2 Image

shows us that

Remark 3.4

Throughout the text, input is in Bold and output is Not; output follows input ddx(f(x)/g(x))=(f(x)g(x)f(x)g(x))/(g(x))2Image; and entering

D[f[g[x]],x]Image f[g[x]]g[x]Image

shows us that ddx(f(g(x)))=f(g(x))g(x)Image.

Example 3.10

Compute the first and second derivatives of (a) y=x4+43x33x2Image, (b) f(x)=4x552x410x3Image, (c) y=e2x+e2xImage, and (d) y=(1+1/x)xImage.

Solution

For (a), we use D.

D[x4+4/3x33x2,x]Image 6x+4x2+4x3Image

For (b), we first define f and then use ′ together with Factor to calculate and factor f(x)Image and f(x)Image.

f [ x _ ] = 4 x 5 5 / 2 x 4 10 x 3 ; Image

Factor[f[x]]Image 10x2(1+x)(3+2x)Image Factor[f[x]]Image 10x(63x+8x2)Image

For (c), we use Simplify together with D to calculate and simplify yImage and yImage.

D[Sqrt[Exp[2x]+Exp[2x]],x]Image

2 e 2 x + 2 e 2 x 2 e 2 x + e 2 x Image

D [ Sqrt [ Exp [ 2 x ] + Exp [ 2 x ] ] , { x , 2 } ] // Simplify Image

e 2 x + e 2 x ( 1 + 6 e 4 x + e 8 x ) ( 1 + e 4 x ) 2 Image

By hand, (d) would require logarithmic differentiation. The second derivative would be particularly difficult to compute by hand. Mathematica quickly computes and simplifies each derivative.

Simplify [ D [ ( 1 + 1 / x ) x , x ] ] Image

( 1 + 1 x ) x ( 1 + ( 1 + x ) Log [ 1 + 1 x ] ) 1 + x Image

Simplify [ D [ ( 1 + 1 / x ) x , { x , 2 } ] ] Image

(1+1x)x(1+x2x(1+x)Log[1+1x]+x(1+x)2Log[1+1x]2)x(1+x)2Image  □

The command Map[f,list] applies the function f to each element of the list list. Thus, if you are computing the derivatives of a large number of functions, you can use Map together with D.

Map and operations on lists are discussed in more detail in Chapter 4.

A built-in Mathematica function is threadable if f[list] returns the same result as Map[f,list]. Many familiar functions like D and Integrate are threadable.

Example 3.11

Compute the first and second derivatives of sinxImage, cosxImage, tanxImage, sin1xImage, cos1xImage, and tan1xImage.

Solution

Notice that lists are contained in braces. Thus, entering

Map [ D [ # , x ] & , { Sin [ x ] , Cos [ x ] , Tan [ x ] , Image

ArcSin [ x ] , ArcCos [ x ] , ArcTan [ x ] } ] Image

{ Cos [ x ] , Sin [ x ] , Sec [ x ] 2 , 1 1 x 2 , 1 1 x 2 , 1 1 + x 2 } Image

computes the first derivative of the three trigonometric functions and their inverses. In this case, we have applied a pure function to the list of trigonometric functions and their inverses. Given an argument #, D[#,x]& computes the derivative of # with respect to x. The & symbol is used to mark the end of a pure function. Similarly, entering

Map [ D [ # , { x , 2 } ] & , { Sin [ x ] , Cos [ x ] , Tan [ x ] , Image

ArcSin [ x ] , ArcCos [ x ] , ArcTan [ x ] } ] Image

{Sin[x],Cos[x],2Sec[x]2Tan[x],x(1x2)3/2,x(1x2)3/2,2x(1+x2)2}Image

computes the second derivative of the three trigonometric functions and their inverses. Because D is threadable, the same results are obtained with the following commands.

D [ { Sin [ x ] , Cos [ x ] , Tan [ x ] , Image

ArcSin [ x ] , ArcCos [ x ] , ArcTan [ x ] } , x ] Image

{ Cos [ x ] , Sin [ x ] , Sec [ x ] 2 , 1 1 x 2 , 1 1 x 2 , 1 1 + x 2 } Image

D [ { Sin [ x ] , Cos [ x ] , Tan [ x ] , Image

ArcSin [ x ] , ArcCos [ x ] , ArcTan [ x ] } , { x , 2 } ] Image

{Sin[x],Cos[x],2Sec[x]2Tan[x],x(1x2)3/2,x(1x2)3/2,2x(1+x2)2}Image □

With DynamicModule, we create a simple dynamic that lets you compute the first and second derivatives of basic functions and plot them on a standard viewing window, [5,5]×[5,5]Image. The layout of Fig. 3.11 is primarily determined by Panel, Column, and Grid. The default function is y=x2Image. To compute and graph the first and second derivatives of a different function, simply type over x2Image with the desired function.

Image
Figure 3.11 Seeing the relationship between the first and second derivative of a function and the original function (Mercer University colors).

Panel [ DynamicModule [ { f = x 2 } , Image

Column [ { InputField [ Dynamic [ f ] ] , Grid [ { { “First Derivative” , Image

Panel [ Dynamic [ D [ f , x ] // Simplify ] ] } , Image

{ “Second Derivative” , Panel [ Dynamic [ D [ f , { x , 2 } ] // Simplify ] ] } } ] , Image

Dynamic [ Plot [ Evaluate [ Tooltip [ { f , D [ f , x ] , D [ f , { x , 2 } ] } ] ] , Image

{ x , 5 , 5 } , PlotRange { 5 , 5 } , Image

PlotStyle { { CMYKColor [ 0 , . 65 , 1 , . 04 ] } , { Black } , { CMYKColor [ . 01 , . 05 , . 23 , . 03 ] } } , Image

AspectRatio Automatic ] ] } ] ] , ImageSize { 300 , 300 } ] Image

3.2.3 Implicit Differentiation

If an equation contains two variables, x and y, implicit differentiation can be carried out by explicitly declaring y to be a function of x, y=y(x)Image, and using D or by using the Dt command.

Example 3.12

Find y=dy/dxImage if (a) cos(exy)=xImage and (b) ln(x/y)+5xy=3yImage.

Solution

For (a) we illustrate the use of D. Notice that we are careful to specifically indicate that y=y(x)Image. First we differentiate with respect to x

Clear [ x , y ] Image

s1 = D [ Cos [ Exp [ x y [ x ] ] ] x , x ] Image

1exy[x]Sin[exy[x]](y[x]+xy[x])Image and then we solve the resulting equation for y=dy/dxImage with Solve.

Solve [ s1 = = 0 , y [ x ] ] Image

{ { y [ x ] e x y [ x ] ( Csc [ e x y [ x ] ] + e x y [ x ] y [ x ] ) x } } Image

For (b), we use Dt. When using Dt, we interpret Dt[x]=1 and Dt[y]=y=dy/dxImage. Thus, entering

s2 = Dt [ Log [ x / y ] + 5 x y 3 y ] Image

5 y Dt [ x ] 3 Dt [ y ] + 5 x Dt [ y ] + y ( Dt [ x ] y x Dt [ y ] y 2 ) x Image

s3 = s2 /. { Dt [ x ] 1 , Dt [ y ] dydx } Image

3 dydx + 5 dydx x + 5 y + ( dydx x y 2 + 1 y ) y x Image

and solving for dydx with Solve

Solve [ s3 = = 0 , dydx ] Image

{ { dydx y ( 1 + 5 x y ) x ( 1 3 y + 5 x y ) } } Image

shows us that if ln(x/y)+5xy=3yImage, y=dydx=(1+5xy)y(5xy3y1)xImage.

To graph each equation, we use ContourPlot. Generally, given an equation of the form f(x,y)=g(x,y)Image, the command

ContourPlot[f[x,y]==g[x,y],{x,a,b},{y,c,d}]

attempts to plot the graph of f(x,y)=g(x,y)Image on the rectangle [a,b]×[c,d]Image. Using Show together with GraphicsRow, we show the two graphs side-by-side in Fig. 3.12.

Image
Figure 3.12 On the left, cos(exy)=xImage for −2 ⩽ x ⩽ 2 and −4 ⩽ y ⩽ 4; on the right, ln(x/y)+5xy=3yImage for .01 ⩽ x ⩽ 3 and .01 ⩽ y ⩽ 3 (MIT colors).

cp1 = ContourPlot [ Cos [ Exp [ x y ] ] == x , { x , 2 , 2 } , { y , 4 , 4 } , PlotPoints 120 , Image

Frame False , Axes Automatic , AxesOrigin { 0 , 0 } , Contours 40 , Image

ContourStyle CMYKColor [ . 24 , 1 , . 78 , . 17 ] , AxesLabel { x , y } , Image

PlotLabel “(a)” ] ; Image

cp2 = ContourPlot [ Log [ x / y ] + 5 x y = = 3 y , { x , . 01 , 3 } , { y , . 01 , 3 } , PlotPoints 120 , Image

AxesLabel { x , y } , PlotLabel “(b)” , Image

ContourStyle CMYKColor [ . 48 , . 39 , . 39 , . 04 ] , Image

Frame False , Axes Automatic , AxesOrigin { 0 , 0 } ] ; Image

Show[GraphicsRow[{cp1,cp2}]]Image □

3.2.4 Tangent Lines

If f(a)Image exists, f(a)Image is interpreted to be the slope of the line tangent to the graph of y=f(x)Image at the point (a,f(a))Image. In this case, an equation of the tangent is given by

y f ( a ) = f ( a ) ( x a ) or y = f ( a ) ( x a ) + f ( a ) .

Example 3.13

Find an equation of the line tangent to the graph of f(x)=sinx1/3+cos1/3xImage at the point with x-coordinate x=5π/3Image.

Solution

Recall that when computing odd roots of negative numbers, Mathematica returns the value with the largest imaginary part. However, for our purposes, we need the real-valued root. To obtain the real-valued root, use Surd: Surd[x,n] returns the real-valued root of x if n is odd. Because we will be graphing a function involving odd roots of negative numbers, we define f(x)Image using the Surd function and then compute f(x)Image.

f [ x _ ] = Sin [ Surd [ x , 3 ] ] + Surd [ Cos [ x ] , 3 ] ; Image

f [ x ] Image

Cos[x3]3x32Sin[x]3Cos[x]32Image

Then, the slope of the line tangent to the graph of f(x)Image at the point with x-coordinate x=5π/3Image is

f [ 5 Pi / 3 ] Image

1 2 1 / 3 3 + Cos [ ( 5 π 3 ) 1 / 3 ] 3 1 / 3 ( 5 π ) 2 / 3 Image

f [ 5 Pi / 3 ] // N Image

0.440013

while the y-coordinate of the point is

f [ 5 Pi / 3 ] Image

1 2 1 / 3 + Sin [ ( 5 π 3 ) 1 / 3 ] Image

f [ 5 Pi / 3 ] // N Image

1.78001

Thus, an equation of the line tangent to the graph of f(x)Image at the point with x-coordinate x=5π/3Image is

y ( 1 2 3 + sin 5 π / 3 3 ) = ( cos 5 π / 3 3 3 3 25 π 2 3 + 1 2 3 3 ) ( x 5 π 3 ) ,

as shown in Fig. 3.13.

Image
Figure 3.13 f(x)=sinx1/3+cos1/3xImage together with its tangent at the point (5π/3,f(5π/3))Image (Stanford colors).

p1 = Plot [ f [ x ] , { x , 0 , 4 Pi } , PlotStyle CMYKColor [ 0 , 1 , . 65 , . 34 ] ] ; Image

p2 = ListPlot [ { { 5 Pi / 3 , f [ 5 Pi / 3 ] } // N } , PlotStyle { PointSize [ . 03 ] , Image

CMYKColor [ . 48 , . 36 , . 24 , . 66 ] } ] ; Image

p3 = Plot [ f [ 5 Pi / 3 ] ( x 5 Pi / 3 ) + f [ 5 Pi / 3 ] , { x , 0 , 4 Pi } , Image

PlotStyle->CMYKColor[.48,.36,.24,.66]];Image

Show [ p1 , p2 , p3 , AspectRatio - > Automatic , PlotRange All , Image

AxesLabel { x , y } ] Image

We use Manipulate to plot different tangents or animate the tangents as shown in Fig. 3.14.

Image
Figure 3.14 Using Manipulate to plot f(x) together with various tangents.

Manipulate [ Image

p1 = Plot [ f [ x ] , { x , 0 , 4 Pi } , PlotStyle CMYKColor [ 0 , 1 , . 65 , . 34 ] ] ; Image

p2 = ListPlot [ { { a , f [ a ] } // N } , PlotStyle { PointSize [ . 03 ] , Image

CMYKColor [ . 48 , . 36 , . 24 , . 66 ] } ] ; Image

p3 = Plot [ f [ a ] ( x a ) + f [ a ] , { x , 0 , 4 Pi } , PlotStyle - > CMYKColor [ . 48 , . 36 , . 24 , . 66 ] ] ; Image

Show [ p1 , p2 , p3 , AspectRatio - > Automatic , PlotRange { 1 , 5 } , Image

AxesLabel{x,y}],{{a,5},.1,4Pi.1}]Image  □

Remark 3.5

Sometimes using Surd may be cumbersome. Therefore, it is worth noting that if you desire a real root to xn/mImage and there is a real root, x^(n/m)=Abs[x]^(n/m) if n is even and x^(n/m)=Sign[x]Abs[x]^(n/m) if n is odd. Of course, remember that if m is even and x is negative, xn/mImage is not a real number. Note that Sign[x] returns 1 if x is positive and −1 if x is negative.

Tangent Lines of Implicit Functions

Example 3.14

Find equations of the tangent line and normal line to the graph of x2yy3=8Image at the point (3,1)Image. Find and simplify y=d2y/dx2Image.

If the line has slope m1Image the line perpendicular (or, normal) to has slope 1/m1Image.

Solution

We evaluate y=dy/dxImage if x=3Image and y=1Image to determine the slope of the tangent line at the point (3,1)Image. Note that we cannot (easily) solve x2yy3=8Image for y so we use implicit differentiation to find y=dy/dxImage:

d d x ( x 2 y y 3 ) = d d x ( 8 )

2 x y + x 2 y 3 y 2 y = 0 y = 2 x y x 2 3 y 2 .

By the product and chain rules, ddx(x2y)=ddx(x2)y+x2ddx(y)=2xy+x2dydx=2xy+x2yImage.

eq = x 2 y y 3 = = 8 Image

x 2 y y 3 = = 8 Image

s1 = Dt [ eq ] Image

2 x y Dt [ x ] + x 2 Dt [ y ] 3 y 2 Dt [ y ] = = 0 Image

s2 = s1 /. Dt [ x ] 1 Image

2 x y + x 2 Dt [ y ] 3 y 2 Dt [ y ] = = 0 Image

s3 = Solve [ s2 , Dt [ y ] ] Image

{ { Dt [ y ] 2 x y x 2 3 y 2 } } Image

Notice that s3 is a list. The formula for y=dy/dxImage is the second part of the first part of the first part of s3 and extracted from s3 with

s3 [ [ 1 , 1 , 2 ] ] Image

2 x y x 2 3 y 2 Image

We then use ReplaceAll (/.) to find that the slope of the tangent at (3,1)Image is

s3 [ [ 1 , 1 , 2 ] ] /. { x 3 , y 1 } Image

1

The slope of the normal is 1/1=1Image. Equations of the tangent and normal are given by

y 1 = 1 ( x + 3 ) and y 1 = 1 ( x + 3 ) ,

respectively. See Fig. 3.15.

Image
Figure 3.15 Graphs of x2y − y3 = 8 and the tangent and normal at (−3,1) (University of California Berkeley colors).

cp1 = ContourPlot [ x 2 y y 3 8 , { x , 5 , 5 } , { y , 5 , 5 } , Contours { 0 } , Image

ContourShading False , PlotPoints 200 , Image

ContourStyle { Thickness [ . 01 ] , CMYKColor [ 1 , . 45 , 0 , . 66 ] } ] ; Image

p1 = ListPlot [ { { 3 , 1 } } , PlotStyle { Black , PointSize [ . 03 ] } ] ; Image

p2 = Plot [ { ( x + 3 ) + 1 , ( x + 3 ) + 1 } , { x , 5 , 5 } , Image

PlotStyle { { CMYKColor [ 0 , . 3 , . 93 , 0 ] , Thickness [ . 01 ] } } ] ; Image

Show [ cp1 , p1 , p2 , Frame False , Axes Automatic , AxesOrigin { 0 , 0 } , Image

AspectRatio Automatic , DisplayFunction $ DisplayFunction ] Image

To find y=d2y/dx2Image, we proceed as follows.

s4 = Dt [ s3 [ [ 1 , 1 , 2 ] ] ] // Simplify Image

2 ( x 2 + 3 y 2 ) ( y Dt [ x ] + x Dt [ y ] ) ( x 2 3 y 2 ) 2 Image

s5 = s4 /. Dt [ x ] 1 /. s3 [ [ 1 ] ] // Simplify Image

6 y ( x 2 y 2 ) ( x 2 + 3 y 2 ) ( x 2 3 y 2 ) 3 Image

The result means that

y = d 2 y d x 2 = 6 ( x 2 y y 3 ) ( x 2 + 3 y 2 ) ( x 2 3 y 2 ) 3 .

Because x2yy3=8Image, the second derivative is further simplified to

y = d 2 y d x 2 = 48 ( x 2 + 3 y 2 ) ( x 2 3 y 2 ) 3 .

 □

Parametric Equations and Polar Coordinates

For the parametric equations {x=f(t),y=g(t)}Image, tIImage,

y = d y d x = d y / d t d x / d t = g ( t ) f ( t )

and

y = d 2 y d x 2 = d d x d y d x = d / d t ( d y / d x ) d x / d t .

If {x=f(t),y=g(t)}Image has a tangent line at the point (f(a),g(a))Image, parametric equations of the tangent are given by

x = f ( a ) + t f ( a ) and y = g ( a ) + t g ( a ) .

If f(a)Image, g(a)0Image, we can eliminate the parameter from (3.2)

x f ( a ) f ( a ) = y g ( a ) g ( a ) y g ( a ) = g ( a ) f ( a ) ( x f ( a ) )

and obtain an equation of the tangent line in point-slope form.

l = Solve [ x [ a ] + t x [ a ] = = cx , t ] Image

r = Solve [ y [ a ] + t y [ a ] = = cy , t ] Image

{ { t cx x [ a ] x [ a ] } } Image

{ { t cy y [ a ] y [ a ] } } Image

Solution

After defining x and y we use ' to compute dy/dtImage and dx/dtImage. We then compute dy/dx=(dy/dt)/(dx/dt)Image and d2y/dx2Image.

x [ t _ ] = t Sin [ t ] ; Image

y [ t _ ] = 1 Cos [ t ] ; Image

dx = x [ t ] Image

dy = y [ t ] Image

dydx = dy / dx Image

1 Cos [ t ] Image

Sin [ t ] Image

Sin [ t ] 1 Cos [ t ] Image

dypdt=Simplify[D[dydx,t]]Image

1 1 + Cos [ t ] Image

secondderiv = Simplify [ dypdt / dx ] Image

1 ( 1 + Cos [ t ] ) 2 Image

We then use ParametricPlot to graph the cycloid for 2πt4πImage, naming the resulting graph p1.

p1 = ParametricPlot [ { x [ t ] , y [ t ] } , { t , 2 Pi , 4 Pi } , Image

PlotStyle { { CMYKColor [ 0 , . 68 , . 98 , 0 ] , Thickness [ . 015 ] } } ] ; Image

Next, we use Table to define toplot to be 40 tangent lines (3.2) using equally spaced values of a between 2πImage and 4π. We then graph each line toplot and name the resulting graph p2. Finally, we show p1 and p2 together with the Show function. The resulting plot is shown to scale because the lengths of the x and y-axes are equal and we include the option AspectRatio->1. In the graphs, notice that on intervals for which dy/dxImage is defined, dy/dxImage is a decreasing function and, consequently, d2y/dx2<0Image. (See Fig. 3.16.)

Image
Figure 3.16 The cycloid with various tangents (California Institute of Technology colors).

toplot = Table [ { x [ a ] + t x [ a ] , y [ a ] + t y [ a ] } , { a , 2 Pi , 4 Pi , 6 Pi / 39 } ] ; Image

p2 = ParametricPlot [ Evaluate [ toplot ] , { t , 2 , 2 } , PlotStyle CMYKColor [ . 35 , . 28 , . 35 , 0 ] ] ; Image

Show [ p1 , p2 , AspectRatio 1 , PlotRange { 3 Pi , 3 Pi } , Image

AxesLabel { x , y } ] Image

With Manipulate, you can animate the tangents. (See Fig. 3.17.)

Image
Figure 3.17 With Manipulate or Animate you can animate the tangents.

Manipulate [ x [ t _ ] = t Sin [ t ] ; Image

y [ t _ ] = 1 Cos [ t ] ; Image

y [ t _ ] = Module [ { p1 , p2 } , p1 = ParametricPlot [ { x [ t ] , y [ t ] } , { t , 2 Pi , 4 Pi } , Image

PlotStyle { { CMYKColor [ 0 , . 68 , . 98 , 0 ] , Thickness [ . 01 ] } } ] ; Image

p2 = ParametricPlot [ { x [ a ] + t x [ a ] , y [ a ] + t y [ a ] } , { t , 5 , 5 } , Image

PlotStyle { { CMYKColor [ . 35 , . 28 , . 35 , 0 ] , Thickness [ . 0075 ] } } ] ; Image

Show [ p1 , p2 , AspectRatio 1 , PlotRange { { 2 Pi , 4 Pi } , { 3 Pi , 3 Pi } } ] ] , Image

{{a,1},2Pi,4Pi}]Image  □

Example 3.16

Orthogonal Curves

Two lines L1Image and L2Image with slopes m1Image and m2Image, respectively, are orthogonal if their slopes are negative reciprocals: m1=1/m2Image.

Extended to curves, we say that the curves C1Image and C2Image are orthogonal at a point of intersection if their respective tangent lines to the curves at that point are orthogonal.

Show that the family of curves with equation x2+2xyy2=CImage is orthogonal to the family of curves with equation y2+2xyx2=CImage.

Solution

We begin by defining eq1 and eq2 to be equations x2+2xyy2=CImage and y2+2xyx2=CImage, respectively. Then, use Dt to differentiate and Solve to find y=dy/dxImage.

eq1 = x 2 + 2 x y y 2 == c ; Image

eq2 = y 2 + 2 x y x 2 == c ; Image

Simplify [ Solve [ Dt [ eq1 , x ] , Dt [ y , x ] ] /. Dt [ c , x ] 0 ] Image

{{Dt[y,x]x+yxy}}Image

Simplify [ Solve [ Dt [ eq2 , x ] , Dt [ y , x ] ] /. Dt [ c , x ] 0 ] Image

{ { Dt [ y , x ] x y x + y } } Image

Because the derivatives are negative reciprocals, we conclude that the curves are orthogonal. We confirm this graphically by graphing several members of each family with ContourPlot and showing the results together. (See Fig. 3.18.)

Image
Figure 3.18 x2 + 2xy − y2 = C and y2 + 2xy − x2 = C for various values of C (University of Illinois colors).

cp1 = ContourPlot [ x 2 + 2 x y y 2 , { x , 5 , 5 } , { y , 5 , 5 } , ContourShading False , Image

ContourStyle { { Thickness [ . 01 ] , CMYKColor [ 1 , . 9 , . 1 , . 77 ] } } ] ; Image

cp2 = ContourPlot [ y 2 + 2 x y x 2 , { x , 5 , 5 } , { y , 5 , 5 } , ContourShading False , Image

ContourStyle { { Thickness [ . 01 ] , CMYKColor [ 0 , . 76 , 1.0 ] } } ] ; Image

Show[cp1,cp2,FrameFalse,AxesAutomatic,AxesOrigin{0,0}]Image  □

Theorem 3.1

The Mean-Value Theorem for Derivatives

If y=f(x)Image is continuous on [a,b]Image and differentiable on (a,b)Image then there is at least one value of c between a and b for which

f ( c ) = f ( b ) f ( a ) b a or, equivalently, f ( b ) f ( a ) = f ( c ) ( b a ) .

Example 3.17

Find all number(s) c that satisfy the conclusion of the Mean-Value Theorem for f(x)=x23xImage on the interval [0,7/2]Image.

Solution

By the power rule, f(x)=2x3Image. The slope of the secant containing (0,f(0))Image and (7/2,f(7/2))Image is

f ( 7 / 2 ) f ( 0 ) 7 / 2 0 = 1 2 .

Solving 2x3=1/2Image for x gives us x=7/4Image.

f [ x _ ] = x 2 3 x Image

3 x + x 2 Image

Solve [ f [ x ] = = 0 , x ] Image

{ { x 3 2 } } Image

Solve [ f [ x ] = = ( f [ 7 / 2 ] f [ 0 ] ) / ( 7 / 2 0 ) ] Image

{ { x 7 4 } } Image

x=7/4Image satisfies the conclusion of the Mean-Value Theorem for f(x)=x23xImage on the interval [0,7/2]Image, as shown in Fig. 3.19.

Image
Figure 3.19 Graphs of f(x)=x2 − 3x, the secant containing (0,f(0)) and (7/2,f(7/2)), and the tangent at (7/4,f(7/4)) (University of Michigan colors).

p1 = Plot [ f [ x ] , { x , 1 , 4 } , PlotStyle CMYKColor [ 1 , . 6 , 0 , . 6 ] ] ; Image

p2 = Plot [ f [ x ] , { x , 0 , 7 / 2 } , PlotStyle { { Thickness [ . 015 ] , CMYKColor [ 0 , . 18 , 1 , 0 ] } } ] ; Image

p3 = ListPlot [ { { 0 , f [ 0 ] } , { 7 / 4 , f [ 7 / 4 ] } , { 7 / 2 , f [ 7 / 2 ] } } , Image

PlotStyle { { CMYKColor [ . 2 , . 14 , . 12 , . 4 ] , PointSize [ . 025 ] } } ] ; Image

p4 = Plot [ { f [ 7 / 4 ] ( x 7 / 4 ) + f [ 7 / 4 ] , ( f [ 7 / 2 ] f [ 0 ] ) / ( 7 / 2 0 ) x + f [ 0 ] } , Image

{ x , 2 , 4 } , PlotStyle { { Dashing [ { . 01 } ] , CMYKColor [ . 06 , . 14 , . 38 , . 08 ] } , Image

{ Dashing [ { . 01 } ] , CMYKColor [ . 21 , . 15 , . 54 , . 31 ] } } ] ; Image

Show [ p1 , p2 , p3 , p4 , DisplayFunction $ DisplayFunction , AspectRatio Automatic , Image

PlotRange{3,3}]Image  □

3.2.5 The First Derivative Test and Second Derivative Test

Example 3.15 illustrates the following properties of the first and second derivative.

Theorem 3.2

Let y=f(x)Image be continuous on [a,b]Image and differentiable on (a,b)Image.

1.  If f(x)=0Image for all x in (a,b)Image, then f(x)Image is constant on [a,b]Image.

2.  If f(x)>0Image for all x in (a,b)Image, then f(x)Image is increasing on [a,b]Image.

3.  If f(x)<0Image for all x in (a,b)Image, then f(x)Image is decreasing on [a,b]Image.

For the second derivative, we have the following theorem.

Theorem 3.3

Let y=f(x)Image have a second derivative on (a,b)Image.

1.  If f(x)>0Image for all x in (a,b)Image, then the graph of f(x)Image is concave up on (a,b)Image.

2.  If f(x)<0Image for all x in (a,b)Image, then the graph of f(x)Image is concave down on (a,b)Image.

The critical points correspond to those points on the graph of y=f(x)Image where the tangent line is horizontal or vertical; the number x=aImage is a critical number if f(a)=0Image or f(x)Image does not exist if x=aImage. The inflection points correspond to those points on the graph of y=f(x)Image where the graph of y=f(x)Image is neither concave up nor concave down. Theorems 3.2 and 3.3 help establish the first derivative test and second derivative test.

Theorem 3.4

First Derivative Test

Let x=aImage be a critical number of a function y=f(x)Image continuous on an open interval I containing x=aImage. If f(x)Image is differentiable on I, except possibly at x=aImage, f(a)Image can be classified as follows.

1.  If f(x)Image makes a simple change in sign from positive to negative at x=aImage, then f(a)Image is a relative maximum.

2.  If f(x)Image makes a simple change in sign from negative to positive at x=aImage, then f(a)Image is a relative minimum.

Theorem 3.5

Second Derivative Test

Let x=aImage be a critical number of a function y=f(x)Image and suppose that f(x)Image exists on an open interval containing x=aImage.

1.  If f(a)<0Image, then f(a)Image is a relative maximum.

2.  If f(a)>0Image, then f(a)Image is a relative minimum.

Example 3.18

Graph f(x)=3x55x3Image.

Solution

We begin by defining f(x)Image and then computing and factoring f(x)Image and f(x)Image.

f [ x _ ] = 3 x 5 5 x 3 ; Image

d1 = Factor [ f [ x ] ] Image

d2 = Factor [ f [ x ] ] Image

15 ( 1 + x ) x 2 ( 1 + x ) Image

30 x ( 1 + 2 x 2 ) Image

By inspection, we see that the critical numbers are x=0Image, 1, and −1 while f(x)=0Image if x=0Image, 1/2Image, or 1/2Image. Of course, these values can also be found with Solve as done next in cns and ins, respectively.

cns = Solve [ d1 = = 0 ] Image

ins = Solve [ d2 = = 0 ] Image

{ { x 1 } , { x 0 } , { x 0 } , { x 1 } } Image

{ { x 0 } , { x 1 2 } , { x 1 2 } } Image

We find the critical and inflection points by using /. (Replace All) to compute f(x)Image for each value of x in cns and ins, respectively. The result means that the critical points are (0,0)Image, (1,2)Image and (1,2)Image; the inflection points are (0,0)Image, (1/2,72/8)Image, and (1/2,72/8)Image. We also see that f(0)=0Image so Theorem 3.5 cannot be used to classify f(0)Image. On the other hand, f(1)=30>0Image and f(1)=30<0Image so by Theorem 3.5, f(1)=2Image is a relative minimum and f(1)=2Image is a relative maximum.

cps = { x , f [ x ] } /. cns Image

{ { 1 , 2 } , { 0 , 0 } , { 0 , 0 } , { 1 , 2 } } Image

f [ x ] /. cns Image

{ 30 , 0 , 0 , 30 } Image

ips = { x , f [ x ] } /. ins Image

{ { 0 , 0 } , { 1 2 , 7 4 2 } , { 1 2 , 7 4 2 } } Image

We can graphically determine the intervals of increase and decrease by noting that if f(x)>0Image (f(x)<0Image), a|f(x)|/f(x)=aImage (a|f(x)|/f(x)=aImage). Similarly, the intervals for which the graph is concave up and concave down can be determined by noting that if f(x)>0Image (f(x)<0Image), a|f(x)|/f(x)=aImage (a|f(x)|/f(x)=aImage). We use Plot to graph |f(x)|/f(x)Image and 2|f(x)|/f(x)Image (different values are used so we can differentiate between the two plots) in Fig. 3.20.

Image
Figure 3.20 Graphs of |f(x)|/f(x) and 2|f(x)|/f(x) (Cornell University colors).

Plot [ { Abs [ d1 ] / d1 , 2 Abs [ d2 ] / d2 } , { x , 2 , 2 } , PlotRange { 3 , 3 } , Image

PlotStyle{{CMYKColor[0,1.,.79,.2]},{CMYKColor[.72,.66,.65,72]}}]Image

From the graph, we see that f(x)>0Image for x in (,1)(1,)Image, f(x)<0Image for x in (1,1)Image, f(x)>0Image for x in (1/2,0)(1/2,)Image, and f(x)<0Image for x in (,1/2)(0,1/2)Image. Thus, the graph of f(x)Image is

•  increasing and concave down for x in (,1)Image,

•  decreasing and concave down for x in (1,1/2)Image,

•  decreasing and concave up for x in (1/2,0)Image,

•  decreasing and concave down for x in (0,12)Image,

•  decreasing and concave up for x in (1/2,1)Image, and

•  increasing and concave up for x in (1,)Image.

We also see that f(0)=0Image is neither a relative minimum nor maximum. To see all points of interest, our domain must contain −1 and 1 while our range must contain −2 and 2. We choose to graph f(x)Image for 2x2Image; we choose the range displayed to be 4y4Image. (See Fig. 3.21.)

Image
Figure 3.21 f(x) for −2 ⩽ x ⩽ 2 and −4 ⩽ y ⩽ 4.

Plot [ f [ x ] , { x , 2 , 2 } , PlotRange { 4 , 4 } , Image

PlotStyle - > CMYKColor [ 0 , 1 . , . 79 , . 2 ] , Image

AxesLabel{x,y}]Image  □

Remember to be especially careful when working with functions that involve odd roots. If n is odd and x is even, use Surd[x,n] to obtain the real-valued nth root of x.

Example 3.19

Graph f(x)=(x2)2/3(x+1)1/3Image.

Solution

We begin by defining f(x)Image and then computing and simplifying f(x)Image and f(x)Image with ′ and Simplify.

Clear [ f ] Image

f [ x _ ] = Surd [ ( x 2 ) 2 , 3 ] Surd [ ( x + 1 ) , 3 ] ; Image

d1 = Simplify [ f [ x ] ] Image

d2 = Simplify [ f [ x ] ] Image

( 2 + x ) x ( 2 + x ) 2 3 2 1 + x 3 2 Image

2 ( 1 + x ) ( 2 + x ) 2 3 2 1 + x 3 2 Image

By inspection, we see that the critical numbers are x=0Image, 2, and −1. We cannot use Theorem 3.5 to classify f(2)Image and f(1)Image because f(x)Image is undefined if x=2Image or −1. On the other hand, f(0)<0Image so f(0)=22/3Image is a relative maximum. By hand, we make a sign chart to see that the graph of f(x)Image is

•  increasing and concave up on (,1)Image,

•  increasing and concave down on (1,0)Image,

•  decreasing and concave down on (0,2)Image, and

•  increasing and concave down on (2,)Image.

Hence, f(1)=0Image is neither a relative minimum nor maximum while f(2)=0Image is a relative minimum by Theorem 3.4. We use Plot to graph f(x)Image for 2x3Image in Fig. 3.22.

Image
Figure 3.22 f(x) for −2 ⩽ x ⩽ 3 (Carnegie Mellon colors).

f [ 0 ] Image

Plot [ f [ x ] , { x , 2 , 3 } , Image

PlotStyle CMYKColor [ . 07 , 1 , . 82 , . 26 ] , Image

AxesLabel { x , y } ] Image

22/3Image  □

The previous examples illustrate that if x=aImage is a critical number of f(x)Image and f(x)Image makes a simple change in sign from positive to negative at x=aImage, then (a,f(a))Image is a relative maximum. If f(x)Image makes a simple change in sign from negative to positive at x=aImage, then (a,f(a))Image is a relative minimum. Mathematica is especially useful in investigating interesting functions for which this may not be the case.

Example 3.20

Consider

f ( x ) = { x 2 sin 2 ( 1 x ) , x 0 0 , x = 0 ,

x=0Image is a critical number because f(x)Image does not exist if x=0Image. The point (0,0)Image is both a relative and absolute minimum, even though f(x)Image does not make a simple change in sign at x=0Image, as illustrated in Fig. 3.23.

Image
Figure 3.23 f(x)=[xsin(1x)]2Image and f(x) for −0.1 ⩽ x ⩽ 0.1 (Carnegie Mellon colors).

f [ x _ ] = ( x Sin [ 1 x ] ) 2 ; Image

f [ x ] // Factor Image

2 Sin [ 1 x ] ( Cos [ 1 x ] x Sin [ 1 x ] ) Image

p1 = Plot [ f [ x ] , { x , 0.1 , 0.1 } , Image

PlotStyle CMYKColor [ . 92 , . 02 , 1 , . 12 ] , Image

AxesLabel { x , y } , PlotLabel “(a)” ] ; Image

p2 = Plot [ f [ x ] , { x , 0.1 , 0.1 } , Image

PlotStyle CMYKColor [ 0 , . 32 , 1 , 0 ] , Image

AxesLabel { x , y } , PlotLabel “(b)” ] ; Image

Show[GraphicsRow[{p1,p2}]]Image

Notice that the derivative “oscillates” infinitely many times near x=0Image, so the first derivative test cannot be used to classify (0,0)Image.

The functions Maximize and Minimize can be used to assist with finding extreme values. For a function of a single variable Maximize[f[x],x] (Minimize[f[x],x]) attempts to find the maximum (minimum) values of f(x)Image; Maximize[{f[x],a<=x<=b},x] (Minimize[{f[x],a<=x<=b},x]) attempts to find the maximum (minimum) values of f(x)Image on [a,b]Image.

Example 3.21

Consider f(x)=110(12x+3x2+2x3)Image. After defining f(x)Image, we plot f(x)Image and f(x)Image together in Fig. 3.24.

Image
Figure 3.24 f(x) has one relative maximum and one relative minimum but no absolute extreme values (Purdue University colors).

f [ x _ ] = 1 / 10 ( 12 x + 3 x 2 + 2 x 3 ) ; Image

Plot [ Tooltip [ { f [ x ] , f [ x ] } ] , { x , 4 , 4 } , PlotRange { 4 , 4 } , Image

AspectRatio Automatic , PlotStyle { { Black } , { CMYKColor [ . 06 , . 27 , 1 , . 12 ] } } ] Image

With Maximize, we see that f(x)Image does not have a maximum on its domain. However, when we restrict the interval to 3x2Image, Maximize finds the relative maximum at x=2Image.

Maximize [ f [ x ] , x ] Image

Maximize: The maximum is not attained at any point satisfying the given constraints.  Image

{ , { x } } Image

Maximize[{f[x],3x2},x]Image

{ 2 , { x 2 } } Image

Similarly, with Minimize we see that the f(x)Image does not have a minimum value on its domain but find the relative minimum when we restrict the interval to 3x2Image.

Minimize [ f [ x ] , x ] Image

Minimize: The minimum is not attained at any point satisfying the given constraints. Image

{ , { x } } Image

Minimize [ { f [ x ] , 3 x 2 } , x ] Image

{ 7 10 , { x 1 } } Image

However, with Solve, we easily find the two zeros of f(x)Image that we see in Fig. 3.24

Solve [ f [ x ] = = 0 , x ] Image

{ { x 2 } , { x 1 } } Image

When using Maximize or Minimize you should verify your results using another method.

Example 3.22

The function f(x)=x/(x2+1)Image is continuous on (,)Image and limx±f(x)=0Image. Thus, f(x)Image has an absolute minimum and maximum value on its domain. In this case,

Maximize [ x / ( x 2 + 1 ) , x ] Image

{ 1 2 , { x 1 } } Image

Minimize [ x / ( x 2 + 1 ) , x ] Image

{ 1 2 , { x 1 } } Image

gives us the absolute maximum and minimum values of f(x)Image and the x-values where they occur. On the other hand, f(x)=x4x2Image is continuous on (,)Image and limx±f(x)=Image. Thus, f(x)Image has an absolute minimum on its domain. Because the derivative of a fourth degree polynomial is a third degree polynomial, we know that f(x)Image has three zeros, two of which probably correspond to relative minimums. Because the graph of f(x)Image is symmetric with respect to the y-axis, we further suspect that the absolute minimum is obtained twice—at each relative minimum. Maximize and Minimize give us the following results.

A polynomial of degree n has n zeros (counting multiplicity).

Maximize [ x 4 x 2 , x ] Image

Maximize: The maximum is not attained at any point satisfying the given constraints.  Image

{,{x}}Image

Minimize [ x 4 x 2 , x ] Image

{ 1 4 , { x 1 2 } } Image

Note that the result returned by Maximize is correct. Similarly, the result returned by Minimize is correct, but a complete answer would indicate that the absolute minimum value occurs at both x=1/2Image and x=1/2Image.

Example 3.23

The function f(x)=(x+1)2/(x2)Image has a vertical asymptote at x=2Image. From the derivative,

f [ x _ ] = ( x + 1 ) 2 / ( x 2 ) ; Image

d1 = Simplify [ f [ x ] ] Image

cns = Solve [ f [ x ] = = 0 , x ] Image

( 5 + x ) ( 1 + x ) ( 2 + x ) 2 Image

{ { x 1 } , { x 5 } } Image

f [ x ] /. cns Image

{ 0 , 12 } Image

we find two critical numbers, one of which is a relative maximum and one is a relative minimum. See Fig. 3.25.

Image
Figure 3.25 A function for which a relative minimum has a function value greater than the function value of a relative maximum (University of California–San Diego colors).

Plot [ Tooltip [ { f [ x ] , f [ x ] } ] , { x , 6 , 10 } , Image

PlotStyle { { CMYKColor [ 1 , . 86 , . 42 , . 42 ] } , Image

{CMYKColor[{.06,.35,.99,.18}]}}]Image

On the other hand, Maximize and Minimize return confusing results because the function is undefined if x=2Image. The function has relative extreme values but not absolute extreme values.

Maximize [ f [ x ] , x ] Image

Maximize: The maximum is not attained at any point satisfying the given constraints.  Image

{ , { x 2 } } Image

Minimize [ f [ x ] , x ] Image

Minimize: The minimum is not attained at any point satisfying the given constraints. Image

{ , { x 2 } } Image

From the graph in Fig. 3.25, we see that limx2+f(x)=+Image while limx2f(x)=Image.

For periodic functions, such as sine and cosine, Maximize and Minimize generally don't indicate all extreme values.

Maximize [ Sin [ x ] , x ] Image

{ 1 , { x π 2 } } Image

Minimize [ Cos [ x ] , x ] Image

{ 1 , { x π } } Image

3.2.6 Applied Max/Min Problems

Mathematica can be used to assist in solving maximization/minimization problems encountered in a differential calculus course.

Example 3.24

A woman is located on one side of a body of water 4 miles wide. Her position is directly across from a point on the other side of the body of water 16 miles from her house, as shown in the following figure.

Image

If she can move across land at a rate of 10 miles per hour and move over water at a rate of 6 miles per hour, find the least amount of time for her to reach her house.

Solution

From the figure, we see that the woman will travel from A to B by land and then from B to D by water. We wish to find the least time for her to complete the trip.

Let x denote the distance BC, where 0x16Image. Then, the distance AB is given by 16xImage and, by the Pythagorean theorem, the distance BD is given by x2+42Image. Because rate×time=distanceImage, time=distance/rateImage. Thus, the time to travel from A to B is 110(16x)Image, the time to travel from B to D is 16x2+16Image, and the total time to complete the trip, as a function of x, is

t i m e ( x ) = 1 10 ( 16 x ) + 1 6 x 2 + 16 , 0 x 16 .

We must minimize the function timeImage. First, we define time and then verify that time has a minimum by graphing time on the interval [0,16]Image in Fig. 3.26.

Image
Figure 3.26 Plot of time(x)=110(16x)+16x2+16Image, 0 ⩽ x ⩽ 16 (The University of Texas at Austin colors).

Clear [ time ] Image

time [ x _ ] = 16 x 10 + 1 6 x 2 + 16 ; Image

Plot [ time [ x ] , { x , 0 , 16 } , PlotRange { { 0 , 16 } , { 2 , 3 } } , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ 0 , . 65 , 1 , . 09 ] } , Image

AxesLabel { x , t } ] Image

Next, we compute the derivative of time and find the values of x for which the derivative is 0 with Solve. The resulting output is named critnums using ReplaceAll (\.).

Together [ time [ x ] ] Image

5 x 3 16 + x 2 30 16 + x 2 Image

critnums = Solve [ time [ x ] == 0 ] Image

{ { x 3 } } Image

At this point, we can calculate the minimum time by calculating time[3].

time [ 3 ] Image

32 15 Image

Alternatively, we demonstrate how to find the value of time[x] for the value(s) listed in critnums.

time [ x ] /. x 3 Image

32 15 Image

Regardless, we see that the minimum time to complete the trip is 32/15 hours. □

One of the more interesting applied max/min problems is the beam problem. We present two solutions.

Example 3.25

The Beam Problem

Find the exact length of the longest beam that can be carried around a corner from a hallway 2 feet wide to a hallway that is 3 feet wide. (See Fig. 3.27.)

Image
Figure 3.27 The length of the beam is found using similar triangles.

Solution

We assume that the beam has negligible thickness. Our first approach is algebraic. Using Fig. 3.27, which is generated with

f [ x _ ] = x + 2 ; Image

p1 = Plot [ f [ x ] , { x , 0 , 4 } , PlotStyle { Thickness [ . 01 ] , CMYKColor [ 1 , . 31 , . 08 , . 42 ] } , Image

PlotRange - > { 0 , 6 } ] ; Image

p2 = Image

Graphics [ { CMYKColor [ . 65 , . 43 , . 26 , . 78 ] , Image

Line [ { { 1 , 0 } , { 1 , f [ 1 ] } , { 4 , f [ 1 ] } , { 4 , f [ 4 ] } , { 4 , f [ 4 ] } , { 0 , f [ 4 ] } , Image

{0,0},{1,0}}]}];Image

p3 = Graphics [ { Text [ “2” , { . 5 , . 2 } ] , { Text [ “3” , { 3.8 , 4.5 } ] } } ] ; Image

p4 = Graphics [ { CMYKColor [ . 62 , . 19 , . 45 , . 5 ] , Dashing [ { 0.01 , 0.01 } ] , Image

Line [ { { 0 , f [ 0 ] } , { 1 , f [ 0 ] } } ] } ] ; Image

p5 = Graphics [ { Text [ θ , { . 5 , 2.25 } ] , Text [ θ , { 1.5 , 3.25 } ] } ] ; Image

p6 = Graphics [ { Text [ x , { . 9 , 2.35 } ] , Text [ y , { 2.5 , 3.25 } ] } ] ; Image

Show [ p1 , p2 , p3 , p4 , p5 , p6 , Axes - > None ] Image

and the Pythagorean theorem, the total length of the beam is

L = 2 2 + x 2 + y 2 + 3 2 .

By similar triangles,

y 3 = 2 x so y = 6 x

and the length of the beam, L, becomes

L ( x ) = 4 + x 2 + 9 + 36 x 2 , 0 < x < .

Observe that the length of the longest beam is obtained by minimizing L. (Why?)

We ignore negative and imaginary values because length must be nonnegative real number.

Clear [ l ] ; Image

l [ x _ ] = Sqrt [ 2 2 + x 2 ] + Sqrt [ y 2 + 3 2 ] /. y - > 6 / x Image

9 + 36 x 2 + 4 + x 2 Image

We use two different methods to solve L(x)=0Image. Differentiating

l [ x ] Image

36 9 + 36 x 2 x 3 + x 4 + x 2 Image

36 2 Image

1296

Solve [ 12 4 + x 2 + x 4 4 + x 2 x 2 == 0 , x ] Image

{ { x 2 i } , { x 2 i } , { x 2 2 / 3 3 1 / 3 } , { x 2 2 / 3 3 1 / 3 } } Image

p1 = x 8 ( 9 + 36 / x 2 ) 1296 ( 4 + x 2 ) // Expand // Factor Image

9(4+x2)(12+x3)(12+x3)Image

and solving L(x)=0Image gives us

Solve [ p1 == 0 , x ] Image

{ { x 2 i } , { x 2 i } , { x ( 3 ) 1 / 3 2 2 / 3 } , { x ( 3 ) 1 / 3 2 2 / 3 } , { x ( 2 ) 2 / 3 3 1 / 3 } , Image

{ x ( 2 ) 2 / 3 3 1 / 3 } , { x 2 2 / 3 3 1 / 3 } , { x 2 2 / 3 3 1 / 3 } } Image

N [ 2 2 / 3 3 1 / 3 ] Image

2.28943

l [ 2 2 / 3 3 1 / 3 ] Image

9 + 3 2 2 / 3 3 1 / 3 + 4 + 2 2 1 / 3 3 2 / 3 Image

N [ % ] Image

7.02348

2 ( 3 / 2 ) ( 1 / 3 ) Sqrt [ 1 + ( 4 / 9 ) ( 1 / 3 ) ] + 3 Sqrt [ 1 + ( 4 / 9 ) ( 1 / 3 ) ] // N Image

7.02348

It follows that the length of the beam is L(22/331/3)=9+322/331/3+4+221/332/3=13+922/331/3+621/332/37.02Image. See Fig. 3.28.

Image
Figure 3.28 Graph of L(x).

Plot [ l [ x ] , { x , 0 , 20 } , PlotRange - > { 0 , 20 } , AspectRatio - > Automatic , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ . 62 , . 19 , . 45 , . 5 ] } , AxesLabel - > { x , y } ] Image

Our second approach uses right triangle trigonometry. In terms of θ, the length of the beam is given by

L ( θ ) = 2 csc θ + 3 sec θ , 0 < θ < π / 2 .

Differentiating gives us

L ( θ ) = 2 csc θ cot θ + 3 sec θ tan θ .

To avoid typing the θ symbol, we define L as a function of t.

Clear [ l ] Image

l[t_]=2Csc[t]+3Sec[t]Image

2 Csc [ t ] + 3 Sec [ t ] Image

We now solve L(θ)=0Image. First multiply through by sinθImage and then by tanθImage.

3 sec θ tan θ = 2 csc θ cot θ tan 2 θ = 2 3 cot θ tan 3 θ = 2 3 tan θ = 2 3 3 .

In this case, observe that we cannot compute θ exactly. However, we do not need to do so. Let 0<θ<π/2Image be the unique solution of tanθ=2/33Image. See Fig. 3.29. Using the identity tan2θ+1=sec2θImage, we find that secθ=1+4/93Image. Similarly, because cotθ=3/23Image and cot2θ+1=csc2θImage, cscθ=3/231+4/93Image. Hence, the length of the beam is

L ( θ ) = 2 3 2 3 1 + 4 9 3 + 3 1 + 4 9 3 7.02 .

Image
Figure 3.29 Graph of L(θ) and L(θ).

Plot [ Tooltip [ { l [ t ] , l [ t ] } ] , { t , 0 , Pi / 2 } , PlotRange - > { 20 , 20 } , Image

PlotStyle - > { { Thickness [ . 01 ] , CMYKColor [ . 52 , . 59 , . 45 , . 9 ] } , Image

{ Thickness [ . 01 ] , CMYKColor [ . 03 , . 04 , . 14 , . 08 ] } } , Image

When you use Tooltip, scrolling the cursor over the plot will identify the plot for you.

AxesLabel{t,y}]Image  □

In the next two examples, the constants do not have specific numerical values.

Example 3.26

Find the volume of the right circular cone of maximum volume that can be inscribed in a sphere of radius R.

Solution

Try to avoid three-dimensional figures unless they are absolutely necessary. For this problem, a cross-section of the situation is sufficient. See Fig. 3.30, which is created with

Image
Figure 3.30 Cross-section of a right circular cone inscribed in a sphere (UCLA colors).

p1 = ParametricPlot [ { Cos [ t ] , Sin [ t ] } , { t , 0 , 2 Pi } , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 0 , . 05 , 1 , 0 ] } } ] ; Image

p2 = Graphics [ { CMYKColor [ . 75 , . 35 , 0 , . 07 ] , Thickness [ . 005 ] , Image

Line [ { { 0 , 1 } , { Cos [ 4 Pi / 3 ] , Sin [ 4 Pi / 3 ] } , { Cos [ 5 Pi / 3 ] , Sin [ 5 Pi / 3 ] } , { 0 , 1 } } ] , Image

PointSize [ . 02 ] , Point [ { 0 , 0 } ] , Line [ { { Cos [ 4 Pi / 3 ] , Sin [ 4 Pi / 3 ] } , { 0 , 0 } , { 0 , 1 } } ] , Image

Line [ { { 0 , 0 } , { 0 , Sin [ 4 Pi / 3 ] } } ] } ] ; Image

p3 = Graphics [ { Text [ R , { . 256 , . 28 } ] , Text [ R , { . 04 , . 5 } ] , Text [ y , { . 04 , . 5 } ] , Image

Text [ x , { . 2 , . 8 } ] } ] ; Image

Show [ p1 , p2 , p3 , AspectRatio - > Automatic , Ticks - > None , Axes - > None ] Image

The volume, V, of a right circular cone with radius r and height h is V=13πr2hImage. Using the notation in Fig. 3.30, the volume is given by

V = 1 3 π x 2 ( R + y ) .

However, by the Pythagorean theorem, x2+y2=R2Image so x2=R2y2Image and equation (3.4) becomes

V = 1 3 π ( R 2 y 2 ) ( R + y ) = 1 3 π ( R 3 + R 2 y R y 2 y 3 ) ,

s1 = Expand [ ( r 2 y 2 ) ( r + y ) ] Image

r3+r2yry2y3Image

where 0yRImage. V(y)Image is continuous on [0,R]Image so it will have a minimum and maximum value on this interval. Moreover, the minimum and maximum values either occur at the endpoints of the interval or at the critical numbers on the interior of the interval. Differentiating equation (3.5) with respect to y gives us

Remember that R>0Image is a constant.

d V d y = 1 3 π ( R 2 2 R y 3 y 2 ) = 1 3 π ( R 3 y ) ( R + y )

s2 = D [ s1 , y ] Image

r 2 2 r y 3 y 2 Image

and we see that dV/dy=0Image if y=13RImage or y=RImage.

Factor [ s2 ] Image

( r 3 y ) ( r + y ) Image

Solve [ s2 = = 0 , y ] Image

{ { y r } , { y r 3 } } Image

We ignore y=RImage because −R is not in the interval [0,R]Image. Note that V(0)=V(R)=0Image. The maximum volume of the cone is

V ( 1 3 R ) = 1 3 π 32 27 R 3 = 32 81 π R 2 1.24 R 3 .

s3 = s1 /. y - > r / 3 // Together Image

32r327Image

s3 1 / 3 Pi Image

32 π r 3 81 Image

N [ % ] Image

1.24112r3Image  □

Example 3.27

The Stayed-Wire Problem

Two poles D feet apart with heights L1Image feet and L2Image feet are to be stayed by a wire as shown in Fig. 3.31. Find the minimum amount of wire required to stay the poles, as illustrated in Fig. 3.31, which is generated with

Image
Figure 3.31 When the wire is stayed to minimize the length, the result is two similar triangles (Texas A & M colors).

p1 = Graphics [ { CMYKColor [ . 15 , 1 , . 39 , . 69 ] , Thickness [ . 0075 ] , Image

Line [ { { 0 , 0 } , { 0 , 4 } , { 3.5 , 0 } , { 9 , 5.5 } , { 9 , 0 } , { 0 , 0 } } ] } ] ; Image

p2 = Graphics [ { Text [ " L 1 " , { . 2 , 2 } ] , Text [ " L 2 " , { 8.8 , 2.75 } ] , Text [ x , { 1.75 , . 2 } ] , Image

Text [ x , { 1.75 , . 2 } ] , Text [ " L 1 2 + x 2 " , { 1.75 , 2.75 } ] , Image

Text [ " ( D x ) 2 + L 2 2 " , { 5.5 , 2.75 } ] , Text [ “D-x” , { 6.5 , . 2 } ] } ] ; Image

Show [ p1 , p2 ] Image

Solution

Using the notation in Fig. 3.31, the length of the wire, L, is

L ( x ) = L 1 2 + x 2 + L 2 2 + ( D x ) 2 , 0 x D .

In the special case that L1=L2Image, the length of the wire to stay the beams is minimized when the wire is placed halfway between the two beams, at a distance D/2Image from each beam. Thus, we assume that the lengths of the beams are different; we assume that L1<L2Image, as illustrated in Fig. 3.31. We compute L(x)Image and then solve L(x)=0Image. We use PowerExpand because PowerExpand[expr] expands out all products and powers assuming the variables are real and positive. That is, with PowerExpand we obtain that x2=xImage rather than x2=|x|Image.

Clear [ l ] Image

l [ x _ ] = Sqrt [ x 2 + l1 2 ] + Sqrt [ ( d x ) 2 + l1 2 ] Image

l1 2 + ( d x ) 2 + l1 2 + x 2 Image

l [ x ] // Together Image

d l1 2 + x 2 + x l1 2 + x 2 + x d 2 + l1 2 2 d x + x 2 l1 2 + x 2 d 2 + l1 2 2 d x + x 2 Image

Solve [ l [ x ] == 0 , x ] Image

{ { x d 2 } } Image

The result indicates that x=L1D/(L1+L2)Image minimizes L(x)Image. (Note that we ignore the other value because L1L2<0Image.) Moreover, the triangles formed by minimizing L are similar triangles.

Clear [ l ] Image

l [ x _ ] = Sqrt [ x 2 + l1 2 ] + Sqrt [ ( d x ) 2 + l1 2 ] Image

l1 2 + ( d x ) 2 + l1 2 + x 2 Image

l [ x ] // Together Image

d l1 2 + x 2 + x l1 2 + x 2 + x d 2 + l1 2 2 d x + x 2 l1 2 + x 2 d 2 + l1 2 2 d x + x 2 Image

l [ 0 ] // PowerExpand Image

l1 + d 2 + l1 2 Image

l [ d ] // PowerExpand Image

l1 + d 2 + l1 2 Image

Solve [ l [ x ] == 0 , x ] Image

{ { x d 2 } } Image

l [ d / 2 ] // Together // PowerExpand Image

d 2 + 4 l1 2 Image

d 2 + 4 l1 2 Image

d2+4l12Image

l1 / ( d l1 l1 + l2 ) // Simplify Image

l1 + l2 d Image

l2 / ( d d l1 l1 + l2 ) // Simplify Image

l1+l2dImage  □

3.2.7 Antidifferentiation

3.2.7.1 Antiderivatives

F(x)Image is an antiderivative of f(x)Image if F(x)=f(x)Image. The symbols

f ( x ) d x

mean “find all antiderivatives of f(x)Image.” Because all antiderivatives of a given function differ by a constant, we usually find an antiderivative, F(x)Image, of f(x)Image and then write

f ( x ) d x = F ( x ) + C ,

where C represents an arbitrary constant. The command

Integrate[f[x],x]

attempts to find an antiderivative, F(x)Image, of f(x)Image. Instead of using Integrate, you might prefer to use the Image button on the Basic Math Input or Basic Math Assistant palettes to help you evaluate antiderivatives. Mathematica does not include the “+C” that we include when writing f(x)dx=F(x)+CImage. In the same way as D can differentiate many functions, Integrate can antidifferentiate many functions. However, antidifferentiation is a fundamentally difficult procedure so it is not difficult to find functions f(x)Image for which the command Integrate[f[x],x] returns unevaluated.

Example 3.28

Evaluate each of the following antiderivatives: (a) 1x2e1/xdxImage, (b) x2cosxdxImage, (c) x21+x2dxImage, (d) x2x+2x3x2+x1dxImage, and (e) sinxxdxImage.

u-Substitutions

Usually, the first antidifferentiation technique discussed is the method of u-substitution. Suppose that F(x)Image is an antiderivative of f(x)Image. Given

f ( g ( x ) ) g ( x ) d x ,

we let u=g(x)Image so that du=g(x)dxImage. Then,

f ( g ( x ) ) g ( x ) d x = f ( u ) d u = F ( u ) + C = F ( g ( x ) ) + C ,

where F(x)Image is an antiderivative of f(x)Image. After mastering u-substitutions, the integration by parts formula,

u d v = u v v d u ,

is introduced.

Example 3.29

Evaluate 2x4x1dxImage.

Solution

We use Integrate to evaluate the antiderivative.

i1 = Integrate [ 2 x Sqrt [ 4 x 1 ] , x ] Image

2 x 1 + 4 x Log [ 2 x + 1 + 4 x ] Log [ 4 ] Image

Proceeding by hand, we let u=2xImage. Then, du=2xln2dxImage or, equivalently, 1ln2du=2xdxImage

D [ 2 x , x ] Image

2 x Log [ 2 ] Image

so 2x4x1dx=1ln2u21duImage. We now use Integrate to evaluate 1ln2u21duImage

i2 = 1 / Log [ 2 ] Integrate [ Sqrt [ u 2 1 ] , u ] Image

1 2 u 1 + u 2 1 2 Log [ u + 1 + u 2 ] Log [ 2 ] Image

Simplify [ i2 ] Image

u 1 + u 2 Log [ u + 1 + u 2 ] Log [ 4 ] Image

and then /. (ReplaceAll)/ to replace u with 2xImage.

i3 = i2 /. u 2 x Image

2 1 + x 1 + 2 2 x 1 2 Log [ 2 x + 1 + 2 2 x ] Log [ 2 ] Image

Observe that the result we obtained by hand is the same as the result obtained by Integrate directly. Sometimes, the results will look different and have slightly different forms. To verify that they are equivalent, subtract the two, and simplify the result. If the result is a constant, the two antiderivatives are equivalent. If not, they aren't.  □

As we did with derivatives, with DynamicModule, we create a simple dynamic that lets you compute the derivative and antiderivative of basic functions and plot them on a standard viewing window, [5,5]×[5,5]Image. The layout of Fig. 3.32 is primarily determined by Panel, Column, and Grid.

Image
Figure 3.32 Seeing the relationship between the derivative and antiderivative of a function and the original function (Texas A & M colors).

Panel [ DynamicModule [ { f = x 2 } , Image

Column [ { InputField [ Dynamic [ f ] ] , Grid [ { { “First Derivative” , Image

Panel [ Dynamic [ D [ f , x ] // Simplify ] ] } , Image

{ “Antiderivative” , Image

Panel [ Dynamic [ Integrate [ f , x ] // Simplify ] ] } } ] , Image

Dynamic [ Plot [ Evaluate [ Tooltip [ { f , D [ f , x ] , Image

Integrate [ f , x ] } ] ] , { x , 5 , 5 } , PlotRange { 5 , 5 } , Image

AspectRatio Automatic , AxesLabel { x , y } , Image

PlotStyle { { CMYKColor [ . 15 , 1 , . 39 , . 69 ] } , { CMYKColor [ 1 , . 48 , . 09 , . 46 ] } , Image

{ CMYKColor [ . 46 , . 23 , . 84 , . 68 ] } } ] ] } ] ] , ImageSize { 300 , 300 } ] Image

3.3 Integral Calculus

3.3.1 Area

In integral calculus courses, the definite integral is frequently motivated by investigating the area under the graph of a positive continuous function on a closed interval. Let y=f(x)Image be a nonnegative continuous function on an interval [a,b]Image and let n be a positive integer. If we divide [a,b]Image into n subintervals of equal length and let [xk1,xk]Image denote the kth subinterval, the length of each subinterval is (ba)/nImage and xk=a+kbanImage. The area bounded by the graphs of y=f(x)Image, x=aImage, x=bImage, and the y-axis can be approximated with the sum

k = 1 n f ( x k ) b a n ,

where xk[xk1,xk]Image. Typically, we take xk=xk1=a+(k1)banImage (the left endpoint of the kth subinterval), xk=xk1=a+kbanImage (the right endpoint of the kth subinterval), or xk=12(xk1+xk)=a+12(2k1)banImage (the midpoint of the kth subinterval). For these choices of xkImage, (3.8) becomes

b a n k = 1 n f ( a + ( k 1 ) b a n )

b a n k = 1 n f ( a + k b a n ) ,  and 

b a n k = 1 n f ( a + 1 2 ( 2 k 1 ) b a n ) ,

respectively. If y=f(x)Image is increasing on [a,b]Image, (3.9) is an under approximation and (3.10) is an upper approximation: (3.9) corresponds to an approximation of the area using n inscribed rectangles; (3.10) corresponds to an approximation of the area using n circumscribed rectangles. If y=f(x)Image is decreasing on [a,b]Image, (3.10) is an under approximation and (3.9) is an upper approximation: (3.10) corresponds to an approximation of the area using n inscribed rectangles; (3.9) corresponds to an approximation of the area using n circumscribed rectangles.

In the following example, we define the functions leftsum[f[x],a,b,n], middlesum[f[x],a,b,n], and rightsum[f[x],a,b,n] to compute (3.9), (3.11), and (3.10), respectively, and leftbox[f[x],a,b,n], middlebox[f[x], a,b,n], and rightbox[f[x],a, b,n] to generate the corresponding graphs. After you have defined these functions, you can use them with functions y=f(x)Image that you define.

Remark 3.6

To define a function of a single variable, f(x)=expressioninxImage, enter f[x_]=expression in x. To generate a basic plot of y=f(x)Image for axbImage, enter Plot[f[x],{x,a,b}].

Example 3.30

Let f(x)=94x2Image. Approximate the area bounded by the graph of y=f(x)Image, x=0Image, x=3/2Image, and the y-axis using (a) 100 inscribed and (b) 100 circumscribed rectangles. (c) What is the exact value of the area?

Solution

We begin by defining and graphing y=f(x)Image in Fig. 3.33.

Image
Figure 3.33 f(x) for 0 ⩽ x ⩽ 3/2 (Princeton University colors).

f [ x _ ] = 9 4 x 2 ; Image

Plot [ f [ x ] , { x , 0 , 3 / 2 } , Image

AxesLabel { x , y } , Image

PlotStyle { { CMYKColor [ 0 , . 61 , . 97 , 0 ] , Thickness [ . 01 ] } } ] Image

The first derivative, f(x)=8xImage is negative on the interval so f(x)Image is decreasing on [0,3/2]Image. Thus, an approximation of the area using 100 inscribed rectangles is given by (3.10) while an approximation of the area using 100 circumscribed rectangles is given by (3.9). After defining leftsum, rightsum, and middlesum, these values are computed using leftsum and rightsum. The use of middlesum is illustrated as well. Approximations of the sums are obtained with N.

N[number] returns a numerical approximation of number.

leftsum [ f _ , a _ , b _ , n _ ] := Module [ { } , Image

( b a ) / n Sum [ f /. x - > a + ( k 1 ) ( b a ) / n , { k , 1 , n } ] ] ; Image

rightsum [ f _ , a _ , b _ , n _ ] := Module [ { } , Image

( b a ) / n Sum [ f /. x - > a + k ( b a ) / n , { k , 1 , n } ] ] ; Image

middlesum [ f _ , a _ , b _ , n _ ] := Module [ { } , Image

( b a ) / n Sum [ f /. x - > a + 1 / 2 ( 2 k 1 ) ( b a ) / n , { k , 1 , n } ] ] ; Image

l100 = leftsum [ f [ x ] , 0 , 3 / 2 , 100 ] Image

N [ % ] Image

r100 = rightsum [ f [ x ] , 0 , 3 / 2 , 100 ] Image

N [ % ] Image

m100 = middlesum [ f [ x ] , 0 , 3 / 2 , 100 ] Image

N [ % ] Image

362691 40000 Image

9.06728

357291 40000 Image

8.93228

720009 80000 Image

9.00011

Observe that these three values appear to be close to 9. In fact, 9 is the exact value of the area of the region bounded by y=f(x)Image, x=0Image, x=3/2Image, and the y-axis. To help us see why this is true, we define leftbox, middlebox, and rightbox, and then use these functions to visualize the situation using n=4Image, 16, and 32 rectangles in Fig. 3.34.

It is not important that you understand the syntax of these three functions at this time. Once you have entered the code, you can use them to visualize the process for your own functions, y=f(x)Image.

Image
Figure 3.34 f(x) with 4, 16, and 32 rectangles.

leftbox [ f _ , a _ , b _ , n _ , opts _ _ _ ] := Module [ { z , p1 , recs , ls } , Image

z [ k _ ] = a + ( b a ) k / n ; Image

p1 = Plot [ f , { x , a , b } , PlotRange All , Image

PlotStyle - > { { Thickness [ . 02 ] , CMYKColor [ 0 , . 61 , . 97 , 0 ] } } ] ; Image

recs = Table [ Rectangle [ { z [ k 1 ] , 0 } , { z [ k ] , f /. x - > z [ k 1 ] } ] , { k , 1 , n } ] ; Image

ls = Table [ Line [ { { z [ k 1 ] , 0 } , { z [ k 1 ] , f /. x - > z [ k 1 ] } , { z [ k ] , f /. x - > z [ k 1 ] } , Image

{ z [ k ] , 0 } } ] , { k , 1 , n } ] ; Image

Show [ Graphics [ { Black , recs } ] , Graphics [ ls ] , p1 , opts , Axes - > Automatic , Image

AspectRatio 1 ] ] Image

rightbox [ f _ , a _ , b _ , n _ , opts _ _ _ ] := Module [ { z , p1 , recs , ls } , Image

z [ k _ ] = a + ( b a ) k / n ; Image

p1 = Plot [ f , { x , a , b } , PlotRange All , Image

PlotStyle - > { { Thickness [ . 02 ] , CMYKColor [ 0 , . 61 , . 97 , 0 ] } } ] ; Image

recs = Table [ Rectangle [ { z [ k 1 ] , 0 } , { z [ k ] , f /. x - > z [ k ] } ] , { k , 1 , n } ] ; Image

ls = Table [ Line [ { { z [ k 1 ] , 0 } , { z [ k 1 ] , f /. x - > z [ k ] } , { z [ k ] , f /. x - > z [ k ] } , Image

{ z [ k ] , 0 } } ] , { k , 1 , n } ] ; Image

Show [ Graphics [ { Black , recs } ] , Graphics [ ls ] , p1 , opts , Image

Axes - > Automatic , AspectRatio 1 ] ] Image

middlebox [ f _ , a _ , b _ , n _ , opts _ _ _ ] := Module [ { z , p1 , recs , ls } , Image

z [ k _ ] = a + ( b a ) k / n ; Image

p1 = Plot [ f , { x , a , b } , PlotRange All , Image

PlotStyle - > { { Thickness [ . 02 ] , CMYKColor [ 0 , . 61 , . 97 , 0 ] } } ] ; Image

recs = Table [ Rectangle [ { z [ k 1 ] , 0 } , { z [ k ] , f /. x - > 1 / 2 ( z [ k 1 ] + z [ k ] ) } ] , Image

{ k , 1 , n } ] ; Image

ls = Table [ Line [ { { z [ k 1 ] , 0 } , { z [ k 1 ] , f /. x - > 1 / 2 ( z [ k 1 ] + z [ k ] ) } , Image

{ z [ k ] , f /. x - > 1 / 2 ( z [ k 1 ] + z [ k ] ) } , { z [ k ] , 0 } } ] , { k , 1 , n } ] ; Image

Show [ Graphics [ { Black , recs } ] , Graphics [ ls ] , p1 , opts , Image

Axes - > Automatic , AspectRatio 1 ] ] Image

somegraphs = { { leftbox [ f [ x ] , 0 , 3 2 , 4 , DisplayFunction Identity ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 4 , DisplayFunction Identity ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 4 , DisplayFunction Identity ] } , Image

{ leftbox [ f [ x ] , 0 , 3 2 , 16 , DisplayFunction Identity ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 16 , DisplayFunction Identity ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 16 , DisplayFunction Identity ] } , Image

{ leftbox [ f [ x ] , 0 , 3 2 , 32 , DisplayFunction Identity ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 32 , DisplayFunction Identity ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 32 , DisplayFunction Identity ] } } ; Image

Show [ GraphicsGrid [ somegraphs ] ] Image

somegraphs = { { leftbox [ f [ x ] , 0 , 3 2 , 4 ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 4 ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 4 ] } , Image

{ leftbox [ f [ x ] , 0 , 3 2 , 16 ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 16 ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 16 ] } , Image

{ leftbox [ f [ x ] , 0 , 3 2 , 32 ] , Image

middlebox [ f [ x ] , 0 , 3 2 , 32 ] , Image

rightbox [ f [ x ] , 0 , 3 2 , 32 ] } } ; Image

Show [ GraphicsGrid [ somegraphs ] ] Image

Notice that as n increases, the under approximations increase to the value of the area while the upper approximations decrease to the value of the area. In the limit as nImage, if the two limits are equal, we can conclude that the area is the value of the limits.

These graphs help convince us that the limit of the sum as nImage of the areas of the inscribed and circumscribed rectangles is the same. We compute the exact value of (3.9) with leftsum, evaluate and simplify the sum with Simplify, and compute the limit as nImage with Limit. We see that the limit is 9.

ls = leftsum [ f [ x ] , 0 , 3 / 2 , n ] Image

ls2 = Simplify [ ls ] Image

Limit [ ls2 , n - > Infinity ] Image

9 ( 1 + 3 n + 4 n 2 ) 4 n 2 Image

9 ( 1 + 3 n + 4 n 2 ) 4 n 2 Image

9

Similar calculations are carried out for (3.10) and again we see that the limit is 9. We conclude that the exact value of the area is 9.

rs = rightsum [ f [ x ] , 0 , 3 / 2 , n ] Image

rs2 = Simplify [ rs ] Image

Limit [ rs2 , n - > Infinity ] Image

9 ( 1 3 n + 4 n 2 ) 4 n 2 Image

9 ( 1 3 n + 4 n 2 ) 4 n 2 Image

9

For illustrative purposes, we confirm this result with middlesum.

ms = middlesum [ f [ x ] , 0 , 3 / 2 , n ] Image

ms2 = Simplify [ ms ] Image

Limit [ ms2 , n - > Infinity ] Image

9 ( 1 + 8 n 2 ) 8 n 2 Image

9 + 9 8 n 2 Image

9

As illustrated earlier, with Manipulate, you can experiment with different functions and different n values. First, we define a set of “typical” functions.

quad [ x _ ] = 100 x 2 ; Image

cubic [ x _ ] = 4 / 9 x 3 49 / 9 x 2 + 100 ; Image

rational [ x _ ] = 100 / ( x 2 + 1 ) ; Image

root [ x _ ] = Sqrt [ 10 x ] ; Image

sin[x_]=75Sin[Pix/5];Image

Next, we use Manipulate to create an object that allows us to experiment with how “typical” functions react to changes in n using left, middle, and right-hand endpoint approximations for computations of Riemann sums. In the resulting Manipulate object, n=4Image rectangles is the default; you can choose n-values from 0 to 100. The value of the corresponding Riemann sum is shown below the graphic. See Fig. 3.35.

Image
Figure 3.35 With Manipulate, we can investigate Riemann sum approximations and their graphical representations for various functions.

How does the Manipulate object change if you remove Transpose from the command?

Manipulate [ Show [ GraphicsGrid [ { { leftbox [ f [ x ] , 0 , 10 , n ] , Image

Graphics [ { Inset [ leftsum [ f [ x ] , 0 , 10 , n ] // N , { 0 , 0 } ] } ] } , Image

{ middlebox [ f [ x ] , 0 , 10 , n ] , Image

Graphics [ { Inset [ middlesum [ f [ x ] , 0 , 10 , n ] // N , { 0 , 0 } ] } ] } , Image

{ rightbox [ f [ x ] , 0 , 10 , n ] , Image

Graphics [ { Inset [ rightsum [ f [ x ] , 0 , 10 , n ] // N , { 0 , 0 } ] } ] } } // Image

Transpose ] ] , { { f , quad } , { quad , cubic , rational , root , sin } } , Image

{{n,4},0,100,1}]Image  □

3.3.2 The Definite Integral

In integral calculus courses, we formally learn that the definite integral of the function y=f(x)Image from x=aImage to x=bImage is

a b f ( x ) d x = lim | P | 0 k = 1 n f ( x k ) Δ x k ,

provided that the limit exists. In equation (3.12), P={a=x0<x1<x2<<xn=b}Image is a partition of [a,b]Image, |P|Image is the norm of P,

| P | = max { x k x k 1 | k = 1 , 2 , , n } ,

Δxk=xkxk1Image, and xk[xk1,xk]Image.

The Fundamental Theorem of Calculus provides the fundamental relationship between differentiation and integration.

By the Fundamental Theorem of Calculus and the Chain Rule, it follows that

d d x ( g ( x ) h ( x ) f ( t ) d t ) = f ( h ( x ) ) h ( x ) f ( g ( x ) ) g ( x ) .

Mathematica's Integrate command can compute many definite integrals. The command

Integrate[f[x],{x,a,b}]

attempts to compute abf(x)dxImage while

Integrate[f[x],x]

attempts to find an antiderivative of f(x)Image. Remember that Mathematica does not include the “+C” when computing antiderivatives. Because integration is a fundamentally difficult procedure, it is easy to create integrals for which the exact value cannot be found explicitly. In those cases, use N to obtain an approximation of its value or obtain a numerical approximation of the integral directly with

NIntegrate[f[x],{x,a,b}].

In the same way as you use the Image button to compute antiderivatives, you can use the Image button to compute definite integrals. If the result returned is unevaluated, use N to obtain a numerical approximation of the value of the integral or use NIntegrate.

Example 3.31

Evaluate (a) 14(x2+1)/xdxImage; (b) 0π/2xcosx2dxImage; (c) 0πe2xsin22xdxImage; (d) 012πex2dxImage; and (e) 10u3duImage.

Improper integrals are computed using Integrate in the same way as with definite integrals.

Example 3.32

Evaluate (a) 01lnxxdxImage; (b) 2πex2dxImage; (c) 11xx21dxImage; (d) 01x2+x4dxImage; (e) 241(x3)23dxImage; and (f) 1x2+x6dxImage.

Solution

(a) This is an improper integral because the integrand is discontinuous on the interval [0,1]Image but we see that the improper integral converges to −4.

Integrate [ Log [ x ] / Sqrt [ x ] , { x , 0 , 1 } ] Image

−4

(b) This is an improper integral because the interval of integration is infinite but we see that the improper integral converges to 2.

Integrate [ 2 / Sqrt [ Pi ] Exp [ x 2 ] , { x , Infinity , Infinity } ] Image

2

(c) This is an improper integral because the integrand is discontinuous on the interval of integration and because the interval of integration is infinite but we see that the improper integral converges to π/2Image.

Integrate [ 1 / ( x Sqrt [ x 2 1 ] ) , { x , 1 , Infinity } ] Image

π 2 Image

(d) As with (c), this is an improper integral because the integrand is discontinuous on the interval of integration and because the interval of integration is infinite but we see that the improper integral diverges to ∞.

Image

(e) Recall that Mathematica does not return a real number when we compute odd roots of negative numbers so the following result would be surprising to many students in an introductory calculus course because it contains imaginary numbers.

Integrate [ 1 / ( x 3 ) ( 2 / 3 ) , { x , 2 , 4 } ] Image

3 3 ( 1 ) 1 / 3 Image

Therefore, we use Surd to obtain the real-valued third root of x3Image.

Integrate [ Surd [ 1 / ( x 3 ) 2 , 3 ] , { x , 2 , 4 } ] Image

6

(f) In this case, Mathematica warns us that the improper integral diverges.

Image

To help us understand why the improper integral diverges, we note that 1x2+x6=15(1x21x+3)Image and

1 x 2 + x 6 d x = 1 5 ( 1 x 2 1 x + 3 ) d x = 1 5 ln ( x 2 x + 3 ) + C .

Integrate [ 1 / ( x 2 + x 6 ) , x ] Image

1 5 Log [ 2 x ] 1 5 Log [ 3 + x ] Image

Hence the integral is improper because the interval of integration is infinite and because the integrand is discontinuous on the interval of integration so

1 x 2 + x 6 d x = 4 1 x 2 + x 6 d x + 4 3 1 x 2 + x 6 d x + 3 0 1 x 2 + x 6 d x + 0 2 1 x 2 + x 6 d x + 2 3 1 x 2 + x 6 d x + 3 1 x 2 + x 6 d x

Image

Evaluating each of these integrals,

Image

we conclude that the improper integral diverges because at least one of the improper integrals in (3.13) diverges. □

In many cases, Mathematica can help illustrate the steps carried out when computing integrals using standard methods of integration like u-substitutions and integration by parts.

Example 3.33

Evaluate (a) ee31xlnxdxImage and (b) 0π/4xsin2xdxImage.

3.3.3 Approximating Definite Integrals

Because integration is a fundamentally difficult procedure to produce exact answers or results, Mathematica is unable to compute a “closed form” of the value of many definite integrals. In these cases, numerical integration can be used to obtain an approximation of the definite integral using N together with Integrate or NIntegrate:

NIntegrate[f[x],{x,a,b}]

attempts to approximate abf(x)dxImage.

Example 3.34

Evaluate 0π3ex2cosx3dxImage.

Solution

In this case, Mathematica is unable to evaluate the integral with Integrate.

We use the Image button to complete the Integrate command.

i1 = Integrate [ Exp [ x 2 ] Cos [ x 3 ] , { x , 0 , Pi ( 1 / 3 ) } ] Image

0 π 1 / 3 e x 2 Cos [ x 3 ] d x Image

An approximation is obtained with N.

N [ i1 ] Image

0.701566

Instead of using Integrate followed by N, you can use NIntegrate to numerically evaluate the integral.

NIntegrate [ Exp [ x 2 ] Cos [ x 3 ] , { x , 0 , Pi ( 1 / 3 ) } ] Image

0.701566

returns the same result as that obtained using Integrate followed by N. □

In some cases, you may wish to investigate particular numerical methods that can be used to approximate integrals. To implement numerical methods like Simpson's rule or the trapezoidal rule, redefine the function leftsum (middlesum or rightsum) discussed previously to perform the calculation for the desired method.

3.3.4 Area

Suppose that y=f(x)Image and y=g(x)Image are continuous on [a,b]Image and that f(x)g(x)Image for axbImage. The area of the region bounded by the graphs of y=f(x)Image, y=g(x)Image, x=aImage, and x=bImage is

A = a b [ f ( x ) g ( x ) ] d x .

Sometimes determining the “greater” function and the “lower” function can be difficult. Equation (3.14) in its more general form tells us that the region bounded by the graphs of y=f(x)Image, y=g(x)Image, x=aImage, and x=bImage is

A = a b | f ( x ) g ( x ) | d x .

Example 3.35

Find the area between the graphs of y=sinxImage and y=cosxImage on the interval [0,2π]Image.

Solution

We graph y=sinxImage and y=cosxImage on the interval [0,2π]Image in Fig. 3.36 with Plot. The graph of y=cosxImage is dashed. Observe that including the option Filling->{1->{2}} fills the region between the two plots.

Image
Figure 3.36 y=sinxImage and y=cosxImage on the interval [0,2π] (University of Wisconsin colors).

Plot [ { Sin [ x ] , Cos [ x ] } , { x , 0 , 2 π } , Image

PlotStyle { { CMYKColor [ . 03 , 1 , . 66 , . 12 ] , Thickness [ . 01 ] } , Image

{ Thickness [ . 01 ] , Dashing [ { 0.025 } ] , CMYKColor [ . 05 , . 26 , 1 , . 27 ] } } , Filling { 1 { 2 } } , Image

AspectRatio Automatic ] Image

To find the upper and lower limits of integration, we must solve the equation sinx=cosxImage for x. Observe that Mathematica returns all solutions to the equation that it can find. The results show us that there are infinitely many solutions to the equation.

Solve [ Sin [ x ] == Cos [ x ] , x ] Image

{ { x ConditionalExpression [ 3 π 4 + 2 π C [ 1 ] , C [ 1 ] Integers ] } , Image

{ x ConditionalExpression [ π 4 + 2 π C [ 1 ] , C [ 1 ] Integers ] } } Image

For us the solutions of interest are valid for 0x2πImage, which are x=π/4Image and x=5π/4Image. We check that these are valid solutions of sinx=cosxImage with ==; in each case the returned result is True.

Sin [ π 4 ] == Cos [ π 4 ] Image

Sin [ 5 π 4 ] == Cos [ 5 π 4 ] Image

True

True

Hence, the area of the region between the graphs is given by

A = 0 π / 4 [ cos x sin x ] d x + π / 4 5 π / 4 [ sin x cos x ] d x + 5 π / 4 2 π [ cos x sin x ] d x .

Notice that if we take advantage of symmetry we can simplify (3.16) to

A = 2 π / 4 5 π / 4 [ sin x cos x ] d x .

We evaluate (3.17) with Integrate to see that the area of the region between the two graphs is 42Image.

0 π 4 ( Cos [ x ] Sin [ x ] ) d x + π 4 5 π 4 ( Sin [ x ] Cos [ x ] ) d x + 5 π 4 2 π ( Cos [ x ] Sin [ x ] ) d x Image

42Image  □

In cases when we cannot calculate the points of intersection of two graphs exactly, we can frequently use FindRoot to approximate the points of intersection.

Solution

After defining p and q, we graph them on the interval [1,5]Image in Fig. 3.37 to obtain an initial guess of the intersection points of the two graphs.

Image
Figure 3.37 p and q on the interval [−1,5] (University of Maryland colors).

When you use Tooltip, you can slide your cursor over a plot and the function being graphed is displayed.

Clear [ p , q ] Image

p [ x _ ] = 3 x 5 10 3 x 4 + 11 x 3 18 x 2 + 12 x + 1 ; Image

q [ x _ ] = 4 x 3 + 28 x 2 56 x + 32 ; Image

Plot [ Tooltip [ { p [ x ] , q [ x ] } ] , { x , 1 , 5 } , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 0 , . 91 , . 76 , . 06 ] } , Image

{ Thickness [ . 01 ] , CMYKColor [ 0 , . 15 , . 94 , 0 ] } } , Image

AxesLabel { x , y } , AspectRatio 1 ] Image

The x-coordinates of the three intersection points are the solutions of the equation p(x)=q(x)Image. Although Mathematica can solve this equation exactly, approximate solutions are more useful for the problem and obtained with NSolve.

intpts = NRoots [ p [ x ] == q [ x ] , x ] Image

x = = 0.772058 x = = 1.5355 3.57094 i x = = 1.5355 + 3.57094 i x = = 2.29182 x = = 3.86513 Image

The numbers are extracted from the list with Part ([[...]]). For example, 0.772058 is the second part of the first part of intpts. Counting from left to right, 2.29182 is the second part of the fourth part of intpts.

x1 = intpts [ [ 1 , 2 ] ] Image

x2 = intpts [ [ 4 , 2 ] ] Image

x3 = intpts [ [ 5 , 2 ] ] Image

0.772058

2.29182

3.86513

Using the roots to the equation p(x)=q(x)Image and the graph we see that p(x)q(x)Image for 0.772x2.292Image and q(x)p(x)Image for 2.292x3.865Image. Hence, an approximation of the area bounded by p(x)Image and q(x)Image is given by the sum

0.772 2.292 [ p ( x ) q ( x ) ] d x + 2.292 3.865 [ q ( x ) p ( x ) ] d x .

These two integrals are computed with Integrate and NIntegrate. As expected, the two values are the same.

x1 x2 ( p [ x ] q [ x ] ) d x + x2 x3 ( q [ x ] p [ x ] ) d x Image

12.1951

NIntegrate [ p [ x ] q [ x ] , { x , x1 , x2 } ] + NIntegrate [ q [ x ] p [ x ] , { x , x2 , x3 } ] Image

12.1951

We conclude that the area is approximately 12.195 units2. □

Parametric Equations

If the curve, C, defined parametrically by x=x(t)Image, y=y(t)Image, atbImage is a nonnegative continuous function of x and x(a)<x(b)Image the area under the graph of C and above the x-axis is

x ( a ) x ( b ) y d x = a b y ( t ) x ( t ) d t .

Graphically, y is a function of x, y=y(x)Image, if the graph of y=y(x)Image passes the vertical line test.

Example 3.37

The Astroid

Find the area enclosed by the astroid x=sin3tImage, y=cos3tImage, 0t2πImage.

Solution

We begin by defining x and y and then graphing the astroid with ParametricPlot in Fig. 3.38.

Image
Figure 3.38 The astroid x=sin3tImage, y=cos3tImage, 0 ⩽ t ⩽ 2π (Harvard University colors).

x [ t _ ] = Sin [ t ] 3 ; Image

y [ t _ ] = Cos [ t ] 3 ; Image

ParametricPlot [ { x [ t ] , y [ t ] } , { t , 0 , 2 Pi } , AspectRatio - > Automatic , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ . 07 , . 94 , . 65 , . 25 ] } ] Image

Observe that x(0)=0Image and x(π/2)=1Image and the graph of the astroid in the first quadrant is given by x=sin3tImage, y=cos3tImage, 0tπ/2Image. Hence, the area of the astroid in the first quadrant is given by

0 π / 2 y ( t ) x ( t ) d t = 3 0 π / 2 sin 2 t cos 4 t d t

and the total area is given by

A = 4 0 π / 2 y ( t ) x ( t ) d t = 12 0 π / 2 sin 2 t cos 4 t d t = 3 8 π 1.178 ,

which is computed with Integrate and then approximated with N.

area = 4 Integrate [ y [ t ] x [ t ] , { t , 0 , Pi / 2 } ] Image

3 π 8 Image

N [ area ] Image

1.1781  □

Polar Coordinates

For problems involving “circular symmetry” it is often easier to work in polar coordinates. The relationship between (x,y)Image in rectangular coordinates and (r,θ)Image in polar coordinates is given by

x = r cos θ y = r sin θ

and

r 2 = x 2 + y 2 tan θ = y x .

If r=f(θ)Image is continuous and nonnegative for αθβImage, then the area A of the region enclosed by the graphs of r=f(θ)Image, θ=αImage, and θ=βImage is

A = 1 2 α β [ f ( θ ) ] 2 d θ = 1 2 α β r 2 d θ .

Solution

This problem is much easier solved in polar coordinates so we first convert the equation from rectangular to polar coordinates with ReplaceAll (/.) and then solve for r with Solve.

lofb = ( x 2 + y 2 ) 2 == a 2 ( x 2 y 2 ) ; Image

topolar=lofb/.{x->rCos[t],y->rSin[t]}Image

( r 2 Cos [ t ] 2 + r 2 Sin [ t ] 2 ) 2 = = a 2 ( r 2 Cos [ t ] 2 r 2 Sin [ t ] 2 ) Image

Solve [ topolar , r ] // Simplify Image

{ { r 0 } , { r 0 } , { r a 2 Cos [ 2 t ] } , { r a 2 Cos [ 2 t ] } } Image

These results indicate that an equation of the lemniscate in polar coordinates is r2=a2cos2θImage. The graph of the lemniscate is then generated in Fig. 3.39 (top figure) using PolarPlot. The portion of the lemniscate in quadrant one is obtained by graphing r=2cos2θImage, 0θπ/4Image.

Image
Figure 3.39 On the left, the lemniscate and on the portion of the lemniscate in quadrant 1 (Harvard University colors).

p1 = PolarPlot [ { 2 Sqrt [ Cos [ 2 t ] ] , 2 Sqrt [ Cos [ 2 t ] ] } , { t , 0 , 2 Pi } , Image

PlotStyle { Thickness [ . 015 ] , CMYKColor [ . 16 , . 23 , . 23 , . 44 ] } , Image

AxesLabel { x , y } ] ; Image

p2 = PolarPlot [ 2 Sqrt [ Cos [ 2 t ] ] , { t , 0 , Pi / 4 } , Image

PlotStyle { Thickness [ . 015 ] , CMYKColor [ . 33 , . 15 , . 14 , . 17 ] } , Image

AxesLabel { x , y } ] ; Image

Show [ GraphicsRow [ { p1 , p2 } ] ] Image

Then, taking advantage of symmetry, the area of the lemniscate is given by

A = 2 1 2 π / 4 π / 4 r 2 d θ = 2 0 π / 4 r 2 d θ = 2 0 π / 4 a 2 cos 2 θ d θ = a 2 ,

which we calculate with Integrate.

Integrate [ 2 a 2 Cos [ 2 t ] , { t , 0 , Pi / 4 } ] Image

a2Image  □

3.3.5 Arc Length

Let y=f(x)Image be a function for which f(x)Image is continuous on an interval [a,b]Image. Then the arc length of the graph of y=f(x)Image from x=aImage to x=bImage is given by

L = a b ( d y d x ) 2 + 1 d x .

The resulting definite integrals used for determining arc length are usually difficult to compute because they involve a radical. In these situations, Mathematica is helpful with approximating solutions to these types of problems.

Example 3.39

Find the length of the graph of y=x48+14x2Image from (a) x=1Image to x=2Image and from (b) x=2Image to x=1Image.

Parametric Equations

If the smooth curve, C, defined parametrically by x=x(t)Image, y=y(t)Image, t[a,b]Image is traversed exactly once as t increases from t=aImage to t=bImage, the arc length of C is given by

L = a b ( d x d t ) 2 + ( d y d t ) 2 d t .

C is smooth if both x(t)Image and y(t)Image are continuous on (a,b)Image and not simultaneously zero for t(a,b)Image.

Example 3.40

Find the length of the graph of x=2t2Image, y=2t12t3Image, 2t2Image.

Solution

For illustrative purposes, we graph x=2t2Image, y=2t12t3Image for 3t3Image and 2t2Image (thickened) in Fig. 3.40.

Image
Figure 3.40 x=2t2Image, y=2t12t3Image (Pennsylvania State University colors).

x [ t _ ] = t 2 Sqrt [ 2 ] ; y [ t _ ] = 2 t 1 / 2 t 3 ; Image

p1 = ParametricPlot [ { x [ t ] , y [ t ] } , { t , 3 , 3 } , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ . 75 , . 2 , 0 , 0 ] } ] ; Image

p2 = ParametricPlot [ { x [ t ] , y [ t ] } , { t , 2 , 2 } , Image

PlotStyle { CMYKColor [ . 75 , . 66 , 0 , 0 ] , Thickness [ . 02 ] } ] ; Image

Show [ p1 , p2 , PlotRange - > All , AxesLabel { x , y } ] Image

Mathematica is able to compute the exact value of the arc length (3.19) although the result is quite complicated. For length considerations, the result of entering the i1 command are not displayed here.

Factor [ x [ t ] 2 + y [ t ] 2 ] Image

14(44t+3t2)(4+4t+3t2)Image

i1 = Integrate [ 2 Sqrt [ x [ t ] 2 + y [ t ] 2 ] , { t , 0 , 2 } ] Image

0 2 2 8 t 2 + ( 2 3 t 2 2 ) 2 d t Image

A more meaningful approximation is obtained with N or using NIntegrate.

N [ i1 ] Image

13.7099

NIntegrate [ 2 Sqrt [ x [ t ] 2 + y [ t ] 2 ] , { t , 0 , 2 } ] Image

13.7099

We conclude that the arc length is approximately 13.71.

Observe that Mathematica 11 cannot evaluate the definite integral directly. However, if we first compute an anti-derivative with integrate in i2,

i2 = Integrate [ 2 Sqrt [ x [ t ] 2 + y [ t ] 2 ] , t ] Image

( 27 i i 2 2 t ( 16 + 8 t 2 + 9 t 4 ) 16 ( i + 2 2 ) 4 i 8 2 + 9 i t 2 i 2 2 4 i + 8 2 + 9 i t 2 i + 2 2 Image

EllipticE [ i ArcSinh [ 3 2 i i 2 2 t ] , i 2 2 i + 2 2 ] + 32 ( 4 i + 2 ) 4 i 8 2 + 9 i t 2 i 2 2 4 i + 8 2 + 9 i t 2 i + 2 2 Image

EllipticF [ i ArcSinh [ 3 2 i i 2 2 t ] , i 2 2 i + 2 2 ] ) / ( 81 i i 2 2 16 + 8 t 2 + 9 t 4 ) Image

and then apply the Fundamental Theorem of Calculus by subtracting the value of i2 if t=0Image from the value of i2 if t=2Image,

ul = i2 /. t 2 Image

ll = i2 /. t 0 Image

val = ul ll Image

1 648 3 i i 2 2 ( 10368 i i 2 2 16 40 i 8 2 i 2 2 ( i + 2 2 ) 40 i + 8 2 i + 2 2 Image

EllipticE [ i ArcSinh [ 3 i i 2 2 ] , i 2 2 i + 2 2 ] + 32 40 i 8 2 i 2 2 ( 4 i + 2 ) 40 i + 8 2 i + 2 2 Image

EllipticF [ i ArcSinh [ 3 i i 2 2 ] , i 2 2 i + 2 2 ] ) Image

0

1 648 3 i i 2 2 ( 10368 i i 2 2 16 40 i 8 2 i 2 2 ( i + 2 2 ) 40 i + 8 2 i + 2 2 Image

EllipticE [ i ArcSinh [ 3 i i 2 2 ] , i 2 2 i + 2 2 ] + 32 40 i 8 2 i 2 2 ( 4 i + 2 ) 40 i + 8 2 i + 2 2 Image

EllipticF[iArcSinh[3ii22],i22i+22])Image

N [ val ] Image

13.7099 + 1.7763568394002505 ` * 15 i Image

N [ val ] // Chop Image

13.7099

we obtain the same result. □

Polar Coordinates

If the smooth polar curve C given by r=f(θ)Image, αθβImage is traversed exactly once as θ increases from α to β, the arc length of C is given by

L = α β ( d r d θ ) 2 + r 2 d θ

Example 3.41

Find the length of the graph of r=θImage, 0θ10πImage.

Solution

We begin by defining r and then graphing r with PolarPlot in Fig. 3.41.

Image
Figure 3.41 r = θ for 0 ⩽ θ ⩽ 10π (Pennsylvania State University colors).

r [ t _ ] = t ; Image

PolarPlot [ r [ t ] , { t , 0 , 10 Pi } , AspectRatio - > Automatic , Image

PlotStyle { CMYKColor [ 0 , . 75 , . 6 , 0 ] , Thickness [ . 01 ] } , Image

AxesLabel{x,y}]Image

Using (3.20), the length of the graph of r is given by 010π1+θ2dθImage. The exact value is computed with Integrate

ev = Integrate [ Sqrt [ r [ t ] 2 + r [ t ] 2 ] , { t , 0 , 10 Pi } ] Image

5 π 1 + 100 π 2 + 1 2 ArcSinh [ 10 π ] Image

and then approximated with N.

N [ ev ] Image

495.801

We conclude that the length of the graph is approximately 495.8 units. □

3.3.6 Solids of Revolution

Volume

Let y=f(x)Image be a nonnegative continuous function on [a,b]Image. The volume of the solid of revolution obtained by revolving the region bounded by the graphs of y=f(x)Image, x=aImage, x=bImage, and the x-axis about the x-axis is given by

V = π a b [ f ( x ) ] 2 d x .

If 0a<bImage, the volume of the solid of revolution obtained by revolving the region bounded by the graphs of y=f(x)Image, x=aImage, x=bImage, and the x-axis about the y-axis is given by

V = 2 π a b x f ( x ) d x .

Example 3.42

Let g(x)=xsin2xImage. Find the volume of the solid obtained by revolving the region bounded by the graphs of y=g(x)Image, x=0Image, x=πImage, and the x-axis about (a) the x-axis; and (b) the y-axis.

Solution

After defining g, we graph g on the interval [0,π]Image in Fig. 3.42 (a).

Image
Figure 3.42 (a) g(x) for 0 ⩽ x ⩽ π. (b) g(x) revolved about the x-axis. (c) g(x) revolved about the y-axis (University of California–Santa Barbara colors).

With Mathematica 11, for three dimensional graphics, you can adjust the viewpoint by clicking on the three-dimensional graphics object and dragging to the desired viewing angle.

g [ x _ ] = x Sin [ x ] 2 ; Image

p1 = Plot [ g [ x ] , { x , 0 , Pi } , AspectRatio - > Automatic , Image

PlotLabel “(a)” , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 1 , . 82 , . 17 , . 04 ] } } ] ; Image

The volume of the solid obtained by revolving the region about the x-axis is given by equation (3.21) while the volume of the solid obtained by revolving the region about the y-axis is given by equation (3.22). These integrals are computed with Integrate and named xvol and yvol, respectively. We use N to approximate each volume.

xvol = Integrate [ Pi g [ x ] 2 , { x , 0 , Pi } ] Image

N [ xvol ] Image

1 64 π 2 ( 15 + 8 π 2 ) Image

9.86295

yvol = Integrate [ 2 Pi x g [ x ] , { x , 0 , Pi } ] Image

N [ yvol ] Image

1 6 π 2 ( 3 + 2 π 2 ) Image

27.5349

We can use ParametricPlot3D to visualize the resulting solids by parametrically graphing the equations given by

{ x = r cos t y = r sin t z = g ( r )

for r between 0 and π and t between −π and π to visualize the graph of the solid obtained by revolving the region about the y-axis and by parametrically graphing the equations given by

{ x = r y = g ( r ) cos t z = g ( r ) sin t

for r between 0 and π and t between −π and π to visualize the graph of the solid obtained by revolving the region about the x-axis. (See Figs. 3.42 (b) and 3.42 (c).) In this case, we identify the z-axis as the y-axis. Notice that we are simply using polar coordinates for the x and y-coordinates, and the height above the x, y-plane is given by z=g(r)Image because r is replacing x in the new coordinate system.

p2 = ParametricPlot3D [ { r , g [ r ] Cos [ t ] , g [ r ] Sin [ t ] } , { r , 0 , Pi } , { t , 0 , 2 Pi } , Image

PlotPoints - > { 30 , 30 } , PlotLabel “(b)” , Image

PlotStyle { CMYKColor [ 0 , . 18 , . 89 , 0 ] , Specularity [ White , 10 ] } , Image

MeshFalse];Image

p3 = ParametricPlot3D [ { r Cos [ t ] , r Sin [ t ] , g [ r ] } , { r , 0 , Pi } , { t , 0 , 2 Pi } , Image

PlotPoints - > { 30 , 30 } , PlotLabel “(c)” , Image

PlotStyle { CMYKColor [ 1 , . 86 , . 36 , . 28 ] , Image

Opacity [ . 9 ] , Specularity [ White , 1 ] } , Image

Mesh False ] ; Image

p1, p2, and p3 are shown together side-by-side in Fig. 3.42 using Show together with GraphicsRow.

Show[GraphicsRow[{p1,p2,p3}]]Image  □

We now demonstrate a volume problem that requires the method of disks.

Example 3.43

Let f(x)=e(x3)2cos[4(x3)]Image. Approximate the volume of the solid obtained by revolving the region bounded by the graphs of y=f(x)Image, x=1Image, x=5Image, and the x-axis about the x-axis.

Solution

Proceeding as in the previous example, we first define and graph f on the interval [1,5]Image in Fig. 3.43 (a).

Image
Figure 3.43 (a) f(x) for 1 ⩽ x ⩽ 5. (b) f(x) revolved abut the x-axis (University of Southern California colors).

f [ x _ ] = Exp [ ( x 3 ) 2 Cos [ 4 ( x 3 ) ] ] ; Image

p1 = Plot [ f [ x ] , { x , 1 , 5 } , AspectRatio - > Automatic , Image

PlotLabel “(a)” , AxesLabel { x , y } , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ . 07 , 1 , . 65 , . 32 ] } ] ; Image

In this case, an approximation is desired so we use NIntegrate to approximate the integral V=15π[f(x)]2dxImage.

NIntegrate[Pif[x]2,{x,1,5}]Image

16.0762

In the same manner as before, ParametricPlot3D can be used to visualize the resulting solid by graphing the set of equations given parametrically by

{ x = r y = f ( r ) cos t z = f ( r ) sin t

for r between 1 and 5 and t between 0 and 2π. In this case, polar coordinates are used in the y, z-plane with the distance from the x-axis given by f(x)Image. Because r replaces x in the new coordinate system, f(x)Image becomes f(r)Image in these equations. See Fig. 3.43 (b).

p2 = ParametricPlot3D [ { r , f [ r ] Cos [ t ] , f [ r ] Sin [ t ] } , { r , 1 , 5 } , { t , 0 , 2 Pi } , Image

PlotPoints - > { 45 , 35 } , PlotLabel “(b)” , Image

PlotStyle { CMYKColor [ 0 , . 27 , 1 , 0 ] } ] ; Image

Show[GraphicsRow[{p1,p2}]]Image  □

When revolving a curve about the y-axis, you can use RevolutionPlot3D rather than the parametrization given previously.

Example 3.44

Let f(x)=exp(2(x2)2)+exp((x4)2)Image for 0x6Image. (a) Find the minimum and maximum values of f(x)Image on [0,6]Image. Let R be the region bounded by y=f(x)Image, x=0Image, x=6Image, and the y-axis. (b) Find the volume of the solid obtained by revolving R about the y-axis. (c) Find the volume of the solid obtained by revolving R about the x-axis.

Solution

(a) Although Maximize and Minimize cannot find the exact maximum and minimum values, using N or NMaximize and NMinimize give accurate approximations.

NMaximize and NMinimize work in the same way as Maximize and Minimize but return approximations rather than exact results.

f [ x _ ] = Exp [ 2 ( x 2 ) 2 ] + Exp [ ( x 4 ) 2 ] ; Image

Maximize [ f [ x ] , x ] Image

{ e ( 4 + Root [ { 4 + 2 # 1 + e # 1 2 ( 4 e 8 + # 1 e 8 ) & , 2.0196244769513376905 } ] ) 2 Image

× e 2 ( 2 + Root [ { 4 + 2 # 1 + e # 1 2 ( 4 e 8 + # 1 e 8 ) & , 2.0196244769513376905 } ] ) 2 Image

( e ( 4 + Root [ { 4 + 2 # 1 + e # 1 2 ( 4 e 8 + # 1 e 8 ) & , 2.0196244769513376905 } ] ) 2 Image

+ e 2 ( 2 + Root [ { 4 + 2 # 1 + e # 1 2 ( 4 e 8 + # 1 e 8 ) & , 2.0196244769513376905 } ] ) 2 ) , { x Root [ { 4 + 2 # 1 Image

+ e # 1 2 ( 4 e 8 + # 1 e 8 ) & , 2.0196244769513376905 } ] } } Image

Maximize [ f [ x ] , x ] // N Image

{1.01903,{x2.01962}}Image

NMaximize [ { f [ x ] , 0 x 6 } , x ] Image

{ 1.00034 , { x 3.99864 } } Image

Minimize [ { f [ x ] , 0 x 6 } , x ] Image

{ e 8 + e 16 e 24 , { x 0 } } Image

Minimize [ { f [ x ] , 0 x 6 } , x ] // N Image

{ 0.000335575 , { x 0 . } } Image

NMinimize [ { f [ x ] , 0 x 6 } , x ] // N Image

{ 0.000335575 , { x 0 . } } Image

We double check these results by graphing f(x)Image and f(x)Image in Fig. 3.44 and then using FindRoot to approximate the critical numbers.

Image
Figure 3.44 We use the graph of f(x) to help us estimate the initial values to approximate the critical numbers with FindRoot (University of Minnesota colors).

pf1 = Plot [ f [ x ] , { x , 0 , 6 } , PlotLabel “(a)” , Image

AxesLabel { x , y } , PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 0 , . 16 , 1 , 0 ] } } ] Image

pf2 = Plot [ Tooltip [ { f [ x ] , f [ x ] } ] , { x , 0 , 6 } , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ 0 , . 16 , 1 , 0 ] } , Image

{ Thickness [ . 01 ] , CMYKColor [ 0 , 1 , . 63 , . 29 ] } } , Image

PlotLabel “(b)” , AxesLabel { x , y } ] Image

Show [ GraphicsRow [ { pf1 , pf2 } ] ] Image

Map [ FindRoot [ f [ x ] = = 0 , { x , # 1 } ] & , { 2 , 3 , 4 } ] Image

{{x2.01962},{x2.92167},{x3.99864}}Image

(b) Mathematica finds the exact volume of the solids although the results are expressed in terms of the Error function, Erf.

Integrate [ Pi x f [ x ] , { x , 0 , 6 } ] Image

π ( 1 + 2 e 16 + e 24 2 e 28 + 2 e 32 π ( 4 Erf [ 2 ] + 4 Erf [ 4 ] + 2 ( Erf [ 2 2 ] + Erf [ 4 2 ] ) ) ) 4 e 32 Image

NIntegrate [ Pi x f [ x ] , { x , 0 , 6 } ] Image

30.0673

Integrate [ Pi f [ x ] 2 , { x , 0 , 6 } ] Image

1 12 e 8 / 3 π 3 / 2 ( 3 e 8 / 3 ( Erf [ 4 ] + Erf [ 8 ] + 2 ( Erf [ 2 2 ] + Erf [ 4 2 ] ) ) + 4 3 ( Erf [ 8 3 ] + Erf [ 10 3 ] ) ) Image

NIntegrate [ Pi f [ x ] 2 , { x , 0 , 6 } ] Image

7.1682

To visualize the solid revolved about the y-axis, we use RevolutionPlot3D in p1. We generate the curve in p2, a set of axes, and a representative “slice” of the curve. See Fig. 3.45 (a). After, we show the solid together with a representative shell. See Fig. 3.45 (b).

Image
Figure 3.45 (a) The solid. (b) The solid with a “typical” shell. (c) Several shells.

p1 = RevolutionPlot3D [ f [ x ] , { x , 1 , 5 } , Image

BoxRatios { 2 , 2 , 1 } , PlotRange { { 5 , 5 } , { 5 , 5 } , { 0 , 5 / 4 } } , Image

Mesh None , PlotStyle Opacity [ . 4 ] , Image

ColorFunction “LightTemperatureMap” ] ; Image

p2 = ParametricPlot3D [ { x , 0 , Exp [ 2 ( x 2 ) 2 ] + Exp [ ( x 4 ) 2 ] } , Image

{ x , 1 , 5 } , { t , 0 , 2 Pi } , Image

PlotStyle Thickness [ . 05 ] , BoxRatios { 2 , 2 , 1 } , Image

Axes Automatic , Boxed False ] ; Image

p3 = ParametricPlot3D [ { x , 0 , 0 } , { x , 5 , 5 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 075 ] } , BoxRatios { 2 , 2 , 1 } , Image

Axes Automatic , Boxed False ] ; Image

p4 = ParametricPlot3D [ { 0 , 0 , x } , { x , 0 , 5 / 4 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 1 ] } , BoxRatios { 2 , 2 , 1 } , Image

Axes Automatic , Boxed False ] ; Image

p5 = Graphics3D [ { Gray , Thickness [ . 01 ] , Line [ { { 3.6 , 0 , 0 } , Image

{ 3.6 , 0 , Exp [ 2 ( 3.6 2 ) 2 ] + Exp [ ( 3.6 4 ) 2 ] } } ] } ] ; Image

p6 = ParametricPlot3D [ { 3.6 Cos [ t ] , 3.6 Sin [ t ] , z } , { t , 0 , 2 Pi } , Image

{ z , 0 , Exp [ 2 ( 3.6 2 ) 2 ] + Exp [ ( 3.6 4 ) 2 ] } , Mesh None , Image

PlotStyle Opacity [ . 8 ] , ColorFunction “TemperatureMap” ] ; Image

g1 = Show [ p1 , p2 , p3 , p4 , p5 , Boxed False , Axes None ] Image

g2 = Show [ p1 , p2 , p3 , p4 , p5 , p6 , Boxed False , Axes None ] Image

Show [ GraphicsRow [ { g1 , g2 } ] ] Image

Finally, we show the solid together with several shells in Fig. 3.45 (c).

sp = Table [ j // N , { j , 1.1 , 4.9 , 3.8 / 14 } ] ; Image

p7 = Table [ ParametricPlot3D [ { sp [ [ i ] ] Cos [ t ] , sp [ [ i ] ] Sin [ t ] , z } , Image

{ t , 0 , 2 Pi } , Image

{ z , 0 , Exp [ 2 ( sp [ [ i ] ] 2 ) 2 ] + Exp [ ( sp [ [ i ] ] 4 ) 2 ] } , Image

Mesh None , Image

PlotStyle Opacity [ . 8 ] , Image

ColorFunction “TemperatureMap” ] , { i , 1 , Length [ sp ] } ] ; Image

g3 = Show [ p1 , p2 , p3 , p4 , p5 , p7 , Boxed False , Axes None ] Image

Show [ GraphicsRow [ { g1 , g2 , g3 } ] ] Image

You can use Animate to animate the process as illustrated in Fig. 3.46.

Image
Figure 3.46 Using Animate to illustrate the finding the volume of a solid using the method of shells.

Animate [ Image

p8 = ParametricPlot3D [ { i Cos [ t ] , i Sin [ t ] , z } , { t , 0 , 2 Pi } , Image

{ z , 0 , Exp [ 2 ( i 2 ) 2 ] + Exp [ ( i 4 ) 2 ] } , Mesh None , Image

PlotStyle Opacity [ . 8 ] , ColorFunction “TemperatureMap” ] ; Image

Show [ p1 , p2 , p3 , p4 , p5 , p8 , Boxed False , Axes None ] , Image

{i,1.1,4.9}]Image

For revolving f(x)Image about the x-axis, we proceed in much the same way. First, we plot f(x)Image with a set of axes in three-space.

f [ x _ ] = Exp [ 2 ( x 2 ) 2 ] + Exp [ ( x 4 ) 2 ] ; Image

p1 = ParametricPlot3D [ { x , 0 , f [ x ] } , { x , 0 , 6 } , PlotStyle { Thick , Black } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

p1b = ParametricPlot3D [ { x , 0 , f [ x ] } , { x , 0 , 6 } , PlotStyle { Thick , Black } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

p2 = ParametricPlot3D [ { x , 0 , 0 } , { x , 0 , 6 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 075 ] } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

p3 = ParametricPlot3D [ { 0 , 0 , x } , { x , 3 / 2 , 3 / 2 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 1 ] } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

Show [ p1 , p1b , p2 , p3 ] Image

(c) Next, we generate a basic plot of the solid in p4 and then a set of disks inside the solid in t3d.

f [ x _ ] = Exp [ 2 ( x 2 ) 2 ] + Exp [ ( x 4 ) 2 ] ; Image

p1 = ParametricPlot3D [ { x , 0 , f [ x ] } , { x , 0 , 6 } , PlotStyle { Thick , Black } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

p1b = ParametricPlot3D [ { x , 0 , f [ x ] } , { x , 0 , 6 } , PlotStyle { Thick , Black } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , BoxRatios { 1 , 1 , 1 } ] ; Image

p2 = ParametricPlot3D [ { x , 0 , 0 } , { x , 0 , 6 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 075 ] } , PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } ] ; Image

p3 = ParametricPlot3D [ { 0 , 0 , x } , { x , 3 / 2 , 3 / 2 } , { t , 0 , 2 Pi } , Image

PlotStyle { Gray , Thickness [ . 1 ] } , PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } ] ; Image

Show [ p1 , p1b , p2 , p3 ] Image

p4 = ParametricPlot3D [ { r , f [ r ] Cos [ t ] , f [ r ] Sin [ t ] } , Image

{ r , 0 , 6 } , { t , 0 , 2 Pi } , PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } ] Image

t3d = Table [ ParametricPlot3D [ { x , r f [ x ] Cos [ t ] , r f [ x ] Sin [ t ] } , { r , 0 , 1 } , { t , 0 , 2 Pi } , Image

PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } , ColorFunction “TemperatureMap” , Mesh 5 ] , { x , 0 , 6 , 6 / 14 } ] ; Image

Two variations of the solid are plotted in p5 and p6. In each case, we use MeshFunctions to have the contour lines (mesh) correspond to f(x)Image values rather than the rectangular default mesh. In p6 the solid is made transparent with the Opacity option.

p5 = ParametricPlot3D [ { r , f [ r ] Cos [ t ] , f [ r ] Sin [ t ] } , Image

{ r , 0 , 6 } , { t , 0 , 2 Pi } , PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , { 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } , MeshFunctions - > { # 1 & } , Mesh 60 ] Image

p6 = ParametricPlot3D [ { r , f [ r ] Cos [ t ] , f [ r ] Sin [ t ] } , Image

{ r , 0 , 6 } , { t , 0 , 2 Pi } , PlotRange { { 0 , 6 } , { 3 / 2 , 3 / 2 } , Image

{ 3 / 2 , 3 / 2 } } , Image

BoxRatios { 1 , 1 , 1 } , MeshFunctions - > { # 1 & } , Mesh 25 , Image

PlotStyle Opacity [ . 2 ] , Image

MeshStyle { Gray , Thick } ] ; Image

Show [ p1 , p1b , p2 , p3 , p6 ] Image

Several combinations of the images are shown in Figs. 3.47 and 3.48.

Image
Figure 3.47 (a) Seeing f(x) on the solid. (b) Disks in the solid.
Image
Figure 3.48 (a) f(x) in space. (b) The basic solid. (c) Contours based on f(x) values. (d) Seeing f(x) on the solid.

Show [ GraphicsRow [ { Show [ p1 , p1b , p2 , p3 , p6 ] , Show [ p1 , p1b , p2 , p3 , p6 , t3d ] } ] ] Image

Show [ GraphicsGrid [ { { Show [ p1 , p1b , p2 , p3 ] , p4 } , Image

{p5,Show[p1,p1b,p2,p3,p6]}}]]Image  □

To help identify regions, RegionPlot[constraints,{x,a,b},{y,a,b}] attempts to shade the region in the rectangle [a,b]×[c,d]Image that satisfies the constraints in constraints.

Example 3.45

Let g(x)=xImage, h(x)=x2Image, and R the region bounded by the graphs of g(x)Image and h(x)Image. Find the volume of the solid obtained by revolving R about (a) the x-axis and (b) the y-axis.

Solution

We illustrate the use of RegionPlot to help us see R. See Fig. 3.49

Image
Figure 3.49 (a) Graphs of f(x) and g(x). (b) The region in [0,2]×[0,2] for which x2yxImage. (c) The two plots displayed together.

g [ x _ ] = Sqrt [ x ] ; Image

h [ x _ ] = x 2 ; Image

p1a = Plot [ Tooltip [ { g [ x ] , h [ x ] } ] , { x , 0 , 2 } , PlotRange { { 0 , 2 } , { 0 , 2 } } , Image

AspectRatio Automatic , PlotLabel “(a)” , Image

PlotStyle { { CMYKColor [ . 85 , 1 , 0 , . 15 ] } , { CMYKColor [ . 5 , . 5 , . 5 , 1 ] } } ] ; Image

p1b = RegionPlot [ x 2 y Sqrt [ x ] , { x , 0 , 2 } , { y , 0 , 2 } , PlotStyle Purple , Image

PlotLabel “(b)” ] ; Image

Show [ GraphicsRow [ { p1a , p1b , Show [ { p1a , p1b } , PlotLabel “(c)” ] } ] ] Image

We plot the solids with ParametricPlot3D and contour lines along the function values using the MeshFunctions option in Fig. 3.50.

Image
Figure 3.50 (a) The solid formed by revolving R about the x-axis. (b) The solid formed by revolving R about the y-axis (Northwestern University colors).

p4 = ParametricPlot3D [ { { r , g [ r ] Cos [ t ] , g [ r ] Sin [ t ] } , Image

{ r , h [ r ] Cos [ t ] , h [ r ] Sin [ t ] } } , { r , 0 , 1 } , Image

{ t , 0 , 2 Pi } , PlotRange { { 0 , 3 / 2 } , { 5 / 4 , 5 / 4 } , { 5 / 4 , 5 / 4 } } , Image

BoxRatios { 1 , 1 , 1 } , MeshFunctions { # 1 & } , PlotStyle { Purple , Opacity [ . 1 ] } , Image

PlotLabel “(a)” ] ; Image

p5 = ParametricPlot3D [ { { r Cos [ t ] , r Sin [ t ] , g [ r ] } , Image

{ r Cos [ t ] , r Sin [ t ] , h [ r ] } } , { r , 0 , 1 } , Image

{ t , 0 , 2 Pi } , PlotRange { { 5 / 4 , 5 / 4 } , { 5 / 4 , 5 / 4 } , { 1 / 4 , 9 / 4 } } , Image

BoxRatios { 1 , 1 , 1 } , MeshFunctions { # 1 & } , PlotStyle { Purple , Opacity [ . 1 ] } , Image

PlotLabel “(b)” ] ; Image

Show [ GraphicsRow [ { p4 , p5 } ] ] Image

The volume of each solid is then found with Integrate and approximated with N.

Integrate [ Pi ( g [ x ] 2 h [ x ] 2 ) , { x , 0 , 1 } ] Image

3 π 10 Image

N [ % ] Image

0.942478

Integrate [ Pi x ( g [ x ] h [ x ] ) , { x , 0 , 1 } ] Image

3 π 20 Image

N [ % ] Image

0.471239 □

Surface Area

Let y=f(x)Image be a nonnegative function for which f(x)Image is continuous on an interval [a,b]Image. Then the surface area of the solid of revolution obtained by revolving the region bounded by the graphs of y=f(x)Image, x=aImage, x=bImage, and the x-axis about the x-axis is given by

S A = 2 π a b f ( x ) 1 + [ f ( x ) ] 2 d x .

Example 3.46

Gabriel's Horn

Gabriel's horn is the solid of revolution obtained by revolving the area of the region bounded by y=1/xImage and the x-axis for x1Image about the x-axis. Show that the surface area of Gabriel's horn is infinite but that its volume is finite.

Solution

After defining f(x)=1/xImage, we use ParametricPlot3D to visualize a portion of Gabriel's horn in Fig. 3.51.

Image
Figure 3.51 A portion of Gabriel's horn.

f [ x _ ] = 1 / x ; Image

ParametricPlot3D [ { r , f [ r ] Cos [ t ] , f [ r ] Sin [ t ] } , { r , 1 , 10 } , { t , 0 , 2 Pi } , Image

PlotPoints - > { 40 , 40 } , ViewPoint - > { 1.509 , 2.739 , 1.294 } ] Image

Using equation (3.23), the surface area of Gabriel's horn is given by the improper integral

S A = 2 π 1 1 x 1 + 1 x 4 d x = 2 π lim L 1 L 1 x 1 + 1 x 4 d x .

f [ x ] Image

1 x 2 Image

step1=Integrate[2Pif[x]Sqrt[1+f[x]2],{x,1,capl}]Image

ConditionalExpression [ 2 π ( 1 2 ( 2 ArcSinh [ 1 ] ) + 1 + 1 capl 4 ( 1 + capl 4 + capl 2 ArcSinh [ capl 2 ] ) 2 1 + capl 4 ) , Image

Re [ 1 capl 4 ] 1 & & ( . ( ( ( 1 + Re [ capl ] ) 4 Im [ capl ] 4 = = 1 ( 1 + Re [ capl ] ) 4 Im [ capl ] 4 1 ) & & capl Reals ) Re [ capl ] Image

0 ) & & ( ( Im [ capl ] + Re [ capl ] = = 0 & & ( 0 < Re [ capl ] < 1 Im [ capl ] > 0 Re [ capl ] > 1 ) ) 1 < Im [ capl ] < 0 ( Re [ capl ] 0 & & 1 < Im [ capl ] 0 ) Im [ capl ] < 1 ) & & Image

( Im [ capl ] ( Im [ capl ] + Re [ capl ] ) 1 + Im [ capl ] = = 0 Im [ capl ] 2 ( Im [ capl ] + Re [ capl ] ) 2 ( 1 + Im [ capl ] ) 2 0 1 1 + Im [ capl ] = = 1 1 1 + Im [ capl ] 1 Im [ capl ] < 1 ) ] Image

Limit [ step1 , capl - > Infinity ] Image

On the other hand, using equation (3.21) the volume of Gabriel's horn is given by the improper integral

V = 2 π 1 1 x 2 d x = π lim L 1 L 1 x 2 d x ,

which converges to π.

step1 = Integrate [ Pi f [ x ] 2 , { x , 1 , capl } ] Image

ConditionalExpression [ ( 1 1 capl ) π , Re [ capl ] > 0 capl Reals ] Image

Limit [ step1 , capl - > Infinity ] Image

π

Integrate [ Pi f [ x ] 2 , { x , 1 , Infinity } ] Image

π  □

3.4 Infinite Sequences and Series

3.4.1 Introduction to Sequences

Sequences and series are usually discussed in the third quarter or second semester of introductory calculus courses. Most students find that it is one of the most difficult topics covered in calculus. A sequence is a function with domain consisting of the positive integers. The terms of the sequence {an}Image are a1Image, a2Image, a3Image, …. The nth term is anImage; the (n+1)Imagest term is an+1Image. If limnan=LImage, we say that {an}Image converges to L. If {an}Image does not converge, {an}Image diverges. We can sometimes prove that a sequence converges by applying the following theorem.

Theorem 3.7

Every bounded monotonic sequence converges.

A sequence {an}Image is monotonic if {an}Image is increasing (an+1anImage for all n) or decreasing (an+1anImage for all n).

In particular, Theorem 3.7 gives us the following special cases.

1.  If {an}Image has positive terms and is eventually decreasing, {an}Image converges.

2.  If {an}Image has negative terms and is eventually increasing {an}Image converges.

After you have defined a sequence, use Table to compute the first few terms of the sequence.

1.  Table[a[n],{n,1,m}] returns the list {a1,a2,a3,,am}Image.

2.  Table[a[n],{n,k,m}] returns {ak,ak+1,ak+2,,am}Image.

The command ListPlot[listofpoints] plots the list of points listofpoints while ListLinePlot[listofpoints] plots the list of points listofpoints and connects consecutive points with line segments.

Remark 3.7

An extensive database of integer sequences can be found at the On-Line Encyclopedia of Integer Sequences,

http://www.research.att.com/~njas/sequences/Seis.html.

Example 3.47

If an=50nn!Image, show that limnan=0Image.

Solution

We remark that the symbol n! in the denominator of anImage represents the factorial sequence:

n ! = n ( n 1 ) ( n 2 ) 2 1 .

We begin by defining anImage and then computing the first few terms of the sequence with Table.

Clear [ a ] Image

a [ n _ ] := 50 n / n ! ; Image

afewterms = Table [ a [ n ] , { n , 1 , 10 } ] Image

{ 50 , 1250 , 62500 3 , 781250 3 , 7812500 3 , 195312500 9 , 9765625000 63 , 61035156250 63 , 3051757812500 567 , Image

15258789062500 567 } Image

N [ afewterms ] Image

{ 50 . , 1250 . , 20833.3 , 260417 . , 2.60417 × 10 6 , 2.17014 × 10 7 , 1.5501 × 10 8 , 9.68812 × 10 8 , Image

5.38229×109,2.69114×1010}Image

The first few terms increase in magnitude. In fact, this is further confirmed by graphing the first few terms of the sequence with ListPlot in Fig. 3.52 (a). Based on the graph and the values of the first few terms we might incorrectly conclude that the sequence diverges.

Image
Figure 3.52 (a) The first few terms of an. (b) The first 75 terms of an. (c) The first 75 terms of an connected with line segments. (d) Displaying the points together with the first 75 terms of an connected with line segments (The Ohio State University colors).

p1 = ListPlot [ afewterms , PlotStyle { PointSize [ . 025 ] , CMYKColor [ . 03 , 1 , . 63 , . 12 ] } , Image

PlotLabel “(a)” ] ; Image

However, notice that an+1=50n+1anan+1an=50n+1Image. Because 50/(n+1)<1Image for n>49Image, we conclude that the sequence is decreasing for n>49Image. Because it has positive terms, it is bounded below by 0 so the sequence converges by Theorem 3.7. Let L=limnanImage. Then,

lim n a n + 1 = lim n 50 n + 1 a n L = lim n 50 n + 1 L L = 0 .

When we graph a larger number of terms, it is clear that the limit is 0. (See Fig. 3.52 (b).) It is a good exercise to show that for any real value of x, limnxnn!=0Image.

Use ListLinePlot to connect consecutive points with line segments.

p2 = ListPlot [ Evaluate [ Table [ a [ k ] , { k , 1 , 75 } ] ] , Image

PlotStyle { PointSize [ . 025 ] , CMYKColor [ . 03 , 1 , . 63 , . 12 ] } , Image

PlotLabel “(b)” ] ; Image

p3 = ListLinePlot [ Evaluate [ Table [ a [ k ] , { k , 1 , 75 } ] ] , Image

PlotStyle CMYKColor [ . 56 , . 47 , . 47 , . 15 ] , Image

PlotLabel “(c)” ] ; Image

p4 = Show [ p2 , p3 , PlotLabel “(d)” ] ; Image

Show[GraphicsGrid[{{p1,p2},{p3,p4}}]]Image □

Example 3.48

The Rational Numbers and the Calkin–Wilf Sequence

A set S is countably infinite if there is a one-to-one correspondence between the elements of S and the natural numbers. In other words, S is countably infinite if it can be written as a sequence.

Students in introductory set theory classes often learn that the set of rational numbers, Q={nm:n,m0 integers}Image is countably infinite using Cantor's Diagnalization Process.

In 2000, Neil Calkin and Herbert Wilf published a paper introducing the Calkin–Wilf sequence. The Calkin–Wilf sequence is a recursively defined sequence that gives a one-to-one correspondence between the natural numbers and the positive rational numbers. Stating a specific sequence that yields the positive rational numbers proving the countability of the rationals provides an interesting contrast to the traditional method of using Cantor's Diagnalization Process.

The Calkin–Wilf sequence is defined by

q 1 = 1 q i = 1 2 q i 1 q i 1 + 1  for  i > 1 ,

where qi1Image represents the integer part of qi1Image. The Mathematica command IntegerPart[x] returns the integer part of x. When defining q, observe that we use the form q[i_]:=q[i]= so that Mathematica “remembers” the computed values of qiImage. Thus, to compute qnImage, Mathematica need only have computed qn1Image rather than re-computing the previous n1Image qiImage values. Compute and plot the first n terms of the Calkin–Wilf sequence with n=50Image and n=500Image.

You can use Mathematica to define quite complex sequences. In the following example, we define a sequence that depends on four other sequences. Observe that when defining the terms, we consistently use the form a[n_]:=a[n]=... so that Mathematica “remembers” sequence values computed and need not recompute them to compute subsequent terms.

Example 3.49

The Gauss–Legendre Algorithm

One algorithm to approximate π is the Gauss–Legendre algorithm. Although it is memory intensive, 25 iterations approximate π to around 45 million digits. After defining akImage, bkImage, tkImage, and pkImage, π is approximated with π(an+bn)24tnImage. Approximate π to 100 decimal places.

Solution

Remove [ a , b , t , p , pi ] Image

a [ 0 ] = 1 ; Image

b [ 0 ] = 1 / Sqrt [ 2 ] ; Image

t [ 0 ] = 1 / 4 ; Image

p [ 0 ] = 1 ; Image

a [ n _ ] := a [ n ] = N [ ( a [ n 1 ] + b [ n 1 ] ) / 2 , 10000 ] ; Image

b [ n _ ] := b [ n ] = N [ Sqrt [ a [ n 1 ] b [ n 1 ] ] , 10000 ] ; Image

t [ n _ ] := t [ n ] = N [ t [ n 1 ] p [ n 1 ] ( a [ n 1 ] a [ n ] ) 2 , 10000 ] ; Image

p [ n _ ] := p [ n ] = N [ 2 p [ n 1 ] , 10000 ] ; Image

π is then approximated with

pi[n_]:=N[(a[n]+b[n])2/(4t[n]),100]Image

To increase the accuracy of your approximation, increase 10000 and 100 to your desired values. However, even on relatively fast machines, if you replace all these numbers with a number such as 1000000, the computation time will increase considerably.

For illustrate purposes, we approximate π with π(a6+b6)24t6Image. Observe that the result is accurate to at least 100 decimal places.

pi [ 6 ] Image

3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

N [ Pi , 100 ] Image

3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 □

3.4.2 Introduction to Infinite Series

An infinite series is a series of the form

k = 1 a k = a 1 + a 2 + a 3 +

where {an}Image is a sequence. The nth partial sum of (3.25) is

s n = k = 1 n a k = a 1 + a 2 + + a n .

Notice that the partial sums of the series (3.25) form a sequence {sn}Image. Hence, we say that the infinite series (3.25) converges to L if the sequence of partial sums {sn}Image converges to L and write

k = 1 a k = L .

The infinite series (3.25) diverges if the sequence of partial sums diverges. Given the infinite series (3.25),

Sum[a[k],{k,1,n}]

calculates the nth partial sum (3.26). In some cases, if the infinite series (3.25) converges,

Sum[a[k],{k,1,Infinity}]

can compute the value of the infinite sum. In addition to using Sum to compute finite and infinite sums, you can use the Image button on the Basic Math Input palette to calculate sums. You should think of the Sum function as a “fragile” command and be certain to carefully examine its results and double check their validity.

Example 3.50

Determine whether each series converges or diverges. If the series converges, find its sum. (a) k=1(1)k+1Image; (b) k=22k21Image; and (c) k=0arkImage.

Solution

For (a), we compute the nth partial sum (3.26) in sn with Sum.

sn = Sum [ ( 1 ) ( k + 1 ) , { k , 1 , n } ] Image

1 2 ( 1 + ( 1 ) 1 + n ) Image

Notice that the odd partial sums are 1: s2n+1=12((1)2n+1+1+1)=12(1+1)=1Image while the even partial sums are 0: s2n=12((1)2n+1+1)=12(1+1)=0Image. We confirm that the limit of the partial sums does not exist with Limit. Mathematica's result indicates that it cannot determine the limit. The series diverges.

Limit [ sn , n Infinity ] Image

1 2 ( 1 + e 2 i Interval [ { 0 , π } ] ) Image

Similarly, when we attempt to compute the infinite sum with Sum, Mathematica is able to determine that the partial sums diverge, which means that the infinite series diverges.

Image

For (b), we have a telescoping series. Using partial fractions,

k = 2 2 k 2 1 = k = 2 ( 1 k 1 1 k + 1 ) = ( 1 1 3 ) + ( 1 2 1 4 ) + ( 1 3 1 5 ) + + ( 1 n 2 1 n ) + ( 1 n 1 1 n + 1 ) +

we see that the nth partial sum is given by

s n = 3 2 1 n 1 n + 1

and sn3/2Image as nImage so the series converges to 3/2:

k = 2 2 k 2 1 = 3 2 .

We perform the same steps with Mathematica using Sum, Apart, and Limit.

Apart computes the partial fraction decomposition of a rational expression.

sn = Sum [ 1 / ( k 1 ) 1 / ( k + 1 ) , { k , 2 , n } ] Image

2n+3n22n(1+n)Image

Apart [ sn ] Image

3 2 1 n 1 1 + n Image

Limit [ sn , n Infinity ] Image

3 2 Image

(c) A series of the form k=0arkImage is called a geometric series. We compute the nth partial sum of the geometric series with Sum.

sn = Sum [ a r k , { k , 0 , n } ] Image

a ( 1 + r 1 + n ) 1 + r Image

When using Limit to determine the limit of snImage as nImage, we see that Mathematica returns the limit unevaluated because Mathematica does not know the value of r.

Limit [ sn , n Infinity ] Image

Limit [ a ( 1 + r 1 + n ) 1 + r , n ] Image

In fact, the geometric series diverges if |r|1Image and converges if |r|<1Image. Observe that if we simply compute the sum with Sum, Mathematica returns a/(1r)Image which is correct if |r|<1Image but incorrect if |r|1Image.

Sum [ a r k , { k , 0 , Infinity } ] Image

a 1 r Image

However, the result of entering

Image

is correct because the series k=0(53)kImage is geometric with |r|=5/31Image and, consequently, diverges. Similarly,

Sum [ 9 ( 1 / 10 ) k , { k , 1 , Infinity } ] Image

1

is correct because k=19(110)kImage is geometric with a=9/10Image and r=1/10Image so the series 0.999… converges to

a 1 r = 9 / 10 1 1 / 10 = 1 .

 □

3.4.3 Convergence Tests

Frequently used convergence tests for infinite series are stated in the following theorems. Note that the infinite series k=1akImage converges absolutely means that k=1|ak|Image converges. If an infinite series converges absolutely, it converges. If a series converges, but does not converge absolutely, we say that the series conditionally converges.

The alternating harmonic series, k=1(1)k+11/kImage is an example of a series that converges conditionally. It is a good exercise to show that the alternating harmonic series converges to ln2Image. On the other hand, the harmonic series, k=11/kImage diverges to +∞.

Theorem 3.8

The Divergence Test

Let k=1akImage be an infinite series. If limkak0Image, then k=1akImage diverges.

Theorem 3.9

The Integral Test

Let k=1akImage be an infinite series with positive terms. If f(x)Image is a decreasing continuous function for which f(k)=akImage for all k, then k=1akImage and 1f(x)dxImage either both converge or both diverge.

Theorem 3.10

The Ratio Test

Let k=1akImage be an infinite series and let ρ=limk|ak+1ak|Image.

1.  If ρ<1Image, k=1akImage converges absolutely.

2.  If ρ>1Image, k=1akImage diverges.

3.  If ρ=1Image, the Ratio Test is inconclusive.

Theorem 3.11

The Root Test

Let k=1akImage be an infinite series and let ρ=limk|ak|kImage.

1.  If ρ<1Image, k=1akImage converges absolutely.

2.  If ρ>1Image, k=1akImage diverges.

3.  If ρ=1Image, the Root Test is inconclusive.

Theorem 3.12

The Limit Comparison Test

Let k=1akImage and k=1bkImage be infinite series with positive terms and let L=limkakbkImage. If 0<L<Image, then either both series converge or both series diverge.

Example 3.51

Determine whether each series converges or diverges. (a) k=1(1+1k)kImage; (b) k=11kpImage; (c) k=1k3kImage; (d) k=1(k!)2(2k)!Image; (e) k=1(k4k+1)kImage; (f) k=12k+1(k+1)(2k+1)Image.

Solution

(a) Using Limit, we see that the limit of the terms is e0Image so the series diverges by the Divergence Test, Theorem 3.8.

Limit [ ( 1 + 1 / k ) k , k Infinity ] Image

e

It is a very good exercise to show that the limit of the terms of the series is e by hand. Let L=limk(1+1/k)kImage. Take the logarithm of each side of this equation and apply L'Hôpital's rule:

ln L = lim k ln ( 1 + 1 k ) k ln L = lim k k ln ( 1 + 1 k ) ln L = lim k ln ( 1 + 1 k ) 1 k ln L = lim k 1 1 + 1 k 1 k 2 1 k 2 ln L = 1 .

Exponentiating yields L=elnL=e1=eImage.

(b) A series of the form k=11kpImage (p>0Image) is called a p-series. Let f(x)=xpImage. Then, f(x)Image is continuous and decreasing for x1Image, f(k)=kpImage and

1 x p d x = { , if  p 1 1 / ( p 1 ) , if  p > 1

so the p-series converges if p>1Image and diverges if p1Image. If p=1Image, the series k=11kImage is called the harmonic series. Observe that Mathematica's result is given in terms of a “conditional expression.” In this example, the interpretation is that 1xpdx=1/(p1)Image provided that the real part of p is greater than 1.

Clear [ x , p ] Image

s1 = Integrate [ x ( p ) , { x , 1 , Infinity } ] Image

ConditionalExpression [ 1 1 + p , Re [ p ] > 1 ] Image

(c) Let f(x)=x3xImage. Then, f(k)=k3kImage and f(x)Image is decreasing for x>1/ln3Image because f(x)<0Image for x>1/ln3Image.

f [ x _ ] = x 3 ( x ) ; Image

Factor [ f [ x ] ] Image

3 x ( 1 + x Log [ 3 ] ) Image

Solve [ 1 + x Log [ 3 ] = = 0 , x ] Image

{{x1Log[3]}}Image

Using Integrate, we see that the improper integral 1f(x)dxImage converges.

ival = Integrate [ f [ x ] , { x , 1 , Infinity } ] Image

N [ ival ] Image

1 + Log [ 3 ] 3 Log [ 3 ] 2 Image

0.579592

Thus, by the Integral Test, Theorem 3.9, we conclude that the series converges. Note that when applying the Integral Test, if the improper integral converges its value is not the value of the sum of the series. In this case, we see that Mathematica is able to evaluate the sum with Sum and the series converges to 3/4.

Sum [ k 3 ( k ) , { k , 1 , Infinity } ] Image

3 4 Image

(d) If akImage contains factorial functions, the Ratio Test is often a good first test to try. After defining akImage we compute

lim k a k + 1 a k = lim k [ ( k + 1 ) ! ] 2 [ 2 ( k + 1 ) ] ( k ! ) 2 ( 2 k ) ! = lim k ( k + 1 ) ! ( k + 1 ) ! k ! k ! ( 2 k ) ! ( 2 k + 2 ) ! = lim k ( k + 1 ) 2 ( 2 k + 2 ) ( 2 k + 1 ) = lim k ( k + 1 ) 2 ( 2 k + 1 ) = 1 4 .

Because 1/4<1Image, the series converges by the Ratio Test. We confirm these results with Mathematica.

Remark 3.8

Use FullSimplify instead of Simplify to simplify expressions involving factorials.

a [ k _ ] = ( k ! ) 2 / ( 2 k ) ! ; Image

s1 = FullSimplify [ a [ k + 1 ] / a [ k ] ] Image

1 + k 2 + 4 k Image

Limit [ s1 , k Infinity ] Image

1 4 Image

We illustrate that we can evaluate the sum using Sum and approximate it with N as follows.

ev=Sum[a[k],{k,1,Infinity}]Image

1 27 ( 9 + 2 3 π ) Image

N [ ev ] Image

0.7364

(e) Because

lim k ( k 4 k + 1 ) k k = lim k k 4 k + 1 = 1 4 < 1 ,

the series converges by the Root Test.

a [ k _ ] = ( k / ( 4 k + 1 ) ) k ; Image

Limit [ a [ k ] ( 1 / k ) , k Infinity ] Image

1 4 Image

As with (d), we can approximate the sum with N and Sum.

ev = Sum [ a [ k ] , { k , 1 , Infinity } ] Image

k = 1 ( k 1 + 4 k ) k Image

N [ ev ] Image

0.265757

(f) We use the Limit Comparison Test and compare the series to k=1kkk=k=11kImage, which diverges because it is a p-series with p=1Image. Because

0 < lim k 2 k + 1 ( k + 1 ) ( 2 k + 1 ) 1 k = 1 <

and the harmonic series diverges, the series diverges by the Limit Comparison Test.

a [ k _ ] = ( 2 Sqrt [ k ] + 1 ) / ( ( Sqrt [ k ] + 1 ) ( 2 k + 1 ) ) ; Image

b [ k _ ] = 1 / k ; Image

Limit [ a [ k ] / b [ k ] , k Infinity ] Image

1  □

3.4.4 Alternating Series

An alternating series is a series of the form

k = 1 ( 1 ) k a k or k = 1 ( 1 ) k + 1 a k

where {ak}Image is a sequence with positive terms.

Definition 3.3

The alternating series (3.27) converges absolutely if k=1akImage converges.

Theorem 3.14

If the alternating series (3.27) converges absolutely, it converges.

Definition 3.4

If the alternating series (3.27) converges but does not converge absolutely, we say that the alternating series, (3.27), conditionally converges.

Example 3.52

Determine whether each series converges or diverges. If the series converges, determine whether the convergence is conditional or absolute. (a) k=1(1)k+1kImage; (b) k=1(1)k+1(k+1)!4k(k!)2Image; (c) k=1(1)k+1(1+1k)kImage.

Solution

(a) Because {1/k}Image is decreasing and 1/k0Image as kImage, the series converges. The series does not converge absolutely because the harmonic series diverges. Hence, k=1(1)k+1kImage, which is called the alternating harmonic series, converges conditionally. We see that this series converges to ln2Image with Sum.

a [ k _ ] = ( 1 ) ( k + 1 ) / k ; Image

Sum [ a [ k ] , { k , 1 , Infinity } ] Image

Log [ 2 ] Image

(b) We test for absolute convergence first using the Ratio Test. Because

lim k ( ( k + 1 ) + 1 ) ! 4 k + 1 [ ( k + 1 ) ! ] 2 ( k + 1 ) ! 4 k ( k ! ) 2 = lim k k + 2 4 ( k + 1 ) 2 = 0 < 1 ,

a [ k _ ] = ( k + 1 ) ! / ( 4 k ( k ! ) 2 ) ; Image

s1 = FullSimplify [ a [ k + 1 ] / a [ k ] ] Image

Limit [ s1 , k Infinity ] Image

2 + k 4 ( 1 + k ) 2 Image

0

the series converges absolutely by the Ratio Test. Absolute convergence implies convergence so the series converges.

(c) Because limk(1+1k)k=eImage, limk(1)k+1(1+1k)kImage does not exist, so the series diverges by the Divergence Test. We confirm that the limit of the terms is not zero with Limit.

Sum [ ( 1 ) ( k + 1 ) a [ k ] , { k , 1 , Infinity } ] Image

3 4 e 1 / 4 4 e 1 / 4 Image

Image

Limit [ a [ k ] , k Infinity ] Image

e1+2iInterval[{0,π}]Image □

3.4.5 Power Series

Let x0Image be a number. A power series in xx0Image is a series of the form

k = 0 a k ( x x 0 ) k .

A fundamental problem is determining the values of x, if any, for which the power series converges, the interval of convergence.

Theorem 3.15

For the power series (3.28), exactly one of the following is true.

1.  The power series converges absolutely for all values of x. The interval of convergence is (,)Image.

2.  There is a positive number r so that the series converges absolutely if x0r<x<x0+rImage. The series may or may not converge at x=x0rImage and x=x0+rImage. The interval of convergence will be one of (x0r,x0+r)Image, [x0r,x0+r)Image, (x0r,x0+r]Image, or [x0r,x0+r]Image.

3.  The series converges only if x=x0Image. The interval of convergence is {x0}Image.

Example 3.53

Determine the interval of convergence for each of the following power series. (a) k=0(1)k(2k+1)!x2k+1Image; (b) k=0k!1000k(x1)kImage; (c) k=12kk(x4)kImage.

Solution

(a) We test for absolute convergence first using the Ratio Test. Because

lim k | ( 1 ) k + 1 ( 2 ( k + 1 ) + 1 ) ! x 2 ( k + 1 ) + 1 ( 1 ) k ( 2 k + 1 ) ! x 2 k + 1 | = lim k 1 2 ( k + 1 ) ( 2 k + 3 ) x 2 = 0 < 1

a [ x _ , k _ ] = ( 1 ) k / ( 2 k + 1 ) ! x ( 2 k + 1 ) ; Image

s1 = FullSimplify [ a [ x , k + 1 ] / a [ x , k ] ] Image

Limit [ s1 , k Infinity ] Image

x 2 6 + 10 k + 4 k 2 Image

0

for all values of x, we conclude that the series converges absolutely for all values of x; the interval of convergence is (,)Image. In fact, we will see later that this series converges to sinxImage:

sin x = k = 0 ( 1 ) k + 1 ( 2 k + 1 ) ! x 2 k + 1 = x 1 3 ! x 3 + 1 5 ! x 5 1 7 ! x 7 + ,

which means that the partial sums of the series converge to sinxImage. Graphically, we can visualize this by graphing partial sums of the series together with the graph of y=sinxImage. Note that the partial sums of a series are a recursively defined function: sn=sn1+anImage, s0=a0Image. We use this observation to define p to be the nth partial sum of the series. We use the form p[x_,n_]:=p[x,n]=... so that Mathematica “remembers” the partial sums computed. That is, once p[x,3] is computed, Mathematica need not recompute p[x,3] when computing p[x,4].

In Fig. 3.54 we graph pn(x)=k=0n(1)k(2k+1)!x2k+1Image together with y=sinxImage for n=1Image, 5, and 10. In the graphs, notice that as n increases, the graphs of pn(x)Image more closely resemble the graph of y=sinxImage.

Image
Figure 3.54 y=sinxImage together with the graphs of p1(x), p5(x), and p10(x).

When you use Tooltip, placing the cursor over the plot shows you the function being plotted.

Clear [ p ] Image

p [ x _ , 0 ] = a [ x , 0 ] ; Image

p[x_,n_]:=p[x,n]=p[x,n1]+a[x,n]Image

p [ x , 2 ] Image

x x 3 6 + x 5 120 Image

p1 = Plot [ Tooltip [ { Sin [ x ] , p [ x , 1 ] , p [ x , 5 ] } ] , { x , 2 Pi , 2 Pi } , Image

PlotStyle { { CMYKColor [ 1 , . 7 , . 07 , . 45 ] } , { CMYKColor [ 0 , . 63 , 1 , 0 ] } , Image

{ CMYKColor [ . 96 , . 09 , . 32 , . 29 ] } } , Image

PlotRange { Pi , Pi } , AspectRatio Automatic ] Image

We use Manipulate to investigate how n affects the situation with (see Fig. 3.55)

Image
Figure 3.55 Using Manipulate to investigate the situation.

p2 = Manipulate [ Plot [ Tooltip [ { Sin [ x ] , p [ x , n ] } ] , Image

{ x , 2 Pi , 2 Pi } , Image

PlotStyle { { CMYKColor [ 1 , . 7 , . 07 , . 45 ] } , { CMYKColor [ 0 , . 63 , 1 , 0 ] } } , Image

PlotRange { 2 Pi , 2 Pi } , AspectRatio Automatic ] , { { n , 5 } , 1 , 25 , 1 } ] Image

(b) As in (a), we test for absolute convergence first using the Ratio Test:

lim k | ( k + 1 ) k ! 1000 k + 1 ( x 1 ) k + 1 k ! 1000 k ( x 1 ) k | = 1 1000 ( k + 1 ) | x 1 | = { 0 , if  x = 1 , if  x 1 .

a [ x _ , k _ ] = k ! / 1000 k ( x 1 ) k ; Image

s1 = FullSimplify [ a [ x , k + 1 ] / a [ x , k ] ] Image

Limit[s1,kInfinity]Image

( 1 + k ) ( 1 + x ) 1000 Image

( 1 + x ) Image

Be careful of your interpretation of the result of the Limit command because Mathematica does not consider the case x=1Image separately: if x=1Image the limit is 0. Because 0<1Image the series converges by the Ratio Test.

The series converges only if x=1Image; the interval of convergence is {1}. You should observe that if you graph several partial sums for “small” values of n, you might incorrectly conclude that the series converges. (c) Use the Ratio Test to check absolute convergence first:

lim k | 2 k + 1 k + 1 ( x 4 ) k + 1 2 k k ( x 4 ) k | = lim k 2 k k + 1 | x 4 | = 2 | x 4 | .

By the Ratio Test, the series converges absolutely if 2|x4|<1Image. We solve this inequality for x with Reduce to see that 2|x4|<1Image if 7/2<x<9/2Image.

Clear [ a , s1 , k ] Image

a [ x _ , k _ ] = 2 k / Sqrt [ k ] ( x 4 ) k ; Image

s1 = Simplify [ Abs [ a [ x , k + 1 ] / a [ x , k ] ] ] Image

Limit [ s1 , k Infinity ] Image

2 Abs [ k 1 + k ( 4 + x ) ] Image

2 Abs [ 4 + x ] Image

Use Reduce to solve the inequality.

Reduce [ 2 Abs [ x 4 ] < 1 , x ] Image

7 2 < Re [ x ] < 9 2 & & 1 2 63 + 32 Re [ x ] 4 Re [ x ] 2 < Im [ x ] Image

< 1 2 63 + 32 Re [ x ] 4 Re [ x ] 2 Image

From the output, we see that for real values of x, the inequality is satisfied for 7/2<x<9/2Image. We check x=7/2Image and x=9/2Image separately. If x=7/2Image, the series becomes k=1(1)k1kImage, which converges conditionally.

Simplify [ a [ x , k ] /. x 7 / 2 ] Image

( 1 ) k k Image

On the other hand, if x=9/2Image,

Simplify [ a [ x , k ] /. x 9 / 2 ] Image

1 k Image

the series is k=11kImage, which diverges. We conclude that the interval of convergence is [7/2,9/2)Image. □

3.4.6 Taylor and Maclaurin Series

Let y=f(x)Image be a function with derivatives of all orders at x=x0Image. The Taylor series for f(x)Image about x=x0Image is

k = 0 f ( k ) ( x 0 ) k ! ( x x 0 ) k .

The Maclaurin series for f(x)Image is the Taylor series for f(x)Image about x=0Image. If y=f(x)Image has derivatives up to at least order n at x=x0Image, the nth degree Taylor polynomial for f(x)Image about x=x0Image is

p n ( x ) = k = 0 n f ( k ) ( x 0 ) k ! ( x x 0 ) k .

The nth degree Maclaurin polynomial for f(x)Image is the nth degree Taylor polynomial for f(x)Image about x=0Image. Generally, finding Taylor and Maclaurin series using the definition is a tedious task at best.

Example 3.54

Find the first few terms of (a) the Maclaurin series and (b) the Taylor series about x=π/4Image for f(x)=tanxImage.

Solution

(a) After defining f(x)=tanxImage, we use Table together with /. and D to compute f(k)(0)/k!Image for k=0Image, 1, …, 8.

Use Short to obtain an abbreviated result. Many terms will be missing, but with Short, you will see the beginning and end of your result.

Clear [ f ] Image

f [ x _ ] = Tan [ x ] ; Image

t1 = Table [ { k , D [ f [ x ] , { x , k } ] , D [ f [ x ] , { x , k } ] /. x 0 } , { k , 0 , 8 } ] ; Image

Short [ t1 ] Image

{ { 0 , Tan [ x ] , 0 } , 7 , { 8 , 7936 Sec [ x ] 8 Tan [ x ] + 24576 1 6 1 3 + 1 + 128 Sec [ x ] 2 Image

Tan [ x ] 7 , 0 } } Image

To see these results in tabular form, enter

t1 // TableForm Image

For length considerations, the resulting output is not shown here. Another way of approaching the problem is to use Manipulate. See Fig. 3.56.

Image
Figure 3.56 With Manipulate, we can adjust the function and function values.

Manipulate [ { k , D [ f [ x ] , { x , k } ] // FullSimplify , D [ f [ x ] , { x , k } ] /. x 0 , Image

D [ f [ x ] , { x , k } ] /. x 0 // N } , { { k , 5 } , 0 , 25 , 1 } ] Image

Using the values in the table or from the Manipulate object, we apply the definition to see that the Maclaurin series is

k = 0 f ( k ) ( 0 ) k ! x k = x + 1 3 x 3 + 2 15 x 5 + 17 315 x 7 +

For (b), we repeat (a) using x=π/4Image instead of x=0Image

Manipulate [ { k , D [ f [ x ] , { x , k } ] // FullSimplify , D [ f [ x ] , { x , k } ] /. x Pi / 4 , Image

D [ f [ x ] , { x , k } ] /. x Pi / 4 // N } , { { k , 1 } , 0 , 25 , 1 } ] Image

and then apply the definition to see that the Taylor series about x=π/4Image is

k = 0 f ( k ) ( x 0 ) k ! ( x x 0 ) k = 1 + 2 ( x π 4 ) + 2 ( x π 4 ) 2 + 8 3 ( x π 4 ) 3 + 10 3 ( x π 4 ) 4 + 64 15 ( x π 4 ) 5 + 244 45 ( x π 4 ) 6 +

From the series, we can see various Taylor and Maclaurin polynomials. For example, the third Maclaurin polynomial is

p 3 ( x ) = x + 1 3 x 3

and the 4th degree Taylor polynomial about x=π/4Image is

p 4 ( x ) = 1 + 2 ( x π 4 ) + 2 ( x π 4 ) 2 + 8 3 ( x π 4 ) 3 + 10 3 ( x π 4 ) 4 .

See Fig. 3.57. □

Image
Figure 3.57 We use Manipulate to investigate series for the tangent function.

The command Series[f[x],{x,x0,n}] computes (3.29) to (at least) order n1Image. Because of the O-term in the result that represents the terms that are omitted from the power series for f(x)Image expanded about the point x=x0Image, the result of entering a Series command is not a function that can be evaluated if x is a particular number. We remove the remainder (O-) term of the power series Series[f[x],{x,x0,n}] with the command Normal and can then evaluate the resulting polynomial for particular values of x.

Example 3.55

Find the first few terms of the Taylor series for f(x)Image about x=x0Image. (a) f(x)=cosxImage, x=0Image; (b) f(x)=1/x2Image, x=1Image.

Solution

Entering

Series [ Cos [ x ] , { x , 0 , 4 } ] Image

1 x 2 2 + x 4 24 + O [ x ] 5 Image

computes the Maclaurin series to order 4. Entering

Series [ Cos [ x ] , { x , 0 , 14 } ] Image

1 x 2 2 + x 4 24 x 6 720 + x 8 40320 x 10 3628800 + x 12 479001600 x 14 87178291200 + O [ x ] 15 Image

computes the Maclaurin series to order 14. In this case, the Maclaurin series for cosxImage converges to cosxImage for all real x. To graphically see this, we define the function p. Given n, p[n] returns the Maclaurin polynomial of degree n for cosxImage.

p [ n _ ] := Series [ Cos [ x ] , { x , 0 , n } ] // Normal Image

p [ 3 ] Image

1 x 2 2 Image

We then graph cosxImage together with the Maclaurin polynomial of degree n=2Image, 4, 8, and 16 on the interval [3π/2,3π/2]Image in Fig. 3.58. Notice that as n increases, the graph of the Maclaurin polynomial more closely resembles the graph of cosxImage. We would see the same pattern if we increased the length of the interval and the value of n.

Image
Figure 3.58 Using Manipulate to investigate graphs of y=cosxImage together with plots of several of its Maclaurin polynomials (University of Pennsylvania colors).

Manipulate [ Plot [ Evaluate [ Tooltip [ { Cos [ x ] , p [ n ] } ] ] , { x , 3 Pi / 2 , 3 Pi / 2 } , Image

PlotStyle { { CMYKColor [ 0 , 1 , . 65 , . 34 ] } , { CMYKColor [ 1 , . 65 , 0 , . 3 ] } } , Image

PlotRange { { 3 Pi / 2 , 3 Pi / 2 } , { 3 Pi / 2 , 3 Pi / 2 } } , AspectRatio Automatic ] , Image

{ { n , 4 } , { 2 , 4 , 8 , 16 , 32 , 64 } , ControlType Setter } ] Image

(b) After defining f(x)=1/x2Image, we compute the first 10 terms of the Taylor series for f(x)Image about x=1Image with Series.

f [ x _ ] = 1 / x 2 ; Image

p10 = Series [ f [ x ] , { x , 1 , 10 } ] Image

12(x1)+3(x1)24(x1)3+5(x1)46(x1)5+7(x1)68(x1)7+9(x1)810(x1)9+11(x1)10+O[x1]11Image

In this case, the pattern for the series is relatively easy to see: the Taylor series for f(x)Image about x=1Image is

k = 0 ( 1 ) k ( k + 1 ) ( x 1 ) k .

This series converges absolutely if

lim k | ( 1 ) k + 1 ( k + 2 ) ( x 1 ) k + 1 ( 1 ) k ( k + 1 ) ( x 1 ) k | = | x 1 | < 1

or 0<x<2Image. The series diverges if x=0Image and x=2Image. In this case, the series converges to f(x)Image on the interval (0,2)Image.

a [ x _ , k _ ] = ( 1 ) k ( k + 1 ) ( x 1 ) k ; Image

s1 = FullSimplify [ Abs [ a [ x , k + 1 ] / a [ x , k ] ] ] Image

Abs [ ( 2 + k ) ( 1 + x ) 1 + k ] Image

s2 = Limit [ s1 , k Infinity ] Image

Abs [ 1 + x ] Image

Reduce [ s2 < 1 , x ] Image

0 < Re [ x ] < 2 & & 2 Re [ x ] Re [ x ] 2 < Im [ x ] < 2 Re [ x ] Re [ x ] 2 Image

To see this, we use Manipulate to graph f(x)Image together with the Taylor polynomial for f(x)Image about x=1Image of degree n for large n. Regardless of the size of n, the graphs of f(x)Image and the Taylor polynomial closely resemble each other on the interval (0,2)Image – but not at the endpoints or outside the interval. (See Fig. 3.59.)

Image
Figure 3.59 Graphs of f(x) together with the various Taylor polynomials about x = 1.

p [ n _ ] := Series [ f [ x ] , { x , 1 , n } ] // Normal Image

Manipulate [ Plot [ Evaluate [ Tooltip [ { f [ x ] , p [ n ] } ] ] , Image

{ x , 0 , 3 } , PlotStyle { { CMYKColor [ 0 , 1 , . 65 , . 34 ] } , { CMYKColor [ 1 , . 65 , 0 , . 3 ] } } , Image

PlotRange { { 0 , 3 } , { 3 / 2 , 3 / 2 } } , AspectRatio Automatic ] , Image

{{n,10},{5,10,15,25,30,35,40,45,50,55,60},ControlTypeSetter}]Image □

3.4.7 Taylor's Theorem

Taylor's theorem states the relationship between f(x)Image and the Taylor series for f(x)Image about x=x0Image.

Solution

Let f(x)=sinxImage. Then, for each value of x, there is a number z between 0 and x so that sinx=pn(x)+Rn(x)Image where pn(x)=k=0nf(k)(0)k!xkImage and Rn(x)=f(n+1)(z)(n+1)!xn+1Image. Regardless of the value of n, f(n+1)(z)Image is one of sinzImage, sinzImage, coszImage, or coszImage, which are all bounded by 1. Then,

| sin x p n ( x ) | = | f ( n + 1 ) ( z ) ( n + 1 ) ! x n + 1 | | sin x p n ( x ) | 1 ( n + 1 ) ! | x | n + 1

and xn/n!0Image as nImage for all real values of x.

You should remember that the number z in Rn(x)Image is guaranteed to exist by Taylor's theorem. However, from a practical point of view, you would rarely (if ever) need to compute the z value for a particular x value.

For illustrative purposes, we show the difficulties. Suppose we wish to approximate sinπ/180Image using the Maclaurin polynomial of degree 4, p4(x)=x16x3Image, for sinxImage. The fourth remainder is R4(x)=1120coszx5Image.

The Maclaurin polynomial of degree 4 for sinxImage is k=04f(k)(0)k!x4=Image 0+x+0x2+13!x3+0x4Image.

Clear [ f ] Image

f [ x _ ] = Sin [ x ] ; Image

r5 = D [ f [ z ] , { z , 5 } ] / 5 ! x 5 Image

1 120 x 5 Cos [ z ] Image

If x=π/180Image there is a number z between 0 and π/180Image so that

| R 4 ( π 180 ) | = 1 120 cos z ( π 180 ) 5 1 120 ( π 180 ) 5 0.135 × 10 10 ,

which shows us that the maximum the error can be is 1120(π180)50.135×1010Image.

maxerror = N [ 1 / 120 ( Pi / 180 ) 5 ] Image

1.349601623163255 ` * 11 Image

Abstractly, the exact error can be computed. By Taylor's theorem, z satisfies

f ( π 180 ) = p 4 ( π 180 ) + R 4 ( π 180 ) sin π 180 = 1 180 π 1 34992000 π 3 + 1 22674816000000 π 5 cos z 0 = 1 180 π 1 34992000 π 3 + 1 22674816000000 π 5 cos z sin π 180 .

We graph the right-hand side of this equation with Plot in Fig. 3.60. The exact value of z is the z-coordinate of the point where the graph intersects the z-axis.

Image
Figure 3.60 Finding z (Observe that Mathematica's default color is similar to Columbia University's blue).

p4 = Series [ f [ x ] , { x , 0 , 4 } ] // Normal Image

x x 3 6 Image

exval = Sin [ Pi / 180 ] Image

p4b = p4 /. x Pi / 180 Image

r5b = r5 /. x Pi / 180 Image

Sin [ π 180 ] Image

π 180 π 3 34992000 Image

π 5 Cos [ z ] 22674816000000 Image

toplot = r5b + p4b exval ; Image

Plot [ toplot , { z , 0 , Pi / 180 } ] Image

We can use FindRoot to approximate z, if we increase the number of digits carried in floating point calculations with WorkingPrecision.

exz = FindRoot [ toplot = = 0 , { z , 0 , . 004 } , WorkingPrecision 32 ] Image

{ z 0.0038086149165541606417429516417308 } Image

Alternatively, we can compute the exact value of z with Solve

cz = Solve [ toplot = = 0 , z ] Image

{ { z ConditionalExpression [ ArcCos [ 648000 ( 194400 π + π 3 + 34992000 Sin [ π 180 ] ) π 5 ] + 2 π C [ 1 ] , Image

C[1]Integers]},{zConditionalExpression[ArcCos[648000(194400π+π3+34992000Sin[π180])π5]Image

+ 2 π C [ 1 ] , C [ 1 ] Integers ] } } Image

and then approximate the result with N.

N [ cz ] Image

{ { z ConditionalExpression [ 0.00384232 + 6.28319 C [ 1 ] , C [ 1 ] Integers ] } , Image

{zConditionalExpression[0.00384232+6.28319C[1],C[1]Integers]}}Image □

Example 3.57

Newton's Approximation of π.

Newton's Approximation of π is a fascinating combination of calculus, infinite series, and geometry. Newton began the approximation after proving the Binomial Theorem.

Theorem 3.17

Binomial Theorem

We use Series to find the first few terms of the Binomial series.

Series [ ( 1 + x ) r , { x , 0 , 5 } ] Image

1 + r x + 1 2 ( 1 + r ) r x 2 + 1 6 ( 2 + r ) ( 1 + r ) r x 3 + 1 24 ( 3 + r ) ( 2 + r ) ( 1 + r ) r x 4 + 1 120 ( 4 + r ) ( 3 + r ) ( 2 + r ) ( 1 + r ) r x 5 + O [ x ] 6 Image

Newton then used the Binomial series to find the first few terms of the series for 1x=(1x)1/2Image.

f [ x _ ] = Series [ Sqrt [ 1 x ] , { x , 0 , 20 } ] // Normal Image

1 x 2 x 2 8 x 3 16 5 x 4 128 7 x 5 256 21 x 6 1024 33 x 7 2048 429 x 8 32768 715 x 9 65536 2431 x 10 262144 4199 x 11 524288 29393 x 12 4194304 52003 x 13 8388608 185725 x 14 33554432 334305 x 15 67108864 9694845 x 16 2147483648 17678835 x 17 4294967296 64822395 x 18 17179869184 119409675 x 19 34359738368 883631595 x 20 274877906944 Image

In Fig. 3.61, observe that the series quickly converges to 1xImage if x is small. He used this observation to use the series to approximate 3Image by observing

3 = 4 3 4 = 2 1 1 4

and substituting x=1/4Image into the first few terms of the series.

Image
Figure 3.61 The Maclaurin series for 1xImage converges quickly to 1xImage when x is small (Virginia Polytechnic Institute & State University colors).

Plot [ { f [ x ] , Sqrt [ 1 x ] } , { x , 5 , 5 } , PlotRange { 5 , 5 } , AspectRatio 1 , Image

PlotStyle { { Thickness [ . 01 ] , CMYKColor [ . 4 , 1 , . 5 , . 15 , . 5 ] } , Image

{Thickness[.01],CMYKColor[0,.65,.9,0],Dashing[.02]}},AxesLabel{x,y}]Image

Next, Newton looked at the circle x2x+y2=(x1/2)2+y2=(1/2)2Image with center at (1/2,0)Image and radius 1/2. Refer to Fig. 3.62.

Image
Figure 3.62 Newton's circle. The area of the green region is 01/4xx2dxImage.

p1 = PolarPlot [ Cos [ r ] , { r , 0 , 2 Pi } , PlotStyle { Thickness [ . 01 ] , Image

CMYKColor [ . 4 , 1 , . 5 , . 15 ] } ] ; Image

p2 = Graphics [ { Thickness [ . 01 ] , CMYKColor [ 0 , . 65 , . 9 , 0 ] , Image

Line [ { { 1 / 2 , 0 } , { 1 / 4 , Sqrt [ 3 ] / 4 } } ] , Line [ { { 1 / 4 , 0 } , { 1 / 4 , Sqrt [ 3 ] / 4 } } ] , Image

CMYKColor [ 0 , . 18 , 1 , . 27 ] , Image

Line [ { { 1 / 4 , Sqrt [ 3 ] / 4 } , { 3 / 4 , Sqrt [ 3 ] / 4 } } ] , Image

Line [ { { 1 / 2 , 0 } , { 3 / 4 , Sqrt [ 3 ] / 4 } } ] } ] ; Image

p3 = Plot [ Sqrt [ x x 2 ] , { x , 0 , 1 / 4 } , Image

PlotStyle { Thickness [ . 01 ] , CMYKColor [ . 4 , 1 , . 5 , . 15 ] } , Image

Filling Bottom , FillingStyle CMYKColor [ . 43 , 0 , . 14 , . 21 ] ] ; Image

Show [ p1 , p2 , p3 , AxesLabel { x , y } , PlotLabel “Newton's Circle” ] Image

Newton understood that the area of a circle with radius r is πr2Image so it followed that the area of Newton's circle is π/4Image. Moreover, the area of the sector formed by the green region and the orange triangle is 1/6th the area of the circle so the area of the sector is Asector=π/24Image. The orange triangle has width 1/4 and height 3/4Image so the orange triangle has area

A t r i a n g l e = 1 2 1 4 3 4 = 3 32 .

Because the top half of the circle is given by y=xx2Image, the area of the green region, R, is AR=01/4xx2dxImage. Newton then added and solved for π.

A s e c t o r = A R + A t r i a n g l e π 24 = 0 1 / 4 x x 2 d x + 1 32 3 π = 24 ( 0 1 / 4 x x 2 d x + 1 32 3 ) .

Newton already had an excellent approximation of 3Image as described above. Thus, to obtain an excellent approximation of π he needed only to find an excellent approximation of 01/4xx2dxImage. To obtain it, he started with his power series for 1xImage and then observed that for 0x1Image, xx2=xx1=x1/2(1x)1/2Image. With that in mind, he decided to take his power series for 1xImage and multiply it by x1/2Image to obtain a series that he predicted would converge to xx2Image. Newton was right and it worked!

p1 = Series [ Sqrt [ x x 2 ] , { x , 0 , 9 } ] // Normal Image

x x 3 / 2 2 x 5 / 2 8 x 7 / 2 16 5 x 9 / 2 128 7 x 11 / 2 256 21 x 13 / 2 1024 33 x 15 / 2 2048 429 x 17 / 2 32768 Image

He then integrated his series (which was no longer a power series) term-by-term

Integrate [ p1 , x ] // Simplify Image

2 x 3 / 2 3 x 5 / 2 5 x 7 / 2 28 x 9 / 2 72 5 x 11 / 2 704 7 x 13 / 2 1664 7 x 15 / 2 2560 33 x 17 / 2 17408 429 x 19 / 2 311296 Image

and evaluated it if x=1/4Image to obtain his approximation of 01/4xx2dxImage.

There is no need to show the evaluation of the series if x=0Image because the value of the series if x=0Image is 0.

Integrate [ Series [ Sqrt [ x x 2 ] , { x , 0 , 9 } ] // Normal , x ] /. x 1 / 4 Image

1919013728784979 24995910798802944 Image

We use N to obtain a numerical result.

Integrate [ Series [ Sqrt [ x x 2 ] , { x , 0 , 9 } ] // Normal , x ] /. x 1 / 4 // N Image

0.0767731

We use Table to illustrate the steps Newton carried out by hand. In the first column, k, in the second column, the kth term of the series for xx2Image centered at x=0Image, in the third column, an antiderivative of the kth term of the series for xx2Image centered at x=0Image, and in the fourth column, the value of the antiderivative of the kth term of the series for xx2Image centered at x=0Image evaluated at x=1/4Image.

Table [ { k , f [ k ] , x ( 1 / 2 ) f [ k ] , Integrate [ x ( 1 / 2 ) f [ k ] , x ] , Image

Integrate [ x ( 1 / 2 ) f [ k ] , x ] /. x 1 / 4 } , { k , 0 , 9 } ] // TableForm Image

0 1 x 2 x 3 / 2 3 1 12 1 x 2 x 3 / 2 2 x 5 / 2 5 1 160 2 x 2 8 x 5 / 2 8 x 7 / 2 28 1 3584 3 x 3 16 x 7 / 2 16 x 9 / 2 72 1 36864 4 5 x 4 128 5 x 9 / 2 128 5 x 11 / 2 704 5 1441792 5 7 x 5 256 7 x 11 / 2 256 7 x 13 / 2 1664 7 13631488 6 21 x 6 1024 21 x 13 / 2 1024 7 x 15 / 2 2560 7 83886080 7 33 x 7 2048 33 x 15 / 2 2048 33 x 17 / 2 17408 33 2281701376 8 429 x 8 32768 429 x 17 / 2 32768 429 x 19 / 2 311296 429 163208757248 9 715 x 9 65536 715 x 19 / 2 65536 715 x 21 / 2 688128 715 1443109011456 Image

Thus, Newton's approximation of π, π=24(01/4xx2dx+1323)Image using his approximations of 01/4xx2dxImage was given by

24 ( Sqrt [ 3 ] / 32 + Integrate [ Series [ Sqrt [ x x 2 ] , { x , 0 , 9 } ] // Normal , x ] /. x 1 / 4 ) Image

24 ( 1919013728784979 24995910798802944 + 3 32 ) Image

We use N to approximate 3Image.

N [ 24 ( Sqrt [ 3 ] / 32 + Integrate [ Series [ Sqrt [ x x 2 ] , { x , 0 , 9 } ] // Normal , x ] /. x 1 / 4 ) , Image

20 ] Image

3.1415926683631729578

When we compare Newton's approximation of π to our present day approximation of π, it is truly remarkable that Newton's approximation was accurate to seven decimal places (to the right of the decimal point).

N [ Pi , 20 ] Image

3.1415926535897932385

There are volumes of literature about the history of π, its applications, and how to efficiently and accurately approximate π (as well as other irrational and transcendental numbers).

Example 3.58

Determine whether the following series converge or diverge: (a) k=0116k(48k+128k+418k+518k+6)Image; (b) k=02k(k!)2(2k+1)!Image; (c) 229801k=0(4k)!(1103+26390k)(k!)43964kImage; (d) 12k=0(1)k(6k)!(135910409+545140134k)(3k)!(k!)36403203k+3/2Image.

Solution

To determine whether each series converges or diverges, we use the Ratio Test. For (a), we see that limk|ak+1ak|=116Image. Because 1/16<1Image, the series converges (absolutely).

a [ k _ ] = 1 / 16 k ( 4 / ( 8 k + 1 ) 2 / ( 8 k + 4 ) 1 / ( 8 k + 5 ) 1 / ( 8 k + 6 ) ) Image

16 k ( 4 1 + 8 k 2 4 + 8 k 1 5 + 8 k 1 6 + 8 k ) Image

s1 = FullSimplify [ a [ k + 1 ] / a [ k ] ] Image

( 1 + 2 k ) ( 3 + 4 k ) ( 1 + 8 k ) ( 5 + 8 k ) ( 318 + k ( 391 + 120 k ) ) 16 ( 3 + 2 k ) ( 7 + 4 k ) ( 9 + 8 k ) ( 13 + 8 k ) ( 47 + k ( 151 + 120 k ) ) Image

Limit [ s1 , k Infinity ] Image

1 16 Image

In fact, in 1997, David Bailey, Peter Borwein, and Simon Plouffe (BBP) proved that

π = k = 0 1 16 k ( 4 8 k + 1 2 8 k + 4 1 8 k + 5 1 8 k + 6 ) .

Notice that the second partial sum is accurate to three decimal places,

N[Sum[a[k],{k,0,1}],10]Image

3.141422466

and the seventh partial sum is accurate to ten decimal places.

N [ Sum [ a [ k ] , { k , 0 , 6 } ] , 15 ] Image

3.14159265357288

N [ Pi , 15 ] Image

3.14159265358979

Interestingly, in 2013, Fabrice Bellard improved on the BBP equation and proved that

π = 1 2 6 k = 0 ( 1 ) k 2 10 k ( 2 5 4 k + 1 1 4 k + 3 + 2 8 10 k + 1 2 6 10 k + 3 2 2 10 k + 5 2 2 10 k + 7 + 1 10 k + 9 ) .

(b) Using the Ratio Test, we see that the series converges because the limit of the ratio of successive terms is 1/2<1Image: limk|ak+1ak|=12Image.

a [ k _ ] = 2 k ( k ! ) 2 / ( 2 k + 1 ) ! Image

2 k ( k ! ) 2 ( 1 + 2 k ) ! Image

s1 = FullSimplify [ a [ k + 1 ] / a [ k ] ] Image

1 + k 3 + 2 k Image

Limit [ s1 , k Infinity ] Image

1 2 Image

Newton proved that this series converges to π/2Image:

π 2 = k = 0 2 k ( k ! ) 2 ( 2 k + 1 ) ! .

Observe that the “patterns” of the terms of this series are much easier to see than in the example illustrating Newton's approximation of π using integral calculus, infinite series, and Euclidean geometry. You can use the 31st partial sum of this series to approximate π/2Image to 10 decimal places.

N [ Sum [ a [ k ] , { k , 0 , 30 } ] , 10 ] Image

1.570796327

N [ Pi / 2 , 10 ] Image

1.570796327

(c) Using the Ratio Test, we see that

a [ k _ ] = 2 Sqrt [ 2 ] / 9801 ( 4 k ) ! ( 1103 + 26390 k ) / ( ( k ! ) 4396 ( 4 k ) ) Image

2 3 2 8 k 99 2 4 k ( 1103 + 26390 k ) ( 4 k ) ! ( k ! ) 4 Image

p1 = FullSimplify [ a [ k + 1 ] / a [ k ] ] Image

( 1 + 2 k ) ( 1 + 4 k ) ( 3 + 4 k ) ( 27493 + 26390 k ) 3073907232 ( 1 + k ) 3 ( 1103 + 26390 k ) Image

Limit [ p1 , k Infinity ] Image

1 96059601 Image

limk|ak+1ak|=196059601<1Image so the series converges absolutely. This series that was introduced by Srinivasa Ramanujan around 1910 converges to 1/πImage:

1 π = 2 2 9801 k = 0 ( 4 k ) ! ( 1103 + 26390 k ) ( k ! ) 4 396 4 k .

As with the other series in this example, the convergence is quick.

N [ Sum [ a [ k ] , { k , 0 , 2 } ] , 24 ] Image

0.318309886183790671537767

N [ 1 / Pi , 24 ] Image

0.318309886183790671537768

With just the third partial sum of the series, we see that it approximates 1/πImage to 23 decimal places.

(d) Using the Ratio Test, we see that the series converges. This formulation of π was introduced by brothers David Chudnosky and Gregory Chudnosky in 1989:

1 π = 12 k = 0 ( 1 ) k ( 6 k ) ! ( 135910409 + 545140134 k ) ( 3 k ) ! ( k ! ) 3 640320 3 k + 3 / 2 .

a [ k _ ] = 12 ( 1 ) k ( 6 k ) ! ( 13591409 + 545140134 k ) / ( ( 3 k ) ! ( k ! ) 3640320 ( 3 k + 3 / 2 ) ) Image

( 1 ) k 3 1 2 3 k 4 7 2 9 k 3335 3 2 3 k ( 13591409 + 545140134 k ) ( 6 k ) ! ( k ! ) 3 ( 3 k ) ! Image

p1 = Abs [ FullSimplify [ a [ k + 1 ] / a [ k ] ] ] Image

Abs [ ( 1 + 2 k ) ( 1 + 6 k ) ( 5 + 6 k ) ( 558731543 + 545140134 k ) ( 1 + k ) 3 ( 13591409 + 545140134 k ) ] 10939058860032000 Image

Limit[p1,kInfinity]Image

1 151931373056000 Image

The series converges very quickly. Using the third partial sum, we see that it yields an approximation of 1/πImage accurate to 42 decimal places.

N [ Sum [ a [ k ] , { k , 0 , 2 } ] , 42 ] Image

0.318309886183790671537767526745028724068919

N [ 1 / Pi , 42 ] Image

0.318309886183790671537767526745028724068919

To use the Chudnosky's series to approximate π, we first rewrite it as

1 π = 1 42680 10005 k = 0 ( 1 ) k ( 6 k ) ! ( 13591409 + 545140134 k ) ( 3 k ) ! ( k ! ) 3 640320 3 k .

Now let A=k=0ak=k=0(1)k(6k)!(3k)!(k!)36403203kImage and B=k=0bk=k=0(1)k(6k)!k(3k)!(k!)36403203kImage. Then (3.33) becomes

1 π = 1351409 A + 545140134 B 42680 10005

and reciprocating gives us

π = 42680 10005 1351409 A + 545140134 B .

Observe that ak=(1)k(6k)!(3k)!(k!)36403203kImage, bk=kakImage, and

a k a k 1 = ( 6 k 1 ) ( 6 k 5 ) ( 2 k 1 ) 10939058860032000 k 2 a k = ( 6 k 1 ) ( 6 k 5 ) ( 2 k 1 ) 10939058860032000 k 2 a k 1 .

Then, if we let An=k=0nakImage,

A n = k = 0 n 1 a k ( 6 n 1 ) ( 6 n 5 ) ( 2 n 1 ) 10939058860032000 ( n 1 ) n 2 a n 1 = A n 1 ( 6 n 1 ) ( 6 n 5 ) ( 2 n 1 ) 10939058860032000 ( n 1 ) n 2 a n 1

and if we let Bn=k=0nbkImage, Bn=k=0nkak=k=0n1kak+nan=Bn1+nanImage. Then, we approximate π with π=42680100051351409An+545140134BnImage.

Remove [ a , b , pi , capa , capb ] Image

a [ 0 ] = 1 ; Image

a [ n _ ] := a [ n ] = N [ ( 1 + 2 n ) ( 5 + 6 n ) ( 1 + 6 n ) 10939058860032000 n 3 a [ n 1 ] , 250 ] ; Image

b[n_]:=b[n]=na[n]Image

capa [ 0 ] = a [ 0 ] ; Image

capb [ 0 ] = b [ 0 ] ; Image

capa [ n _ ] := capa [ n ] = capa [ n 1 ] + a [ n ] Image

capb [ n _ ] := capb [ n ] = capb [ n 1 ] + b [ n ] Image

pi [ n _ ] := N [ 426880 Sqrt [ 10005 ] / ( 13591409 capa [ n ] + 545140134 capb [ n ] ) , 250 ] Image

We illustrate the quick convergence using A10Image and B10Image. Observe that the approximation gives us an approximation of π accurate to at least 155 digits.

N [ pi [ 10 ] , 155 ] Image

3.1415926535897932384626433832795028841971693993751058209749 445923078164062862089986280348253421170679821480865132823066 470938446095505822317253594081284811 Image

N [ Pi , 155 ] Image

3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811Image □

Closely related to these series is the Madhava–Leibniz series, π=12k=0(1)k2k+13kImage. It is a good exercise to verify that the first 21 terms of the Madhava–Leibniz series compute an approximation of π accurate to eleven decimal places.

3.4.8 Other Series

In calculus, we learn that the power series f(x)=k=0ak(xx0)kImage is differentiable and integrable on its interval of convergence. However, for series that are not power series this result is not generally true. For example, in more advanced courses, we learn that the function

f ( x ) = k = 0 1 2 k sin ( 3 k x )

is continuous for all values of x but nowhere differentiable. We can use Mathematica to help us see why this function is not differentiable. Let

f n ( x ) = k = 0 n 1 2 k sin ( 3 k x ) .

Notice that fn(x)Image is defined recursively by f0(x)=sinxImage and fn(x)=fn1(x)+12nsin(3nx)Image. We use Mathematica to recursively define fn(x)Image.

Clear [ f ] Image

f [ 0 ] = Sin [ x ] ; Image

f[k_]:=f[k]=f[k1]+Sin[3kx]2kImage

We define fn(x)Image using the form

f[n_]:=f[n]=...

so that Mathematica “remembers” the values it computes. Thus, to compute f[5], Mathematica uses the previously computed values, namely f[4], to compute f[5]. Note that we can produce the same results by defining fn(x)Image with the command

f[n_]:=...

However, the disadvantage of defining fn(x)Image in this manner is that Mathematica does not “remember” the previously computed values and thus takes longer (and uses more memory) to compute fn(x)Image for larger values of n.

Next, we use Table to generate f3(x)Image, f6(x)Image, f9(x)Image, and f12(x)Image.

tograph = Table [ f [ n ] , { n , 3 , 12 , 3 } ] Image

We now graph each of these functions and show the results as a graphics array with GraphicsGrid in Fig. 3.63. (Note that you do not need to include the option DisplayFunction->Identity to suppress the resulting output unless you forget to include the semi-colon at the end of the command.)

Image
Figure 3.63 Approximating a function that is continuous everywhere but nowhere differentiable (Duke University colors).

graphs = Table [ Plot [ Evaluate [ tograph [ [ i ] ] ] , { x , 0 , 3 π } , Image

PlotStyle CMYKColor [ 1 , . 75 , . 06 , . 24 ] ] , { i , 1 , 4 } ] ; Image

toshow = Partition [ graphs , 2 ] ; Image

Show [ GraphicsGrid [ toshow ] ] Image

From these graphs, we see that for large values of n, the graph of fn(x)Image, although actually smooth, appears “jagged” and thus we might suspect that f(x)=limnImage fn(x)=k=012ksin(3kx)Image is indeed continuous everywhere but nowhere differentiable.

3.5 Multi-Variable Calculus

Mathematica is useful in investigating functions involving more than one variable. In particular, the graphical analysis of functions that depend on two (or more) variables is enhanced with the help of Mathematica's graphics capabilities.

3.5.1 Limits of Functions of Two Variables

Mathematica's graphics and numerical capabilities are helpful in investigating limits of functions of two variables.

Example 3.59

Show that the limit lim(x,y)(0,0)x2y2x2+y2Image does not exist.

Solution

We begin by defining f(x,y)=(x2y2)/(x2+y2)Image. Next, we use Plot3D to graph z=f(x,y)Image for 1/2x1/2Image and 1/2y1/2Image. ContourPlot is used to graph several level curves on the same rectangle. (See Fig. 3.64.) (To define a function of two variables, f(x,y)=expressioninxandyImage, enter f[x_,y_]=expression in x and y. Plot3D[f[x,y],{a,x,b},{y,c,d}] generates a basic graph of z=f(x,y)Image for axbImage and cydImage)

Image
Figure 3.64 (a) Three-dimensional and (b) contour plots of f(x,y) (North Carolina State University colors).

Clear [ f ] Image

f [ x _ , y _ ] = ( x 2 y 2 ) / ( x 2 + y 2 ) ; Image

p1 = Plot3D [ f [ x , y ] , { x , 2 , 2 } , { y , 2 , 2 } , PlotPoints 40 , Image

PlotStyle { Opacity [ . 8 ] , CMYKColor [ 0 , 1 , . 81 , . 04 ] } , Image

MeshFunctions { # 3 & } , MeshStyle { Black , Thickness [ . 005 ] } ] ; Image

c1 = ContourPlot [ f [ x , y ] , { x , 2 , 2 } , { y , 2 , 2 } , ContourShading False , Image

Axes Automatic , AxesOrigin { 0 , 0 } , PlotPoints 60 , Contours 20 , Image

ContourStyle CMYKColor [ 0 , 1 , . 81 , . 04 ] , Frame False , Image

AxesLabel { x , y } ] ; Image

Show [ GraphicsRow [ { p1 , c1 } ] ] Image

From the graph of the level curves, we suspect that the limit does not exist because we see that near (0,0)Image, z=f(x,y)Image attains many different values. We obtain further evidence that the limit does not exist by computing the value of z=f(x,y)Image for various points chosen randomly near (0,0)Image. We use Table and RandomReal to generate 10 ordered pairs (x,y)Image for x and y “close to” 0. Because RandomReal is included in the calculation, your results will almost certainly be different from those here.

When you slide the cursor over the contours in the contour plot, the contour values are displayed.

pts = Table [ RandomReal [ { 10 i , 10 i } ] , { i , 1 , 10 } , { 2 } ] Image

{ { 0.0240696 , 0.0964425 } , { 0.00929171 , 0.00582256 } , { 0.000875533 , 0.000861975 } , { 4.93995041959814 ` * 6 , 0.0000585256 } , { 5.7785374509223095 ` * 6 , 6.7869167280744185 ` * 6 } , { 6.964772344758519 ` * 7 , 9.809015465572932 ` * 8 } , { 1.669922073323435 ` * 8 , 7.416883164217774 ` * 8 } , { 4.256718340841544 ` * 9 , 2.2211732111688833 ` * 10 } , { 4.8322758801790404 ` * 11 , 4.063639702523537 ` * 10 } , { 2.96738846034934 ` * 11 , 9.412273092884795 ` * 11 } } Image

Next, we define a function g that given an ordered pair (x,y)Image ({x,y} in Mathematica), g((x,y))Image returns the ordered triple (x,y,f(x,y))Image ({x,y,f[x,y]} in Mathematica).

g [ { x _ , y _ } ] = { x , y , f [ x , y ] } Image

{ x , y , x 2 y 2 x 2 + y 2 } Image

We then use Map to apply g to the list pts.

Map [ g , pts ] // TableForm Image

0.02406960.09644250.8827290.009291710.005822560.4360830.0008755330.0008619750.01560524.93995041959814`*60.00005852560.9858525.7785374509223095`*66.7869167280744185`*60.1594736.964772344758519`*79.809015465572932`*80.9611011.669922073323435`*87.416883164217774`*80.9035054.256718340841544`*92.2211732111688833`*100.9945694.8322758801790404`*114.063639702523537`*100.9721132.96738846034934`*119.412273092884795`*110.819184Image

From the third column, we see that z=f(x,y)Image does not appear to approach any particular value for points chosen randomly near (0,0)Image. In fact, along the line y=mxImage we see that f(x,y)=f(x,mx)=(1m2)/(1+m2)Image. Hence as (x,y)(0,0)Image along y=mxImage, f(x,y)=f(x,mx)1m21+m2Image. Thus, f(x,y)Image does not have a limit as (x,y)(0,0)Image.

We choose lines of the form y=mxImage because near (0,0)Image the level curves of z=f(x,y)Image look like lines of the form y=mxImage.

v1 = Simplify [ f [ x , m x ] ] Image

1 m 2 1 + m 2 Image

v1 /. m 0 Image

v1 /. m 1 Image

v1 /. m 1 / 2 Image

1

0

35Image □

In some cases, you can establish that a limit does not exist by converting to polar coordinates. For example, in polar coordinates, f(x,y)=x2y2x2+y2Image becomes f(rcosθ,rsinθ)=2cos2θ1Image

Simplify [ f [ r Cos [ t ] , r Sin [ t ] ] ] Image

Cos [ 2 t ] Image

and

lim ( x , y ) ( 0 , 0 ) f ( x , y ) = lim r 0 f ( r cos θ , r sin θ ) = lim r 0 2 cos 2 θ 1 = 2 cos 2 θ 1 = cos 2 θ

depends on θ.

3.5.2 Partial and Directional Derivatives

Partial derivatives of functions of two or more variables are computed with Mathematica using D. For z=f(x,y)Image,

1.  D[f[x,y],x] computes fx=fx(x,y)Image,

2.  D[f[x,y],y] computes fy=fy(x,y)Image,

3.  D[f[x,y],{x,n}] computes nfxnImage,

4.  D[f[x,y],y,x] computes 2fyx=fxy(x,y)Image, and

5.  D[f[x,y],{x,n},{y,m}] computes n+mfnxmyImage.

6.  You can use the Image button located on the BasicMathInput palette to create templates to compute partial derivatives.

The calculations are carried out similarly for functions of more than two variables.

Example 3.60

Calculate fx(x,y)Image, fy(x,y)Image, fxy(x,y)Image, fyx(x,y)Image, fxx(x,y)Image, and fyy(x,y)Image if f(x,y)=sinx2+y2+1Image.

Solution

After defining f(x,y)=sinx2+y2+1Image,

f [ x _ , y _ ] = Sin [ Sqrt [ x 2 + y 2 + 1 ] ] ; Image

we illustrate the use of D to compute the partial derivatives. Entering

D [ f [ x , y ] , x ] Image

x Cos [ 1 + x 2 + y 2 ] 1 + x 2 + y 2 Image

computes fx(x,y)Image. Entering

D [ f [ x , y ] , y ] Image

y Cos [ 1 + x 2 + y 2 ] 1 + x 2 + y 2 Image

computes fy(x,y)Image. Entering

D [ f [ x , y ] , x , y ] // Together Image

x y ( Cos [ 1 + x 2 + y 2 ] + 1 + x 2 + y 2 Sin [ 1 + x 2 + y 2 ] ) ( 1 + x 2 + y 2 ) 3 / 2 Image

computes fyx(x,y)Image. Entering

D [ f [ x , y ] , y , x ] // Together Image

x y ( Cos [ 1 + x 2 + y 2 ] + 1 + x 2 + y 2 Sin [ 1 + x 2 + y 2 ] ) ( 1 + x 2 + y 2 ) 3 / 2 Image

computes fxy(x,y)Image. Remember that under appropriate assumptions, fxy(x,y)=fyx(x,y)Image. Entering

D [ f [ x , y ] , { x , 2 } ] // Together Image

Cos [ 1 + x 2 + y 2 ] + y 2 Cos [ 1 + x 2 + y 2 ] x 2 1 + x 2 + y 2 Sin [ 1 + x 2 + y 2 ] ( 1 + x 2 + y 2 ) 3 / 2 Image

computes fxx(x,y)Image. Entering

D [ f [ x , y ] , { y , 2 } ] // Together Image

Cos [ 1 + x 2 + y 2 ] + x 2 Cos [ 1 + x 2 + y 2 ] y 2 1 + x 2 + y 2 Sin [ 1 + x 2 + y 2 ] ( 1 + x 2 + y 2 ) 3 / 2 Image

computes fyy(x,y)Image.  □

The directional derivative of z=f(x,y)Image in the direction of the unit vector u=cosθi+sinθjImage is

D u f ( x , y ) = f x ( x , y ) cos θ + f y ( x , y ) sin θ ,

provided that fx(x,y)Image and fy(x,y)Image both exist.

The vectors i and j are defined by i=1,0Image and j=0,1Image.

If fx(x,y)Image and fy(x,y)Image both exist, the gradient of f(x,y)Image is the vector-valued function

f ( x , y ) = f x ( x , y ) i + f y ( x , y ) j = f x ( x , y ) , f y ( x , y ) .

Notice that if u=cosθ,sinθImage,

D u f ( x , y ) = f ( x , y ) cos θ , sin θ .

Let (x0,y0)Image be a point in the domain of the differentiable function z=f(x,y)Image. At (x0,y0)Image, f(x,y)Image increases most rapidly in the direction of the gradient, f(x,y)Image, evaluated at (x0,y0)Image. Similarly, f(x,y)Image decreases most rapidly in the direction of f(x,y)Image. Consequently, the gradient is perpendicular to the level curves of f(x,y)Image.

StreamPlot[{f(x,y),g(x,y)},{x,a,b},{y,c,d}]

generates a stream plot of the vector field <f(x,y),g(x,y)>Image. Thus,

StreamPlot[{D[f[x,y],x],D[f[x,y],y]},{x,a,b},{y,c,d}]

generates a stream plot of the gradient of f(x,y)Image.

Vectors and vector-valued functions will be discussed in more detail in Chapters 4 and 5.

Example 3.61

Let f(x,y)=6x2y3x42y3Image. (a) Find Duf(x,y)Image in the direction of v=3,4Image. (b) Compute D3/5,4/5f(139+33,1)Image. (c) Find an equation of the line tangent to the graph of 6x2y3x42y3=0Image at the point (139+33,1)Image.

Solution

After defining f(x,y)=6x2y3x42y3Image, we graph z=f(x,y)Image with Plot3D in Fig. 3.65, illustrating the PlotPoints, PlotRange, and ViewPoint options.

Image
Figure 3.65 f(x,y)=6x2y − 3x4 − 2y3 for −2 ⩽ x ⩽ 2 and −2 ⩽ y ⩽ 3 (Rice University colors).

f [ x _ , y _ ] = 6 x 2 y 3 x 4 2 y 3 ; Image

Plot3D [ f [ x , y ] , { x , 2 , 2 } , { y , 2 , 3 } , PlotPoints 50 , Image

PlotRange { { 2 , 2 } , { 2 , 3 } , { 2 , 2 } } , Image

PlotStyle { CMYKColor [ 1 , . 93 , . 28 , . 22 ] , Opacity [ . 5 ] } , Image

BoxRatios { 1 , 1 , 1 } , ViewPoint { 1.887 , 2.309 , 1.6 } , Image

ClippingStyle None ] Image

(a) A unit vector, u, in the same direction as v is

u = 3 3 2 + 4 2 , 4 3 2 + 4 2 = 3 5 , 4 5 .

v = { 3 , 4 } ; Image

u = v / Sqrt [ v . v ] Image

{ 3 5 , 4 5 } Image

Then, Duf(x,y)=fx(x,y),fy(x,y)uImage, calculated in du.

gradf = { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } Image

{ 12 x 3 + 12 x y , 6 x 2 6 y 2 } Image

du = Simplify [ gradf . u ] Image

12 5 ( 2 x 2 + 3 x 3 3 x y + 2 y 2 ) Image

(b) D3/5,4/5f(139+33,1)Image is calculated by evaluating du if x=139+33Image and y=1Image.

du1 = du /. { x 1 / 3 Sqrt [ 9 + 3 Sqrt [ 3 ] ] , y 1 } // Simplify Image

4 5 ( 2 3 3 3 + 3 ) Image

(c) The gradient is evaluated if x=139+33Image and y=1Image.

nvec = gradf /. { x 1 / 3 Sqrt [ 9 + 3 Sqrt [ 3 ] ] , y 1 } // Simplify Image

{43+3,23}Image

Generally, f(x,y)Image is perpendicular to the level curves of z=f(x,y)Image, so

nvec = f ( 1 3 9 + 3 3 , 1 ) = f x ( 1 3 9 + 3 3 , 1 ) , f y ( 1 3 9 + 3 3 , 1 )

is perpendicular to f(x,y)=0Image at the point (139+33,1)Image. Thus, an equation of the line tangent to the graph of f(x,y)=0Image at the point (139+33,1)Image is

f x ( 1 3 9 + 3 3 , 1 ) ( x 1 3 9 + 3 3 ) + f y ( 1 3 9 + 3 3 , 1 ) ( y 1 ) = 0 ,

which we solve for y with Solve. We confirm this result by graphing f(x,y)=0Image using ContourPlot in conf and then graphing the tangent line in tanplot. tanplot and conf are shown together with Show in Fig. 3.66.

An equation of the line L containing (x0,y0)Image and perpendicular to n=a,bImage is a(xx0)+b(yy0)=0Image.

Image
Figure 3.66 Level curve of f(x,y) together with a tangent line.

conf = ContourPlot [ f [ x , y ] = = 0 , { x , 2 , 2 } , { y , 2 , 2 } , PlotPoints 60 , Image

ContourShading False , Frame False , Axes Automatic , Image

ContourStyle - > CMYKColor [ 1 , . 93 , . 28 , . 22 ] , Image

AxesOrigin { 0 , 0 } ] ; Image

tanline=Solve[nvec[[1]](x1/3Sqrt[9+3Sqrt[3]])+nvec[[2]](y1)==0,y]Image

{ { y 2 + 3 2 3 + 3 x 3 } } Image

tanplot = Plot [ Evaluate [ y /. tanline ] , { x , 2 , 2 } , Image

PlotStyle - > CMYKColor [ 0 , 0 , 0 , . 77 ] ] ; Image

Show [ conf , tanplot , PlotRange { { 2 , 2 } , { 2 , 3 } } , AspectRatio Automatic ] Image

More generally, we use ContourPlot together with the StreamPlot function to illustrate that the gradient vectors are perpendicular to the level curves of z=f(x,y)Image in Fig. 3.67.

Image
Figure 3.67 (a) Level curves of z = f(x,y). (b) Gradient field of z = f(x,y). (c) The gradient together with several level curves.

p1 = ContourPlot [ f [ x , y ] , { x , 2 , 2 } , { y , 2 , 3 } , Image

Contours 25 , ContourStyle CMYKColor [ 0 , 0 , 0 , . 77 ] , Image

ContourShading False , Frame False , Axes Automatic , Image

AxesOrigin { 0 , 0 } , AxesLabel { x , y } , Image

PlotLabel “(a)” ] Image

p2 = StreamPlot [ Evaluate [ { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } ] , Image

{ x , 2 , 2 } , { y , 2 , 3 } , StreamStyle CMYKColor [ 1 , . 93 , . 28 , . 22 ] , Image

Frame False , Axes Automatic , AxesLabel { x , y } , Image

PlotLabel “(b)” ] Image

p3 = Show [ p1 , p2 , PlotLabel “(c)” ] Image

Show [ GraphicsRow [ { p1 , p2 , p3 } ] ] Image

In Figs. 3.67 (b) and (c), observe that if the gradient vectors are all converging to a point, f(x,y)=0Image and the point will be a relative maximum. At (0,0)Image, f(x,y)=0Image but at this point, some gradient vectors are pointing towards the origin and some away so (0,0)Image is a saddle. Compare to Fig. 3.65. Note that if f(x,y)=0Image and all the gradient vectors were pointing away from the point, the point would be a relative minimum. □

Example 3.62

Let

f ( x , y ) = ( y 1 ) 2 e ( x + 1 ) 2 y 2 10 3 ( x 5 + 1 5 y y 3 ) e x 2 y 2 1 9 e x 2 ( y + 1 ) 2 .

Calculate f(x,y)Image and then graph f(x,y)Image together with several level curves of f(x,y)Image.

Solution

We begin by defining and graphing z=f(x,y)Image with Plot3D in Fig. 3.68 (a).

Image
Figure 3.68 (a) f(x,y) for −3 ⩽ x ⩽ 3 and −3 ⩽ y ⩽ 2. (b) Contour plot of f(x,y) along with several gradient vectors (University of Washington colors).

Clear [ f ] Image

f [ x _ , y _ ] = ( y 1 ) 2 Exp [ ( x + 1 ) 2 y 2 ] Image

10 / 3 ( x 5 + 1 / 5 y y 3 ) Exp [ x 2 y 2 ] Image

1 / 9 Exp [ x 2 ( y + 1 ) 2 ] ; Image

p1 = Plot3D [ f [ x , y ] , { x , 3 , 3 } , { y , 3 , 3 } , Image

PlotStyle { CMYKColor [ 0 , . 13 , . 43 , . 13 ] , Opacity [ . 5 ] } , Image

ViewPoint { 1.99 , 2.033 , 1.833 } , Image

PlotRange All , PlotLabel “(a)” ] ; Image

conf = ContourPlot [ f [ x , y ] , { x , 3 , 3 } , { y , 3 , 3 } , Image

PlotPoints 60 , Contours 30 , ContourShading False , Image

Frame False , Axes Automatic , ContourStyle CMYKColor [ . 93 , 1 , . 18 , . 21 ] , Image

AxesOrigin { 0 , 0 } ] ; Image

In the three-dimensional plot, notice that z appears to have six relative extrema: three relative maxima and three relative minima. We also graph several level curves of f(x,y)Image with ContourPlot and name the resulting graphic conf.

Next we calculate fx(x,y)Image and fy(x,y)Image using Simplify and D. The gradient is the vector-valued function fx(x,y),fy(x,y)Image.

gradf = { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } // Simplify Image

{ 2 9 e 2 x x 2 ( 1 + y ) 2 ( e 2 x x + 9 e 2 y ( 1 + x ) ( 1 + y ) 2 + 3 e 1 + 2 x + 2 y x ( 25 x 3 + 10 x 5 2 y + 10 y 3 ) ) , 2 9 e 2 x x 2 ( 1 + y ) 2 ( e 2 x ( 1 + y ) + 9 e 2 y ( 1 2 y 2 + y 3 ) + e 1 + 2 x + 2 y ( 3 + 30 x 5 y 51 y 2 + 30 y 4 ) ) } Image

We use StreamPlot to graph the gradient naming the resulting graphic gradfplot. gradfplot and conf are displayed together using Show in Fig. 3.68 (b).

gradfplot = StreamPlot [ gradf , { x , 3 , 3 } , { y , 3 , 3 } , Image

StreamStyle CMYKColor [ . 3 , . 35 , . 6 , 0 ] Image

];

Show [ GraphicsRow [ { p1 , Show [ conf , gradfplot , PlotLabel “(b)” ] } ] ] Image

In the result (see Fig. 3.68 (b)), notice that the gradient is perpendicular to the level curves; the gradient is pointing in the direction of maximal increase of z=f(x,y)Image. □

Classifying Critical Points

Let z=f(x,y)Image be a real-valued function of two variables with continuous second-order partial derivatives. A critical point of z=f(x,y)Image is a point (x0,y0)Image in the interior of the domain of z=f(x,y)Image for which

f x ( x 0 , y 0 ) = 0 and f y ( x 0 , y 0 ) = 0 ,

or, equivalently, f(x0,y0)=0Image. Critical points are classified by the Second Derivatives (or Partials) test.

Example 3.63

Find the relative maximum, relative minimum, and saddle points of f(x,y)=2x2+x4+3yy3Image.

Solution

After defining f(x,y)Image, the critical points are found with Solve and named critpts.

f [ x _ , y _ ] = 2 x 2 + x 4 + 3 y y 3 ; Image

critpts = Solve [ { D [ f [ x , y ] , x ] = = 0 , D [ f [ x , y ] , y ] = = 0 } , { x , y } ] Image

{ { x 1 , y 1 } , { x 0 , y 1 } , { x 1 , y 1 } , { x 1 , y 1 } , { x 0 , y 1 } , { x 1 , y 1 } } Image

We then define dfxx. Given (x0,y0)Image, dfxx(x0,y0)Image returns the ordered quadruple x0Image, y0Image, equation (3.36) evaluated at (x0,y0)Image, and fxx(x0,y0)Image.

dfxx [ x0 _ , y0 _ ] = { x0 , y0 , Image

D [ f [ x , y ] , { x , 2 } ] D [ f [ x , y ] , { y , 2 } ] D [ f [ x , y ] , x , y ] 2 /. Image

{ x x0 , y y0 } , D [ f [ x , y ] , { x , 2 } ] /. { x x0 , y y0 } } Image

{ x 0 , y 0 , 6 ( 4 + 12 x 0 2 ) y 0 , 4 + 12 x 0 2 } Image

For example,

dfxx [ 0 , 1 ] Image

{ 0 , 1 , 24 , 4 } Image

shows us that a relative maximum occurs at (0,1)Image. We then use /. (ReplaceAll) to substitute the values in each element of critpts into dfxx.

dfxx [ x , y ] /. critpts // TableForm Image

1 1 48 8 0 1 24 4 1 1 48 8 1 1 48 8 0 1 24 4 1 1 48 8 Image

From the result, we see that (0,1)Image results in a relative maximum, (0,1)Image results in a saddle, (1,1)Image results in a saddle, (1,1)Image results in a relative minimum, (1,1)Image results in a saddle, and (1,1)Image results in a relative minimum. We confirm these results graphically with a three-dimensional plot generated with Plot3D and a contour plot together with the gradient generated with ContourPlot and StreamPlot in Fig. 3.69.

Image
Figure 3.69 (a) Three-dimensional and (b) contour plots of f(x,y) (University of Florida colors).

p1 = Plot3D [ f [ x , y ] , { x , 3 / 2 , 3 / 2 } , { y , 3 / 2 , 3 / 2 } , PlotPoints 40 , Image

PlotStyle { CMYKColor [ 0 , . 7 , 1 , 0 ] , Opacity [ . 4 ] } , Image

PlotLabel “(a)” ] ; Image

p2 = ContourPlot [ f [ x , y ] , { x , 3 / 2 , 3 / 2 } , { y , 3 / 2 , 3 / 2 } , Image

PlotPoints 40 , ContourShading False , Contours 20 , Image

Frame False , Axes Automatic , AxesOrigin { 0 , 0 } , Image

ContourStyle CMYKColor [ 1 , . 6 , 0 , . 2 ] , Image

AxesLabel { x , y } ] ; Image

p3 = StreamPlot [ Evaluate [ { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } ] , { x , 3 / 2 , 3 / 2 } , Image

{ y , 3 / 2 , 3 / 2 } , Image

StreamStyle CMYKColor [ . 1 , . 2 , . 4 , . 1 ] ] ; Image

Show [ GraphicsRow [ { p1 , Show [ p2 , p3 , PlotLabel “(b)” ] } ] ] Image

In the contour plot, notice that near relative extrema, the level curves look like circles while near saddles they look like hyperbolas. Further, at the maximums, the gradient is directed towards the point while at the minimums it is directed away from the point. □

If the Second Derivatives Test fails, graphical analysis is especially useful.

Example 3.64

Find the relative extrema and saddle points of f(x,y)=x2+x2y2+y4Image.

Solution

Initially we proceed in the exact same manner as in the previous example: we define f(x,y)Image and compute the critical points. Several complex solutions are returned, which we ignore.

f [ x _ , y _ ] = x 2 + x 2 y 2 + y 4 ; Image

critpts = Solve [ { D [ f [ x , y ] , x ] = = 0 , D [ f [ x , y ] , y ] = = 0 } , { x , y } ] Image

{{x0,y0},{x0,y0},{x2,yi},{x2,yi},{x2,yi},{x2,yi}}Image

We then compute the value of (3.36) at the real critical point, and the value of fxx(x,y)Image at this critical point.

dfxx [ x0 _ , y0 _ ] = { x0 , y0 , Image

D [ f [ x , y ] , { x , 2 } ] D [ f [ x , y ] , { y , 2 } ] D [ f [ x , y ] , x , y ] 2 /. Image

{ x x0 , y y0 } , D [ f [ x , y ] , { x , 2 } ] /. { x x0 , y y0 } } Image

{ x 0 , y 0 , 16 x 0 2 y 0 2 + ( 2 + 2 y 0 2 ) ( 2 x 0 2 + 12 y 0 2 ) , 2 + 2 y 0 2 } Image

dfxx [ 0 , 0 ] Image

{ 0 , 0 , 0 , 2 } Image

The result shows us that the Second Derivatives Test fails at (0,0)Image.

p1 = Plot3D [ f [ x , y ] , { x , 1 , 1 } , { y , 1 , 1 } , BoxRatios Automatic , Image

PlotStyle { CMYKColor [ 1 , . 56 , 0 , . 34 ] , Opacity [ . 3 ] } , Image

MeshFunctions - > { # 3 & } , MeshStyle { CMYKColor [ 0 , . 18 , 1 , . 15 ] , Thickness [ . 0075 ] } , Image

PlotLabel “(a)” ] ; Image

p2 = ContourPlot [ f [ x , y ] , { x , 1 , 1 } , { y , 1 , 1 } , PlotPoints 40 , Image

Contours 20 , ContourShading False , Frame False , Image

Axes Automatic , AxesOrigin { 0 , 0 } , ContourStyle Image

{ { CMYKColor [ 0 , . 18 , 1 , . 15 ] , Thickness [ . 0075 ] } } ] ; Image

p3 = StreamPlot [ Evaluate [ { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } ] , { x , 1 , 1 } , Image

{ y , 1 , 1 } , Image

StreamStyle CMYKColor [ . 03 , 1 , . 7 , . 12 ] ] ; Image

Show [ GraphicsRow [ { p1 , Show [ p2 , p3 , PlotLabel b ] } ] ] Image

However, the contour plot and the stream plot of the gradient of f(x,y)Image near (0,0)Image indicates that an extreme value occurs at (0,0)Image. Because the gradient vectors are all pointing away from the origin, (0,0)Image is a relative minimum which is confirmed in the three-dimensional plot. It is also an absolute minimum. (See Fig. 3.70.) □

Image
Figure 3.70 (a) Three-dimensional and (b) contour plots of f(x,y) (University of California-Davis colors).

Tangent Planes

Let z=f(x,y)Image be a real-valued function of two variables. If both fx(x0,y0)Image and fy(x0,y0)Image exist, then an equation of the plane tangent to the graph of z=f(x,y)Image at the point (x0,y0,f(x0,y0))Image is given by

f x ( x 0 , y 0 ) ( x x 0 ) + f y ( x 0 , y 0 ) ( y y 0 ) ( z z 0 ) = 0 ,

where z0=f(x0,y0)Image. Solving for z yields the function (of two variables)

z = f x ( x 0 , y 0 ) ( x x 0 ) + f y ( x 0 , y 0 ) ( y y 0 ) + z 0 .

Symmetric equations of the line perpendicular to the surface z=f(x,y)Image at the point (x0,y0,z0)Image are given by

x x 0 f x ( x 0 , y 0 ) = y y 0 f y ( x 0 , y 0 ) = z z 0 1

and parametric equations are

{ x = x 0 + f x ( x 0 , y 0 ) t y = y 0 + f y ( x 0 , y 0 ) t z = z 0 t .

The plane tangent to the graph of z=f(x,y)Image at the point (x0,y0,f(x0,y0))Image is the “best” linear approximation of z=f(x,y)Image near (x,y)=(x0,y0)Image in the same way as the line tangent to the graph of y=f(x)Image at the point (x0,f(x0))Image is the “best” linear approximation of y=f(x)Image near x=x0Image.

Example 3.65

Find an equation of the plane tangent and normal line to the graph of f(x,y)=414(2x2+y2)Image at the point (1,2,5/2)Image.

Solution

We define f(x,y)Image and compute fx(1,2)Image and fy(1,2)Image.

f [ x _ , y _ ] = 4 1 / 4 ( 2 x 2 + y 2 ) ; Image

f [ 1 , 2 ] Image

dx = D [ f [ x , y ] , x ] /. { x 1 , y 2 } Image

dy = D [ f [ x , y ] , y ] /. { x 1 , y 2 } Image

5 2 Image

−1

−1

Using (3.38), an equation of the tangent plane is z=1(x1)1(y2)+f(1,2)Image. Using (3.40), parametric equations of the normal line are x=1tImage, y=2tImage, z=f(1,2)tImage. We confirm the result graphically by graphing f(x,y)Image together with the tangent plane in p1 using Plot3D. We use ParametricPlot3D to graph the normal line in p2 and then display p1 and p2 together with Show in Fig. 3.71.

Image
Figure 3.71 Graph of f(x,y) with a tangent plane and normal line (Washington University in St. Louis colors).

p1 = Plot3D [ f [ x , y ] , { x , 1 , 3 } , { y , 0 , 4 } , Image

PlotStyle { CMYKColor [ 0 , 1 , . 59 , . 24 ] , Opacity [ . 3 ] } ] ; Image

p2 = Plot3D [ dx ( x 1 ) + dy ( y 2 ) + f [ 1 , 2 ] , { x , 1 , 3 } , { y , 0 , 4 } , Image

PlotStyle { CMYKColor [ . 59 , . 41 , . 42 , . 14 ] , Opacity [ . 6 ] } ] ; Image

p3 = ParametricPlot3D [ { 1 + dx t , 2 + dy t , f [ 1 , 2 ] t } , { t , 4 , 4 } , Image

PlotStyle { CMYKColor [ 1 , 0 , . 6 , . 4 ] , Thickness [ . 01 ] } ] ; Image

Show [ p1 , p2 , p3 , PlotRange { { 1 , 3 } , { 0 , 4 } , { 0 , 4 } } , Image

BoxRatios Automatic , AxesLabel { x , y , z } ] Image

Because z=1(x1)1(y2)+f(1,2)Image is the “best” linear approximation of f(x,y)Image near (1,2)Image, the graphs are very similar near (1,2)Image as shown in the three-dimensional plot. We also expect the level curves of each near (1,2)Image to be similar, which is confirmed with ContourPlot in Fig. 3.72.

Image
Figure 3.72 Zooming in near (1,2).

p4 = ContourPlot [ f [ x , y ] , { x , 0.75 , 1.25 } , { y , 1.75 , 2.25 } , Image

Contours 20 , Image

ContourStyle { { CMYKColor [ 0 , 1 , . 59 , . 24 ] , Thickness [ . 01 ] } } , Image

PlotLabel “(a)” ] ; Image

p5 = ContourPlot [ dx ( x 1 ) + dy ( y 2 ) + f [ 1 , 2 ] , { x , 0.75 , 1.25 } , { y , 1.75 , 2.25 } , Image

Contours 20 , Image

ContourStyle { { CMYKColor [ . 59 , . 41 , . 42 , . 14 ] , Thickness [ . 01 ] } } , Image

PlotLabel “(b)” ] ; Image

Show[GraphicsRow[{p4,p5}]]Image □

Lagrange Multipliers

Certain types of optimization problems can be solved using the method of Lagrange multipliers that is based on the following theorem.

Graphically, the points (x0,y0)Image at which the extreme values occur correspond to the points where the level curves of z=f(x,y)Image are tangent to the graph of g(x,y)=0Image.

Example 3.66

Find the maximum and minimum values of f(x,y)=xyImage subject to the constraint 14x2+19y2=1Image.

Solution

For this problem, f(x,y)=xyImage and g(x,y)=14x2+19y21Image. Observe that parametric equations for 14x2+19y2=1Image are x=2costImage, y=3sintImage, 0t2πImage. In Fig. 3.73 (a), we use ParametricPlot3D to parametrically graph g(x,y)=0Image and f(x,y)Image for x and y-values on the curve g(x,y)=0Image by graphing

{ x = 2 cos t y = 3 sin t z = 0 and { x = 2 cos t y = 3 sin t z = x y = 6 cos t sin t

for 0t2πImage. Our goal is to find the minimum and maximum values in Fig. 3.73 (a) and the points at which they occur.

Image
Figure 3.73 (a) f(x,y) on g(x,y)=0. (b) Level curves of f(x,y) together with g(x,y)=0 (Yale University colors).

f [ x _ , y _ ] = x y ; Image

g [ x _ , y _ ] = x 2 / 4 + y 2 / 9 1 ; Image

s1 = ParametricPlot3D [ { 2 Cos [ t ] , 3 Sin [ t ] , 0 } , { t , 0 , 2 Pi } , Image

PlotStyle { { CMYKColor [ 1 , . 75 , . 08 , . 4 ] , Thickness [ . 02 ] } } ] ; Image

s2 = ParametricPlot3D [ { 2 Cos [ t ] , 3 Sin [ t ] , 6 Cos [ t ] Sin [ t ] } , { t , 0 , 2 Pi } , Image

PlotStyle { { CMYKColor [ . 42 , . 4 , . 44 , . 04 ] , Thickness [ . 02 ] } } ] ; Image

plot1 = Show [ s1 , s2 , BoxRatios Automatic , PlotRange All , Image

PlotLabel “(a)” , AxesLabel { x , y , z } ] ; Image

To implement the method of Lagrange multipliers, we compute fx(x,y)Image, fy(x,y)Image, gx(x,y)Image, and gy(x,y)Image with D.

fx = D [ f [ x , y ] , x ] Image

fy = D [ f [ x , y ] , y ] Image

gx = D [ g [ x , y ] , x ] Image

gy=D[g[x,y],y]Image

y

x

x 2 Image

2 y 9 Image

Solve is used to solve the system of equations (3.41):

f x ( x , y ) = λ g x ( x , y ) f y ( x , y ) = λ g y ( x , y ) g ( x , y ) = 0

for x, y, and λ.

vals = Solve [ { fx = = λ gx , fy = = λ gy , g [ x , y ] = = 0 } , { x , y , λ } ] Image

{ { x 2 , y 3 2 , λ 3 } , { x 2 , y 3 2 , λ 3 } , { x 2 , y 3 2 , λ 3 } , { x 2 , y 3 2 , λ 3 } } Image

The corresponding values of f(x,y)Image are found using ReplaceAll (/.).

n1 = { x , y , f [ x , y ] } /. vals // TableForm Image

2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 Image

N [ n1 ] Image

1.41421 2.12132 3 . 1.41421 2.12132 3 . 1.41421 2.12132 3 . 1.41421 2.12132 3 . Image

We conclude that the maximum value f(x,y)Image subject to the constraint g(x,y)=0Image is 3 and occurs at (2,322)Image and (2,322)Image. The minimum value is −3 and occurs at (2,322)Image and (2,322)Image. We graph several level curves of f(x,y)Image and the graph of g(x,y)=0Image with ContourPlot and show the graphs together with Show. The minimum and maximum values of f(x,y)Image subject to the constraint g(x,y)=0Image occur at the points where the level curves of f(x,y)Image are tangent to the graph of g(x,y)=0Image as illustrated in Fig. 3.73 (b).

gradfplot = StreamPlot [ Evaluate [ { D [ f [ x , y ] , x ] , D [ f [ x , y ] , y ] } ] , { x , 3 , 3 } , Image

{ y , 3 , 3 } , StreamStyle CMYKColor [ 1 , . 75 , . 08 , . 4 ] ] ; Image

cp1 = ContourPlot [ f [ x , y ] , { x , 3 , 3 } , { y , 3 , 3 } , Contours - > 30 , Image

ContourShading - > False , PlotPoints - > 40 , Image

ContourStyle { { CMYKColor [ . 42 , . 4 , . 44 , . 04 ] , Thickness [ . 01 ] } } ] ; Image

cp2 = ContourPlot [ g [ x , y ] == 0 , { x , 3 , 3 } , { y , 3 , 3 } , ContourStyle - > Thickness [ 0.01 ] , Image

ContourShading - > False ] ; Image

plot2 = Show [ cp1 , cp2 , gradfplot , Frame False , Image

Axes Automatic , AxesOrigin { 0 , 0 } , AxesLabel { x , y } , Image

PlotLabel “(b)” ] ; Image

Show [ GraphicsRow [ { plot1 , plot2 } ] ] Image

Observe that the maximum and minimum values occur where the gradient vectors of z=f(x,y)Image are parallel to the gradient vectors of z=g(x,y)Image on the equation g(x,y)=0Image. □

3.5.3 Iterated Integrals

The Integrate command, used to compute single integrals, is used to compute iterated integrals. The command

Integrate[f[x,y],{y,c,d},{x,a,b}]

attempts to compute the iterated integral

c d a b f ( x , y ) d x d y .

If Mathematica cannot compute the exact value of the integral, it is returned unevaluated, in which case numerical results may be more useful. The iterated integral (3.42) is numerically evaluated with the command N or

NIntegrate[f[x,y],{y,c,d},{x,a,b}]

Example 3.67

Evaluate each integral: (a) 2412(2xy2+3x2y)dxdyImage; (b) 02y22y(3x2+y3)dxdyImage; (c) 00xyex2y2dydxImage; (d) 0π0πesinxydxdyImage.

Solution

(a) First, we compute (2xy2+3x2y)dxdyImage with Integrate. Second, we compute 2412(2xy2+3x2y)dxdyImage with Integrate.

Integrate [ 2 x y 2 + 3 x 2 y , y , x ] Image

16x2y2(3x+2y)Image

Integrate [ 2 x y 2 + 3 x 2 y , { y , 2 , 4 } , { x , 1 , 2 } ] Image

98

(b) We illustrate the same commands as in (a), except we are integrating over a nonrectangular region.

Integrate [ 3 x 2 + y 3 , { x , y 2 , 2 y } ] Image

8 y 3 + 2 y 4 y 5 y 6 Image

Integrate [ 3 x 2 + y 3 , y , { x , y 2 , 2 y } ] Image

2 y 4 + 2 y 5 5 y 6 6 y 7 7 Image

Integrate [ 3 x 2 + y 3 , { y , 0 , 2 } , { x , y 2 , 2 y } ] Image

1664 105 Image

(c) Improper integrals can be handled in the same way as proper integrals.

Integrate [ x   y Exp [ x 2 y 2 ] , x , y ] Image

1 4 e x 2 y 2 Image

Integrate [ x y Exp [ x 2 y 2 ] , { x , 0 , Infinity } , { y , 0 , Infinity } ] Image

1 4 Image

(d) In this case, Mathematica cannot evaluate the integral exactly so we use NIntegrate to obtain an approximation.

Integrate [ Exp [ Sin [ x y ] ] , y , x ] Image

e Sin [ x y ] d x d y Image

NIntegrate [ Exp [ Sin [ x y ] ] , { y , 0 , Pi } , { x , 0 , Pi } ] Image

15.5092 □

Area, Volume, and Surface Area

Typical applications of iterated integrals include determining the area of a planar region, the volume of a region in three-dimensional space, or the surface area of a region in three-dimensional space. The area of the planar region R is given by

A = R d A .

If z=f(x,y)Image has continuous partial derivatives on a closed region R, then the surface area of the portion of the surface that projects onto R is given by

S A = R ( f x ) 2 + ( f y ) 2 + 1 d A .

If f(x,y)g(x,y)Image on R, the volume of the region between the graphs of f(x,y)Image and g(x,y)Image is

V = R ( f ( x , y ) g ( x , y ) ) d A .

Example 3.68

Find the area of the region R bounded by the graphs of y=2x2Image and y=1+x2Image.

Solution

We begin by graphing y=2x2Image and y=1+x2Image with Plot in Fig. 3.74. The x-coordinates of the intersection points are found with Solve.

Image
Figure 3.74 y = 2x2 and y = 1 + x2 for −3/2 ⩽ x ⩽ 3/2 (Michigan State University colors).

Plot [ Tooltip [ { 2 x 2 , 1 + x 2 } ] , { x , 3 / 2 , 3 / 2 } , Image

PlotStyle { { CMYKColor [ . 82 , 0 , . 64 , . 7 ] , Thickness [ . 01 ] } , Image

{ CMYKColor [ . 43 , . 3 , . 33 , 0 ] , Thickness [ . 01 ] } } , Image

AxesLabel { x , y } ] Image

Solve [ 2 x 2 = = 1 + x 2 ] Image

{ { x 1 } , { x 1 } } Image

Using (3.43) and taking advantage of symmetry, the area of R is given by

A = R d A = 2 0 1 2 x 2 1 + x 2 d y d x ,

which we compute with Integrate.

2Integrate[1,{x,0,1},{y,2x2,1+x2}]Image

4 3 Image

We conclude that the area of R is 4/3. □

If the problem exhibits “circular symmetry,” changing to polar coordinates is often useful. If R={(r,θ)|arb,αθβ}Image, then

R f ( x , y ) d A = α β a b f ( r cos θ , r sin θ ) r d r d θ .

Solution

First, observe that the domain of f(x,y)Image is

{ ( x , y ) | 4 y 2 x 4 y 2 , 2 y 2 } = { ( r , θ ) | 0 r 2 , 0 θ 2 π } .

Similarly,

R = { ( x , y ) | 1 y 2 x 1 y 2 , 1 y 1 } = { ( r , θ ) | 0 r 1 , 0 θ 2 π } .

With this observation, we use ParametricPlot3D to graph f(x,y)Image in p1 and the portion of the graph of f(x,y)Image above R in p2 and show the two graphs together with Show. We wish to find the area of the black region in Fig. 3.75.

Image
Figure 3.75 The portion of the graph of f(x,y) above R (Iowa State University colors).

f [ x _ , y _ ] = Sqrt [ 4 x 2 y 2 ] ; Image

p1 = ParametricPlot3D [ { r Cos [ t ] , r Sin [ t ] , f [ r Cos [ t ] , r Sin [ t ] ] } , { r , 0 , 2 } , Image

{ t , 0 , 2 Pi } , PlotPoints 45 , PlotStyle { { CMYKColor [ . 02 , 1 , . 85 , . 06 ] , Image

Opacity [ . 4 ] } } ] ; Image

p2 = ParametricPlot3D [ { r Cos [ t ] , r Sin [ t ] , f [ r Cos [ t ] , r Sin [ t ] ] } , { r , 0 , 1 } , Image

{ t , 0 , 2 Pi } , PlotPoints 45 , PlotStyle { { CMYKColor [ . 31 , . 38 , . 75 , . 76 ] , Image

Opacity [ . 4 ] } } ] ; Image

Show [ p1 , p2 , BoxRatios Automatic ] Image

We compute fx(x,y)Image, fy(x,y)Image and [fx(x,y)]2+[fy(x,y)]2+1Image with D and Simplify.

fx = D [ f [ x , y ] , x ] Image

fy = D [ f [ x , y ] , y ] Image

x 4 x 2 y 2 Image

y 4 x 2 y 2 Image

s1 = Simplify [ Sqrt [ 1 + fx 2 + fy 2 ] ] Image

2 1 4 + x 2 + y 2 Image

Then, using (3.44), the surface area is given by

S A = R ( f x ) 2 + ( f y ) 2 + 1 d A = R 2 4 x 2 y 2 d A = 1 1 1 y 2 1 y 2 2 4 x 2 y 2 d x d y .

However, notice that in polar coordinates,

R = { ( r , θ ) | 0 r 1 , 0 θ 2 π }

so in polar coordinates the surface area is given by

S A = 0 2 π 0 1 2 4 r 2 r d r d θ ,

s2 = Simplify [ s1 /. { x r Cos [ t ] , y r Sin [ t ] } ] Image

2 1 4 r 2 Image

which is much easier to evaluate than (3.46). We evaluate the iterated integral with Integrate

s3=Integrate[rs2,{t,0,2Pi},{r,0,1}]Image

4 ( 2 + 3 ) π Image

N [ s3 ] Image

3.36715

and conclude that the surface area is (843)π3.367Image. □

Example 3.70

Find the volume of the region between the graphs of z=4x2y2Image and z=2xImage.

Solution

We begin by graphing z=4x2y2Image and z=2xImage together with Plot3D in Fig. 3.76 (a). The region of integration, R, is determined by graphing 4x2y2=2xImage with ContourPlot in Fig. 3.76 (b).

Image
Figure 3.76 (a) z = 4 − x2 − y2 and z = 2 − x for −2 ⩽ x ⩽ 2 and −2 ⩽ y ⩽ 2. (b) Graph of 4 − x2 − y2 = 2 − x (University of California-Irvine colors).

p1 = Plot3D [ { 4 x 2 y 2 , 2 x } , { x , 2 , 2 } , { y , 2 , 2 } , Image

PlotRange { { 2 , 2 } , { 2 , 2 } , { 2 , 4 } } , Image

PlotStyle { { CMYKColor [ . 93 , . 62 , . 09 , . 01 ] , Opacity [ . 4 ] } , Image

{ { CMYKColor [ . 01 , . 16 , 1 , 0 ] , Opacity [ . 6 ] } } } , Image

MeshFunctions - > { # 3 & } , Image

BoxRatios Automatic ] ; Image

p2 = ContourPlot [ 4 x 2 y 2 ( 2 x ) = = 0 , { x , 2 , 2 } , { y , 2 , 2 } , Image

PlotPoints 50 , Frame False , Axes Automatic , AxesOrigin { 0 , 0 } , Image

ContourStyle { { CMYKColor [ . 01 , . 16 , 1 , . 0 ] , Thickness [ . 01 ] } } ] ; Image

Show[GraphicsRow[{p1,p2}]]Image

Another way to see the situation illustrated in Fig. 3.77 is to use RegionPlot3D, which works in the same way as RegionPlot but in three dimensions.

Image
Figure 3.77 Using RegionPlot3D to see the region 2 − x ⩽ z ⩽ 4 − x2 − y2 (University of California-Irvine colors).

RegionPlot3D [ 2 x z < = 4 x 2 y 2 , { x , 2 , 2 } , { y , 2 , 2 } , Image

{ z , 4 , 4 } , PlotPoints 75 , Mesh False , Image

PlotStyle - > { CMYKColor [ . 93 , . 62 , . 09 , . 01 ] , Opacity [ . 4 ] } ] Image

Completing the square shows us that

R = { ( x , y ) | ( x 1 2 ) 2 + y 2 9 4 } = { ( x , y ) | 1 2 1 2 9 4 y 2 x 1 2 + 1 2 9 4 y 2 , 3 2 y 3 2 } .

Thus, using (3.45), the volume of the solid is given by

V = R [ ( 4 x 2 y 2 ) ( 2 x ) ] d A = 3 2 3 2 1 2 1 2 9 4 y 2 1 2 + 1 2 9 4 y 2 [ ( 4 x 2 y 2 ) ( 2 x ) ] d x d y ,

which we evaluate with Integrate.

i1 = Integrate [ ( 4 x 2 y 2 ) ( 2 x ) , { y , 3 / 2 , 3 / 2 } , Image

{x,1/21/2Sqrt[94y2],1/2+1/2Sqrt[94y2]}]Image

81 π 32 Image

N [ i1 ] Image

7.95216

We conclude that the volume is 8132π7.952Image. □

Triple Iterated Integrals

Triple iterated integrals are calculated in the same manner as double iterated integrals.

Solution

Entering

i1 = Integrate [ ( x + 2 z ) Sin [ y ] , { y , 0 , Pi / 4 } , { z , 0 , y } , { x , 0 , y + z } ] Image

17 ( 384 96 π 12 π 2 + π 3 ) 384 2 Image

calculates the triple integral exactly with Integrate.

An approximation of the exact value is found with N.

N [ i1 ] Image

0.157206 □

We illustrate how triple integrals can be used to find the volume of a solid when using spherical coordinates.

Example 3.72

Find the volume of the torus with equation in spherical coordinates ρ=sinϕImage.

Solution

We proceed by graphing the torus with SphericalPlot3D in Fig. 3.79 (see Fig. 3.78 for the help feature associated with this command).

Image
Figure 3.78 Mathematica's help for SphericalPlot3D.
Image
Figure 3.79 A graph of the torus (University of Arizona colors).

SphericalPlot3D [ Sin [ Phi ] , { Phi , 0 , Pi } , { theta , 0 , 2 Pi } , PlotPoints 40 ] Image

In general, the volume of the solid region D is given by

V = D d V .

Thus, the volume of the torus is given by the triple iterated integral

V = 0 2 π 0 π 0 sin ϕ ρ 2 sin ϕ d ρ d ϕ d θ ,

i1 = Integrate [ rho 2 Sin [ phi ] , { theta , 0 , 2 Pi } , Image

{ phi , 0 , Pi } , { rho , 0 , Sin [ phi ] } ] Image

π24Image

N [ i1 ] Image

2.4674

which we evaluate with Integrate. We conclude that the volume of the torus is 14π22.467Image. □