Chapter 7	Techniques of Integration

7.1  Numerical Integration

Students should read Section 7.1 of Rogawski’s Calculus [1] for a detailed discussion of the material presented in this section.

Numerical integration is the process of approximating a definite integral using appropriate sums of function values.  We already saw in Chapter 5 of this text formulas for Right, Left, and Midpoint Rules and their subroutines LRSUM, RRSUM, and MRSUM, respectively.  In this section, we will develop two additional rules: the Trapezoidal Rule and Simpson’s Rule.

7.1.1  Trapezoidal Rule

The Trapezoidal Rule approximates the definite integral (∫_a^b)f(x)dx by using areas of trapezoids and is given by the formula:

(Subscript[T, n])  =  .5 ((b-a)/n )((Subscript[y, 0]) +2(Subscript[y, 1]) + ...  + 2(Subscript[y, n-1]) + (Subscript[y, n]))

where n is the number of trapezoids and (Subscript[y, i])=f(a+i (b-a)/n) .  This formula can be found in your calculus text.  Here is a Mathematica subroutine, called TRAP, for implementing the Trapezoidal Rule:

Clear[f,a,b,n]

TRAP[a_,b_,n_] := (f[a] + 2 Sum[f[a+i*(b-a)/n],{i,1,n-1}] + f[b])(.5 (b-a)/n)

Example 7.1.  Calculate the area under the function f(x)=(x^2) on [0,1] using the Trapezoidal Rule for various values of n.

Solution: The following output gives a table of approximations of (∫_0^1)(x^2)dx based on the Trapezoidal Rule for n=10,20,...,100.

f[x_]:=(x^2)
TableForm[Table[{n,N[TRAP[0,1,n]]},{n,10,100,10}],TableHeadings->{{}, {"n", " (Subscript[T, n])"}}]

It is clear that these values are converging to 1/3, which is the exact value of our definite integral:

(∫_0^1)(x^2)\[DifferentialD]x

7.1.2  Simpson’s Rule

One difference between Simpson’s Rule and all the other rules we have developed so far (TRAP, LRSUM, RRSUM, and MRSUM) is that the number of partition points, n, in this case, must be even.  The other difference is that Simpson’s Rule is a quadratic approximation based on parabolas, whereas the other rules are linear approximations based on lines.  The formula for Simpson’s Rule is given by (refer to your calculus text for details):

(Subscript[S, n])= (1/3) [(Subscript[y, 0])+ 4(Subscript[y, 1])+2(Subscript[y, 2])+4(Subscript[y, 3])+2(Subscript[y, 4])+...+4(Subscript[y, n-3])+2(Subscript[y, n-2])+4(Subscript[y, n-1])+(Subscript[y, n])] (b-a)/n
     =(1/3)[((Subscript[y, 0])+ 4(Subscript[y, 1])+(Subscript[y, 2]))+((Subscript[y, 2])+4(Subscript[y, 3])+(Subscript[y, 4]))+...+((Subscript[y, n-2])+4(Subscript[y, n-1])+(Subscript[y, n]))] (b-a)/n

where (Subscript[y, i])=f(a+i (b-a)/n).  Here is a Mathematica subroutine, called SIMP, for implementing Simpson’s Rule:

Clear[a,b,n]

SIMP[a_,b_,n_] := (1/3)Sum[f[a + (2 i -2)(b-a)/n] + 4 f[a + (2i-1)(b-a)/n] + f[a + 2i (b-a)/n],{i, 1, n/2}] (b-a)/n

Example 7.2.  Calculate the area under the function f(x)=(x^2) on [0,1] using Simpson’s Rule for various values of n.

Solution: We use the same set of values of n as in the previous example.  This will allow us to compare Simpson’s Rule with the Trapezoidal Rule.

f[x_]:=(x^2)
TableForm[Table[{n,N[SIMP[0,1,n]]},{n,10,100,10}],TableHeadings->{{}, {"n", " (Subscript[s, n])"}}]

Notice how fast SIMP converges to the actual value of the integral (1/3) compared to TRAP.

Example 7.3.  Calculate the definite integral of f(x)=sin(25(x^2)) on [0,1] using Simpson’s Rule and approximate it to five decimal places.  What is the minimum number of partition points needed to obtain this level of accuracy?

Solution: We first evaluate SIMP using values for n in increments of 20.

f[x_]:=Sin[25(x^2)]
TableForm[Table[{n,N[SIMP[0,1,n]]},{n,20,200,20}], TableHeadings-> {{},{"n", " (Subscript[s, n])"}}]

Based on the output our approximation, accurate to five decimal places, is 0.10558.  This first occurs between n=100 to n=120.  We evaluate SIMP inside this range to zoom in on the minimum number of partition points needed.

f[x_]:=Sin[25(x^2)]
TableForm[Table[{n,N[SIMP[0,1,n]]},{n,100,120,2}], TableHeadings-> {{},{"n", " (Subscript[s, n])"}}]

Thus, we see that the minimum number of points needed is n=116.  How does this compare with the minimum number of points needed by TRAP to obtain the same level of accuracy?

NOTE: Observe that SIMP does not converge as fast in this example as in the previous example.  This is because the function f(x)=sin(25(x^2)) is oscillatory as the following graph demonstrates:

Plot[f[x],{x,0,1}]

Try increasing the frequency of this function, say to sin(100(x^2)), to see how well SIMP performs.

7.1.3  Midpoint Rule

Since most calculus texts include again the Midpoint Rule in the section on numerical integration, for completeness, we will too.  The Riemann sum using the midpoints of each subinterval is given by the following formula:

Clear[f]
MRSUM[a_,b_,n_]:=Sum[f[a+(i-1/2)*(b-a)/n]*(b-a)/n,{i,1,n}]

Example 7.4.  Calculate the area under the function f(x)=(x^2) on [0,1] using the Midpoint Rule for various values of n.

Solution:

f[x_]:=(x^2)
TableForm[Table[{n, N[MRSUM[0,1,n]]},{n,10,100,10}], TableHeadings-> {{},{"n", "Midpoint rule"}}]

Exercises

1. Consider the definite integral (∫_1^2)ln(x)dx.
a) Using the Trapezoidal Rule, Simpson's Rule, and Midpoint Rule, approximate this integral for n=10,20,...,100.
b) Compare how fast each subroutine (TRAP, SIMP, MRSUM) converges to (∫_a^b)ln(x)dx and decide which of these rules is "best."

2. Repeat Exercise 1 for the following definite integrals:
a)  (∫_0^2)((e^x)/(x+1))dx   		b)  (∫_0^1)cos((x^2))dx		c)  (∫_0^1)(e^(x^2))dx		
Can you make any general conclusions about which rule (Trapezoidal, Simpson’s, Midpoint) is best?

3.  For each of the functions given below, set up a definite integral for the volume of the solid of revolution obtained by revolving the region under f(x) along the given interval and about the given axis.  Then use the subroutines TRAP, SIMP, and MRSUM to approximate the volume of each solid accurate to two decimal places (use various values of n to obtain the desired accuracy).
a) f(x) = cos x;    [0, π/2];    x-axis           b) f(x) = (e^(-(x^2)));    [0,1];   y-axis	c) f(x)=sin x,  [0,π], x-axis

7.2  Techniques of Integration

Students should read Sections 7.2 trhough 7.4 and 7.6 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

All calculus texts have at least a chapter devoted to "Techniques of Integration."  When using Mathematica, these techniques are usually not necessary since Mathematica automatically gives you the answer.

7.2.1 Substitution

On occasion, we do need to use techniques of integration, even when using Mathematica.

Example 7.5.  Evaluate the following integral: ∫(2^x)(Sqrt[((((2^x)))^2)-1])dx.

Solution: We evaluate this integral in Mathematica:

∫(2^x)(Sqrt[((((2^x)))^2)-1])\[DifferentialD]x

To students in a first-year calculus course, this answer makes no sense.  There are many integrals that Mathematica cannot evaluate at all, or cannot evaluate in terms of elementary functions (such as the integral above).  Some of these integrals are doable in terms we should understand, once we first use an appropriate technique of integration. In the above example, all we need to do is first make the following substitution:  u = (2^x)  and d u = (ln 2) (2^x) d x, which transforms the integral to:

(1/(Log[2]))∫(Sqrt[(u^2)-1])\[DifferentialD]u

This is the correct answer.  All we need to do is substitute (2^x) for u, and add the arbitrary constant of integration, getting:
(1/(2 Log[2]))( (2^x)(Sqrt[-1 + ((((2^x)))^2)]) - Log[(2^x) + (Sqrt[-1 + ((((2^x)))^2)])] ) + C
Note that the Mathematica function Log[x] is equivalent to the standard form ln x.

7.2.2 Trigonometric Substitution

Example 7.6.  Evaluate ∫(1/((x^2)(Sqrt[(x^2)-9])))dx.

Solution: By hand, the integral ∫(1/((x^2)(Sqrt[(x^2)-9])))dx would normally be evaluated with a trigonometric substitution of the form x=3secθ.  But with Mathematica, we can do this directly:

∫(1/((x^2)(Sqrt[(x^2)-9])))\[DifferentialD]x

This, of course, is the correct answer, when we remember that Mathematica does not add an arbitrary constant to indefinite integrals.

7.2.3 Method of Partial Fractions

Integrals of rational expressions often require the Method of Partial Fraction Decomposition to evaluate them (by hand).  For example:

∫((3x-3)/((x^2)+5x+4))dx=∫((5/(x+4))-(2/(x+1)))dx=5ln|x+4|-2ln|x+1|=ln|((((x+4))^5)/(((x+1))^2))|

On the other hand, Mathematica will give us essentially the same answer for this integral, but does its work behind the scenes without revealing its technique:

Simplify[∫((3x-3)/((x^2)+5x+4))\[DifferentialD]x]

If we would like to see the partial fraction decomposition of the integrand, ((3x-3)/((x^2)+5x+4)), Mathematica will also do that for us without strain by using the Apart command:

Apart[((3x-3)/((x^2)+5x+4))]

Example 7.7.  Evaluate ∫((2(x^3)+(x^2)-2x+2)/((((x^2)+1))^2))dx.

Solution:  We simply evaluate this integral using Mathematica:

∫((2 (x^3)+ (x^2) -2 x + 2)/((((x^2)+ 1))^2))\[DifferentialD]x

But again, if we would like to see the partial fraction decomposition of the integrand, ((2(x^3)+(x^2)-2x+2)/((((x^2)+1))^2)), then this is straightforward with Mathematica:

Apart[((2 (x^3)+ (x^2) -2 x + 2)/((((x^2)+ 1))^2))]

Exercises

1.  Evaluate ∫(1+ln(x))(Sqrt[1+(((x ln(x)))^2)])dx with Mathematica. If it doesn't give an understandable answer, use a technique of integration that changes the integral into one that Mathematica will evaluate.

In Exercises 2 through 5, use Mathematica to find the partial fraction decomposition of the given functions and then integrate them:
	2.  (((x^2)+3 x - 44)/((x-3)(x+5)(3x-2)))     		3.  ((3(x^2)-4x+5)/((x-1)((x^2)+1)))     	 4.  (25/(x ((x^2)+2x+5))) 		5.  (10/((x((x^2)+2x+5))^2))

In Exercises 6 through 10, use Mathematica to evaluate the given  integrals.
	6. ∫((x^2)/((((x^2)- 4))^(3/2)))dx		7. ∫(x^3)(Sqrt[9-(x^2)])dx		8. ∫(1/(Sqrt[25+(x^2)]))dx	
	9. ∫(sin^5)xdx			9. ∫(((tan^(-1))t)/(1+(t^2)))dt			10. ∫(sinh^3)x cosh xdx

7.3  Improper Integrals

Students should read Section 7.7 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

Recall that there are two types of improper integrals.

Type I: If we assume that f(x) is integrable over [a,b] for all b≥a, then the improper integral of f(x) over [a,∞) is defined as
	(∫_a^∞)f(x)dx = (lim_(t-> ∞))(∫_a^t)f(x)dx,
provided this limit exists.  Similarly, we define
	(∫_(-∞)^b)f(x)dx = (lim_(t-> -∞))(∫_t^b)f(x)dx,
provided this limit exists.

Type II: If f(x) is continuous on [a,b) but discontinuous at x=b, we define
	(∫_a^b)f(x)dx = (lim_(t-> b-))(∫_a^t)f(x)dx ,
provided this limit exists.  Similarly, if f(x) is continuous on (a,b] but discontinuous at x=a,
	(∫_a^b)f(x)dx = (lim_(t-> a+))(∫_t^b)f(x)dx,
provided this limit exists.  Finally, if f(x) is continuous for all x on [a,b] except at x=c, where a<c<b, we define
	(∫_a^b)f(x)dx=(lim_(t->c-))(∫_a^t)f(x)dx+(lim_(t->c+))(∫_t^b)f(x)dx,
provided both of these limits exist.

By using the Limit command in Mathematica along with Integrate, Mathematica eliminates the drudgery of having to evaluate these integrals by hand.

Example 7.8.  Evaluate the following improper integrals:
a)  (∫_20^∞)(1/y)dy
b) (∫_2^∞)(e^(-2x))dx
c) (∫_0^1)x ln xdx
d) (∫_(-∞)^∞)(1/(1+(x^2)))dx

Solution:

a)  We evaluate

(∫_20^∞)(1/y)\[DifferentialD]y

Thus, evaluating this integral directly using Mathematica tells us it does not exist.  Alternatively, we could have used the limit definition:

Limit[(∫_20^t)(1/y)\[DifferentialD]y,t-> ∞]

Observe the difference in the two outputs above.  Both correctly express the answer as divergent; however, the second answer is better since it reveals the nature of the divergence (infinity), which is the answer we would expect if solving this problem by hand.

b)  We evaluate

(∫_2^∞)(E^(-2x))\[DifferentialD]x

Again, we obtain the same answer using the limit definition (as it should):

Limit[(∫_2^t)(E^(-2x))\[DifferentialD]x , t-> ∞]

Mathematica will similarly handle discontinuities. In the following example, the function has a discontinuity at x = 0.

c) We evaluate

(∫_0^1)x Log[x]\[DifferentialD]x

Limit[(∫_t^1)x Log[x]\[DifferentialD]x, t-> 0, Direction->-1]

d)  We evaluate

(∫_(-∞)^∞)(1/(1+(x^2)))\[DifferentialD]x

Note that Mathematica does not require us to break the integral up into two integrals, which would be required according to its definition, if evaluated by hand.  On the other hand, there is nothing wrong with dividing this integral into two in Mathematica:

(∫_(-∞)^0)(1/(1+(x^2)))\[DifferentialD]x + (∫_0^∞)(1/(1+(x^2)))\[DifferentialD]x

NOTE: Observe that it does not matter where we divide the integral.  It is valid to express (∫_(-∞)^a)(1/(1+(x^2)))dx+(∫_a^∞)(1/(1+(x^2)))dx for the integral  (∫_(-∞)^∞)(1/(1+(x^2)))dx for any real value a as long as they are convergent.  However, evaluating this sum in Mathematica yields different expressions for the answer, which depend on the sign of a and whether it is real or complex.  This is shown in the following output:

Clear[a]
(∫_(-∞)^a)(1/(1+(x^2)))\[DifferentialD]x + (∫_a^∞)(1/(1+(x^2)))\[DifferentialD]x

If instead, a is given a fixed value, then Mathematica will give us our answer of π:

a=1
(∫_(-∞)^a)(1/(1+(x^2)))\[DifferentialD]x + (∫_a^∞)(1/(1+(x^2)))\[DifferentialD]x

Exercises

In Excercises 1 through 8, evaluate the given improper integrals:
1.  (∫_(-∞)^4)(e^(.01 t))dt 		2.  (∫_(-3)^∞)(1/(((x+4))^(3/2)))dx 		3.  (∫_(-2)^4)(1/(((x+2))^(1/3)))dx 		4.  (∫_(-∞)^∞)x (e^(-(x^2)))dx		
5. (∫_0^3)(1/(x-1))dx			6. (∫_(-∞)^∞)(1/((e^x)+(e^(-x))))dx		7. (∫_1^∞)(1/(x^(.999)))dx			8.  (∫_1^∞)(1/(x^1.003))dx

11.  Find the volume of the solid obtained by rotating the region below the graph of  y=(e^(-x)) about the x-axis for  0≤x<∞.

12.  Determine how large the number b has to be in order that   (∫_b^∞)(1/((x^2)+1))dx <  .0001.

13. Evaluate the improper integral (∫_(-1)^1)(1/(|(x^(1/3))|))dx.

14.  Determine how large the number b should be so that  (∫_b^∞)(1/((x^2)+1))dx   <   .0001.

15. Consider the function defined by

G(x)=(∫_0^∞)(t^(x-1))(e^(-t))dt

a)  Evaluate G(n)  for n=0, 2,,3, 4, ...., 10.  Make  a conjecture about these values.  Verify your conjecture.
b) Evaluate G((2n-1)/2), for n=1, 2, 3, ... 10.  Make a conjecture about these values.  Verify your conjecture.
c) Plot the graph of G(x) on the interval [0, 5].

NOTE: The function G is called the gamma function and is denoted by Γ[x]. In Mathematica it is denoted by Gamma[x].   The gamma function was first introduced by Euler as a generalization of the factorial function.

7.4  Hyperbolic and Inverse Hyperbolic Functions

Students should read Section 7.5 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

7.4.1. Hyperbolic Functions

The hyperbolic functions are defined in terms of the exponential functions.  They have a direct connection to engineering mathematics, including bridge construction.  For example, cables from suspension bridges typically form a curve called a catenary (derived from the Latin word catena, which means chain) that is described by these functions.

The six hyperbolic functions are denoted and defined as follows:

sinh x =(((e^x)- (e^(-x)))/2), 	 cosh x=(((e^x)+ (e^(-x)))/2),	tanh x=(((e^x)- (e^(-x)))/((e^x)+ (e^(-x))))

coth x =(((e^x)+ (e^(-x)))/((e^x)- (e^(-x)))), 	 sech x=(2/((e^x)+ (e^(-x)))),	csch x=(2/((e^x)- (e^(-x))))

The reason these functions are called hyperbolic functions is due to their connection with the equilateral hyperbola (x^2)-(y^2)=1.  Here, one defines x=cosh t and y=sinh t.  Hence, one obtains the basic hyperbolic identity (cosh^2)t-(sinh^2)t=1, much the same manner as the corresponding trigonometric identity (cos^2)t+(sin^2)t=1, when one considers the unit circle (x^2)+(y^2)=1 with x=cos t and y=sin t.

In Mathematica, we use the same notation with the obvious convention that the first letter of each function is capitalized and square brackets must be used in place of parentheses.  Thus, sinh x will be entered as Sinh[x].

Example 7.9.  Consider the hyperbolic sine function f(x)=sinh x.
a) Plot the graph of f. 
b) From the graphs deduce the domain and range of the function. 
c) Is f bounded? 
d) Does f attain an absolute minimum? Maximum?
e) Repeat a) through d) for the hyperbolic function g(x)=cosh x  
f) Repeat a) through d) for the hyperbolic function h(x)=tanh x.

Solution: We begin by defining f in Mathematica:

Clear[f,x]
f[x_]=Sinh[x]

a) We next plot its graph on the interval [-3,3].

Plot[f[x], {x, -3,3}]

b) The preceding graph indicates that the domain and range of sinh x is (-∞,∞). To convince yourself, you should plot the graph over wider intervals.  We should also expect this from the definition of sinh x itself.  Can you explain why?

c) The function sinh x is not bounded. The graph earlier should not be used as a proof of this.  However, we can evaluate its limit at -∞ and ∞ to see that this is indeed true.

Limit[f[x],x->-∞]
Limit[f[x],x->∞]

d) The limits just computed show that sinh x has no absolute maximum or minimum since it is unbounded.

e) Next, we consider the hyperbolic cosine function denoted by cosh x.

Clear[g,x]
g[x_]=Cosh[x]

Plot[g[x],{x,-3,3}]

The preceding graph indicates that the domain of cosh x is (-∞,∞). The range appears to be  [1,∞). Can you prove this?

The hyperbolic cosine function, cosh x, is not bounded from above. This can be seen from the following limits:

Limit[Cosh[x],x->-∞]
Limit[Cosh[x],x->∞]

Again, since cosh x is not bounded from above, it follows that cosh x has no absolute maximum. As we have observed in part b) of this example, cosh x has absolute minimum value 1, attained at x=0.

f) Finally, we consider the hyperbolic tangent function, tanh x:

Clear[h,x]
h[x_]=Tanh[x]

Plot[h[x],{x,-3,3}]

Again, the preceding graph indicates that the domain of tanh x is (-∞,∞). The range appears to be  (-1,1). This can be seen from the following limits:

Limit[Tanh[x],x->-∞]
Limit[Tanh[x],x->∞]

The graph of tanh x also indicates that it is strictly increasing on its domain.  This can be proven by showing that its derivative, which we will calculate later, is strictly positive.  It is clear that tanh x has no absolute extrema.

NOTE: The reader will notice some similarities between the hyperbolic functions and the associated trigonometric functions. Moreover, if one studies the theory of functions of a complex variable, the relationship between these classes of transcendental functions becomes even more transparent; for numerous identities exist between the classes of functions.

7.4.2 Identities Involving Hyperbolic Functions

It is immediate that the ratio and reciprocal identities for the hyperbolic functions coincide with their trigonometric counterparts. In fact, for each trigonometric identity, there is a corresponding (not necessarily the same) hyperbolic identity.  Following are some examples.

Example 7.10.  Show that the following identities hold true.
a) 1-(tanh^2)x=(sech^2)x	b)  cosh(x+y)=cosh x cosh y+sinh x sinh y

Solution:

a) We use the definitions for tanh x and sech x to express each side of the identity in terms of exponentials:

Simplify[(1-((Tanh[x])^2))/.Tanh[x]->(E^x-E^(-x))/(E^x+E^(-x))]

Simplify[((Sech[x])^2)/.Sech[x]->2/(E^x+E^(-x))]

We leave it for the reader to verify that both of these outputs agree, that is, ((4(e^(2x)))/(((1+(e^(2x))))^2))=(4/((((e^(-x))+(e^x)))^2)) (cross-multiply and then simplify).

The identity can also be confirmed in Mathematica by evaluating the difference between its left- and right-hand sides, which should equal zero:

Simplify[1-((Tanh[x])^2)-((Sech[x])^2)]

NOTE: We can also confirm the identity graphically by plotting the graphs of each side of the identity, which should coincide.

Plot[{1-Tanh[x]^2,Sech[x]^2},{x,-2,2}]

b) We again evaluate the difference between the left- and right-hand sides of the identity:

Simplify[Cosh[x+y]-(Cosh[x] Cosh[y]+Sinh[x] Sinh[y])]

7.4.3 Derivatives of Hyperbolic Functions

We next contrast the formulas for the derivatives of the trigonometric functions versus the formulas for the derivatives of the companion hyperbolic functions.

Example 7.11.  Compare the derivatives of the given pair of functions.
a) sinh x and sin x	b)  cosh x and cos x	 c) tanh x and tan x

Solution: We use the derivative command, D, to evaluate derivatives of each pair.

a)

D[Sinh[x],x]
D[Sin[x],x]

b)

D[Cosh[x],x]
D[Cos[x],x]

b)

D[Tanh[x],x]
D[Tan[x],x]

It is clear that derivatives of hyperbolic and trigonometric functions are quite similar.

7.4.4 Inverse Hyperbolic Functions

In light of the fact that hyperbolic functions are defined in terms of the exponential functions, it is readily apparent that the inverse hyperbolic functions are defined in terms of the natural logarithmic function.  The inverses of the hyperbolic functions have notation similar to those of inverse trigonometric functions.  Thus, the inverse of sinh x is denoted by arcsinh x or (sinh^(-1)) x.  In Mathematica, the notation is (sinh^(-1))x is ArcSinh[x].

Example 7.12.  Plot the graphs of (sinh^(-1))x and sinh x on the same axis.

Solution: Recall that the graph of a function and the graph of its inverse are reflections of each other across the line y=x.  This is confirmed by the following plot of (sinh^(-1))x (in blue) and sin x (in red).

Plot[{Sinh[x], x, ArcSinh[x]},{x, -3,3}, PlotStyle->{Blue,Green,Red},AspectRatio->Automatic,PlotRange->{-3,3}]

Example 7.13.  Show that (tanh^(-1))x=(1/2)ln(((1+x)/(1-x))) for -1<x<1.

Solution: We plot the graphs of y=(tanh^(-1))x and y=(1/2)ln(((1+x)/(1-x))) on the same axes. Note that Mathematica's notation of (tanh^(-1))x is ArcTanh [x] and ln y is entered as Log[y]:

Plot[{ArcTanh[x],(1/2)Log[((1+x)/(1-x))]},{x,-2,2}]

The fact that there is only one graph indicates that the functions are the same. We prove this by letting y=(tanh^(-1))x and solving for y as follows.  From y=(tanh^(-1))x we get x=tanh y=(((e^y)-(e^(-y)))/((e^y)+(e^(-y)))).  Now solving this last equation for y in Mathematica yields:

Solve[x==(E^y-E^(-y))/(E^y+E^(-y)),y]

The first solution in the preceding output is imaginary, which we ignore, and consider only the second solution.  Hence,

(tanh^(-1)) x =y=ln((Sqrt[-1-x])/(Sqrt[-1+x]))=ln(Sqrt[((1+x)/(1-x))])=(1/2)ln(((1+x)/(1-x))).

NOTE: The message in the previous output refers to the fact that when solving equations involving inverse functions, not all solutions are necessarily found by Mathematica since there may be infinitely many of them or they depend on the domain of definition.  For example, the equation sin x=1 has infinitely many solutions, in particular all values of the form x=π/2+2π n, where n is any integer.  On the other hand, solving this equation in Mathematica yields only the solution in its principal domain, that is, x=π/2:

Solve[Sin[x]==1,x]

Exercises

In Exercises 1 through 5, verify the given hyperbolic identities using the Simplify command. Also state the corresponding trigonometric identity.

1.  sinh(x+y)=sinh x cosh y+cosh x sinh y 			2.  cosh 2x = (cosh^2)x+(sinh^2)x		3.   tanh 2x=((2 tanh x)/(1+(tanh^2)x)) 
4.  cosh(x+y)=cosh x cosh y + sonh x sinh y		5.  tanh(x+y)=((tanh x+tanh y)/(1+tanh x tanh y))

6.  Determine the first few positive integral powers of cosh x + sinh x. Can you form a general conjecture for the nth case, namely (((cosh x+ sinh x))^n), where n is any natural number?  Then justify your conclusion via mathematical induction.

In Exercises 7 through 12, determine the derivatives of thegiven functions and simplify your answers where possible. Compare your solution via paper and pencil methods with the one generated by Mathematica.

7.  f(x)=tanh (1+(x^2)) 			8.  f(x)=x sinh x - cosh x					9. f(x)=(Sqrt[((1+tanh x)/(1- tanh x))])
10. f(x)=(x^2)(sinh^(-1))(2x)	 		11.  f(x)=x (tanh^(-1))x+ ln ((Sqrt[1-(x^2)]))			12. f(x)=x coth x -sech x

13. The Gateway Arch in St. Louis was designed by Eero Saarinen and was constructed using the equation

y = 211.49 - 20.96 cosh (0.03291765 x)

for the central curve of the arch, where x and y are measured in meters and |x|≤ 91.20.

a) Plot the graph of the central curve.
b) What is the height of the arch at its center?
c) At what points is the arch 100 meters in height?
d) What is the slope of the arch at the points in part (c)?

14.  A flexible cable always hangs in the shape of a catenary y = c + a cosh (x / a), where c and a are constants and a > 0.  Plot several members of the family of functions y = a cosh (x / a) for various values of a.  How does the graph change as a varies?

In Exercises 15 through 17,  evaluate each of the given integrals:

15.  ∫sinh x (cosh^n)xdx			16. ∫((cosh x)/((cosh^2)x-1))dx			17.  ∫(((sech^2)x)/(2+tanh x))dx

18.   Let t=ln(((1+(Sqrt[5]))/2)) and define

f(n)={({{(2/(Sqrt[5]))cosh(t n), if n is odd}, {(2/(Sqrt[5]))sinh(t n), if n is even}})

Evaluate f(n) for n=1, 2, 3, ...,20.  Do these values seem familiar? If not, we highly recommend the interesting article by Thomas Osler, Vieta-like products of nested radicals with Fibonacci and Lucas numbers, to appear in the journal Fibonacci Quarterly.

Chapter  8	Further Applications of Integration

8.1  Arc Length and Surface Area

Students should read Section 8.1 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

8.1.1 Arc Length

The integrals for calculating arc length and surface area are generally difficult to do by hand.  Thus, Mathematica is the appropriate tool for evaluating these integrals.

If y is a function of x, that is, y = f(x), and f'(x) exists and is continuous on [a,b], then the arc length of the graph of f(x) over the interval [a,b] is

L=(∫_a^b)(Sqrt[1 + f'(((x))^2)])dx

If x is a function of y, that is, x = g(y), and g'(y) exists and is continuous on [c,d], then the arc length of the graph of g(y) over the interval [c,d] is

L=(∫_c^d)(Sqrt[f'(((y))^2) +1])dy

Example 8.1.  Estimate the arc length of  y=(1/x) over the interval [1,2].

Solution: Finding the arc length of this simple rational function by hand is virtually impossible.  This is because f'(x)=-(1/(x^2)) and thus the arc length integral is L=(∫_1^2)(Sqrt[1+ (1/(x^4))])dx, which cannot be evaluated in terms of elementary functions, as the following answer illustrates.

(∫_1^2)(Sqrt[1 + (1/(x^4))])\[DifferentialD]x

However, there are numerical techniques that we can use.  For example, the Mathematica command NIntegrate uses sophisticated algorithms to gives us a good estimate for this definite integral:

NIntegrate[(Sqrt[1 + (1/(x^4))]), {x,1,2}]

A more elementary method of estimating this arc length is Simpson's Rule as shown in Section 7.1 of this text.

Clear[f, a,b,n]
SIMP[a_,b_,n_,f_] := (1/3)Sum[f[a + (2 i -2)(b-a)/n] + 4 f[a + (2i-1)(b-a)/n] + f[a + 2i (b-a)/n],{i, 1, n/2}] (b-a)/n

f[x_]:= (Sqrt[1 + (1/(x^4))])
TableForm[Table[{n,N[SIMP[1,2,n,f]]},{n,10,100,10}],TableHeadings->{{},{"n", "(Subscript[S, n])"}} ]

Thus, we see that Simpson's Rule gives us as accurate an estimate of the arc length, as does the NIntegrate command for n as small as 20.

Example 8.2.  Consider the the ellipse whose equation is given by

((x^2)/(a^2))+((y^2)/(b^2))=1

Assume that a>b. Find the arc length of the upper half of the ellipse.

Solution: To plot the ellipse for various values of a and b, we define a plotting command plot[a,b] as follows.

Clear[a,b,x,y,eq,plot]
eq[x_,y_,a_,b_]:=((x^2)/(a^2))+((y^2)/(b^2))-1 
plot[a_,b_]:=ContourPlot[eq[x,y,a,b]==0, {x, -a,a}, {y, -b,b},
AspectRatio->Automatic, Axes->True, Frame->False]

Here is a plot of the ellipse for a=2 and b=3.

plot[2,3]

On the upper half of the ellipse, we have y≥0. Thus, we can solve for y and and take the positive solution. We will denote this positive solution as a function of x, a, and b.

sol=Solve[((x^2)/(a^2))+((y^2)/(b^2))==1, y];
f[x_,a_,b_]=sol[[2,1,2]]

Clearly, the domain of f is [-a, a]. The natural thing to do would be to evaluate the integral (∫_(-a)^a)(Sqrt[1+(((f'(x)))^2)])dx.  Try this yourself, but be prepared to wait awhile.  Moreover, Mathematica will give the following output:

If[Im[a]==0&&(a Im[(1/(Sqrt[-(a^2)+(b^2)]))]≥1||1+a Im[(1/(Sqrt[-(a^2)+(b^2)]))]≤0||a Im[(1/(Sqrt[-(a^2)+(b^2)]))]==0||a Re[(1/(Sqrt[-(a^2)+(b^2)]))]≠0),((2 (((-a))^(3/2)) (Sqrt[(b^2)]) EllipticE[1-((b^2)/(a^2))] Sign[a])/(Sqrt[-a (b^2)])),Integrate[(Sqrt[1+(((b^2) (x^2))/((a^4)-(a^2) (x^2)))]),{x,-a,a},Assumptions->(Re[b]==0&&Re[a]≠0&&Im[a]==0&&Im[b]≠0)||Im[a]<0||Im[a]>0]]

To understand this output, let us make a change of variable x=a sin  t. Then the integral becomes (verify this)

(∫_(-a)^a)(Sqrt[1+(((f'(x)))^2)])dx=a(∫_(-π/2)^(π/2))(Sqrt[1+(((b^2)(sin^2)t)/((a^2)(cos^2)t))])cos t d t

The latter integral can be expressed as

2a(∫_0^(π/2))(Sqrt[1+(((b^2)(sin^2)t)/((a^2)(cos^2)t))])cos t d t =2a(∫_0^(π/2))(Sqrt[(cos^2)t+((b^2)/(a^2))(sin^2)t]) d t =2a (∫_0^(π/2))(Sqrt[1-(c^2) (sin^2)t]) d t ,

where  c=(Sqrt[1-(((b/a))^2)])and we have used the identity (cos^2)t=1-(sin^2)t.

To simplify our notation, let us define the integrand in the preceding far left integral as

g[t_, a_,b_]=(Sqrt[1-(1-(((b/a))^2))(((Sin[t]))^2)])

Here are some values of the arc length of the upper half of the ellipse.

TableForm[Table[2a(∫_0^(π/2))g[t,a,b] \[DifferentialD]t,{a,1,3},{b,1,3}],
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"} }]

Observe that we obtain exact values for the arc length when a=b.  Can you explain why?

The approximate values of the numbers appearing in the preceding table are as follows:

TableForm[N[Table[2a(∫_0^(π/2))g[t,a,b] \[DifferentialD]t,{a,1,3},{b,1,3}],10],
 TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"} }]

NOTE: The integral ∫(Sqrt[1-(c^2)(sin^2)t])dt is known as an elliptic integral.  It is very useful in mathematics and has many applications. In Mathematica, it is denoted by Elliptic[t,c^2].  The command Elliptic[x,m] gives (∫_0^x)(Sqrt[1-m (sin^2)t])dt, while Elliptic[m] gives  (∫_0^(π/2))(Sqrt[1-m (sin^2)t])dt.

8.1.2 Surface Area

If f'(x) exists and is continuous on [a,b], then the surface area of revolution obtained by rotating the graph of f(x) about the x-axis for a ≤ x ≤ b is

S=2π(∫_a^b)f(x)(Sqrt[1 + (([f'(x)])^2)])dx

Similarly, if x=g(y) and g'(y) exists and is continuous on [c,d], then the surface area of revolution obtained by rotating g(y) about the y-axis for c ≤ y ≤ d is

S=2π(∫_c^d)g(y)(Sqrt[(([g'(y)])^2)+ 1])dy

Again, evaluating these complicated integrals is what Mathematica does best, as the following examples illustrate.

Example 8.3.  Determine the surface area of revolution obtained by rotating the region under y=(e^(-x)) along the interval [0,2] about the x-axis.

Solution: We calculate

Clear[f,x]
f[x_] := (E^(-x))
S= 2π(∫_0^2)f[x](Sqrt[1+ ((f'[x])^2)])\[DifferentialD]x

N[%]

Here is the corresponding surface of revolution (rotated 90° about the y-axis):

RevolutionPlot3D[(E^(-x)), {x,0,2}]

NOTE: Observe that in this case Mathematica was able to find an anti-derivative of the integrand.  However, not all integrals of this form can be evaluated analytically as the next example illustrates.

Example 8.4.  Determine the surface area of revolution obtained by rotating the region under y=tan x along the interval [0,(π/4)] about the x-axis.

Solution: As in the previous example, we evaluate

Clear[f,x]
f[x_] := Tan[x]
NIntegrate[2π f[x](Sqrt[1+ ((f'[x])^2)]), {x,0,Pi/4}]

To appreciate the complexity of the integral and understand why we used the command NIntegrate, we advise the reader to define the anti-derivative F[t] below and evaluate F[π/4] (be prepared to wait awhile).

F[t_]:=Integrate[f[x](Sqrt[1+ ((f'[x])^2)]),{x,0,t}]

Here is the corresponding surface of revolution:

RevolutionPlot3D[Tan[x],{x,0, Pi/4}]

Exercises

In Exercises 1 and 2, calculate the arc length of the given function over the given interval:
1.  y=(x^4),  over [1,2]         2.  y=sin x,  over [0,(π/2)]

3.  Calculate the arc length of the astroid  (x^(2/3)) + (y^(2/3))=1.  Below is a plot of its graph.  Hint: By symmetry it suffices to calculate only the portion in the first quadrant.

ContourPlot[(x^2)^(1/3)+(y^2)^(1/3)==1,{x,-1,1},{y,-1,1}]

4.  Show that the circumference of the unit circle is 2π by calculating its arc length. Use the fact that the equation of the unit circle is given by   (x^2) + (y^2)=1.

In Exercises 5 through 7, compute the surface area of the given functions rotated about the x-axis over the given intervals:
5.  y=(x^3)+(1/x),  over [1,4]      	6.  y=(((4-(x^(2/3))))^(2/3)) over [0,8]   	 7.  y=cos x, over [0,π]

8.  Show that the surface area of the unit sphere is 4π by rotating the top half of the unit circle  (x^2)+(y^2)=1 about the x-axis.

8.2  Center of Mass

Students should read Section 8.3 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

A lamina is a thin plate whose mass is distributed throughout a region in the plane. Suppose a lamina has a constant density ρ and that the lamina occupies a region in the plane under the graph of a continuous function f over the interval [a,b], where f(x)≥0 for all x.

The mass of the lamina is given by

M=ρ(∫_a^b)f(x)dx

Then the moments of the lamina with respect to x-axis and y-axis are denoted by (Subscript[M, x]) and (Subscript[M, y]) and are defined by

(Subscript[M, x])=(1/2)ρ(∫_a^b)(([f(x)])^2)dx

(Subscript[M, y])=ρ(∫_a^b)x f(x)dx

The center of mass (also called the centroid) of the lamina is defined to be ((OverBar[x]),(OverBar[y])), where

(OverBar[x])=((Subscript[M, y])/M) and (OverBar[y])=((Subscript[M, x])/M)

NOTE:  If the lamina described above as a density ρ that continuously depends on x, that is, if ρ=ρ(x) for x in the interval [a,b], then the moments, the total mass, and the center of mass are given by

M=(∫_a^b)ρ(x)f(x)dx

(Subscript[M, x])=(1/2) (∫_a^b)((ρ(x)[f(x)])^2)dx

(Subscript[M, y])= (∫_a^b)x ρ(x)f(x)dx

(OverBar[x])=((Subscript[M, y])/M) and (OverBar[y])=((Subscript[M, x])/M)

Example 8.5.  Suppose a lamina lies underneath the graph of y=16-(x^2) and over the interval [-4,4].

a)  Assume the density of the lamina is ρ=3. Find the mass, moments, and the center of mass of the lamina. 
b)  Assume the density of the lamina is ρ=(x/2)+2. Find the mass, moments, and the center of mass of the lamina.

Solution:

a) We use the above formulas with ρ=3:

f[x_]=16-(x^2)

The mass is given by

M=3(∫_(-4)^4)f[x]\[DifferentialD]x

The moment with respect to the x-axis is

Mx=(3/2)(∫_(-4)^4)(((f[x]))^2)\[DifferentialD]x

The moment with respect to the y-axis is

My=3(∫_(-4)^4)x f[x]\[DifferentialD]x

The coordinates for the center of mass are

xbar=My/M
ybar=Mx/M

Observe that the region of the lamina is symmetric with respect to the y-axis. Hence, the fact that (OverBar[x])=0 is also clear from the fact that the density is a constant.

Below is the plot of the lamina and its center of mass:

plot1=Plot[f[x], {x, -4,4} ,Filling->Axis];
plot2=ListPlot[{{xbar,ybar}},PlotStyle->{PointSize[0.02],Red}];
Show[plot1,plot2]

b) Here, ρ=x+4. With the above notation we have

f[x_]=16-(x^2)
ρ[x_]=(x/2)+2

The mass is

Mv=(∫_(-4)^4)ρ[x] f[x]\[DifferentialD]x

The moment with respect to the x-axis is

Mxv=(1/2)(∫_(-4)^4)ρ[x] (((f[x]))^2)\[DifferentialD]x

The moment with respect to the y-axis is

Myv=(∫_(-4)^4)ρ[x] x f[x]\[DifferentialD]x

The coordinates for the center of mass are

xbarv=Myv/M
ybarv=Mxv/M

Here is a plot of the lamina showing the center of masses with the uniform density of ρ=3 and variable density of ρ=(x/2)+2  represented by the red and green dots, respectively.

plot3=ListPlot[{{ xbarv,ybarv}}, PlotStyle->{Green,PointSize[.02]}];
 Show[plot1,plot2,plot3]

NOTE: Observe that the center of mass with variable density (green dot) is shifted to the right, as expected, since the density is more weighted to the right.

Example 8.6.  Suppose a lamina covers the top half of the ellipse

((x^2)/(a^2))+((y^2)/(b^2))=1

a) Assume the density of the lamina is ρ=1. Find the mass, moments and the center of mass of the lamina. 
b) Assume the density of the lamina is ρ=(e^(-x)). Find the mass, moments and the center of mass of the lamina.

Solution:  To distinguish between the uniform and variable density cases in parts a) and b), respectively, we attach the letter u and v to the notation in this solution. Thus, Mu will be the mass corresponding to the uniform density while Mv is the mass corresponding the variable density.

a) We solve the equation of the ellipse for y:

Clear[a,b,x,y]
sol=Solve[((x^2)/(a^2))+((y^2)/(b^2))==1,y]

In the top half of the ellipse , we have y≥0. Thus, we take the second solution, simplify, and define it as a function of x, a, and b

fa[x_,a_,b_]:=b (Sqrt[1-((x^2)/(a^2))])

Let the mass, the moment with respect to the x-axis, the moment with respect to the y-axis , and the center of mass be denoted by M(a,b), (Subscript[M, x])(a,b), (Subscript[M, y])(a,b), and ((OverBar[x])(a,b), (OverBar[y])(a,b)), respectively.  We now compute these quantities assuming ρ=1.

Clear[a,b,Mua,Mxua,Myua,xbaru,ybaru]
Mua[a_,b_]=(∫_(-a)^a)fa[x,a,b]\[DifferentialD]x
Mxua[a_,b_]=(1/2)(∫_(-a)^a)(((fa[x,a,b]))^2)\[DifferentialD]x
Myua[a_,b_]=(∫_(-a)^a)x fa[x,a,b]\[DifferentialD]x

xbarua[a_,b_]=((Myua[a,b])/(Mua[a,b]))
ybarua[a_,b_]=((Mxua[a,b])/(Mua[a,b]))

That  (OverBar[x])=0 is also clear from the fact that the density is a constant and the upper half of the ellipse is symmetric with respect to the y-axis.

The mass of the lamina, the moments of the lamina with respect to the x- and y-axis for various values of a and b are as follows:

umassa=TableForm[Table[Mua[a,b],{a,1,3},{b,1,3}],
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
uxmomenta=TableForm[ Table[Mxua[a,b]  ,{a,1,3},{b,1,3}] ,
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
uymomenta=TableForm[ Table[Myua[a,b]  ,{a,1,3},{b,1,3}]  ,
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
TableForm[{umassa,uxmomenta,uymomenta},TableHeadings->{{"Mass","x-moment","y-moment"},{}}]

The corresponding y-coordinate of the center of mass in each case is (recall that (OverBar[x])=0 for all cases)

centermassua=Table[((Mxua[a,b])/(Mua[a,b])),{a,1,3},{b,1,3}];
TableForm[centermassua,
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}]

The following animation shows how the center of mass changes as a and b varies.

plot4a[a_,b_]:=Plot[f[x,a,b],{x,-a,a},PlotRange->{{-5,5},{-15,15}},Filling->Axis];
plot5a[a_,b_]:=ListPlot[{{((Myua[a,b])/(Mua[a,b])),((Mxua[a,b])/(Mua[a,b]))}},PlotStyle->{Red,PointSize[0.02]}]
plotua[a_,b_]:=Show[plot4a[a,b],plot5a[a,b]]

Important Note:: If you are reading the printed version of this publication, then you will not be able to view any of the animations generated from the Animate command in this chapter.  If you are reading the electronic version of this publication formatted as a Mathematica Notebook, then evaluate each Animate command to view the corresponding animation.  Just click on the arrow button to start the animation.  To control the animation just click at various points on the sliding bar or else manually drag the bar.

Animate[plotua[a,b],{a,1,8},{b,1,10}]

b) Here, ρ=(e^(-x)). With the above notations modified to reflect variable density,  we have

Clear[a,b,Mv,Mxv,Myv,xbarv,ybarv]
 ρ[x_]=(E^(-x))
Mvb[a_,b_]=(∫_(-a)^a)ρ[x] fa[x,a,b]\[DifferentialD]x
Mxvb[a_,b_]=(1/2)(∫_(-a)^a)ρ[x] (((fa[x,a,b]))^2)\[DifferentialD]x
Myvb[a_,b_] =(∫_(-a)^a)ρ[x]  x fa[x,a,b]\[DifferentialD]x

xbarvb[a_,b_]=((Myvb[a,b])/(Mvb[a,b]))
ybarv[a_,b_]=((Mxvb[a,b])/(Mvb[a,b]))

Observe that the formulas for the mass and moments of the lamina are no longer elementary.  Here is a table of numerical values for these quantities assuming various choices for a and b:

umassb=TableForm[Table[Mvb[a,b],{a,1,3},{b,1,3}],
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
uxmomentb=TableForm[ Table[Mxvb[a,b]  ,{a,1,3},{b,1,3}] ,
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
uymomentb=TableForm[ Table[Myvb[a,b]  ,{a,1,3},{b,1,3}]  ,
TableHeadings->{{"a=1","a=2","a=3"},{"b=1","b=2","b=3"}}];
TableForm[N[{umassb,uxmomentb,uymomentb}],TableHeadings->{{"Mass","x-moment","y-moment"},{}}]

The coordinates for the center of mass are

centermassvb=N[Table[{((Myvb[a,b])/(Mvb[a,b])),((Mxvb[a,b])/(Mvb[a,b]))},{a,1,3},{b,1,3}]]

Here is a plot showing the two centers of mass with for uniform and variable density.

plot4b[a_,b_]:=Plot[f[x,a,b],{x,-a,a},PlotRange->{{-8,8},{-1,8}},AspectRatio->Automatic,Filling->Axis];
plot5b[a_,b_]:=ListPlot[{{((Myvb[a,b])/(Mvb[a,b])),((Mxvb[a,b])/(Mvb[a,b]))}},PlotStyle->{Green,PointSize[0.02]}]
plotvb[a_,b_]:=Show[plot4b[a,b],plot5b[a,b]]

Important Note:  If you are reading the printed version of this publication, then you will not be able to view any of the animations generated from the Animate command in this chapter.  If you are reading the electronic version of this publication formatted as a Mathematica Notebook, then evaluate each Animate command to view the corresponding animation.  Just click on the arrow button to start the animation.  To control the animation just click at various points on the sliding bar or else manually drag the bar.

Animate[plotvb[a,b],{a,1,8},{b,1,8}]

Exercises

1.  Suppose a lamina is lying underneath the graph of y=1+(x^2) over the interval [0,2] .
a) Assume the density of the lamina is ρ=3. Find the mass, moments, and the center of mass of the lamina. 
b) Assume the density of the lamina is ρ=2x. Find the mass, moments, and the center of mass of the lamina. 
c) Plot the lamina and the center of mass on the same axes for both parts a) and b) above.

2.  Suppose a lamina of constant density ρ=2 is in the shape of the astroid  (x^(2/3)) + (y^(2/3))=1.  Find its mass, moments, and center of mass.  Plot the lamina with its center of mass.

Chapter 9	Introduction to Differential Equations

9.1  Solving Differential Equations

Students should read Section 9.1 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

An ordinary differential equation is an equation that involves an unknown function, its derivatives, and an independent variable. Differential equations are useful for modeling many physical phenomena some of which are discussed in the next section.

Given a differential equation, our objective is to find all functions that satisfy it.  Mathematica's command for solving a differential equation is DSolve[eqn,y[x],x] where eqn is the differential equation to be solved and y[x] is the unknown function that depends on the independent variable x.

If the differential equation has initial conditions, we use braces { } to group the equation as well as the initial conditions (separated by commas): DSolve[{eqn,cond1,cond2,...,condn},y[x],x], where cond1, cond2,...,condn are initial conditions.

9.1.1. Separation of Variables

As discussed in your textbook, there is a special class of first-order differential equations that can be solved by hand using the method of separation of variables.  Mathematica can help in applying this method but of course it can solve the differential equation outright.  This makes Mathematica useful for verifying solutions obtained by other methods or for solving more complicated differential equations.  Since your textbook focuses on solving differential equations by hand, we will primarily discuss how to solve them using Mathematica.

Example 9.1.  Solve the given differential equation and plot the graph of the solutions.

a)  y'=2(4-y), y(0)=1		b)  (Sqrt[1-(x^2)])y'=x y		 c) y ((d y)/(d x)) +5x =0

Solution:

a) This is an initial value problem. Let us first solve this differential equation by hand using the method of separation of variables:
				(dy/dx)=2(4-y)	   ⟹ 	(dy/(y-4))=-2dx
							∫(dy/(y-4))=-∫2dx
							log|y-4|= -2x+C
							|y-4|= (e^(-2x+C))=(e^C)(e^(-2x))
							y-4=±(e^C)(e^(-2x))=C (e^(-2x)) (±(e^C) replaced by C)
This shows that the general solution is given by

y=C (e^(-2x))+4

It remains to determine the value of the constant C using the initial condition y(0)=1 (recall from your textbook that each value of C corresponds to a particular solution):

1=y(0)=C (e^(-2·0))+4=C+4

Thus, C=-3 and the unique solution is

y=-3 (e^(-2x))+4

Next, let us confirm this solution using Mathematica.  Recall that when entering a differential equation in Mathematica, we write y[x] instead of y to make explicit the dependence on x.

sola=DSolve[{y'[x]==2(4-y[x])},y[x],x]

This solution agrees with the solution obtained earlier by hand (the arbitrary constant C[1] is the same to the constant C).  We can visualize the behavior of the particular solutions by plotting some of their graphs for different values of C[1].  First, let us define the general solution to be g(x,c), where c=C[1] as follows (see Section 1.2.3 to learn how to extract elements from lists):

Clear[g,x,c]
g[x_,c_]=sola[[1,1,2]]/.C[1]->c

We then plot the one-parameter family of solution curves by combining the graphs of g(x,c) for c=-5,-4,...,5.

plotgeneralsolution=Plot[Table[g[x,c],{c,-5,5}],{x,-2,2},PlotRange->{-20,20},ImageSize->250]

Can you explain how the graph of g(x,c) varies as c varies?  Which c value corresponds to the top graph?

Next, to find the unique particular solution satisfying the given initial condition y(0)=1, we solve the equation g(0,c)=1 for c:

Solve[g[0,c]==1,c]

Thus, our unique solution is y=-3 (e^(-2x))+4.  This agrees with the solution we obtained earlier by hand.  Of course, Mathematica can solve for the unique solution on its own, bypassing the algebraic steps involved:

sola=DSolve[{y'[x]==2(4-y[x]), y[0]==1},y[x],x]

However, this unique solution does not appear to be the same as the one we obtained earlier.  To remedy this, let us extract solution from the output and define it as y=f(x):

f[x_]= sola[[1,1,2]]

We then apply the Expand command to simplify f(x):

Expand[f[x]]

Thus, the unique solution obtained by Mathematica is the same as the one obtained by hand.  Here is the plot of the unique solution:

plotuniquesolution=Plot[f[x], {x,-2,2},PlotRange->{-20,20},PlotStyle->Thickness[0.01],ImageSize->250]

Lastly, we combine plots of the general solution and the unique solution to show where the latter (bold graph) is situated in the former:

Show[{plotgeneralsolution,plotuniquesolution},ImageSize->250]

b)  From this point on, we shall skip using the method of separation of variables, which we leave for the reader to employ, and proceed directly to solving all differential equations using Mathematica as in part a) above.

solb=DSolve[(Sqrt[1-(x^2)])y'[x]==x y[x],y[x],x]

Again, we can visualize the behavior of these particular solutions by plotting graphs of some particular solutions corresponding to different values of C[1].  As before, we define the general solution to be g(x,c), where c=C[1].

Clear[g,x,c]
g[x_,c_]=solb[[1,1,2]]/.C[1]->c

We then make a combined plot of the graphs of g(x,c) for c=-5,-4,...,5.

Plot[Table[g[x,c],{c,-5,5}],{x,-2,2},ImageSize->250]

c) We again use Mathematica to directly obtain the solution:

Clear[y]
solde=DSolve[ y[x] y'[x]-5 x==0,y[x],x]

Observe that the two solutions, which we denote by f(x,c) and g(x,c), differ only in sign:

f[x_,c_]=solde[[2,1,2]]/.C[1]->c
g[x_,c_]=solde[[1,1,2]]/.C[1]->c

The following two plots show the graphs of f(x,c) and g(x,c) corresponding to c=-50, -40,...,0,..., 40,50.

Plot[Table[f[x,c],{c,-50,50,10}],{x,-5,5},PlotRange->{0,10},ImageSize->250]

Plot[Table[g[x,c],{c,-50,50,10}],{x,-5,5},PlotRange->{-10,0},ImageSize->250]

Observe that the two solutions y=-(Sqrt[5(x^2)+2c]) and y=(Sqrt[5(x^2)+2c])can be represented by a single equation:

(y^2)-5(x^2)=2c

which describes a family of hyperbolas. Here is a contour plot of this equation.  Observe that it nothing more than a combination of the two plots above as to be expected.

ContourPlot[(y^2)-5(x^2),{x, -5,5}, {y,-10,10}, Frame->False, Axes->True,ContourShading->False,Contours->10,ImageSize->250]

Exercises

In Exercises 1 through 8, solve the given differential equations.  If initial conditions are also given, then plot the unique solution.  If not, then make a combine plot of several particular solutions by choosing various values of the arbitrary constant.  Then describe the graphs and explain how they vary as the arbitrary constant varies.

1.  (1+(x^2))y'=(x^(2 ))y; y(0)=2		2.  y'+3(x^4)(y^2)=0; y(0)=1
3.  y'+(y^2)=-1; y(0)=-1			4.  y'+3 y=sin x; y(0)=0

5.  y'=-2x y (bell-shaped curves)		6.  16y y'+9x=0
7.  y'- y=(y^2)					8. 2x y y'-(y^2)+(x^2)=0

9. Consider the differential equation

(3+2 y)y'=2-(e^x),  y(0)=a

a) Solve the equation.
b) Plot the graphs for values of a=-2,-1, 0, 1, 2.
c) Plot the graphs for the values of a=-.5, -.1, .1,.5.
NOTE: For parts b) and c), make sure to use a sufficiently large interval for x.

10. Consider the differential equation

y=x y (b-y)/(4+x),    y(0)=a

a) Solve the equation.
b) Plot the graphs for values of a=-2,-1, 0, 1, 2  and b=-2, -1, 0, 1, 2.
c) Plot the graphs for the values of a=-.5, -.1, .1,.5 and b=-.5, -.1, .1,.5
d) Show that the limit as x-> ∞ of the solution does not depend on a. Does the limit depend on b? If so, how?

11. Suppose a skydiver falls from rest toward the earth and assume that the air resistance caused by his open parachute is  proportional to the square of his velocity v with proportionality constant k (we neglect air resistance due to the skydiver himself).  A model for describing the skydiver's velocity after his parachute opens is then given by the differential equation

v'=-(k/m)((v^2)-((m g)/k))

where m is the mass of the skydiver and g=9.8 meters/(sec^2) is his acceleration due to gravity.

a) Solve the equation assuming an initial velocity v(0)=(Subscript[v, 0]).
b) Suppose that for a particular skydiver m=70 kg and k=30 kg/meter.  Solve the equation again using these values and plot the particular solutions for the following values of (Subscript[v, 0]): 0, 2, ..., 10.
c) What is the skydiver's limiting (terminal) velocity as t->∞ for each of the particular solutions in part b)?  Does it depend on (Subscript[v, 0])?
d) Find a formula for the terminal velocity in terms of m, g, and k.

12. Recall that the first-order linear differential equation y'+y=0 has solution y=C (e^(-x)).  Solve the following higher-order generalizations of this equation:

a) y''+2y'+y=0
b) y'''+3y''+3y'+y=0
c) (y^((4)))+4y'''+6y''+4y'+y=0
d) Do you recognize the coefficients involved in the differential equations above?  What would be the next differential equation (of order 5) that follows this pattern?  Solve this differential equation to verify that its solution follows that same pattern exhibited in parts a) through c).

9.2  Models of the Form y'=k(y-b)

Students should read Section 9.2 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

NOTE: The differential equations we encounter in this section can be solved by the method of separation of variables and is discussed in the text. We leave it to the reader to solve the examples in this section by hand to verify the solutions obtained using Mathematica.

9.2.1. Bacteria Growth

The growth of bacteria in a culture is known to be proportional to the amount of the bacteria present at time t.  Suppose the initial amount of the bacteria is (Subscript[y, 0]) and the amount at time t is y(t). Then the above physical law is modeled by the differential equation

y'=k y,           y(0)=(Subscript[y, 0])

where k is the proportionality (growth) constant. Such a model exhibits exponential growth as can be seen from its solution below:

Clear[k]
DSolve[{y'[x]==k*y[x],y[0]==y0},y[x],x]

NOTE: Since the bacteria is growing in number, y(t) is increasing and hence y'(t)>0. Thus, k must be a positive number.

Example 9.2.  Suppose the amount of bacteria in a culture was 200 at time t=0.  It was found that there were 450 bacteria after 2 minutes.
a) Find the amount of the bacteria at any time t.   
b) At what time will the number of bacteria exceed 10,000?

Solution:

a) First, note that y(0)=200 and y(2)=450. We solve the differential equation y'=k y with the former as the initial condition:

Clear[y,t,k]
solde=DSolve[{y'[t]==k y[t],y[0]==200},y[t],t]

f[t_]=solde[[1,1,2]]

To find the value of k we solve f(2)=450 for k.

solk=Solve[f[2]==450,k]

N[%]

Thus, the proportionality constant is k=(1/2)l n(9/4)≈0.405465. Substituting this value into y(t), we see that the amount of bacteria at a given time t is

y(t)=200 (e^(0.405465 t))

b) To find the amount of time it takes for the bacteria to exceed 10,000, we solve

k=solk[[1,1,2]]
Solve[f[t]==10000,t]

We can approximate this value for t by

N[%]

Thus, it takes about 9.64824 minutes for the bacteria to reach 10,000. To visually see this, we plot the graphs of the solution y(t)=200 (e^(0.405465 t)) (blue curve) and y=10000 (red line) on the same axes.

Plot[{f[t],10000}, {t, 0, 15},PlotStyle->{Blue,Red},ImageSize->250]

NOTE: The solution y(t)=200 (e^(0.405465 t)) is only approximate since we approximated the growth constant k.  By using the exact value for k=(1/2)l n(9/4)=l n(3/2), we can derive the exact solution:

y(t)=200 (e^(k t))=200 (e^( t ln(3/2)))=200 (e^( ((ln((3/2)))^t)))=200((((3/2)))^t)

This agrees with the answer obtained by Mathematica:

f[t]

9.2.2. Radioactive Decay

The differential equation y'=k y is also used to model the amount of a radioactive substance whose rate of decay is proportional to the amount present.  However, in this case we note that the proportionality constant k<0. (Explain this!)

Example 9.3.  Carbon dating is a method used to determine the age of a fossil based on the amount of radioactive Carbon-14 in it compared to the amount normally found in the living environment. Suppose that a bone fossil contains 5% of the amount of Carbon-14 normally found in living animals. If the half-life of Carbon-14 is 5600 years, estimate the age of the bone.

Solution: Let y(t) be the amount of Carbon-14 in the bone and let (Subscript[y, 0]) be the initial amount of Carbon-14. Then the differential equation we need to solve is

Clear[k,y,y0]
solde=DSolve[{y'[t]==k y[t],y[0]==y0} , y[t],t]

Thus, the solution to the differential equation is y(t)=(Subscript[y, 0])(e^(k t)).  The half-life of Carbon-14 is 5600 implies that y(5600)=(1/2)(Subscript[y, 0]). We solve this equation for k:

y[t_]=solde[[1,1,2]]
solk=Solve[y[5600]==(1/2)y0,k]

N[%]

Thus, k=-0.000123776. To find the age of the bone, we solve y(t) = 0.05(Subscript[y, 0]) (5% of the initial amount) for t.

k=-((Log[2])/5600);
Solve[y[t]==0.05y0,t]

Thus, the bone is about 24,203 years old. Observe that it not necessary to know the original amount (Subscript[y, 0]) of Carbon-14 in the bone.

9.2.3. Annuity

An annuity is an  investment in which a principal amount of money is placed in a bank account that earns interest at an annual rate (compounded continuously) and the money is withdrawn at a regular interval. The differential equation that models an annuity is given by the annuity equation (rate of change = growth due to interest - withdrawal rate):

P'(t)=r P(t)-W =r(P(t)-(W/r))

where P(t) is the balance in the annuity at time t, r is the interest rate, and W is the rate (dollars per year) at which money is withdrawn continuously.

Example 9.4.  Find the general solution of the annuity equation for P(t) and then use it to calculate the following:
a) Assume r=6% and W=$ 6000 per year and P(0)=$ 50000.  Find P(t) and determine if and when the annuity runs out of money.
b) Assume r=6% and W=$ 6000 per year and P(0)=$ 100000.  Find P(t) and determine if and when the annuity runs out of money.
c) Assume r=6% and W=$ 12000 per year.  If we want the annuity to run out of money after 20 years, how much should be invested now?

Solution: We solve

DSolve[P'[t]==r(P[t]-(W/r)),P[t], t]

Thus, the general solution is P(t)=W/r+c (e^(r t)).

a) We set r=0.06, W=6000, and solve the initial value problem:

Clear[r,W,P]
r=0.06;
W=6000;
solde=DSolve[{P'[t]==r(P[t]-(W/r)),P[0]==50000},P[t], t]

We then define P(t) to be the solution above and plot it to see when the money will run out.

P[t_]=solde[[1,1,2]]
Plot[P[t], {t, 0,15},ImageSize->250]

As the graph indicates, the money runs out after approximately 11.5 years. We can confirm this by solving P(t)=0:

NSolve[P[t]==0,t]

b) We repeat the procedure in part a) with the obvious modifications:

Clear[r,W,P]
r=0.06;
W=6000;
solde=DSolve[{P'[t]==r(P[t]-(W/r)),P[0]==100000},P[t], t];
P[t_]=solde[[1,1,2]]
Plot[P[t], {t, 0, 80},ImageSize->250]

Observe that the balance P(t)=100,000 remains constant (can you explain why?) and thus the account will never run out of money.  What happens if we invest $100,001? $99,999?

c) In this case, we have r=0.06 and W=10000 per year.  The general solution is then given by

Clear[r,W,P,c]
r=0.06;
W=12000;
dsol=DSolve[{P'[t]==r(P[t]-(W/r)),P[0]==c},P[t], t];
P[t_]=dsol[[1,1,2]]

To determine the principal amount that will make the account run out of money in 20 years, we solve P(20)=0 for c:

NSolve[P[20]==0,c]

Thus, we need to invest $139,761.00 now.

9.2.4. Newton's Law of Cooling

Newton's Law of Cooling states that the rate of change in the temperature of an object is proportional to the difference between its temperature and that of the surrounding environment (known as the ambient temperature).  If A is the ambient temperature and T(t) is the temperature of the object at time t, then the differential equation that models this law is

T'(t)=-k(T(t)-A),   T(0)=(Subscript[T, 0])

where (Subscript[T, 0]) is the initial temperature of the object and k is a positive proportionality constant.

Example 9.6.  The temperature in an oven is (350^°) F when the oven is turned off. After 15 minutes, the temperature is (250^°) F.  Assume the temperature in the house is (70^°) F.

a) Find the temperature of the oven at any time t.
b) At what time will the temperature become (75^°) F? 
c) What will the temperature be in the limit as t-> ∞?
d) Does your answer in c) conform with your physical intuition?

Solution:

a) The ambient temperature here is room temperature.  Hence, A=70.  The initial temperature is (Subscript[T, 0])=350.  Newton's Law of Cooling then gives the model

T'(t)=-k(T(t)-70)),   T(0)=350

We solve this equation to get

Clear[T,k]
sol=DSolve[{T'[t]==-k (T[t]-70),T[0]==350},T[t],t]

T[t_]=sol[[1,1,2]]

Thus, the solution is T(t)=70(e^(-k t))(4+(e^(k t))) or T(t)=70+280 (e^(-k t)). To find the value of k, we solve T(15)=250 for k:

solk=Solve[T[15]==250,k]

k=solk[[1,1,2]]

N[%]

Thus, k=((ln(14/9))/15)=0.0294555.  Hence, the temperature of the oven at any time t is given by

T(t)=20+280(e^(-0.029455516818602614`t))

b) We solve T(t)=75 for t:

NSolve[T[t]==75, t]

Thus, the temperature will be (75^°) F after about two hours and 17 minutes.

c) We make a plot of the solution:

Plot[T[t], {t, 0, 100},AxesOrigin->{0,0},ImageSize->250]

To find the limiting temperature, we evaluate

Limit[T[t], t->Infinity]

d) Since heat flows from a region of higher temperature to a region of lower temperature, it is intuitively clear that the oven will cool down to the room (ambient) temperature.  Hence, the limit should be (70^°) F as expected.

Exercises

1. Mass of bacteria in a culture grow at a rate proportional to its size. Suppose the culture contains 200 cells intially and there are 800 cells after 3 hours.

a) Find the formula for the number of cells in the culture at time t.
b) Find the amount of bacteria after 2 hours.
c) At what time will the bacteria exceed 10,000 cells?

2. A mummy excavated from an archaelogical site in Egypt is found to contain 20% of Carbon-14 normally found in living humans.  Use carbon dating to estimate the age of the mummy.

3. Plutonium-239 is a highly radioactive element generated from waste in nuclear power plants and has a half-life of approximately 24,000 years.  How many years would it take for Plutonium-239 to decay to a safe level of 1/1000 its original amount?

4. Solve the following using the annuity differential eqaution discussed in this section.
a) Assume r=6% and W=$500 per year and P(0)=$5,000. Find P(t) and determine when the annuity runs out of money.
b) Assume r=6% and W=$500 per year and P(0)=$9,000. Find P(t) and determine when the annuity runs out of money.
c) Assume r=6% and W=$20,000 per year.  If we want the annuity to run out after 40 years, how much should we invest now?

5. Suppose a retired worker wants to invest in an annuity that will pay out $10,000 per year.
a) Assuming the annuity has an interest rate of 5%, find the minimum principal amount that should be invested so that the annuity never runs out of money.
b) Assuming the principal amount of money invested is $250,000, find the minimum interest rate that the annuity should bear so that it never runs out of money.

6. A hot metal rod is placed in a water bath whose temperature is  40° F. The rod cools from 300° F to 200° F in 1 minute. How long will take the rood to cool down to 150° F?  45° F?

9.3  Numerical Methods Using Slope Fields

Students should read Section 9.3 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

9.3.1.  Slope Fields

Consider a differential equation in the form

y'=f(x,y)

Since y' represents the slope of the line tangent to the graph of the solution y, we can think of f(x,y) as the slope of the same tangent line at the point (x,y), which we indicate by drawing a segment of it at the point of tangency.  The set of all such line segments (normalized to have the same length) is called the slope (or direction) field of the differential equation. Note that the slope field gives a graphical approximation to the solution.  It enables us to draw or visualize the graph of the unique solution of the equation passing through a given point. We will illustrate this in an upcoming example.

To plot the slope field of the differential equation y'=f(x,y) along the intervals (a,b) and (c,d) on the x- and y-axis, respectively, we use the command VectorPlot[{1, f[x, y]}, {x, a, b}, {y, c, d}], where slope is represented as a two-dimensional vector (1,f(x,y)) with the change in x normalized to equal 1.

NOTE: The command VectorPlot replaces the command VectorFieldPlot, which is obsolete in version 7 of Mathematica.

Example 9.9.  Consider the differential equation y'=(x^2)-2y, y(0)=-1.

a)  Draw the slope fields for the differential equation.
b)  Solve the differential equation.
c)  Plot both the slope field and the solution on the same axes.
d)  Redo parts b) and c) for the same equation but with initial condition given by y(a)=b.  Choose various values for a and b.

Solution:

a) Here, f(x,y)=(x^2)-2y.  We use the VectorPlot command to plot the corresponding slope field:

f[x_,y_]:=(x^2)-2y

plot1=VectorPlot[{1,f[x,y]},{x, -5,5},{y,-10,10},Axes->True,Frame->False,VectorScale->{Tiny,Tiny,None},ImageSize->250]

b) We use the DSolve command to find the exact solution of the differential equation.

Clear[y,x,g]
sol=DSolve[{y'[x]==f[x,y[x]],y[0]==-1},y[x],x]
g[x_]=sol[[1,1,2]]

c) We now plot the slope field together with the solution above passing through the point (0,-1):

plot2=Plot[g[x],{x,-5,5}, PlotRange->{-10,10},ImageSize->250]

Show[plot1,plot2,Graphics[{PointSize[Large],Point[{0,-1}]}],ImageSize->250]

d) We can show several graphs of solution curves (called integral curves) together with the corresponding slope field. Here is an example of how this can be done.

Clear[y,x,h,a,b]
sola=DSolve[{y'[x]==f[x,y[x]],y[a]==b},y[x],x];
h[x_,a_,b_]=Simplify[sola[[1,1,2]]]

plot3=Plot[Evaluate[Table[h[x,a,b],{a,-3,3,2},{b, -3,3,2}]],{x,-5,5},PlotRange->{-10,10}];
Show[plot1,plot3,ImageSize->250]

9.3.2.  Euler's Method

The simplest numerical method for solving a first order differential equation is Euler's Method. This method approximates the solution by moving along tangent lines described by the slope field of the differential equation.  Here is a brief description.

Let y=ϕ(x) be the solution of the differential equation

y'=f(x,y), y((Subscript[x, 0]))=(Subscript[y, 0])

Then the equation of the line tangent to the graph of y=φ(x) at x=(Subscript[x, 0]) is given by

y=φ'((Subscript[x, 0]))(x-(Subscript[x, 0]))+φ((Subscript[x, 0]))

But when x=(Subscript[x, 0]), we have φ((Subscript[t, 0]))=(Subscript[y, 0]) and φ'((Subscript[x, 0]))=f((Subscript[x, 0]),(Subscript[y, 0])). Thus, when x is close to (Subscript[x, 0]), φ(x) can be approximated by

y≈f((Subscript[x, 0]),(Subscript[y, 0]))(x-(Subscript[x, 0]))+(Subscript[y, 0])

We now choose h>0 to be a small positive number, called the step size, and define (Subscript[x, 1])=(Subscript[x, 0])+h. Then φ((Subscript[x, 1])) is approximately equal to

(Subscript[y, 1])=(Subscript[y, 0])+f((Subscript[x, 0]),(Subscript[y, 0]))((Subscript[x, 1])-(Subscript[x, 0]))

or

(Subscript[y, 1])=(Subscript[y, 0])+h f((Subscript[x, 0]),(Subscript[y, 0]))

We repeat the above argument at the point ((Subscript[x, 1]),(Subscript[y, 1])) to get an approximation of φ((Subscript[x, 2])), where (Subscript[x, 2])=(Subscript[x, 1])+h=(Subscript[x, 0])+2h:

(Subscript[y, 2])=(Subscript[y, 1])+h f((Subscript[x, 1]),(Subscript[y, 1]))

Proceeding in this manner, we obtain Euler's Method:

(Subscript[y, n+1])=(Subscript[y, n])+h f((Subscript[x, n]),(Subscript[y, n]))  for n=0, 1, 2, 3, ....

where φ((Subscript[x, n]))≈(Subscript[y, n]).

If the approximated solution is calculated over an interval [a,b] and the step size h is specified, then the number of iterations (or steps) required is given by m=(b-a)/h, where (Subscript[x, 0])=a and (Subscript[x, n])=(Subscript[x, 0])+n h.

Here is a Mathematica program called Euler for evaluating Euler's Method in m steps (the option SetPrecision sets the precision of our calculations to 10 digits).

Clear[f,x,y,x0,y0,h, m]
Euler[f_,h_,m_]:=Module[{n},
Do[
y[n+1]=SetPrecision[N[y[n]+h*f[x[n],y[n]]],10];
x[n+1]=x[n]+h,
{n,0,m}]]

Example 9.7.  Use the Euler program to construct a table of solution values for the differential equation y'=(x^2)+2y, y(0)=1 with a step size of h=0.1 and for m=10 steps.

Solution: Here f(x,y)=(x^2)+2y, (Subscript[x, 0])=0, (Subscript[y, 0])=1.

f[x_,y_]:=(x^2)+2y
m=10;
x0=0;
y0=1;
h=0.1;
x[0]=x0;
y[0]=y0;
Euler[f,h,m]
TableForm[Table[{n,x[n],y[n]},{n,1,m}],TableHeadings->{{},{"n ","(Subscript[x, n])","(Subscript[y, n])" }}]

To see how accurate the above approximation is, we solve the differential equation for the exact solution and plot both the approximate and exact solutions on the same axes.

Clear[z,t,exact]
exact=DSolve[{z'[t]==f[t,z[t]],z[x0]==y0},z[t],t];
z[t_]=z[t]/.exact[[1]]

Clear[plot1,plot2]
plot1=Plot[z[t],{t,0,1} ];
plot2=ListPlot[Table[{x[n],y[n]},{n,0,m}],PlotStyle->PointSize[0.01] ];
Show[{plot1,plot2},ImageSize->250]

Observe that the approximations become less accurate as we move away from the initial point (0,1). This is typical of numerical methods such as Euler's Method.  However, we can increase the accuracy of our approximation by decreasing the step size.  For example, we recompute the solution using h=0.05 (this increases the number of steps to m=20):

h=0.05;
m=20;
Euler[f,h,m]
TableForm[Table[{n,x[n],y[n]},{n,1,m}],TableHeadings->{{},{"n ","(Subscript[x, n])","(Subscript[y, n])" }}]

The following plot of the two numerical solutions corresponding to h=0.1 (small blue dots) and h=0.05 (large red dots) clearly shows that the latter is more accurate in comparison to the exact solution (curve):

plot3=ListPlot[Table[{x[n],y[n]},{n,0,m}],PlotStyle->{PointSize[0.01],Red,PointSize[0.015] }];
Show[{plot1,plot2,plot3},ImageSize->250]

Here is a modification of the Euler progam that allows the user to input the endpoints a and b directly (instead of the step size h) and m.

Clear[f,x,y,h,a,b,m]
EulerEndpt[f_,a_,b_,m_]:=Module[{n,h},h=N[((b-a)/m)];
Do[
y[n+1]=SetPrecision[N[y[n]+h*f[x[n],y[n]]],10];
x[n+1]=x[n]+h,
{n,0,m}]]

Example 9.8.  For the differential equation y'=(x^2)+2y, y(0)=1, approximate its solution over the interval [0,2] using m=10 steps.

Solution: Again, we have f(x,y)=(x^2)+y, (Subscript[x, 0])=0, (Subscript[y, 0])=1.  However, we now input the interval [a,b]=[0,2] into EulerEndPt.

f[x_,y_]:=(x^2)+y
m=10;
x0=0;
y0=1;
x[0]=x0;
y[0]=y0;
a=0;
b=2;

EulerEndpt[f,0,2,m]
TableForm[Table[{n,x[n],y[n]},{n,1,m}],
TableHeadings->{{},{"n ","(Subscript[x, n])","(Subscript[y, n])" }}]

This time we numerically compare the approximate solution with the exact solution:

Clear[z,t,exact]
exact=DSolve[{z'[t]==f[t,z[t]],z[x0]==y0},z[t],t];
z[t_]=z[t]/.exact[[1]]
TableForm[Table[{n,x[n],y[n],N[z[x0+n(b-a)/m]]},{n,1,m}],
TableHeadings->{{},{"n ","(Subscript[x, n])","(Subscript[y, n])","y(n)" }}]

Exercises

In Exercises 1 through 4, plot the slope field of the given differential equations:
1.  y'=(x^2)+(y^2)		2.  y'=(t^2)y		3.  y'=sin(x+y)		4.  y'=x (e^(-y))

5. Consider the differential equation  y'=3y-2(y^2).
a) Draw the slope field for the differential equation.
b) Solve the differential equation.
c) Assume y(0)=2.  Plot the graph of the solution for this case and also the slope field on the same axes.  Discuss the behavior of the solution as x->∞.
d)  Redo part c) for the same differential equation but with initial condition given by y(a)=b (choose various values for a and b).

In Exercises 6 through 9, use Euler's Method to find a numerical solution to the given initial value problem along the stated interval and using the prescribed number of steps.  Also, find their exact solutions and compare the results.
6.  y'=(x^2)-y,  y(0)=1; [0,1]; m=10	7.  y'=(1-(x^2)) cos y,  y(1)=0; [1,2]; m=20	8.  y'-(y^2)=x,  y(0)=1; [0,5]; m=50		9.  y'=-3x/2+ln((x^2)+y),  y(1)=1; [1,2]; m=100

10. Heun's method is a numerical method that improves on Euler's method.  It uses the approximation from Euler's method as an auxiliary value (called a predictor), which we denote by (Subscript[y, n+1]^( * )):

(Subscript[y, n+1]^( * ))=(Subscript[y, n])+h f((Subscript[x, n]),(Subscript[y, n]))

The actual approximation (called the corrector) is then computed as the mean of (Subscript[y, n+1]^( * )) (based on the slope of the tangent line at ((Subscript[x, n]),(Subscript[y, n]))) and (Subscript[y, n+1]^( ** ))=(Subscript[y, n])+h f((Subscript[x, n+1]),(Subscript[y, n+1]^( * )))  (based on the slope of the tangent line at ((Subscript[x, n+1]),(Subscript[y, n+1]^( * )))):

(Subscript[y, n+1])=(1/2)[(Subscript[y, n+1]^( * ))+(Subscript[y, n+1]^( ** ))] =(Subscript[y, n])+(1/2)[h f((Subscript[x, n]),(Subscript[y, n]))+h f((Subscript[x, n+1]),(Subscript[y, n+1]^( * )))]

a) Apply Heun's method to Exercise 6 and the compare the results obtained by Euler's method with the exact solution.  How much more accurate is Heun's method?
b) Redo part a) using m=20.  How much more accurate is the solution compared to that for m=10?

9.4  The Logistic Equation

Students should read Section 9.4 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

The differential equation

((d y)/(d t))=k y(1-(y/A))

is called the logistics equation. Here, k>0 and A is a constant called the carrying capacity.  This equation is useful for modeling the growth of a population where resources are limited and can only sustain a certain maximum population given by the carrying capacity.

Example 9.5.   The population p(t) of mosquito larvae growing in a tree hole increases according to the logistics equation with growth constant k=0.3 per day and carrying capacity A=1000.

a) Assuming that the initial population of the larvae is 50, find the population p(t) at any time t. 
b) After how many days will the larvae population exceed 500?
c) When does the larvae population reach 99% of the maximum capacity?

Solution:  
a) We use k=(3/10) and solve the corresponding differential equation in Mathematica:

Clear[y]
solde=DSolve[{y'[t]==(3/10) y[t](1-((y[t])/1000)), y[0]==50}, y[t],t]

NOTE:  Be careful with using a decimal approximation for k.  For example, try using k=0.3 and see what happens.

Next, for convenience we write the solution given in the previous output as

Clear[p,t]
p[t_]=solde[[1,1,2]]

Thus, the population of larvae at any time t is given by

p(t)=((1000 (e^(3 t/10)))/(19+(e^(3t/10))))

b) To find how long it takes for the larvae population to reach 500, we solve

NSolve[p[t]==500,t]

Thus, it takes about ten days for the larvae population to exceed 500.  Observe that p(10)≈513.887.

NOTE: We ignored the other two solutions in the previous output since they are complex-valued and not physically relevant.

c) We first plot the graph of p(t) to estimate the number of days required for the larvae population to reach 99% of the maximum capacity, that is, p(t)=999.

Plot[p[t], {t,0, 60},ImageSize->250]

It appears that the population reaches 999 larvae after t=30. We use the Table command to numerically confirm this.

TableForm[Table[{t,N[p[t],20]}, {t, 10, 50, 5}],TableHeadings->{{},{"Days     ", "Larvae Population"}}]

We can reasonably conclude from the table that the population reaches 999 larvae between 30 and 35 days. To obtain a more precise answer, we use Mathematica to solve p(t)=999 for t:

NSolve[p[t]==999,t]

Thus, the desired time is approximately t=33 days.

Exercises

1. A population of squirrels live in a forest with a carrying capacity of 3000. Assume logistic growth with growth constant k=0.8 per year.
a) Find the population of the squirrels at any time t assuming an initial population of P(0)=800.
b) How long will it take for the squirrel population to double?  Triple?

2. From 1960 to 2000, the world's population doubled from approximately 3 billion to 6 billion people.  Assuming that the human population follows logistic growth and that the earth has a carrying capacity of 100 billion people, determine the following:
a) Find the population at any time t.  What is the growth constant?
b) What will the population be in the year 2050?  How does this answer compare with projections from the United Nations?
c) Find the year in which the human population will reach half its carrying capacity?
d) When will the population grow the fastest, that is, the point on the graph where it changes from concave up to concave down (point of inflection)? What is the growth rate then?

3. In medicine, the logistics equation is used to model the growth of tumors in certain organs.  Suppose a patient is diagnosed with a tumor that has doubled in size to 2% of his liver when a year ago it only covered 1% of his liver.  How long will it take the tumor to grow to 10% of his liver when a transplant will most like by required to increase his chances of survival.

4. The current population of a herd of bison living inside a national park is 1000.  To ensure that the population does not reach more than 1500 bison in 50 years time and 2000 bison in 100 years time, what carrying capacity should the park maintain?  Assume that the bison population follows a logistics model.

Chapter 10 	Infinite Series

10.1 Sequences

Students should read Section 10.1 of Rogawski’s Calculus [1] for a detailed discussion of the material presented in this section.

Recall that a sequence is a function whose domain is the set of non-negative integers.

In Mathematica, we denote a sequence (Subscript[a, n]) as a function. Thus, instead of (Subscript[a, n  ])we write a(n). The limit of a sequence is evaluated by using the Limit command. When Limit[a[n], n->∞] is evaluated, Mathematica automatically assumes that n is a continuous variable (instead of a discrete variable). It employs various techniques to evaluate limits.

To plot the graph of a sequence, we use the ListPlot command. ListPlot[list] plots the graph of list, where list is a list of points (x,y), denoted in Mathematica by {x,y}. In our case, list will be the table of values of the form {n,a[n]}.  The corresponding plot command in this case would be ListPlot[Table[{n,a[n]},{n,min,max}].

Example 10.1.  Consider the sequence defined by

(Subscript[a, n])=((4n+1)/(3n+2))

a) Find the first few terms of the sequence.

b) Plot the graph of the sequence.

c) Make a conjecture for the limit based on the graph.

d) Find the limit of the sequence.

Solution:

a) We define the sequence as a function of n and use the Table command to generate the first ten terms of the sequence.

Clear[a,n]
a[n_]:= ((4 n+1)/(3 n+2))

TableForm[Table[{n,a[n]},{n,1,10}],
TableHeadings->{{},{"n","(Subscript[a, n])"}}]

To obtain decimal expressions of these values, we evaluate

TableForm[N[Table[{n,a[n]},{n,1,10}]],
TableHeadings->{{},{"n","(Subscript[a, n])"}}]

b) To plot the graph of the sequence, we use the ListPlot command. Here is a plot of the first 100 terms of the sequence.

ListPlot[Table[{n, a[n]}, {n, 1, 100}]]

c) The graph suggests that the limit is 1.333....  We can use the Table command to see this more clearly.

TableForm[N[Table[{n,a[n]},{n,1000,10000,1000}]],
TableHeadings->{{},{"n","(Subscript[a, n])"}}]

Hence, the limit seems to be 1.3333... or 4/3. Here is a plot of y=4/3 and the graph of the sequence for large values of n:

Clear[plot1,plot2]
plot1=ListPlot[Table[{n, a[n]}, {n, 1, 1000,10}]];
plot2=Plot[4/3, {x, 1, 1000}];
Show[plot1, plot2,PlotRange->{1.25,4/3}]

d) Finally, we confirm this in Mathematica by evaluating the limit as n goes to ∞.

Limit[a[n],n->Infinity]

Example 10.2.  Consider the sequence defined by

(Subscript[a, n])=((((-1))^n)/n)

a) Plot the graph of the sequence.

b) Does the sequence converge?

Solution:

a) Again, we use ListPlot to plot the graph.

Clear[a,n] 
a[n_]:=((((-1))^n)/n)

ListPlot[Table[{n, a[n]}, {n, 1, 100}]]

b) From the graph, it is clear that the sequence approaches 0 in the limit. We confirm this using the Limit command.

Limit[a[n],n->Infinity]

NOTE: There are instances where the sequence (Subscript[a, n]) may not be well-defined if n  is treated as a real variable (as opposed to an integer variable). In such cases, Mathematica may return the limit unevaluated or else gives an output that indicates the limit may not exist, as the following example illustrates.

Example 10.3.  Determine whether or not the sequence defined below converges:

(Subscript[a, n])=(((-1))^n)(n/(n+1))

Solution: First, we will plot the graph of the sequence.

Clear[a,n]
a[n_]:=(((-1))^n)(n/( n+1))

ListPlot[Table[{n, a[n]}, {n, 1, 100}]]

The graph clearly indicates the sequence does NOT converge (to a unique limiting value). We can see this by investigating the following tables of values. The first one lists the even terms while the second one lists the odd terms of the sequence.

TableForm[Table[{n,N[a[2n]]},{n,10,100,10}],
TableHeadings->{{},{"n","(Subscript[a, 2n])"}}]

TableForm[Table[{n,N[a[2n-1]]},{n,10,100,10}],
TableHeadings->{{},{"n","\!\(\*Cell[TextData[Cell[BoxData[
FormBox[
SubscriptBox["a", 
RowBox[{
RowBox[{"2", "n"}], "-", "1"}]], TraditionalForm]]]]]\)"}}]

Finally, let us evaluate the limit.

Limit[a[n],n->Infinity]

This output, specifically the notation Interval[{0, π}], means that the limit does not exist uniquely, but has subsequences whose limits take on the set of complex values (e^(2i x)) for all x∈[0,π].  This is because the variable n that appears in the Limit command is automatically assumed by Mathematica to be a complex variable.  In our case, for n an integer variable, we have two subsequences, (Subscript[a, 2n]) and (Subscript[a, 2n+1]) (even and odd, respectively), converging to different limits (1 and -1, respectively).  Thus, (Subscript[a, n]) diverges.

Example 10.4.  Consider the sequence {(Subscript[a, n])} defined recursively by (Subscript[a, 1])=1 and (Subscript[a, n+1])=(Sqrt[(Subscript[a, n])+1]).  Generate the first ten terms of this sequence and compute its limit.

Solution: Here is one method of defining a recursive sequence.

Clear[a,n]
a[1]=1
a[n_]:=a[n]=Sqrt[a[n-1]+2]

NOTE: The second occurrence of a[n] in the preceding command tells Mathematica to store all intermediate values of the recurrence in evaluating a[n].

Here are the first ten terms of the sequence:

TableForm[Table[{n,a[n]},{n,1,10}],
TableHeadings->{{},{"n","(Subscript[a, n])"}}]

The following table gives decimal expressions of the same first ten terms and reveals the limit to be equal to 2.

TableForm[Table[{n,N[a[n]]},{n,1,10}],
TableHeadings->{{},{"n","(Subscript[a, n])"}}]

NOTE: In general, Mathematica is not able to directly compute limits of sequences defined recursively.  Assuming (Subscript[a, n]) converges (prove this!), we then compute its limit, called L, say, by letting n->∞ in the recurrence formula for (Subscript[a, n]):

L=(lim_(n->∞))(Subscript[a, n])=(lim_(n->∞))(Sqrt[(Subscript[a, n-1])+2])=(Sqrt[(lim_(n->∞))(Subscript[a, n-1])+2])=(Sqrt[L+2])

Solving the equation L=(Sqrt[L+2]) then yields L=2 as the limit.

Solve[L==Sqrt[L+2],L]

Example 10.5.  Let (Subscript[a, 1])=1 and (Subscript[b, 1])=(Sqrt[2]).  Define two sequences recursively by

(Subscript[a, n+1])=(Sqrt[(Subscript[a, n])(Subscript[b, n])])  and (Subscript[b, n+1])=(((Subscript[a, n])+(Subscript[b, n]))/2)

a) Choose various values of (Subscript[a, 1]) and (Subscript[b, 1]) and calculate the first ten terms of the sequences {(Subscript[a, n])} and {(Subscript[b, n])}.

b)  Show that (Subscript[a, n])≤(Subscript[b, n]) for every positive integer n.

c) Show that both sequences converge to the same limit.  (NOTE: This common limit is called the arithmetic-geometric mean of (Subscript[a, 1])and (Subscript[b, 1]).)

Solution:

a) Here is a program that generates the first ten values of (Subscript[a, n]) and (Subscript[b, n]).

Clear[a,b,n]
a[1]=1
b[1]=10
a[i_]:= a[i]= (Sqrt[a[i-1]*b[i-1]]) ;
b[i_]:= b[i]= ((a[i-1]+b[i-1])/2) ;

TableForm[Table[{k,N[a[ k],10],N[b[ k],10]},{k, 1, 10} ],
TableHeadings->{{},{"n","a[n]","b[n]"} }]

b) The following table suggests that (Subscript[a, n])≤(Subscript[b, n]) for at least the first ten terms:

TableForm[Table[{k,N[a[ k],10],N[b[ k],10],N[b[k],10]-N[a[k],10]},{k, 1, 10} ],
TableHeadings->{{},{"n","a[n]","b[n]","b[n]-a[n]"} }]

For a better feel on this, let us plot the graphs on the same axes. To this end, we define two lists using the Table command and use the ListPlot command to plot the graphs.

plot1=ListPlot[Table[{k,a[k]},{k,1,10}],PlotStyle->{Blue}];
plot2=ListPlot[Table[{k,b[k]},{k,1,10}],PlotStyle->{Red}];
Show[plot1,plot2,PlotRange->{0,10}]

The above graph suggests that the two sequences converge to the same limit.  Unfortunately, Mathematica's Limit command cannot help us compute the limit of (Subscript[a, n]) and (Subscript[b, n]) due to their recursive nature. (Try this!)

NOTE: We encourage the reader to experiment with different initial values for (Subscript[a, 1]) and (Subscript[b, 1]) to see if the sequences (Subscript[a, n]) and (Subscript[b, n]) always converge to the same limit.

Example 10.6.  Consider the sequence

(Subscript[a, n])=((((n!))^(1/n))/n)

a) Show that if  (Subscript[b, n])=ln (Subscript[a, n]), then (Subscript[b, n])=((ln (n!)-n ln n)/n).

b)  Does (Subscript[b, n]) converge? If so, find the limit.

c)  Does (Subscript[a, n]) converge? If so, find the limit.

Solution:

a)  We define a sequence (Subscript[c, n])=((ln (n!)-n ln n)/n) and then show that (Subscript[b, n])=(Subscript[c, n]).

Clear[a,b,c]
a[n_]:=((((n!))^(1/n))/n)
b[n_]:=Log[a[n]]

c[n_]:=((Log[ n!]-n Log[n])/n)

TableForm[Table[{N[c[n]],N[b[n]],N[c[n],10]-N[b[n],10]}, {n, 2, 10}],
TableHeadings->{Automatic,{" (Subscript[c, n])"," (Subscript[b, n])"," (Subscript[c, n])-(Subscript[b, n])"}}]

The preceding table indicates that the two sequences are the same.  Here is a plot of both:

ListPlot[{Table[{n,b[n]}, {n, 1, 100}],Table[{n,c[n]}, {n, 1, 100}]},PlotRange->{-1,0.1},AxesOrigin->{0,0}]

This plot clearly shows that (Subscript[b, n])=(Subscript[c, n]), that is, ln((Subscript[a, n]))=ln(((((n!))^(1/n))/n))=((ln (n!)-n ln n)/n).  We leave it to the student to establish this equality using properties of the natural logarithmic function.

b) The previous plot indicates that the limit of (Subscript[b, n]) is -1.  To confirm this, we use the Limit command.

Limit[b[n], n->Infinity]

c) Since (Subscript[b, n])=ln ((Subscript[a, n])), it follows that (Subscript[a, n])=(e^(Subscript[b, n])) and hence (lim_(n-> ∞))(Subscript[a, n])=(e^(-1)).  Again, we verify this using the Limit command:

Limit[a[n], n->Infinity]

Exercises

In Exercises 1 though 3, determine the convergence of the given sequence. 
1.  (Subscript[a, n])=((3(n^2)+n+2)/(2(n^2)+1))			2. (Subscript[a, n])=ln(((2n+3)/(n+1)))	 			3. (Subscript[a, n])= (n^(1/n))

4.  Let   (Subscript[c, n])=(1/(n+1))+(1/(n+2))+(1/(n+3))+ ... + (1/(2n)).

a)  Find the first ten terms of the sequence.
b)  Plot the graph of the sequence.
c)  Is the sequence increasing? Bounded? Convergent? Prove each of your assertions.
d)   Find (lim_(n-> ∞))(Subscript[c, n]).

5. The nth harmonic number is defined to be the sum

(Subscript[H, n])=1+(1/2)+(1/3)+ ... + (1/n).

Let  (Subscript[a, n])=(Subscript[H, n])-ln n and (Subscript[b, n])=(∫_1^(n+1  )) (1/x)  dx.

a)  Show that (Subscript[H, n])≥(Subscript[b, n]) for n=1,2,3,...,10.  Prove that this holds for all positive integers n.

b)  Show that (Subscript[a, n])≥0 for n=1,2,3,...,10.  Prove that this holds for all positive integers n.

c)  Use the ListPlot command to plot the graph of (Subscript[a, n]).  Does the graph indicate that (Subscript[a, n]) is decreasing or increasing?

d)  Evaluate (lim_(n-> ∞))(Subscript[a, n]).

e)  The limit in part d) is called Euler's Constant and is denoted by γ. Compute γ accurate to 20 digits.

10.2  Infinite Series

Students should read Section 10.2-10.3 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

10.2.1 Finite Sums

Sum[a[n], n, n1, n2] evaluates the finite sum of (Subscript[a, n]) as n goes from (Subscript[n, 1]) to (Subscript[n, 2]).  
Sum[a[n], n, n1, Infinity] evaluates the infinite series of (Subscript[a, n]) as n goes from (Subscript[n, 1]) to ∞.

Using the BasicMathInput Palette, we can also enter finite sums or infinite series as (∑_(n=n1)^n2)a[n] or (∑_(n=n1)^∞)a[n], respectively.

Example 10.7.  Compute the following finite sums:

a) (∑_(n=1)^10)((((-1))^n)/n)		b)  (∑_(k=1)^5)(k-1)(k+1)

c) (∑_(k=1)^30) (({{20}, {k}}))(2^k)	d)  (∑_(i=1)^n)(3i-2)	e)  (∑_(k=0)^10)(((k^2)+1)/((k^3)+2(k^2)+1))

Solution:

a)

(∑_(n=1)^10)((((-1))^n)/n)

b)

Sum[(k+1)(k-1), {k, 1,5}]

c) The binomial coefficient (({{n}, {m}}))=((n!)/(m!(n-m)!)) is expressed in Mathematica by the command Binomial[n, m].

(∑_(k=0)^30)Binomial[30,k] (2^k)

NOTE: The above number is the same as (3^30)=205891132094649. Verify this!

d)

(∑_(j=1)^n) (3j-2)

Simplify[%]

e)

(∑_(k=0)^10)(((k^2)+1)/((k^3)+2(k^2)+1))

10.2.2  Partial Sums and Convergence

Example 10.8.  Consider the series (∑_(n=1)^∞)(1/(4(n^2)-1)).   Let (Subscript[s, n ])denote its nth partial sum.

a)  Find (Subscript[s, 100]). 		
b)  Compute every 10th partial sum up to n=100.
c)  Compute every 1000th partial sum up to n =10,000.
d)  From the tables of values in parts a) and b) what do you infer about the convergence of the series?  Prove your assertion.

Solution:

a) First, we define (Subscript[s, n]) in Mathematica and then evaluate (Subscript[s, 100]).

Clear[s,n]
s[n_]:= (∑_(j=1)^n)(1/(4(j^2)-1))
s[100]

N[%]

b) Here, we use the command Table[s[n],{n,1,J,K}], which gives the list of every K-th value of (Subscript[s, n]), as n goes from 1 to J.  The command TableForm[N[Table[s[n],{n, 1, J, K }]]] lists the values in column form.

Table[s[n],{n,1,100,10}]

N[%]

TableForm[Table[{n,N[s[n]]},{n,10,100,10}],
TableHeadings->{{}, {"n", "(Subscript[s, n])"}}]

c)

TableForm[Table[{n,N[s[n]]},{n,1000,10000,1000}],
TableHeadings->{{}, {"n", " (Subscript[s, n])"}}]

d) It seems that the partial sums converge to 0.5. We  confirm this by evaluating

Limit[s[n], n->∞]

Can you prove this?  Hint: Use the method of partial fractions to decompose this series into a telescoping series as discussed in your calculus text.

Example 10.9.  Let (Subscript[s, n ])be the nth partial sum of the harmonic series

(∑_(k=1)^∞)(1/k).

a)  Find   (Subscript[s, 100]). 		
b)  Compute every 1000th partial sum up to n =10,000
c)  Plot the graphs of the partial sums.
d)  From the table of values in part (b) what do you infer? Prove your assertion.

Solution:  We will follow the method of the preceding example.  First, we define the nth partial sum.

Clear[s,n]
s[n_]:=Sum[1/k,{k, 1, n}]

a) Then (Subscript[s, 100]) is given by

s[100]

N[%]

b) Here is a table of values of every 1000th term in the sequence (Subscript[s, n]) for n less than or equal to 10, 000.

TableForm[Table[{n,N[s[n]]},{n,1000,10000,1000}],
TableHeadings->{{}, {"n", " (Subscript[s, n])"}}]

c) Here is a plot of (Subscript[s, n]).

ListPlot[Table[{n,s[n]},{n,1, 300,20}]]

The graph above indicates a slow growth that makes it difficult to reach a definitive conclusion regarding the convergence of the harmonic series.

d) The table in b) and the plot in c) both suggest that the sequence of the partial sums is increasing. To convince ourselves of this, we compare (Subscript[s, (2^n)]) and (n/2).

TableForm[Table[{n/2.,N[s[(2^n)]]},{n,1,10}],
TableHeadings->{{}, {"(n/2)", " (Subscript[s, (2^n)])"}}]

This table suggests that (Subscript[s, (2^n)])≥(n/2) for n≥2.  Use this fact (a proof of it can be found in your calculus text) to establish the divergence of the harmonic series.

Example 10.10.  Determine whether the following series converges or diverges.

a)   (∑_(n=1)^∞)((((-1))^n)/(n^2))		b)  (∑_(j=1)^∞)((j-1)/j)		c)  (∑_(n=1)^∞)((1/(Sqrt[n]))-(1/(Sqrt[n+1])))		d)  (∑_(n=1)^∞)(ln(n+1)-ln n)

Solution: In all cases, we let Mathematica attempt to evaluate the infinite sum. For those cases where Mathematica returns a numeric output, this is understood to mean that the series converges and that the sum of the series is the given value.

a)

(∑_(n=1)^∞)((((-1))^n)/(n^2))

Thus, the series converges to -((π^2)/12). To see this graphically, we plot the graph of the partial sums of the series using the ListPlot command, along with the horizontal line representing its sum s=-((π^2)/12)≈-0.822467.

Clear[s,n]
s[n_]=(∑_(k=1)^n)((((-1))^k)/(k^2));

plot1=ListPlot[Table[{n,s[n]}, {n, 1, 100}]];
plot2=Plot[-((π^2)/12), {x, 1, 100}];
Show[plot1, plot2]

b) Observe that (lim_(j->∞))((j-1)/j)=1≠0.  Hence, the series does not converge according to the Test for Divergence. This explains the following output message from Mathematica if we attempt to evaluate the series.

(∑_(j=1)^∞)((j-1)/j)

c) Since this is a telescoping series, it can be shown that the nth partial sum is given by (Subscript[s, n])=1-(1/(Sqrt[n+1])).  This can be seen in the following output:

s[n_]:=(∑_(k=1)^n)((1/(Sqrt[k]))-(1/(Sqrt[k+1])))

TableForm[Table[{n,s[n]},{n,1,10}],
TableHeadings->{{}, {"n", " (Subscript[s, n])"}}]

Hence, the series converges to 1, which we confirm with Mathematica.

(∑_(n=1)^∞)((1/(Sqrt[n]))-(1/(Sqrt[n+1])))

d) This, too, is a telescoping series with the nth partial sum given by (Subscript[s, n])=ln (n+1) (verify this).  Hence, the series diverges, as shown by the following output.

(∑_(n=1)^∞)(Log[n+1]-Log[n])

Exercises

1. Consider the series (∑_(n=1)^∞)(1/((n^2)+3n+2)).

a)  Use the Apart command to decompose the terms of the series, (Subscript[a, n])=(1/((n^2)+3n+2)), into partial fractions.

b)  Use part (a) to find a formula for the nth partial sum of the series.

c) Is the series convergent? If so, then find its sum.

In Exercises 2 through 5, determine if the given series is convergent.  If it is, then find its sum.

2.  (∑_(n=1)^∞)(1/(n(n+1)))				3.  (∑_(n=0)^∞)((((-1))^n)/(n!))				4.  (∑_(n=1)^∞)(((-1))^(n+1))

5. The sereis (∑_(n=0)^∞)a (r^n) is called a geometric series.

a)   Find the nth partial sum of the geometric series.
b)   For what values of r does the series converge? Diverge?
c)   Find the sum of the geometric series for those values where the series converges.

6.  Consider the series (∑_(n=1)^∞)(1/(n^(1/3))).

a)  Use the ListPlot command to plot the first ten partial sums of this series.

b)  Show that the series converges.

10.3  Tests for Convergence

Students should read Sections 10.4-10.5 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

10.3.1  Comparison and Limit Comparison Tests

The Comparison Test: Suppose 0≤(Subscript[a, n])≤(Subscript[b, n]) for all n>M, where M is some positive integer.

a) If (∑_(n==1)^∞)(Subscript[b, n]) is convergent, then (∑_(n=1)^∞)(Subscript[a, n]) is also convergent.

b) If (∑_(n==1)^∞)(Subscript[a, n]) is divergent, then (∑_(n=1)^∞)(Subscript[b, n]) is also divergent.

The Limit Comparison Test: Suppose (Subscript[a, n]) and (Subscript[b, n]) are both positive and  (lim_(n->∞))((Subscript[a, n])/(Subscript[b, n]))=l. If  0<l<∞ (i.e.,, if l is a finite positive number), then (∑_(n=1)^∞)(Subscript[a, n]) and (∑_(n=1)^∞)(Subscript[b, n]) both converge or both diverge.

To test convergence of a given series(∑_(n=1)^∞)(Subscript[a, n]) using the Limit Comparison Test,  it is important that the series (∑_(n=1)^∞)(Subscript[b, n]) easily be checked for convergence.

Example 10.11.  Discuss the convergence of the series

(∑_(n=1)^∞) (1/( (Sqrt[(n^2)+2])))

Solution:  Since (1/( (Sqrt[(n^2)+2])))<(1/(Sqrt[(n^2)]))=(1/n) and the harmonic series (∑_(n=1)^∞) (1/( n)) was shown to divergence in Example 10.8 of this text, it follows by the Comparison Test that our series diverges also.  This is verified by Mathematica:

(∑_(n=1)^∞)(1/(Sqrt[(n^2)+2]))

Example 10.12.  Discuss the convergence of the series

(∑_(n=1)^∞) ((3(n^3)+40(n^2)+4)/((n^5)+200(n^4)+1))

Solution: To find another series to compare ours with, we consider one with terms (Subscript[b, n])=(3/(n^2)).  This comes from considering lower powers of n in both the numerator and denominator of (Subscript[a, n]).

Clear[a,b,n]
a[n_]:=((3(n^3)+40(n^2)+4)/((n^5)+200 (n^4)+1))
b[n_]:=(3/(n^2))

Limit[((a[n])/(b[n])), n->Infinity]

Since the series (∑_(n=1)^∞)(3/(n^2)) is convergent (p-series) and (lim_(n->∞))((Subscript[a, n])/(Subscript[b, n]))=1, we conclude from the Limit Comparison Test that our series (∑_(n=1)^∞) ((3(n^3)+40(n^2)+4)/((n^5)+200(n^4)+1)) is also convergent.

Example 10.13.  Discuss the convergence of the series (∑_(n=1)^∞)[1-cos((1/n))].

Solution: We note that  (lim_(n->∞))[1-cos((1/n))]=0.  This is confirmed by Mathematica.

Limit[1-Cos[1/n],n->∞]

Thus, the necessary condition for convergence is satisfied. But this does not guarantee convergence.  We will use the ListPlot command to plot the graph of the partial sums to see if the series converges.

Clear[s]
s[n_]:=Sum[1-Cos[1/k], {k,1, n}]

ListPlot[Table[{n,s[n]},{n, 1, 100}],PlotRange->{0,1}]

The graph above clearly indicates convergence. To see that this is indeed true, we compare it with a series that is known to converge: (∑_(n=1)^∞)(1/(n^2)). To this end, let us define (Subscript[a, n]) and (Subscript[b, n]) as follows.

Clear[a,b,n]
a[n_]:=1-Cos[(1/n)]
b[n_]:=(1/(n^2))

Observe that both (Subscript[a, n]) and (Subscript[b, n]) are positive terms for all n. Hence, we can apply Limit Comparison Test:

Limit[((a[n])/(b[n])), n->Infinity]

Therefore, the given series, (∑_(n=1)^∞)[1-cos((1/n))], converges.

10.3.2  The Integral Test

The Integral Test.  Given an infinite series

(∑_(n=1)^∞)(Subscript[a, n])

we define f(x) so that f(n)=(Subscript[a, n]) . If f(x) is positive on the interval [1, ∞), decreasing on this interval, and if (lim_(x->∞))f(x)=0, then

(∫_1^∞)f(x)dx     and      (∑_(n=1)^∞)(Subscript[a, n])

both converge or both diverge.

Example 10.14.  Use the integral test to determine the convergence of the following series.

a)   (∑_(n=1)^∞)(1/(Sqrt[n])) 		c)    (∑_(j=1)^∞) j (e^(-(j^2)))		c)  (∑_(n=1)^∞)(1/((Sqrt[n])ln n))

Solution:

a) Here, (Subscript[a, n])=(1/(Sqrt[n])) and so we define f(n) in Mathematica:

Clear[f,x]
f[x_]:=(1/(Sqrt[x]))

f'[x]

Since f'(x)<0 for all x∈[1,∞), it follows that f is decreasing.  Clearly f is positive in value and  (lim_(x->∞))f(x)=0. Thus we can apply the Integral Test by evaluating (∫_1^∞)f(x)dx:

Integrate[f[x], {x, 1, Infinity}]

To confirm this, we evaluate this improper integral according to its limit definition:

Clear[F,b]
F[b_]:=Integrate[f[x], {x, 1, b}]

Limit[F[b], b->∞]

b) Here, we define f as

Clear[f,x]
f[x_]= x (E^(-(x^2)))

Plot[f[x],{x, 0, 5},PlotRange->{0,1}]

The graph clearly shows that the function is decreasing. We can confirm this by solving

f'[x]
Solve[f'[x]==0]

f'[1]

N[1/Sqrt[2]]

Thus, f has critical points at ±(1/(Sqrt[2]))≈0.707.  Since f'(1)<0, we conclude that f  is decreasing on (1, ∞).

The graph also shows that (lim_(x->∞))f(x)=0. Again, we can confirm this by evaluating

Limit[f[x], x->Infinity]

Hence, the Integral Test can be used to determine if the series is convergent. That the series (∑_(j=1)^∞)j (e^(-(j^2))) is convergent follows from the fact that

(∫_1^∞)f[x]\[DifferentialD]x

Since the corresponding integral is convergent, it follows that the series (∑_(j=1)^∞)j (e^(-(j^2))) is also convergent.

c) In this case, we define f as

Clear[f,x]
f[x_]=(( 1)/((Sqrt[x])Log[x]))

Plot[f[x], {x,2,100}]

We leave it for the reader to check that f satisfies all the conditions of the Integral Test, which we now apply.

(∫_2^∞)f[x]\[DifferentialD]x

Since the preceding output states that the integral is divergent, we conclude that the corresponding series is divergent also.

Example 10.15.  For what values of p does the series (∑_(n=2)^∞)(1/((n(ln n))^p)) converge?

Solution: We apply the Integral Test.  Toward this end, we define f(x) so that f(n)=(1/((n(ln n))^p)) and then verify that f(x) is positive and decreasing on the interval [a, ∞),  and that (lim_(x->∞))f(x)=0:

Clear[f,x,p]
f[x_]:=(1/(x (((Log[x]))^p)))

Limit[f[x], x->Infinity]

To confirm this limit, we will plot graphs of f(x) for some values of p

Plot[Evaluate[Table[f[x], {p, -4, 2, .5}]], {x, 2,100},PlotRange->{0,5}]

In the plot above, observe that some of the graphs are initially increasing, but then begin to decrease at a certain point.  Let us then find the interval over which the functionf(x) is decreasing for each  p. To this end, we compute the derivative f'(x) and solve f'(x)<0 for x.

f'[x]

Simplify[%]

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

Since (((ln x))^(-1-p))>0 for all x>1, we see that f'(x)<0 if ln x>-p, or equivalently, x=(e^(-p)).  Thus, f(x) is decreasing on [2, ∞) where a is the maximum of 2 and (e^(-p)).

To apply the Integral Test, we integrate fover the interval [2,∞).  This is easier than integrating over the interval [a,∞), and permissible since the integrals (∫_2^∞)f(x)dx and (∫_a^∞)f(x)dx either converge or diverge together.

Integrate[f[x],{x,2,∞}]

The preceding output shows that (∫_2^∞)f(x)dx is convergent for p>1.  However, the case p≤1 remains unsolved.  To evaluate the integral in this situation, we define its anti-derivative F(b)=(∫_2^b)f(x)dx and find the limit of F(b) as b-> ∞.

Clear[F,b]
F[b_]=Integrate[f[x], {x, 2, b}]

Since b is a real number and b>2 , the solution to our integral is the first one, that is, F(b)= (((((ln 2))^(1-p))-ln (((b))^(1-p)))/(1-p)), provided p≠1. But then for p<1, we see that (lim_(b->∞))F(b)=∞ since (lim_(b->∞))((ln(b))^(1-p))=∞.  For p>1, we have (lim_(b->∞))F(b)=((((ln 2))^(1-p))/(1-p)) , which we already knew from the second previous Mathematica output.  The following tables might be helpful to convince you about this.

Table[Limit[F[b], b->Infinity], {p, -3, .9, .5}]

Table[Limit[F[b], b->Infinity], {p, 1.1, 9, .5}]

For p=1, we make this substitution inside the integral and evaluate it directly:

p=1;
Integrate[f[x], {x, 2, ∞}]

Therefore, the infinite series (∑_(n=2)^∞)(1/((n(ln n))^p)) is convergent for p>1 and divergent for p≤1.

NOTE: To see how slow the growth of this series is for the value of p=1, we consider the following table of partial sums. Recall that f(n) is the nth term of the series and hence the nth partial sum is given by

Clear[p,s,n]
s[n_]=Sum[f[k], {k, 2, n}]

The following output shows that the sum of the first ten thousand terms is only about 3.01501088.

p=1;
N[s[10000]]

Here is a plot of the graph of the first ten thousand partial sums in steps of 1,000.

ListPlot[Table[{n, s[n]}, {n, 1000, 10000, 1000}]]

10.3.3  Absolute and Conditional Convergence

Suppose (Subscript[a, n])>0 for all n. The infinite series

(∑_(n=1)^∞)(((-1))^n)(Subscript[a, n])

is called an alternating series.  If the series (∑_(n=1)^∞)(((-1))^n)(Subscript[a, n]) is convergent but the series (∑_(n=1)^∞)(Subscript[a, n]) is divergent, then the alternating series is called conditionally convergent.  If (∑_(n=1)^∞)(Subscript[a, n]) is convergent, then the alternating series  (∑_(n=1)^∞)(((-1))^n)(Subscript[a, n]) is called absolutely convergent.

Alternating Series Test: If (Subscript[a, n]) is decreasing and (lim_(n->∞))(Subscript[a, n])=0, then the series (∑_(n=1)^∞)(((-1))^n)(Subscript[a, n]) is convergent.

Example 10.16.  Determine if the given series is conditionally or absolutely convergent.

a)   (∑_(n=1)^∞)((((-1))^n)/((n^2)+1)) 		c)    (∑_(n=2)^∞) ((((-1))^n)/(n ln n))

Solution:

a) We define (Subscript[a, n])=(1/((n^2)+1)) in Mathematica and check that (Subscript[a, n]) satisfies the conditions of the Alternating Series Test.

Clear[a,n]
a[n_]:=  (1/((n^2)+1))

Limit[a[n],n->∞ ]

f[x_]=a[x];
f'[x]

Thus, (Subscript[a, n]) is decreasing since f'(x)>0, where f(n)=(Subscript[a, n]).  Moreover, (Subscript[a, n]) converges to 0. Hence, the series (∑_(n=1)^∞)((((-1))^n)/((n^2)+1))   is convergent by the Alternating Series Test.

To check absolute convergence, we use the Limit Comparison Test with (Subscript[b, n])=(1/(n^2)).

Limit[((a[n])/(1/(n^2))), n->Infinity]

Since the series (∑_(n=1)^∞)(1/(n^2)) is convergent and the previous output shows (lim_(n->∞))((Subscript[a, n])/(Subscript[b, n]))=1, we conclude that the series (∑_(n=1)^∞)(Subscript[a, n])=(∑_(n=1)^∞)(1/((n^2)+1)) is also convergent.  Therefore, the alternating series (∑_(n=1)^∞)((((-1))^n)/((n^2)+1))  is absolutely convergent.

b) We procced as in part a).

Clear[a,n]
a[n_]:=  (1/( n Log[n]))

Limit[a[n],n->∞ ]

f[x_]=a[x];
f'[x]

For the same reasons we conclude that (Subscript[a, n]) is decreasing and converges to 0.  Hence, the series (∑_(n=2)^∞)((((-1))^n)/( n ln n))   is convergent by the Alternating Series Test.

To check absolute convergence, we apply the Intgeral Test to f(x):

Clear[m]
Limit[(∫_2^m)f[x]\[DifferentialD]x,m->Infinity]

From this, we conclude that the series is conditionally convergent.

Example 10.17.  Show that the series

(∑_(n=1)^∞)((((-1))^n)/(Sqrt[(n^2)+1]))

is conditionally convergent.  Find a value of n for which the partial sum (Subscript[s, n]) approximates the series by an error less than (10^(-5)).  Also, find the corresponding value for (Subscript[s, n]).

Solution: We leave it for the reader to check that the series converges conditionally as in the preceding example.  For the second part of the problem, we proceed by first defining the partial sums of the series.

Clear[s,a,n]
a[n_]:=(1/(Sqrt[(n^2)+1]))
s[n_]:=Sum[(((-1))^k) a[k], {k, 1, n}]

If S denotes the sum of the alternating series, it can be shown that |S-(Subscript[s, n])|<(Subscript[a, n+1]) (refer to your calculus text for a proof of this fact).  The following table of values gives some numerical evidence of this fact:

Table[{N[Abs[(∑_(n=1)^∞)((((-1))^n)/(Sqrt[(n^2)+1]))-s[m]]],N[a[m]]},{m,1,10 }]

Clear[S,n]
S=(∑_(n=1)^∞)((((-1))^n)/(Sqrt[(n^2)+1]))

The table below gives the values of (Subscript[a, n]) for large values of n.

Table[N[a[(10^n)] ], {n, 1,10  }]

Thus, n=(10^6) is a possible value. But solving (Subscript[a, n])=(10^(-5)) can give us a more accurate value.

NSolve[a[x]==(10^(-5)),x]

Thus, if n=100001, we have |S-(Subscript[s, n])|<(10^(-5)).  We confirm this with Mathematica:

N[S-s[100001]]

Can you find a smaller value of n for which |S-(Subscript[s, n])|<(10^(-5))?

10.3.4  Ratio Test

The Ratio Test:  Suppose (Subscript[a, n])>0 and let

r=(lim_(n->∞))((Subscript[a, n+1])/(Subscript[a, n])).

a) If r<1, the series (∑_(n=1)^∞)(Subscript[a, n]) converges. 
b) If r>1, the series (∑_(n=1)^∞)(Subscript[a, n]) diverges.
c) If r=1, no conclusion can be drawn about the convergence of the series (∑_(n=1)^∞)(Subscript[a, n]).  In other words, if r=1, then we must use another test to determine the convergence.

Example 10.18.  Use the Ratio Test to determine the convergence of the following series.

a)   (∑_(n=1)^∞)((n^n)/(n!)) 		c)    (∑_(j=2)^∞) (1/(j (((ln j))^3)))		c)  (∑_(n=1)^∞) ((3(n^3)+40(n^2)+4)/((n^5)+200(n^4)+1))

Solution: For each series, we define (Subscript[a, n]) to be its nth term and evaluate (lim_(n->∞))((Subscript[a, n+1])/(Subscript[a, n])).

a)

Clear[a,n]
a[n_]:= ((n^n)/(n!))

Limit[a[n+1]/a[n],n->∞ ]

Since e>1, the series (∑_(n=1)^∞)((n^n)/(n!)) converges by the Ratio Test.

b)

Clear[a,j]
a[j_]:= (1/(j(((Log[j]))^3)))
 Limit[a[j+1]/a[j],j->∞ ]

This output means that we must use a different test. However, this is an instance of Example 11.12 in this text with p=3.  Hence, the series converges by the Integral Test.

c)

Clear[a,n]
a[n_]:= ((3(n^3)+40(n^2)+1)/((n^5)+200(n^4)+1))

Limit[a[n+1]/a[n],n->∞ ]

Again, this output means we are forced to use a different test.  Therefore, we shall use the Limit Comparison Test instead. To this end, we define (Subscript[b, n])=(3/(n^2)):

Clear[b,n]
b[n_]:=(3/(n^2))

Limit[((a[n])/(b[n])), n->Infinity]

Since the series (∑_(n=1)^∞)(1/(n^2)) is convergent, we conclude that the series (∑_(n=1)^∞) ((3(n^3)+40(n^2)+4)/((n^5)+200(n^4)+1)) is also convergent.

10.3.5  Root Test

The Root Test:  Suppose (Subscript[a, n])>0 and let

r=(lim_(n->∞))((((Subscript[a, n])))^(1/n)).

a) If r<1, the series (∑_(n=1)^∞)(Subscript[a, n])converges. 
b) If r>1, the series (∑_(n=1)^∞)(Subscript[a, n]) diverges.
c) If r=1, no conclusion can be drawn about the convergence of the series (∑_(n=1)^∞)(Subscript[a, n]). In other words, if r=1, then we must use another test to determine the convergence.

Example 10.19.  Use the Root Test  to determine the convergence of the following series:

a)   (∑_(n=1)^∞)((((n/(2n+1))))^n) 		b)    (∑_(n=1)^∞) (1/(n  (3^n)+(n^2)))		c)  (∑_(n=1)^∞)((3n+1)/((n^2)+n+1))

Solution: For each series we define (Subscript[a, n]) to be its nth term and evaluate (lim_(n->∞))((((Subscript[a, n])))^(1/n)).

a)

Clear[a,n]
a[n_]:= ((((n/(2n+1))))^n)

Limit[(((a[n]))^(1/n)),n->∞ ]

Thus, the series (∑_(n=1)^∞)((((n/(2n+1))))^n) converges by Root Test.

b)

Clear[a,n]
a[n_]:=  (1/(n (3^n)+(n^2)))

Limit[(((a[n]))^(1/n)),n->∞ ]

Even though the preceding Limit command is returned as unevaluated, the N command reveals that it is approximately 1/3.

N[%]

To verify this, we use the Squeeze Theorem (discussed in your calculus text) with (Subscript[b, n])=(1/(2 n (3^n))) and (Subscript[c, n])=(1/(n (3^n))).  First, note that (Subscript[b, n])≤(Subscript[a, n])≤(Subscript[c, n]).  We can verify this using the following plot:

Plot[{((3^(-x))/(2x)), a[x],((3^(-x))/x)}, {x, 1, 10}, PlotStyle->{Green, Red, Blue}]

We now define (Subscript[b, n ])and (Subscript[c, n]) as and evaluate (lim_(n->∞))((((Subscript[c, n])))^(1/n))  and (lim_(n->∞))((((Subscript[b, n])))^(1/n)).

Clear[b, c, n]
b[n_]:=(1/(2 n (3^n)))
c[n_]:=(1/(n (3^n)))

Limit[(((b[n]))^(1/n)), n->Infinity]
Limit[(((c[n]))^(1/n)), n->Infinity]

Thus, we also have (lim_(n->∞))((((Subscript[a, n])))^(1/n))=(1/3) and hence the series converges by the Root Test.

c)

Clear[a,n]
a[n_]:= ((3n+2)/((n^2)-n+1))

Limit[ (((a[n]))^(1/n)),n->∞ ]

The Root Test fails. Let us try the Ratio Test:

Limit[((a[n+1])/(a[n])), n-> Infinity]

The Ratio Test fails as well. We can easily verify that the Integral Test is applicable. We will evaluate the integral

(∫_1^∞)a[x]\[DifferentialD]x

To confirm the divergence of the improper integral, we leave it to the reader to evalaute the function F(x) defined below for large values of x.

Clear[F,b]
F[b_]:=(∫_1^b)a[x]\[DifferentialD]x

Exercises

In Exercises 1 through 6, use the Comparison Test or the Limit Comparison Test to determine if the given series is convergent. If it is convergent, then find its sum.

1.  (∑_(n=1)^∞)(n/(Sqrt[(n^3)+1]))			2.  (∑_(n=2)^∞) ((ln n)/((n^2)+3 ln n))			3.  (∑_(n=1)^∞) (((n^4)+200(n^2)+1000n+2222)/((n^6)+5(n^4)+n+1))

4.  (∑_(n=1)^∞)((ln n)/( (n^2)))		   		5.  (∑_(n=2)^∞) (( 1 )/((n^(ln n)) ))				6.  (∑_(n=1)^∞) (1-(2^(-1/n)))

In Exercises 7 through 9, use the Integral Test to determine if the given series is convergent. If it converges, then find its sum.

7.  (∑_(n=1)^∞)(n/((n^2)+1))				8.  (∑_(n=2)^∞) (n/(2^n))				9.  (∑_(n=1)^∞)  ((((ln n))^3)/(n^2))

10. For what values of p does the series (∑_(n=1)^∞)(1/((n^p) ln n)) converge?

11. Consider the series (∑_(n=2)^∞)((((ln n))^k)/(n^p)).

a)   Fix a value of p (say, p=2 or p=1/2) and find all values of k for which the series converges.

b)   Fix a value of k (say, k=2 or k=-2) and find all values of p for which the series converges.

c)   Generalize the results of a) and b) to all values of p and k.

12.  Let f be  a positive valued function that decreases on [1, ∞) and let (Subscript[a, n])=f(n). It can be shown that

(∫_1^∞)f(x)dx≤(∑_(n=1)^∞)(Subscript[a, n])≤(Subscript[a, 1])+(∫_1^∞)f(x)dx .

a)  Use f(x)=(1/(x^1.1)) to verify this.

b)  Approximate (∑_(n=1)^∞)(1/(n^1.1)) using its nth partial sums with n=10, 100, 1000, 10000.

In Exercises 13 through 16, determine if each of the infinite series is absolutely convergent, conditionally convergent, or divergent. Justify your conclusions! 
13.  (∑_(n=1)^∞)(((((-1))^n)((n^2)-1))/((n^2)+1))		14. (∑_(n=1)^∞)((20(n^2)-n-1)/((n^3)+(n^2)+33))		15. (∑_(n=1)^∞)((((-2))^n)/(n!))		16.  (∑_(n=1)^∞)(((-1))^(n+1))[(Sqrt[n+1])-(Sqrt[n]) ]

17.  Discovery Exercise: 
a)  Determine the convergence or divergence of (∑_(n=2)^∞)(1/(n ln (((ln ln n))^0.5))), (∑_(n=2)^∞)(1/(n ln (((ln ln n))^( )))), and (∑_(n=2)^∞)(1/(n ln (((ln ln n))^2))).
b)  Generalize your work in part a) by determining for which real numbers p the series(∑_(n=2)^∞)(1/(n ln (((ln ln n))^p))) converges.

In Exercises 18 through 25, determine the convergence or divergence of the given infinite series using any of the convergence tests discussed in this section.

18. (∑_(n=1)^∞)((3n+1)/(4n+5)) 			19. (∑_(n=1)^∞)(n/(2(n^2)+1))	 	20. (∑_(n=1)^∞)((n+3)/(4(n^3)+5))  		21. (∑_(n=1)^∞)((n((2/3)))^n) 

22. (∑_(n=1)^∞)((n((3/2)))^n) 		23. (∑_(n=1)^∞)((n^n)/(n!))			24. (∑_(n=1)^∞)((((n!))^2)/((3n)!)) 			25. (∑_(n=0)^∞)(((-1))^n)(((1+(1/n)))^n)

26.  The Ratio Test proved to be inconclusive for some of the series in the previous exercise. Can you conjecture for what type of series the Ratio Test will fail in general? Use other tests to rework the problems in the first exercise where the Ratio Test failed.

27. Of the following four conditions, one guarantees that a series will diverge, two conditions guarantee that a series will converge, and one has no guarantee (the series can either converge or diverge).  Identify each one and explain your reasoning.

(lim_(n-> ∞))|((Subscript[a, n+1])/(Subscript[a, n]))|= 0
(lim_(n-> ∞))|((Subscript[a, n+1])/(Subscript[a, n]))|= (1/2)
(lim_(n-> ∞))|((Subscript[a, n+1])/(Subscript[a, n]))|= 1
(lim_(n-> ∞))|((Subscript[a, n+1])/(Subscript[a, n]))|= 2

28.  Identify the two series that are the same:

a)  (∑_(n=1)^∞)((n((3/4)))^n)			b)  (∑_(n=0)^∞)(n+1)  ((((3/4)))^n)			c)   (∑_(n=1)^∞)((n((3/4)))^(n-1))

In Exercises 29 through 32, determine the convergence or divergence of the series: 

29.  (∑_(n=1)^∞)(2(n^(1/n))+1)n	 		30, (∑_(n=0)^∞)(e^(-n)) 			31. (∑_(n=1)^∞)(((((-2n)/(3n+1))))^(3n)) 			32. (∑_(n=1)^∞)((n/(2n+1)))n

33. Construct two examples of infinite series, the first convergent and the second divergent, for which the Root Test generates inconclusive information.

34. Use the Root Test to test for convergence or divergence of the series:

a)  (1/(((ln 3))^3))+(1/(((ln 4))^4))+(1/(((ln 5))^5))+(1/(((ln 6))^6))+...

b)  1+ (2/3)+(3/(3^2))+(4/(3^3))+(5/(3^4))+(6/(3^5))+...

Hint: Write a formula for the general nth term in each case.

10.4  Power Series

Students should read Sections 10.6-10.7 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

10.4.1  Taylor Polynomials

The Taylor polynomial of a given function f at a point x=a is given by

(Subscript[T, n])(x)=f(a)+f'(a)(x-a)+((f''(a))/(2!))(((x-a))^2)+((f'''(a))/(3!))(((x-a))^3)+.... + (((f^((n)))(a))/(n!))(((x-a))^n).

The Mathematica Series[f,{x, a, n}] generates the nth Taylor polynomial (Subscript[T, n])(x) plus a term of the form ((O[x])^(n+1)).  To obtain the Taylor polynomial without this term, we use the command Normal[Series[f,{x, a, n}]].

The nth remainder (Subscript[R, n])(x) of f(x) at x=a is defined by

(Subscript[R, n])(x)=f(x)-(Subscript[T, n])(x).

Taylor's Theorem states that

(Subscript[R, n])(x)=(1/(n!))(∫_a^x)(f^((n+1)))(u)(((x-u))^n)du.

Here is a way to define the Taylor polynomial of fat x=a by defining (Subscript[T, n])(x) and the nth remainder (Subscript[R, n])(x) (using Taylor's Theorem for (Subscript[R, n])) without referring to Mathematica's built-in command Series.

Clear[a, x, f,T,R]
T[x_,a_, n_]:=(∑_(k=0)^n)((D[f[x],{x,k}]/.x->a)/(k!))(((x-a))^k)
 R[x_,a_, n_]:=(1/(n!))(∫_a^x)D[f[u],{u,n+1}]*(((x-u))^n) \[DifferentialD]u

Example 10.20.  Let f(x)=(e^x).  Find its 5th Taylor polynomial at x=0.

Solution: We use the Series command to obtain the answer:

Normal[Series[(E^x),{x,0,5}]]

Using the polynomial T[x,a,n], we defined above we get

Clear[f]
f[x_]:=(E^x)
T[x, 0, 5]

R[x,0,5]

Example 10.21.	 Find the nth Taylor polynomial of f(x) at x=a for various values of a and n.

a) f(x)=(Sqrt[x])	 	b)  f(x)=cos x

Solution:  a) We shall use the same function T[x,a,n] defined in the previous example (make sure you evaluate this function before you evaluate the table below).

Clear[a, x, f]
T[x_,a_, n_]:=(∑_(k=0)^n)((D[f[x],{x,k}]/.x->a)/(k!))(((x-a))^k)
R[x_,a_, n_]:=(1/(n!))(∫_a^x)D[f[u],{u,n+1}]*(((x-u))^n) \[DifferentialD]u

Clear[f]
f[x_]=(Sqrt[x])
TableForm[Table[ T[x, a, n] ,  {a,1, 5},{n, 1, 3}]  , 
TableHeadings->{{"at a=1", "at a=2","at a=3","at a=4","at a=5"},{"n=1","n=2","n=3"}}]

b) We proceed as in part a):

Clear[f]
f[x_]=Cos[x]
TableForm[Table[ T[x, a, n] ,  {a,0, 2Pi, Pi/2},{n, 1, 4}]  , 
TableHeadings->{{"at a=0", "at a=π/2","at a=π","at a=3π/2","at a=2π"},{"n=1","n=2","n=3","n=4"}}]

Example 10.22.  Let f(x)=(1/(2 +3(x^2))).

a) Find the Taylor polynomials (Subscript[T, n])(x) of f at  x=0 for n=1,2,..., 6.
b) Draw the graphs of the function f and its Taylor polynomials found in part a).
c) Over which interval does the nth Taylor polynomial gives a close approximation to f(x) if n=4, n=10, and n=20?

Solution:

a) Here are the Taylor polynomials up to order n=6.

Clear[f]
f[x_]=(1/(2+3(x^2)))
TableForm[Table[ {n,T[x, 0, n]} ,{n, 1, 6}]  , 
TableHeadings->{{},{"n", "(Subscript[T, n]) at a=0"}}]

b)  We first use the Plot command to plot the graphs of f and its Taylor polynomial at x=0 for the desired values of n.  We then use the Show command to plot both graphs on the same axes.

Clear[plot1,plot2]
plot1=Plot[f[x],{x,-3,3}, PlotStyle->  Red];
plot2=Plot[Evaluate[Table[T[x,0,n],{n, 1, 6}]], {x,-3,3}]  ;
Show[plot1,plot2]

c) We use the same commands as in part b) except that we do not use the Table command. The first one is for the case n=4.

Clear[plot1,plot2] 
plot1=Plot[f[x],{x,-3,3}, PlotStyle->  Red];
plot2=Plot[Evaluate[T[x,0,4]], {x,-3,3}]  ;
Show[plot1,plot2]

It seems that the two graphs are close to each other  if x is in the interval (-0.5, 0.5). To see this close up, we recommend that you change the range of values for x in both plots (plot1 and plot2) to the interval [-1,1]. We can confirm this by plotting the 4th remainder of f(x) at x=0.

Plot[Evaluate[R[x,0,4]],{x, -1,1}, PlotRange->{-1,1}]

We repeat the above with n=10.

Clear[plot1,plot2]
plot1=Plot[f[x],{x,-3,3}, PlotStyle->  Red];
plot2=Plot[Evaluate[T[x,0,100]], {x,-3,3}]  ;
Show[plot1,plot2]

The graph above clearly indicates the 10th Taylor polynomial gives a close approximation for f in the interval [-.6,.6]. Again, plotting  (Subscript[R, n]) will confirm this.

Plot[Evaluate[R[x,0,10]],{x, -1,1}, PlotRange->{-1,1}]

If we continue in this manner, we see that the Taylor polynomial  (Subscript[P, n]) for large values of n gives a better approximation of f in the interval [-1,1].  In fact, for n=20, we see that (Subscript[R, n])(x) is almost zero in the interval [-0.7,0.7], which is an improvement over the previous interval [-0.6,0.6] obtained for n=10.

Plot[Evaluate[R[x,0,20]],{x, -1,1}, PlotRange->{-1,1}]

10.4.2  Convergence of Power Series

A series of the form

(∑_(n=0)^∞)(((Subscript[a, n])(x-(Subscript[x, 0])))^n)=(Subscript[a, 0])+(Subscript[a, 1])(x-(Subscript[x, 0]))+(((Subscript[a, 2])(x-(Subscript[x, 0])))^2)+(((Subscript[a, 3])(x-(Subscript[x, 0])))^3)+ ....

is called a power series.

The set of all x for which the series converges is called the interval of convergence.

If the series converges for x=(Subscript[x, 0]) only, we say is radius of interval is R=0. In this case, its interval of convergence is {(Subscript[x, 0])}.

If the series converges for all real numbers x, we say its radius of convergence is R=∞. In this case, its interval of convergence is (-∞,∞).

If the series converges for some x≠(Subscript[x, 0]) and diverges for some y, then it can be shown that there exists R>0 such that the power series converges for all x for which |x-(Subscript[x, 0])|<R and diverges for all x for which |x-(Subscript[x, 0])|>R. The convergence at x=(Subscript[x, 0])-R and x=(Subscript[x, 0])+R needs to be checked.

When the radius of convergence R is a positive real number, there are four possiblities for the interval of convergence:

((Subscript[x, 0])-R, (Subscript[x, 0])+R) or [(Subscript[x, 0])-R, (Subscript[x, 0])+R) or ((Subscript[x, 0])-R, (Subscript[x, 0])+R] or [(Subscript[x, 0])-R, (Subscript[x, 0])+R]

depending on the convergence at the end points of the intervals.

The radius of convergence R of the power series (∑_(n=0)^∞)(((Subscript[a, n])(x-(Subscript[x, 0])))^n) can be found by using the Ratio or Root Test.  Let

r=(lim_(n->∞))|((Subscript[a, n+1])/(Subscript[a, n]))|    or    r=(lim_(n-> ∞))((|(Subscript[a, n])|)^(1/n))

a) If r=0, then R=∞. 
b) If r=∞, then  R=0 .
c) If 0<r<∞, then R=(1/r).

Example 10.23.  Find the radius and interval of convergence for the given power series.

a)   (∑_(n=0)^∞)(n/(2n+1)) (x^n) 		b)    (∑_(n=1)^∞) ((((x-3))^n)/(n (3^n)))		c)  (∑_(n=0)^∞)((((x+2))^n)/((n^2)+n+1))

d)   (∑_(n=0)^∞)(n^n) (x^n) 		e)    (∑_(n=0)^∞) (1/(n!))(((x-1))^n)

Solution:

a) Let us define (Subscript[s, m])(x) to be the mth partial sum of the series and plot the graph of some of these partial sums. We will plot every 100th partial sum up to 10,000 terms.

Clear[s,n,m]
s[x_,m_]:=(∑_(n=0)^m)(n/(2n+1))(x^n)

Plot[Evaluate[Table[s[x, m],{m,1, 1000, 100}]], {x, -2,2}]

This clearly indicates that the partial sums diverge outside (-1,1). Here is the plot over the interval (-1,1).

Plot[Evaluate[Table[s[x, m],{m,1, 1000, 100}]], {x, -1,1}]

We now use calculus. Here, note that (Subscript[a, n])=(n/(2n +1)) and (Subscript[x, 0])=0. We first define (Subscript[a, n]) in Mathematica and find the radius of convergence. We recall |a| (absolute value of a) is entered as Abs[a].

Clear[a,n,r]
a[n_]:=(n/(2n+1))

r= Limit[Abs[((a[n+1])/(a[n]))], n->Infinity]

Thus, the radius of convergence is R=(1/r)=(1/1)=1. The power series convrges on (-1, 1). To check convergence at the endpoints x=-1 and x=1, we note that the power series becomes (∑_(n=0)^∞)(n/(2n+1))(((-1))^n)and (∑_(n=0)^∞)(n/(2n+1))(((1))^n), both of which are divergent, since their nth terms do not converge to 0. Here, Mathematica confirms the divergence at the endpoints.

(∑_(n=0)^∞)(n/(2n+1))(((-1))^n)

(∑_(n=0)^∞)(n/(2n+1))(((1))^n)

Therefore, the interval of convergence is (-1,1).

b)   (∑_(n=1)^∞) ((((x-3))^n)/(n (3^n)))

Clear[a,r,n]
a[n_]:=(1/(n (3^n)))

r=Limit[((a[n+1])/(a[n])), n->Infinity]

Thus the radius of convergence is R=(1/r)=(1/(1/3))=3.

Since (Subscript[x, 0])=3, the power series converges on ((Subscript[x, 0])-R, (Subscript[x, 0])+R)=(3-3,3+3)=(0,6). We need to check the endpoints x=0 and x=6. We substitute these in the power series and evaluate

(∑_(n=1)^∞)((((x-3))^n)/(n (3^n)))/.x->{0,6}

Thus, the interval of convergence is [0,6).

c)  (∑_(n=1)^∞)((((x+2))^n)/((n^2)+n+1))

Clear[a,r,n]
a[n_]:=(1/((n^2)+n+1))

r=Limit[Abs[((a[n+1])/(a[n]))], n-> ∞]

Hence, the radius of convergence is R=(1/1)=1. Since (Subscript[x, 0])=-2, we see that the power series converges at least on the open interval (-2-1,-2+1)=(-3,-1). To determine the actual interval of convergence we need to check the endpoints. As in part c), we evaluate

(∑_(n=0)^∞)((((x+2))^n)/((n^2)+n+1))/.x->{-3,-1}

N[%]

Since this is not clear, we examine the series by plugging in by hand x=-3 and x=-1. When x=-3 the series becomes (∑_(n=1)^∞)((((-3+2))^n)/((n^2)+n+1))= (∑_(n=1)^∞)((((-1))^n)/((n^2)+n+1)), which is an alternating series. We leave it to the reader to verify that the Alternating Series Test applies in this case.  Thus, we have a convergent series.

Next, we substitute x=-1 to obtain the series (∑_(n=1)^∞)((((-1+2))^n)/((n^2)+n+1))= (∑_(n=1)^∞)(1/((n^2)+n+1)) to which we apply the Integral Test (verify that the conditions of the Integral Test are satisfied):

Integrate[(1/((x^2)+x+1)),{x,0,Infinity}]

Thus, the series converges in this case as well. Therefore, the interval of convergence for the power series is [-3,-1].

d)   (∑_(n=0)^∞)(n^n)(x^n)

Clear[a,r,n]
a[n_]:=(n^n)

r=Limit[Abs[((a[n+1])/(a[n]))],n-> ∞]

Thus, the radius of convergence is R=0 and the series converges for x=0 only.

e)    (∑_(n=0)^∞) (1/(n!))(((x-1))^n)

Clear[a,r,n]
a[n_]:=(1/(n!))

r=Limit[Abs[((a[n+1])/(a[n]))],n-> ∞]

Thus, the radius of convergence is R=∞ and the series converges for all real x.  Hence, the interval of convergence is (-∞,∞).

10.4.3  Taylor Series

The Taylor series for f(x) at x=a is given by the power series

(∑_(n=0)^∞)(((f^((n)))(a))/(n!))(((x-a))^n)=f(a)+f'(a)(x-a)+((f''(a))/2)(((x-a))^2)+((f'''(a))/6)(((x-a))^3)+.....

The Mathematica command Series[f,{x, a, n}] generates the power series of f at x=a to the order (((x-a))^n).  It is not possible to write all the terms explicitly since there are infinitely many.

Example 10.24.  Let f(x) =((1+x)/(1+(x^2))).

a) Find the first ten terms of the Taylor series of f at x =0.
b) Estimate the radius and interval of convergence of the Taylor series of f at x =0.

Solution:

a) We use the Series command to obtain the Taylor series as follows:

Clear[f,x]
f[x_]:=((1-x)/(2+x))

Series[f[x],{x, 0, 10}]

This output gives the Taylor series to order n=10.

b) To first gain intuition for the radius of convergence of the Taylor series, we define the nth Taylor polynomial of f(x) as a function of n (note our use of the Normal command to truncate the remainder term from the Taylor series).

Clear[T,x,n]
T[x_,n_]:=Normal[Series[f[x],{x, 0, n}]]

Here is a list of the first 20 of these polynomials.

Table[T[x,n],{n, 0, 10}]

Observe that each polynomial appears twice, that is, (Subscript[T, 2n])=(Subscript[T, 2n+1]), since f is an even function.  Next, we plot the graphs of some of these polynomials:

Clear[plot1]
plot1=Plot[Evaluate[Table[T[x,n],{n, 1, 20}]],{x,-5,3},PlotRange->{-10,10}]

To compare the graph of these polynomials, we plot the graph of f and use the Show command.

Clear[plot2]
plot2=Plot[f[x], {x,-5,3}, PlotRange->{-10,10}, PlotStyle->Red]

Show[{plot1, plot2}, PlotRange->{-10,10}]

Observe that the graphs of the Taylor polynomials in the preceding plot seem to give a good approximation to f only inside the interval (-2,2).  This suggests that the radius of convergence is 2.  This becomes more evident as we plot the graph of (Subscript[T, n]) for large values of n as shown in the following plot, where n=30,35,40,45,50.

Clear[plot3]
plot3=Plot[Evaluate[Table[T[x,n],{n, 30, 50,5}]],{x,-3,3}];
plot4=Plot[f[x], {x,-5,3}, PlotStyle->{Red, Thickness[0.002]}];
Show[{plot3, plot4}, PlotRange->{-10,10}]

To prove that the radius of convergence is indeed R=2, we first find a formula for the Taylor coefficients.  Based on the following table, it is clear that (Subscript[a, 0])=1/2 and (Subscript[a, n])=(((-1))^n)3/(2^(n+1)) (prove this for all n).

a[n_]:=D[f[x],{x,n}]/n!/.x->0
Table[a[n],{n,0,10}]

We now apply the Ratio Test on (∑_(n=0)^∞)(Subscript[a, n])(x^n).

Clear[a]
a[n_]=(-1)^n*3/2^(n+1)
r=Limit[Abs[((a[n+1])/(a[n]))],n-> ∞]

Hence, the radius of convergence is R=1/r=2.

Next, we determine whether the endpoints should be included in the interval of convergence.  For this, we evaluate our Taylor series at x=-2 and x=2.

(∑_(n=1)^∞)a[n](-2)^n
(∑_(n=1)^∞)a[n](2)^n

This shows that the Taylor series diverges at both endpoints.  Thus, the interval of convergence is (-2,2).

Example 10.25.  Let f(x)  =  sin x.

a) Find the Taylor series of f at x =0.
b) Find the radius and interval of convergence of the Taylor series.

Solution:

a) We repeat the steps in the previous example.

Clear[f]
f[x_]:=Sin[x]

Clear[T]
T[x_,n_]:=Normal[Series[f[x],{x, 0, n}]]

Table[T[x,n],{n, 0, 10}]

Observe that all terms of the Taylor polynomials are odd powers of x.  Can you explain why?

Here is a plot of the graphs of the first ten of these polynomials and the function f.

Clear[plot1,pl0t2]
plot1=Plot[Evaluate[Table[T[x,n],{n, 0, 10}]],{x,-3Pi,3Pi}];
plot2=Plot[f[x], {x,-3Pi,3Pi}, PlotStyle->Red];
Show[{plot1, plot2}, PlotRange->{-10,10}]

b) Observe that the higher the order of the Taylor polynomial the better it approximates f over a wider interval.  To see this more clearly, we plot (Subscript[T, n]) for n=20,40,60.

Clear[plot1,plot2]
plot1=Plot[f[x], {x,-40,40}, PlotStyle->Red,PlotRange->{-5,5}];
plot2=Plot[ Evaluate[T[x,20]]  ,{x,-40,40 }, PlotStyle->Blue,PlotRange->{-5,5}];
plot3=Plot[ Evaluate[T[x,40]]  ,{x,-40,40 }, PlotStyle->Blue,PlotRange->{-5,5}];
plot4=Plot[ Evaluate[T[x,60]]  ,{x,-40,40 }, PlotStyle->Blue,PlotRange->{-5,5}];
Show[{plot1, plot2}]

Show[{plot1, plot3}]

Show[{plot1, plot4}]

The preceding plots suggest that the radius of convergence for the Taylor series of sin x is R=∞.  To prove this, we first find a formula for the Taylor coefficients {(Subscript[a, n])}.  Again, based on the following table, it is clear that (Subscript[a, n])=sin(π n/2)/n! (prove this for all n).

a[n_]:=D[f[x],{x,n}]/n!/.x->0
Table[a[n],{n,0,10}]

We now apply the Root Test on (∑_(n=0)^∞)(Subscript[a, n])(x^n).

Clear[a,n,r]
a[n_]=Sin[Pi*n/2]/n!
Table[a[n],{n,0,10}]
r=Limit[Abs[a[n]]^(1/n),n-> ∞]

Hence, the radius of convergence is R=∞.

Exercises

In Exercises 1 through 6,  determine the radius and interval of convergence for the given power series.

1. (∑_(n=1)^∞)(((((-1))^(n+1))(x^n))/(4^n)) 			2. (∑_(n=0)^∞)(2n)!((x/2))n			3. (∑_(n=1)^∞)((n!(x^n))/((2n)!))
4. (∑_(n=0)^∞)(((-1))^n)((x^n)/(n+1))			5. (∑_(n=0)^∞)(((4x))^n)  				6. (∑_(n=0)^∞)((((2x))^n)/(n!))

7. Give examples of power series that have an infinite radius of convergence, a radius of convergence containing only the center, and a radius of convergence of one.

8. Find the Taylor series for f(x)=(e^(2x)) centered about c=0.

9. Find the Taylor series for f(x) = ln x centered about the point c = 1.

In Exercises 10 through 12, find the MacLaurin series for each of the given function.

10. f(x) =sin 2x			11. g(x)=sinh x			12. h(x)=(arc sin x)/x

13. Consider the function f(x)={({{(e^(-1/(x^2))) if x≠0}, {0             if x=0}}).  
a)  Plot the graph of this function using Mathematica.
b)  Use the limit definition of the derivative and L'Hopital's Rule to show that every higher-order derivative of f at x=0 vanishes.
c)  Find the MacLaurin series for f.  Does the series converge to f?

14. Use Taylor series to evalaute the following definite integral, which cannot be integrated via elementary means:

(∫_0^1)((sin x )/x)dx.

15. Find the following limit using the theory of Taylor series.

(Subscript[lim , x-> 0]) ((1-cos x)/x)

Chapter 11 	Parametric Equations, Polar Curves, and Conic Sections

11.1  Parametric Equations

Students should read Sections 11.1-11.2 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

Parametric equations are useful for describing curves not modeled by functions or motions parametrized by quantities such as time.  The standard form for a set of parametric equations is

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

where t is called the parameter.

11.1.1.  Plotting Parametric Equations

The Mathematica command for plotting a curve defined by parametric equations x=f(t) and y=g(t) for a≤t≤b is ParametricPlot[{f(t),g(t)},{t,a,b}].

Here are some examples:

Example 11.1.  Plot the curve described by the parametric equations x =cos t and y=sin t for 0≤t≤2 π.

Solution:

ParametricPlot[{Cos[t],Sin[t]},{t,0,2π},ImageSize->200]

NOTE: Recall that the above parametric equations represent the unit circle. However, Mathematica may produce a graph that, depending on its default settings, looks visually like an ellipse due to different scalings of the x- and y-axes.  In that case, the plot option AspectRatio can be used to specify the ratio of the height to the width for a plot.  For example, to stretch the plot above so that the circle becomes elliptical where the height is twice as long as the width, we can set AspectRatio equal to 2.

ParametricPlot[{Cos[t],Sin[t]},{t,0,2π},AspectRatio->2,ImageSize->200]

Example 11.2.  Plot the curve described by the parametric equations x =(t^2)-4 and y=t/2 for -2≤t≤3.

Solution: Here is a plot of the curve:

ParametricPlot[{t^2-4,t/2},{t,-2,3}]

Example 11.3.  Plot the curve (prolate cycloid) described by the parametric equations x =2θ-4sin θ and y=2-4cos θ for 0≤t≤2 π and determine its y-intercepts.

Solution: We first plot the curve:

Clear[f,g,θ]
f[θ_]=2θ-4Sin[θ];
g[θ_]=2-4Cos[θ];
ParametricPlot[{f[θ],g[θ]},{θ,-4Pi,4Pi},
PlotLabel->"Prolate cycloid"]

To find the y-intercepts (there appears to be two based on the graph), we solve f(θ)=0 for θ:

Solve[f[θ]==0,θ]

Observe that the Solve command here fails to give us an answer since the equation is non-algebraic.  However, note that the negative y-intercept is trivially located at y=-2 corresponding to θ=0.  The other (positive) y-intercept must be solved numerically using the FindRoot command (even the NSolve command fails in this case), where we provide a nearby location (θ=π/2) for our desired solution.

root=FindRoot[f[θ]==0,{θ,Pi/2}]

g[root[[1,2]]]

Thus, the second y-intercept is located approximately at y≈f(1.89549)=3.27609.

NOTE: Observe that we used of the option PlotLabel to print the label "Prolate cycloid" in the plot above. In general, the inside PlotLabel ->"text" inside a plot command prints the title text for the given plot.

11.1.2.  Parametric Derivatives

Recall that for a curve described by parametric equations x=f(t) and y=g(t), its derivative dy/dx can be expressed as a ratio between the parametric derivatives dy/dt and dx/dt (application of the Chain Rule):

(dy/dx)=((dy/dt)/(dx/dt))=((g'(t))/(f'(t)))

where it is assumed that f'(t)≠0.

Example 11.4.  Consider the following parametric equations (folium of Descartes):

x=((4t)/(1+(t^3))) and y=((4(t^2))/(1+(t^3)))

a) Plot the curve described by the parametric equations above (select an appropriate interval for t that captures all the salient features of the graph).
b) Find all points of horizontal tangency on the curve.
c) Find the derivative at the tip of the folium.

Solution:

a) Here is a plot of the folium of Descartes on the interval [0,20]:

Clear[f,g,t]
f[t_]=3t/(1+t^3);
g[t_]=3t^2/(1+t^3);
ParametricPlot[{f[t],g[t]},{t,0,20},PlotRange->All,AspectRatio->1,
PlotLabel->"Folium of Descartes",ImageSize->200]

NOTE: The plot above does not reveal the full graph of the folium.  A more complete graph is shown in the following plot.  The dashed line indicates an asymptote.  Can you generate a Mathematica plot of it?  Can you find an equation of the asymptote (see Exercise 7)?  Hint: Beware of the discontinuity at t=-1.

b) In order to find points of horizontal tangency, that is, points where the slope of the tangent line is equal to zero, it suffices to solve (dy/dx)=0, or equivalently, (dy/dt)=0 (assuming (dx/dt)≠0).  Hence, we evaluate

Solve[D[g[t],t]==0,t]

Since (dx/dt) does not vanish at t = 0 and t = (2^(1/3)) (we ignore the imaginary solutions), we conclude that there are two points corresponding to these values at which the tangent lines are horizontal, namely at (0,0) and ((2^(1/3)),(2^(2/3))):

{f[t],g[t]}/.t->0
{f[t],g[t]}/.t->(2^(1/3))

c) To locate the tip of the folium, we take advantage of the folium's symmetry to argue that the slope of the tangent at the tip must equal -1 (parallel to the asymptote of the folium).  Thus, we solve (dy/dx)=-1, or equivalently, g'(t)=-f'(t), for t:

sol=Solve[g'[t]==-f'[t],t]

f[sol[[1,1,2]]]
g[sol[[1,1,2]]]

Thus, the tip is located at (3/2,3/2).

11.1.3.  Arclength and Speed

The arc length of a curve described by parametric equations x=f(t) and y=g(t), a≤t≤b, is given by

s=(∫_a^b)(Sqrt[((((dx/dt)))^2)+((((dy/dt)))^2)])dt

Suppose (x(t),y(t)) now represent the position of a particle moving along a path at time t.  The distance traveled by the particle over the interval [(Subscript[t, 0]),t] is given by

s(t)=(∫_(Subscript[t, 0])^t)(Sqrt[((((dx/du)))^2)+((((dy/du)))^2)])du

and

(ds/dt)=(Sqrt[((((dx/dt)))^2)+((((dy/dt)))^2)])

represents its speed (length of the velocity vector (x'(t),y'(t))).

Example 11.5.  Find the arc length of the curve x = (e^(-t)) cos t,  y =(e^(-t)) sin t for 0≤t≤π/2.

Solution: Here is a plot of the curve:

Clear[x,y,t]
x[t_]=E^(-t)*Cos[t];
y[t_]=E^(-t)*Sin[t];
ParametricPlot[{x[t],y[t]},{t,0,Pi/2},ImageSize->250]

To find its arc length, we compute

(∫_0^(π/2))√((D[x[t],t])^2 +(D[y[t],t])^2)\[DifferentialD]t

N[%]

This answer makes sense based on the graph.

Example 11.5.  A particle moves along a path described by x = (t^2)-4,  y =t/2.
a) Find the distance traveled by the particle over the interval [-3,3].
b) What is the particle's minimum speed over the same interval?  When does this occur?

Solution:
a) The distance traveled is given by

Clear[x,y,t]
x[t_]=t^2-4;
y[t_]=t/2;
(∫_(-3)^3)√((D[x[t],t])^2 +(D[y[t],t])^2)\[DifferentialD]t

N[%]

a) We make a plot of the particle's speed:

speed=√((D[x[t],t])^2 +(D[y[t],t])^2)
Plot[speed,{t,-3,3},ImageSize->250]

This shows that the minimum speed is 1/2 and occurs at t=0.  Can you verify this using calculus techniques?

Exercises

In Exercises 1 through 3, sketch the curve represented by the given parametric equations.  Be sure to select an appropriate interval for the parameter that captures all the salient features of the curve.
1.  x=(t^3) , y = (t^2)/2		2.  x=2(θ-sin θ),  y= 1-cos θ		3.  x=3(cos^3)θ, y=3(sin^3)θ

4. Find all points of horizontal and vertical tangency to the curve x= cos θ + θ sin θ,  y= sin θ - θ cos θ,  0≤θ≤2π.

5. Consider parametric equations given by x= 3 cos (t/3) - cos t and y = 3 sin (t/3) - sin t.
a) Graph the curve represented by the parametric equations above.
b) Find the slope of the line tangent to the curve at the point where t = π/4.
c) Find the arc length of the curve from t=0 to t = 3π/2.

6. Consider a particle moving along a curve described by x=t-cos t and y=t-sin t with respect to time t.
a) Approximate the distance traveled by the particle over the interval [0,2π].  Hint: Use the NIntegrate command.
b) Find the minimum and maximum speeds of the particle over the same interval.  At what times do they occur?

7. Cornu's spiral (also known as Euler's spiral) is a curve defined by the following Fresnel integrals:

x(t)=(∫_0^t)cos((u^2))du, y(t)=(∫_0^t)sin((u^2))du

a) Plot Cornu's spiral for -10≤t≤10.
b) Compute the length of Cornu's spiral over the same interval.  Then find a formula for the length of Cornu's spiral over the interval a≤t≤b.
c) Determine the coordinates of the center of the two "eyes" that form Cornu's spiral.

8. Find the asymptote corresponding to the folium of Descartes (see Example 11.4) and plot the asymptote together with the folium of Descartes.

11.2   Polar Coordinates and Curves

Students should read Sections 11.3-11.4 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

Polar coordinates, expressed as (r,θ), represent the location of a point on the Cartesian plane in terms of distance r from the origin and angle θ with respect to the positive x-axis.

11.2.1.  Conversion Formulas

Conversion between Cartesian (rectangular) coordinates (x,y) and polar coordinates (r,θ) can be achieved by the following formulas:

(r^2)=(x^2)+(y^2)
θ=(tan^(-1))y/x		x=r cos θ
y=r sin θ

Example 11.6.  Perform the following conversions:
a) Convert the rectangular coordinates (3,4) into polar coordinates.
b) Convert the polar coordinates (7,π/3) into Cartesian coordinates.

Solution:

a) Using the first set of conversion formulas above, we find that

r=(Sqrt[(3^2)+(4^2)])
θ=N[ArcTan[4/3]]

b) This time, we use the second set of conversion formulas:

x=7*Cos[Pi/3]
y=7*Sin[Pi/3]

11.2.2.  Polar Curves

The Mathematica command for plotting a curve described by a polar equation in the form r=f(θ) for α≤θ≤β is PolarPlot[f(θ),{θ, α, β}].

Example 11.7.  Plot the graph of the limacon r=3-4cos θ.

Solution: Here is a plot of the limacon:

PolarPlot[3-4Cos[θ],{θ,-4Pi,4Pi},
	AspectRatio->Automatic,ImageSize->200]

Example 11.8.  Plot the graph of the six-leaf rose r=2cos(3θ/2).

Solution: Here is a plot of the six-leaf rose:

PolarPlot[2Cos[3θ/2],{θ,-4Pi,4Pi},
	PlotLabel->"A Six-Leaf Rose",AspectRatio->Automatic,ImageSize->200]

Can you can modify the function to generate a 12-leaf rose?

11.2.2.  Calculus of Polar Curves

Recall that the derivative of a polar equation in the form r=f(θ) for α≤θ≤β is given by

(dy/dx)=((f'(θ)sin θ+f(θ)cos θ)/(f'(θ)cos θ-f(θ)sin θ))

Moreover, the area A of the region bounded by a polar equation in the form r=f(θ) between α≤θ≤β is given by

A=(1/2)(∫_α^β)(f^2)(θ)dθ

Example 11.9.  Locate all horizontal and vertical tangents of the limacon r=2-sin θ.

Solution: We first plot the limacon to anticipate our solution points:

PolarPlot[1+Cos[θ],{θ,-2Pi,2Pi},ImageSize->200]

From the plot above, we should expect to find two horizontal tangents and three vertical tangents.

Next, we compute the derivative of the limacon:

Clear[f,θ]
f[θ_]=1+Cos[θ]

dydx=Simplify[(f'[θ]*Sin[θ]+f[θ]*Cos[θ])/(f'[θ]*Cos[θ]-f[θ]*Sin[θ])]

To obtain horizonal tangents, we solve dy/dx=0 for θ.

dydx==0
Solve[dydx==0,θ]

Therefore, our two horizontal tangents are located at θ=±π/3.

As for vertical tangents, we solve for where the reciprocal of the derivative is zero, that is, 1/(dy/dx)=0 for θ.

1/dydx
Solve[1/dydx==0,θ]

Since the solution above only gives us the principal solution θ=0 of -tan(3θ/2)=0, we need to additionally solve 3θ/2=±π for θ, which yields our two other solutions, θ=±2π/3.

NOTE: What is the derivative at θ=π?

Example 11.10.  Find the area of the region contained inside the circle r=3sin θ and outside the convex limacon r=2-sin θ.

Solution: We first plot the two polar curves on the same set of axes.

PolarPlot[{3Sin[θ],2-Sin[θ]},{θ,0,2π},
	AspectRatio->Automatic,ImageSize->200]

Next, we find their points of intersection by equating them and solving for θ:

Solve[3Sin[θ]==2-Sin[θ],θ]

Observe that Mathematica gives only the solution θ = π/6, which lies in the first quadrant since trigonometric inverse functions are involved.  We can see from the above graph that the other point of intersection must be at θ = 5 π/6 due to symmetry. Thus, the area of the enclosed region is given by the difference in areas enclosed by the circle and limacon between θ = π/6 and θ = 5 π/6:

(1/2)(Integrate[(3Sin[θ])^2,{θ,Pi/6,5Pi/6}] -Integrate[(2-Sin[θ])^2,{θ,Pi/6,5Pi/6}])

N[%]

NOTE: Using even symmetry of our region, it would have been enough to integrate between θ=π/6 and θ=π/2 and double the result.

Exercises

In Exercises 1 and 2, use Mathematica to perform the following conversions.
1. Convert the rectangular coordinates (-1,(Sqrt[3])) into polar coordinates.
2. Convert the polar coordinates (5,3π/4) into Cartesian coordinates.  What if we replace (5,3π/4) with (-5,3π/4)?

In Exercises 3 through 6, plot the graph of each of the given polar equations and find an interval for θ over which each graph is traced only once.
3.  r=3-4 cos θ    4.  r=2+sin θ   5.  r=3cos(3θ/2)  6.  r=5 sin 2θ

7. Generate the butterfly curve r = (e^(cos θ))-2 cos (4θ)+(sin^5) (θ/12).

8. Find all horizontal and vertical tangents of the lemniscate (r^2)=cos(2θ).  Plot its graph to confirm your answers.

9. Consider the rose curve r = cos (2θ) for -2π≤ θ≤2π.
a) Plot its graph.
b) Find the area of one petal of the curve.

In Exercises 10 through 12, graph and find the area of each of the given regions.
10. The common interior of r=3-2 sin θ and r=-3+2 sin θ.
11. Inside r=2 (1+cos θ) and outside r=2 cos θ.
12. Inner loop of r=3+4 sin θ.

In Exercises 13 and 14, find the length of the given curve over the specified interval.
13.  r=1+ sin θ, 0≤θ≤2π		14.  r=6 (1+cos θ),  0 ≤ θ≤2π

15. Consider the polar equations r = 4 sin θ and r = 2 ( 2-(sin^2) θ).
a) Graph the polar equations on the same axes.
b) Find the points of intersection of the curves.
c) Find the circumference of each curve.

11.3   Conic Sections

Students should read Section 11.5 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

Conic sections refer to the three families of curves (ellipses, hyperbolas, parabolas) generated by intersecting a plane with a cone.  Recall the equations for describing each family of curves in standard position:

I. Ellipse

((((x/a)))^2)+((((y/b)))^2)=1

If b>a>0, then the ellipse has two foci located at (0,±c), where c=(Sqrt[(b^2)-(a^2)]).

II. Hyperbola

((((x/a)))^2)-((((y/b)))^2)=1

III. Parabola

y=(1/(4(c^2)))(x^2)

NOTE: These formulas assume that the "center" of the conic section is at the origin.  To translate the center to a different point, say ((Subscript[x, 0]),(Subscript[y, 0])), we replace x and y by x-(Subscript[x, 0]) and y-(Subscript[y, 0]), respectively.

The most useful command for plotting conic sections is ContourPlot[eqn,{x,a,b},{y,c,d}], where eqn is the equation of the conic.

Example 11.10.  Determine the family that each conic section below belongs to and then make a plot of each.
a) ((x^2)/9)+((y^2)/16)=1
b) y=(9/4)(x^2)
c) ((x^2)/4)-((y^2)/9)=1

Solution:

a) This conic is an ellipse.  To plot it, we evaluate

ContourPlot[x^2/9+y^2/16==1,{x,-4,4},{y,-4,4},Axes->True,Frame->False,ImageSize->200]

Observe that the length of semi-major and semi-minor axes are 4 and 3, respectively.  How would this change if we happen to switch the coefficients 9 and 16?

b) This conic is a parabola.  Since the equation here is solved for y, we merely use the Plot command:

Plot[(9/4)x^2,{x,-2,2},ImageSize->200]

c) This conic is a hyperbola.  Here is its plot:

ContourPlot[x^2/4-y^2/9==1,{x,-6,6},{y,-6,6},Axes->True,Frame->False,ImageSize->200]

Example 11.11.  Find an equation of an ellipse with center at (-1,3) and having semi-major and semi-minor axes of lengths (Sqrt[5]) and 1/2, respectively.

Solution: From the given data, we see that ((Subscript[x, 0]),(Subscript[y, 0]))=(-1,3), a=(Sqrt[5]), and b=1/2.  The equation of our ellipse is therefore:

((((x+1))^2)/5)+4(((y-3))^2)=1

To plot it, we evaluate

ContourPlot[(x+1)^2/5+4(y-3)^2==1,{x,-4,2},{y,2,4},AspectRatio->2/3,Axes->True,Frame->False,ImageSize->200]

Exercises

In Exercises 1 through 4, plot each of the given conic sections.  Can you determine the family that each conic section belongs to before plotting?  Also, what are the values of the parameters a and b (or c) in each conic section?
1.  ((x^2)/25)+((y^2)/4)=1		2.  ((y^2)/36)-((x^2)/16)=1		3.  y=3(x^2)		4.   ((((y-2))^2)/25)-((((x+1))^2)/49)=1

5. Consider the ellipse ((x^2)/9)+4(y^2)=1.
a) Make a plot of the ellipse.
b) What are the lengths of the semi-major and semi-minor axes?
c) Where are the foci located?
d) Compute the sum of the distances from the two foci to any point on the ellipse.  Do you recognize the answer?

6. Find an equation of an ellipse with center (1/2,-5) and having semi-major and semi-minor axes of lengths 3/4 and (Sqrt[7]), respectively.

7. Find all points on the hyperbola ((x^2)/25)-((y^2)/9)=1 where its slope equals 1.

8. Consider a polar curve of the form r=((d e)/(1+e cos θ)), where d and e are non-negative constants.

a) Plot this curve for d=3, and e=1/2.  Do you recognize this curve as a conic section?  Of which type?  Hint: Use the command PolarPlot.

b) Repeat part a) but this time use e=2 instead.  Do you recognize this curve as a conic section?  Of which type?

c) Repeat part a) but this time use e=1 instead.  Do you recognize this curve as a conic section?  Of which type?

d) Describe how the graph changes as we vary the values d and e.  What happens to the graph when e=0?  NOTE: The value e  is called the eccentricity of the conic section.

e) Assume 0<e<1.  Convert the polar equation r=((d e)/(1+e cos θ)) to that in standard form for an ellipse,  (((((x-(Subscript[x, 0]))/a)))^2)+(((((y-(Subscript[y, 0]))/b)))^2)=1, and determine formulas for its center, semi-major, and semi-minor axes.  Verify these formulas for the ellipse in part a).