> restart;

>

Introduction to Maple in Calculus II

Maple Worksheets

In MTH 142 we shall continue our work with Maple. Similarly as last semester, our work is going to be organized into worksheets like this one. A worksheet consists of text and Maple command lines. Portions of a worksheet containing text and portions containing Maple command lines marked by vertical lines on the left of the screen are called execution groups . It is very important for you to learn how to toggle between the text mode and the command line mode. Your homework problems will require of you opening a new Maple worksheet, using Maple to plot functions, perform calculations etc., as well as entering your answers and comments in complete sentences using the text mode. As most of you already know, you toggle between the text mode and the Maple command mode by pressing the two buttons on the toolbar marked " T " for text, and " [> " for Maple command prompt. Right now we are, of course, in the text mode. As an excercise, place the cursor at the end of this sentence, press the button marked " [> " and see a new Maple prompt ">" appear.

>

Type a simple command at the first prompt, say 2+2; (Don't forget the semicolon!) Press "Enter". Maple output, hopefully 4, appears and the cursor jumps to the next prompt. (If there was none below, Maple would create one). With the cursor at the new prompt press the " T " button. The prompt disappears and the mode changes to the text mode. Type something, say your name. Then switch back to the command mode by pressing " [> " again. And so it goes. Should you ever want to insert a command line before already typed text go to the "Insert" menu, choose "Execution Group" and click on "Before Cursor". Be aware of one thing though, you can't insert a command prompt in the middle of an execution group which consists of already typed text. If you are within already typed worksheet, after you click on any command, the cursor jumps to the next command line. If there is none below, one will be created.

If you want Maple to do something, you type your command at a command prompt and press "Enter". Your success with Maple depends on your use of correct and precise syntax . Syntax is a way of entering your commands. Last semester we learned quite a bit of Maple syntax and we shall continue using it this semster, as well as introduce new commands. For those of you who want to refresh your memory or who didn't take MTH 141 last semester, we review below Maple syntax used in Calculus I. Remember, also, that whenever in doubt, you can refer to the manual Getting Started with Maple that came with your textbook or to this introductory worksheet. Those of you who have never worked with Maple should not get discouraged by the amount of syntax reviewed in the next section. You don't have to memorize it all at once. You shall learn it as you work on examples in this and in subsequent worksheets.

Note: As you probably learned the hard way last semester, whenever you open a worksheet and want to do more with it than only viewing, if you want to change commands, enter new commands etc., you have to re-execute all the commands in the worksheet; that is you have to click "Enter" on all command lines, even if they have been saved and their outputs appear already on screen. Otherwise, Maple will not recognize functions and expressions defined in the worksheet and you will get strange error messages.

>

>

Review of Calculus I Maple Syntax

Each of the sections below describes syntax related to a specific topic. If you want to view any of the sections just click on the "+" button. The "+" will be replaced with "-" and the section will open. If a section contains material familiar to you, click on "-". The section will close.

In all sections below the symbol " % " is used. In Release 5 of Maple, " % " denotes the last executed output. That is, the output of the last command on which you have clicked. (It was " in earlier releases.) The symbol " % " easily leads to confusion and it should preferably be used on the same command line as the command to which it refers.

>

Basic syntax

Functions and Expressions. Evaluating Expressions.

Limits

Derivatives

Integrals

Plotting

Solving Equations

Packages

Using Maple's Help

Examples

The first example, which is very similar to some examples that we looked at last semester, will help you refresh your memory about the syntax. We use it to illustrate how you are expected to do your homework problems in terms of proper comments and explanations. Remember, it is usually not sufficient to hand in a bunch of Maple inputs and outputs. In most examples, you have to interpret the results and write your comments and answers in complete sentences.

Example 1. A rumor is spreading among a group of 200 people in an isolated region. The number of people, N(t), who have heard the rumor by time t, measured in hours since the rumor started to spread, can be approximated by the following function

[Maple Math] .

How many people have heard the rumor after 20 hours? After 30 hours? When has practically everybody heard the rumor? What can you say about the pattern according to which the rumor is spreading? When have150 people heard the rumor? When is the rumor spreading fastest?

We shall have to analyze the function N(t), hence we shall begin by defining it for Maple. To answer the first two questions we shall evaluate N(20), N(30). Then we shall calculate some more values to see when practically everyone has heard the rumor. To answer the question about the pattern we shall graph N(t) and describe its shape. The usefulness of your graph depends on the proper choice of the range for t. We shall have to choose the range for t large enough to see the global behavior of the function. To answer the question, when have 150 people heard the rumor we will have to solve an equation. Answering the last question will, of course require finding the maximum of the first derivative, which, in turn, will require finding zeros of the second derivative. As you work through the problem, you should comment and explain your methods and results. Should a problem like this be a homework problem, your solution should look like the one below in order for you to get full credit. (Remember, all comments are part of the solution.)

A Solution That Will Earn You Full Credit

> N:=t->200/(1+199*exp(-.17*t));

[Maple Math]

> N(20); N(30);

[Maple Math]

[Maple Math]

After 20 hours approximately 26 people have heard the rumor. After 30 hours approximately 90 people have heard the rumor.

> N(40);N(50);N(60);N(65);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

After about 65 hours practically everyone has heard the rumor.

> plot(N(t),t=0..70);

[Maple Plot]

>

At first the rumor is spreading slowly as the graph climbs slowly, then the rumor is spreading faster and faster. After about 40 hours it begins to spread slower again. After about 60 hours the graph levels off. Practically everyone has heard the rumor.

> D(N);

[Maple Math]

> plot(D(N)(t),t=0..70);

[Maple Plot]

>

The rumor is spreading fastest when the derivative is maximal. It seems to be around t=30. To find the point exactly, we shall find the corresponding zero of the second derivative.

> D(D(N));

[Maple Math]

> fsolve(D(D(N))(t)=0,t,20..40);

[Maple Math]

The rumor is spreading fastest at approximately t = 31.14.

> solve(N(t)=150,t);

[Maple Math]

>

150 people have heard the rumor at t approximately 37.6, that is, 37.6 hours after the rumor began spreading.

This was a model homework problem solution. Usually, examples in the worksheets will contain much more elaborate explanations.

Since the first part of the course is devoted to integration, our next example involves indefinte and definite integrals.

Example 2. Consider the function

[Maple Math] .

(a) Try to find the indefinite integral of r(t). What does Maple's response indicate?

(b) Find the definite integral

[Maple Math] .

(c) Define in Maple the function

[Maple Math] .

(d) Find the derivative of R(x). Are you surprised with the result? Why not or why yes?

(e) Plot graphs of r(x) and R(x) in one coordinate system for x between 1 and 8. Comment on how the two graphs are related.

We start from defining the function r(t) in Maple.

> r:=t->sin(t)/(2+(ln(t))^2);

[Maple Math]

Now we ask Maple to find the indefinite integral of r(t).

> int(r(t),t);

[Maple Math]

>

Maple simply printed out the input. This means that an antiderivative of r(t) cannot be found in terms of elementary (and even not so elementary) functions. Believe it or not, it is hard to come up with a function whose antiderivative cannot be found by Maple! Nevertheless, the definite integral of r(t) can be found numerically in any interval in the positive half-line. (Remember, ln(t) is defined only for positive t.). The integral can be found numerically, thus we need the command " evalf " in front of " int ".

> evalf(int(r(t),t=1..2));

[Maple Math]

The integral is well-defined and can be found numerically in any interval [1,x], hence we can define the function

> R:=x->int(r(t),t=1..x);

[Maple Math]

>

Of course, we cannot find a more explicit formula for R(x). Nonetheless, there is plenty that we can do with the function. For example, find its derivative

> diff(R(x),x);

[Maple Math]

>

Are we surprised? Of course not! The 2nd Fundamental Theorem of Calculus says exactly that R'(x)=r(x).

Amazingly , Maple can also plot the function R(x) (by evaluating numerically the corresponding definite integral for many values of x). We shall plot both functions r and R in one coordinate system. (Observe that we have to enter r(x) not r(t) to plot them both together.

> plot([r(x),R(x)],x=1..8,color=[red,blue]);

[Maple Plot]

>

How are the graphs related the red graph r(x) is the derivative of the blue graph R(x). Hence, where r(x) is positive, R(x) increases. Where r(x) in negative, R(x) decreases. Local minima and maxima of R(x) correspond to zeros of the red graph, which happens around 3.2 and 6.2.

Homework Problems

To solve your homework problems you should open a new worksheet, enter your name and the title of the worksheet to which your homework corresponds in the text mode. You should perform all the necessary Maple operations and supplement them by your explanations and answers as in the example above.

Problem 1. Suppose that the total number of people, M, in a small town, who have contracted a contagious disease by a time t days after its outbreak is given by

[Maple Math] .

(a) How many people have become sick after 5 days? After 10 days?

(b) Graph the function M(t) and describe its behavior.

(c) How long will it take for 300 people to have become sick?

(d) When is the disease spreading fastest?

Problem 2. Consider the function

[Maple Math] .

(a) Try finding the indefinite integral of p(t). What does Maple's response indicate?

(b) Find numerically the integral

[Maple Math] .

(c) Define the function

[Maple Math] .

(d) Find the derivative P'(x). Is the answer what you expected?

(e) Plot p(x) and P(x) in one coordinate system between x=1 and x=9. Comment on the relationship between the two graphs.

MTH 142 Maple Worksheets written by B. Kaskosz and L. Pakula, Copyright 1998.

Last modified August 1999.

>