Maple Module Part 1

21
MCSU Mathematics 73 (Introduction to Maple) 1 Introduction to Maple 6 Maple is an extensive mathematical-problem-solving environment used to support an expansive range of mathematical operation such as numerical analysis, symbolic algebra and graphics. It is comprehensive computer software for advanced mathematics. It includes facilities for interactive algebra, calculus, discrete mathematics, graphics, numerical computation and many other areas of mathematics. It also provides a unique environment for rapid development of mathematical programs using its vast library of built-in functions and operations. Worksheet Toolbar The toolbar is the area of the Maple window that contains buttons for performing common tasks. You can toggle between having the toolbar visible and having it hidden. From the View menu choose Toolbar. A check mark next to Toolbar in the menu indicates that the toolbar is displayed. The following is a list of the buttons on the worksheet toolbar. Create a new worksheet. Open an existing worksheet. Open a specified URL. Save the active worksheet. Print the active worksheet. Cut the selection to the clipboard. Copy the selection to the clipboard. Paste the clipboard contents into the current worksheet. Undo the last operation. Redo undone operation. Insert nonexecutable Standard Math in a text region. Insert text at the cursor. Insert a new execution group after the cursor. Remove the section enclosing the selection. Enclose the selection in a section or subsection. Go backward in the hyperlink history. Go forward in the hyperlink history. Cancel the computation in progress. Set the zoom magnification to 100%. Set the zoom magnification to 150%. Set the zoom magnification to 200%. Toggle the display of nonprinting characters. Resize the active window to fill the available space.

Transcript of Maple Module Part 1

Page 1: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 1

Introduction to Maple 6

Maple is an extensive mathematical-problem-solving environment used to support an expansive range of mathematical operation such as numerical analysis, symbolic algebra and graphics. It is comprehensive computer software for advanced mathematics. It includes facilities for interactive algebra, calculus, discrete mathematics, graphics, numerical computation and many other areas of mathematics. It also provides a unique environment for rapid development of mathematical programs using its vast library of built-in functions and operations. Worksheet Toolbar The toolbar is the area of the Maple window that contains buttons for performing common tasks. You can toggle between having the toolbar visible and having it hidden.

From the View menu choose Toolbar. A check mark next to Toolbar in the menu indicates that the toolbar is displayed.

The following is a list of the buttons on the worksheet toolbar.

Create a new worksheet.

Open an existing worksheet.

Open a specified URL.

Save the active worksheet.

Print the active worksheet.

Cut the selection to the clipboard.

Copy the selection to the clipboard.

Paste the clipboard contents into the current worksheet.

Undo the last operation.

Redo undone operation.

Insert nonexecutable Standard Math in a text region.

Insert text at the cursor.

Insert a new execution group after the cursor.

Remove the section enclosing the selection.

Enclose the selection in a section or subsection.

Go backward in the hyperlink history.

Go forward in the hyperlink history.

Cancel the computation in progress.

Set the zoom magnification to 100%.

Set the zoom magnification to 150%.

Set the zoom magnification to 200%.

Toggle the display of nonprinting characters.

Resize the active window to fill the available space.

Page 2: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 2

Overview of Basic Features Maple worksheets are files that document how to solve mathematical problems from the fields of mathematics, science, and engineering. Worksheets are both interactive and reusable. They can be used to replace calculators, spreadsheet application programs, and programs in languages such as FORTRAN. Specifically, in worksheets you can:

• perform computations

• manipulate mathematical expressions

• describe the problem-solving process When you use Maple to perform computations or manipulate expressions, Maple displays the corresponding results, which you can use for subsequent processing. The request you send Maple is called Maple input, it is displayed in red Courier typeface by default. You can change the default by modifying the Maple Input text style. The result is called Maple output, it is displayed centered in blue Times typeface by default. You can change the default by modifying the Maple Output text style. Together, Maple input and output comprises an execution group, which is the fundamental element of the worksheet.

Overview of Insert Menu The Insert menu contains commands to insert text and Maple objects into an active Maple worksheet.

� Text

Insert text into your Maple worksheet. Text can include comments which help explain your steps more effectively.

1. From the Insert menu, choose Text. 2. Type the text you want in the worksheet.

� Standard Math

Standard Math notation is displayed in a format similar in appearance to that found in a textbook. It is not necessarily executable.

1. From the Insert menu, choose Standard Math. A question mark appears at the insertion point and the edit field is displayed.

2. Type the expression, using the edit field for editing, if necessary.

3. Press the Enter key. The output will be displayed in nonexecutable Standard Math notation.

� Maple Input

Maple input is executable Maple notation, usually a mathematical expression, that Maple can evaluate.

1. From the Insert menu, choose Maple Input. The command prompt appears.

2. Type in the expression, followed by a semicolon to display the output, or by a colon to suppress the output.

Page 3: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 3

� Standard Math Input

Standard Math notation is displayed in a format similar in appearance to that found in a textbook. Standard Math Input is executable.

1. From the Insert menu, choose Standard Math Input. A question mark appears at the insertion point and the edit field is displayed.

2. Type the expression, followed by a semicolon to display the output, or by a colon to suppress the output. Use the edit field for editing, if necessary.

� Execution Group

An execution group is a grouping of Maple input with its corresponding Maple output. It is characterized by a large square bracket, called a group range, at the left. When you insert

an execution group, Maple also inserts a command prompt . Maple commands entered at this prompt are recognized as Maple input and can be executed.

From the Insert menu, choose Execution Group, and then either Before Cursor or After Cursor.

You can also set an option to have Maple always automatically insert a new execution group below any group that gets executed.

� Plot

Create a blank plot object after the cursor.

Two-dimensional Plot Object Create a blank smart plot object.

From the Insert menu, choose Plot, and then 2-D.

Place a curve in the plot object by moving or copying an expression from elsewhere in the worksheet.

Three-dimensional Plot Object

Create a blank smart plot object.

From the Insert menu, choose Plot, and then 3-D.

Place a surface in the plot object by moving or copying an expression from elsewhere in the worksheet.

� Standard Math Input

Add comments to your worksheets to provide information to readers about the steps you took to solve a problem.

1. From the Insert menu, choose Paragraph, and then Before or After. A new paragraph is inserted and the cursor is moved to the new blank line.

2. Type the paragraph.

Page 4: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 4

Overview of Palettes A palette is a collection of buttons representing predefined symbols, expressions, operators, or Matrices. By clicking on the buttons on the palettes, you can build or edit mathematical expressions without having to remember the Maple command syntax.

You can toggle between having the palettes visible and having them hidden.

Use the Expression Palette - to build expressions containing constructions such as integrals, derivatives, sums, and products.

The expression palette contains buttons for constructing expressions such as integrals, derivatives, sums, and products.

1. Display the expression palette.

2. Click where you want to insert the expression.

3. On the expression palette, click the template for the expression you want to enter. For

example, for division, click . 4. Fill in the first placeholder by entering a number, a symbol, or an expression.

5. Press the Tab key to move the cursor to the next placeholder.

6. Continue filling all placeholders that apply to your expression.

7. If you are using Standard Math notation, press the Enter key to accept your value for the last placeholder.

8. When all of the relevant placeholders have been filled, press the Enter key.

Use the Symbol Palette - to add symbols and Greek letters to expressions.

The symbol palette contains buttons for inserting mathematical symbols into your expressions.

1. Display the symbol palette. (See Show Palettes.)

2. Click where you want to insert the symbol.

3. On the symbol palette, click the symbol you want to enter. For example, to enter an alpha,

click on .

Title Your Worksheet 1. Place your cursor at the top of the worksheet.

2. From the Insert menu, choose Paragraph, and then Before.

3. Type the title.

4. In the list of styles on the far left of the context bar, click Title.

To change the way the text appears, see Overview: Maple Text Styles.

Page 5: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 5

The Worksheet Interface

Page 6: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 6

Maple as a Mathematical Problem-solving Tool

Use Maple to solve a wide range of mathematical problems. Enter, compute, and manipulate mathematical expressions by using the powerful Maple mathematical engine. During the problem-solving process, Maple can take the result of one calculation and use it as input for a second calculation. In this way, Maple can solve complicated mathematical problems.

Active and Inert Functions Certain Maple commands have both active and inert forms. In these cases, the command beginning with a lower-case letter is the active form and causes Maple to compute a result immediately. The inert commands start with a capital letter and are useful to show steps in the problem-solving process.

These are some of the Maple commands that have both active and inert forms.

• diff (Diff)

• int (Int)

• limit (Limit)

• normal (Normal)

• product (Product)

• sum (Sum)

Maple displays inert forms in two colors in the worksheet. It maintains the default color for variables and elements of the expression you can change, and it displays items you cannot change in black.

> int(x^2,x);

> Int(x^2,x);

13

x3

d⌠⌡x2 x

Page 7: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 7

Enter Expressions in Maple

A new worksheet opens with a Maple prompt in the upper left-hand corner. Enter Maple commands at this prompt so that Maple recognizes your entry as Maple input and executes the command. (See Overview of Palettes for information on using palettes to enter expressions without having to remember all the syntax of Maple commands.) The following assumes the Input Display is set to Maple Notation. See Set Input Display for more information.

1. Type the Maple input, followed by either a semicolon or a colon. The semicolon indicates that the input executes and the corresponding Maple output is displayed, as seen below.

> factor(x^2 + 2*x + 1);

The colon indicates that the input executes, but the corresponding output is suppressed, as seen below.

> assume(z > 0):

2. Press the Enter key. Maple evaluates the input and displays the output, provided that the input ends with a semicolon.

Assigning Names to Expressions Assign a name to a Maple expression so that you can use the expression again in subsequent calculations. > expn := 3 * sin(x) + 2 * cos(x);

> sin(x) * expn;

You can even give names to equations. > eqn := y = 5*x - 3;

Define your own functions. > f := x -> x * 2;

> f(3);

> f(y + 1);

( ) + x 1 2

:= expn + 3 ( )sin x 2 ( )cos x

( )sin x ( ) + 3 ( )sin x 2 ( )cos x

:= eqn = y − 5 x 3

:= f → x 2 x

6

+ 2 y 2

Page 8: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 8

Examples of Maple Functions Maple functions include most standard mathematical functions such as sin, sinh, arcsin, exp, ln, sqrt, binomial, and so on.

Examples of Maple Functions

The following are examples of some basic Maple functions

> cos(alpha)^2+sin(alpha)^2;

> a*x^2+b*x=c;

> a*Int(exp(sqrt(2)*x),x);

> Limit(f(x),x=infinity);

> Sum(a[k]*x^k, k=0..m)=Product(b[j]*x^j, j=0..n);

Examples of Advanced Maple Functions More advanced Maple functions include the differential operator, the sequence function, the composite function, and so on.

Derivatives and the Differential Operator Express derivatives using the function diff. > diff(a*x^2+b*x +c, x,x);

Composition Function The Composition function, @ @, takes two arguments. The first argument must be a function, such as sin or cos, or a variable name that can be treated as a function. The second argument specifies the number of times the function should be composed. Because the @ symbol

+ ( )cos α 2 ( )sin α 2

= + a x2 b x c

a d⌠

⌡eeee

( )2 xx

lim → x ∞

( )f x

= ∑ = k 0

m

akxk ∏

= j 0

n

bjxj

2 a

Page 9: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 9

is special to Maple, you must enclose the name @ inside single open quotes (`) when using it as a function. `@@`(cos, 3)(x) means cos(cos(cos(x))) and `@@`(D,2)(y)(x) means D(D(y))(x)

RootOf Maple uses the function RootOf to represent the roots of a polynomial in one variable. It is a compact representation because all roots can be expressed at once. In addition, it enables Maple to manipulate the roots of a polynomial even when it is unable to find explicit representations for them. The polynomial is always expressed in terms of the variable _Z. Solve for the Roots explicitly.

1. Select the expression.

2. From the Context menu, choose All Values You could also use the allvalues function.

Examples: > RootOf(x^2+1=0);

> RootOf(x^2-a*x=b, x);

> RootOf(a*b^2+a/b, b);

> RootOf(a*x+b, x);

> RootOf(x^3-1, x) mod 7;

> RootOf(x^2-2*x+1, x) mod 5;

> alias(alpha = RootOf(x^2+x+1)): Normal(1/alpha) mod 2;

> RootOf(x^2=2, x, -1.41);

> evalf(%);

( )RootOf + _Z2 1

( )RootOf − − _Z2 a _Z b

( )RootOf + _Z3 1

−ba

( )RootOf + _Z3 6

1

+ α 1

( )RootOf , − _Z2 2 -1.41

-1.414213562

Page 10: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 10

> RootOf( x^3-2, x, -0.7-1.1*I .. -0.6-1.0*I );

> evalf(%);

> r1 := RootOf(_Z^4+_Z^2+1, index=1);

> evalf(r1);

> allvalues(r1);

> r2 := RootOf(_Z^4+_Z^2+1, label=1);

> evalf(r2);

> allvalues(r2);

Getting Started

Executing Commands To execute commands in the New User's Tour (and any other) worksheets:

1. Place the cursor on the first command line (for example, 1+1; below) by using your mouse or the Tab key.

2. Press Enter.

Try this now: > 1+1;

( )RootOf , − _Z3 2 .. − -.7 1.1I − -.6 1.0I

− -.6299605249 1.091123636I

:= r1 ( )RootOf , + + _Z4 _Z2 1 = index 1

+ .5000000000 .8660254038I

+ 12

12

I 3

:= r2 ( )RootOf , + + _Z4 _Z2 1 = label 1

( )RootOf , + + _Z4 _Z2 1 = label 1

, , ,− + 12

12

I 3 − − 12

12

I 3 + 12

12

I 3 − 12

12

I 3

Page 11: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 11

By pressing Enter, you also move the cursor to the next command line (in this case, limit( x-7, x=3 );) in the worksheet. > limit( x-7, x=3 ); Please note:

• If you happen to place the cursor elsewhere in a worksheet, place it back on the appropriate command line before pressing Enter to continue.

• It is important to execute the commands in order because some computations require results from previous command lines.

Maple worksheets can serve as an interactive problem-solving environment, or as a system for generating technical documentation. This topic explains the various elements and features of Maple worksheets.

Interacting with Maple's Computational Engine

Execution groups and spreadsheets help you to interact with the Maple computational engine. They provide the primary means by which Maple is asked to carry out specific tasks and display the results. Maple commands can be entered into either of these.

Execution Groups

Execution groups are the fundamental computation elements in the worksheet. Their primary purpose is to combine one or more Maple commands and their results into a single re-executable unit. You can easily recognize an execution group by a square bracket immediately to the left of the command prompt.

> solve( a*x^2 = 4, {x} ); The function above solves the equation as indicated on its first parameter (e.g. 42 =ax ). The output would be:

When you place the cursor on any command line in an execution group and press Enter, all commands in that group are executed in sequence and the results (or output) are displayed at the end of the execution group. The cursor is automatically advanced to the first command line in the next execution group. In addition to Maple commands and their results, an execution group can contain descriptive paragraphs.

,{ } = x 21

a{ } = x −2

1

a

Page 12: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 12

Examples: The following execution group contains a paragraph and a Maple command line with one command. After you place the cursor on the command line and press Enter, it will also contain the command result. A Maple command and the computed result. > expand((a + b)^3); The function above is used to expand a given expression to its nth power. The output would be:

New Maple worksheets begin with a single execution group containing a command prompt (as shown below). To create a new execution group within a worksheet, from the Insert menu, choose Execution Group, then Before Cursor or After Cursor. The results produced by a Maple command may be numeric, symbolic, or graphical. The following command generates a plot of a three-dimensional surface: > plot3d( sin(x*y) , x = -2..2, y = -1..1 );

DIAGRAM

Constructing and Executing Maple Commands

This section presents three primary means of creating Maple commands and results.

Typing Commands You can execute commands by typing them at a Maple prompt, and pressing Enter. You can display commands as Maple notation or as standard math notation.

Using Context-sensitive Menus Existing Maple results can be used to suggest and construct new actions. To obtain an on-screen list of suggested actions, right-click on a Maple object. (Option-click if you have only one mouse button.) The resulting list of actions is called a context-sensitive menu, because the items it contains vary depending on the properties of the selected object. Try this out now. Copy the equation: Select it, and from the Edit menu, choose Copy. Create a new worksheet: From the File menu, choose New. (Switch between the worksheet and this one by using the Window menu.) Paste the equation at the command prompt: From the Edit menu, choose Paste. Type a semicolon at the end of the command line, and press Enter. Right-click (or option-click) on the result to see the context-sensitive menu. (Left-click elsewhere to close the menu without choosing an item.)

+ + + a3 3 a2 b 3 a b2 b3

Page 13: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 13

You can also use the context-sensitive menus to plot expressions. Go back to your new worksheet, and right-click on the result again. From the context-sensitive menu, choose Plots, then Implicit 3-D Plot, then x,y,z as the desired permutation for the axes. You should arrive at the three-dimensional smart plot displayed below. > smartplot3d[x,y,z](z = sin(x^2*y));

DIAGRAM

Dragging and Dropping You can move Maple output to or from smart plots by using the mouse. When you drag the result of an evaluation to a smart plot, it will become a curve or surface. When you drag a curve or surface away from a set of axes, the corresponding expression will be placed in the worksheet. Formulae may also be dragged from the worksheet into a cell of a spreadsheet, or from a cell of a spreadsheet to a worksheet.

Annotating and Structuring Documents

Paragraphs, sections, and hyperlinks exist to help you document and organize your results. This section describes how to use these features to make your worksheet document more interactive and usable.

Paragraphs and Text

A paragraph in a worksheet is analogous to a paragraph in a word processor. Paragraphs can contain styled text, inline mathematics, and graphics, including copies of Maple-generated output, such as plots. A paragraph can also be contained in an execution group. Paragraphs are used for explanatory notes such as this. They are presented in black Times or Times New Roman font by default. The following sentences illustrate the types of formatting that you can easily apply to Maple paragraphs: 1. Paragaphs can be centered. 2. They can be left-justified. 3. They can be right-justified. 4. Text can be italicized and underlined, and it can be made bold. 5. The size and font of the text can easily be changed. (Please note that you cannot change text in this worksheet, because it's set to "read only.") As in word processors and desktop publishers, you can create your own paragraph and character styles for text. To do so, from the Format menu, choose Styles.

= z ( )sin x2 y

Page 14: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 14

Maple supports inline mathematics so that you can develop sophisticated documents featuring typeset equations and graphics within text areas. For example, it is possible to create the following:

To compute the symbolic definite integral in Maple, type:

> int( x^2*sin(alpha*x), x=0..beta );

Numerical Calculations

Computations with Integers At its most basic level, you can use Maple as a very powerful calculator. To calculate (32)( ), you would enter the following: > 32*12^13;

Maple recognizes many special operators, including factorial, greatest common divisor, least common multiple, and computation over the integers modulo m. The following line is an example of the factorial operator in use. > 200!;

You can easily include the previous expansion of in any subsequent calculation without having to type it. The ditto operator, represented by a percent sign (%), refers to the last expression computed by Maple. (For more information on the ditto operator, see the help page for ditto.) The command ifactor factors the previous result into its prime factors. > ifactor(%);

The next command calculates the product again, which is precisely the value of 200!. > expand(%);

Floating-point Arithmetic

A principal strength of Maple is its ability to do exact arithmetic. Fractions and radicals during computation are not converted to their decimal equivalent, thereby avoiding round-off

d⌠⌡

0

β

x2 ( )sin α x x

1213

3423782572130304

7886578673647905035523632139321850622951359776871732632947425332443594\499634033429203042840119846239041772121389196388302576427902426371\050619266249528299311134628572707633172373969889439224456214516642\402540332918641312274282948532775242424075739032403212574055795686\602260319041703240623517008587961789222227896237038973747200000000\00000000000000000000000000000000000000000

!200

( ) 2 197 ( ) 3 97 ( ) 5 49 ( ) 7 32 ( ) 11 19 ( ) 13 16 ( ) 17 11 ( ) 19 10 ( ) 23 8 ( ) 29 6 ( ) 31 6 ( ) 37 5

( ) 41 4 ( ) 43 4 ( ) 47 4 ( ) 53 3 ( ) 59 3 ( ) 61 3 ( ) 67 2 ( ) 71 2 ( ) 73 2 ( ) 79 2 ( ) 83 2 ( ) 89 2

( ) 97 2 ( ) 101 ( ) 103 ( ) 107 ( ) 109 ( ) 113 ( ) 127 ( ) 131 ( ) 137 ( ) 139 ( ) 149 ( ) 151( ) 157 ( ) 163 ( ) 167 ( ) 173 ( ) 179 ( ) 181 ( ) 191 ( ) 193 ( ) 197 ( ) 199

Page 15: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 15

errors. When you do need to use decimal equivalents, Maple has a command that approximates the value of the expression in a floating-point form.

Consider the expression , which is entered on the Maple command line as follows:

> (2^30/3^20)*sqrt(3);

Use the evalf command to generate an approximation in the form of a floating-point value. > evalf(%);

Finite and Infinite Sums and Products You can calculate both finite and infinite sums.

Consider the finite sum . You calculate its value as follows:

> sum( (1+i)/(1+i^4), i=1..10 );

Consider the infinite sum . To calculate its value, enter:

> sum( 1/k^2, k=1..infinity );

Maple also calculates both finite and infinite products.

To evaluate the finite product , you would enter the following Maple

command: > product( ((i^2+3*i-11)/(i+3)), i=0..10 );

You can do arithmetic with floating-point numbers to any desired precision. In fact, Maple handles numbers up to hundreds of thousands of digits of precision on most operating systems. The following command calculates a 50-digit floating-point approximation of the fraction in the previous calculation.

230 3

320

10737418243486784401

3

.5333783739

∑ = i 1

10 + 1 i

+ 1 i4

5150805672759473291372240626648938819200088497

∑ = k 1

∞ 1

k2

16

π2

∏ = i 0

10 + − i2 3 i 11 + i 3

-778170651265740435200

Page 16: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 16

> evalf( % , 50 );

Complex Numbers and Special Functions Maple also performs calculations using complex numbers. Type the complex unit as a capital I. > (3+5*I)/(7+4*I);

To easily convert a complex number to its polar-coordinate form, use the convert function. Maple represents the expression in the form polar( ), where r is the modulus and is the argument of the complex value of the expression. > convert( % , polar );

You can compute numeric values for the elementary functions and many special functions and constants. For example, compute , the base of the natural logarithm, to 40 digits. > evalf( exp(1.0), 40 );

Consider an example of the Gamma function : > evalf( GAMMA(2.5) );

Finally, suppose that you want to evaluate to 500 digits: > evalf( Pi, 500 );

Algebraic Computations

Working with Expressions Maple provides different ways of manipulating and displaying expressions to make them easier to verify, or more effective to use. This flexibility allows you to do such things as expand binomials, factor results, simplify trigonometric expressions, assign variable names to results, and convert expressions to different forms.

-192448.81965854008388730610952833175055397277619500

+ 4165

2365

I

,r θ θ

polar ,

165

2210

arctan

2341

eeee

2.718281828459045235360287471352662497757

( )Γ 2.5

1.329340388

π

3.14159265358979323846264338327950288419716939937510582097494459230781\640628620899862803482534211706798214808651328230664709384460955058\223172535940812848111745028410270193852110555964462294895493038196\442881097566593344612847564823378678316527120190914564856692346034\861045432664821339360726024914127372458700660631558817488152092096\282925409171536436789259036001133053054882046652138414695194151160\943305727036575959195309218611738193261179310511854807446237996274\95673518857527248912279381830119491

Page 17: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 17

Expanding and Factoring Expressions

Maple can expand binomials such as . The following Maple commands create the expression, and then expand it. > expr := (x+y)^15; > expand(expr);

After viewing the results, you can use the factor command to factor the last result and check the computation. > factor(%);

Simplifying Expressions Maple can apply identities to simplify many lengthy mathematical expressions, such as trigonometric expressions. Consider . > simplify( cos(x)^5 + sin(x)^4 + 2*cos(x)^2 - 2*sin(x)^2 - cos(2*x) );

Another way to simplify expressions is to use the normal command, which puts fractions on a common denominator and removes common factors in the numerator and denominator.

The fraction is much simpler after Maple removes the common factors.

> normal( (x^3-y^3)/(x^2+x-y-y^2) );

Assigning Variable Names You can assign a variable name to the results of a computation. The use of variables is essential for managing large numbers of expressions and functions, especially if you want to reuse the output later in a session.

For example, create the expression , and store it as . > expr1 := (41*x^2+x+1)^2*(2*x-1);

Use the expand command on and store the result as a variable, . > expr2 := expand(expr1);

( ) + x y 15

x15 15y x14 105y2 x13 455y3 x12 1365y4 x11 3003y5 x10 5005y6 x9 6435y7 x8 + + + + + + + 6435y8 x7 5005y9 x6 3003y10 x5 1365y11 x4 455y12 x3 105y13 x2 + + + + + + 15y14 x y15 + +

( ) + x y 15

+ + − − ( )cos x 5 ( )sin x 4 2 ( )cos x 2 2 ( )sin x 2 ( )cos 2x

+ ( )cos x 5 ( )cos x 4

− x3 y3

+ − − x2 x y y2

+ + x2 y x y2

+ + x 1 y

( ) + + 41 x2 x 12

( ) − 2 x 1 expr1

:= expr1 ( ) + + 41 x2 x 12

( ) − 2 x 1

expr1 expr2

Page 18: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 18

Evaluate at x=1. > eval(expr2 , x=1 );

In the next example, is assigned the normalized quotient of the expansion of two expressions, and . > top := expr2;

> bottom := expand((3*x+5)*(2*x-1));

> answer := normal( top/bottom );

Converting Expressions to Different Forms The convert command allows you to convert many types of expressions into specific forms. For a complete list of conversions available in Maple, see the Help page for the convert command.

The following example converts a symbolic expression, , into its

partial fraction decomposition. > my_expr := (a*x^2+b)/(x*(-3*x^2-x+4));

> convert( my_expr, parfrac, x );

The following example converts a trigonometric expression, , into an exponential expression. > convert( cot(x), exp );

:= expr2 − + − − 3362x5 1517x4 84 x3 79 x2 1

expr2

1849

answertop bottom

:= top − + − − 3362x5 1517x4 84 x3 79 x2 1

:= bottom + − 6 x2 7 x 5

:= answer + + + + 1681x4 82x3 83x2 2 x 1

+ 3 x 5

+ a x2 b

x ( )− − + 3 x2 x 4

:= my_expr + a x2 b

x ( )− − + 3 x2 x 4

− − 14

bx

128

+ 16a 9 b + 3 x 4

17

+ a b − x 1

( )cot x

I ( ) + ( )eeee( )I x

2

1

− ( )eeee( )I x

2

1

Page 19: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 19

Function Notation Maple provides several ways to define functions. One way is to use arrow notation (which closely resembles standard mathematical notation for a mapping). You can also use the unapply command, which turns an expression into a function.

Define the function .

> f := x -> x^2+1/2 ; Evaluate the function at numeric and symbolic values. > f(2);

> f(a+b);

Use the unapply command to turn an expression into a function. > g := unapply(x^2 + 1/2, x);

Solving Equations and Systems of Equations You can use Maple to solve and verify solutions to equations and systems of equations.

Solving an Equation

Use Maple to solve the following equation: .

> eqn := x^3-1/2*a*x^2+13/3*x^2 = 13/6*a*x+10/3*x-5/3*a;

> solve( eqn, {x} );

To verify one of the solutions, evaluate the equation at that particular value of x. > eval( eqn , x=1/2*a );

Solving a System of Equations You can also solve systems of equations in Maple. Consider the following set of four equations and five unknowns: > eqn1 := a+2*b+3*c+4*d+5*e=41;

→ x + x2 12

92

+ ( ) + a b 2 12

= − + x3 a x2

213x2

3 + −

13a x6

10x3

5 a3

:= eqn = − + x3 12

a x2 133

x2 + − 136

a x103

x53

a

, ,{ } = x23

{ } = x -5 { } = x12

a

= 1312

a2 1312

a2

Page 20: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 20

> eqn2 := 5*a+5*b+4*c+3*d+2*e=20; > eqn3 := 3*b+4*c-8*d+2*e=125; > eqn4 := a+b+c+d+e=9; Now solve the system for the variables , , , and d. Maple will return its solutions in terms of the fifth variable, e. Since there are four equations and five unknowns, we will have a parametric set of solutions. On the other hand, if we solved for a, b, c, d and e, Maple would choose one of the variables (at random) as a free parameter. > solve( {eqn1, eqn2, eqn3, eqn4}, {a, b, c, d} );

To verify that this solution satisfies eqn1 and eqn2, evaluate both of them at this solution. > eval( {eqn1, eqn2} , % );

Further Examples of Solving Equations The following examples show other types of equations that you can solve using Maple, such as equations using trigonometric functions and absolute values. Solve an equation involving trigonometric functions. > solve( arccos(x) - arctan(x)= 0, {x} );

As a final example, solve an equation containing absolute values: . > solve( abs( (z+abs(z+2))^2-1 )^2 = 9, {z});

> abs( (z+abs(z+2))^2-1 )^2 = 9;

Solving Inequalities The following examples show how easy it is to solve systems of inequalities in Maple.

Use Maple to solve systems of inequalities, such as .

> solve( {x^2<1, y^2<=1, x+y<1/2}, {x,y} );

Another example involves solving the inequality , for x in terms of y.

a b c

{ }, , , = b − + 31313

2213

e = c − 48313

3113

e = d − − 7913

413

e = a 2

{ }, = 20 20 = 41 41

= x12

− + 2 2 5

− +

− +

12

12

52

12

12

5

= − ( ) + z + z 2 2 12

9

,{ } = z 0 { } ≤ z -2

= − ( ) + z + z 2 2 12

9

, , < x2 1 ≤ y2 1 < + x y12

{ }, , , , < -1 x < x 1 ≤ y 1 ≤ -1 y < + x y12

< + + x y4

+ x y10

Page 21: Maple Module Part 1

MCSU Mathematics 73 (Introduction to Maple) 21

> ineq := x+y+4/(x+y) < 10; > solve( ineq, {x} );

Not only does Maple solve inequalities, but it can also consider a complex inequality such as , and compute its Boolean value, by using the is command. > expr := 2*sqrt(-1-I)*sqrt(-1+I): > is( expr <> 0 );

,{ } < x −y { }, < − − 5 21 y x < x + − 5 21 y

≠ 2 − − 1 I − + 1 I 0

true