# Maple Crash Course

date post

04-Jun-2018Category

## Documents

view

218download

0

Embed Size (px)

### Transcript of Maple Crash Course

8/13/2019 Maple Crash Course

1/139

Crash Course in Maple

for Calculus I

Dr. Jennifer Bergner

Dr. Don Spickler

The goal of this lab is to take you through all you need to know about Maple for Calculus I. It is intended for those who are going into Calculus II or III and did not have a course that implemented the Maple computer algebra system.

Since this lab covers all of the commands you would see in a Calculus I class it will take a while to finish and you may want to finish it in portions. We highly recommend typing in and executing all of the commands discussed in the lab and doing all of the exercises. The solutions to the exercises are at the end of the laboratory.

8/13/2019 Maple Crash Course

2/139

Crash Course in Maple for Calculus I

2

Basic Commands

What is Maple?

Maple is a computer algebra system, which means that it does symbol manipulation in the same way we do when solving a problem by hand. One advantage to using a system like this is that it will keep its answers in exact form whenever possible and in many cases you need to force it to give you an approximation. Maple is a mathematical “worksheet”. It works primarily by what is called command-line interaction. You type in a command, in a way Maple will understand, and Maple will do the calculations and give you an answer. It is not completely menu-driven like many other computer applications. For example, when you start up Maple you will see something like the following

The [> is your command line prompt. You will type in your command here. When you type a command it will show up in red and every command must end with a semi-colon. After you type in the semi-colon and hit Enter Maple will do its thing. Let’s start out with an easy command. Say we wanted to add 3 and 4 together. The command would be

> 3+4; 7

Note that you only type in 3+4; Also note that Maple output the solution, in exact form, in blue and centered it. Try the following simple commands.

> 1/2+1/3; 5

6

> 1/2-1/3;

8/13/2019 Maple Crash Course

3/139

Crash Course in Maple for Calculus I

3

1

6

> 7*1/3; 7

3

> 8.3+1/3; 8.633333333

In the last command notice that it gave us a decimal output, that is an approximate solution. Maple has two modes, exact and approximate. Maple will stay in exact mode as long as it can or until you force it to go approximate. There are several commands you can use to get approximate solutions and we will look at many of these in this lab. Another way to force Maple to give you an approximate solution is to include a decimal number in your input.

Getting Started with Maple

Since Maple is a computer algebra system it can deal with variables as easily as it can deal with numbers. For example,

> 3*x-2*y; −3 x 2 y

> x^2;

x2

> x^(1/2);

x

> 4^(1/2);

4

> simplify(4^(1/2)); 2

The syntax for mathematical expressions in Maple is quite similar to other programs like Excel and to most graphing calculators. The main thing to watch is that

you must always use an * to denote multiplication. Otherwise, it is simply + for addition, – for subtraction, * for multiplication, / for division, ^ for powers and we always use parentheses ( ) for grouping. Note that [ ] and { } have other uses in Maple. For example,

> 3*x^2-2*x+7;

− +3 x2 2 x 7

8/13/2019 Maple Crash Course

4/139

Crash Course in Maple for Calculus I

4

> 4^(x-2);

4 ( )− +2 x

Maple will also give you an error if the expression you input is in some way ambiguous.

For example,

> x^x^x; Error, `^` unexpected

> x^(x^x);

x ( ) x

x

> (x^x)^x;

( ) x x x

As you know parentheses can make a big difference in the meaning of an expression. Note the difference in the following outputs.

> (x^2-7*x+2)/(x+3);

− + x2 7 x 2 + x 3

> x^2-7*x+2/x+3;

− + + x2 7 x 2

x 3

> x^2-7*x+2/(x+3);

− + x2 7 x 2

+ x 3

Exercises:

1. Type in the command that will give you the expression

+ − 2

+ x y 3

z 5

2. Type in the command that will give you the expression

− + x y 2

7 z

( )/2 3

3. Type in the command that will give you the expression

+ x ( )+ y 3 + y 3

+ z 2

8/13/2019 Maple Crash Course

5/139

Crash Course in Maple for Calculus I

5

In Maple, percentage signs are used to refer to previously computed expressions. Specifically, the % operator reevaluates the last expression computed, the %% operator reevaluates the second last expression computed, and the %%% operator reevaluates the third last expression computed. Be careful, the last expression is not always the one directly above the %, it is the last one done in the session. For example, if

we execute the following commands in order,

> 1/2+1/3; 5

6

> 1/2-1/3; 1

6

> 7*1/3; 7

3

Then the following ditto commands will return the following values.

> %; 7

3

> %%; 1

6

> %%%; 5

6

If we execute the same commands in reverse order then the following ditto commands will return the following values.

> %; 5

6

> %%; 1

6

> %%%; 7

3

8/13/2019 Maple Crash Course

6/139

Crash Course in Maple for Calculus I

6

Setting a Variable to a Value

One very useful capability of Maple is the ability to store an expression in a variable name. This is much like storing a value into the memory of a pocket calculator.

We simply give the value of expression a name and then simply by using the name we get the entire expression. To set a variable to a value you simply start the command with

the variable name followed by := and then the value or expression. For example, to

define the variable x to be the number 5 we would use,

> x:=5; := x 5

From now on every time x is used the value of 5 replaces it. For example,

> x; 5

> x+3; 8

> x+1/2; 11

2

To define the variable x to be the expression 72 −h we would use,

> x:=2*h-7; := x −2 h 7

Now when we use x the expression 72 −h replaces it. For example,

> 2*x; −4 h 14

> x^2;

( )−2 h 7 2

> expand(x^2);

− +4 h2 28 h 49

As you can see, this could cause a problem if you wanted to define the expression 2 x but you wanted x to be a variable and not 72 −h . If you do define a variable to be a particular value or expression you need to reset it if you then want the variable to be a

8/13/2019 Maple Crash Course

7/139

Crash Course in Maple for Calculus I

7

variable. To reset a variable back to a variable start with the variable followed by the :=

followed by the variable in single quotes. For example,

> x:='x'; := x x

Now we have the following values for the above expressions.

> 2*x; 2 x

> x^2;

x2

> expand(x^2);

x2

Do not use this method to define a function. For example, if we wanted to define to

define the function ( ) 532 2 −+= x x x f the command

> f:=2*x^2+3*x-5;

:= f + −2 x2 3 x 5

Would not do the trick. It does define f to be the given expression but it does not view f as a function. Note the output of the following commands.

> f;

+ −2 x2 3 x 5

> f(3);

+ −2 ( )x 3 2 3 ( )x 3 5

The correct way to define this function is by,

> f:=x->2*x^2+3*x-5;

:= f → x + −2 x2 3 x 5

> f(3); 22

We will talk more about function later in the lab.

8/13/2019 Maple Crash Course

8/139

Crash Course in Maple for Calculus I

8

Exercises:

4. Type in the Maple command that will set the variable a to the value of 17. 5. Type in the Maple command that will set the variable b to the variable a.

6. Get the value of b. What happened?7. Set the variable c to the expression

+ − 2

+ x y 3

z 5

8. Set the variable d to the expression

− + x

y

2 7 z

( )/2 3

9. Set the variable e to the expression

+ x ( )+ y 3 + y 3

+ z 2

10. Set the variable x to the expression + x

( )+ y 3 + y 3 + z 2

What happened and why? 11. Reset the variables a, b, c, d and e back to variables.

Mathematical Functions

The following is a list of some of the more useful mathematical functions and their Maple syntax.

Trigonometric and Hyperbolic Functions

Function Maple Syntax Notes

( )