Maple User Manual
Maple User Manual
© Maplesoft, a division of Waterloo Maple Inc. 2005. All rights reserved. No part of this book may be reproduced,
stored in a retrieval system, or transcribed, in any form or by any means — electronic, mechanical, photocopying,
recording, or otherwise. Information in this document is subject to change without notice and does not represent
a commitment on the part of the vendor. The software described in this document is furnished under a license
agreement and may be used or copied only in accordance with the agreement. It is against the law to copy the
software on any medium except as specifically allowed in the agreement.
Java and all Java based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United
States and other countries. Maplesoft is independent of Sun Microsystems, Inc.
This document was produced using a special version of Maple and DocBook.
Printed in Canada
ISBN 1-894511-75-1
Contents
Preface .................................................................................................... xiii
1 Document Mode ...................................................................................... 1
1.1 Introduction ...................................................................................... 1
1.2 In This Chapter ................................................................................ 3
1.3 Simple Mathematical Expressions ................................................... 4
Rational Expressions (Fractions) ....................................................... 5
Powers ................................................................................................ 5
Products .............................................................................................. 5
Shortcuts for Entering Mathematical Expressions ............................. 6
Other Expressions .............................................................................. 7
1.4 Evaluating Expressions .................................................................... 8
1.5 Editing Expressions and Updating Output ...................................... 9
1.6 Entering Expressions ..................................................................... 10
Palettes ............................................................................................ 10
Symbol Names ................................................................................ 16
1.7 Performing Computations ............................................................. 19
Computing with Palettes ................................................................. 20
Context Menus ................................................................................ 20
Assistants and Tutors ....................................................................... 26
1.8 Document Mode Summary ............................................................ 30
1.9 Getting Help ................................................................................... 32
2 Worksheet Mode ................................................................................... 35
2.1 In This Chapter .............................................................................. 36
2.2 Input Prompt .................................................................................. 37
Suppressing Output .......................................................................... 38
1-D Math Input ................................................................................ 38
Input Separators ............................................................................... 39
2.3 Commands .................................................................................... 40
The Maple Library ........................................................................... 40
Top-Level Commands ...................................................................... 40
Package Commands ........................................................................ 42
2.4 Palettes .......................................................................................... 44
2.5 Context Menus .............................................................................. 46
2.6 Assistants and Tutors ..................................................................... 48
iii
iv • Contents
xi
xii • List of Tables
Table 5.14: Creating Animations Using the Interactive Plot Builder ..... 223
Table 5.15: The animate Command ....................................................... 225
Table 5.16: Animation Options .............................................................. 226
Table 5.17: Customizing Animations Using the Context Menu ............ 229
Table 8.1: Default Clause Values ........................................................... 327
Table 8.2: Iterative Commands .............................................................. 333
Table 8.3: The seq Command ................................................................ 333
Table 8.4: The add and mul Commands ................................................ 334
Table 8.5: The select, remove, and selectremove Commands ............... 335
Table 8.6: The map Command ............................................................... 336
Table 8.7: The zip Command ................................................................. 337
Table 10.1: Summary of Content Translation When Exporting to Different
Formats .................................................................................................. 371
Preface
The Maple Software
The MapleTM software is a powerful system that you can use to solve complex
mathematical problems. You can also create professional quality documents,
presentations, and custom interactive computational tools in the Maple en-
vironment.
You can access the power of the Maple computational engine through a
variety of interfaces.
Interface Description
Standard Worksheet Full-featured graphical user interface offering features
that help you create electronic documents that show all
your assumptions, the calculations, and any margin of
error in your results; or hide the computations to allow
your reader to focus on the problem setup and final res-
ults. The advanced formatting features help you create
the customized document you need. Because the docu-
ments are live, you can edit the parameters and, with the
click of a button, compute the new results.
The User Manual was created using the Standard
Worksheet interface to Maple. An interactive version of
this manual is available in the Standard Worksheet inter-
face. From the Help menu, select Manuals, Dictionary,
and more>Manuals>User Manual.
Classic Worksheet Basic worksheet environment for older computers with
limited memory.
Command-line version Command-line interface, without graphical user inter-
faces features, for solving very large complex problems
or batch processing with scripts.
xiii
xiv • Preface
Interface Description
This manual describes how to use the Standard Worksheet interface. Some
features are not available in the Classic Worksheet interface and Command-
line version. The Standard Worksheet interface has two modes: Document
mode and Worksheet mode.
Document Mode - Using the Document mode, you can perform quick cal-
culations. You can enter a mathematical expression, and then evaluate, ma-
nipulate, solve, or plot with a few keystrokes or mouse clicks.
Using either mode, you can create high quality interactive mathematical
presentations or documents.
In This Manual
This manual provides an overview of all Maple features including:
• Performing computations
• Creating plots and animations
• Creating interactive documents
• The Maple programming language
• Using and creating custom Maplet applications
Preface • xv
• File input and output, and using Maple with third party products
• Data structures
For a complete list of manuals, study guides, toolboxes, and other resources,
visit the Maplesoft Web site at http://www.maplesoft.com.
Audience
The information in this manual is intended for Maple users who have read
the Maple Getting Started Guide.
Conventions
This manual uses the following typographical conventions.
• bold font - Maple command, package name, option name, dialog, menu,
and text field
• italics - new or important concept
• Note - additional information relevant to the section
• Important - information that must be read and followed
Customer Feedback
Maplesoft welcomes your feedback. For suggestions and comments related
to this and other manuals, contact [email protected]
xvi • Preface
1 Document Mode
Using the Maple software, you can create powerful interactive documents.
You can visualize and animate problems in two and three dimensions. You
can solve complex problems with simple point-and-click interfaces or easy-
to-modify interactive documents. You can also devise custom solutions using
the Maple programming language. While you work, you can document your
process, providing text descriptions.
1.1 Introduction
Maple has two modes: Document mode and Worksheet mode.
Using Document mode, you can quickly perform calculations. You can enter
a mathematical expression, and then evaluate, manipulate, solve, or plot it
with a few keystrokes or mouse clicks. This chapter provides an overview
of Document mode.
1
2 • 1 Document Mode
ing the information in this chapter, see Chapter 2, Worksheet Mode (page 35),
for information on using Worksheet mode.
>
(1.1)
>
(1.2)
>
>
Important: In every Maple document, you can use Document mode and
Worksheet mode.
Note: This chapter was created using Document mode. All other chapters
were created using Worksheet mode.
Section Topics
Evaluating Expressions - How to evaluate • Displaying the Value Inline
expressions • Displaying the Value on the Following
Line
To switch between Text and Math modes, press the F5 key. (Alternatively,
click the Text mode or Math mode toolbar icon.) Consequently, it is easy
to enter sentences containing text and inline mathematical expressions.
1.3 Simple Mathematical Expressions • 5
Powers
To enter a power:
Products
To enter a product:
Implied Multiplication
Note: In some cases, you do not need to enter the multiplication operator or
a space character. For example, Maple interprets a number followed by a
variable as multiplication.
Exponent ^ (caret)
Subscript _ (underscore)
For a complete list of shortcut keys, refer to the Math Shortcut and Hints
help page. To access this help page in the Maple software, in Math mode
enter ?MathShortcuts and then press Enter. For information on the Maple
Help System, see Getting Help (page 32).
Other Expressions
It is also easy to enter mathematical expressions, such as:
• Piecewise-continuous functions:
• Limits:
• Continued fractions:
To the right of the expression, Maple inserts an equal sign and then the value
of the expression.
You can replace the inserted equal sign with text or mathematical content.
For example, you can replace the equal sign with the text "is equal to".
is equal to
By default, Maple labels output that is generated by pressing Enter. For in-
formation on equation labels, see Equation Labels (page 59). In this manual,
labels are generally not displayed.
1.5 Editing Expressions and Updating Output • 9
You can use the basic algebraic operators, such as and , with most
expressions, including polynomials—see Polynomial Algebra (page 126)—and
matrices and vectors—see Linear Algebra (page 135).
• Operators: , , , /, , , , , ...
• Constants: π, e, ...
• Mathematical functions: sin(x), , Γ(2), ...
• Names (variables): x, y, z, α, β, ...
• Data structures: sets, lists, Arrays, Vectors, Matrices, ...
Maple contains over a thousand symbols. For some numbers, operators, and
names, you can press the corresponding key, for example, 9, =, >, or x. Most
symbols are not available on the keyboard, but you can insert them easily
using two methods.
• Palettes
• Symbol names
Palettes
Palettes are collections of related items that you can insert by clicking or
dragging. Palettes contain:
• Numbers and constants, like i (the imaginary unit), π, and ∞. For example,
see the Common Symbols palette (Figure 1.1).
1.6 Entering Expressions • 11
• Layouts, like an item with a superscript and subscript. For example, see
the Layout palette (Figure 1.2).
• Mathematical operations, like a definite integral with placeholders for
the integrand, variable of integration, and endpoints of the interval of
integration. For example, see the Expression palette (Figure 1.3).
• Specialized tools. For example, see the Matrix palette (Figure 1.4). For
information on the Matrix palette, see Creating Matrices (page 135).
Using Palettes
To insert a palette item:
1. In the palette, click the item to insert. The item is inserted at the cursor
location.
Note: You can drag palette items to any location in the document.
or
• From the Common Symbols palette, drag the π symbol to the appropriate
location in the document.
5. Enter x.
1. In the Expression palette, click one of the function definition items (Figure
1.5). Maple inserts the function definition.
4. Replace the final placeholder, y, with the expression that defines the
function value. Press Enter.
Note: To insert the right arrow symbol , you can also enter the characters
->.
• From the View menu, select Palettes, and then Expand Docks.
• Drag the palette (by clicking its title) to the new location.
To add a palette:
2. From the context menu, select Show Palette, and then select the palette.
Symbol Names
Each symbol has a name, and some have aliases. By entering its name (or
an alias) in Math mode, you can insert the symbol.
Note: If you hover the mouse pointer over a palette item, a tooltip displays
the symbol's name.
1.6 Entering Expressions • 17
1. Enter sqrt.
2. Press the completion shortcut key. Maple displays a pop-up list of exact
matches .
3. In the completion list, select . Maple inserts the symbol with the
placeholder selected.
4. Enter 603729.
=
18 • 1 Document Mode
For example, if you enter i and then press the completion shortcut key, Maple
displays:
• Use the symbol name and completion list to enter the imaginary unit,
.
3. Enter sin(x).
6. Enter x.
Note: From the int completion list, you can directly insert .
• Palettes
• Context menus
• Assistants and tutors
Note: The Document mode is designed for quick calculations, but it also
supports Maple commands. For information on commands, see Com-
mands (page 40) in Chapter 2, Worksheet Mode (page 35).
3. To execute the operation and display the result, press Ctrl+= (Com-
mand+=, for Macintosh) or Enter.
1. Using the Expression palette, enter the definite integral. See Table
1.2 (page 12).
Context Menus
A context menu is a pop-up menu that lists the operations and actions you
can perform on a particular expression. See Figure 1.7.
1.7 Performing Computations • 21
• The Evaluate and Display Inline operation (see Figure 1.7) is equivalent
to pressing Ctrl+= (Command+=, for Macintosh). That is, it inserts an
equal sign (=) and then the value of the expression.
• The Evaluate operation (see Figure 1.7) is equivalent to pressing Enter.
That is, it evaluates the expression and displays the result centered on
the following line.
From the context menu, you can also select operations different from evalu-
ation. To the right of the expression, Maple inserts a right arrow symbol (→)
and then the result.
22 • 1 Document Mode
1. Enter a fraction.
3. From the context menu, select Approximate, and then the number of
significant digits to use: 5, 10, 20, 50, or 100.
1.7 Performing Computations • 23
You can replace the inserted right arrow with text or mathematical content.
Note: To replace the the right arrow with text, you must first press F5 to
switch to Text mode.
For example, you can replace the arrow with the text "is approximately equal
to" or the symbol ≈.
is approximately equal to
24 • 1 Document Mode
Solving an Equation
You can find an exact (symbolic) solution or an approximate (numeric)
solution of an equation. For more information on symbolic and numeric
computations, see Symbolic and Numeric Computation (page 66).
To solve an equation:
1. Enter an equation.
Using Units
You can create expressions with units. To specify a unit for an expression,
use the Units palettes. The Units (FPS) palette (Figure 1.9) contains import-
ant units from the foot-pound-second (FPS) system of units used in the United
States. The Units (SI) palette (Figure 1.10) contains important units from
the international system (SI) of units.
1.7 Performing Computations • 25
For example, compute the electric current passing through a wire that con-
ducts 590 coulombs in 2.9 seconds.
Assistants
Assistants help you accomplish many tasks, such as solving ordinary differ-
ential equations (ODEs) and ODE systems, creating plots and matrices, curve
fitting, and performing unit conversions (Figure 1.11).
• From the Tools menu, select Assistants, and then one of the topic sub-
menus.
For example:
1. From the Tools menu, select Unit Converter. The Unit Converter dialog
displays. See Figure 1.11.
2. In the Value text field, enter the value as measured in atomic mass units,
1.0.
6. Click the Insert button. Maple inserts the value of the mass in grams,
, in the document. Note: The output has no units.
1.7 Performing Computations • 27
Tutors
Over 40 interactive tutors help student users gain insight and understanding
of topics in courses such as precalculus, calculus, multivariate calculus,
vector calculus, and linear algebra. Some tutors help you work through a
problem step-by-step.
• From the Tools menu, select Tutors, and then one of the topic submenus.
For example, you can create a plot of the compositions of two functions using
the Function Composition Tutor.
1. From the Tools menu, select Tutors, Precalculus, and then Compositions.
The Function Composition Tutor is displayed. See Figure 1.12.
2. In the f(x) = and g(x) = text fields, enter the two functions.
3. Click the Display button. The tutor displays the compositions g(f(x)) and
f(g(x)).
4. To insert the plot into your document, click the Close button.
28 • 1 Document Mode
The Plot Builder can be launched from the Tools menu or the context menu
for an expression.
3. From the context menu, select Plots, and then Plot Builder. The Interact-
ive Plot Builder is displayed. See Figure 1.13.
4. In the Select Plot Type dialog, select the plot type, for example, 3-D plot
or 2-D contour plot.
5. To immediately create a plot, click the Plot button. To customize the plot
before generating it, click the Options button.
For more information on plots, see Plots and Animations (page 189).
*
Inline evaluation is available in Document mode and document blocks. For information
on document blocks, see Document Blocks (page 247).
Resource Description
Help Pages Help for Maple features, commands, packages, and more. Help
pages include examples and screenshots to help you quickly
learn.
• From the Help menu, select Maple Help. You can search
for a help topic, perform a text search, or browse the Table
of Contents. You can also open a help page by entering
?<topic_name> at the input prompt (in Worksheet mode)
or in Math mode (in Document mode).
Task Templates Set of commands with placeholders that you can use to quickly
perform a task.
• From the Tools menu, select Tasks, and then Browse.
Applications and Example Executable documents that demonstrate the power and flexib-
Worksheets ility of the Maple interactive document or provide an overview
of computations in a particular field.
• From the Help menu, select Manuals, Dictionary, and
more, and then Applications and Examples.
Mathematics and Engineer- Over 5000 definitions, including 300 figures and plots.
ing Dictionary • From the Help menu, select Manuals, Dictionary, and
more, and then Dictionary.
For more information on the Maple Help System, refer to the Maple Getting
Started Guide.
34 • 1 Document Mode
2 Worksheet Mode
The Worksheet mode of the Standard Worksheet interface is designed for:
Using Worksheet mode, you have access to most of the Maple features de-
scribed in Chapter 1 including:
For information on these features, see Chapter 1, Document Mode (page 1).
(For a summary, see Table 1.4 (page 30).)
Note: Using a document block, you can use all Document mode features in
Worksheet mode. For information on document blocks, see Document
Blocks (page 247).
Note: This chapter and the following chapters were created using Worksheet
mode.
35
36 • 2 Worksheet Mode
Section Topics
Equation Labels - Automatically generated • Displaying Equation Labels
labels that you can use to refer to expressions • Referring to a Previous Result
• Execution Groups with Multiple Outputs
• Label Numbering Schemes
• Features of Equation Labels
To evaluate input:
• Press Enter.
For example, to find the value of , enter the expression, and then
press Enter.
>
>
38 • 2 Worksheet Mode
Suppressing Output
To suppress the output, enter a colon (:) at the end of the input.
>
A set of Maple input and its output are referred to as an execution group.
• At the input prompt, press F5 to switch from 2-D Math to 1-D Math.
> 123^2 - 29857/120;
Important: 1-D Math input must end with a semicolon or colon. If you use
a semicolon, Maple displays the output. If you use a colon, Maple suppresses
the output.
> 123^2 - 29857/120:
1. From the Tools menu, select Options. The Options dialog is displayed.
2.2 Input Prompt • 39
2. On the Display tab, in the Input display drop-down list, select Maple
Notation.
3. Click Apply to Session (to set for only the current session) or Apply
Globally (to set for all Maple sessions).
2. From the Format menu, select Convert To, and then 1-D Math Input.
Input Separators
In 1-D and 2-D Math input, you can use a semicolon or colon to separate
multiple inputs in the same input line.
>
>
40 • 2 Worksheet Mode
2.3 Commands
Maple contains a large set of commands and a powerful programming lan-
guage. Most Maple commands are written using the Maple programming
language.
You can enter commands using 1-D or 2-D Math. You must use 1-D Math
input when programming in Maple. Basic Programming (page 321) provides
an introduction to Maple programming.
To learn how to use Maple commands, use task templates. See Task Tem-
plates (page 51).
• The top-level commands are the most frequently used Maple commands.
• Packages contain related specialized commands in areas such as student
calculus, linear algebra, vector calculus, and code generation.
For a complete list of packages and commands, refer to the index help pages.
To access the index overview help page, enter ?index, and then press Enter.
For information on the Maple Help System, see Getting Help (page 32).
Top-Level Commands
To use a top-level command, enter its name followed by parentheses (( ))
containing any parameters. This is referred to as a calling sequence for the
command.
command(arguments)
Note: In 1-D Math input, include a semicolon or colon at the end of the
calling sequence.
2.3 Commands • 41
For example, to differentiate an expression, use the diff command. The re-
quired parameters are the expression to differentiate, which must be specified
first, and the independent variable.
>
>
>
For detailed information on how to use a function in Maple, refer to its help
page.
For example:
>
Note: In 1-D and 2-D Math input, when accessing a help page using ?, you
do not need to include a trailing semicolon or colon.
42 • 2 Worksheet Mode
Package Commands
To use a package command, the calling sequence must include the package
name, and the command name enclosed in brackets ([ ]).
package[command](arguments)
If you are frequently using the commands in a package, load the package.
To load a package:
The with command returns a list of the package commands loaded (unless
you suppress the output by entering a colon at the end of the calling se-
quence).
After loading a package, you can use its commands as top-level commands,
that is, without specifying the package name.
For example, use the NLPSolve command from the Optimization package
to find a local minimum of an expression and the value of the independent
variable at which the minimum occurs.
>
>
>
To unload a package:
>
To use the examples in this manual, you may be required to use the unwith
command between examples.
Some packages contain commands that have the same name as a top-level
command. When you load one of these packages, Maple returns a warning.
>
Warning, the name changecoords has been redefined
In general, this manual does not include the warning messages Maple returns.
To use the top-level command, unload the package. (For alternative methods
of accessing the top-level command, refer the ?with help page.)
44 • 2 Worksheet Mode
2.4 Palettes
Palettes are collections of related items that you can insert by clicking or
dragging. See Figure 2.1.
For example, evaluate a definite integral using the definite integration item
>
>
In 1-D Math, clicking the definite integration item inserts the corresponding
command calling sequence.
> int(f,x=a..b);
Specify the problem values (using the Tab to move to the next placeholder),
and then press Enter.
> int(tanh(x), x = 0..1):
Note: Some palette items cannot be inserted into 1-D Math because they are
not defined in the Maple language. When the cursor is in 1-D Math input,
unavailable palette items are dimmed.
For more information on palettes, see Palettes (page 10) and Performing
Computations (page 19) in Chapter 1.
46 • 2 Worksheet Mode
For example:
>
(2.1)
>
For information on equation labels and equation label references, see Equa-
tion Labels (page 59).
For more information on context menus, see Context Menus (page 20) in
Chapter 1.
48 • 2 Worksheet Mode
1. From the Tools menu, select Assistants, and then Plot Builder. Maple
inserts the following command in the document and launches the Interactive
Plot Builder.
>
6. In the Interactive Plot Builder: Select Plot Type dialog (Figure 2.3),
select the type of plot, for example, 3-D Plot or 3-D Contour Plot, and
specify the variable ranges, for example, .
For more information on assistants and tutors, see Assistants and Tu-
tors (page 26) in Chapter 1.
You can also browse the task templates in the Table of Contents of the Maple
Help System.
• Click the Insert Default Content button. Maple inserts the default con-
tent. The default content level is set using the Options dialog. For details,
see the following steps.
• Click the Insert Minimal Content button. Maple inserts only the com-
mands and embedded components, for example, a button to launch the
related assistant or tutor.
• Click the Copy Task to Clipboard button. Place the cursor where you
want to insert the task, and then paste the task. Maple inserts the default
content. Use this method to quickly insert a task multiple times.
1. From the Tools menu, select Options. The Options dialog opens.
3. In the Task content to insert drop-down list, select All Content, Standard
Content, or Minimal Content.
• From the Tools menu, select Tasks, and then the task name.
• Placing the cursor in the first task command, and then pressing Enter
repeatedly to execute each command.
• Selecting all the template commands, and then clicking the execute
toolbar icon .
3. If the template contains a button that computes the result, click it.
For more information on task templates, refer to the Maple Getting Started
Guide or the ?tasks help page.
• Character styles
• Paragraph styles
• Sections and subsections
• Tables
2.9 Names
Instead of re-entering an expression every time you need it, you can assign
it to a name or add an equation label to it. Then you can quickly refer to the
expression using the name or an equation label reference. For information
on labels, see the following section Equation Labels (page 59).
Assigning to Names
You can assign any Maple expression to a name: numeric values, data
structures, procedures (a type of Maple program), and other Maple objects.
>
>
56 • 2 Worksheet Mode
Recall that you can enter using the following two methods.
>
Mathematical Functions
To define a function, assign it to a name.
For example, define a function that computes the cube of its argument.
>
>
Note: To insert the right arrow, enter the characters ->. In 2-D Math, Maple
replaces -> with the right arrow symbol . In 1-D Math, the characters
are not replaced.
2.9 Names • 57
> square(32);
Protected Names
Protected names are valid names that are predefined or reserved.
>
Error, attempting to assign to `sin` which is protected
For more information, refer to the ?type/protected and ?protect help pages.
Unassigning Names
The unassign command resets the value of a name to itself. Note: You must
enclose the name in right single quotes ('').
>
>
Note: To use the examples in this manual, you may be required to use the
unassign or restart command between examples.
Valid Names
A Maple name must be one of the following.
• a
• a1
• polynomial
• polynomial1_divided_by_polynomial2
• `2a`
• `x#y`
• `x y`
2.10 Equation Labels • 59
>
(2.2)
Using equation labels, you can refer to the result in other computations.
>
(2.3)
• From the Format menu, select Labels, and then ensure that Worksheet
is selected.
• In the Options dialog (Tools>Options), on the Display tab, ensure that
Show equation labels is selected.
• From the Insert menu, select Label. (Alternatively, press Ctrl+L. For
Macintosh, Command+L.)
• In the Insert Label dialog, enter the label value, and then click OK.
For example:
4. Press *.
>
2.10 Equation Labels • 61
>
(2.4)
>
• From the Format menu, select Labels, and then Label Display. In the
Format Labels dialog (Figure 2.7), select one of the formats.
• Optionally, enter a prefix.
62 • 2 Worksheet Mode
using Worksheet mode. Except where noted, all features are available in
both Worksheet mode and Document mode.
64 • 2 Worksheet Mode
3 Performing Computations
This chapter discusses key concepts related to performing computations with
Maple. It discusses important features that are relevant to all Maple users.
After learning about these concepts, you will learn how to use Maple to solve
problems in specific areas in the following chapter.
65
66 • 3 Performing Computations
Section Topics
Units, Scientific Constants, and Uncertainty Units
- How to construct and compute with expres- • Conversions
sions that have units, scientific constants, or
uncertainty • Applying Units to an Expression
• Performing Computations with Units
• Changing the Current System of Units
• Extensibility
Scientific Constants
• Scientific Constants
• Element and Isotope Properties
• Value, Units, and Uncertainty
• Performing Computations
• Modification and Extensibility
Uncertainty Propagation
• Quantities with Uncertainty
• Performing Computations with Quantities
with Uncertainty
Exact Computations
In Maple, integers, rational numbers, mathematical constants such as π and
∞, and mathematical structures such as matrices with these as entries are
treated as exact quantities. Names, such as , , , and
mathematical functions, such as sin(x) and LambertW(k, z), are symbolic
objects. Names can be assigned exact quantities as their values, and functions
can be evaluated at symbolic or exact arguments.
>
>
>
>
Floating-Point Computations
In some situations, a numeric approximation of an exact quantity is required.
For example, the plot command requires the expression it is plotting to
evaluate to numeric values that can be rendered on the screen: π cannot be
so rendered, but can be. Maple distinguishes approximate from
exact quantities by the presence or absence of a decimal point: 9 is ap-
>
3.2 Symbolic and Numeric Computation • 69
>
>
• Locally, you can pass the precision as an index to the evalf call.
>
• Globally, you can set the value of the Digits environment variable.
>
70 • 3 Performing Computations
>
For more information, see the ?evalf and ?Digits help pages.
Note: When appropriate, Maple performs floating-point computations directly
using your computer's underlying hardware.
Sources of Error
By its nature, floating-point computation normally involves some error.
Controlling the effect of this error is the subject of active research in Numer-
ical Analysis. Some sources of error are:
>
No correct digits remain. If, however, you use Maple to analyze this expres-
sion, and replace this form with a representation that is more accurate for
small values of , a fully accurate 10-digit result can be obtained.
>
3.3 Integer Operations • 71
>
You can quickly perform many integer operations using context menus. Se-
lecting an integer, and then right-clicking (for Macintosh, Control-clicking)
displays a context menu with integer commands, for example, Integer
Factors, which applies the ifactor command. See Figure 3.1.
72 • 3 Performing Computations
>
(3.1)
>
For more information on equation labels, see Equation Labels (page 59).
You can also enter the ifactor command and specify the integer to factor as
an argument.
>
Maple has many other integer commands, including those listed in Table
3.1.
ifactor factorization
igcd greatest common divisor
iquo quotient of integer division
irem remainder of integer division
iroot integer approximation of nth root
isprime test primality
isqrt integer approximation of square root
max, min maximum and minimum of a set
mod modular arithmetic (See Finite Rings and
Fields (page 75)
numtheory[divisors] set of positive divisors
>
74 • 3 Performing Computations
>
>
>
• Non-base 10 numbers
• Finite ring and field arithmetic
• Gaussian integers
Non-Base 10 Numbers
To represent an expression in another base, use the convert command.
>
>
3.3 Integer Operations • 75
>
>
>
>
Subtraction - >
/
Division (displays in 2-D Math as ) >
1
To enter a caret (^) in 2-D Math, enter a backslash character followed by a caret, that is,
\^.
The mod operator also supports polynomial and matrix arithmetic over finite
rings and fields. For more information, refer to the ?mod help page.
3.3 Integer Operations • 77
Gaussian Integers
Gaussian integers are complex numbers in which the real and imaginary
parts are integers.
>
You can enter the imaginary unit using the following two methods.
Note: In 1-D Math input, enter the imaginary unit as an uppercase i (I).
The GIsqrt command approximates the square root in the Gaussian integers.
>
2. From the context menu, select Solve (or Solve Numerically). See Figure
3.2.
3.4 Solving Equations • 79
In Worksheet mode, Maple inserts a calling sequence that solves the equation
followed by the solutions.
>
(3.2)
>
>
(3.3)
>
>
It is recommended that you verify the solutions returned by the solve com-
mand. For details, see Working with Solutions (page 86).
>
3.4 Solving Equations • 81
>
>
>
>
82 • 3 Performing Computations
>
>
>
>
>
RootOf Structure The solve command may return solutions, for example,
to higher order polynomial equations, in an implicit form using RootOf
structures.
>
(3.4)
These RootOf structures are placeholders for the roots of the equation
. The index parameter numbers and orders the four
solutions.
>
For more information on the solve command, including how to solve equa-
tions defined as procedures and how to find parametric solutions, refer to
the ?solve/details help page.
84 • 3 Performing Computations
>
>
(3.5)
Note: You can also numerically solve equations using the context menus.
See Solving Equations and Inequations (page 78).
It is recommended that you verify the solutions returned by the fsolve com-
mand. For details, see Working with Solutions (page 86).
>
>
>
3.4 Solving Equations • 85
>
>
>
If the fsolve command does not find any solutions, it is recommended that
you specify a range in which to search for solutions, or specify an initial
value.
Range To search for a solution in a range, specify the range in the calling
sequence. The range can be real or complex.
>
>
86 • 3 Performing Computations
Initial Values You can specify a value for each unknown. The fsolve com-
mand uses these as initial values for the unknowns in the numerical method.
>
(3.6)
For more information and examples, refer to the ?fsolve/details help page.
>
>
(3.7)
>
>
>
3.4 Solving Equations • 87
(3.8)
>
For more information, see Substituting a Value for a Subexpression (page 310).
>
>
>
>
88 • 3 Performing Computations
>
>
>
For more information on defining and using functions, see Functional Oper-
ators (page 292).
• Recurrence relations
• From the Tools menu, select Assistants, and then ODE Analyzer.
In the main ODE Analyzer Assistant window, you can define ODEs, initial
or boundary value conditions, and parameters. To define derivatives, use the
4. In the Solve Numerically window (Figure 3.4), you can specify the nu-
meric method and relevant parameters and error tolerances to use for solving
the problem.
2. In the Solve Symbolically window (Figure 3.5), you can specify the
method and relevant method-specific options to use for solving the problem.
When solving numerically or symbolically, you can view a plot of the solution
by clicking the Plot button.
You can control the return value of the ODE Analyzer using the On Quit,
Return drop-down list. You can select to return nothing, the displayed plot,
the computed numeric procedure (for numeric solutions), the solution (for
symbolic solutions), or the Maple commands needed to produce the solution
values and the displayed plot.
To access all available functionality, use the dsolve command directly. For
more information, refer to the ?dsolve help page.
>
94 • 3 Performing Computations
(3.9)
>
Maple generally prints only the return value, errors, and warnings during a
computation. To print information about the techniques Maple uses, increase
the infolevel setting for the command.
>
>
Checking arguments ...
Getting info and details about the PDE ... First set of solution methods (general
or quase general solution) Second set of solution methods (complete solutions)
Trying methods for first order PDEs HINT = strip Trying characteristic strip
method ... characteristic strip method successful. Second set of solution methods
successful
Integer Equations
To find only integer solutions to an equation, use the isolve command. The
isolve command finds solutions for all variables. For more information, refer
to the ?isolve help page.
3.4 Solving Equations • 95
>
>
For example, construct an augmented matrix using the Matrix palette (see
Creating Matrices and Vectors (page 135)) in which the first four columns
contain the entries of A and the final column contains the entries of B.
>
>
96 • 3 Performing Computations
For more information on using Maple to solve linear algebra problems, see
Linear Algebra (page 135).
>
Maple supports hundreds of units, for example, miles, coulombs, and bars,
and provides facilities for adding custom units.
3.5 Units, Scientific Constants, and Uncertainty • 97
Units
The Units package in Maple provides a library of units, and facilities for
using units in computations. It is fully extensible so that you can add units
as required.
Overview of Units
A dimension is a measurable quantity, for example, length or force. The set
of dimensions that are fundamental and independent are known as base di-
mensions.
In Maple, the base dimensions include length, mass, time, electric current,
thermodynamic temperature, amount of substance, luminous intensity, in-
formation, and currency. For a complete list, run Units[GetDimensions]().
of .
Each dimension, base or complex, has associated units. (Base units measure
a base dimension. Complex units measure a complex dimension.) Maple
supports over forty units of length, including feet, miles, meters, angstroms,
microns, and astronomical units. A length must be measured in terms of a
unit, for example, a length of 2 parsecs.
Table 3.4 lists some dimensions, their corresponding base dimensions, and
example units.
98 • 3 Performing Computations
For the complete list of units (and their contexts and symbols) available for
a dimension, refer to the corresponding help page, for example, the
?Units/length help page for the units of length.
Each unit has a context. The context differentiates between different defini-
tions of the unit. For example, the standard and US survey miles are different
units of length, and the second is a unit of time and of angle. You can specify
the context for a unit by appending the context as an index to the unit, for
example, mile[US_survey]. If you do not specify a context, Maple uses the
default context.
Units are collected into systems, for example, the foot-pound-second (FPS)
system and international system, or système international, (SI). Each system
has a default set of units used for measurements. In the FPS system, the foot,
pound, and second are used to measure the dimensions of length, mass, and
time. The unit of speed is the foot/second. In SI, the meter, kilogram, and
second are used to measure the dimensions of length, mass, and time. The
units of speed, magnetic flux, and power are the meter/second, weber, and
watt.
Conversions
To convert a value measured in a unit to the corresponding value in a different
unit, use the Unit Converter.
• From the Tools menu, select Assistants, and then Unit Converter.
3.5 Units, Scientific Constants, and Uncertainty • 99
To perform a conversion:
3. From the From and To menus, select the original unit and the unit to
which to convert.
4. Click Insert.
>
Important: Using the Unit Converter, you can convert temperatures and
temperature changes.
>
>
Figure 3.7: Units (FPS) Palette Figure 3.8: Units (SI) Palette
To insert a unit:
>
For example, to enter standard (the default context) miles, you can
specify the unit name, mile, or symbol, mi.
>
102 • 3 Performing Computations
Important: In 1-D Math input, the quantity and unit (entered using the top-
level Unit command) are a product, not a single entity. The following calling
sequences define different expressions.
> 1*Unit(m)/(2*Unit(s)); > 1*Unit(m)/2*Unit(s);
Some units support prefixes. For example, SI units support prefixes to names
and symbols. You can specify 1000 meters using kilometer or km. For more
information, refer to the ?Units/prefixes help page.
>
To compute with expressions that have units, you must load a Units envir-
onment, Natural or Standard. It is recommended that you use the Standard
environment.
>
>
>
(3.10)
>
(3.11)
>
>
(3.12)
>
To view the name of the default system of units, use the Units[UsingSystem]
command.
>
>
>
>
Extensibility
You can extend the set of:
For more information about units, refer to the ?Units help page.
3.5 Units, Scientific Constants, and Uncertainty • 105
• Physical constants
• Chemical element (and isotope) properties
Scientific Constants
Maple contains many built-in scientific constants, which you can easily in-
clude in your computations.
>
>
Element Properties
Maple also contains element properties and isotope properties.
Elements
Maple supports the first 112 elements of the periodic table, plus elements
number 114 and 116. Each element has a unique name, atomic number, and
chemical symbol. You can specify an element using any of these labels. For
a complete list of supported elements, refer to the ?ScientificConstants/ele-
ments help page.
Isotopes
Isotopes, variant forms of an element that contain the same number of protons
but a different number of neutrons, exist for many elements.
To see the list of supported isotopes for an element, use the GetIsotopes
command.
>
Maple supports isotopes and has a distinct set of properties for isotopes, in-
cluding abundance, binding energy (bindingenergy), and mass excess
(massexcess). For a complete list of isotope properties, refer to the ?Scien-
tificConstants/properties help page.
>
>
>
3.5 Units, Scientific Constants, and Uncertainty • 109
>
Value
To obtain the value of a ScientificConstants object, use the evalf command.
>
>
Note: The value returned depends on the current system of units. For inform-
ation on controlling the system of units, see Changing the Current System
of Units (page 103).
Units
To obtain the units for a ScientificConstants object, use the GetUnit com-
mand.
>
>
110 • 3 Performing Computations
For information on changing the default system of units, for example, from
SI to foot-pound-second, see Changing the Current System of Units (page 103).
>
>
Uncertainty
The value of a constant is often determined by direct measurement or derived
from measured values. Hence, it has an associated uncertainty. To obtain
the uncertainty in the value of a ScientificConstants object, use the GetError
command.
>
>
3.5 Units, Scientific Constants, and Uncertainty • 111
Performing Computations
You can use constant values in any computation. To use constant values
with units, use a Units environment as described in Performing Computations
with Units (page 102). For information on computing with quantities that
have an uncertainty, see the following section.
• Constants
• Elements (and isotopes)
• Element (or isotope) properties
Uncertainty Propagation
Some computations involve uncertainties (or errors). Using the ScientificEr-
rorAnalysis package, you can propagate the uncertainty in these values
through the computation to indicate the possible error in the final result.
quantities represent unknown values with a central tendency. For more in-
formation on central tendency, refer to any text on error analysis for the
physical sciences or engineering.
>
>
>
(3.13)
To specify the error in units of the last digit, the value must be of floating-
point type.
>
To access the value and uncertainty of a quantity with uncertainty, use the
evalf and ScientificErrorAnalysis[GetError] commands.
>
3.5 Units, Scientific Constants, and Uncertainty • 113
>
Rounding To round the error of a quantity with uncertainty, use the ApplyR-
ule command. For a description of the predefined rounding rules, refer to
the ?ScientificErrorAnalysis/rules help page.
>
Units Quantities with errors can have units. For example, the scientific
constants and element (and isotope) properties in the ScientificConstants
packages are quantities with errors and units.
For an absolute error, you must specify the units in both the value and error.
>
>
For a relative error, you can specify the units in only the value.
>
114 • 3 Performing Computations
>
>
>
>
To convert the solution to a single quantity with uncertainty, use the com-
bine/errors command.
>
>
>
3.6 Restricting the Domain • 115
Additional Information
For information on topics including:
Maple has facilities for performing computations in the real number system
and for applying assumptions to variables.
After you load the RealDomain package, Maple assumes that all variables
are real. Commands return simplified results appropriate to the field of real
numbers.
>
>
>
Some commands that generally return NULL instead return a numeric result
when you use the RealDomain package.
>
>
>
3.6 Restricting the Domain • 117
Assumptions on Variables
To simplify problem solving, it is recommended that you always apply any
known assumptions to variables. You can impose assumptions using the
assume command. To apply assumptions for a single computation, use the
assuming command.
Note: The assume and assuming commands are not supported by the
RealDomain package.
To assume that x is a positive real number, use the following calling sequence.
Then compute the square root of .
>
The trailing tilde (~) on the name x indicates that it carries assumptions.
When you use the assume command to place another assumption on x, all
previous assumptions are removed.
>
118 • 3 Performing Computations
>
Originally x, renamed x~: is assumed to be: RealRange(-infinity,Open(0))
>
>
Originally x, renamed x~: is assumed to be: 1
>
The following test returns false because there are values of x and y (x = 0,
y = 10) that satisfy the assumptions, but do not satisfy the relation in the is
calling sequence.
>
3.6 Restricting the Domain • 119
>
>
For more information on the assume command, refer to the ?assume help
page.
>
>
x: nothing known about this object
>
>
>
>
The assuming command does not affect variables inside procedures. (For
information on procedures, see Procedures (page 338).) You must use the
assume command.
> f := proc(x) sqrt(a^2) + x end proc;
>
3.6 Restricting the Domain • 121
>
123
124 • 4 Mathematical Computations
Resource Description
Maple Help System Over 5000 help pages and example worksheets with an in-
tegrated search engine.
• From the Help menu, select Maple Help.
Package index help page A complete list of the over 100 Maple packages, which
contain thousands of commands.
• From the Help menu, select Manuals, Dictionary, and
more, and then List of Packages.
Command index help page A complete list of the over 600 top-level Maple commands.
• From the Help menu, select Manuals, Dictionary, and
more, and then List of Commands.
Maplesoft Web site Maple Application Center - Free documents and point-and-
(http://www.maplesoft.com) click Maplet applications for mathematics, engineering,
finance, and science.
• Visit http://www.maplesoft.com/applications
Toolboxes - Add-on products from Maplesoft, for example,
the Global Optimization Toolbox.
• Visit http://www.maplesoft.com/products/toolboxes
Third-Party Products - Add-on products developed by the
Maple user community for specialized computation.
• Visit http://www.maplesoft.com/products/thirdparty
For instructor and student resources, see Table 4.10 (page 180).
Teaching and Learning with Maple - Student • Table of Student and Instructor Resources
and Instructor resources for using Maple in • Student Packages and Tutors
an academic setting
126 • 4 Mathematical Computations
4.2 Algebra
Maple contains a variety of commands that perform integer operations, such
as factoring and modular arithmetic, as described in Integer Opera-
tions (page 71). In addition, it supports polynomial algebra.
For information on matrix and vector algebra, see Linear Algebra (page 135).
Polynomial Algebra
A Maple polynomial is an expression in powers of an unknown. Univariate
polynomials are polynomials in one unknown, for example, .
Multivariate polynomials are polynomials in multiple unknowns, such as
x.
>
Arithmetic
The polynomial arithmetic operators are the standard Maple arithmetic oper-
ators excluding the division operator (/). (The division operator accepts
polynomial arguments, but does not perform polynomial division.)
Subtraction >
Multiplication1 * >
>
Exponentiation2 ^ >
1
You can specify multiplication explicitly by entering *, which displays in 2-D Math as
. In 2-D Math, you can also implicitly multiply by placing a space character between
two expressions. In some cases, the space character is optional. For example, Maple inter-
prets a number followed by a name as an implicit multiplication.
2
In 2-D Math, exponents display as superscripts.
128 • 4 Mathematical Computations
>
>
>
>
For information on polynomial arithmetic over finite rings and fields, refer
to the ?mod help page.
4.2 Algebra • 129
Sorting Terms
To sort the terms of a polynomial, use the sort command.
>
>
Note: The sort command returns the sorted polynomial, and updates the
order of the terms in the polynomial.
>
To specify the unknowns of the polynomial and their ordering, include a list
of names.
>
>
>
>
The first term has total degree 4. The other two terms have total degree 3.
The order of the final two terms is determined by the order of their names
in the list.
To sort the terms by pure lexicographic order, that is, first by decreasing
order of the first unknown in the list option, and then by decreasing order of
the next unknown in the list option, specify the 'plex' option.
>
The first term has a power of to the 3. The second, a power of to the
2. The third, a power of to the 0.
Using context menus, you can perform operations, such as sorting, for
polynomials and many other Maple objects.
To sort a polynomial:
In Worksheet mode, Maple inserts the calling sequence that performs the
sort followed by the sorted polynomial.
>
>
132 • 4 Mathematical Computations
You can use context menus to perform operations on 2-D Math content in-
cluding output. For more information, see Context Menus (page 20) (for
Document mode) or Context Menus (page 46) (for Worksheet mode).
Collecting Terms
To collect the terms of polynomial, use the collect command.
>
Factorization
To express a polynomial in fully factored form, use the factor command.
>
The factor command factors the polynomial over the ring implied by the
coefficients, for example, integers. You can specify an algebraic number
field over which to factor the polynomial. For more information, refer to the
?factor help page. (The ifactor command factors an integer. For more in-
formation, see Integer Operations (page 71).)
134 • 4 Mathematical Computations
To solve for the roots of a polynomial, use the solve command. For inform-
ation on the solve command, see Solving Equations and Inequa-
tions (page 78). (The isolve command solves an equation for integer solutions.
For more information, see Integer Equations (page 94).)
Other Commands
Table 4.4 lists other commands available for polynomial operations.
Command Description
sqrfree Square free factorization (multivariate polyno-
mial)
Additional Information
You can perform many linear algebra operations using task templates. In the
Task Browser (Tools>Tasks>Browse), expand the Linear Algebra folder.
Creating Matrices
To create a matrix, use the Matrix palette. See Figure 4.2.
136 • 4 Mathematical Computations
In the Matrix palette, you can specify the matrix size (see Figure 4.3) and
properties. To insert a matrix, click the Insert Matrix button.
4.3 Linear Algebra • 137
1. Enter the values of the entries. To move to the next entry placeholder,
press Tab.
>
Creating Vectors
To create a vector, use angle brackets (< >).
>
>
2. In the Type drop-down list, select a matrix type, for example, Custom
values.
>
You can view the matrix or vector as a table or as an image, which can be
inserted into the document. For more information, refer to the ?Mat-
rixBrowser help page.
4.3 Linear Algebra • 141
>
You cannot specify properties when defining vectors using the angle-
bracket notation. You must use the Vector constructor.
>
>
To create a row vector using the Vector constructor, include row as an index.
4.3 Linear Algebra • 143
>
>
The Matrix palette does not support some properties. To set all properties,
use the Matrix constructor.
• The number of rows and columns. If you explicitly specify all element
values, these arguments are not required.
• A list of lists that define the element values row-wise.
• Parameters such as shape, datatype, and fill that set properties of the
matrix.
For example:
>
The Matrix palette cannot fill the matrix with an arbitrary value. Use the
fill parameter.
>
144 • 4 Mathematical Computations
>
>
>
4.3 Linear Algebra • 145
>
>
Similarly, you can access submatrices using an index. In the following two-
dimensional matrix, the first entry selects rows and the second, columns.
>
>
Matrix Arithmetic
The matrix and vector arithmetic operators are the standard Maple arithmetic
operators up to the following two differences.
>
Subtraction >
4.3 Linear Algebra • 147
>
Exponentiation2 ^ >
>
1
You can specify scalar multiplication explicitly by entering *, which displays in 2-D
Math as . In 2-D Math, you can also implicitly multiply a scalar and a matrix or vector
by placing a space character between them. In some cases, the space character is optional.
For example, Maple interprets a number followed by a name as an implicit multiplication.
2
In 2-D Math, exponents display as superscripts.
A few additional matrix and vector operators are listed in Table 4.7.
148 • 4 Mathematical Computations
>
1
Exponential operators display in 2-D Math as superscripts.
2
After loading the LinearAlgebra package, the cross product operator is available as the
infix operator &x . Otherwise, it is available as the LinearAlgebra[CrossProduct] com-
mand.
For information on matrix arithmetic over finite rings and fields, refer to the
?mod help page.
Point-and-Click Interaction
Using context menus, you can perform many matrix and vector operations.
4.3 Linear Algebra • 149
For example, compute the infinity norm of a matrix. See Figure 4.5.
In Document mode, Maple inserts a right arrow followed by the norm. See
Figure 4.6.
150 • 4 Mathematical Computations
For more information on context menus, see Context Menus (page 20) (for
Document mode) or Context Menus (page 46) (for Worksheet mode).
Command Description
GaussianElimination Perform Gaussian elimination on a matrix
HessenbergForm Reduce a square matrix to Hessenberg form
HilbertMatrix Construct a generalized Hilbert matrix
IsOrthogonal Test if a matrix is orthogonal
LeastSquares Compute the least-squares approximation to A . x = b
LinearSolve Solve the linear system A . x = b
MatrixInverse Compute the inverse of a square matrix or pseudo-inverse of a non-
square matrix
QRDecomposition Compute a QR factorization of a matrix
RandomMatrix Construct a random matrix
SylvesterMatrix Construct the Sylvester matrix of two polynomials
Example Determine a basis for the space spanned by the set of vectors {(2,
13, -15), (7, -2, 13), (5, -4, 9)}. Express the vector (25, -4, 9) with respect to
this basis.
>
>
Find a basis for the vector space spanned by these vectors, and then construct
a matrix from the basis vectors.
>
152 • 4 Mathematical Computations
>
Numeric Computations
You can very efficiently perform computations on large matrices and vectors
that contain floating-point data using the built-in library of numeric linear
algebra routines. Some of these routines are provided by the Numerical Al-
gorithms Group (NAG®). Maple also contains portions of the CLAPACK
and optimized ATLAS libraries.
See also Creating Matrices and Vectors for Large Problems (page 141).
For information on using Maple as a teaching and learning tool, see Teaching
and Learning with Maple (page 180).
4.4 Calculus
The Task Browser (Tools>Tasks>Browse) contains numerous calculus
task templates. For a list of tasks, navigate to one of the related folders, such
as Calculus, Differential Equations, Multivariate Calculus, or Vector
Calculus.
This section describes the key Maple calculus commands, many of which
are used in task templates or available in the context menus.
Limits
To compute the limit of an expression as the independent variable ap-
proaches a value:
2. Specify the independent variable, limit point, and expression, and then
evaluate it.
154 • 4 Mathematical Computations
For example:
>
>
>
Using the limit command, you can also compute multidimensional limits.
>
Important: Use the inert Limit command, not the limit command. For more
information, refer to the ?limit help page.
The Limit command accepts the same arguments as the limit command.
For example:
>
The Limit command does not compute the limit. It returns an unevaluated
limit.
>
For more information on the Limit command, refer to the ?Limit help page.
Differentiation
Maple can perform symbolic and numeric differentiation.
156 • 4 Mathematical Computations
To differentiate an expression:
2. Specify the expression and independent variable, and then evaluate it.
>
You can also differentiate using context menus. For more information, see
Context Menus (page 20).
>
>
4.4 Calculus • 157
>
(4.1)
>
>
To calculate a partial derivative, use the same syntax. Maple assumes that
the derivatives commute.
>
For example:
>
Differentiating an Operator
You can also specify a mathematical function as a functional operator (a
mapping). For a comparison of operators and other expressions, see Distinc-
tion between Functional Operators and Other Expressions (page 293).
For example, find the derivative of an operator that represents the mathem-
atical function .
• To move to the next placeholder, press the Tab key. Note: If pressing
the Tab key inserts a tab, click the Tab icon in the toolbar.
>
>
>
For more information on the D operator, refer to the ?D help page. For a
comparison of the diff command and D operator, refer to the ?diffVersusD
help page.
Directional Derivative
To compute and plot a directional derivative, use the Directional Derivative
Tutor. The tutor computes a floating-point value for the directional derivat-
ive.
From the Tools menu, select Tutors, Calculus - Multi-Variable, and then
Directional Derivatives. Maple launches the Directional Derivative Tutor.
See Figure 4.7.
160 • 4 Mathematical Computations
To compute a symbolic value for the directional derivative, use the Stu-
dent[MultivariateCalculus][DirectionalDerivative] command. The first
list of numbers specifies the point at which to compute the derivative. The
second list of numbers specifies the direction in which to compute the deriv-
ative.
For example, at the point [1, 2], the gradient of points in the direction
[2, 4], which is the direction of greatest increase. The directional derivative
in the orthogonal direction [-2, 1] is zero.
>
>
4.4 Calculus • 161
>
Series
To generate the Taylor series expansion of a function about a point, use the
taylor command.
>
Note: If a Taylor series does not exist, use the series command to find a
general series expansion.
For example, the cosine integral function does not have a taylor series expan-
sion about 0. For more information, refer to the ?Ci help page.
>
Error, does not have a taylor expansion, try series()
>
>
To set the order for all computations, use the Order environment variable.
For information about the Order variable and the term, refer to the
?Order help page.
The expansion is of type series. Some commands, for example, plot, do not
accept arguments of type series. To use the expansion, you must convert it
to a polynomial using the convert/polynom command.
>
For information on Maple types and type conversions, see Maple Expres-
sions (page 285).
4.4 Calculus • 163
Integration
Maple can perform symbolic and numeric integration.
2. Specify the integrand and variable of integration, and then evaluate it.
>
Recall that you can also enter symbols, including and , using symbol
completion.
• Enter the symbol name (or part of the name), for example, int and d, and
then press the completion shortcut key.
You can also compute an indefinite integral using context menus. For more
information, see Context Menus (page 20).
>
>
and use the int command. To use the int command directly,
• Expression to integrate
• Variable of integration
>
4.4 Calculus • 165
(4.2)
>
For a definite integration, set the variable of integration equal to the interval
of integration.
>
Numeric Integration
To perform numeric integration:
Important: Use the inert Int command, not the int command. For more in-
formation, refer to the ?int help page.
In addition to the arguments accepted by the int command, you can include
optional arguments such as method, which specifies the numeric integration
method.
For example:
>
To compute iterated integrals, line integrals, and surface integrals, use the
task templates (Tools>Tasks>Browse) in the Multivariate and Vector
Calculus folders.
Differential Equations
Maple has a powerful set of solvers for ordinary differential equations (ODEs)
and partial differential equations (PDEs), and systems of ODEs and PDEs.
For information on solving ODEs and PDEs, see Other Specialized Solv-
ers (page 88).
Calculus Packages
In addition to top-level calculus commands, Maple contains calculus pack-
ages.
VectorCalculus Package
The VectorCalculus package contains commands that perform multivariate
and vector calculus operations on VectorCalculus vectors (vectors with an
additional coordinate system attribute) and vector fields (vectors with addi-
tional coordinate system and vectorfield attributes), for example, Curl, Flux,
and Torsion.
>
>
>
4.4 Calculus • 167
>
>
Compute the torsion of a space curve. The curve must be a vector with
parametric function components.
>
For information on using Maple as a teaching and learning tool, and some
computational examples, see Teaching and Learning with Maple (page 180).
4.5 Optimization
Using the Optimization package, you can numerically solve optimization
problems. The package uses fast Numerical Algorithms Group (NAG) al-
gorithms to minimize or maximize an objective function.
• Linear programs
• Quadratic programs
• Nonlinear programs
• Linear and nonlinear least-squares problems
Point-and-Click Interface
The primary method for solving optimization problems is the Optimization
Assistant.
To solve a problem:
3. Click the Solve button. The solution is displayed in the Solution text box.
You can also enter the problem (objective function, constraints, and bounds)
in the calling sequence.
>
In the Optimization Assistant window, click the Plot button. The Optimiz-
ation Plotter window is displayed. See Figure 4.9.
4.5 Optimization • 171
variables.
>
>
Define the matrix A, the coefficient matrix for the linear inequality con-
straints.
>
>
>
Additional Information
For a complete list of commands and other Optimization package informa-
tion, refer to the ?Optimization help page.
4.6 Statistics
The Statistics package is a collection of commands and the point-and-click
Data Analysis Assistant—refer to the ?Statistics[InteractiveDataAnalysis]
help page—for performing computations in mathematical statistics and data
analysis. The package supports a wide range of common statistical tasks in-
cluding quantitative and graphical data analysis, simulation, and curve fitting.
• Continuous distributions, which are defined along the real line by prob-
ability density functions. Maple supports many continuous distributions,
including the normal, Student-t, Laplace, and logistic distributions.
• Discrete distributions, which have nonzero probability only at discrete
points. A discrete distribution is defined by a probability function. Maple
supports many discrete distributions, including the Bernoulli, geometric,
and Poisson distributions.
>
>
>
represents the Dirac delta function. For more information, refer to the
?Dirac help page.
>
>
4.6 Statistics • 175
>
Statistical Computations
In addition to basic functions, like mean, median, standard deviation, and
percentile, the Statistics package contains commands that compute, for ex-
ample, the interquartile range and hazard rate.
Examples
Example 1
Compute the average absolute range from the interquartile of the Rayleigh
distribution with scale parameter 3.
>
>
Example 2
Compute the hazard rate of the Cauchy distribution with location and scale
parameters a and b at an arbitrary point t.
>
>
You can also specify that Maple compute the result numerically.
>
Plotting
You can generate statistical plots using the visualization commands in the
Statistics package. Available plots include:
• Bar chart
• Frequency plot
• Histogram
• Pie Chart
• Scatter Plot
For example, create a scatter plot for a distribution of points that vary from
>
>
>
>
>
178 • 4 Mathematical Computations
For information on plotting options, such as title, see Plots and Anima-
tions (page 189).
To fit a curve to the data points, include the optional fit equation parameter.
• Function
>
4.6 Statistics • 179
>
>
Additional Information
For more information on the Statistics package, including regression analysis,
estimation, data manipulation, and data smoothing, refer to the ?Statistics
help page.
180 • 4 Mathematical Computations
Maple Application CenterTM The Maple Application Center contains tutorials and ap-
plications that help instructors begin using Maple and use
Maple in the classroom. Browse the many resources in
the Education and Education PowerTools categories.
(http://www.maplesoft.com/applications)
4.7 Teaching and Learning with Maple • 181
Resource Description
Maple Student CenterTM The Maple Student Center contains tutorials and applica-
tions that help students learn how to use Maple, explore
mathematical concepts, and solve problems. Available
resources include:
• Study guides - Complete lessons with examples for
academic courses, including precalculus and calculus.
For example, the Interactive Precalculus Study Guide
contains worked problems, each solved as in a stand-
ard textbook, using Maple commands and custom
Maplet graphical interfaces.
• Free course lessons for many subjects including pre-
calculus to vector calculus; high school, abstract, and
linear algebra; engineering; physics; differential
equations; cryptography; and classical mechanics.
(http://www.maplesoft.com/academic/students)
Instructors can:
Students can:
To launch a tutor:
By rotating the three-dimensional plot, you can show that the gradient points
in the direction of greatest increase of the surface (see Figure 4.12) and show
the direction of the gradient vector in the x-y plane (see Figure 4.13).
When you close the tutor, Maple inserts the 3-D plot.
>
186 • 4 Mathematical Computations
• Plot that visually indicates the vector field, path of integration, and tangent
vectors to the path
• Unevaluated line integral
• Numeric value of the line integral
>
>
4.7 Teaching and Learning with Maple • 187
>
(4.3)
>
>
188 • 4 Mathematical Computations
For more information on the Student package, refer to the ?Student help
page.
5 Plots and Animations
Maple can generate many forms of plots, allowing you to visualize a problem
and further understand concepts.
• Maple accepts explicit, implicit, and parametric forms to display 2-D
and 3-D plots and animations.
• Maple recognizes many coordinate systems.
• All plot regions in Maple are active; therefore, you can drag expressions
to and from a plot region.
• Maple offers numerous plot options, such as axes styles, title, colors,
shading options, surface styles, and axes ranges, which give you complete
control to customize your plots.
Customizing Plots - Methods for applying plot • Interactive Plot Builder Options
options before and after a plot displays • Context Menu Options
• The plot and plot3d Command Op-
tions
189
190 • 5 Plots and Animations
Section Topics
Analyzing Plots - Plot analyzing tools • Point Probe
• Rotate
• Pan
• Scale
Each method offers a unique set of advantages. The method you use depends
on the type of plot to display, as well as your personal preferences.
5.2 Creating Plots • 191
Using the Interactive Plot Builder, you can customize and display a plot
by selecting from the numerous plot types and applying plot options without
any knowledge of plotting command syntax. The output from the Interactive
Plot Builder is a plot of the expression or the command used to generate
the plot in the document.
Plot Builder.
Builder.
Step Details
Enter an expression. 1. In the Specify Expressions window:
window.
Plot the expression. 1. In the Select Plot Type window, notice the default
expression.
2. Click Plot.
To see the Maple syntax used to generate this plot, see Maple commands
from Creating Plots: Interactive Plot Builder (page 208)
5.2 Creating Plots • 195
window.
Step Details
Display the actual plot. Execute the inserted command, that is, display the plot.
By default, Maple displays each plot in a plot region using a different color.
You can also apply a line style such as solid, dashed, or dotted for each ex-
pression in the graph. For more information, refer to the ?plot/options help
page. To see the Maple syntax used to generate this plot, see Maple com-
mands from Creating Plots: Interactive Plot Builder (page 208)
Step Details
Launch the Plot Options win- In the Select Plot Type window:
dow.
a. Notice the available plot types for an expression
each type.
b. Click Options.
grid.
To see the Maple syntax used to generate this plot, see Maple commands
from Creating Plots: Interactive Plot Builder (page 208)
Step Details
Select a plot type. In the Select Plot Type window:
expression.
0 .. 2+2*I.
select polar.
select magenta.
To see the Maple syntax used to generate this plot, see Maple commands
from Creating Plots: Interactive Plot Builder (page 208)
Steps Details
Select a plot type. In the Select Plot Type window:
window.
Adjust the plot. 1. To adjust the numeric values, use the slider.
2. Click Done to return the plot to the Maple document.
204 • 5 Plots and Animations
To see the Maple syntax used to generate this plot, see Maple commands
from Creating Plots: Interactive Plot Builder (page 208)
Context Menu
A context menu in Maple displays a list of commands to manipulate, display,
or calculate using a Maple expression. The commands in the menu depend
on the type of the expression. To display the context menu for a Maple ex-
pression, right-click (for Macintosh, Control-click) the expression.
By invoking the Interactive Plot Builder through the context menu, the
expression automatically passes to the builder and Maple does not display
the Specify Expression window.
3. From the context menu, select Plots > 3-D Plot > x,y.
206 • 5 Plots and Animations
>
5.2 Creating Plots • 207
For information on customizing plots using the context menu, see Context
Menu Options (page 217).
Advantages of the drag-and-drop method include the ease of adding and re-
moving plots and the independence from plotting command syntax.
3. Select the full expression in the input region and drag it into the plot region.
The main advantages of using plotting commands are the availability of all
Maple plot structures and the greater control over the plot output. Plot options
are discussed in Customizing Plots (page 216).
>
5.2 Creating Plots • 209
>
>
>
>
>
210 • 5 Plots and Animations
For more information on the plot options described in this section, refer to
the ?plot/options and ?plot3d/options help pages.
>
>
>
>
>
>
5.2 Creating Plots • 213
>
>
214 • 5 Plots and Animations
>
>
This example plots a curve over a hill with the shadow of the curve projected
onto the hill.
>
>
>
>
>
216 • 5 Plots and Animations
>
>
>
>
Now that you have seen how easy it is to incorporate a plot into your work,
the next section illustrates how to customize plots.
text field.
options using the Plot toolbar and Plot menu options. These menus display
when a plot region is selected. Regardless of the method used to insert a plot
into Maple, you can use the context menu to apply different plot options.
For a list of options available when plotting in two and three dimensions,
see The plot and plot3d Options (page 220).
>
In the previous plot, all interesting details of the plot are lost because there
is a singularity at x = 1. The solution is to view a narrower range, for example,
from y = 0 to 7.
Steps Details
Change the color. Place the mouse pointer on the curve and right-click (Con-
trol-click, for Macintosh). Note: The curve is selected when
it becomes highlighted. Select Color, and then Green.
Change the line style. Select Style, and then Point.
>
Steps Details
Change the axes style. Select Axes, and then Boxed.
Alter the glossiness. Select Glossiness. Using the slider, adjust the level of
glossiness.
Option Description
style Defines how the surface is to be drawn, one of: line, patch, patchcon-
tour, patchnogrid, or point for 2-D plots; contour, hidden, or
wireframe for 3-D plots
symbol Defines the symbol for points in the plot, one of: box, cross, circle,
point, or diamond
title Defines a title for the plot
thickness Defines the thickness of lines in the plot
transparency (3-D) Controls the transparency of the plot surface
view Defines the minimum and maximum coordinate values of the curve
displayed on the screen
>
To create a smoother or more precise plot, calculate more points using the
numpoints option.
222 • 5 Plots and Animations
>
select Animation.
1 .. 30.
224 • 5 Plots and Animations
Steps Details
Set plot options. In the Plot Options window:
For information on playing the animation, see Playing Animations (page 226).
To see the Maple syntax used to generate this plot, see Maple Syntax for
Creating Animations: Interactive Plot Builder Example (page 225).
Color Plates
To access the command, use the short form name after invoking the
with(plots) command.
>
>
>
226 • 5 Plots and Animations
You can also run the animation using the context menu or the Plot menu.
228 • 5 Plots and Animations
>
>
5.7 Customizing Animations • 229
>
>
230 • 5 Plots and Animations
5.8 Exporting
You can export a generated graph or animation to an image in various file
formats, including DXF, EPS, GIF, JPEG/JPG, POV, Windows BMP, and
WMF. Exporting an animation to GIF produces an animated image file. The
exported images can be included in presentations, Web pages, Microsoft
Word, or other software.
To export an image:
Alternatively:
2. From the Plot menu, select Export, and then the file format.
Maple has various plot drivers. By setting the plotdevice, a file can be
automatically created without returning the image to the document. For more
information, refer to the ?plotdevice help page.
From the Help menu, select Manuals, Dictionary, and more, On the Web,
and then Application Center.
You can:
231
232 • 6 Creating Mathematical Documents
Section Topics
Auto-execute - Execute selected re- • Setting the Auto-Execute Feature
gions of your document • Removing the Auto-Execute Setting
• Repeating Auto-Execution
• Security Levels
Spell Checking - Verify text with • How to Use the Spellcheck Utility
the Maple spell checking utility • Selecting a Suggestion
• Spellcheck Usage and the Document
• User Dictionary
To modify text:
2. From the Format menu, select Character, and then the appropriate feature.
For font and highlight colors, you can select from Swatches, HSB, or RGB
values. See Figure 6.1.
To modify text:
2. From the Format menu, select Character, and then Attributes. The
Character Style dialog opens. See Figure 6.2.
To modify a paragraph:
1. In the document, select the paragraph to modify.
2. From the Format menu, select Paragraph, and then the appropriate fea-
ture.
236 • 6 Creating Mathematical Documents
If you paste into an input region, Maple interprets all the pasted content as
input. If you paste into a text region, Maple interprets all the pasted content
as text. Note, however, that 2-D Math retains its format in both input and
text regions.
When you copy and paste to another application, in general, Maple retains
the original structure.
Sections
You can organize your document into sections.
• If the cursor is inside a section, Maple inserts the new section after the
current section.
• If the cursor is in an execution group, Maple inserts the new section after
the execution group.
2. From the Insert menu, select Section. An arrow marks the start of the
section.
238 • 6 Creating Mathematical Documents
• From the View menu, select Markers. A vertical bar is displayed along
the left pane of the document. Icons for hidden elements are displayed
in the vertical bar next to the associated content in the document.
The Tab icon is disabled when using 2-D Math (Math mode), and as such,
the Tab key allows you to move between placeholders.
Tab icon on. Allows you to indent in the document using the Tab key.
• New styles that you have created through the Style Management (Figure
6.4) and Character Style (Figure 6.5) dialogs.
2. In the styles drop-down list in the context bar of your document, select
an appropriate character style. All character styles are preceded by the letter
C. The selected text now reflects the attributes of the character style you
have chosen.
3. (Optional) If necessary, you can remove this style. From the Edit menu,
select Undo.
1. From the Format menu, select Styles. The Style Management dialog
opens. See Figure 6.4.
2. Click Create Character Style. The Character Style dialog opens. See
Figure 6.5.
3. In the Style group box, enter a style name in the blank text field.
4. Select the properties for the new character style, such as Font, Size, At-
tributes, and Color. In the Attributes group box, the Superscript and
Subscript check boxes are mutually exclusive. When you select one of the
6.2 Document Formatting • 241
two check boxes, the other is disabled. You must clear one before selecting
the other.
Note: A preview of the style is displayed in the Example group box at the
bottom of the Character Style dialog.
1. From the Format menu, select Styles. The Style Management dialog
opens. See Figure 6.4.
3. Click Modify. The Character Style dialog opens with the current attributes
displayed. See Figure 6.5.
242 • 6 Creating Mathematical Documents
4. Select the properties to modify, such as Font, Size, Attributes, and Color.
In the Attributes group box, the Superscript and Subscript check boxes
are mutually exclusive. When you select one of the two check boxes, the
other is disabled. You must clear one before selecting the other.
A preview of the style is displayed in the Example group box at the bottom
of the Character Style dialog.
2. In the styles drop-down list in the context bar of your document, select
an appropriate paragraph style. All Maple paragraph styles are preceded by
the letter P. The selected text now reflects the attributes of the paragraph
style you have chosen.
3. (Optional) If necessary, you can remove this style. From the Edit menu,
select Undo.
6.2 Document Formatting • 243
1. From the Format menu, select Styles. The Style Management dialog
opens. See Figure 6.4.
2. Click Create Paragraph Style. The Paragraph Style dialog opens. See
Figure 6.6.
3. In the Style group box, enter the new paragraph style name in the blank
text field.
4. In the Units drop-down list, select the units used to determine spacing
and indentation. Select from inches (in), centimeters (cm), or points (pt).
5. Select the properties to use for this paragraph style, such as Spacing, In-
dent, Justification, Bullet Style, Linebreak, and Page Break Before.
6. To add a font style, click Font. The Character Style dialog opens. For
detailed instructions, see Creating Character Styles (page 240).
1. From the Format menu, select Styles. The Style Management dialog
opens. See Figure 6.4.
3. Select the properties you want to modify, such as Spacing, Indent, Justi-
fication, and Bullet, Linebreak, and Units.
1. From the Format menu, select Manage Style Sets. The Style Set Man-
agement dialog opens. See Figure 6.7.
2. In the Style Set Operations group box, click New Style Set. The Choose
Styles dialog opens. See Figure 6.8.
246 • 6 Creating Mathematical Documents
3. Select all the styles that are part of your document style set. For example,
if you modified the Author paragraph style to justify left versus the default
style of centered, ensure that you have selected the Author check box in the
Choose Styles dialog.
5. Save your style set. The style is now available for future use in other
documents.
1. From the Format menu, select Manage Style Sets. The Style Set Man-
agement dialog opens. See Figure 6.7.
2. In the Style Set Operations group box, click Apply Style Set. The Choose
Filename dialog opens.
3. Select the style file and click Open. The Choose Styles dialog opens. At
this point, you can overwrite all the styles in your current document with the
new style set or apply only a few.
1. From the Format menu, select Manage Style Sets. The Style Set Man-
agement dialog opens.
2. In the Current Style Set group box, select the Default Maple Style Set
or User-defined Style Set. For user-defined style sets, navigate (click
Browse) to the file (Choose Filename dialog) and open the file (click Open).
4. In the Choose Styles dialog, select all the styles to revert, that is, overwrite
with either the Default Maple Style Set or the User-defined Style Set.
5. Click OK.
Document Blocks
With document blocks, you can create documents that present text and math
in formats similar to those found in business and education documents.
By hiding Maple input such that only text and results are visible, you create
a document with better presentation flow. Before using document blocks, it
is recommended that you display Markers. A vertical bar is displayed along
the left pane of the document. Icons representing document blocks are dis-
played in this vertical bar next to associated content.
To activate Markers:
1. Enter input at the Maple command prompt, creating input that can be
referenced elsewhere in the document. See the ?EquationLabels help page.
2. Execute the area, creating output that can be referenced elsewhere in the
document.
3. Intersperse the area with content that is to remain visible, adding references
to the input and output in the appropriate locations.
The block displays text and output only. You can select areas to display input
only.
6. Select the output region you want to display as input. From the View
menu, select Toggle Input/Output Display. The selected region displays
input.
6.2 Document Formatting • 249
1. From the File menu, select New, and then Document Mode. A document
opens with the Document mode markers indicated in the left margin. Note
that margin markers are visible if you select View>Markers.
4. Click the Evaluate and Display Inline menu item. The expression is
evaluated.
Note: Each time you press Enter, a new document block appears. Documents
consist of a series of document blocks.
In the following figures, note how the expression is entered as part of the
text and then evaluated with the context menu option Evaluate and Display
Inline.
250 • 6 Creating Mathematical Documents
Before
After
As document blocks can contain many execution groups, you can select to
expand an execution group within a document block.
Inline Document
Document blocks can display content inline, that is, text, input, and output
in one line as presented in business and education documents.
Typesetting
You can control typesetting and 2-D Math equation parsing options in the
Standard Worksheet interface. Extended typesetting uses a customizable set
of rules for displaying expressions.
• From the View menu, select Typesetting Rules. The Typesetting Rule
Assistant dialog opens.
Creating a Table
To create a table:
2. Specify the number of rows and columns in the table creation dialog.
3. Click OK.
The default properties for the table include visible borders and auto-adjust-
ment to 100% of the document width. These options, as well as the table
6.2 Document Formatting • 253
Cell Contents
Any content that can be placed into a document can also be placed into a
table cell, including other sections and tables. Table cells can contain a mix
of:
• Input commands
• 2-D Math
• Embedded components - buttons, sliders, check boxes, and more
• Plots
• Images
Tab icon on. Allows you to indent in the table using the Tab key.
Pasting
Pasting a table subselection into a table may result in the creation of additional
rows or columns, overwriting existing cell content, or the insertion of a
subtable within the active table cell.
Merging
You can merge cells across row or column borders. See Figure 6.10. The
resultant cell must be rectangular. The contents of the individual cells in the
merge operation are concatenated in execution order. See Figure 6.11.
The most direct way is to press the left mouse button (press mouse button,
for Macintosh) while hovering over the left or right table boundary and
dragging the mouse left or right. Upon release of the mouse button, the table
boundary is updated. This approach can also be used to resize the relative
width of table columns.
6.2 Document Formatting • 255
Alternatively, the size of the table can be controlled from the Table Proper-
ties dialog. Select Tables>Properties. Two sizing modes are supported.
(1) Fixed percentage of page width. Using this option, the table width ad-
justs whenever the width of the document changes. This option is useful for
ensuring that the entire content of the table fits in the screen or printed page.
(2) Scale with zoom factor. This option is used to preserve the size and
layout of the table regardless of the size of the document window or the
zoom factor. If the table exceeds the width of the document window, the
horizontal scroll bar can be used to view the rightmost columns. Note: Using
this option, tables may be incomplete when printed.
Table Borders
The style of exterior and interior borders is set using the Table Properties
dialog. Select Table>Properties.
• You can set all, none, or only some of the borders to be visible in a table.
• You can control the visibility of interior borders by using the Group
submenu of the Table menu.
• Grouping rows or columns suppresses interior borders within the table
selection.
• Grouping rows and columns requires that the interior border style is set
by row and column group.
• Hidden borders are visible when the mouse hovers over a table. Note
that you can hide the visibility of lines on mouse pointer roll over by
using the View>Show/Hide Contents dialog, and clearing the Hidden
Table Borders check box.
Alignment Options
The table alignment tools control the horizontal alignment of columns and
vertical alignment of rows.
256 • 6 Creating Mathematical Documents
Printing Options
The Table Properties dialog contains options to control the placement of
page breaks when printing. You can fit a table on a single page, allow page
breaks between rows, or allow page breaks within a row.
> >
> >
> >
> >
258 • 6 Creating Mathematical Documents
Examples
Table of Values
This example illustrates how to set the visibility options for cell contents to
display a table of values.
> y := t -> 1/2*t^2:
Table settings:
2. Hide Maple input and execution group boundaries: Clear the Show input
and Show execution group boundaries check boxes.
6.2 Document Formatting • 259
t [s] 0 1 2 3 4 5 6
y(t) [m]
By default, invisible cell boundaries are visible on mouse pointer roll over.
You can hide the visibility of lines on mouse pointer roll over by using the
View>Show/Hide Contents dialog, and clearing the Hidden Table Borders
check box.
Parameter 2
Low High
Parameter 1 Low 13 24
High 18 29
Table settings:
6. (Optional) Change Table Size Mode size option to Scale with zoom
factor.
Table Settings:
2. Hide Maple input and execution group boundaries: Clear the Show input
and Show execution group boundaries check boxes.
f(x)
Table Settings:
3. Group rows 2 to 4.
To arrange content in a bullet list using the context bar drop-down list:
2. In the character and paragraph style drop-down list, select P Bullet Item.
The selected text is displayed as a (dot) bullet list.
Ordered lists have 5 default styles. See Figure 6.12. List 1 begins at the left
margin. By default, subsequent lists are indented half an inch. To change
the default, see Modifying Paragraph Styles (page 244). The numbering style
uses numbers, lowercase letters, lowercase roman numerals, uppercase letters,
uppercase Roman numerals.
6.2 Document Formatting • 263
2. In the character and paragraph style drop-down list, select P List Item.
The selected text is displayed as an indented list.
2. From the Format menu, select Paragraph, and then Attributes. The
Paragraph Style dialog opens.
3. In the Bullet and Numbering drop-down list, select one of the styles.
264 • 6 Creating Mathematical Documents
4. If you have selected one of the numbered styles (number, letters, Roman
numerals), set an initial list value.
Bookmarks
Use a bookmark to designate a location in an active document. This bookmark
can then be accessed from other regions in your document or by using hyper-
links in other documents.
2. From the Format menu, select Bookmarks. The Bookmark dialog opens,
listing existing bookmarks in the document.
3. Click New. The Create Bookmark dialog opens. Enter a bookmark name
and click Create.
4. The new bookmark appears in the Bookmark dialog list. Click OK.
Note: You can also rename and delete bookmarks using the Bookmark
dialog.
6.2 Document Formatting • 265
Go to a Bookmark
You can automatically move the cursor to the location of the bookmark in
the active document.
2. Select the bookmark and click OK. The cursor moves to the bookmark.
Inserting Images
Images help illustrate ideas and enhance presentations. You can insert images
in your document at a cursor location or in a table.
You can insert images in these file formats
into your document.
• Graphics Interchange Format - gif
• Joint Photographic Experts Group -
jpe, jpeg, jpg
• Portable Network Graphics - png
• Bitmap Graphics - bmp
• Tagged Image File Format - tif, tiff,
jfx
• Portable aNyMap - pnm
• Kodak FlashPix - fpx
1. From the Insert menu, select Image. The Load Image dialog opens.
2. Specify a path or folder name.
3. Select a filename.
If the source file is altered, the embedded image does not change because
the original object is pasted into the document.
1. Click the image. Resizing anchors appear at the sides and corners of the
image.
2. Move the mouse over the resize anchor. Resizing arrows appear.
ImageTools Package
You can manipulate image data using the ImageTools package. This package
is a collection of utilities for reading and writing common image file formats,
and for performing basic image processing operations within Maple.
For details about this feature, refer to the ?ImageTools help page.
In a document, use the Show Contents dialog to hide all spreadsheets, input,
output, or graphics, plus section boundaries, execution group boundaries,
and hidden table borders on mouse pointer roll over. The dialog is accessed
from the View>Show/Hide Contents menu.
6.2 Document Formatting • 267
1. From the View menu, select Show/Hide Contents. The Show Contents
dialog opens with all items selected for display.
2. Clear the check box associated with the document components or ranges
to hide.
By clearing the Input check box, only Maple Input and 2-D Math input, that
is, 2-D Math content that has been evaluated, are hidden. Clearing the
Graphics check box ensures that a plot, an image, or the Sketch feature in-
serted in the document by using the Insert menu option is also hidden.
The plot resulting from executing the plot(sin) call is considered output.
• To show a plot from the plot(sin) call, select both the Output and
Graphics check boxes in the Show Contents dialog.
If you insert a plot by using the Insert menu option, that plot is not considered
output. Therefore, if you clear the Output check box in the Show Contents
dialog, that plot will be visible in the document.
• To hide an inserted plot, clear the Graphics check box in the Show
Contents dialog.
Inserted images and the Sketch feature are not considered output. As such,
they are not hidden if you clear the Output check box.
• To hide an inserted image or sketch, clear the Graphics check box in
the Show Contents dialog.
268 • 6 Creating Mathematical Documents
By default, palettes are displayed when you launch Maple. If palettes are
not visible, use the following procedure.
To view palettes:
4. For actions, such as Action When Value Changes in the Slider component
dialog, click Edit. A blank dialog opens allowing you to enter Maple code
that is executed when the event occurs. For details, refer to the ?Document-
Tools help page.
2. In the Components palette, click the Slider item. A slider is inserted into
the document.
3. In the Components palette, click the Label item. A label is inserted next
to the slider.
10. To define an action when the value of the slider changes, click Edit. The
Action When Value Changes dialog opens.
11. Enter the following calling sequence and click OK to close all dialogs.
DocumentTools[SetProperty ]('SliderLabel',caption,
DocumentTools[GetProperty] ('Slider1', 'value' ) );
The value from the slider as you move the arrow indicator populates the
Label caption field.
6.4 Creating Graded Assignments • 271
Note: This feature can be used to create questions for Maple T.A.—an online
automated testing and assessment system. For details about Maple T.A., see
Input, Output, and Interacting with Other Products (page 363).
Creating a Question
To create a question:
• From the View menu, select Assignment. This view displays all of the
questions in your assignment with access to hints, plotting, and grading.
After answering your questions, you can test the grading function by clicking
the Grade button. A Maplet dialog is displayed indicating if the question
was answered correctly. If hints were provided in the question, these are also
displayed.
6.5 Auto-Execute
An execution group is a grouping of Maple input with its corresponding
Maple output. It is distinguished by a large square bracket, called a group
boundary, at the left. An execution group may also contain any or all of the
following: a plot, a spreadsheet, and text.
Repeating Auto-Execution
To execute all marked groups:
• From the Edit menu, select Execute, and then Repeat Autoexecution.
Security Levels
By default, Maple prompts the user before automatically executing the doc-
ument.
To set security levels for the autoexecute feature, use the Security tab in the
Options dialog. For details, refer to the ?OptionsDialog help page.
274 • 6 Creating Mathematical Documents
2. From the Insert menu, select Sketch. A sketch pad with grid lines appears
in the document at the insertion point. The Sketch menu is available and
associated context bar icons are displayed.
6.6 Sketch Regions • 275
Drawing
To draw with a pencil or highlighter in the sketch pad:
To adjust the color and width of the pencil and highlighter tools:
1. From the Sketch menu, select Stroke Style Presets. The Stroke Styles
dialog opens.
2. Click the Pencil or Highlighter tab. The current styles are displayed.
4. Using the slider, alter the width and height of the line as necessary.
5. Click the Stroke Color button. The Select Color dialog opens. Choose
from Swatches, HSB, and RGB colors.
6. Select a color and click OK. The current settings are updated with the
color you selected.
7. Click OK.
• Add a grid of horizontal and/or vertical lines. By default, the sketch opens
with a grid of horizontal and vertical lines.
• Change the background color.
• Change the grid line color.
• Change the spacing between grid lines.
276 • 6 Creating Mathematical Documents
1. From the Sketch menu, select Canvas Style. The Canvas Style dialog
opens.
2. For grid lines, select the appropriate grid check boxes and adjust spacing
as required using the slider.
3. For colors, click the Grid Color or Background Color buttons. The Select
Color dialog opens. Select from various colors.
To remove gridlines:
• Clear the Show horizontal grid or Show vertical grid check boxes, and
click OK.
3. Click the drawing in the sketch pad. A line (or point) is erased.
Selection Tool
The Selection tool allows you to select a region in the sketch pad and move
the contents of that selection to another area in the sketch pad.
To select a region:
2. In the sketch pad, click the mouse and drag the cursor across the region
to be selected.
2. If the Spellcheck utility finds a word that it does not recognize, that word
is displayed in the Not Found text box.
• To add the word to your dictionary, click Add. For details, see the fol-
lowing User Dictionary section.
• To close the Spellcheck dialog, that is, quit the Spellcheck utility, click
Cancel.
3. When the Spellcheck is complete, a dialog containing the message
"spellchecking complete" appears. Click OK to close this dialog.
Selecting a Suggestion
To select one of the suggestions as the correct spelling, click the appropriate
word from the list in the Suggestions text box.
If none of the suggestions are correct, highlight the word in the Change To
text box and enter the correct spelling. Click Change to accept this new
spelling.
User Dictionary
You can create and maintain a custom dictionary that works with the Maple
Spellcheck utility.
• It does not require manual maintenance. You build your dictionary file
by using the Add functionality of the Spellcheck. However, you can
manually edit the file if an error is introduced.
2. In Maple, open the Options dialog, Tools>Options, and select the Gen-
eral tab.
3. In the User Dictionary field, enter the path and name of the .txt file you
created in step 1, or click Browse to select the location and filename.
4. To ignore Maple words that are command and function names, select the
Use Maple Words in Spellchecker check box. A check mark indicates that
the Spellcheck ignores Maple words.
1. Click the Add button. If this is the first time you are adding a word, the
Select User Dictionary dialog opens.
2. Enter or select the custom dictionary (.txt file) you created. See User
Dictionary (page 279).
Maple session. If you set your custom dictionary use to Apply Globally,
then this new word will be recognized. See User Dictionary (page 279).
6.8 Hyperlinks
Use a hyperlink in your document to access any of the following.
• Email
• Dictionary Topic
• Help Topic
• Maplet Application
• Web Page (URL)
• Document
1. Position the cursor in a text region where you want to insert a hyperlink.
3. In the Hyperlink Properties dialog box, enter the text of the hyperlink
name in the Link Text edit field. See Figure 6.16.
4. Optionally, use an image as the link. Select the Include an Image check
box and Browse for the correct file. In .mw files, the image appears as the
link, while in .mws files, the Link Text you entered appears as the link. You
can resize the image as necessary. Click the image. Resizing anchors appear
at the sides and corners of the image.
3. Click OK.
Note: For information about email hyperlinks in the Classic Worksheet in-
terface, see Worksheet Compatibility (page 284).
2. In the Target field, enter a topic name. Dictionary topics begin with the
prefix Definition/, for example, Definition/dimension.
3. Click OK.
3. Click OK.
2. In the Target field, enter the local path to a file with the .maplet extension.
Optionally, click Browse to locate the file.
If the Maplet application exists, clicking the link launches the Maplet applic-
ation. If the Maplet application contains syntax errors, then error messages
are displayed in a pop-up window.
3. Click OK.
3. Click OK.
284 • 6 Creating Mathematical Documents
Linking to a Document
To link to a document:
2. In the Target field, enter the path and filename of the document or click
Browse to locate the file. (Optional) In the Bookmark drop-down list, enter
or select a bookmark.
3. Click OK.
285
286 • 7 Maple Expressions
• Expression sequences
• Sets
• Lists
• Tables
• Arrays
• Matrices and Vectors
• Functional operators
• Strings
Expression Sequences
The fundamental Maple data structure is the expression sequence. It is a
group of expressions separated by commas.
>
Accessing Elements
To access one of the expressions:
• Enter the sequence name followed by the position of the expression en-
closed in brackets([ ]).
For example:
>
Using negative integers, you can select an expression from the end of a se-
quence.
7.2 Creating and Using Data Structures • 287
>
You can select multiple expressions by specifying a range using the range
operator (..).
>
Sets
A set is an expression sequence enclosed in curly braces ({ }).
>
For example:
>
Using Sets
To perform mathematical set operations, use the set data structure.
>
288 • 7 Maple Expressions
Note: The union operator is available in 1-D Math input as union. For more
information, refer to the ?union help page.
Lists
A list is an expression sequence enclosed in brackets ([ ]).
>
Accessing Entries
To refer to an element in a list:
For example:
>
Using Lists
Some commands accept a list (or set) of expressions.
For example, you can solve a list (or set) of equations using a context menu
or the solve command.
7.2 Creating and Using Data Structures • 289
>
For more information, see Solving Equations and Inequations (page 78).
For more information on sets and lists, refer to the ?set help page.
Arrays
Conceptually, the Array data structure is a generalized list. Each element
has an index that you can use to access it.
For example:
>
>
290 • 7 Maple Expressions
>
The Array constructor supports other syntaxes. It also supports many options.
For more information on the Array constructor and the Array data structure,
refer to the ?Array help page.
Large Arrays
Only one- and two-dimensional Arrays (with at most 10 indices in each di-
mension) display in the document. Larger Arrays display as a placeholder.
>
The Matrix Browser displays the Array. For more information, see Editing
and Viewing Large Matrices and Vectors (page 138).
Tables
Tables are conceptually an extension of the Array data structure, but the
table data structure is implemented using hash tables. Tables can be indexed
by any values, not only integers.
7.2 Creating and Using Data Structures • 291
>
>
You can also assign anything, for example, a list, to each element.
>
>
>
>
292 • 7 Maple Expressions
>
>
For more information on these data structures, including how to access entries
and perform linear algebra computations, see Linear Algebra (page 135).
Functional Operators
A functional operator is a mapping . The value of is the
result of evaluating .
Defining a Function
To define a function of one or two variables:
1. In the Expression palette, click one of the function definition items. See
Figure 7.1. Maple inserts the function definition.
2. Replace the placeholder f with the function name. Press Tab. Note: If
pressing the Tab key inserts a tab, click the Tab icon in the toolbar.
4. Replace the final placeholder, y, with the expression that defines the
function value. Press Enter.
7.2 Creating and Using Data Structures • 293
>
Note: To insert the right arrow, you can enter the characters ->. In 2-D Math,
Maple replaces -> with the right arrow symbol . In 1-D Math, the
characters are not replaced.
You can evaluate the function add1 with symbolic or numeric arguments.
>
>
>
>
>
For more information on the eval command, and using palettes and context
menus to evaluate an expression at a point, see Substituting a Value for a
Subexpression (page 310).
>
>
A vector function:
>
7.2 Creating and Using Data Structures • 295
>
Using Operators
To perform an operation on a functional operator, specify arguments to the
operator. For example, for the operator f, specify f(x), which Maple evaluates
as an expression. See the following examples.
>
>
296 • 7 Maple Expressions
>
>
Strings
A string is a sequence of characters enclosed in double quotes (" ").
>
Accessing Characters
You can access characters in a string using brackets.
>
Using Strings
The StringTools package is an advanced set of tools for manipulating and
using strings.
>
>
>
>
298 • 7 Maple Expressions
• From the View menu, select Palettes, and then Expand Docks.
Low-Level Operations
Expression Types
A Maple type is a broad class of expressions that share common properties.
Maple contains over 200 types, including:
• `+`
• boolean
• constant
• integer
• Matrix
• trig
• truefalse
For more information and a complete list of Maple types, refer to the ?type
help page.
The type commands return true if the expression satisfies the type check.
Otherwise, they return false.
7.3 Working with Maple Expressions • 299
>
>
Maple types are not mutually exclusive. An expression can be of more than
one type.
>
>
>
300 • 7 Maple Expressions
>
>
>
The has command searches the structure of the expression for an exactly
matching subexpression.
For example, the following calling sequence returns false.
>
For example:
>
(7.1)
>
>
For the following equation, the left endpoint of the range is the left-hand
side of the right-hand side of the equation.
>
(7.2)
>
302 • 7 Maple Expressions
>
>
>
>
The expression can be any algebraic expression. For information on the be-
havior for non-rational expressions, refer to the ?numer help page.
7.3 Working with Maple Expressions • 303
Components of an Expression
The components of an expression are called its operands.
>
>
For more information on the nops command and operands, refer to the ?nops
help page.
Indeterminates
To find the indeterminates of an expression:
The indets command returns the indeterminates as a set. Because the expres-
sion is expected to be rational, functions such as sin(x), f(x), and sqrt(x) are
considered to be indeterminate.
>
304 • 7 Maple Expressions
>
Manipulating Expressions
This section introduces the most commonly used manipulation commands.
For additional manipulation commands, see Iterative Commands (page 333).
Simplifying
To simplify an expression:
>
>
7.3 Working with Maple Expressions • 305
>
>
You can also use the simplify command with side relations. See Substituting
a Value for a Subexpression (page 310).
Factoring
To factor a polynomial:
>
>
Maple can factor polynomials over the domain specified by the coefficients.
You can also factor polynomials over algebraic extensions. For details, refer
to the ?factor help page.
To factor an integer:
306 • 7 Maple Expressions
>
Expanding
To expand an expression:
The expand command distributes products over sums and expands expres-
sions within functions.
>
>
Combining
To combine subexpressions in an expression:
>
7.3 Working with Maple Expressions • 307
>
The combine command applies only transformations that are valid for all
possible values of names in the expression.
>
To perform the operation under assumptions on the names, use the assuming
command. For more information about assumptions, see Assumptions on
Variables (page 117).
>
Converting
To convert an expression:
The convert command converts expressions to a new form, type (see Expres-
sion Types (page 298)), or in terms of a function. For a complete list of con-
versions, refer to the ?convert help page.
>
308 • 7 Maple Expressions
To convert measurements that use units, use the Unit Converter or the con-
vert/units command.
>
For information on the Unit Converter and using units, see Units (page 97).
>
>
>
represents the Legendre function of the second kind. For more inform-
ation, refer to the ?LegendreQ help page.
Normalizing
To normalize an expression:
>
You can also use the normal command for zero recognition.
>
>
>
Sorting
To sort the elements of an expression:
310 • 7 Maple Expressions
>
>
>
Evaluating Expressions
Substituting a Value for a Subexpression
To evaluate an expression at a point, you must substitute a value for a vari-
able.
4. In the text field, enter the value to substitute for the variable. Click OK.
7.3 Working with Maple Expressions • 311
Maple inserts the eval command calling sequence that performs the substitu-
tion. This is the most common use of the eval command.
>
>
For example:
>
Substitutions performed by the eval function are syntactical, not the more
powerful algebraic form of substitution.
If the left-hand side of the substitution is a name, Maple performs the substi-
tution.
>
312 • 7 Maple Expressions
If the left-hand side of the substitution is not a name, Maple performs the
substitution only if the left-hand side of the substitution is an operand of the
expression.
>
>
For algebraic substitution, use the algsubs command, or the simplify com-
mand with side relations.
>
>
7.3 Working with Maple Expressions • 313
Numerical Approximation
To compute an approximate numerical value of an expression:
>
>
>
By default, Maple calculates the result to ten digits of accuracy, but you can
specify any number of digits as an index, that is, in brackets ([ ]).
>
See also Numerically Computing a Limit (page 155) and Numeric Integra-
tion (page 165).
314 • 7 Maple Expressions
If possible, the evalc command returns the output in the canonical form expr1
+ i expr2.
You can enter the imaginary unit using the following two methods.
>
>
Note: In 1-D Math input, enter , , and using the <>, <=, and
>= operators.
The evalb command uses a three-valued logic system. The return values are
true, false, and FAIL. If evaluation is not possible, an unevaluated expression
is returned.
>
>
>
Important: The evalb command does not perform arithmetic for inequalities
involving <, , >, or , and does not simplify expressions. Ensure
that you perform these operations before using the evalb command.
>
>
Levels of Evaluation
In a symbolic mathematics program such as Maple, you encounter the issue
of levels of evaluation. If you assign y to x, z to y, and then 5 to z, what is
the value of x?
316 • 7 Maple Expressions
At the top-level, Maple fully evaluates names. That is, Maple checks if the
name or symbol has an assigned value. If it has a value, Maple substitutes
the value for the name. If this value has an assigned value, Maple performs
a substitution, recursively, until no more substitutions are possible.
For example:
>
>
>
>
If passed a single argument, the eval command fully evaluates that expression.
If you specify an integer second argument, Maple evaluates the expression
to that level.
>
>
>
7.3 Working with Maple Expressions • 317
>
Delaying Evaluation
To prevent Maple from immediately evaluating an expression:
Because right single quotes delay evaluation, they are referred to as unevalu-
ation quotes.
>
>
>
>
318 • 7 Maple Expressions
Error, (in sum) summation variable previously assigned, second argument evaluates
to 4 = 1 .. 5
• Enclose the name in unevaluation quotes. Maple passes the name to the
command.
>
For example, if you enclose the keyword left in unevaluation quotes, Maple
uses the name, not its assigned value.
>
>
>
>
7.3 Working with Maple Expressions • 319
(7.3)
>
(7.4)
>
For information on equation labels and equation label references, see Equa-
tion Labels (page 59).
>
>
>
You can also unassign a name using the unassign command. For more in-
formation, see Unassigning Names (page 57).
320 • 7 Maple Expressions
8 Basic Programming
You have used Maple interactively in the previous chapters, sequentially
performing operations such as executing a single command. Because Maple
has a complete programming language, you can also use sophisticated pro-
gramming constructs.
321
322 • 8 Basic Programming
Using the if statement, you can execute one statement from a series of
statements based on a boolean (true, false, or FAIL) condition. Maple tests
each condition in order. When a condition is satisfied, Maple executes the
corresponding statement, and then exits the if statement.
Syntax
The if statement has the following syntax.
> if conditional_expression1 then
statement_sequence1
elif conditional_expression2 then
statement_sequence2
elif conditional_expression3 then
statement_sequence3
...
else
statement_sequenceN
end if;
The elif clauses are optional. You can specify any number of elif clauses.
Simple if Statements
The simplest if statement has only one conditional expression.
> if conditional_expression then
statement_sequence
end if;
For example:
> x := 1173:
else Clause
In a simple if statement with an else clause, if the evaluation of the conditional
expressions returns false or FAIL, Maple executes the statement sequence
in the else clause.
324 • 8 Basic Programming
For example:
> if false then
"if statement";
else
"else statement";
end if;
elif Clauses
In an if statement with elif clauses, Maple evaluates the conditional expres-
sions in order until one returns true. Maple executes the corresponding
statement sequence, and then exits the if statement. If no evaluation returns
true, Maple exits the if statement.
> x := 11:
In the following if statement, the elif clauses are in the wrong order.
8.2 Flow Control • 325
For more information on the if statement, refer to the ?if help page.
for/from Loop
The for/from loop statement repeats a statement sequence until a counter
variable value exceeds a limit.
Syntax
The for/from loop has the following syntax.
> for counter from initial by increment to final do
statement_sequence
end do;
2. Compare the value of counter to the value of final. If the counter value
exceeds the final value, exit the loop. (This is the loop bound test.)
The from, by, and to clauses are optional and can be in any order between
the for clause and the do keyword.
Examples
The following loop returns the square root of the integers 1 to 5 (inclusive).
> for n to 5 do
evalf(sqrt(n));
end do;
When the value of the counter variable n is strictly greater than 5, Maple
exits the loop.
> n;
The by value can be negative. The loop repeats until the value of the counter
variable is strictly less than the final value.
> for n from 10 by -1 to 3 do
if isprime(n) then
print(n);
end if;
end do;
> n;
for/in Loop
The for/in loop statement repeats a statement sequence for each component
(operand) of an expression, for example, the elements of a list.
Syntax
The for/in loop has the following syntax.
> for variable in expression do
statement_sequence
end do;
8.2 Flow Control • 329
4. Repeat steps 2 and 3 for each operand in expression. If there are no more
operands, exit the loop. (This is the loop bound test.)
Example
The following loop returns a floating-point approximation to the sin function
at the angles (measured in degree) in the list L.
> L := [23.4, 87.2, 43.0, 99.7]:
> for i in L do
evalf(sin(i*Pi/180));
end do;
while Loop
The while loop repeats a statement sequence until a boolean expression does
not hold.
330 • 8 Basic Programming
Syntax
The while loop has the following syntax.
> while conditional_expression do
statement_sequence
end do;
Example
The following loop computes the digits of 872, 349 in base 7 (in order of
increasing significance).
> x := 872349:
After testing the loop bound condition at the beginning of each iteration of
the for loop, Maple evaluates conditional_expression.
Infinite Loops
You can construct a loop for which there is no exit condition, for example,
a while loop in which the conditional_expression always evaluates to true.
This is called an infinite loop. Maple indefinitely executes an infinite loop
unless it executes a break, quit, or return statement or you interrupt the
computation. For more information, refer to the ?break, ?quit, ?return,
and ?interrupt help pages.
Additional Information
For more information on the for statement and looping, refer to the ?do help
page.
8.3 Iterative Commands • 333
Creating a Sequence
The seq command creates a sequence of values by evaluating a specified
expression over a range of index values or the operands of an expression.
See Table 8.3.
The endpoints of the index range (initial and final) in the add and mul
calling sequence must evaluate to numeric constants. For information on
symbolic sums and products, refer to the ?sum and ?product help pages.
8.3 Iterative Commands • 335
• The select command returns the operands for which the procedure or
command returns true.
• The remove command returns the operands for which the procedure or
command returns false.
• The selectremove command returns two expressions of the same type
as the input expression.
- The first consists of the operands for which the procedure or command re-
turns true.
- The second consists of the operands for which the procedure or command
returns false or FAIL.
By default, the length of the returned object is that of the shorter list or vector.
If you specify a value as the (optional) fourth argument, it is used as the
value of the missing elements of the shorter list or vector. In this case, the
length of the return value is that of the longer list or vector. See Table 8.7.
For more information on the zip command, refer to the ?zip help page.
Additional Information
For more information on looping commands, refer to the corresponding
command help page.
338 • 8 Basic Programming
8.4 Procedures
A Maple procedure is a program consisting of Maple statements. Using
procedures, you can quickly execute the contained sequence of statements.
When the user runs the procedure, the parameter names are replaced by the
argument values.
> geometric_mean(13, 17);
You must evaluate the name of the procedure using the print (or eval)
command.
> print(geometric_mean);
By default, the print command returns only the proc and end proc statements
and (if present) the description fields of a Maple procedure.
> print(assign);
To display a Maple library procedure definition, first set the value of the
interface verboseproc option to 2. Then re-execute the print calling se-
quence. See Figure 8.1.
8.4 Procedures • 341
Modules
Maple procedures associate a sequence of commands with a single command.
The module, a more complex programming structure, allows you to associate
related procedures and data.
A key feature of modules is that they export variables. This means that the
variables are available outside the module in which they are created. Most
Maple packages are implemented as modules. The package commands are
exports of the module.
> with(Maplets[Elements]):
343
344 • 9 Maplets
> Maplets[Display](MySimpleMaplet):
Maplet File
To launch a Maplet application saved as a Maplet file:
• In Windows, double-click the file from a Windows file browser.
• In UNIX and on Macintosh, use the command-line interface. At the
command-line, enter maple(maplet_filename).
To view and edit the Maplet code contained within the .maplet file:
1. Start Maple.
2. From the File menu, select Open. Maple displays the Open dialog.
3. In the Files of Type drop-down list, select .maplet.
4. Navigate to the location of the .maplet file and select the file.
5. Click Open.
9.4 Authoring Maplets • 345
Maple Document
To launch a Maplet application for which the Maple code is contained in a
Maple document, you need to execute the Maplet code. To display the Maplet
application, you must use the Maplets[Display] command. Note: The Maplet
code may be quite large if the Maplet application is complex. In this case,
execute the document to ensure user-defined procedures that are referenced
in the Maplet application are also defined.
Typical procedure:
Myproc:=proc...
with( Maplets[Elements] );
Maplet_name:=Maplet( Maplet_definition );
Maplets[Display]( Maplet_name );
simple Maplets. The Maplets package offers more capabilities, control and
options when designing complicated Maplet applications.
Maplet Builder
To start the Maplet Builder:
• From the Tools menu, select Assistants, and then Maplet Builder.
• The Palette pane displays palettes, which contain Maplet elements, or-
ganized by category. For a description of the elements, see the
?MapletBuilder/Palette help page. The Body palette contains the most
popular elements.
• The Layout pane displays the visual elements of the Maplet.
• The Command pane displays the commands and corresponding actions
defined in the Maplet.
• The Properties pane displays the properties of an instance of a defined
element in the Maplet.
Button element
Label element
Plotter element
TextField element
1. From the Body palette, drag the Label element to the left column in
the Layout pane.
2. If necessary, resize the Maplet Builder to display the entire Layout pane.
1. From the Body palette, drag the Button element to the right
list contains the defined elements to which you can send information, in this
case, Plotter1 and TextField1. The List group box, located below the
Expression group box, displays the defined elements to which you can
the Expression group box. (Note: Do not include a semicolon (;) at the end
of the plot command). You can also double-click TextField1 in the List
c. Click Ok.
9.4 Authoring Maplets • 355
Maplets Package
When designing a complicated Maplet, the Maplets package offers greater
control. The Maplets[Elements] subpackage contains the elements available
when designing a Maplet application. After you define the Maplet, use the
Maplets[Display] command to launch the Maplet.
356 • 9 Maplets
Define the Maplet application. To suppress the display of the data structure
associated with the Maplet application, end the definition with a colon.
9.4 Authoring Maplets • 357
> PlottingMaplet:=Maplet(
BoxLayout(
BoxColumn(
# First Box Row
BoxRow(
# Define a Plot region
Plotter('reference' = Plotter1)
# End of first Box Row
),
# Second Box Row
BoxRow(
# Define a Label
Label("Enter a function of x "),
# Define a Text Field
TextField('reference' = TextField1),
# Define a Button
Button(caption="Plot", Evaluate(value = 'plot(TextField1,
x = -10..10)', 'target' = Plotter1))
# End of second Box Row
)
# End of BoxColumn
)
# End of BoxLayout
)
# End of Maplet
):
end use:
end proc:
Saving
When saving a Maplet, you can save the document as an .mw file or you
can export the document as a .maplet file.
Maple Document
To save the Maplet code as an .mw file:
3. Enter a filename.
4. Click Save.
If the document contains only Maplet code, it is recommended that you export
the document as a .maplet file.
Maplet File
To export the Maplet code as a .maplet file:
5. Click Save.
362 • 9 Maplets
10 Input, Output, and
Interacting with Other Products
10.1 In This Chapter
Section Topics
Writing to Files - Saving to Maple file • Saving Data to a File
formats • Saving Expressions to a File
Reading from Files - Opening Maple files • Reading Data from a File
• Reading Expressions from a File
Connectivity - Using Maple with other • Translating Maple Code to Other Program-
programming languages and software ming Languages
• Accessing External Products from Maple
• Accessing Maple from External Products
After using Maple to perform a computation, you can save the results to a
file for later processing with Maple or another program.
363
364 • 10 Input, Output, and Interacting with Other Products
to a file, allowing you to import the numbers into another program. To convert
a list or a list of lists to a Matrix, use the Matrix constructor. For more in-
formation, refer to the ?Matrix help page.
>
>
If the data is a Vector or any object that can be converted to type Vector,
use the ExportVector command. To convert lists to Vectors, use the Vector
constructor. For more information, refer to the ?Vector help page.
>
>
>
You can extend these routines to write more complicated data, such as
complex numbers or symbolic expressions. For more information, refer to
the ?ExportMatrix and ?ExportVector help pages.
10.2 Writing to Files • 365
For more information on matrices and vectors, see Linear Algebra (page 135).
>
In this example, small expressions are used. In practice, Maple supports ex-
pressions with thousands of terms.
>
>
>
Clear the memory using the restart command and retrieve the expressions
using the read command.
366 • 10 Input, Output, and Interacting with Other Products
>
>
>
For more information on writing to files, refer to the ?save help page.
• From the Tools menu, select Assistants, and then Import Data.
• Using the Select Data Source dialog, select the data file to import.
10.3 Reading from Files • 367
From the main window, you can preview the selected file, and specify the
source format, source form, and behavior on close. You can also select a
different file to be imported. Additional help is available from the Help menu
of the Import Data window.
ImportMatrix Command
The Import Data Assistant provides a graphical interface to the Import-
Matrix command. For more information, including options not available in
the assistant, refer to the ?ImportMatrix help page.
When you read a file with the read command, Maple treats each line in the
file as a command. Maple executes the commands and displays the results
in your document but it does not, by default, insert the commands from the
file in your document.
For example, the file ks.tst contains the following Maple commands.
S:= n -> sum( binomial( n, beta ) * ( ( 2*beta )! / 2^beta - beta!*beta ),
beta=1..n );
S(19);
When you read the file, Maple displays the results but not the commands.
>
If you set the interface echo option to 2, Maple inserts the commands from
the file into your document.
>
>
>
S:=n->sum(binomial(n,beta)*((2*beta)!/2^beta-beta!*beta),beta=1..n);
> S(19);
10.4 Exporting to Other Formats • 369
For more information, refer to the ?read and ?interface help pages.
HTML
The .html file that Maple generates can be loaded into any HTML browser.
Exported mathematical content can be displayed in one of the following
formats: GIF, MathML 2.0 Presentation, MathML 2.0 Content, or Maple
Viewer, and is saved in a separate folder. MathML is the Internet standard,
sanctioned by the World Wide Web Consortium (W3C), for the communic-
ation of structured mathematical formulae between applications. For more
information about MathML, refer to the ?MathML help page.
Maple documents that are exported to HTML translate into multiple docu-
ments when using frames. If the frames feature is not selected, Maple creates
only one page that contains the document contents.
LaTeX
The .tex file generated by Maple is ready for processing by LaTeX. All dis-
tributions of Maple include the necessary style files. By default, the LaTeX
style files are set for printing the .tex file using the dvips printer driver. You
can change this behavior by specifying an option to the \usepackage LaTeX
command in the preamble of your .tex file. For more information, refer to
the ?exporttoLaTeX help page.
370 • 10 Input, Output, and Interacting with Other Products
Maple Input
You can export a Maple document as Maple input so that it can be loaded
using the Maple Command-line version.
Maplet Application
The Export as Maplet facility saves a Maple document as a .maplet file,
so that you can run it using the command-line interface or the
MapletViewer. The MapletViewer is an executable program that can launch
saved Maplet applications. It displays and runs Maplet applications independ-
ently of the Maple Worksheet interface.
For information on using the MapletViewer, see Using Maplets (page 344).
Maple Text
Maple text is marked text that retains the distinction between text, Maple
input, and Maple output. Thus, you can export a document as Maple text,
send the text file by email, and the recipient can import the Maple text into
a Maple session and regenerate the computations in the original document.
Plain Text
Export a Maple document as plain text so that you can open the text file in
another application.
10.4 Exporting to Other Formats • 371
Summary of Translation
MapleNet
Overview of MapleNet
Using MapleNet, you can deploy Maple content on the Web. Powered by
the Maple computation engine, MapleNet allows you to embed dynamic
formulas, models, and diagrams as live content in Web pages. The MapleNet
software is not included with the Maple software. For more information on
MapleNet, visit http://www.maplesoft.com/maplenet.
10.4 Exporting to Other Formats • 373
Maple T.A.
Overview of Maple T.A.
Maple T.A. is a Web-based automated testing system, based on the Maple
engine. Instructors can use pre-written questions or create custom question
banks and then choose from these questions to form quizzes and assignments.
Maple T.A. automatically grades responses as students complete assignments
and tests. For more information, visit http://www.maplesoft.com/mapleta.
10.5 Connectivity
Translating Maple Code To Other Programming
Languages
Code Generation
The CodeGeneration package is a collection of commands and subpackages
that enable the translation of Maple code to other programming languages.
Languages currently supported include C, Fortran77, Java, MATLAB®, and
Visual Basic®.
External calling can also be applied to functions other than numerical al-
gorithms. Routines exist that accomplish a variety of non-mathematical tasks.
You can use these routines in Maple to extend its functionality. For example,
you can link to controlled hardware via a serial port or interface with another
program. The Database Integration Toolbox uses external calling to allow
you to query, create, and update databases in Maple. For more information,
visit http://www.maplesoft.com/products/toolboxes.
10.5 Connectivity • 375
Mathematica Translator
The MmaTranslator package provides translation tools for converting
Mathematica® expressions, command operations, and notebooks to Maple.
The package can translate Mathematica input to Maple input and Mathematica
notebooks to Maple documents. The Mma subpackage contains commands
that provide translation for Mathematica commands when no equivalent
Maple command exists. In most cases, the command achieves the translation
through minor manipulations of the input and output of similar Maple com-
mands.
Matlab Package
The Matlab package enables you to call selected MATLAB functions from
a Maple session, provided you have MATLAB installed on your system.
To enable the Maple Excel Add-in in Excel 2000, Excel 2003, or Excel
XP:
More information is available in the Using Maple in Excel online help file
within Excel.
OpenMaple
OpenMaple is a suite of functions that allows you to access Maple algorithms
and data structures in your compiled C, Java, or Visual Basic programs.
(This is the reverse of external calling, which allows access to compiled C,
Fortran77, and Java code from Maple.)
To run your application, Maple 9 or later must be installed. You can distribute
your application to any licensed Maple 9 or later user. For additional terms
and conditions on the use of OpenMaple, refer to extern/OpenMapleLicens-
ing.txt in your Maple installation.
10.5 Connectivity • 377
379
380 • Index
updating, 9 D
with uncertainty, 114 Data Analysis Assistant, 173
with units, 102 Database Integration Toolbox, 374
conditional execution, 322 data structures, 10, 285
constants, 10 creating, 285
content command, 134 datatype option, 142
context default content, 53
of unit, 98 default Maple style set, 247
context menus, 20, 46, 123, 148, 298 degree
customizing animations, 228 command, 133
equation, 78 polynomials, 132
integer, 46, 71 denom command, 302
Plot Builder, 28 derivatives, 155
convert command, 307 directional, 159
base option, 75, 331 partial, 156
degrees option, 307 Tutor, 181
mathematical functions, 308 dictionary, 33, 180
polynom option, 162 dictionary topic
set option, 308 adding hyperlink to, 282
temperature option, 100 diff command, 89, 157
units option, 99, 308 differential equations
copy, 236 ordinary, 89
correlation, 114 partial, 93
coulditbe command, 119 differentiation, 155
covariance, 114 with uncertainty, 114
cross product, 148 with units, 103
Curl command, 167 Differentiation Methods Tutor, 182
Curve Fitting Digits environment variable, 69
Assistant, 134 dimension, 97, 149
package base, 97
PolynomialInterpolation com- Directional Derivative Tutor, 159
mand, 134 discrim command, 134
cut and paste display
in tables, 254 bookmark, 264
hidden formatting attributes, 238
distribution
Index • 383
Q rank, 149
QPSolve command, 172 rational expressions
QR factorization, 151 entering, 5
quadratic programs, 172 read
quantities with uncertainty, 112 from files, 366
accessing error, 112 recurrence relation
accessing value, 112 solving, 96
computing with, 114 reference
constructing, 112 equation labels, 59
element properties, 113 names, 55
rounding the error, 113 relational operators, 322
scientific constants, 113 remainder
with units, 113 integer, 73
quick rem command, 126
character formatting, 233 remove command, 335
help, 32 repetition statements, 325
paragraph formatting, 235 reserved names, 57
reference card, 32 restart command, 58
quit statement, 332 resultant command, 134
quo command, 126 return
quotes statement, 332
double, 297 values, 339
left single, 58 rhs command, 301
right single, 57, 317 right-hand side, 301
unevaluation, 317 right single quotes, 57, 317
quotient RootOf structure, 83
integer, 73 roots
command, 134
R of equations, 83
random row vector
matrices, 142 creating, 142
variables, 173 rsolve command, 96
randpoly command, 134
range S
in plots, 218 scatter plot, 177
operator, 145 scientific constants, 105
Index • 393