for Calculus I and II

Department of Mathematics

Rowan University

Abera Abay, Abdulkadir Hassen, Gary Itzkowitz, Hieu Nguyen

May, 1999

Table of Contents

Chapter 1. Introduction 4

1.1 Getting Started 4

1.2 Mathematica's Conventions for Inputting Commands 4

1.3 Basic Calculator Operations 6

1.4 Functions 7

1.5 Palettes 9

1.6 Solving Equations 9

Chapter 2. Graphs of Functions 11

2.1 Basic Plot 11

2.2 Plot Options 14

Chapter 3. Limits 24

Chapter 4. Differentiation 29

4.2 Applications of Derivative 32

Chapter 5. Integration 37

5.1 The Integral 37

5.2 Applications and Improper Integrals 39

Chapter 6. Sequences and Series 43

6.1 Sequences 43

6.2 Series 44

6.3 Power Series 49

Chapter 7. Parametric Equations and Polar Graphs 52

A. Traditional Notation versus Mathematica Notation 60

B. Formatting Cells in a Notebook 60

C. Saving and Printing Files a Notebook 61

Welcome to Mathematica! To make your getting started with this computer algebra system as easiest as possible, we recommend that you read this introductory chapter very carefully. First of all, a student must have a computer account on the Rowan network in order to access the Mathematica software package. Computer accounts can be obtained from the Office of Instructional Technology.

First-time users of Mathematica 5.2: Launch the program Mathematica 5.2 on your computer. Mathematica will automatically create a new notebook. Just start typing and simultaneously press the SHIFT+ENTER keys whenever you want Mathematica to evaluate an expression; this will launch the kernel application, which does all the computations. This is a one-time procedure and may take a few seconds, so please be patient.

There is an on-line help menu within Mathematica; please feel free to use it if you have questions about the program. There is also the search command given by the question mark ?. For example, evaluating ?Plot will provide all Mathematica commands containing the expression Plot.

1.2. Mathematica's Conventions for Inputting Commands

1.2.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. Furthermore, Mathematica is case sensitive; a common cause of error is the failure to capitalize command names. For example, Plot, Integrate, and Findroot are valid functions names. Sin, Exp, Det, GCD, and 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 functions names.

1.2.2. Parenthesis, Brackets and Braces

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

1) Parentheses, ( ), are used only for grouping expressions. For example, (x-y)^2, 1/(a+b), (x^3-y)/(x+3y^2) demonstrate proper use of parenthesis. Users should realize that Mathematica understands f(2) as f multiplied with 2 and not as the function f evaluated at 2.

2) Square brackets, [ ], are used for function arguments. For example, Sqrt[346], Sin[Pi], and Simplify[(x^3-y^3)/(x-y)] are valid uses of square brackets. Therefore, to evaluate a function f at 2, we can type f[2].

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

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

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

Table[m^3,{m,1,100}] specifies the values of the iterator m in generating a table of elements.

NOTE: one can write comments on any input line. The comments should be enclosed between (* and *). For example,

In[1]:=

Out[1]=

1.2.3. Equal Signs

Here are Mathematica's rules regarding the use of equal signs:

1) A single equal sign (=) assigns a value to a variable. Thus, entering q=3 means that q will be assigned the value 3. If we then evaluate 10+q^3, Mathematica will return 37. As another example, suppose the expression y=x^3-x+1 is entered. If we then assign a value for x, say x=2, then in any input containing y afterwards, Mathematica will use this value of x to calculate y, which would be 7 in our case.

2) A colon-equal sign (:=) creates a delayed statement for an expression and is used to define a function. For example, typing f[x_]:=x^3-x+1 tells Mathematica to reevaluate the function f for each new value of x. We will say more about defining functions in section 1.3 of this notebook.

3) A double-equal sign (= =) is a test of equality between two expressions. If we had previously set x= - 5, then evaluating x = = -5 returns True, whereas evaluating x = = 5 returns False. Another common usage of = = is to solve equations, such as in Solve[x^3-x+1= = 0, x] (see section 1.5 below).

1.2.4. Referring to Previous Results

Mathematica saves all input and ouput in a session. A previous output can be referred to by using the percent sign %. A single % refers to Mathematica's last output, %% refers to the next-to-last ouput, and so forth. %k refers to the output line numbered k. For example, %45 refers to output line number 45.

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

1.3. Basic Calculator Operations

Mathematica uses the standard symbols +, -, *, /, ^, ! for addition, subtraction, multiplication, division, raising exponents, and factorials, respectively. Multiplication can also be performed by leaving a blank space between factors. Powers can also be entered by pressing CTRL+6 and fractions can be entered by pressing CTRL+/.

To convert numerical values to decimal form, use the command N[expr] or N[expr,n]. In most cases, N[expr] returns six digits or expr and may be in the form n.abcde * (scientific notation), whereas N[expr,n] attempts to return n digits of expr. NOTE: Mathematica can perform calculations to arbitrary precision and handle numbers that are arbitrarily large or small. Here are some examples:

In[2]:=

Out[2]=

In[3]:=

Out[3]=

In[4]:=

Out[4]=

In[5]:=

Out[5]=

In[6]:=

Out[6]=

In[7]:=

Out[7]=

Example 1.1. How close is to being an integer?

In[8]:=

Out[8]=

In[9]:=

Out[9]=

We can rewrite this output by moving the decimal place 17 places to the right. This shows that is very close to being an integer. We use the command Mod[n,m], which returns the remainder of n when divided by m, to obtain the fractional part of :

In[10]:=

Out[10]=

In[11]:=

Out[11]=

There are two different ways to define functions in Mathematica, depending on how they are to be used. Consider the following example:

Example 1.2. Enter the function f(x)=into Mathematica.

Method 1: Simply enter

In[12]:=

Out[12]=

To evaluate f(x) at x=10, we use the substitution command slash-period /. as follows:

In[13]:=

Out[13]=

Method 2: An alternative way to define f(x) by using the argument x is to write

In[14]:=

Typing f[10] now tells Mathematica to evaluate f at x=10. More generally, the command f[{a,b,c,...}] evaluates f(x) for a list of values of x:

In[16]:=

Out[16]=

Out[17]=

Here, Mathematica is warning us that it has encountered the undefined expression in evaluating f(-1) by returning the message ComplexInfinity.

Warning: Recall that Mathematica reads f(x) as f multiplied with x.

Method 3: If there is no need to attach a label to the expression , then we can directly enter this expression into Mathematica:

In[18]:=

Out[18]=

In[19]:=

Out[19]=

Piecewise functions can be defined using the command If[p,else,q].

Example 1.3. Enter the piece-wise function f(x) ={

if |x|<1; | |

x, | if |x|≥1, |

In[20]:=

Mathematica allows us to enter commonly used mathematical expressions and commands from 6 different palettes. Palettes are calculator pads containing buttons that can be clicked on to insert the desired expression or command into a command line. These palettes can be found under the File/Palettes menu. By default, the Basic Inputs Palette should appear when the Mathematica application is opened. In fact, you can create your own palette.

Palette Instructions:

1. Move the cursor to the location where an expression will be inserted.

2. Click on the corresponding palette button to insert the expression.

3. Press the TAB key to move between placeholders (i.e. the square boxes) inside the expression.

4. Press CTRL+Spacebar to move outside of a placeholder or an expression.

Example 1.4. Enter into a notebook.

Here is one set of instructions for entering this expression:

a) Open the BasicInput palette (it should have already opened on your screen by default).

b) Click on the palette button .

c) Click on .

d) Enter the number 3 into the highlighted top placeholder.

e) Press the TAB key to move the cursor to the bottom placeholder.

f) Click on .

g) To insert π into the base position, click on the palette button for π.

h) Press the TAB key to move the cursor to the superscript placeholder.

i) Enter the number 4.

Mathematica has a host of built-in commands to help the user solve equations and manipulate expressions. The command Solve[lhs==rhs, var] solves the equation lhs=rhs (i.e left hand side expression equals right hand side expression) for the variable var. For example, typing Solve[-1==0,x] will solve the quadratic equation -1=0 for x. A system of m equations in n unknowns can be solved with the command Solve[{==,==,...,==},{,,...,}]. Numerical approximations of solutions can also be obtained through the command NSolve[lhs==rhs,var].

There are commands to algebraically manipulate expressions: Expand, Factor, Together, Apart, Cancel, Simplify, FullSimplify, TrigExpand, TrigFactor, TrigReduce, ExpToTrig, PowerExpand, and ComplexExpand. These commands can also be entered from the AlgebraicManipulation palette; highlight the expression to be manipulated and click on the button corresponding to the command to be inserted.

Exercise 1.7

1. Evaluate the following expressions:

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

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

2. Enter the following functions into Mathematica:

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

3. Evaluate the following functions using Mathematica:

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

4. Enter the following six expressions into a notebook.

a) b) c)

d) e) f) .

5. Expand each of the following expressions:

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

6. Factor each of the following expressions:

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

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

a) b) c) +

8. Perform the indicated operations:

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

9. Solve the following equations for x:

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

Chapter 2. Graphs of Functions

Plot[f,{x,a,b}] plots the graphs of f as a function of x with x ranging in value from a to b.

Plot[{,,...,},{x,a,b}] plots the graphs of ,,..., on the same set of axes.

Plot[f,{x,a,b},PlotRange->{c,d}] plots the graph of f with a prescribed range of y-values set between c and d.

NOTE: Plot[f,{x,a,b}] can also be entered from the menu File/Palette/BasicCalculations/Graphics (observe the other plot versions inside this palette).

Example 2.1. Plot the graph of along the interval [-6,5].

In[21]:=

Out[21]=

Example 2.2. Plot the graph of sin (4x) along the interval [-4,4].

In[22]:=

Out[22]=

Example 2.3. Plot the graphs of functions given in Examples 1 and 2 on the same set of axes.

In[23]:=

Out[23]=

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

In[24]:=

Out[24]=

Example 2.4. Draw the graph of f(x)=-5-x

In[25]:=

Out[25]=

Note: Observe that Mathematica output of a Plot command is -Graphics-. To obtain the graph of the function without -Graphics-, we add a semicolon ( ; ) at the end of the Plot command. We will do this for the next few examples.

Example 2.5. Draw the graph of f(x)=

In[26]:=

Notice that we have used the BasicInput Palette for the input. Here is a direct way of typing the input. Plot[x^2 / (4-x^2) , {x, -5, 5} ];

Exercise 2.1

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 [-π,π]

d) f(x)=-5+10 on [-5,5]. e) f(x)= on [-4,4].

f) f(x)=x+ for [-10,10].

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.

In this section we will introduce various options of Plot. To begin with, the command Options[Plot] displays the following options:

In[27]:=

Out[27]=

2.2.1 PlotStyle

PlotStyle is an option for Plot that specifies the style of lines or points to be plotted. Among other things, one can use this option to specify a color of the graph and the thickness of the curve. PlotStyle should be followed by a minus sign(-) followed by greater than sign (>). We use PlotStyle for choosing a color of a plot. There are two ways of choosing colors. (1) Click on the Input menu and choose Color Selector. A box of various colors will be displayed. We click on the color of our choice and click Ok to complete the process. (2) Specify the color by typing RGBColor[a, b, c], where a, b, and c are numebrs between 0 and 1. Here is an example:

In[28]:=

The next example shows the use of PlotStyle with two styles: a color and thickness.

In[29]:=

PlotStyle can also be used when plotting graphs of two or more functions. Here are two examples.

In[30]:=

In[31]:=

2.2.2 PlotRange

We have already used the PlotRange option in Section 2.1(see Example 3). This option specifies what points should be used to plot the graph. As observed in Example 3 of Section 2.1, some points of a graph may not be plotted unless we specify the y-range of the plot. The option PlotRange -> All includes all points corresponding to the specified values of x. Here is an example.

In[32]:=

In[33]:=

2.2.3 Axes

There are several options regarding axes. We consider four of them.

1. Axes: Axes->True draws both axes, Axes->False draws no axes, Axes ->{True,False} draws the x-axis only. An example of the last case is given below.

In[34]:=

2. AxesLabel: AxesLabel->None (which is the default option) does not specify the labels of the axes. AxesLabel->y will label the y-axis only. AxesLabel ->{ "x", "y" } labels both axes. Examples of both cases are given below.

In[35]:=

In[36]:=

3. Origin: AxesOrigin specifies the location where the two axes should intersect. The default value given by AxesOrigin-> Automatic chooses the intersection point of the axes based on an internal (Mathematica) algorithm. It usually chooses (0,0). The option AxesOrigin->{a,b} chooses the point (a,b) as the intersection point.

4. AxesStyle: This option specifies the style of the axes. Here is an example where we specify the thickness and the color of the axes. We also use the AxesOrigin option.

In[37]:=

2.2.4 Frame

There are several options regarding the frame of a plot. We will show some of these by using the following examples.

In[38]:=

In[39]:=

In[40]:=

We recommend that the reader experiment with this example by changing the color specifications to see which option controls which color.

2.2.5 Show

The other important option of Plot is Show. The command Show[ plot, options] displays the graphics plot using the options specified by options. Also Show[ plot1,plot2, ....] displays the graphics plot1, plot2, ... on one coordinate system. Before we give an example, we need to discuss the plot option DisplayFunction. DisplayFunction -> Identity is an option that causes Mathematica to compute the graphics but not dispaly the graph. DisplayFunction -> $DisplayFunction displays the graph. Here is how it works.

In[41]:=

In[42]:=

In[43]:=

Here is an option we can use to identify the curves by inserting the function names near the graph.

In[44]:=

Exercises 2.2

1. Plot the graphs of the following functions using at least one plot option discussed in this section.

Note: 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]. For the natural base e you either type E or you can obtain e from File-Palette-BasicInput, where you can also find ∞ among others.

(a) f(x)=+2+1 for -3≤x≤3 (b) f(x)= x ln x for 0≤x≤4

(c) f(x)=1-+ for -20≤x≤20

2. Plot the graphs of the following pairs of functions on the same axes. Use a plot style to identify the graphs.

(a) f(x)= and g(x)=ln x (b) f(x)= and g(x)=

(c) f(x)= -sin x and g(x)=-

Limit[f,x->a] finds the limiting value of f as x approaches a. This command can also be found from the menu File/Palette/BasicCalculations/Calculus/Common Operation (notice the other operations that can be found in this way).

Limit[f,x->a,Direction->1] computes the limit as x as approaches a from the left (i.e. x increases to a).

Limit[f,x->a,Direction->-1] computes the limit as x approaches a from the right (i.e. x decreases to a).

If the limit does not exist, then Mathematica will attempt to explain why or else return the limit expression unevaluated if it has insufficient information about the function.

Example 3.1. Evaluate ().

In[45]:=

Out[45]=

Compare the answer with the graph of this function obtained in Example 2.1.

Example 3.2. Evaluate .

In[46]:=

Out[46]=

Let us check the answer by graphing the function up close at x=0:

In[47]:=

Out[47]=

Example 3.3. Evaluate

In[48]:=

Out[48]=

Example 3.4. Evaluate

In[49]:=

Out[49]=

Again, we can check the answer by plotting the graph of the function:

In[50]:=

Out[50]=

Example 3.5. Evaluate (3x -2)/.

In[51]:=

Out[51]=

In[52]:=

Out[52]=

Example 3.6. Evaluate .

In[53]:=

Out[53]=

Again, let us plot the function to visually understand why the answer is -∞.

In[54]:=

Out[54]=

The messages prior to the plot informs us that Mathematica was unable to evaluate the function for values of x greater than 2 because this results in taking the square root of a negative number.

Example 3.7. Evaluate sin x (this is an example where the limit does not exist).

In[55]:=

Out[55]=

Here, Mathematica is telling us that the limit does not exist by returning the range of values for sin x as x approaches infinity.

Example 3.8. Evaluate

x→∞ |

Note: For the natural base e you either type E or you can obtain e from File-Palette-BasicInput, where you can also find ∞ among others. 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].

In[57]:=

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

Out[57]=

Example 3.9. Evaluate

In[58]:=

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

Out[58]=

Again, we can graph the function near x=1 to visually understand why the answer is . We leave this to the student.

Let us end with an example where the Limit command is used to evaluate the derivative of a function (in anticipation of commands introduced in the next section for computing derivatives).

Example 3.11. Find the derivative of f(x) = according to the limit definition.

By definition, the derivative of a function f(x) is

f '(x)=.

In[59]:=

Out[59]=

Exercise 3.1

1. Compute the following limits:

a) - b) c) d)

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

3. Evaluate each of the following limits:

(a)

x→2 |

(c)

lim ( sec 3x cos 5x) |

(e)

All the rules of differentiation are programmed into Mathematica. This makes it easy to differentiate complicated expressions. The command D[f,x] calculates the derivative of the function f with respect to the variable x. You can obtain higher order derivatives of order n by using the command D[f,{x,n}]. Again, all these commands are available from the palette menu File/Palette-BasicCalculations/Common Operations. The symbol for the derivative of a function of one variable from the palette is □.

Example 4.1. Find the derivative of x sin x and evaluate it at x= .

There are a number of ways to compute the derivative. We demonstrate five methods, including how to evaluate expressions by using the substitution command /.x->a.

Method 1:

In[60]:=

Out[60]=

Out[61]=

In[62]:=

Out[62]=

Method 2: Click on the palette button □ (the symbol ∂ traditionally refers to partial differentiation, but just think of it as the symbol for now), then enter x in the lower box for the variable of differentiation, press the Tab key to move between boxes and enter the function into the upper box.

In[63]:=

Out[63]=

Method 3: If the function x sin x and its derivative need to be referred to often, then it is more convenient to label them, say by f and D f, when performing the computation:

In[64]:=

Out[64]=

Out[65]=

Out[66]=

Method 4: If the function x sin x will be evaluated for different values of x, then labeling it as f[x] by using the argument x is more suitable. In this case, the derivative can easily be obtained by evaluating f'[x] (Mathematica is programmed to understand prime notation for derivatives):

In[67]:=

Out[69]=

Out[70]=

Example 4.2. Differentiate .

In[71]:=

Out[71]=

In[72]:=

Out[72]=

Example 4.3. Differentiate arcsin x+x.

In[73]:=

Out[73]=

Example 4.4. Find the second derivative of x.

In[74]:=

Out[74]=

Recall that we can also use prime notation to obtain the second derivative as follows:

In[75]:=

Out[76]=

Example 4.5. (Implicit Differentiation) Find an equation of the line tangent to the graph of (+)= at the point P(,).

The solution here boils down to finding the slope of the tangent line at P, which can be found by evaluating the derivative at (x,y)=(,).

In[77]:=

Out[78]=

In[79]:=

Out[79]=

In[80]:=

Out[80]=

Lastly, the slope can be found by evaluating the output at the coordinates of P.

In[81]:=

Out[81]=

The slope of 3 here can now be substituted into the slope-intercept equation of a line:

In[82]:=

Out[83]=

In[84]:=

Out[84]=

The equation of the tangent line at P is therefore y=3x-.

Exercises 4. 1

1. Compute the derivatives of the following functions:

a) f(x)= 3+1 b) g(x)= c) h(x)=

2. 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

3. Compute the second derivatives of the functions given in Exercise 2.

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

5. Find all relative extrema of the function f(x)=-7+10.

6. Differentiate the following

(a) y= (b) y=

(c) y= (d) y=ln(cos())

(e) y=arcsec x (f) y=x+x

(g) y=sinh(1-) (h) y=x x+ln

7. 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).

8. 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.

4.2 Applications of Derivative

Example 4.6. Use the second derivative test to find the relative extrema of f(x)=-3+5.

Recall that the second derivative test involves evaluating the second derivative f''(x) at the critical points of f(x), i.e. points where the derivative is zero. Therefore, we begin by solving the equation f'(x)=0 for x.

In[85]:=

Out[87]=

Let us evaluate f''(x) at these critical values: x=-1, 0,1.

In[88]:=

Out[88]=

Hence, there is a relative minimum at x=-1 since f''(-1)>0 and a relative maximum at x=1 since f''(1)<0. What happens at x=0? Try to use the first derivative test or plot the graph of f(x).

Example 4.7. Determine all horizontal or vertical asymptotes of f(x)=2().

We begin our analysis by plotting the graph of f(x):

In[89]:=

Out[90]=

To get a precise hold of where the horizontal asymptotes are, we need to compute f(x) (recall that a function f(x) has a horizontal asymptote at y=c if either f(x)=c or f(x)=c):

In[91]:=

Out[91]=

Out[92]=

Therefore, there is a horizontal asymptote at y=2. Next, the vertical asymptotes can be found at points that are infinite discontinuities of f(x) (recall that a function f(x) has a vertical asymptote at x=d if either f(x)=±∞ or f(x)=±∞. As f(x) is a rational function, this reduces the work to determining the zeros of its denominator, -4:

In[93]:=

Out[93]=

Indeed, the graph of f(x) reveals that there should be vertical asymptotes at x=2 and x=-2. We can verify this mathematically by computing

In[94]:=

Out[94]=

Out[95]=

Example 4.8. Sketch the graph of f(x)= and determine its relative extrema (if any exists at all).

Again, we begin our analysis by plotting the graph of f(x):

In[96]:=

Out[98]=

The output messages here tell us that Mathematica cannot evaluate f(x) on the open interval (-2,2) because the base -4<0 there; this makes f(x) ill-defined as an exponential complex function. Therefore, we should explain to Mathematica that f(x) should be treated as a real radical function and ask it to plot f(x) again with the function rewritten in radical form:

In[99]:=

Out[100]=

The relative extrema of f(x) can now be found by using the first derivative test. If x=c is a critical point of f(x), then the test works as follows:

(1) If f '(x) changes from negative to positive at x=c, then f(x) has a relative minimum at x=c, and (2) If f '(x) changes from positive to negative at x=c, then f(x) has a relative maximum at x=c.

From the graph, it seems that the critical points where f '(x) is undefined are at x=-2,2. We can verify this by evaluating f'(x) at these values:

In[101]:=

Out[101]=

Out[102]=

Now, the critical points where f '(x) vanishes can be found with the Solve command:

In[103]:=

Out[103]=

Based on the graph, we can conclude that f(x) has relative minima at x=-2,2 since the derivative changes from negative to positive there and a relative maximum at x=0 by a similar argument.

Exercises 4.2

1. Determine all horizontal and vertical asymptotes of y=5(-).

2. Determine all relative extrema of f(x)=.

Integrate[f,x] gives the indefinite integral of f with respect to x. On the other hand,

Integrate[f,{x,a,b}] gives the definite integral of f on the interval [a,b].

NIntegrate[f,{x,a,b}] gives a numerical approximation of the definite integral of f on [a,b].

The command Integrate can evaluate all rational functions and a host of transcendental functions, including exponential, logarithmic, trigonometric and inverse trigonometric functions. It can also be obtained from the palette menu File/Palette/BasicCalculations/Calculus/Common Operations.

Example 5.1. Evaluate ∫dx.

Method 1: (Palette buttons)

In[104]:=

Out[104]=

Note: Mathematica does not explicitly include the constant of integration C in its answers for indefinite integrals; the user should always include the constant of integration.

Method 2:

In[105]:=

Out[105]=

Question: if the substitution method with u=+1 is used to solve this integral, then the answer becomes . How does one reconcile this answer with the one obtained in the output above?

Example 5.2. Evaluate ∫dx.

In[106]:=

Out[106]=

Example 5.3. Evaluate ∫sin xdx.

In[107]:=

Out[107]=

Example 5.4. Evaluate dx.

In[108]:=

Out[108]=

Example 5.5. Evaluate dx.

In[109]:=

Out[109]=

In[110]:=

Out[110]=

In[111]:=

Out[111]=

Example 5.6. Approximate tan dx.

Here is an example of an integral that Mathematica will not evaluate but return the integral unevaluated because the precise answer is not easily expressible in simple form. However, a numerical approximation is still possible through the command N.

In[112]:=

Out[112]=

In[113]:=

Out[113]=

Or we can just use the command NIntegrate to perform both steps at once:

In[114]:=

Out[114]=

Exercises 5.1

1. Evaluate the following integrals:

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

2. Integrate each of the following. Simplify your answers.

(a) ∫d x (b) ∫d x

(c) ∫5 x 5x d x (d) ∫cos 2x d x

3. Evaluate the following integrals.

(a) (-4+x)d x (b) (+2)d x

(c) sec x d x (d) d x

5.2 Applications and Improper Integrals

Example 5.7. Compute the arclength of the graph of y=ln (cos x) on the interval [0,].

Recall that the formula for the arclenth s of a function f(x) on the interval [a,b] is given by

s=dx.

We enter this formula into Mathematica to obtain

In[115]:=

Out[117]=

In[118]:=

Out[118]=

The arclength is therefore s=0.881374.

Example 5.8. Evaluate ∫dx

Solution:

In[119]:=

Out[119]=

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

In[120]:=

Out[120]//TraditionalForm=

Example 5.9. Evaluate the improper integral: (1-x)dx

In[121]:=

Out[121]=

Example 5.10. Determine the convergence of the improper integral: dx

In[122]:=

Out[122]=

The above output shows that the integal is divergent.

Example 5.11. Show that the function f(x)= has points of inflection at x=-1 and x=1. Also find the total area of the region under the curve and above the x-axis. (This function is very useful in probablity and statistics. The graph is called the normal (or bell) curve.

Solution: We will first define a function that represents the given function using Mathematica as follows.

In[123]:=

Here is the graph of f.

In[125]:=

Plot[f[x],{x,-4,4} ];

To find the inflection points we enter:

In[126]:=

Out[126]=

We leave it to the student to verify that x=-1 and x=1 are indeed inflection points. To find the area of the region in question we enter:

In[127]:=

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

Out[127]=

Example 5.12: Sketch the region enclosed by the graphs of f(x)=x(-3x+3) and g(x)= and find the area of the region.

Solution: We define these functions in Mathematica and draw their graphs on the same coordinate system. Then we will find the intersection points of the graphs and identify the region. Finally, we evaluate the appropriate integrals.

In[128]:=

In[131]:=

In[132]:=

Out[132]=

In[133]:=

Out[133]=

Exercises 5.2

1. Approximate the area under the curve y= and above the interval [0,1].

2. Compute the arclength of the curve in Exercise 1 along the interval [0,1].

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

4. Find the area of the region enclosed by the curves y=-2, y=2-3x, x=0, x=3. Also skecth the region.

Chapter 6. Sequences and Series

We define a sequence exactly the way we define a function. Thus, instead of we use a(n). The limit of a sequence may be obtained by using the command Limit. When Limit[a[n], n->∞] is used, Mathematica automatically assumes that n is a real number( instead of a positive integer). However, for an arbitrary sequence, a[n] may not be well-defined if n is a real number other than a positive integer. In such cases Mathematica returns the unevaluated limit. The command NLimit[a[n], n->∞] gives a numerical approximation of the limit. Before we use NLimit we need to download the package NumericalMath`NLimit. Here are some examples:

Example 6.1. Find the limit of the following sequences.

(a) = (b) =

(c) =cos() (d) =

Solution: We will use the letter corresponding to the sequence to define a sequence in Mathematica. Thus, will be defined as a[n].

In[134]:=

In[136]:=

Out[136]=

In[137]:=

In[139]:=

Out[139]=

In[140]:=

In[141]:=

Out[141]=

The above output suggests that the limit is zero. To show that this is true, we use the fact that if f(x) is a function such that =f(n) for all positive integers n, then =L if and only if =L. We also recall that =0 if and only if |=0

In[142]:=

Out[142]=

Thus, =0

In[143]:=

In[145]:=

Out[145]=

Thus, does not exist.

In[146]:=

In[148]:=

Out[148]=

Exercises 6. 1

1. Find the limit of the following sequences.

(a) = (b) =

(c) =sin() (d) =n

Sum[ , {n, , }] is the sum of as n goes from to . Using the BasicInput Palette, we can also enter this as . Similarily we enter the infinite series .

Example 6.2. Find the following finite sums

(a) (b) (k+1)(k-1)

(c) (

20 |

k |

Solution: We will use the letters corresponding to the question for the sum. The binomial coefficient (

n |

m |

In[149]:=

Out[149]=

In[150]:=

Out[150]=

In[151]:=

Out[151]=

In[152]:=

Out[152]=

Example 6.3. Consider the harmonic series . Let be its nth partial sum.

(a) Find . (b) Compute every 10th partial sum up to n=100.

Solution: First we define . For (b) the command we need is Table[ s[n] , {n, 1, J, k }], which gives the list of values s[1], s[1+k], s[1+2k], s[1+3k], ... , s[1+m*k], where 1+m*k is the largest integer less than or equal to J. N[ Table[ s[n] , {n, 1, J, K }] ] gives the list in decimals and TableForm[ N[ Table[ s[n] , {n, 1, J, K } ] ] ] lists the values in a column. We will use all the three commands.

In[153]:=

In[155]:=

Out[155]=

In[156]:=

Out[156]=

In[157]:=

Out[157]=

In[158]:=

Out[158]=

In[159]:=

Out[159]//TableForm=

2.92897 |

3.59774 |

3.99499 |

4.27854 |

4.49921 |

4.67987 |

4.83284 |

4.96548 |

5.08257 |

5.18738 |

Example 6.4. Determine whether the series converges or diverges.

a) b) c)

d) e)

Solution: We will use the letter of the question for the solution. Thus, in an input e= is the solution of e).

In[160]:=

Out[160]=

In[161]:=

Out[161]=

In[162]:=

Out[162]=

Note that Mathematica returned the last series unevaluated and without comment. This means that Mathematica could not decide whether the series is divegrent or not. We apply the Ratio Test as follows.

In[163]:=

In[165]:=

Out[165]=

Thus, the series diverges by Ratio Test.

In[166]:=

Out[166]=

The above series is convergent. But its closed form is unknown. In such cases, Mathematica can be used to approximate the nth partial sum of the series.

In[167]:=

In[170]:=

Out[170]=

Thus, the Ratio Test is inconclusive. Let us try the Integral Test. First observe that a(x) is a positive valued function. To verify that it is decreasing, we evaluate

In[171]:=

Out[171]=

In[172]:=

Out[172]=

Clearly a'(x)<0 for all x>1. Thus we can apply the Integral Test. We will use the command NIntegrate[ a[x], { x ,1, ∞ } ].

In[173]:=

Out[173]=

Thus, by the Integral Test the series is convergent.

In[174]:=

Out[175]=

The above example shows that we must be careful when using Mathematica to determine the convergence of a series. However, as the following two examples show, when we specify the common ratio of the geometric series, we get the expected result.

In[176]:=

Out[176]=

This shows that that the series is divergent.

In[177]:=

Out[177]=

Exercises 6.2

1. Find the following finite sums

(a) (b)

(c) (

100 |

k |

2. Consider the geometric series . Let be its nth partial sum.

(a) Find . (b) Compute every 10th partial sum up to n=100.

3. Determine whether the series converges or diverges.

a) b)

c) d)

The Taylor polynomial of a given function f at a point is given by the command Series[f , { x, , n} ], which gives the nth Taylor polynomial (x) plus a term of the form . To get the exact Taylor polynomial the command is Normal[ Series[f , { x, , n} ] ].

The command to obtain the Taylor series of a function f at a point is the same as that of its Taylor polynomial. Thus, Mathematica can only give the first "few" terms of the Taylor series of a function.

SeriesCoefficient[s, n] gives the coefficient of the nth power of the series s.

Example 6.5. Let f(x) . Find its 5th Taylor polynomial at x = 0

In[178]:=

Out[178]=

In[179]:=

Out[179]=

Example 6.6. Find the nth coefficient of the Taylor series of f(x) at x=c

(a) f(x) = , c = 1, n = 6

(b) f(x) = sinx, c = , n = 10

Solution: Note that we must first find the Taylor series of these functions at the given points and that we must evaluate the series to the order greater than or equal to the given value of n. However, unless we want to, we do not have to see the actual power series of the function. For the first function we will give both the series and the desired coefficient and for the second we calculate the coefficient only.

In[180]:=

Out[180]=

In[181]:=

Out[181]=

In[182]:=

Out[182]=

Example 6.7. Let f(x) = .

a) Find the Taylor polynomials (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 (a)

c) Use the graph in (b) to estimate the radius of convergence of the Taylor series of f at x =0

Solution: Recall that Normal[Series[f[x], {x,0, n}]] is the command to obtain the nth Taylor polynomial of f at 0. We will use the command Table[Normal[Series[f[x], {x,0, n}]] ,{n, 0, 6}] to generate the first 6 Taylor polynomials of f. For a better visualization of these polynomials we will use the command TableForm. The simplest way to draw the graphs of the Taylor polynomials is by using the Evaluate command. To use this command we let a=Table[Normal[Series[f[x], {x,0, n}]] ,{n, 0, 6}] Then Plot[ Evaluate[ a ], {x, -2, 2} ] plots the graphs of the polynomials. To make the comparison between the graph of f and its Taylor polynomials we will use the PlotStyle option for the graph of f. Finally to estimate the radius of convergence of the Taylor series of f, we use Show to draw the two graphs on the same axis.

In[183]:=

In[185]:=

In[186]:=

Out[186]//TableForm=

In[187]:=

In[188]:=

In[189]:=

This clearly suggests that the radius of convergence is 1. We leave it to the student to redo the above example with larger values of n to confirm this and find the interval of convergence..

Exerciese 6.3

1. Let f(x) =cos x. Find its 5th Taylor polynomial at x = π.

2. Find the nth coefficient of the Taylor series of f(x) at x=c

(a) f(x) = cos(π), c = 1, n = 6

(b) f(x) =, c = , n = 10

3. Let f(x) = .

a) Find the Taylor polynomials (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 (a)

c) Use the graph in (b) to estimate the radius of convergence of the Taylor series of f at x =0

Chapter 7. Parametric Equations and Polar Graphs

Example 7.1. Sketch the curve described by the parametric equation x=cos t ; and y=sin t, 0 !≤ t !≤ 2π.

Solution:

In[190]:=

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

In[191]:=

Out[191]=

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.

In[192]:=

Example 7.2. Sketch the curve described by the parametric equation

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

Solution:.

In[193]:=

Example 7.3. Sketch the curve (prolate cycloid) described by the parametric equations

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

Solution:

In[194]:=

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.

In[195]:=

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

In[196]:=

Out[196]=

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

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

Solution:

In[197]:=

Out[197]=

In[198]:=

Out[198]=

Exercise 7. 1

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θ

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

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

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.

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:

In[199]:=

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

Solution:

In[200]:=

Solution:

In[201]:=

Example 7.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.

In[202]:=

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

In[203]:=

Out[203]=

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)

In[204]:=

Out[204]=

In[205]:=

Out[205]=

Exercise 7. 2

1. 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θ

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

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

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

4. 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 θ

5. Find the length of the given curve on the specified interval.

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

6. 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.

A. Traditional Notation versus Mathematica Notation

Traditional Mathematica

f(x)= f=x^2 or f[x_]:=x^2

f(1) f/.x->1 or f[1]

Sqrt[f(x)]

|f(x)| Abs[f(x)]

f(x) Limit[f[x],x->a]

f '(x) f ' [x] or D[f[x],x]

∫f(x)dx Integrate[f[x],x]

f(x)dx Integrate[f[x],{x,a,b}] or NIntegrate[f[x],{x,a,b}]

Plot f(x) on [a,b] Plot[f[x],{x,a,b}]

Solve f(x)=g(x) for x Solve[f(x)==g(x),x]

e (Euler number) E

∞ Infinity

sin x Sin[x]

ln x Log[x]

x Log[x,a]

B. Formatting Cells in a Notebook

Mathematica organizes a notebook in terms of data boxes called cells. The size of a cell is indicated by the corresponding size of the right bracket symbol attached to the right hand margin of each cell. A new cell can always be created by moving the cursor to any position between cells and begin typing. To edit a cell, just move the cursor to the desired position within that cell.

Each cell can be formatted to perform a specified function. By default, a new cell is always formatted as an input cell, which are used to evaluate Mathematica expressions. Mathematica outputs are contained within output cells, naturally. Other cell formats included title, section, subsection, text, formula, etc. The format of a cell is indicated by the left-most box on the toolbar. To change its format, first highlight the cell by clicking on the right bracket symbol attached to it. Then click on the indicator box and choose the desired format.

C. Saving and Printing a Notebook

Saving or printing a notebook can be accomplished by going to the File menu and highlighting the desired option. To print a selected portion of a notebook that has been highlighted, choose the Print Selection option instead.

Created by Mathematica (May 24, 2007) |