for Calculus III

Department of Mathematics

Rowan University

Abera Abay, Abdulkadir Hassen, Gary Itzkowitz, Hieu Nguyen

August 1998

TABLE OF CONTENTS

Chapter 1. Introduction

1.1 Mathematica's Conventions 2

1.2 Calculator Operations 4

1.3 Functions 5

1.4 Basic Inputs 6

1.5 Basic Calculations 7

Chapter 2. Calclulus of One Variable

2.1 Graphs of Functions 11

2.2 Limits 12

2.2 Differentiation 14

2.3 Integration 17

Chapter 3. Parametric Equations and Polar Graphs

3.1 Parametric Curves 19

3.2 Polar Curves 23

Chapter 4. Vector Calculus

4.1 Vector Algebra 26

4.2 Vector Valued Functions 29

Chapter 5. Functions of Several Variables

5.1 Graphs of Functions of Two Variables 35

5.2 Partial Derivatives and Gradient 42

5.3 Multiple Integrals 53

Chapter One

Introduction to Mathematica

1.1 Mathematica's Conventions

1. 1. 1 Naming

Built-in Mathematica commands, functions, constants, and other expressions begin with capital letters, and are - for the most part- one or more full-length English words. Mathematica is case sensitive and so a common cause of error is the failure to capitalize command names. For example, Plot, Integrate, FindRoot, ParametricPlot3D are valid function names. Sin, Exp, Det, GCD, Max are some of the standard mathematical abbreviations that are exceptions to the full-length-English-word(s) rule. User defined functions and variables can be any mixture of upper and lower case letters and numbers. However, a name cannot begin with a number. By convention, user defined functions begin with a lower-case letter, but this is not required. For example f, g1, myPlot, r12, sOLution, Method1, are permissible function names.

Example 1: Evaluate cos(π)

Solution: We will use this example to show two possible errors before giving the correct answer.

This is a typical capitalization error one makes when using Mathematica. The comment before the output Out[1] = cos[π] indicates a possible error.

Here Mathematica did not recognize pi and hence returned the command unevaluated. The correct command to evaluate cos(π) is

NOTE: It is worth noting that Mathematica keeps track of the calculations it performs in a given session. The inputs are denoted by In[k] and the outputs are denoted by Out[k]. Thus, In[1] is the first input and Out[1] is the output of the first input.

1. 1. 2 Parentheses, Square Brackets and Braces

Mathematica interprets various types of brackets differently. Using an incorrect type of bracket is another common source of error. Mathematica's bracketing conventions are:

1) Parentheses, ( ), are used only for grouping. For example (x-y)^2, 1/(a+b), (x^3-y)/(x+3y^2). It is worth noting that Mathematica understands f(2) as f times 2, and not as the value of the function f at 2.

2) Square Brackets, [ ], are used for function arguments. Thus Sin[Pi], Simplify[(x^3-y`^3)/x-y)], Sqrt[346] are proper use of square brackets. If f is a user-defined function, then f[2] is f evaluated at 2.

3) Braces or curly brackets, { }, are used for lists, ranges, and iterators. In all cases, elements are separated by commas. Here are the typical use of braces:

{1, 4, 9, 16, 25 ,36} the list of the square of the first six positive integers.

Plot[ f[x], {x, -5,5}] specifies the range of values for x.

Table[m^3, {m, 1, 100}] specifies the values of the iterator m, i.e., the values of m; m goes from 1 to 100.

NOTE: We can write comments with an input. The comments should be enclosed by (* and *). For example, Table[ ,{ n, 1, 6 } ] (*returns a list of the square of the first six positive integers*)

Example 2: Below we give examples of the correct and incorrect usage of brackets.

1. 1. 3 Equal Signs

The following are Mathematica rules of using the equal sign symbol.

1) A single equal sign ( = ) assigns a value to a variable. Thus q=3 means that q will be assigned the value 3. If we enter 10+q^3, Mathematica will return 37. As another example take y=x^3-x+1. Now, if we assign a value for x, say x=2, then Mathematica evaluates y using that value of x and uses the result, 7 in our case, in any input containing y afterwards.

2) A colon-equal sign( := ) creates a delayed statement for an expression, used in defining a function. For example f[x_]:=x^3-x+1 will reevaluate the function f for each new value of x. We will say more about defining functions in Section 1.3 below.

3) A double equal sign( = = ) is a test for the equality of two expressions. If we set x = -5, then evaluating x == -5 returns True, and x == 5 returns False. Another common usage of == is as in Solve[x^3-x+1==0,x] (See Section 1.5 below.)

1. 1. 4 Referring to Previous Results

Mathematica remembers all of the inputs and outputs in a session, and we can refer to a previous output by using the percent sign (%) notation. A single % refers to Mathematica's last output, %% refers to the next-to-last output, and so on. %k refers to output line numbered k. For example %45 refers to output number 45.

NOTE: CTRL +L reproduces the last input and CTRL+SHIFT+ L reproduces the last output.

1.2 Basic Calculator Operations

Mathematica uses +, - , * , / , and ^ for addition, subtraction, multiplication, division and power, respectively. Multiplication can also be performed by leaving a blank space between factors.

Mathematica can convert numerical values to decimal form. The command for this is N[expr] or N[expr,n]. In most cases, N[expr] returns six digits of expr or gives expr in the form n.abcde*. N[expr,n] attempts to give n digits of expr. Mathematica can perform calculations to arbitrary precision and can handle numbers that are arbitrarily large or small.

Example 3: Here are some typical usages of N[..]

Note that the command N[%] gives a decimalized version of the last output. Similarily N[%k] can be used to get the decimal equivalent of Output[k].

Exercise 1.1. Evaluate the following expressions:

a) 103.41+20*76 b) c) d)

e) What is the remainder of 1998 divided by 13?

1.3 Functions

We can define our own function in Mathematica. The command for defining a function such as f(x)= in Mathematica is f[x_]:=. Once we evaluate this, Mathematica will understand f[x] as . Thus, evaluating f[a] returns the value of f at a, while evaluating f[ {a, b, c, ...}] returns the values of f at a, b, c, ... respectively. Here is an example. But first an important

Reminder: Mathematica reads f(a) as f times a.

Example 4: (a) Define the function f(x)=in Mathematica

(b) Evaluate f(10)

(c) Evaluate f(x), for x =-3, -2, -1, 0, 1, 2, 3.

Solution:

Observe that the output is not displayed. To check that we have defined our function correctly, we evaluate

Since addition is commutative, this is the given function f(x). We now proceed to solve (b) and (c).

Thus f(10)=112/11, and the last output shows that f(-3)=-4, f(-2)=-4, f(-1)=ComplexInfinity, f(0)=2, f(1)=2, f(2)=8/3, and f(3)=7/2. Note that Mathematica is warning us that it has encountered the undefined expression 1/0 and gave us ComplexInfinity for f(-1).

Sometimes we may want to deal with an expression such as temporarily. To evaluate such expressions at some given value(s) of x, say, x = 10 or x =-3, -2, -1, 0, 1, 2, 3, we do not need to define the expression as a function. We can use the substitution command /. Here is how it works.

Example 5: Consider the expression .

(a) Find the value of this expression when x =10.

(b) Find the value of this expression for x=-3, -2, -1, 0, 1, 2, 3.

Solution:

Exercise 1.2. Enter the following functions into Mathematica:

a) f(x)=2-6+x-5 b) g(x)= c) h(x)=|-3|

Exercise 1.3. Evaluate the following functions using Mathematica and evaluate each function at the given point.

a) f(x)=1001+ at x=25 b) 1+++ at x=π

1.4 Basic Inputs

Mathematica 3.0 allows us to enter mathematical expressions and some of the commonly used commands from 6 different palettes. If we click on the File menu and go to Palettes we will find 7 options. The first six options conatin most of the symbols we need. BasicInput is a palette which can be used to enter mathematical expressions involving exponents, rational expressions, radicals, integrals, derivatives, summation, product, matrices, some of the commonly used constants( π, e, i, ∞) and some of the Greek letters.

Example 6: Enter dx in a notebook.

Solution: One way to enter this expression into a Mathematica notebook is as follows: Go to the BasicInput palette and click on the definite integration symbol □d□ . Type 0 in the lower box and using the TAB key move to the top box and type 1. Use the TAB to go to the box where the integrand should be typed. While in this box go to the palette and click on . Go back to the pallete and click on and type in this box. Go to the box in the denominator and then go to the palette to click on and type 2x-1. Finally, using the TAB once again, go to the last box and type x.

Exercise 1.4: Enter the following expressions in a notebook.

(a) (b) (c)

(d) (e) (f)

1.5 Basic Calculations

The BasicCalculations palette contains several options. These are Arithmetic and Numbers, Algebra, Lisits and Matrices, Trigonometric and Exponential Functions, Calculus, Other Functions, and Graphics. Each of these is preceeded by a triangle. Click on the shape to see the contents of a palette in a category. In this section, we will discuss the options in Algebra and Calculus triangle.

1.5.1 Algebra

Algebra is subdivided into three parts: Solving Equations, Polynomial Manipulation and Complex Numbers.

Polynomial Manipulation contains the commands Expand[ ], Factor[ ], Together[ ], Apart[ ], Cancel[ ], Simplify[ ], FullSimplify[ ].

NOTE: The commands Expand, Factor, Together, Apart, Cancel, Simplify, FullSimplify, TrigExpand, TrigFactor, TrigReduce, ExpToTrig, PowerExpand, and ComplexExpand can also be entered from AlgebraicManipulation palette of the Palettes submenu. However, the commands in AlgebraicManipulation palette are applied after entering and highlighting the expressions to which we apply the command and click on the button of the command we want from the palette. The result of a command will replace the input we have entered. In other words, the commands of AlgebraicManipulation palette are in-place simplifications.

Solving Equations contains different forms of the Solve commands. Solve[ lhs == rhs, var] is the command to solve the equation lhs = rhs for the variable var. Thus, Solve[-1==0,x] is the command to solve -1=0 for x. In such cases where there is only one variable in the equation, we may not need to specify the varaible. Thus, Solve[-1==0,x] and Solve[-1==0] give the same solutions. Solve[{ == ,== ,... },{,,...} ] solves a system of equations for the variables ,,...

Numerical approximations of solutions may be obtained by the command NSolve[ lhs==rhs,var].

Example 7: Expand each of the following:

(a) (x+1)(x-1) (b) (x+y-2)(2x-3)

Solution: The command we need is Expand[...].

Example 8: Factor each of the following:

(a) -2-3x (b) 4+8 +4

Solution: We use the Factor[...] command.

Example 9: Simplify the given expressions.

(a) (b) (c) +

Solution: We will first use Simplify or FullSimplify command and then apply Together.

Note that the last result of (c) is not in its simplest form (1+x -2 )/. Thus, we should keep in mind that the commands Simplify and FullSimplify are efficient for polynomials and rational function but may not be efficient for expressions involving radicals , trigonometric functions, and exponentials.

Example 10 : Perform the indicated operations:

(a) -++ (b) (-)÷(+4)

Solution:

Example 11: Solve the folowing equations:

a) -x-1=0 b)

2x + 13y = 4 |

3x -3y =- 5 |

Solution:

Exercise 1.5. Expand each of the following expressions:

a) (x+1)(x-1) b) (x+y-2)(2x-3)

Exercise 1.6. Factor each of the following expressions:

a) -2-3x b) 4+8+3.6 c) 6+2x-3-

Exercise 1.7. Simplify the following expressions using both of the commands Simplify and FullSimplify:

a) b) c) +

Exercise 1.8. Perform the indicated operations:

a) -++ b) (-)÷(+4)

Exercise 1.9. Solve the following equations for x:

a) -x+1=0 b) +=0

Exercise 1.10. Approximate the solution of the equation tan x + =0 near x=0.

1.5.2 Calculus

The Calculus palette is subdivided into three parts: Common Operations, Differential Equations and Numerical Root Finding. Common Operations contains a palette for integration, derivative, limit, summation, product, and series. The symbols for all of these can also be entered from the BasicInput palette, which was discussed in Section 1.4 above.

Differential Equations contains a palette for solving differential equations symbolically as well as numerically. The last part, Numeric Root Finding, contains commands for finding numerical solutions for equations by specifying an initial approximation of a root. FindRoot [ lhs==rhs,{x,}] finds a root of the equation lhs=rhs in the variable x with a first approximation . FindRoot[ lhs==rhs,{x,, a,b}] searchs for a root between a and b. For transcendental equations or for search of a zero of a function near a given point FindRoot is recommended. We give an example below.

Example 12: Solve the equation: sin2x + cosx =0

Solution: We will use Solve command first and then FindRoot.

Thus, Solve does not give a solution while FindRoot does. In fact, FindRoot yields the solution x = -0.523599 or x = -π /6 for the equation sin 2x + cos x = 0. This solution is the one closest to x = 0. Similarily we can find the solutions of this equation near other points, such as 1, 2, 3, .... We leave this to the student as an exercise. In the next chapter, we shall learn how to draw graphs of functions. Here is the graph of f(x) = sin(2x) + cosx.

CHAPTER TWO

CALCULUS OF ONE VARIABLE

2.1 Graphs of Functions

Plot[f,{x,a,b}] generates a plot of f as a function of x as x goes from a to b. Plot[ { , , , ... }, { x, a, b } ] plots the graphs of the functions , , ... over the interval [a,b]. Plot has many options most of which we will discuss in this chapter. In Mathematica 3.0 Plot can be entered from the menu File-Palette-BasicCalclulations-Graphics.

Plot[x+5/x , {x,-5,5}];

Example 2: Plot the graphs of the functions and on the same set of axes for -4≤x≤4.

Notice that the graph of ( + x + 2)/(x+1) is not visible in this output since the range from -1 to 1 along the vertical axis is too small. We can expand this range by using the PlotRange option:

Exercise 2.1. Plot the graphs of the following functions on the specified interval:

a) f(x)=+1 on [-5,5] b) g(x)= on [0,4] c) h(x)= on [-π,π]

Exercise 2.2. Plot the graphs of f(x)=0.01x(x-3)(x+3) and g(x)=2x+1 together on the same set of axes and over the interval [20,20]. Use the PlotRange option to change the range so that their points of intersection are visible.

2.2 Limits

Limit[f, x -> a] finds the limit of the function f when the variable x approaches a. The command for the left hand-side limit is Limit[f, x->a, Direction->1] and for the right hand-side limit is Limit[f, x->a, Direction->-1]. If it encounters functions about which it has no specific information, Limit returns an unevaluated expression. Limit returns an interval to represent a range of possible values of the function when a limit does not exist.

Example 3: Evaluate

lim |

x→1 |

Limit[(x^2+x+2)/(x+1),x->1]

Example 4: Evaluate

lim |

x→0 |

Limit[Sin[4x]/Tan[x],x→0]

Example 5: Evaluate

lim |

x→∞ |

(Note: To enter the Euler number e, you can either type E or obtain it from the BasicInput palette, where you can also find ∞ among others).

Limit[e^(x)/x,x->∞]

Example 6: Evaluate

lim |

Note: The natural logarithmic function ln x is one of the built-in Mathematica functions and is entered as Log[x]. The logarithmic function x is entered as Log[a,x].

Limit[(1/Log[x])-(1/(x-1)),x->1,Direction->-1]

Example 7: ( An example where the limit does not exist.) Evaluate

lim |

x→∞ |

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

Exercise 2.3. Compute the following limits:

a) - b) c) d) sin

e) ( ) f)

lim ( sec 3x cos 5x) |

Exercise 2.4. Find the derivative of f(x)=cos x according to the limit definition and evaluate the answer at x=π.

2.3 Differentiation

All the rules of differentiation are programmed into Mathematica. This makes it easy to differentiate complicated expressions. The notation D[ f, x ] calculates the derivative of the function f with respect to the variablre x. We can obtain higher derivatives of order n, by using the command D[f, { x, n } ]. In Mathematica 3.0 we can get the command for derivatives from the File-Palette-BasicCalculations-Calculus-Common Operations. The symbol for the derivative of a functions of one variable is □ .

Example 8: Find the derivative of x sin x and the value of the derivative at x=.

Solution: There are a number of ways to find this derivative. One way is to type in D[x*Sin[x], x]. The second method is to go to the Common Operations submenu of Calculus and click on □, and in the lower box type x and use the TAB key to move to the second box and type the function, in this case x*Sin[x]. The third way is to type f=x*Sin[x] and compute D[f, x]. Yet, another way to find the derivative is by defining a function. This is done by typing f[x_] := x*Sin[x]. Now we can just type f'[a] to find the derivative of f at a. It is very important to Clear any previous use of the letters you are going to use to denote a function or an expression. Here is an illustration of each of the above methods. In all the methods except Method 5, we will use the substitution command expr /.x-> a which replaces x in expr by the value a.

Method 1:

D[x*Sin[x],x]

D[x*Sin[x],x]/.x-> π/4

Method 2: (Note: x sinx should be written between parentheses. Can you guess why?)

Method 3:

Clear[f]

f = x*Sin[x]

Df= D[f,x]

Df /. x->Pi/4

Method 4:

Clear[f]

f[x_] := x*Sin[x]

D[f[x],x] /. x -> Pi/4

Method 5:

f'[Pi/4]

Example 9: Find the second derivative of x

Solution: We give two methods:

Method 1: We use the command D[f, { x, 2 } ] for the second derivative of f.

D[x*Sqrt[x^2-1],{x,2}]

Together[%]

Method 2: We use the prime notation of the derivative by defining a function in Mathematica :

Example 10: Find an equation of the tangent line to the graph given by (+)= at the point (,).

Solution: We need to find the slope of the tangent line. That is, find at x= and y=. To this end, we rewrite the given equation as (+)= so that Mathematica will understand y as a function of x. We shall call this equation eq. Then we solve deq= D[eq,x] (this is the derivative of eq with respect to x) for y'[x] and substitute x and y[x] by . (Note: An equation in Mathematica is entered as ==.) Here are the steps outlined above.

eq =(x^2(x^2+y[x]^2)==y[x]^2)

deq=D[eq,x]

soln = Solve[deq,y'[x]]

m= soln /. {x->Sqrt[2]/2, y[x]->Sqrt[2]/2}

The output {{[]→3}} means that the slope is 3.(Can you see why?) Finally we write the equation of the tangent line as:

y=3(x-Sqrt[2]/2)+Sqrt[2]/2

Thus, the equation of the tangent line is y=3 x-.

Exercise 2.5. Compute the derivatives of the following functions:

a) f(x)= 3+1 b) g(x)= c) h(x)= d) y=ln(cos()) e) y=arcsec x

Exercise 2.6. Evaluate the derivatives of the following functions at the specified values of x:

a) f(x)=(x-1)(x+1) at x=1 b) g(x)= at x=9

Exercise 2.7. Compute the second derivatives of the functions given in Exercise 2.5.

Exercise 2.8. Find an equation of the line tangent to the graph of x+=0 at the point P(9,-3).

Exercise 2.9. Find all relative extrema of the function: a) f(x)=-7+10 and b) f(x)=.

Exercise 2.10. Find all relative extrema of f(x)= - 1/2 x. Also, find the absolute minimum and absolute maximum values of f(x) on [0,2].

Exercise 2.11. Use implicit differentiation to find if y+3x -x=3. Also find the equation of the tangent line to the graph of the equation at the point (1,1).

Exercise 2.12. Let f(x)= for -2π≤x≤2π

(a) Define f in Mathematica

(b) Find the solutions of f ' (x)=0. (Hint: Use FindRoot )

(c) Identify the relative extrema of f.

(d) Find the inflection points of f.

(e) Verify your answers in (b), (c), and (d) by drawing the graph of f.

2.3 Integration

Integrate[ f, x] gives the indefinite integral of f . Integrate[f, {x, a,b}] gives the definite integral of f over the interval [a , b]. Integrate can evaluate integrals of rational functions. It can also evaluate integrals that involve exponential, logarithmic, trigonometric and inverse trigonometric functions, so long as the result comes out in terms of the same set of functions. Integrate[ f, x] and Integrate[f, {x, a, b}] can be entered from ( what should by now be) the familiar menu File-Palette-BasicCalculations-Calculus-Common Operations. We can get a numerical result by applying N to a definite integral. That is, NIntegrate[f, {x, a, b}] gives a numerical approximation to the definite integral f(x) dx.

Example 11: Evaluate ∫dx

Solution: We give two methods. In the first method, the input will be entered without using a palette. In the second method we will use a palette for the input.

Method 1:

Integrate[x(x^2+1)^2,x]

Method 2:

Question: If you use the substitution method the answer you get is +C. How do we reconcile these differences?

Example 12: Evaluate ∫dx

Solution:

Note: All functions in an output appear in Mathematica's notation. To convert a function in an output to a more familiar form use the command TraditionalForm. For the above example the "traditional" form is obtained as follows. (Note that log x is the same as ln x.)

Example 13: Approximate tan dx

Solution: The first thing we want to do is let Mathematica evaluate the integral. If Mathematica returns an unevaluated integral , we use either N[%] ( a command for numerical approximation of the previous output) or NIntegrate[f, {x, a, b}] .

The above two steps can be combined as follows:

Exercise 2.13. Integrate each of the following and check your work by differentiating the answer.

a) ∫(+2)dx b) ∫cos 3xdx c) ∫dx d) ∫dx

Exercise 2.14. Evaluate each of the following integrals.

a) dx b) xdx c) dx

Exercise 2.15. Approximate the area under the curve y= and above the interval [0,1]. (How does this answer compare with the answer in part c, Exercise 2.14 a)?)

Exercise 2.16. Compute the arc length of the curve:

a) y= along the interval [0,1]. b) y = 1/6 + 1/(2x) on [1,3].

Exercise 2.17. a) Compute the area of the region enclosed by the graphs of f(x)= and g(x)=x.

b) Sketch the region that is bounded by the graphs of f(x) = and g(x) = 2x+1 and find the area of the region.

CHAPTER THREE

PARAMETRIC EQUATIONS AND POLAR GRAPHS

3.1 PARAMETRIC CURVES

Example 1: Sketch the curve described by the parametric equation

x =cos t ; and y=sin t, 0 !≤ t !≤ 2π

Solution:.

Recall that the above parametric equations represent the unit circle. However, Mathematica produced a graph that visually looks like an ellipse due to the different settings of the x and y-axes. An important option to fix this is to use the option AspectRatio. The default value of aspect ratio, which is the ratio of the height to the width of a plot, is 1/GoldenRatio and its value is

This value was chosen because it produces plots that are pleasing to the eye. However, to get a plot that accurately represents the graph of the given equations we need to set aspect ratio to automatic. We do this as follows.

Example 2: Sketch the curve described by the parametric equation

x = - 4; and y= , -2 !≤ t !≤ 3

Solution:.

Example 3: Sketch the curve (prolate cycloid) described by the parametric equations

x =2θ - 4 sinθ and y= 2 - 4 cosθ.

Solution:

Note that in the above input we have used the the command PlotLabel. In general, the command PlotLabel ->"text" prints the title text for the given plot.

b) In order to find the points of horizontal tangency, we find the points where the slope of the tangent line is zero. Hence, we evaluate

Thus, there are two points, corresponding to t = 0 and t = , at which the tangent lines are horizontal.

Example 5: Find the arc length of the curve x = cost, y = sint; 0 !≤ t !≤ .

Solution:

Exercise 3.1. Sketch the curve represented by the parametric equations.

a) x= , y = /2 b) x=2(θ-sin θ), y= 1-cos θ c) x=3 θ, y=3θ

Exercise 3.2. Find all points of horizontal and vertical tangency to the curve

x= cos θ + θ sin θ, y= sin θ - θ cos θ, 0 !≤ θ !≤2π.

Exercise 3.3.Consider the 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.

b) Find the slope of the tangent line at the point where t = π/4.

c) Find the length of the arc from t=0 to t = 3π/2.

3.2 POLAR CURVES

In order to graph polar equations in Mathematica, we must load the package for polar plotting, We do this prior to plotting and by typing:

Example 6: Sketch the graph of r = 3 - 4 cosθ.

Solution:

Example 8: Find the area of the region that is inside the circle r = 3 sinθ and outside the convex limacon r = 2- sinθ.

Solution: First, we plot the two polar curves on the same axes.

Next, we find the values of θ that correspond to the two points of intersection of the above curves.

Note that Mathematica gives only the solution θ = which lies in the first quadrant since inverse functions are being used. We can see from the above graph that the other point of intersection must be at θ = . Thus, the area enclosed is given by (using symmetry)

Exercise 3.4. Graph the given polar equation and find an interval for θ over which the graph is traced only once.

a) r = 3 -4 cos θ b) r = 2 + sin θ c) r= 3cos(3θ/2) d) r= 5 sin 2θ

Exercise 3.5. Consider the rose curve r = cos ( 2θ) for -2π !≤ θ !≤ 2π.

a) Graph the curve.

b) Find the area of one petal of the curve.

Exercise 3.6. Generate the butterfly curve r = - 2 cos (4θ) + (θ/12).

Exercise 3.7. Graph and find the area of each of the following regions.

a) The common interior of r=3- 2 sin θ and r=-3+2 sin θ

b) Inside r=2 (1+cos θ) and outside r=2 cos θ

c) Inner loop of r=3+4 sin θ

Exercise 3.8. Find the length of the given curve on the specified interval.

a) r=1+ sin θ , 0 !≤ θ!≤2π. b) r=6 (1+ cos θ), 0 !≤ θ!≤2π.

Exercise 3.9. Consider the polar equations r = 4 sin θ and r = 2 ( 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.

CHAPTER FOUR

VECTOR CALCULUS

4.1 VECTOR ALGEBRA

Vectors are typed in braces with commas between components. For example if a is the vector

a= i+3j -5k we type

a={1,3,-5}

The jth components of a is denoted by a[[j]]. Vector addition, subtraction and scalar multiplications are performed in a similar way as with numbers.The dot product of vectors a and b is obtained by a.b and the length of a is obtained by Sqrt[a.a].

Example 1: Let a= i+3j -5k and b= -i+2j +3k.

Find 3a-2b, a.b, ||b||, ||a||, and the third component of 5a+4b.

Solution: First we will enter the components of a and b as lists. Then we we enter the solutions for all the problems in one cell: (Note: It is possible to enter more than one input under the same cell but on different lines. To go to a new line press the [RETURN] key. When Mathematica computes such inputs the outputs will appear in rows with consecutive output numbers.)

a={1,3,-5}

b={-1,2,3}

Example 2: Show that the dot product of vectors is commutative and that it is distributive over addtion, that is , a.b= b.a and a.(b+c)=a.b+a.c for any vectors a ,b and c.

Solution: We will show commutativity of dot product for vectors in space.

a={a1,a2,a3}

b={b1,b2,b3}

c={c1,c2,c3}

a.b-b.a

a.(b+c)-(a.b+a.c) (*if this is equal to 0, this proves the

distributive property*)

It is not clear why the last output is zero. We check this by entering:

Simplify[%]

Example 3: Let u= i+3j + 2k v= 2i+3 j and w = -2i+3j +4k. Find u × v, i×w and the saclar triple product of u, v, and w (that is (u × v).w)

Solution: In order to calculate the cross product of two vectors we need a package, called Calculus`VectorAnalysis`. It is recommended that you load this package before starting your work. The command to load this package is Needs["Calculus`VectorAnalysis`"]. To compute the cross product u × v of u and v we type CrossProduct[u,v]. In Mathematica 3.0, there is a palette that contains the command for cross product. It is in File-Palettes-Lists and Matrices-Matrix Operations and is denoted by Cross[□ ,□]. First, we load the package:

Needs["Calculus`VectorAnalysis`"]

u={1,3,2}

v={-2,3,0}

w={-2,3,4}

i={1,0,0}

prod= CrossProduct[u,v]

CrossProduct[i,w]

prod.w

Example 4: Consider the parallelepiped with sides a=i+k, b=2i+j+3k and c=i+j-2k.

a) Find the volume. b) Find the area of the face determined by b and c.

Solution:

Exercise 4.1. Let u= 2i - j + 2k and v= 5i + 4j - k.

a) Determine each of the following. i) 6u-4v ii) ||u+v|| iii) u.v

b) Find u.v and u x v.

c) Find a unit vector that is orthogonal to both u and v.

c) Find the area of the triangle determined by u and v.

Exercise 4.2. Find the volume of the parallelepiped that is detremined by the vectors u=i +j and v=j + k and w = i +k .

Exercise 4.3. Let u = i + j + k, v = i + j + k and w = i + j + k be vectors in space. Prove that:

a) u x ( v + w ) = ( u x v ) + ( u x w) b) u . ( v x w ) = v . ( w x u )

4.2 VECTOR VALUED FUNCTIONS

The derivative of a vector valued function r(t) ={ x(t) , y(t) , z(t) } of a single variable t can be obtained by entering D[r,t]. Another way is to type MapThread[ D,{r, {t, t, t}}]. MapThread applies the operator D (i.e., differentiation) to each of the three components of r with respect to the corresponding parameter in { t, t, t }, so that we get , , and .

Example 5: Find the first and second derivative of r(t)=a cost i +asin t j+ bt k.

Solution: We will give two different methods. First, we want to make an observation. Once you use letters like a ,b, x, y, etc, to represent a certain quantity, Mathematica will keep using those values for every input containing those letters. Thus, before using the same letter for another representation we should tell Mathematica to clear the prevoius usage of the letters. The command for this is (naturally) Clear[....]. For both methods we define r in Mathematica.

Method 1:

Method 2:

Example 6: Represent the hyperbola 4-9=36 , x ≥ 3, in parametric form and find the equation of the tangent line at (3,0).

Solution: One way of representing the curve in parametric form is by using hyperbolic functions and letting

x= 3 cosh t, and y= 2 sinh t.

To find the equation of the tangent line we proceed as follows:

We solve r(t) = (3,0) to find the value of t that corresponds to the point (3,0). Once we find this value, say , we use the formula q(w)=r()+ w r'() for the tangent line.

Thus, a parametric equation of the tangent line is x=3, and y=2w. The following is the graph of the curve and the tangent line at (3,0).

Example 7: Consider the curve given by r(t)=a cost i +a sint j+ ct k.

a) Find the length of the curve from (a,0,0) to (a,0,2πc).

b) Find the arc length parametrization of the curve.

c) Find its curvature.

Solution: We begin by defining r(t) in Mathematica.

a) Note that when we move from (a,0,0) to (a,0,2πc), t goes from t=0 to t=2π. Thus the length of the curve between these two points is

b) The arc length parameter s is given by:

Solving for t we see that t =.Thus the arc length parametrization of the curve is

r(s) = a cos() i +a sin() j+ k.

c) We first use the arc length parametrization of the curve to compute its curvature.

Thus, the curvature is given by:

From this, it can easily be shown that κ=

Example 8: The curve that is represented by the vector equation r(t) = a(1+cos(t)) i + a sin(t) j + 2a sin(t/2) k is known as Vidiani's curve. Consider the curve for a=1.

a) Plot the curve.

b) Compute the length of the curve from t=0 to t=π.

c) Calculate the curvature of the curve and compute the curvature at t=0.

Solution: To plot a curve in three dimensions, we use the command ParametricPlot3D. The syntax for this is ParametricPlot3D[{x,y,z},{t, tmin,tmax}].

Thus, the curvature at t=0 is given by

Exercise 4.4. Graph the space curve that is represented by the vector-valued function.

a) r(t) = 1/2 t i + j + 1/4 k b) r(t) = t i + ln t j + 1/2 k

Exercise 4.5. Sketch and find the length of the curve:

r(t) = (sin t - t cos t) i +(cos t + t sint) j + k.

Exercise 4.6. Find the curvature of the curve r(t) = t i + j + 1/2 k.

Exercise 4.7. Plot the following pairs of intersecting lines in space and find the point of intersection.

: x = 2t + 3, y = 5t - 2, z = -t + 1; : x = -2t + 7, y = t + 8, z = 2t - 1.

CHAPTER FIVE

FUNCTIONS OF SEVERAL VARIABLES

5.1 GRAPHS OF FUNCTIONS OF TWO VARIABLES

The following command loads all graphics packges of Mathematica.

Needs["Graphics`Master`"]

5.1.1 Plot3D

Plot3D is the three-dimensional analog of the Plot command. Given an expression in two variables and the domains for those two variables, Plot3D produces a surface plot. Plot3D has many options. We will discuss some of these options below. We begin with the simplest way of plotting a graph of a function of two variables.

Example 1: Plot f(x,y) = sin(x-cosy).

Plot3D[ Sin[ x-Cos[y] ],{x,-3,3},{y,-3,3} ];

The first option we consider is BoxRatios. BoxRatios is an option in Plot3D used to specify the ratio of the lengths of the sides of the box. This is analogous to specifying the AspectRatio of a two-dimensional plot. For Plot3D the default is BoxRatios->Automatic. Below, we plot the graph of the function in example 1 with a different BoxRatio.

Example 2:

Plot3D[ Sin[ x-Cos[y] ],{x,-3,3},{y,-3,3},

BoxRatios->{1,1,.62}];

Next, we consider the ViewPoint option. ViewPoint selects the point in space from which the observer looks at the object. Its default value is {1.3,-2.4,2.0}. This may be changed by entering a new value directly as an option or can be entered from 3D ViewPoint Selector of the Input menu. We give an example below.

Example 3:

Plot3D[ Sin[ x-Cos[y] ],{x,-3,3},{y,-3,3},

ViewPoint -> {0,3,2},

BoxRatios->{1,1,.62} ];

Our third option is AxesLabel. It is a command used to label the axes in plotting.

Example 4:

Plot3D[Sin[x-Cos[y]],{x,-3,3},{y,-3,3},

BoxRatios->{1,1,.62},

AxesLabel -> {"x ", "y ", "z "}];

The fourth option we discuss is ColorFunction. ColorFunction is an option for various graphics functions which specifies a function to apply to z values to determine the color to use for a particular x, y region. It is an option for Plot3D, ListPlot3D, DensityPlot, ContourPlot and related functions. The arguments provided for the function specified by ColorFunction are always in the range 0 to 1. ColorFunction -> Automatic yields a range of gray levels. ColorFunction -> Hue yields a range of colors. Another way of applying color to a surface is to select the color you want from Color Selector of the Input menu.

Example 5:

Plot3D[ { Sin[x-Cos[y]], RGBColor[0.996109, 0, 0]},

{x,-3,3},{y,-3,3} ];

Example 6:

Plot3D[Sin[x-Cos[y]],{x,-3,3},{y,-3,3},

ColorFunction->Hue ];

Show is another option of Plot3D. Show[graphics, options] displays two-and three-dimensional graphics, using the options specified. Show[, , …] shows several plots combined.

Example 7: Plot the graphs of f(x,y) = 3x + 4y - 3 and g(x,y) = 10 sin(xy) on the same axes.

a= Plot3D [ {3x+4y-3,RGBColor[1.000,0.000,0.000]}, {x,-3,3},

{y,-3,3} ,

DisplayFunction->Identity ];

b=Plot3D[ {10 Sin[x*y],RGBColor[0.000,0.502,0.251]}, {x,-3,3},

{y, -3,3},

DisplayFunction->Identity ];

Show[a, b,DisplayFunction->$DisplayFunction];

5.1.2 ParametricPlot3D

ParametricPlot3D is a direct analog of ParametricPlot. Depending on the input, ParametricPlot3D produces a space curve or a surface. ParametricPlot3D[{ f, g, h}, {t, a, b }] produces a three dimensional space curve parametrized by a variable t which runs from a to b. ParametricPlot3D[{ f, g, h}, {t, a, b },{u, c, d}] produces a two-dimensional surface parametrized by t and u. Options are given to ParametricPlot3D the same way as for Plot3D. Most of the options are the same.

Example 8: Plot the curve that is parametrized by x = sin t, y = cos t, and z = t/3.

ParametricPlot3D[ {Sin[t],Cos[t],t/3, Thickness[.02]},

{t,0,6Pi} ];

Example 9: Plot the surface that is parametrized by x = u cos u (4 + cos(u + v)), y = u sin u (4 + cos(u + v)), and z = u sin(u + v).

Exercise 5.1. Plot each of the following.

a) z = , -3 ≤ x ≤ 3, -3 ≤ y ≤ 3.

b) f(x,y) = , -1 ≤ x ≤ 1, -1 ≤ y ≤ 1.

c) f(x,y) = , -2 ≤ x ≤ 2, -2 ≤ y ≤ 2.

d) z(x,y)= sin(x + sin(y)) for -4 ≤ x ≤ 4 and -4 ≤ y ≤ 4.

Exercise 5.2. Graph the portion of the helicoid (spiral ramp) that is defined by:

x = u cos v, y = u sin v, z = v for 0 ≤ u ≤ 2 and 0 ≤ v ≤ π.

Exercise 5.3. Use parametric plot to graph the surface f(x,y) = .

[Hint: z = and so let x = 3 r cos θ, y = 4 r sin θ. Then, z = . ]

5.2 Partial Derivatives and Gradient

5.2.1 Partial Derivatives

The command for the partial derivative of f with respect to x is D[f, x], and D[f,{x,n}] gives the nth partial derivative of f with respect to x. The multiple(mixed) partial derivative of f with respect to ,,,.... is obtained by D[f,,,, ...]. In Mathematica 3.0 we can access this command from File- Palettes- BasicInputs or File- Palettes- BasicCalculations- Calculus- Common Operations. The symbols are □ and □ .

Example 10: Find the first partial derivatives of + with respect to and .

Solution: We give two methods.

Method 1: We can type all the inputs and the command as follows:

Method 2: We can use the BasicInput palette to enter the inputs.

Example 11: Find the four second partial derivatives of sin y+ .

Solution:

Method 1:

Method 2:

Example 12: Evaluate the first partial derivatives of xy++xz at (-1,2,3).

Solution: Recall that Expr /.{->->->... } is the command for substituting by , by , by , .... in Expr.

Clear[x,y,z]

D[x*y + y*z^2 + x*z,x]/.{x->-1, y->2, z->3}

Example 13: Let f(x,y,z) =+x ln z . Find , , , , and

Solution: First we define f(x,y,z) in Mathematica. Then we use the □ notation. Since the palette gives only two boxes for the variables, we need to add one more box. This can be done by using CTRL + .

Example 14: Let x=+s , y=t+ and z=x sin y. Find the first partial derivatives of z with respect to s and t.

Solution:

5.2.2 Directional Derivative and Gradient

The notation for a vector such as u =2i + 5j - 6k in Mathematica is {2,5,-6}. The command for the dot product of two vectors u and v is obtained by typing u.v

Example 15: Find the gradient and directional derivative of f( x , y ) = sin2y at the point (1,,0) in the direction of v=(,)

Solution: The gradient of f, ∇f, at (a,b) can be obtained by evaluating ∇ f=(f,f)(a,b). We will discuss other commands for obtaining the gradient in the near future. The directional derivative of f at (a,b) in the direction of a unit vector v is given by v. ∇f(a,b).

Method 1:

f=x^2*Sin[2y]

v={3/5, -4/5}

Method 2:

Example 16: Find the gradient and directional derivative of f(x,y,z) = xy+ yz + x z at the point (1, 1, 1) in the direction of v = 2i + j - k

Solution:

w= x*y + y*z + x*z

v={2,1,-1}

Example 17: Let the temperature T at a point (x,y) on a metal plate be given by T= .

a) Plot the level curves.

b) Plot the graph of the temperature.

c) Find the rate of change of temperature at (3,4), in the direction of u=i-2j

d) Find the unit vector in the direction of which the temperature increases most rapidly at (3,4).

e) Find the maximum rate of increase in the temperature at (3,4).

Solution: The command to plot level curves is ContourPlot[ f,{x,a,b},{y,c,d}] and the command to plot the graph of functions of two variables is Plot3D[ f,{x,a,b},{y,c,d}]. Rate of change in a given direction is nothing but directional derivative. The gradient vector is the direction of most rapid increase and its norm is the maximum rate if change.

a) We give two methods of drawing level curves; one uses the ContourPlot command and the other uses the Plot command.

Note: 1. Use the command ContourPlot[T[x,y],{x,-5,5},{y,-5,5}, ContourShading->False]; to get unshaded contours.

2. Solving T(x,y)=c for y we get (for c=-5,-4,-3,-2,-1,1,2,3,4,5) the following level curves. (We leave it as an exercise to plot level curves for smaller values of |c|.)

It is a good exercise to draw these level curves using PolarPlot. Note that the polar form of the equations T(x,y) = c is r= or simply r = c cosθ (since c is arbitrary).

Here is the graph of T.

d) The unit vector in the direction of which the temperature increases most rapidly at (3,4) is given by

e) The maximum rate of increase in the temperature at (3,4) is the norm of the gradient at this point. This can be obtained by:

Example 18: Let f(x,y)=2-3xy-x+y+and let R be the rectangle in the xy plane whose vertices are at (0,0), (2,0), (2,2), and (0,2).

a) Find all relative extremum values of f inside R.

b) Find the maximum and minimum values of f on R.

Thus (1,1) is the local minimum point of f inside R and its local minimum value is f(1,1) = 0. Next we find the extreme values of f on the boundary of the rectangle. This is done by considering f as a function of one variable on the sides of R. Let f1=f[x,0], f2=f[x,2] for x between 0 and 2, and f3=f[0,y] and f4=f[2,y] for y between 0 and 2. We now proceed as follows:

Thus, we have the following points on the boundary of R as critical points of f: (, 0), (, 2), (2,). Observe that the point (0, -1/2) is outside the rectangle R. The four vertices of R: (0,0), (2,0), (0,2) and (2,2) are also critical points (Why?). We now evaluate f at each of these points and at (1,1) (the relative minimum point found above) and compare the results. We do this using the substitution command.

Thus, the minimum value of f is -1/4 and the maximum value of f is 6. At what points are these attained?

Here is the graph of f.

Exercise 5.4. Let f(x, y) = . Find a) (1,0) b)

Exercise 5.5. The temperature at a point (x,y) on a metal plate is modeled by;

T(x,y) = 400 Exp ( -( + y) /2 ); x ≥ 0, y ≥ 0.

a) Find ▽ T (x, y).

b) Find the directional derivative of T(x,y) at the point (3, 5) in the dierection of u = i + j.

c) Find the direction of greatest increase in heat from the point (3,5).

Exercise 5.6. Let f(x,y) = for -2 ≤ x ≤ 2, and 0 ≤ y ≤3.

a) Find a set of parametric equations of the normal line and an equation of the tangent plane to the surface at the point (1, 2, 8/10).

b) Graph the surface, the normal line and the tangent plane found in a).

5.3 Multiple Integrals

The command for multiple integrals is more or less the same as the command for single integrals. If f is a function of two variables x and y, then Integrate[f,x] integrates f with respect to x while Integrate[f,y] integrates f with respect to y. Integrate[f, x, y ] integrates f with respect to x and y. It is worthwhile to keep in mind that Mathematica does not give a constant of integration. Integrate[f,{x,a,b},{y,c,d}] evaluates (fdy)dx=fdydx. Here c and d can be functions of x. In Mathematica 3.0, the command for multiple integrals can be entered from the BasicInputs palette as follows: From the palette click on ∫d□ or □d□. Use the TAB key to move to the first box inside the integral sign and then click on the integral sign of your choice from the palette.

Method 1:

Method 2:

Solution: We will use the letter of the question to denote the integral:

This example shows that there are double integrals that Mathematica can not evaluate exactly. For such cases we can get a numerical approximation by using NIntegrate or N[%]. (We will use N[%] below.)

We leave it as an exercise to the reader to skecth the regions of integration for the integrals of Example 2.

Example 21: Evaluate each of the following triple integrals:

a)2z dydxdz b)xdzdydx

Exercise 5.7. a) Evaluate the iterated integral dy dx

b) Switch the order of integration and evaluate the integral in a).

Exercise 5.8. Approximate the integral dy dx

Exercise 5.9. Find the volume of the solid that lies below the surface z = 1 - xy and above the plane region R bounded by y = x, y = 1, and x =0.

Exercise 5.10. Evaluate the iterated integral sinθ cosθ dr dθ .

Exercise 5.11. a) Evaluate the sum of the integrals

x y dy dx + x y dy dx

b) Use polar coordinates to combine the sum of the integrals in a) into a single integral and evaluate it.

Exercise 5.12. Find the surface area of z = 2x + over the triangle with vertices (0,0), (2,0), and (2,2).

Exercise 5.13. Evaluate the triple integral:

ydzdydx

Created by Mathematica (May 24, 2007) |