UserManual 2018 PDF
UserManual 2018 PDF
Adobe and Acrobat are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Java and all Java based marks are trademarks or registered trademarks of Oracle and/or its affiliates.
ISBN 978-1-926902-45-6
Contents
Preface ........................................................................................................................................... xiii
1 Getting Started ................................................................................................................................. 1
1.1 In This Chapter .......................................................................................................................... 1
1.2 Introduction to Maple .................................................................................................................. 2
Working in Maple ....................................................................................................................... 2
Starting the Standard Document Interface ........................................................................................ 4
Entering 2-D Math ...................................................................................................................... 5
Toolbar Options .......................................................................................................................... 8
The Context Panel and Copy & Drag ............................................................................................ 11
Saving a Maple Document .......................................................................................................... 14
Saving a Maple Document as a Workbook ..................................................................................... 14
1.3 Entering Expressions ................................................................................................................. 14
Execution Groups ...................................................................................................................... 14
Math Mode vs. Text Mode .......................................................................................................... 15
Palettes ................................................................................................................................... 16
Symbol Names ......................................................................................................................... 22
Toolbar Icons ........................................................................................................................... 24
1.4 Point-and-Click Interaction ......................................................................................................... 25
Assistants ................................................................................................................................ 25
Tutors .................................................................................................................................... 30
Math Apps ............................................................................................................................... 32
The Context Panel ..................................................................................................................... 32
Task Templates ......................................................................................................................... 33
Exploration Assistant ................................................................................................................. 35
1.5 Commands .............................................................................................................................. 37
The Maple Library .................................................................................................................... 37
Entering Commands .................................................................................................................. 38
Document Blocks ...................................................................................................................... 41
1.6 The Maple Help System ............................................................................................................. 43
Accessing the Help System ......................................................................................................... 43
Using the Help Navigator ........................................................................................................... 44
Viewing Help Pages as Documents ............................................................................................... 44
Viewing Examples in 2-D Math ................................................................................................... 44
Copying Examples .................................................................................................................... 45
1.7 Available Resources .................................................................................................................. 45
Resources Available through the Maple Help System ....................................................................... 45
Maple Tour and Quick Resources ................................................................................................. 46
Web Site Resources ................................................................................................................... 46
2 Document Mode .............................................................................................................................. 49
2.1 In This Chapter ......................................................................................................................... 49
2.2 Introduction ............................................................................................................................. 49
2.3 Entering Expressions ................................................................................................................. 50
Example 1 - Enter a Partial Derivative ........................................................................................... 51
Example 2 - Define a Mathematical Function ................................................................................. 51
2.4 Evaluating Expressions .............................................................................................................. 52
2.5 Editing Expressions and Updating Output ...................................................................................... 53
2.6 Performing Computations ........................................................................................................... 53
Computing with Palettes ............................................................................................................. 53
Computing with the Context Panel ............................................................................................... 54
Assistants and Tutors ................................................................................................................. 58
3 Worksheet Mode ............................................................................................................................. 61
iii
iv • Contents
ix
x • List of Figures
xi
xii • List of Tables
Preface
Maple Software
MapleTM software is a powerful system that you can use to solve mathematical problems from simple to complex. You
can also create professional quality documents, presentations, and custom interactive computational tools in the Maple
environment.
You can access the power of the Maple computational engine through a variety of interfaces.
Interface Description
Standard (default) A full-featured graphical user interface that helps you create electronic documents to show all
your calculations, assumptions, and any margin of error in your results. You can also hide the
computations to allow your reader to focus on the problem setup and final results. The advanced
formatting features lets you create the customized document you need. Because the documents
are live, you can edit the parameters and, with the click of a button, compute the new results.
The Standard interface has two modes: Document mode and Worksheet mode.
Classic A basic worksheet environment for older computers with limited memory. The Classic interface
does not offer all of the graphical user interface features that are available in the Standard
interface. The Classic interface has only one mode, Worksheet mode.
Command-line version A command-line interface for solving very large complex problems or batch processing with
scripts. No graphical user interface features are available.
MapletTM Applications Graphical user interfaces containing windows, textbox regions, and other visual interfaces,
which gives you point-and-click access to the power of Maple. You can perform calculations
and plot functions without using the worksheet.
This manual describes how to use the Standard interface. As mentioned, the Standard interface offers two modes:
Document mode and Worksheet mode. Using either mode, you can create high quality interactive mathematical docu-
ments. Each mode offers the same features and functionality, the only difference is the default input region of each
mode.
The keystrokes given in this document are for Windows. There will be differences for other platforms. If you are using
a different platform, see Shortcut Keys.
Command Completion
• Esc, Macintosh, Windows, and Linux
• Ctrl + Space, Windows
• Ctrl + Shift + Space, Linux
Begin entering a command in a Maple document. Press the Esc key. Alternatively, use the platform-specific keys. For
Windows, press and hold the Ctrl key and then press the Space bar.
For more information on Command Completion, see Command Completion (page 39).
In This Manual
This manual provides an introduction to the following Maple features:
• Ease-of-use when entering and solving problems
xiii
xiv • Preface
• Point-and-click interaction with various interfaces to help you solve problems quickly
• Maple commands and standard math notation
• Clickable Calculus
• The help system
• Online resources
• Performing computations
• Creating plots and animations
• The Maple programming language
• Using and creating custom Maplet applications
• 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 first-time Maple users and users looking for a little more information.
Conventions
This manual uses the following typographical conventions.
• bold font - Maple command, package name, option name, dialog, menu, or 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].
1 Getting Started
Don't worry about your difficulties in Mathematics. I can assure you mine are still greater.
~Albert Einstein
Mathematics touches us every day—from the simple chore of calculating the total cost of our purchases to the complex
calculations used to construct the bridges we travel.
To harness the power of mathematics, Maplesoft provides a tool in an accessible and complete form. That tool is Maple.
1
2 • 1 Getting Started
Alternatively:
Alternatively:
1. Add the Maple directory (for example, /usr/local/maple/bin) to your command search path.
2. Enter xmaple.
When the first Maple session opens, a Start Page displays shortcuts to useful tasks and topics.
or
• From the File menu, select New, and then either Document Mode or Worksheet Mode. A blank document displays.
You can opt to start Maple with a blank document instead of the start page. You can also replace the default start page
with a custom start page. For instructions, refer to the startpage help page.
To invoke the Start Page at any time, click the home button ( ) on the worksheet toolbar.
Document Mode
Document mode uses Document Blocks as the default input region to hide Maple syntax. A Document Block region
is indicated by two triangles located in the vertical Markers column along the left pane of the Maple Document, .
If the Markers column is not visible, open the View menu and select Markers. This allows you to focus on the problem
instead of the commands used to solve the problem. For example, when using the context-sensitive operations from
the Context Panel on Maple input in Document mode (invoked by moving your mouse cursor over your input expression,
then selecting the appropriate operation from the displayed context panel), input and output are connected using an
arrow or equal sign with self-documenting text indicating the calculation that had taken place. The command used to
solve this expression is hidden.
Worksheet Mode
Worksheet mode uses a Maple prompt as the default input region. The Maple input prompt is a red angle bracket, .
When using context-sensitive operations on input in Worksheet mode, all commands are displayed.
1.2 Introduction to Maple • 5
For example, you can hide commands in Worksheet Mode by adding a document block from the Edit menu, Edit →
Document Blocks→ Create Document Block (see Document Blocks (page 41)), or you can show commands in
Document mode by adding a Maple prompt from the Insert menu, Insert → Execution Group → Before / After
Cursor (see Input Prompt (page 62)).
This chapter discusses features common to both modes. Specific aspects of Document mode are explained in Document
Mode (page 49), and aspects of Worksheet mode are explained in Worksheet Mode (page 61).
Navigation of Workbook files is accomplished through the workbook Navigator palette, available in the Workbook
tab. For more information, see The Workbook Navigator.
Common Operations
To enter a power:
1. Enter the base.
2. Press the caret (^) key.
3. Enter the exponent, which displays in math as a superscript.
4. To leave the exponent, press the right arrow key.
To enter a product:
1. Enter the first factor.
2. Press the asterisk (*) key, which displays in 2-D Math as a dot, .
3. Enter the second factor.
Implied Multiplication:
In general, the best practice is to enter a multiplication symbol (*) for multiplication in any calculation. In some cases,
you can instead insert a space character between two quantities to multiply them. This is called implicit multiplication.
For example, in the expression a space is used for the multiplication 4*a*c and 2*a.
In the case of a number followed by a variable, Maple interprets the expression as meaning multiplication even without
the presence of * or a space character.
However, it's easier to identify and correct mistakes in your formulas if you use the multiplication symbol (*) regularly.
Important: Maple interprets a sequence of letters, for example, , as a single variable. To specify the product of
two variables, you must insert a space character (or multiplication operator), for example, or . For more inform-
ation, refer to the 2DMathDetails help page.
Shift + *
explicit multiplication
/ (forward slash)
fraction
// (two forward slashes)
Shift + ^
exponent (superscript)
Ctrl + Shift + _ (Command + Shift + _ in
indexed subscript
Mac)
literal subscript (subscripted __ (two underscores)
variable name)
navigating expressions Arrow keys
1.2 Introduction to Maple • 7
use the right arrow key to leave a denominator, numerator, superscript, or subscript region
For a complete list of shortcut keys, refer to the 2-D Math Shortcut Keys 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 The Maple Help System (page 43).
3. Enter 2.
4. Press the right arrow key. The cursor moves right and out of the superscript position.
6. Enter y.
10. Enter the / symbol. The cursor moves to the denominator, with the entire expression in
the numerator.
11. Enter 2.
12. Press the right arrow key to move right and out of the denominator position.
To execute 2-D Math, you can use any of the following methods.
• Pressing Ctrl + = (Command + = in Mac). That is, press and hold the Ctrl (or Command) key, and then press the
equal sign (=) key. This evaluates and displays results inline.
• Pressing the Enter key. This evaluates and displays results on the next line and centered.
• Select the input and from the context panel, select Evaluate and Display Inline. See The Context Panel (page 32)
for more details.
• Using the Edit menu items Evaluate and Evaluate and Display Inline.
Toolbar Options
The Maple toolbar offers several buttons to assist you when interacting with Maple. See Table 1.2.
Save the active document or worksheet From the File menu, select Save...
Print the active document or worksheet From the File menu, select Print...
Print preview the active document or worksheet From the File menu, select Print
Preview...
Cut the selection to the clipboard From the Edit menu, select Cut
Copy the selection to the clipboard From the Edit menu, select Copy
Paste the clipboard contents into the current document From the Edit menu, select Paste
or worksheet
Undo the last operation From the Edit menu, select Undo
Redo the last operation From the Edit menu, select Redo
1.2 Introduction to Maple • 9
Inserts Maple Input after the current execution group. From the Insert menu, select
For details, refer to Execution Groups (page 14). Execution Group and then After
Cursor
Encloses the selection in a document block. If nothing From the Edit menu, select Document
is selected, it creates a new document block. Blocks and then Create Document
Block
Encloses the selection in a subsection. For details, From the Format menu, select Insert
refer to Sections (page 231). Section
Remove one level of indentation enclosing the From the Format menu, select Remove
selection. Section
Move backward to previous document in the hyperlink
history
Open the start page
Opens the Maple help system in a new window. For From the Help menu, select Maple
details, refer to The Maple Help System (page 43). Help.
Search box provides quick access to the help system.
For 1-D Math and text regions, the Tab icon in the toolbar allows you to set the Tab key to move between placeholders
(or cells in a table) or to indent text.
The Tab icon is disabled when using 2-D Math (Math mode), and as such, the Tab key allows you to
move between placeholders.
Toolbar icons are controlled by the location of the cursor in the document. For example, place the cursor at an input
region and the Text and Math icons are accessible while the others are dimmed. See Table 1.4 for a list of the tools
available in each icon.
Math tools
Drawing tools
Animation tools
The Text and Math icons allow you to enter text and math in the same line by choosing the appropriate input style at
each stage when entering the sentence.
is
For an example, see Example 6 - Enter Text and 2-D Math in the Same Line Using Toolbar Icons (page 24).
1.2 Introduction to Maple • 11
The meaning of the Text and Math icons differs while at a Maple input prompt. The Math icon displays input as 2-D
Math, whereas the Text icon displays Maple input. For details, refer to Math Mode vs. Text Mode (page 15).
>
> x^2/2;
To access the tools available in the Plot and Drawing icons, click a plot region. These tools allow you to manipulate
the plot or draw shapes and enter text on the plot region. By clicking an animation region, you have the same features
available for a plot region, in addition to tools for playing the animation in the Animation icon. For details on plots
and animations, refer to Plots and Animations (page 187).
For the remaining icons, hover the mouse over the icon to display the icon description.
Context Panel
Maple dynamically generates a collection of of applicable options when you select or hover your mouse over an object,
expression, or region. The options are organized and collectively displayed in the context panel to the right-hand side
of the Maple user interface. The options available in the context panel depend on the selected input region. For example,
you can manipulate and graph expressions, enhance plots, format text, manage palettes, structure tables, and more.
When using menu items from the context panel to perform an action on an expression, the input and output are connected
with a self-documenting arrow or equal sign indicating the action that had taken place. For more information, see The
Context Panel (page 32).
That is, highlight the region you want to copy. Press and hold the Ctrl key while you drag the input to the new region
using the mouse. The analogous operation on Mac uses the Command key.
Example 2 - Solve and Plot an Equation Using Context Panel Options and Copy & Drag
Review the following example:
In this example, you will enter the equation and then solve and plot the equation using the context panel and the copy
& drag feature. This example will only refer to the keystrokes needed on a Windows operating system to invoke the
context panel and the copy & drag feature. For your operating system, refer to section Shortcut Keys by
Platform (page xiii) for the equivalent keystrokes.
12 • 1 Getting Started
Input:
Result:
A brief description, "move to left" is displayed above the arrow that connects the input and output.
3. Right-click the output from the previous action, , and select Solve → Isolate Expression for → x.
Input:
Result:
1.2 Introduction to Maple • 13
Now that we have solved the equation, we can plot it. To do this, we will copy the equation to a new document block
and use the context panel again.
4. From the Edit menu, select Document Blocks→ Create Document Block.
5. To copy the expression , highlight this expression from the previous line. Press and hold the Ctrl key and
drag the expression to the new document block region.
Result:
14 • 1 Getting Started
Input:
Result:
Execution groups are the fundamental computation and documentation elements in the document. If you place the
cursor in an input command and press the Enter or Return key, Maple executes all of the input commands in the
current execution group.
1.3 Entering Expressions • 15
> a*int(exp(sqrt(2)*x),x);
> limit(f(x),x=infinity);
In Document Mode, to enter input using Maple Input mode, insert a Maple prompt by clicking in the toolbar, and
then click the Text button in the toolbar. In Worksheet Mode, simply click the Text button. See Figure 1.2.
Access from the Insert → 2-D Math menu. Access from the Insert → Maple Input menu.
When using 2-D Math, the Math mode icon is highlighted in the When entering Maple Input or text in a text region, the Text mode
toolbar, . icon is highlighted in the toolbar, .
In Document Mode (or a document block), input is entered in a In Document Mode (or a document block), input is entered with
document block with a slanted cursor, . a vertical cursor, as plain text, .
In Worksheet Mode, input is made at an input prompt with a In Worksheet Mode, input is made at an input prompt with a
If you prefer 1-D Math input in Worksheet mode, you can change the default math input notation.
To change math input notation for a session or globally across all documents:
1. From the Tools menu, select Options. The Options Dialog opens.
2. Click the Display tab.
3. In the Input Display drop-down list, select Maple Notation.
4. Click the Apply to Session or Apply Globally button.
Important: The new input display becomes the default setting after pressing the Enter key.
Palettes
Palettes are collections of related items that you can insert into a document by clicking or drag-and-dropping. The
Maple environment provides access to over 30 palettes containing items such as symbols , layouts math-
By default, palettes are displayed in the left pane of the Maple environment when you launch Maple. If the palettes
are not displayed,
1. From the View menu, select Palettes.
2. Select Expand Dock.
3. Right-click (Control-click, Mac) the palette dock. From the context menu, select Show All Palettes.
Alternatively, from the main menu, select View → Palettes → Arrange Palettes to display specific palettes.
You can create a Favorites palette of the expressions and entities you use often by right-clicking (Control-click, Mac)
the palette template you want to add and selecting Add To Favorites Palette from the context menu.
1.3 Entering Expressions • 17
Common Symbols,
Relational ,
Relational Round ,
Operators ,
Large Operators ,
Negated ,
Fenced ,
Arrows ,
Constants and Symbols .
Punctuation - insert punctuation symbols, such as inserting the registered trademark and
copyright symbols into text regions
Miscellaneous - insert miscellaneous math and other symbols outside the above categories
.
18 • 1 Getting Started
Matrix - enter the number of rows and columns required, designate type, such as zero-filled,
and designate shape, such as diagonal.
Layout - add math content that has specific layout, such as expressions with one or more
Units (SI) - insert a unit from the International System of Units (SI), or any general unit
.
Units (FPS) - insert a unit from the Foot-Pound-Second System (FPS), or any general unit
.
Accents - insert decorated names, such as an with an arrow over it to denote a vector .
Group Constructors - a palette for constructing groups based on the Group Theory package
1.3 Entering Expressions • 19
Favorites - add templates that you use most often from other palettes.
MapleCloud - view worksheets shared by other users and share your worksheets.
Variables - manage all of your assigned variables in your current Maple session.
Task Palettes Live Data Plots - templates for visual representation of your data.
eBook Metadata - markup tags for use when creating eBooks from Maple worksheets
Tasks - a palette where you can store tasks that you have created
To add a palette:
1. Right-click the palette dock. Maple displays a context
menu near the palette.
2. From the context menu, select Show Palette and then
select the palette.
Handwriting Palette
The Handwriting palette provides another way to find and insert desired symbols easily.
1. Draw the symbol with your mouse in the space provided.
2. Click the recognize button, . Maple matches your input against symbols available in the system.
See Figure 1.3.
3. To view more symbols (where indicated with a box around the result), click the displayed symbol and choose one
of the selections from the drop-down menu.
4. To insert a symbol, click the displayed symbol.
Snippets Palettes
You can create your own custom Snippets palettes for tasks that you find most useful. Details on how to create and
customize Snippets palettes can be found on the createpalette help page.
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 in your document. All common mathematical symbols, including all Greek characters, , and the square root
symbol ( ), are recognized by Maple.
Note: If you hover the mouse pointer over a palette item, a tooltip displays the symbol's name.
1.3 Entering Expressions • 23
To insert a symbol, enter the first few characters of a symbol name using a keyword that is familiar to you and then
press the completion shortcut key, Esc (see Shortcut Keys by Platform (page xiii)). Symbol completion works in the
same way as command completion (see Command Completion (page 39)).
• If a unique symbol name matches the characters entered, Maple inserts the corresponding symbol.
• If multiple symbol names match the characters entered, Maple displays the completion list, which lists all matches,
including commands. To select an item, click its name or symbol.
In Maple, the default display for imaginary i is a capital . When you simply type the letter in Math mode, it is in
italics. This letter is just a variable, and is not the same as the imaginary unit denoted by or in Maple.
We will compute the result two ways, using and then using . The first way is the quickest to enter.
The next method, while not as quick to enter, displays the computation using lowercase i.
24 • 1 Getting Started
For more information on entering complex numbers, refer to the HowDoI/EnterAComplexNumber help page.
Toolbar Icons
In the introduction section, you learned about the toolbar icons and context toolbars available in Maple (see Toolbar
Options (page 8)). The toolbar can be used to format your document, alter plots and animations, draw in a canvas,
write in both Math and Text modes in one line and much more. The last of these is demonstrated in the next example.
Example 6 - Enter Text and 2-D Math in the Same Line Using Toolbar Icons
Enter the following sentence:
Evaluate
17. Put the cursor after the expression and click the Text icon
in the toolbar, then enter the rest of the sentence: " and
write in simplest terms."
Note: When an expression is intended for display purposes only, it can be made nonexecutable.
Assistants
Maple offers a set of assistants in the form of graphical user interfaces to perform many tasks without the need to use
any syntax. An example of an assistant is shown in Figure 1.4.
26 • 1 Getting Started
Using the Tools → Assistants menu, you can access tools to help you accomplish various tasks. See Figure 1.5. In
some cases, you can launch an assistant by entering an expression and selecting the assistant from the options in the
Context Panel.
1.4 Point-and-Click Interaction • 27
4. In this dialog, you can plot the data and several types of
interpolations, including Polynomial, Spline, and Least
Squares. For example, click the Plot button in the
Polynomial Interpolation section. The polynomial is plotted
with the data, and the interpolating function is displayed
below.
Descriptions of Assistants
The available assistants are described below. Some of the assistants are interfaces to package commands. For more
information on package commands, see Package Commands (page 38).
• Back-Solver - an interface that allows you to take a mathematical formula, involving multiple parameters, enter
values for all but one of the parameters and solve for the remaining value. You can also plot the behavior of the
formula as one of the parameters change.
• CAD Link - an interface to explore the properties of models from supported CAD applications (available on Microsoft
Windows only).
• Code Generation - an interface to automatically transform Maple expressions and programs to other languages.
• Curve Fitting - an interface to commands in the CurveFitting package. Data points can be entered as independent
and dependent values, and interpolated with polynomials, rational functions, or splines.
• Data Set Search - an interface for searching built-in and online data sources.
• Data Analysis - an interface to the data analysis commands in the Statistics package.
• eBook Publisher - an interface to the eBook Publisher tools.
• Equation Manipulator - an interface for interactively performing a sequence of operations on an equation. You
can group terms, apply an operation to both sides of the equation, complete the square, and so on.
• Import Data - an interface to read data from an external file into Maple.
30 • 1 Getting Started
• Installer Builder - an interface to the InstallerBuilder package in which you can create installers for your Maple
toolboxes.
• Library Browser - an interface to manipulate the libraries in a specified directory.
• Maplet Builder - an interface to the Maplets package. The Maplets package contains commands for creating and
displaying Maplet applications (point-and-click interfaces). Using the Maplet Builder, you can define the layout of
a Maplet, drag-and-drop elements (visual and functional components of Maplets), set actions associated with elements,
and directly run a Maplet application. The Maplet Builder is available in the Standard interface only.
• ODE Analyzer - an interface to obtain numeric or symbolic solutions to a single ordinary differential equation
(ODE) or a system of ODEs and plot a solution of the result.
• Optimization - an interface to the solver commands in the Optimization package. The Optimization package is a
collection of commands for numerically solving optimization problems, which involves finding the minimum or
maximum of an objective function possibly subject to constraints.
• Plot Builder - an interface for creating two and three-dimensional plots, animations, and interactive plots.
• Scientific Constants - an interface to over 20 000 values of physical constants and properties of chemical elements.
All of these constants come with the corresponding unit and, if applicable, with the uncertainty or error, that is, how
precisely the value of this constant is known.
• Special Functions - an interface to the properties of over 200 special functions, including the Hypergeometric,
Bessel, Mathieu, Heun and Legendre families of functions.
• Units Converter - an interface to convert between 500 units of measurement.
• Worksheet Migration - an interface to convert worksheets from Classic Maple (.mws files) to Standard Maple
(.mw files).
Tutors
Maple provides over 50 interactive tutors to aid in the learning of
• Precalculus
• Calculus
• Multivariate Calculus
• Vector Calculus
• Differential Equations
• Linear Algebra
• Numerical Analysis
• Complex Variables
These tutors are easily accessible in the Tools menu by selecting Tutors. See Figure 1.6.
1.4 Point-and-Click Interaction • 31
Some of the tutors can also be accessed through the Student package. The Differential Equations tutor, DE Plots, is
accessible through the DEtools package. For a definition of the term package, see Package Commands (page 38).
The Student package is a collection of subpackages designed to assist with the teaching and learning of standard un-
dergraduate mathematics. The subpackages contain many commands for displaying functions, computations, and the-
orems in various ways, and include support for stepping through important computations.
The interactive commands help you explore concepts and solve problems using a point-and-click interface. These
commands launch tutors that provide a graphical interface to some of the visualization and computation commands
described above. See Figure 1.7 for an example of one of the tutors.
For more information on the tutors and related resources for mathematics education, see Teaching and Learning with
Maple (page 151).
32 • 1 Getting Started
Math Apps
Maple provides Math Apps that offer interactive, entertaining ways to explore mathematical concepts, ranging from
Precalculus to Physics to Economics. A guide to these demonstrations is accessible in the Tools menu by selecting
Math Apps.
When performing calculations or manipulations on an expression, a self-documenting arrow or equal sign connects
the input and output, indicating the action that took place. See Figures 1.8 and 1.9 for two examples of context-sensitive
operations.
1.4 Point-and-Click Interaction • 33
Figure 1.9: Click the plot to see plot options in the context
panel
Task Templates
Task templates help you perform specific tasks in Maple, such as:
• performing a mathematical computation such as solving an equation symbolically or numerically, or determining
the Taylor approximation of a function of one variable
• constructing a Maple object such as a function
• creating a document such as an application
Each task contains a description along with a collection of content that you can insert directly into your document.
Content consists of 2-D mathematics, commands, embedded components (for example, buttons), and plots. You specify
the parameters of your problem and then execute the commands in the document. See Figure 1.10 for an example of
a Task Template.
34 • 1 Getting Started
Previewing Tasks
To preview Maple tasks,
• From the Tools menu, select Tasks, and then Browse. The Browse Tasks dialog opens and displays the list of tasks.
The tasks are sorted by subject to help you quickly find the desired task. In the Browse Tasks dialog, you can view
tasks without inserting them into your document.
• Click the Insert Default Content button. Maple inserts the default content. The default content level is set using
the Options dialog. For instructions, see the usingtasks help page.
• Click the Insert Minimal Content button. Maple inserts only the commands 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.
Note: You can view the history of previously inserted tasks. From the Tools menu, select Tasks. Previously selected
task names are displayed below the Browse menu item.
Before inserting a task, Maple checks whether the task variables have assigned values in your document. If any task
variable is assigned, the Task Variables dialog opens to allow you to modify the names. Maple uses the edited variable
names for all variable instances in the inserted task.
By default, the Task Variables dialog is displayed only if there is a naming conflict. You can set it to display every
time you insert a task.
To specify that the Task Variables dialog be displayed every time you insert a task:
1. From the Tools menu, select Options.
2. Click the Display tab.
3. In the Show task variables on insert drop-down list, select Always.
4. Click Apply to Session or Apply Globally, as necessary.
For more information on task templates, refer to the tasks help page.
Exploration Assistant
The Exploration Assistant allows you to interactively make parameter changes to expressions and view the result. The
assistant can be used with almost any Maple expression or command that has at least one variable or parameter.
If you enter integer ranges, only integer values are allowed for parameters. To allow floating-point values, enter floating-
point ranges.
Select skip for any of the parameters to leave that parameter as a variable.
36 • 1 Getting Started
4. Click Explore to continue to the Exploration Assistant. The assistant creates a table in the document. You can use
the slider or sliders to vary the parameters and see your changes as the expression output is updated.
5. Once you are finished interacting with the assistant, you can copy and paste the results into your document, or save
the interactive document for later use.
In this example, we will explore how the plot of changes as we vary the parameters and .
1.5 Commands
Even though Maple comes with many features to solve problems and manipulate results without entering any commands,
you may find that you prefer greater control and flexibility by using the set of commands and programming language
that Maple offers.
The main library contains the most frequently used Maple commands.
Packages contain related commands for performing tasks from disciplines such as Student Calculus, Statistics, or
Differential Geometry. For example, the Optimization package contains commands for numerically solving optimiz-
ation problems.
For details on top-level and package commands, see Commands (page 63).
38 • 1 Getting Started
Entering Commands
If you want to interact with Maple using commands, simply enter the command using 2-D math. Notice that commands
and variable names display in italics. Maple commands are constructed in a format similar to command(arguments),
based on the command you are using.
For a list of the top commands in Maple, see Top Commands (page 65).
Package Commands
There are two ways to access commands within a package, using the long form of the package command or the short
form.
1.5 Commands • 39
The long form specifies both the package and command names using the syntax package[command](arguments).
The short form makes all of the commands in the package available using the with command, with(package). If you
are using a number of commands in a package, loading the entire package is recommended. When you execute the
with command, a list of all commands in the package displays. To suppress the display of all command names, end
the with(package) command with a colon. Alternatively, you can load packages through the Tools menu, by selecting
Load Package, and then the package name.
After loading a package, you can use the short-form names, that is, the command names, without the package name.
For a list of the top packages in Maple, see Top Packages (page 66).
Command Completion
To help with syntax and reduce the amount of typing when entering Maple commands, you can use command completion.
Command completion displays a list of all Maple packages, commands, and functions that match the entered text. If
there are multiple ways to call a command, then the command completion list contains each one, with appropriate
placeholders.
4. Some inserted commands have placeholders, denoted by purple text. The first placeholder is highlighted after you
insert it into the document. Replace it with your parameter, then move to the next placeholder by pressing the Tab
key.
Equation Labels
Equation labels help to save time entering expressions by referencing Maple output. See Figure 1.11.
By default, equation labels are displayed. If equation labels are not displayed,
1. From the Tools menu, select Options, and click the Display tab. Ensure that the Show equation labels check box
is selected.
2. From the Format menu, select Equation Labels. Ensure that both Execution Group and Worksheet are selected.
The Label Reference menu item allows you to switch between the label name and its reference content. Place the
cursor on the referenced equation label and select Format → Equation Labels → Label Reference.
The label is associated with the last output within an execution group.
Document Blocks
In Document mode, content is created as a series of document blocks. Document blocks allow you to hide the syntax
used to perform calculations, which in turn lets you focus on the concept presented instead of the command used to
manipulate or solve the problem. You can also create document blocks in Worksheet mode to perform the same function.
Document blocks are typically collapsed to hide the Maple code, but these regions can also be expanded to reveal this
code.
From the Edit menu, select Document Blocks→ Create Document Block. If text or math in one or more execution
groups is selected, then a document block is created that contains those execution groups. If not, a new document block
is created after the current execution group. For more information, see the next example.
Document block regions are identified using markers that are located in a vertical bar along the left pane of the document.
See Figure 1.15. In addition to document block boundaries, these markers (icons) indicate the presence of hidden at-
tributes in the document such as annotations, bookmarks, and numeric formatting.
42 • 1 Getting Started
To activate markers:
With the Document Block expanded, you can see the Maple command that was used to perform this calculation. In
Figure 1.16, the solve command was used.
Also notice a red prompt (>) before the original expression and the solve command. Entering commands outside of a
document block region is done at this input region. To insert an input region, click the button in the toolbar menu.
In Figure 1.16, an equation label was used to refer to the expression. For more information, see Equation
Labels (page 40).
You can use this process of expanding document blocks to view and edit Maple commands within a document block.
You can specify which parts of the input and output are displayed when the document block is collapsed. For each
execution group in the block, you can choose to display either the input or the output.
• Place the cursor in the execution group.
• From the Edit→Document Blocks menu, select Toggle Input/Output Display.
Also, you can choose to display output either inline or centered on a new line.
• From the Edit→Document Blocks menu, select Inline Document Output.
1.6 The Maple Help System • 43
The Maple help system opens in a separate window with two panes. The left pane contains the Help Navigator where
you initiate searches and browse the table of contents, and the right pane displays the final search result, such as a
specific help page.
Every help page in Maple lists the command's calling sequence, parameters, and a description, with examples of the
command at the end of the page. Some help pages also contain hyperlinks to related help pages and hyperlinks to dic-
44 • 1 Getting Started
tionary definitions. Hyperlinks to dictionary definitions display in red to distinguish them from hyperlinks to help
pages.
Search results are displayed as a list in the Search Results tab of the left pane. Click the Table of Contents tab to
view a structured list of all topics in the help system.
Note that some tutorials open in a Maple window instead of in the Help window.
In the left pane, the type of resource is indicated by an icon. Table 1.11 describes the icons.
Icon Description
A folder icon in the Table of Contents tab indicates that a topic can be expanded into subtopics.
Question mark icon indicates a help page and displays the associated help page in the right pane when selected.
WS icon indicates an example worksheet. Example worksheets open in a new tab in the Maple document.
D icon indicates a definition and displays the associated dictionary definition in the right pane when selected.
T icon indicates a Task template and displays the associated Task Template in the right pane when selected.
M icon indicates a manual. Manuals open in a new tab in the Maple document.
The Maple help system allows you to open help pages as documents that you can execute.
To open a help page as a worksheet:
• With the help page displayed in the right pane of the help system, from the View menu, select Open Page as
Worksheet. A new worksheet tab opens and displays the help page as an executable document.
Alternatively, in the help system toolbar, click the open current help page in a worksheet window icon.
Note: Some input in help pages displays as 1-D Math, no matter which option you have chosen. This is for Maple
procedures and other code that is best input in 1-D Math. For more information, see the helpnavigator help page.
Copying Examples
Instead of opening the entire page as a document, you can copy the Examples section only.
To copy examples:
1. With the help page displayed in the right pane of the help system, from the Edit menu, select Copy Examples.
2. Close or minimize the Help Navigator and return to your document.
3. In your document, place the cursor at the location where you want to paste the examples.
4. From the Edit menu, select Paste. The Examples section of the help page is inserted as executable content in your
document.
Help Pages
Use the help system to find information about a specific topic, command, package, or feature. For more information,
see The Maple Help System (page 43).
Dictionary
More than 5000 mathematical and engineering terms with over 300 figures and plots.
1. From the Help menu, select Maple Help.
2. Enter a search term. Dictionary entries that match your query are displayed in the left pane with a icon.
Sample applications demonstrate how Maple can be used to find and document a solution to a specific problem. Some
applications allow for input or contain animations that you can run; however, their primary use is for demonstrations.
Topics include Bouncing Ball, Digital Filter Design, Frequency Domain System Identification, Harmonic Oscillator,
Image Processing, Radiator Design with CAD Systems, and Sunspot Periodicity.
Examples
Example worksheets are executable documents covering topics that demonstrate syntax or invoke a user interface to
make complex problems easy to solve and visualize. You can copy and modify the examples as needed. Topics include
Algebra, Calculus, Connectivity, Discrete Mathematics, General Numerics and Symbolics, and Integral Transforms.
• Explore the available topics in the Table of Contents under Applications and Example Worksheets.
Manuals
You can access all of Maple's manuals from within Maple, including the Maple Programming Guide and this manual.
You can execute examples, copy content into other documents, and search the contents using the Maple Help System.
• Access the manuals in the Table of Contents under Manuals.
Maple's manuals are also available as PDFs on the Maplesoft web site.
http://www.maplesoft.com/documentation_center
Task Templates
Set of commands with placeholders that you can use to quickly perform a task. For details, see Task Templates (page 33).
• From the Tools menu, select Tasks, and then Browse.
Maple Tour
The Maple Tour consists of interactive sessions on several of the following topics: Ten Minute Tour, Numeric and
Symbolic Computations, Matrix Computations, Differential Equations, Statistics, Programming and Code Generation,
Units and Tolerances, and Education Assessment with Maple T.A.TM
• From the Help menu, select Take a Tour of Maple.
Welcome Center
A Maple web site offering all of Maplesoft's key user resources in one central location. In the Welcome Center, you
can view sample applications, participate in user forums, and access premium content. You can also access our support
services, view training videos, download user manuals, and more.
http://www.maplesoft.com/welcome
1.7 Available Resources • 47
http://www.maplesoft.com/studentcenter
http://www.maplesoft.com/TeacherResource
Application Center
Maple web site resource for free applications related to mathematics, education, science, engineering, computer science,
statistics and data analysis, finance, communications, and graphics. Many applications are available in translations
(French, Spanish, and German).
http://www.maplesoft.com/applications
Training
Maplesoft offers a comprehensive set of complementary training materials. From complete training videos to recorded
training seminars to downloadable documentation, you have many options to get familiar with Maplesoft products. In
addition, custom training sessions can be created to meet your needs.
http://www.maplesoft.com/support/training
MaplePrimes
A web community dedicated to sharing experiences, techniques, and opinions about Maple and related products, as
well as general interest topics in math and computing.
http://www.mapleprimes.com
Online Help
All of Maple's help pages are available online.
http://www.maplesoft.com/support/help
Technical Support
A Maple web site containing FAQs, downloads and service packs, links to discussion groups, and a form for requesting
technical support.
http://www.maplesoft.com/support
2.2 Introduction
Maple has two modes: Document mode and Worksheet mode.
Document mode is designed for quickly performing 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.
Worksheet mode is designed for interactive use through commands and programming using the Maple language. The
Worksheet mode supports the features available in Document mode described in this chapter. For information on using
Worksheet mode, see Chapter 3, Worksheet Mode (page 61). Note: To enter a Maple input prompt while in Document
mode, click in the Maple toolbar.
49
50 • 2 Document Mode
Important: In any Maple document, you can use Document mode and Worksheet mode.
These features are described in Chapter 7, Creating Mathematical Documents (page 221).
Note: This chapter and Chapter 1 were created using Document mode. All of the other chapters were created using
Worksheet mode.
• Piecewise-continuous functions:
• Limits:
• Continued fractions:
• Numbers: integers, rational numbers, complex numbers, floating-point values, finite field elements, , , ...
• Operators: /, ...
• Constants: ...
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 and symbol names.
2.3 Entering Expressions • 51
To evaluate the derivative and display the result inline, press Ctrl+= (Command+=, for Macintosh) or Enter. For
more information, see Computing with Palettes (page 53).
You can enter any expression using symbol names and the symbol completion list.
Action Result in Document
1. Begin typing the name of the symbol,
diff, and press the symbol completion
key (see Shortcut Keys by
Platform (page xiii)).
Note: To insert the right arrow symbol , you can also enter the characters -> in Math mode. In this case, symbol
completion is automatic.
To the right of the expression, Maple inserts an equal sign and then the value of the expression.
In mathematical content, pressing Enter evaluates the expression and displays it centered on the following line. The
cursor moves to a new line below the output.
(2.1)
By default, Maple labels output that is generated by pressing Enter. For information on equation labels, see Equation
Labels (page 74). In this manual, labels are generally not displayed.
You can use the basic algebraic operators, such as and , with most expressions, including polynomials—see
Polynomial Algebra (page 116)—and matrices and vectors—see Matrix Arithmetic (page 129).
=
2.5 Editing Expressions and Updating Output • 53
Note: Be careful when you revisit a document and make changes, as it's possible to produce a document with worksheet
commands out of order (i.e. where a certain command won't work properly without a later one).
Note: The Document mode is designed for quick calculations, but it also supports Maple commands. For information
on commands, see Commands (page 63) in Chapter 3, Worksheet Mode (page 61).
Important: In Document mode, you can execute a statement only if you enter it in Math mode. To use a Maple command,
you must enter it in Math mode.
1. Using the Calculus palette, enter the partial derivative. See Example 1 - Enter a Partial Derivative (page 51).
2. Press Ctrl+= (Command+=, for Macintosh).
2. Move your mouse cursor over Pin Open Context Panel ( ), or click it to fix the context panel in place.
You can evaluate expressions using context panel options. The Evaluate and Display Inline operation (see Figure 2.1)
is equivalent to pressing Ctrl+= (Command+=, for Macintosh). That is, it inserts an equal sign (=) and then the value
of the expression.
Alternatively, press Enter to evaluate the expression and display the result centered on the following line.
From the context panel, you can also select operations different from evaluation. To the right of the expression, Maple
inserts a right arrow symbol (→) and then the result.
You can perform a sequence of operations by repeatedly using context panel options. For example, to compute the
derivative of use the Differentiate operation on the expression, and then to evaluate the result at a point,
use the Evaluate at a Point operation on the output and enter 10:
Note: For the sequence of operations to make sense when being read from left to right, stale results are deleted before
new operations are performed.
For example:
Enter the expression .
Click on the expression and use the Differentiate option from
the context panel to differentiate with respect to x.
Click on 2x and use the Integrate option from the context panel
to integrate with respect to x.
Click on 2x again and use the Differentiate option to differentiate
with respect to x.
The following subsections provide detailed instructions on performing a few of the numerous operations available using
context-sensitive operations in the context panel.
56 • 2 Document Mode
You can replace the inserted right arrow with text or mathematical content.
Note: To replace 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 ≈.
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 80).
To solve an equation:
1. Enter an equation.
2. Display the context panel. See Figure 2.3.
2.6 Performing Computations • 57
3. From the context panel, select Solve or Numerically Solve in the Solve menu item.
For more information on solving equations, including solving inequations, differential equations, and other types of
equations, see Solving Equations (page 86).
Using Units
You can create expressions with units. To specify a unit for an expression, use the Units palettes. The Units (FPS)
palette (Figure 2.4) contains important units from the foot-pound-second (FPS) system of units used in the United
States. The Units (SI) palette (Figure 2.5) contains important units from the international system (SI) of units.
For example, compute the electric current passing through a wire that conducts 590 coulombs in 2.9 seconds.
Assistants and tutors can be launched from the Tools menu or the Context Panel for an expression. For example, you
can use the Linear System Solving tutor to solve a linear system, specified by a matrix or a set of equations.
2.6 Performing Computations • 59
Example 3 - Using the Context Panel to Open the Linear System Solving Tutor
Use the Linear System Solving tutor to solve the following system of linear equations, written in matrix form:
For more information on linear systems and matrices, see Linear Algebra (page 122).
3 Worksheet Mode
The Worksheet mode of the Standard Worksheet interface is designed for:
• Interactive use through Maple commands, which offers advanced functionality and customized control not available
using the context panel or other syntax-free methods
• Programming using the powerful Maple language
Using Worksheet mode, you have access to all of the Maple features described in Chapter 1, and most of those described
in Chapter 2, including:
• Math and Text modes
• Palettes
• The context panel
• Assistants and tutors
For information on these features, see Chapter 1, Getting Started (page 1) and Chapter 2, Document Mode (page 49).
Note: Using a document block, you can use all Document mode features in Worksheet mode. For information on
document blocks, see Document Blocks (page 41).
Note: This chapter and the following chapters except Chapter 7 were created using Worksheet mode.
61
62 • 3 Worksheet Mode
Section Topics
Names (page 72) - References to the expressions you assign to • Assigning to Names
them • Unassigning Names
• Valid Names
Equation Labels (page 74) - Automatically generated labels that • Displaying Equation Labels
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.
>
(3.1)
>
(3.2)
A set of Maple input and its output are referred to as an execution group.
Suppressing Output
To suppress the output, enter a colon (:) at the end of the input.
>
As with 2-D math, in 1-D math, if you use a colon, Maple suppresses the output.
>
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.
> sqrt(4.4); tan(3.2);
If you do not specify a semicolon or colon, Maple interprets it as a single input. This can either give unexpected results
or an error. Notice that the following example gives an error in 1-D math but in 2-D math this is interpreted as multi-
plication.
> sqrt(4.4) tan(3.2)
Error, missing operator or `;`
>
3.3 Commands
Maple contains a large set of commands and a powerful programming language. Most Maple commands are written
using the Maple programming language.
You can enter commands using 1-D or 2-D Math. 1-D Math input is recommended when programming in Maple. Basic
Programming (page 287) provides an introduction to Maple programming.
To learn how to use Maple commands, see the appropriate help page, or use task templates. For more information, see
The Maple Help System (page 43) and Task Templates (page 70).
64 • 3 Worksheet Mode
For a complete list of packages and commands, refer to the index/help help pages. For information on the Maple Help
System, see The Maple Help System (page 43).
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.
For example, to differentiate an expression, use the diff command. The required parameters are the expression to dif-
ferentiate, which must be specified first, and the independent variable.
>
Mathematical Functions
For a complete list of commands that implement mathematical functions, such as BesselI and AiryAi, available in the
library, refer to the initialfunctions help page.
>
For detailed information on the properties of a function, use the FunctionAdvisor command.
>
This definition is displayed using the typeset form of the BesselI function, the hypergeometric function (hypergeom)
and the Gamma function (GAMMA). To see the function names rather than the typeset form, use lprint:
>
[BesselI(a, z) = z^a*hypergeom([], [a+1], (1/4)*z^2)/(GAMMA(a+1)*2^a), `with no restrictions
on `(a, z)]
For detailed information on how to use a function in Maple, refer to its help page.
3.3 Commands • 65
For example:
>
Another way to access help is to select the word for which you want help and use the shortcut key for context help, F2
(Control + Shift + ?, for Mac).
Top Commands
Here are a few of the most frequently used Maple commands. A complete list of top-level commands is available on
the index/function help page.
Package Commands
To use a package command, the calling sequence must include the package name, and the command name enclosed
in square brackets ([ ]).
package[command](arguments)
If you are frequently using the commands in a package, load the package.
To load a package:
• Use the with command, specifying the package as an argument.
The with command displays a list of the package commands loaded (unless you suppress the output by entering a colon
at the end of the calling sequence).
66 • 3 Worksheet Mode
After loading a package, you can use the short form names of its commands. That is, you can enter the commands
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:
• Use the unwith command, specifying the package as an argument.
>
Alternatively, use the restart command. The restart command clears Maple's internal memory. The effects include
unassigning all names and unloading all packages. For more information, refer to the restart help page.
Note: To execute the examples in this manual, you may be required to use the unassign or restart command between
examples.
Some packages contain commands that have the same name as a top-level command. For example, the plots package
contains a changecoords command. Maple also contains a top-level changecoords command.
>
After the plots package is loaded, the name changecoords refers to the plots[changecoords] command. To use the
top-level changecoords command, unload the package or use the restart command. (For alternative methods of accessing
the top-level command, see the rebound help page.)
Top Packages
Here are a few of the most frequently used Maple packages. A complete list of packages is available on the index/pack-
age help page.
3.4 Palettes
Palettes are collections of related items that you can insert by clicking or dragging. For example, see Figure 3.1.
68 • 3 Worksheet Mode
For example, evaluate a definite integral using the definite integration item in the Calculus palette.
>
1. Enter values in the placeholders. To move to the next placeholder, press Tab.
2. To evaluate the integral, press Enter.
>
In 1-D Math, clicking the definite integration item inserts the corresponding command calling sequence.
> int(f,x=x[1]..x[2]);
Specify the problem values (using the Tab to move to the next placeholder), and then press Enter. Note: If pressing
the Tab key inserts a tab, click the Tab icon in the toolbar.
> 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 viewing and using palettes, see Palettes (page 16) in Chapter 1.
3.5 The Context Panel • 69
You can use the context panel to perform operations on 2-D Math, including output.
2. Move your mouse cursor over Pin Open Context Panel ( ), or click it to fix the context panel in place.
3. From the context panel, select a tool or operation.
Determine the rational expression (fraction) that approximates the floating-point number .
Action Result in Document
1. Enter and execute the expression. >
(3.3)
Notice that an equation label reference has been used. For information on equation labels and equation label references,
see Equation Labels (page 74).
70 • 3 Worksheet Mode
For more information on the Context Panel, see Computing with the Context Panel (page 54) in Chapter 2.
For more information on assistants and tutors, see Assistants (page 25) in Chapter 1.
After inserting a task template, specify the parameters of your problem in the placeholders, and then execute the com-
mands, or click a button.
You can also browse the task templates in the Table of Contents of the Maple Help System.
3.8 Text Regions • 71
For details on inserting and using task templates, see Task Templates (page 33). You can also create your own task
templates for performing common tasks. For details, refer to the creatingtasks help page.
Note: The mathematical content in a text region is by default executable. To enter nonexecutable mathematical
content, use Shift + F5.
• Insert any palette item. Palette items are inserted in Math mode (2-D Math). Note: After you insert a palette item,
you must press F5 or click the toolbar icon to return to Text mode.
For more information on formatting documents, see Creating Mathematical Documents (page 221).
3.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 74).
Note: Through the Variable Manager you can manage the top-level assigned variables currently active in your Maple
Session. For more information about the Variable Manager, see the Variable Manager help page. For Maple workbooks,
you can use the Variable Manager palette to return to the saved state of your variables.
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.
>
>
Recall that you can enter using the following two methods.
• Use the Common Symbols palette.
• In 2-D Math enter pi, and then press the symbol completion shortcut key. See Shortcuts for Entering Mathematical
Expressions (page 6).
3.9 Names • 73
When Maple evaluates an expression that contains a name, it replaces the name with its value. For example:
>
For information on Maple evaluation rules, see Evaluating Expressions (page 279).
Mathematical Functions
To define a function, assign it to a name.
For example, define a function that computes the cube of its argument.
>
For information on creating functions, see Example 2 - Define a Mathematical Function (page 51).
>
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.
Protected Names
Protected names are valid names that are predefined or reserved.
>
Error, attempting to assign to `sin` which is protected. Try declaring `local sin`; see
?protect for details.
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
(' ').
>
74 • 3 Worksheet Mode
>
Right single quotes (unevaluation quotes) prevent Maple from evaluating the name. For more information on unevaluation
quotes, see Delaying Evaluation (page 285) or refer to the uneval help page.
The restart command clears Maple's internal memory. The effects include unassigning all names. For more information,
refer to the restart help page.
Note: To execute 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 sequence of alphanumeric and underscore (_) characters that begins with an alphabetical character.
• A sequence of characters enclosed in left single quotes (` `).
Important: Do not begin a name with an underscore character. Maple reserves names that begin with an underscore
for use by the Maple library.
>
(3.4)
Using equation labels, you can refer to the result in other computations.
>
(3.5)
3.10 Equation Labels • 75
For example:
4. Press *.
5. Press Ctrl+L (Command+L, for Macintosh).
6. In the Insert Label dialog, enter 3.5. Click OK.
7. To move to the variable of integration placeholder, press Tab.
>
8. Enter x.
(3.6)
76 • 3 Worksheet Mode
>
(3.7)
>
(3.8)
• Maple labels the output values sequentially. If you remove or insert an output, Maple automatically re-numbers all
equation labels and updates the label references.
• If you change the equation label format (see Label Numbering Schemes (page 76)), Maple automatically updates
all equation labels and label references.
For information on assigning to, using, and unassigning names, see Names (page 72).
For more information on equation labels, refer to the equationlabel help page.
The following chapters describe how to use Maple to perform tasks such as solving equations, producing plots and
animations, and creating mathematical documents. The chapters were created using Worksheet mode. Except where
noted, all features are available in both Worksheet mode and Document mode.
78 • 3 Worksheet Mode
4 Basic Computations
This chapter discusses key concepts related to performing basic 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 mathematical disciplines in the following chapter.
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
79
80 • 4 Basic Computations
Section Topics
Restricting the Domain (page 109) - How to restrict the domain • Real Number Domain
for computations • Assumptions on Variables
Numeric computation is the manipulation of expressions in the context of finite-precision arithmetic. Expressions in-
volving exact numbers, for example, are replaced by close approximations using floating-point numbers, for
example 1.41421. These computations generally involve some error. Understanding and controlling this error is often
of as much importance as the computed result.
In Maple, numeric computation is normally performed if you use floating-point numbers (numbers containing a
decimal point) or the evalf command. The plot command (see Plots and Animations (page 187)) uses numeric compu-
tation, while commands such as int, limit, and gcd (see Integer Operations (page 82) and Mathematical Problem
Solving (page 115)) generally use only symbolic computation to achieve their results.
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 and are symbolic objects. Names can be assigned exact quantities as
their values, and functions can be evaluated at symbolic or exact arguments.
>
Important: Unless requested to do otherwise (see the following section), Maple evaluates expressions containing exact
quantities to exact results, as you would do if you were performing the calculation by hand, and not to numeric approx-
imations, as you normally obtain from a standard hand-held calculator.
>
>
>
4.2 Symbolic and Numeric Computation • 81
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
Note: An alternative representation of floating-point numbers, called e-notation, may not include an explicit decimal
point: 1e5 , 3e-2 .
In the presence of a floating-point (approximate) quantity in an expression, Maple generally computes using numeric
approximations. Arithmetic involving mixed exact and floating-point quantities results in a floating-point result.
>
If a mathematical function is passed a floating-point argument, it normally attempts to produce a floating-point approx-
imation of the result.
>
>
By default, Maple computes such approximations using 10 digit arithmetic. You can modify this in one of two ways:
• Locally, you can pass the precision as an index to the evalf call.
>
• Globally, you can set the value of the Digits environment variable.
>
>
For more information, see the evalf and Digits help pages.
82 • 4 Basic Computations
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 Numerical Analysis. Some sources of error are:
• An exact quantity may not be exactly representable in decimal form: and are examples.
>
No correct digits remain. If, however, you use Maple to analyze this expression, and replace this form with a represent-
ation that is more accurate for small values of a fully accurate 10-digit result can be obtained.
>
>
For information on evaluating an expression at a point, see Substituting a Value for a Subexpression (page 279). For
information on creating a series approximation, see Series (page 139). For more information on floating-point numbers,
refer to the float and type/float help pages.
Note: Many integer operations are available as task templates (Tools→Tasks→Browse, under Integers).
You can quickly perform many integer operations using the context panel. Clicking on an integer, displays the context
panel with integer commands. For example, the context-sensitive operation Integer Factors applies the ifactor command
to compute the prime factorization of the given integer. See Figure 4.1.
4.3 Integer Operations • 83
>
(4.1)
>
(4.2)
Maple inserts the command ifactor, using an equation label reference to the integer 946929. For more information on
equation labels, see Equation Labels (page 74).
For more information on using context-sensitive operations in Worksheet mode, see The Context Panel (page 69). For
information on using context-sensitive operations in Document mode, see Computing with the Context Panel (page 54).
Maple has many other integer commands, including those listed in Table 4.1.
Command Description
abs absolute value (displays in 2-D math as )
factorial factorial (displays in 2-D math as )
ifactor prime 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 84).)
NumberTheory[Divisors] set of positive divisors
84 • 4 Basic Computations
>
>
>
>
For information on finding integer solutions to equations, see Integer Equations (page 97).
Non-Base 10 Numbers
To represent an expression in another base, use the convert command.
>
>
For information on enclosing keywords in right single quotes ('), see Delaying Evaluation (page 285).
>
Note: The convert/base command returns a list of digit values in order of increasing significance.
>
By default, the mod operator uses positive representation (modp command). Symmetric representation is available
using the mods command.
>
>
For information on setting symmetric representation as the default, refer to the mod help page.
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, \^.
For information on solving an equation modulo an integer, see Integer Equations in a Finite Field (page 98).
The mod operator also supports polynomial and matrix arithmetic over finite rings and fields. For more information,
refer to the mod help page.
Gaussian Integers
Gaussian integers are complex numbers in which the real and imaginary parts are integers.
The GaussInt package contains commands that perform Gaussian integer operations.
>
In Maple, complex numbers are represented as a+b*I, where the uppercase I represents the imaginary unit .
You can also enter the imaginary unit using the following two methods.
• In the Common Symbols palette, click the , or item. See Palettes (page 16).
• Enter i or j, and then press the symbol completion key. See Symbol Names (page 22).
Note that the output will still be displayed with I, no matter what symbol was used for input. You can customize Maple's
settings to use a different symbol for . For more information on entering complex numbers, including how to
customize this setting, refer to the HowDoI/EnterAComplexNumber help page.
The GIsqrt command approximates the square root in the Gaussian integers.
>
For more information on Gaussian integers including a list of GaussInt package commands, refer to the GaussInt
help page.
Note: Many solve operations are available in the context panel and as task templates (Tools→Tasks→Browse). Most
of this section focuses on other methods.
In Worksheet mode, Maple inserts a calling sequence that solves the equation followed by the solutions.
>
(4.3)
>
(4.4)
>
(4.5)
>
(4.6)
88 • 4 Basic Computations
For information on solving equations and inequations symbolically using the solve command, see the following section.
For information on solving equations numerically using the fsolve command, see Numerically Solving
Equations (page 90).
>
In general, solve computes solutions in the field of complex numbers. To restrict the problem to only real solutions,
see Restricting the Domain (page 109).
It is recommended that you verify the solutions returned by the solve command. For details, see Working with
Solutions (page 91).
To return the solutions as a list, enclose the calling sequence in brackets ([ ]).
>
Expressions: You can specify expressions instead of equations. The solve command automatically equates them to
zero.
>
Multiple Equations: To solve multiple equations or inequations, specify them as a Creating and Using Data
Structures (page 263).
>
>
Solving for Specific Unknowns: By default, the solve command returns solutions for all unknowns. You can specify
the unknowns for which to solve.
4.4 Solving Equations • 89
>
>
Transcendental Equations: In general, the solve command returns one solution to transcendental equations.
>
>
>
Maple uses variables of the form _ZN~, where N is a positive integer, to represent arbitrary integers. The tilde (~) in-
dicates that it is a quantity with an assumption. For information about names with assumptions, see Assumptions on
Variables (page 110).
RootOf Structure: The solve command may return solutions, for example, to higher order polynomial equations, in
an implicit form using RootOf structures.
>
(4.7)
These RootOf structures are placeholders for the roots of the equation The index para-
meter numbers and orders the four solutions.
Like any symbolic expression, you can convert RootOf structures to a floating-point value using the evalf command.
>
90 • 4 Basic Computations
Some equations are difficult to solve symbolically. For example, polynomial equations of order five and greater do
not in general have a solution in terms of radicals. If the solve command does not find any solutions, it is recommended
that you use the Maple numerical solver, fsolve. For information, see the following section, Numerically Solving
Equations.
For more information on the solve command, including how to solve equations defined as procedures and how to find
parametric solutions, refer to the solve/details help page.
For information on verifying and using solutions returned by the solve command, see Working with Solutions (page 91).
>
>
(4.8)
Note: You can also numerically solve equations using the context panel. See Solving Equations and
Inequations (page 86).
It is recommended that you verify the solutions returned by the fsolve command. For details, see Working with
Solutions (page 91).
Multiple Equations: To solve multiple equations, specify them as a set. For more information, see Creating and Using
Data Structures (page 263). The fsolve command solves for all unknowns.
>
Univariate Polynomial Equations: In general, the fsolve command finds one real solution. However, for a univariate
polynomial equation, the fsolve command returns all real roots.
>
>
Controlling the Number of Solutions: To limit the number of roots returned, specify the maxsols option.
>
To find additional solutions to a general equation, use the avoid option to ignore known solutions.
>
Complex Solutions: To search for a complex solution or find all complex and real roots for a univariate polynomial,
specify the complex option for the fsolve command.
4.4 Solving Equations • 91
>
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.
>
The syntax for specifying a region in the complex plane is lower-left point..upper-right point.
>
Initial Values: You can specify a value for each unknown. The fsolve command uses these as initial values for the
unknowns in the numerical method.
>
(4.9)
For more information and examples, refer to the fsolve/details help page.
For information on verifying and using solutions returned by the fsolve command, see the following section, Working
with Solutions.
>
>
(4.10)
>
(4.11)
>
92 • 4 Basic Computations
>
(4.12)
>
(4.13)
For more information, see Substituting a Value for a Subexpression (page 279).
Assigning the Value of a Solution to a Variable: To assign the value of a solution to the corresponding variable as
an expression, use the assign command.
For example, consider the numeric solution in (4.9), , found using the starting value .
>
>
Creating a Function from a Solution: The assign command assigns a value as an expression to a name. It does not
define a function. To convert a solution to a function, use the unapply command.
>
>
Here, solutions[1] selects the first element of the list of solutions. For more information on selecting elements, see
Accessing Elements (page 263).
>
>
>
For more information on defining and using functions, see Functional Operators (page 268).
ODE Analyzer Assistant The ODE Analyzer Assistant is a point-and-click interface to the Maple ODE solving
routines.
Maple inserts the dsolve[interactive]() calling sequence in the document. The ODE Analyzer Assistant (Figure 4.3)
is displayed.
94 • 4 Basic Computations
In the main ODE Analyzer Assistant window, you can define ODEs, initial or boundary value conditions, and para-
meters. To define derivatives, use the diff command. For example, diff(x(t), t) corresponds to and
diff(x(t), t, t) corresponds to For more information on the diff command, see The diff
x
Figure 4.4: ODE Analyzer Assistant: Solve Numerically Dialog
When solving numerically or symbolically, you can view a plot of the solution by clicking the Plot button.
• To plot the solution to a symbolic problem, all conditions and parameters must be set.
• To customize the plot, click the Plot Options button to open the Plot Options window.
To view the corresponding Maple commands as you solve the problem or plot the solution, select the Show Maple
commands check box.
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.
The ODE Analyzer provides a point-and-click interface to the Maple dsolve command.
• Series solutions
To access all available functionality, use the dsolve command directly. For more information, refer to the dsolve help
page.
For example, solve the following PDE symbolically. For help entering a partial derivative, see Example 1 - Enter a
Partial Derivative (page 51).
>
(4.14)
>
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 ...
First set of solution methods (general or quasi general solution)
Trying characteristic strip method for first order PDEs
First set of solution methods successful
<- Returning a *general* solution
For more information on solving PDEs, including numeric solutions and solving PDE systems, refer to the pdsolve
help page.
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.
98 • 4 Basic Computations
>
>
For example, construct an augmented matrix using the Matrix palette (see Creating Matrices and Vectors (page 122))
in which the first four columns contain the entries of A and the final column contains the entries of B.
>
>
For more information on using Maple to solve linear algebra problems, see Linear Algebra (page 122).
>
Maple supports hundreds of units, for example, miles, coulombs, and bars, and provides facilities for adding custom
units.
Maple has a library of hundreds of scientific constants with units, including element and isotope properties.
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 and unit systems as required.
Note: Some unit operations are available as task templates (see Tools→Tasks→Browse) and through the context
panel.
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 dimensions.
In Maple, the base dimensions include length, mass, time, electric current, thermodynamic temperature, amount of
substance, luminous intensity, information, and currency. For a complete list, enter and execute Units[GetDimensions]().
Complex dimensions (or composite dimensions) measure other quantities in terms of a combination of base dimensions.
Each dimension, base or complex, has associated units. (Base units measure a base dimension. Complex units measure
a complex dimension.) Maple supports over 40 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 4.4 lists some dimensions, their corresponding base dimensions, and example units.
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.
100 • 4 Basic Computations
Each unit has a context. The context differentiates between different definitions 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, respectively.
Unit Conversions
To convert a value measured in a unit to the corresponding value in a different unit, use the Units Converter.
• From the Tools→Assistants menu, select Units Converter.
To perform a conversion:
1. In the Convert text field, enter the numeric value to convert.
2. In the Dimension drop-down list, select the dimensions of the unit.
3. In the From and To drop-down lists, select the original unit and the unit to which to convert.
4. Click Perform Unit Conversion.
>
Using the Units Converter, you can convert temperatures and temperature changes.
• To perform a temperature conversion, in the Dimension drop-down list, select temperature(absolute).
• To perform a temperature change conversion, in the Dimension drop-down list, select temperature(relative).
To convert temperature changes, the Units Converter uses the convert/units command. For example, an increase of
32 degrees Fahrenheit corresponds to an increase of almost 18 degrees Celsius.
4.5 Units, Scientific Constants, and Uncertainty • 101
>
To convert absolute temperatures, the Unit Converter uses the convert/temperature command. For example, 32 degrees
Fahrenheit corresponds to 0 degrees Celsius.
>
To insert a unit:
• In a Units palette, click a unit symbol.
>
1. In a Units palette, click the unit symbol . Maple inserts a Unit object with the placeholder selected.
2. In the placeholder, enter the unit name (or symbol). Note that you see double brackets around the unit when you
are editing it.
For example, to enter standard (the default context) miles, you can specify the unit name, mile, or symbol, mi.
As you edit, the unit is enclosed in double brackets:
>
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.
102 • 4 Basic Computations
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 environment, Simple, Standard, or Natural. It is
recommended that you use the Simple environment.
>
In the Simple Units environment, commands that support expressions with units return results with the correct units.
>
>
(4.15)
>
(4.16)
>
>
(4.17)
By default, Maple uses the SI system of units, in which length is measured in meters and time is measured in seconds.
>
To view the name of the default system of units, use the Units[UsingSystem] command or view the current selection
for Choose System, under the Convert Output Units section of the context panel.
>
Automatically loading the Units[Simple] subpackage
>
To change the system of units, use the Units[UseSystem] command or click the output and then select the desired
system of units in the Choose System list, under the Convert Output Units section of the context panel.
>
>
Extensibility
You can extend the set of:
• Base dimensions and units
• Complex dimensions
• Complex units
• Systems of units
For more information about units, refer to the Units help page.
The quantities available in the ScientificConstants package are divided into two distinct categories.
• Physical constants
• Chemical element (and isotope) properties
Scientific Constants
Name Symbol
Newtonian_constant_of_gravitation G
Planck_constant h
elementary_charge e
Bohr_radius a[0]
deuteron_magnetic_moment mu[d]
Avogadro_constant N[A]
Faraday_constant F
To view the definition of the Newtonian gravitational constant, specify the symbol G (or its name) in a call to the
GetConstant command.
>
>
For information on accessing a constant's value, units, or uncertainty, see Value, Units, and Uncertainty (page 105).
Element Properties
Maple also contains element properties and isotope properties.
Elements
Maple supports all 117 elements of the periodic table. 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/elements help page.
Maple supports key element properties, including atomic weight (atomicweight), electron affinity (electronaffinity),
and density. For a complete list of element properties, refer to the ScientificConstants/properties help page.
4.5 Units, Scientific Constants, and Uncertainty • 105
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, including abundance, binding energy
(bindingenergy), and mass excess (massexcess). For a complete list of isotope properties, refer to the ScientificCon-
stants/properties help page.
>
>
>
>
Value
To obtain the value of a ScientificConstants object, use the evalf command.
106 • 4 Basic Computations
>
>
Units
To obtain the units for a ScientificConstants object, use the GetUnit command.
>
>
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 102).
>
>
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.
>
>
4.5 Units, Scientific Constants, and Uncertainty • 107
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.
For more information about constants, refer to the ScientificConstants help page.
Uncertainty Propagation
Some computations involve uncertainties (or errors). Using the ScientificErrorAnalysis package, you can propagate
the uncertainty in these values through the computation to indicate the possible error in the final result.
The ScientificErrorAnalysis package does not perform interval arithmetic. That is, the error of an object does not
represent an interval in which possible values must be contained. (To perform interval arithmetic, use the Tolerances
package. For more information, refer to the Tolerances help page..) The quantities represent unknown values with a
central tendency. For more information on central tendency, refer to any text on error analysis for the physical sciences
or engineering.
>
>
>
>
(4.18)
To specify the error in units of the last digit, the value must be of floating-point type.
108 • 4 Basic Computations
>
To access the value and uncertainty of a quantity with uncertainty, use the evalf and ScientificErrorAnalysis[GetError]
commands.
>
>
Rounding: To round the error of a quantity with uncertainty, use the ApplyRule 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.
To construct a new quantity with units and an uncertainty, include units in the Quantity calling sequence.
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.
>
For information on the correlation between, variance of, and covariance between quantities with uncertainty, refer to
the ScientificErrorAnalysis help page.
>
>
>
>
To convert the solution to a single quantity with uncertainty, use the combine/errors command.
>
>
>
Additional Information
For information on topics including:
• Creating new rounding rules,
• Setting the default rounding rule, and
• Creating a new interface to quantities with uncertainty,
Maple has facilities for performing computations in the real number system and for applying assumptions to variables.
The RealDomain package contains a small subset of Maple commands related to basic precalculus and calculus
mathematics, for example, arccos, limit, and log, and the symbolic manipulation of expressions and formulae, for ex-
ample, expand, eval, and solve. For a complete list of commands, refer to the RealDomain help page.
After you load the RealDomain package, Maple assumes that all variables are real. Commands return simplified results
appropriate to the field of real numbers.
In Maple's default environment, without loading After loading RealDomain, the answers are simplified.
RealDomain, the answers are correct for the entire complex
field. >
> >
(4.19) (4.22)
> >
(4.20) (4.23)
> >
(4.24)
(4.21)
>
>
After loading the RealDomain package, you can also use the context-sensitive items for simplify and solve to perform
computations in the field of real numbers. For example, using the context panel item Simplify > Simplify,
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.
The assume command allows improved simplification of symbolic expressions, especially multiple-valued functions,
for example, computing the square root.
To assume that x is a positive real number, use the following calling sequence. Then compute the square root of .
4.6 Restricting the Domain • 111
>
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.
>
Displaying Assumptions: To view the assumptions on an expression, use the about command.
>
Originally x, renamed x~:
is assumed to be: RealRange(-infinity,Open(0))
Imposing Multiple Assumptions: To simultaneously impose multiple conditions on an expression, specify multiple
arguments in the assume calling sequence.
>
To specify additional assumptions without replacing previous assumptions, use the additionally command. The syntax
of the additionally calling sequence is the same as that of the assume command.
>
Originally x, renamed x~:
is assumed to be: 1
Testing Properties: To test whether an expression always satisfies a condition, use the is command.
>
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.
>
To test whether an expression can satisfy a condition, use the coulditbe command.
>
>
112 • 4 Basic Computations
For more information on the assume command, refer to the assume help page.
The syntax of the assuming command is <expression> assuming <property or relation>. Properties and relations are
introduced in The assume Command (page 110).
>
Using the assuming command is equivalent to imposing assumptions with the assume command, evaluating the ex-
pression, and then removing the assumptions.
>
x:
nothing known about this object
If you do not specify the names to which to apply a property, it is applied to all names.
>
Assumptions placed on names using the assume command are ignored by the assuming command, unless you include
the additionally option.
>
>
>
The assuming command does not affect variables inside procedures. (For information on procedures, see
Procedures (page 298).) You must use the assume command.
4.6 Restricting the Domain • 113
>
>
For more information on the assuming command, refer to the assuming help page.
114 • 4 Basic Computations
5 Mathematical Problem Solving
This chapter focuses on solving problems in specific mathematical disciplines. The areas described below are not all
that Maple provides, but represent the most commonly used packages. Examples are provided to teach you how to use
the different methods of calculation available in Maple, including tutors, assistants, commands, task templates, plotting,
and context-sensitive operations.
The examples in this chapter assume knowledge of entering commands and mathematical symbols. For information,
see Entering Expressions (page 14). For information on basic computations, including integer operations and solving
equations, see Basic Computations (page 79).
5.2 Algebra
Maple contains a variety of commands that perform integer operations, such as factoring and modular arithmetic, as
described in Integer Operations (page 82). In addition, it supports polynomial algebra.
For information on matrix and vector algebra, see Linear Algebra (page 122).
115
116 • 5 Mathematical Problem Solving
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
The coefficients can be integers, rational numbers, irrational numbers, floating-point numbers, complex numbers,
variables, or a combination of these types.
>
Arithmetic
The polynomial arithmetic operators are the standard Maple arithmetic operators excluding the division operator (/).
(The division operator accepts polynomial arguments, but does not perform polynomial division.)
Polynomial division is an important operation. The quo and rem commands find the quotient and remainder of a
polynomial division. See Table 5.1. (The iquo and irem commands find the quotient and remainder of an integer division.
For more information, see Integer Operations (page 82).)
Subtraction
>
Multiplication1 *
>
>
Exponentiation2 ^
>
5.2 Algebra • 117
>
If you need to determine whether one polynomial divides another, but do not need the quotient, use the divide command.
The divide command tests for exact polynomial division.
>
Important: You must insert a space character or a multiplication operator ( ) between adjacent variables names.
Otherwise, they are interpreted as a single variable.
For example, without a space, is considered a single variable, and does not divide the single variable
>
>
For information on polynomial arithmetic over finite rings and fields, refer to the mod help page.
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.
>
>
By default, the sort command sorts a polynomial by decreasing total degree of the terms.
>
>
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.
>
For information on enclosing keywords in right single quotes ('), see Delaying Evaluation (page 285).
The first term contains to the power 3; the second, to the power 2; and the third, to the power 0.
Using context-sensitive operations, you can perform operations, such as sorting, for polynomials and many other Maple
objects.
To sort a polynomial:
1. Select the polynomial.
2. From the Context Panel, under the Sorts menu, select:
• Single-variable, and then the unknown, or,
• Two-variable (or Three-variable), Pure Lexical or Total Degree, and then the sort priority of the unknowns.
In Worksheet mode, Maple inserts the calling sequence that performs the sort followed by the sorted polynomial. For
this example, choose Sorts > Two-variable > Pure Lexical > y,x.
>
>
(5.1)
120 • 5 Mathematical Problem Solving
You can use the Context Panel to perform context-sensitive operations on 2-D Math content including output. For
more information, see Computing with the Context Panel (page 54) (for Document mode) or The Context
Panel (page 69) (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.
5.2 Algebra • 121
>
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 information, see Integer Operations (page 82).)
To solve for the roots of a polynomial, use the solve command. For information on the solve command, see Solving
Equations and Inequations (page 86). (The isolve command solves an equation for integer solutions. For more inform-
ation, see Integer Equations (page 97).)
Other Commands
Table 5.3 lists other commands available for polynomial operations.
Command Description
content Content (multivariate polynomial)
compoly Decomposition
discrim Discriminant
gcd Greatest common divisor (of two polynomials)
gcdex Extended Euclidean algorithm (for two polynomials)
CurveFitting[PolynomialInterpolation] Interpolating polynomial (for list of points)
Additional Information
Topic Resource
General polynomial information polynom help page
PolynomialTools package PolynomialTools package overview help page
Algebraic manipulation of numeric polynomials SNAP (Symbolic-Numeric Algorithms for Polynomials) package
overview help page
Polynomial information and commands Maple Help System Table of Contents:
Mathematics→Algebra→Polynomials section
122 • 5 Mathematical Problem Solving
You can perform many linear algebra operations using task templates. In the Task Browser (Tools → Tasks →
Browse), expand the Linear Algebra folder.
Creating Matrices
You can create a Matrix using
• The Matrix command
• The angle bracket shortcut notation
• The Matrix palette (see Figure 5.2).
When creating a Matrix using the Matrix command, there are several input formats available. For example, enter a list
of lists. The dimensions of the matrix are inferred from the number of entries given.
>
Alternatively, use the angle bracket shortcut, <>. Separate items in a column with commas, and separate columns with
vertical bars, |.
>
For information on the Matrix command options, see Creating Matrices and Vectors with Specific Properties (page 126).
5.3 Linear Algebra • 123
In the Matrix palette, you can specify the matrix size (see Figure 5.3) and properties. To insert a matrix, click the Insert
Matrix button.
>
Creating Vectors
You can create a Vector using angle brackets (< >).
To create a column vector, specify a comma-delimited sequence, <a, b, c>. The number of elements is inferred from
the number of expressions.
>
To create a row vector, specify a vertical-bar-delimited (|) sequence, <a | b | c>. The number of elements is inferred
from the number of expressions.
>
For information on the Vector command options, refer to the Vector help page.
You can also create vectors using the Matrix palette. If either the number of rows or number of columns specified is
1, then you have the option of inserting a matrix, or inserting a vector of the appropriate type. See Figure 5.4.
Matrices and smaller, and vectors with 10 or fewer elements, display in the document. Larger objects are
displayed as a placeholder.
5.3 Linear Algebra • 125
>
To edit or view a large matrix or vector, double-click the placeholder. This launches the Matrix Browser. See Figure 5.5.
You can view the matrix or vector as a table or as an image, which can be inserted into the document. For more inform-
ation, refer to the MatrixBrowser help page.
126 • 5 Mathematical Problem Solving
>
You cannot specify properties when defining vectors using the angle-bracket notation. You must use the Vector con-
structor.
To define a column vector using the Vector constructor, specify:
• The number of elements. If you explicitly specify all element values, this argument is not required.
• A list of expressions that define the element values.
• Parameters such as shape, datatype, and fill that set properties of the vector.
>
>
To create a row vector using the Vector constructor, include row as an index.
>
>
The Matrix palette does not support some properties. To set all properties, use the Matrix constructor.
For example:
>
The Matrix palette cannot fill the matrix with an arbitrary value. Use the fill parameter.
>
For more information on the constructors, including other calling sequence syntaxes and parameters, refer to the storage,
Matrix, and Vector help pages.
Matrices
To select an entry in a Matrix, enter the matrix name with a sequence of two non-zero integer indices, row first.
>
>
To select an entire row, enter a single index; to select an entire column, enter first the entire range of rows, then
the column index.
>
>
Similarly, you can access submatrices. Enter the indices as a list or range.
>
Vectors
To select an entry in a vector, enter the vector name with a non-zero integer index.
>
>
>
To create a Vector consisting of multiple entries, specify a list or range of integers in the index. For more information,
refer to the set and range help pages.
>
>
Matrix Arithmetic
The matrix and vector arithmetic operators are the standard Maple arithmetic operators up to the following two differ-
ences.
• The scalar multiplication operator is the asterisk (*), which displays in 2-D Math as . The noncommutative matrix
and vector multiplication operator is the period (.).
• There is no division operator (/) for matrix algebra. (You can construct the inverse of a matrix using the exponent
.)
>
Multiplication . >
>
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 5.6.
>
>
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] command.
For information on matrix arithmetic over finite rings and fields, refer to the mod help page.
Point-and-Click Interaction
Using the Context Panel, you can perform many matrix and vector operations.
For example, compute the infinity norm of a matrix. See Figure 5.6.
In Document mode, Maple inserts a right arrow and the name of the computation performed, followed by the norm.
For more information on context-sensitive operations, see Computing with the Context Panel (page 54) (for Document
mode) or The Context Panel (page 69) (for Worksheet mode).
Table 5.7 lists some LinearAlgebra package commands. For a complete list, refer to the LinearAlgebra/Details help
page.
5.3 Linear Algebra • 133
Command Description
Basis Return a basis for a vector space
CrossProduct Compute the cross product of two vectors
DeleteRow Delete a row or rows of a matrix
Dimension Determine the dimension of a matrix or a vector
Eigenvalues Compute the eigenvalues of a matrix
Eigenvectors Compute the eigenvectors of a matrix
FrobeniusForm Reduce a matrix to Frobenius form
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 the QR factorization of a matrix
RandomMatrix Construct a random matrix
SylvesterMatrix Construct the Sylvester matrix of two polynomials
For information on selecting entries, subvectors, and submatrices, see Accessing Entries in Matrices and
Vectors (page 128).
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.
>
>
134 • 5 Mathematical Problem Solving
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 Algorithms
Group (NAG®). Maple also contains portions of the CLAPACK and optimized ATLAS libraries.
For information on performing efficient numeric computations using the LinearAlgebra package, refer to the Effi-
cientLinearAlgebra help page.
See also Creating Matrices and Vectors with Specific Properties (page 126) and Reading from Files (page 321).
In the Student[LinearAlgebra] subpackage, the environment differs from that of the LinearAlgebra package in that
floating-point computations are generally performed using software precision, instead of hardware precision, and
symbols are generally assumed to represent real, rather than complex, quantities. These defaults, and others, can be
controlled using the SetDefault command. For more information, refer to the Student[SetDefault] help page.
For information on using Maple as a teaching and learning tool, see Teaching and Learning with Maple (page 151).
5.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 Panel.
For a complete list of calculus commands, refer to the Mathematics (including Calculus, Differential Equations,
Power Series, and Vector Calculus subfolders) and Student Package sections of the Maple Help System Table of
Contents.
Limits
To compute the limit of an expression as the independent variable approaches a value:
For example:
>
>
>
Using the limit command, you can also compute multidimensional limits.
>
For more information on multidimensional limits, refer to the limit/multi help page.
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:
>
For information on the evalf command, see Numerical Approximation (page 281).
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.
To differentiate an expression:
1. In the Calculus palette, click the differentiation item or the partial differentiation item .
2. Specify the expression and independent variable, and then evaluate it.
136 • 5 Mathematical Problem Solving
>
You can also differentiate using the Context Panel. For more information, see The Context Panel (page 32).
To calculate a higher order or partial derivative, edit the derivative symbol inserted. For example, to calculate the
second derivative of with respect to :
>
>
Note: To enter another symbol, you can copy and paste the existing symbol, or enter d and use symbol completion.
>
(5.2)
>
(5.3)
For information on equation labels such as (5.2), see Equation Labels (page 74).
You can calculate a higher order derivative by specifying a sequence of differentiation variables. Maple recursively
calls the diff command.
>
(5.4)
To calculate a partial derivative, use the same syntax. Maple assumes that the derivatives commute.
5.4 Calculus • 137
>
To enter higher order derivatives, it is convenient to use the syntax diff(f, x$n). This syntax can also be used to compute
the symbolic nth order derivative.
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 Distinction between Functional Operators and Other Expressions (page 269).
For example, find the derivative of an operator that represents the mathematical function
>
>
>
138 • 5 Mathematical Problem Solving
For more information on the D operator, refer to the D help page. For a comparison of the diff command and D oper-
ator, 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 derivative.
To compute a symbolic value for the directional derivative, use the Student[MultivariateCalculus][DirectionalDe-
rivative] 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 derivative.
For example, at the point the gradient of points in the direction which is the direction of
greatest increase. The directional derivative in the orthogonal direction is zero.
>
5.4 Calculus • 139
>
>
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 expansion about 0. For more information, refer
to the Ci help page.
>
Error, does not have a taylor expansion, try series()
To generate a truncated series expansion of a function about a point, use the series command.
>
By default, Maple performs series calculations up to order 6. To use a different order, specify a non-negative integer
third argument.
>
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 do not accept arguments of type series. To use the expansion, you
must convert it to a polynomial using the convert/polynom command.
140 • 5 Mathematical Problem Solving
>
For information on Maple types and type conversions, see Maple Expressions (page 263).
Integration
Maple can perform symbolic and numeric integration.
>
Recall that you can also enter symbols, including and using symbol completion.
• Enter the symbol name (or part of the name), for example, int or d, and then press the completion shortcut key.
You can also compute an indefinite integral using the Context Panel. For more information, see The Context
Panel (page 32).
5.4 Calculus • 141
>
Maple treats the parameter a as a complex number. As described in Assumptions on Variables (page 110), you can
compute under the assumption that a is a positive, real number using the assuming command.
>
To compute iterated integrals, line integrals, and surface integrals, use the task templates (Tools → Tasks → Browse)
in the Multivariate and Vector Calculus folders.
and use the int command. To use the int command directly, specify the following arguments.
• Expression to integrate
• Variable of integration
>
(5.5)
>
(5.6)
For a definite integration, set the variable of integration equal to the interval of integration.
>
(5.7)
142 • 5 Mathematical Problem Solving
Numeric Integration
To perform numeric integration:
• Use the evalf(Int(arguments)) calling sequence.
Important: Use the inert Int command, not the int command. For more information, 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 information on the evalf command, see Numerical Approximation (page 281).
For information on numeric integration, including iterated integration and controlling the algorithm, refer to the evalf/Int
help page.
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 Solvers (page 93).
Calculus Packages
In addition to top-level calculus commands, Maple contains calculus packages.
VectorCalculus Package
The VectorCalculus package contains commands that perform multivariate and vector calculus operations on Vector-
Calculus vectors (vectors with an additional coordinate system attribute) and vector fields (vectors with additional
coordinate system and vectorfield attributes), for example, Curl, Flux, and Torsion.
>
>
>
>
Note: For information on changing the display format in the VectorCalculus package, see the VectorCalculus[Basis-
Format] help page.
>
>
Compute the torsion of a space curve. The curve must be a vector with parametric function components.
>
For information on the assuming command, see The assuming Command (page 112).
For more information on the VectorCalculus package, including a complete list of commands, refer to the VectorCal-
culus help page.
To find other calculus packages, such as VariationalCalculus, refer to the index/package help page.
For information on using Maple as a teaching and learning tool, and some computational examples, see Teaching and
Learning with Maple (page 151).
5.5 Optimization
Using the Optimization package, you can numerically solve optimization problems. The package uses fast Numerical
Algorithms Group (NAG) algorithms to minimize or maximize an objective function.
The Optimization package contains local solvers. In addition, for univariate finitely-bounded nonlinear programs with
no other constraints, you can compute global solutions using the NLPSolve command. To find global solutions generally,
purchase the Global Optimization Toolbox. For more information, visit
http://www.maplesoft.com/products/toolboxes.
144 • 5 Mathematical Problem Solving
Point-and-Click Interface
The primary method for solving optimization problems is the Optimization Assistant.
To solve a problem:
1. Enter the objective function, constraints, and bounds.
2. Select the Minimize or Maximize radio button.
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 of the Optimiza-
tion[Interactive] command.
>
Note: When you close the Optimization Assistant, you can choose to return the solution, problem, command used,
plot, or nothing, using the drop-down in the bottom right corner of the assistant window.
For information on the algorithms used to solve optimization problems, refer to the Optimization/Methods help page.
The Matrix form, described in the Optimization/MatrixForm help page, is more complex but offers greater flexibility
and efficiency.
>
146 • 5 Mathematical Problem Solving
>
2. Define the matrix A, the coefficient matrix for the linear inequality constraints.
>
3. Define the column vector b, the linear inequality constraints.
>
4. The QPSolve command solves quadratic programs.
>
This example uses a random data set to demonstrate the problem. You could also read data from an external file as
Matrices, and use that data. For details and an example, see Reading from Files (page 321).
Note: For information on creating matrices and vectors (including how to use the Matrix palette to easily create
matrices), see Linear Algebra (page 122).
For additional information on performing efficient computations, refer to the Optimization/Computation help page.
Command Description
LPSolve Solve a linear program (LP), which involves computing the minimum (or maximum) of a linear
objective function subject to linear constraints; input is in equation or Matrix form
LSSolve Solve a least-squares (LS) problem, which involves computing the minimum of a real-valued
For a complete list of commands and other Optimization package information, refer to the Optimization help page.
5.6 Statistics • 147
5.6 Statistics
The Statistics package provides tools for mathematical statistics and data analysis. The package supports a wide range
of common statistical tasks including quantitative and graphical data analysis, simulation, and curve fitting.
In addition to standard data analysis tools, the Statistics package provides a wide range of symbolic and numeric tools
for computing with random variables. The package supports over 35 major probability distributions and can be extended
to include new distributions.
You can define random variables by specifying a distribution in a call to the RandomVariable command.
>
>
Find the probability distribution function for X. (For information on statistics computations, see Statistical
Computations (page 148).)
>
>
To construct a piecewise-continuous function in 1-D Math, use the piecewise command, for example, t ->
piecewise(t < 0, 0, t < 3, 1/3, 0).
>
>
Statistical Computations
In addition to basic functions, like mean, median, standard deviation, and percentile, the Statistics package contains
commands that compute, for example, the interquartile range and hazard rate.
>
>
>
>
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 by a small value determined
by a normally distributed sample.
>
>
>
>
150 • 5 Mathematical Problem Solving
>
To fit a curve to the data points, include the optional fit equation parameter.
• the function
>
>
5.7 Teaching and Learning with Maple • 151
>
For more information on statistical plots, refer to the Statistics/Visualization help page.
Additional Information
For more information on the Statistics package, including regression analysis, estimation, data manipulation, and data
smoothing, refer to the Statistics help page.
The Data Analysis Assistant provides an interactive way to perform data analysis. For more information, refer to the
Statistics[InteractiveDataAnalysis] help page.
Resource Description
Student Packages and Tutors The Student package contains computational and visualization (plotting and
animation) functionality, and point-and-click interfaces for explaining and exploring
concepts (Tools→Tutors). For more information, refer to the Student help page.
152 • 5 Mathematical Problem Solving
Resource Description
Teacher Resource Center The Maple Teacher Resource Center contains resources and tips for teachers using
Maplesoft products to help in the classroom. Available resources include:
• Classroom content for subjects including Precalculus, Calculus, and Engineering
• Training videos
• E-books
(http://www.maplesoft.com/teachercenter)
Maple Portal The Maple Portal includes material designed for all Maple users as well as specific
portals for students and educators. The Maple Portal includes:
• How Do I... topics that give quick answers to essential questions
• Tutorials that provide an overview of topics from getting started to plotting and
working with matrices
• Navigation to portals with specialized information for students, math educators,
and engineers
Access the portal the table of contents in the Maple Help System, under Getting
Started.
Mathematics and Engineering Dictionary The Maple Help System has an integrated dictionary of over 5000 mathematics
and engineering terms. You can search the dictionary by entering a term in the Help
System search field.
Maple Application Center The Maple Application Center contains tutorials and applications 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)
Student Help Center The Maple Student Help Center contains tutorials and applications 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 standard textbook, using Maple
commands and custom Maplet graphical interfaces.
• Free course lessons for many subjects including precalculus to vector calculus;
high school, abstract, and linear algebra; engineering; physics; differential
equations; cryptography; and classical mechanics.
• Applications for students, written by students, providing examples in many
subject areas.
• Student FAQs with answers from experts.
(https://www.maplesoft.com/studentcenter/index.aspx)
Instructors can:
• Teach concepts without being distracted by the mechanics of the computations.
• Create examples and quickly update them during a lesson to demonstrate different cases or show the effect of the
variation of a parameter.
• Create plots and animations to visually explain concepts, for example, the geometric relationship between a math-
ematical function and its derivatives (Tools→Tutors→Calculus - Single Variable→Derivatives). See Figure 5.10.
5.7 Teaching and Learning with Maple • 153
Students can:
• Perform step-by-step computations, for example, compute a derivative by applying differentiation rules using com-
mands or a tutor (Tools→Tutors→Calculus - Single Variable→Differentiation Methods). See Figure 5.11.
• Perform computations.
• Visually explore concepts.
154 • 5 Mathematical Problem Solving
To launch a tutor:
1. From the Tools menu, select Tutors.
2. Select a subject, for example, Calculus - Multivariate.
3. Select a tutor, for example, Gradients.
Maple inserts the Student[MultivariateCalculus][GradientTutor]() calling sequence (in Worksheet mode), and launches
the Multivariate Calculus Gradient 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 5.12) and show the direction of the gradient vector in the x-y plane by rotating the plot (see
Figure 5.13).
5.7 Teaching and Learning with Maple • 155
When you close the tutor, Maple inserts the 3-D plot.
>
Many Student package commands can return a value, mathematical expression, plot, or animation. This allows you
to compute the final answer, see the general formula applied to a specific problem, or visualize the underlying concepts.
For example, the Student[VectorCalculus][LineInt] (line integral) command can return the following.
• 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
>
5.7 Teaching and Learning with Maple • 157
>
>
(5.8)
To evaluate the integral returned by the output = integral calling sequence, use the value command.
>
(5.9)
>
For more information on the Student package, refer to the Student help page.
Problem
Scenario A:
Your company is designing a bottle for its new spring water product. The bottle
must contain 18 ounces of water and the height is fixed. The design includes an
undulating curved surface. You know the amplitude and equation of the curve,
but you must find the radius. You require the Volume of Revolution.
Scenario B:
>
The Volume of Revolution Tutor is displayed. See Figure 5.15. Use this tutor to enter a function and an interval,
view and manipulate the corresponding plot, and view the full Maple command associated with your entries and selec-
tions.
160 • 5 Mathematical Problem Solving
After you Close the tutor, the plot is inserted into your worksheet.
Click Insert Default Content. Before inserting a task, Maple checks whether the task variables have assigned values
in your worksheet. If any task variable is assigned, the Task Variables dialog opens allowing you to modify the names.
Maple uses the edited variable names for all variable instances in the inserted task. The content is inserted into your
document. See Figure 5.16.
5.7 Teaching and Learning with Maple • 161
6. When a Task Template is inserted, parameters are marked as placeholders, denoted by purple font. To navigate
between placeholders, press the Tab key. After updating any parameters, execute the command by pressing Enter.
4. Click Search.
5. From the search results page, under Displaying applications, click the Click here link.
6. From the list of archived applications, select any of the Maple document you want to view.
7. Click on the Download Maple Document link to download the .mw file.
5.8 Clickable MathTM • 163
Two key features of the Clickable Math tool collection are Smart Popups and Drag-to-SolveTM.
Smart Popups
Smart Popups are interactive popup options that are invoked when you select certain types of equations, expressions
or subexpressions.
Smart popups, if any, are shown at the top of the Context Panel. For more information on Smart Popups, as well as
examples, see the Clickable Math: Smart Popups help page.
Drag-to-Solve
The Drag-to-Solve feature enables you to solve your equations step-by-step by dragging terms to where you want them
to be.
For more information on Drag-to-Solve, as well as examples, see the Clickable Math: Drag-to-Solve help page.
Examples
This chapter is designed to show several ways to solve the same problem in Maple. Throughout these examples, you
will need to insert new document block regions. This is done using the Create document block icon ( ) on the toolbar
or through the Edit menu, by selecting Document Blocks>Create Document Block. Also, these examples only give
164 • 5 Mathematical Problem Solving
the keyboard keys needed for a Windows operating system. Refer to Shortcut Keys by Platform (page xiii) for the keys
needed for your operating system.
Solution by Tutor
The Student Calculus 1 package contains a tutor called Derivatives, which displays a plot of the expression along
with its derivatives. In this example, we solve the same problem as previously, using this tutor
Action Result in Document
1. Load the Student Calculus 1 package. From the Loading Student:-Calculus1
Tools menu, select Load Package → Student
Calculus 1.
6. Click Return Steps to close the dialog and return all of the
steps to the Maple document.
Or,
Instant Solution
To apply an instant solution to this problem, use the Context Panel.
Action Result in Document
1. Ctrl + drag the equation
to a new
document block region.
2. From the Context Panel for the expression, select Solve →
Obtain Solutions for → x.
7. From the Context Panel for the result, select Solve → Obtain
Solutions for → x.
Graphical Solution
Now that we have seen several methods to solve this problem, we can check the answer by plotting the expression.
Action Result in Document
1. Ctrl + drag the equation
to a new
document block region and press Enter.
4. Select the output and from the Context Panel select Expand.
5.8 Clickable MathTM • 173
Or,
Right-click the output from step 4 and select Plots → 2-D Plot.
Click the Vertical tab and clear the Use data extents check
box. Change the Range min and Range max to -5 and 10,
respectively.
8. Click OK to apply the changes and return to the plot.
The interception points of this graph with the -axis are 1 and 3,
the same solutions that we found previously.
(5.11)
(5.12)
(5.14)
(5.15)
(5.16)
Once again, select the left side of the equation. A smart popup
window is displayed. Select 2D plot.
The resulting plot is displayed in the document.
(5.17)
(5.18)
(5.19)
5.8 Clickable MathTM • 175
You can also solve the equation using smart popups. Highlight
the simplified equation and from the Smart Popup menu, select
solve.
Graphical Solution
Action Result in Document
Analytic Solution
Action Result in Document
Solution by Tutor
Action Result in Document
1. Load the Student Calculus 1 package. From the Tools Loading Student:-Calculus1
menu, select Load Package → Student Calculus 1.
region.
2. From the Context Panel for the expression and select Evaluate
and Display Inline. =
182 • 5 Mathematical Problem Solving
(5.21)
Calculate :
(5.25)
The solution is .
For a reference to the types of plots available in Maple, see the Plotting Guide.
187
188 • 6 Plots and Animations
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.
The Plot Builder can be accessed from the Assistants menu, accessed from the Tools menu of the Standard Menu
Bar.
When launched in this way, an interactive dialogue allows the expression to be plotted to be entered. This is equivalent
to calling the PlotBuilder command with no arguments.
Note: The Tools menu also offers tutors to easily generate plots in several academic subjects. For more information,
see Teaching and Learning with Maple (page 151).
The Plot Builder can also be launched using the context panel for an expression.
Click on the expression you'd like to plot and from the context panel select Plot Builder. In this case, the Plot Builder
Panel opens.
190 • 6 Plots and Animations
Notes: In worksheet mode, Maple inserts PlotBuilder() in the Maple document and opens the Specify Expressions
window.
Entering this command at the Maple prompt also opens the Plot Builder.
Enter an expression:
3. In the Interactive Plot Builder:Specify Expressions window:
a. Add the expression, sin(x)/x.
b. Click Accept in the Add/Edit Expression window.
c. Click OK in Interactive Plot Builder:Specify Expressions window.
6.2 Creating Plots • 191
Note: You can toggle the show command option to view the Maple syntax used to generate this plot.
The Plot Builder accepts expressions in 1-D Math and performs basic calculations on expressions. For example, entering
diff(sin(x^2), x) in the Specify Expression window performs the calculation and displays the expression as 2*cos(x^2)*x in the
Expression group box.
1. In three separate steps:
• Launch the PlotBuilder then add the expression sin(x^2). Select 2-D Plot as the plot type. Change the x-axis range to -Pi..Pi
• Launch another instance of the PlotBuilder and add the expression diff(sin(x^2),x). Select 2-D Plot as the plot type. Change the
x-axis range to -Pi..Pi
• Launch a third instance of the PlotBuilder and add the expression int(sin(x^2), x). Select 2-D Plot as the plot type. Change the
x-axis range to -Pi..Pi
You should have three separate plots in separate plot component windows.
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 expression 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 commands from Creating Plots: Interactive Plot
Builder (page 196)
Note: To apply plot options before interactively adjusting the plot, click Options.
You can also click Preview to preview your interactive plot from the Plot Builder.
To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot
Builder (page 196).
For information on customizing plots using the Interactive Plot Builder, refer to Customizing Plots: Interactive Plot
Builder Options (page 206).
You can also explore an interactive plot with parameters using the Exploration Assistant. For more information, see
Exploration Assistant (page 35).
6.2 Creating Plots • 195
Context Panel
The context panel is a collection of tools and operations that are appropriate for a particular expression. The context
panel changes according to the expression, table, or region that you click on.
When you invoke the Interactive Plot Builder through the context panel, the expression automatically passes to the
builder, and Maple does not display the Specify Expression window.
One advantage of using the context panel is the simplicity of creating an expression using the tools and operations in
the panel. By using this method, you do not need any knowledge of plot command syntax.
>
(6.1)
For information on customizing plots using the context menu, see Context Panel Options (page 207).
196 • 6 Plots and Animations
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 206).
Note: The default ranges for plot and plot3d commands are to , or to in case of trigonometric
functions.
>
To display multiple expressions in a plot, include the expressions in a list. To enter and use
the Expression palette. For more information, see Palettes (page 16).
6.2 Creating Plots • 197
>
>
198 • 6 Plots and Animations
>
>
6.2 Creating Plots • 199
>
To play the animation, click the plot and the from the Animation Toolbar, select Play ( ). For information on playing
the animation, see Playing Animations (page 217).
For more information on the plot options used in this section, refer to the plot/options and plot3d/options help pages.
>
>
>
>
>
6.2 Creating Plots • 203
>
>
>
204 • 6 Plots and Animations
>
Place your pointer over the graph to see the contour labels.
Advantages of the drag-and-drop method include the ease of adding and removing plots and the independence from
plotting command syntax.
Example:
1. Enter the command in an input region.
2. Execute.
4. Drag the expression onto the plot of . When dragging an expression to a plot region, you can either make a copy of the
expression from the input region or you can cut the expression, thereby removing it from the input region. To make a copy of
the expression, select the full expression in the input region and press Ctrl (Command, Macintosh) while you drag the expression
to the plot region. To cut the expression and paste it in the plot region, highlight the expression and drag it to the plot region.
Tip: To remove an expression from the plot region, drag-and-drop the expression plot from the plot region to a Maple input region.
List of Expressions
To display multiple expressions in the same plot region, enter the expressions in a list data structure. To distinguish
the surfaces, apply different shading options, styles, or colors to each surface.
>
This example plots a curve over a hill with the shadow of the curve projected onto the hill.
>
>
>
>
>
>
>
>
Example:
Launch the Interactive Plot Builder and enter the expression:
1. Add the expression 2*x^5-10*x^3+6*x-1. For information on interacting with the Interactive Plot Builder, see Example 1 -
Display a plot of a single variable expression (page 190).
Set the x-axis range:
2. Select 2-D Plot as the plot type.
3. Change the x-axis range to -2 .. 2.
In the Plot Options window:
4. From the line style list box, select dot.
5. From the color list box, select Blue.
6. From the axes style list box, select frame.
7. Select the Axes and Text menu.
8. In the text field beside title, enter My Plot.
>
208 • 6 Plots and Animations
There is a singularity at x = 1. What are the and -intercepts? It's hard to see in the current view. If you change the
range, the locations of the intercepts are easier to see.
Alter the y-axis range:
1. Click the plot region. From the context panel, select Axes, and then Properties.
2. In the Axes Properties dialog, click the Vertical tab.
3. Clear the Use data extents check box and enter -2 and 5 in the Range min and Range max text regions, respectively.
4. Click Apply to view the changes, or OK to return to the document.
Change the color:
5. Click on the curve. Note: The curve is selected when it becomes highlighted.
6. Select Color, and then Green.
Note: The Niagara colors listed form the default color palette in Maple.
Change the line style:
7. Select Line, and then Dash.
The -intercept is at x=-2, and the -intercept is at y=2. This can be verified using the equation .
>
Option Description
axes Defines the type of axes, one of: boxed, frame, none, or normal
caption Defines the caption for the plot
color Defines a color for the curves to be plotted
font Defines the font for text objects in the plot
glossiness (3-D) Controls the amount of light reflected from the surface
gridlines (2-D) Defines gridlines in the plot
lightmodel (3-D) Controls the light model to illuminate the plot, one of: none, light1, light2, light3, or light4
linestyle Defines the dash pattern used to render lines in the plot, one of: dot, dash, dashdot, longdash, solid,
spacedash, and spacedot
legend (2-D) Defines a legend for the plot
numpoints Controls the minimum total number of points generated
scaling Controls the scaling of the graph, one of: constrained or unconstrained
shading (3-D) Defines how the surface is colored, one of: xyz, xy, z, zgrayscale, zhue, or none
size (2-D) Specifies the size (or ratio) of the plot window
style Defines how the surface is to be drawn, one of: line, point, pointline, polygon, or polygonoutline
for 2-D plots; contour, point, pointline, surface, surfacecontour, surfacewireframe, wireframe,
or wireframeopaque for 3-D plots
6.3 Customizing Plots • 211
Option Description
symbol Defines the symbol for points in the plot, one of: asterisk, box, circle, cross, diagonalcross, diamond,
point, solidbox, solidcircle, or soliddiamond for 2-D plots; asterisk, box, circle, cross,
diagonalcross, diamond, point, solidsphere, or sphere for 3-D plots
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 axes displayed on the screen
For a complete list of plot options, refer to the plot/options and plot3d/options help pages.
>
To create a smoother or more precise plot, calculate more points using the numpoints option.
212 • 6 Plots and Animations
>
(3-D)
Pan Pan the plot by changing the view ranges for 2-D plots; smartplots re-sample to reflect the new
view. Change the position of the plot in the plot region for 3-D plots.
Zoom in Zoom into the plot; smartplots re-sample to reflect the new view. Also, scale the plot by placing
the pointer over the plot and then rotating the wheel button.
After you select a type of plot, an interactive environment allows you to change a number of options to refine the look
of your plot. As you refine your plot, Maple automatically updates the plot command with your options.
If the Live Data Plots palette is not displayed in the palette dock, from the main menu select View → Palettes →
Show Palette, and then select Live Data Plots.
>
214 • 6 Plots and Animations
For information on playing the animation, see Playing Animations (page 217). To see the Maple syntax used to generate
this plot, see Maple Syntax for Creating Animations: Interactive Plot Builder Example (page 214).
To access the command, use the short form name after invoking the with(plots) command.
>
>
6.6 Creating Animations • 215
>
For more information on the animate command, refer to the plots[animate] help page.
The moveable position from which you view the surface is called the camera. You can specify the orientation of the
camera to view different sides of a surface, the path along which the camera moves throughout and around a surface,
and the location of the camera in 3-D space in each animation frame. For example, you can specify coordinates to
move the camera to specific points beside a surface; a pre-defined camera path to move the camera in a circle around
the surface; and the range of view to move the camera close to or away from the surface. Refer to the viewpoint help
page for more information.
To animate the following examples, click the plot object and then click the play button ( ) in the Animation context
bar.
In the following example, a pre-defined path circleleft moves the camera in a counter-clockwise circle around the plot
surface.
216 • 6 Plots and Animations
>
Example 2: Specifying a Path to Move the Camera Towards and Around a 3-D Plot
In the following example, a camera path is specified to zoom into and view different sides of the plot surface.
>
6.7 Playing Animations • 217
You can also run the animation using the context menu or the Plot menu.
218 • 6 Plots and Animations
(6.2)
>
6.9 Exporting • 219
>
>
6.9 Exporting
You can export a generated plot or animation to an image in various file formats, including DXF and X3D (for 3-D
plots), 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:
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 plot,device help page.
From the Help menu, select On the Web, User Resources, and then Application Center.
You can:
• Copy, cut, and paste information
• Format text for reports or course material
• Add headers and footers
• Insert images, tables, and symbols
• Generate 2-D and 3-D plots and animations
• Sketch in the document or on a plot
• Insert hyperlinks to other Maple files, web sites, or email addresses
• Place instructions and equations side by side
• Bookmark specific areas
• Easily update, revise, and distribute your documents
In this chapter, we will create a document that demonstrates many of Maple's documentation features. For further ex-
amples, note that this guide was written using Maple.
221
222 • 7 Creating Mathematical Documents
Section Topics
Canvas (page 248) - Sketch an idea in the document • Insert a Canvas
by inserting a canvas • Drawing
• Canvas Style
• Inserting Images
Hyperlinks (page 252) and Bookmarks - Add • Inserting a Hyperlink in the Document
hyperlinks to various sources • Linking to an Email Address, Dictionary Topic, Help Page, Maplet
Application, Web Page, or Document
• Bookmarks
Embedded Components (page 257) - Insert buttons, • Overview of available components
sliders, and more in your document • Example using a task template
Spell Checking (page 259) - Verify text with the • How to Use the Spellcheck Utility
Maple spell checking utility
• Selecting a Suggestion
• User Dictionary
Creating Graded Assignments (page 261) - Create • Creating a Question
documents for automated testing and assessment • Viewing Questions in Maple
• Saving Test Content
Worksheet Compatibility (page 262) - Compatibility • Classic Worksheet interface does not support all Standard Worksheet
Issues interface features
If you paste into a math 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. However, note 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.
To modify text:
1. In the document, select the text to modify.
2. From the Format menu, select Character, and then the appropriate feature. Alternatively, select
Format Character from the context panel.
3. Select the quick formatting feature you want to apply (for example, bold or italic font).
Alternatively, use the context bar icons. For example, to apply a color to the parameters "f, x=x0..x1":
For font and highlight colors, you can select from Swatches, a color wheel, RGB values, or choose a color using the
eye dropper tool. See Figure 7.1.
224 • 7 Creating Mathematical Documents
To format this text as bold, click the Bold toolbar icon, . Also, select the text "Calling Sequence" and format as bold.
Result:
To modify text:
1. In the document, select text to modify.
2. From the Format menu, select Character, and then Attributes. The Character Style dialog opens. See Figure 7.2.
7.2 Document Formatting • 225
To modify a paragraph:
1. In the document, select the paragraph to modify.
2. From the Format menu, select Paragraph, and then the appropriate feature.
Attributes Submenu: Spacing, Indent, Alignment, Bullets, Line Break, and Page Break
You can change various paragraph attributes in one dialog.
• From the Format menu, select Paragraph, and then Attributes. The Paragraph Style dialog opens. See Figure 7.3.
• When changing spacing, you must indicate units (inches, centimeters, or points) in the Units drop-down list.
226 • 7 Creating Mathematical Documents
For example, in the pasted text, select all of the items under "Parameters", then open the Paragraph Style dialog.
Notice that the spacing has already been set.
In the Indent section, change the Left Margin indent to 10.0 pt.
In the Bullets and Numbering section, click the Style drop-down and select Dash. Click OK to close the dialog and
apply the styles.
Result:
• A character style controls text font, size, color, and attributes such as bold and italic. To override the character style
within a paragraph style, you must apply a character style or character formatting.
• A paragraph style controls all aspects of a paragraph's appearance, such as text alignment, line spacing, and indent-
ation. In Maple, each paragraph style includes a character style.
3. (Optional) If necessary, you can remove this style. From the Edit menu, select Undo.
• In the first row of the dialog, enter a style name in the blank text region.
Note: A preview of the style is displayed in the last row of the Character Style dialog.
3. To save the style, click OK or to abandon, click Cancel. If you have modified a style, all text in your document
that uses the altered style is updated to reflect the changes.
For example, in the pasted text, suppose we want to create a character style for the bold, purple parameter.
• From the Format menu, select Styles, then click Create Character Style.
• Enter the style name, "Placeholder", and then select the character attributes. In this case, click the Bold check box.
Then click the Color button and choose a dark purple. Click OK to create the character style.
Now you can apply the style to any text. Under Calling Sequences, select each list of parameters inside the command.
To apply the style, from the Styles drop-down menu in the toolbar, select Parameter.
7.2 Document Formatting • 229
Result:
For example, to format the title of the pasted text as a title, first select the line: "plot - create a two-dimensional plot".
In the Styles drop-down, select Title.
Result:
3. (Optional) If necessary, you can remove this style. From the Edit menu, select Undo.
For information on creating and managing style sets, see the worksheet/documenting/styles help page.
Sections
You can organize your document into sections, either before or after the text has been entered.
232 • 7 Creating Mathematical Documents
For example, to create two sections containing the two categories of information in the pasted text:
1. Select "Parameters" and all of the items under it.
2. Click the Indent toolbar item.
3. Cut and paste "Parameters" from inside the section to its title.
4. Similarly, create a section with the title "Calling Sequence", containing the items under that heading.
7.2 Document Formatting • 233
Result:
Note: The section titles are automatically formatted as section titles, but you can change the formatting through the
Paragraph Style dialog.
From the Insert menu, select Header Footer. The Header Footer dialog appears. See Figure 7.8.
The available elements include the current date, page number, number of pages, an image, the filename, or any plain
text. These elements can be placed in the left or right corner or the center of the page.
You can choose one of the predefined header or footer styles in the Predefined Header and Footer tab, or create your
own by clicking the Custom Header or Custom Footer tab.
For more information on header and footer options, refer to the headerfooter help page.
In a document, use the Show Contents dialog to hide all spreadsheets, input, output, or graphics, plus markers for
section boundaries, execution group boundaries, hidden table borders on mouse pointer roll over, and annotations. The
dialog is accessed from the View→Show/Hide Contents menu.
234 • 7 Creating Mathematical Documents
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 markers to hide them.
Note: By clearing the Input check box, Maple Input (1-D Math) and 2-D Math input are hidden. However, this will
not hide Text input in Document mode. Clearing the Graphics check box ensures that a plot, an image, or the Canvas
inserted in the document by using the Insert menu option is also hidden.
The plot resulting from executing the plot(sin) command is considered output.
• To show a plot from the plot(sin) command, select both the Output and Graphics check boxes in the Show Contents
dialog.
Inserted images and the Canvas are not considered output. As such, they are not hidden if you clear the Output check
box.
• To hide an inserted image or canvas, clear the Graphics check box in the Show Contents dialog.
Tab icon off. Allows you to move between placeholders using the Tab key.
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.
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 displayed in this vertical bar next to associated content.
To activate Markers:
• From the View menu, select Markers.
For further details on document blocks, see Document Blocks (page 41) in Chapter 1.
2. Enter text and an expression to evaluate. For example, enter "Plot the expression and its derivative,
". For detailed instructions on entering this phrase, see Example 6 - Enter Text and 2-D Math in the
Same Line Using Toolbar Icons (page 24) in Chapter 1.
3. Select the expression to display the context panel.
4. From the context panel, click Evaluate and Display Inline. The expression is evaluated.
5. Check that the input mode is Text, then enter the rest of the sentence: ", in the same plot." See Figure 7.10.
Before
After
Result:
236 • 7 Creating Mathematical Documents
3. To hide code again, clear the check box beside Show Command.
As document blocks can contain many execution groups, you can select to expand an execution group within a document
block.
1. Place the cursor near the end of the document block region.
2. From the Edit→Document Blocks menu, select Show Execution Group.
7.3 Commands in Documents • 237
3. To hide the group, clear the check box beside Show Execution Group.
Input from any executable math or commands is displayed in one instance, or only output is displayed.
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.
The rule-based typesetting functionality is available when the Typesetting level is set to Extended (the default). You
can set the typesetting level under Tools→Options→Display tab). This parsing functionality applies to 2-D Math
editing (Math mode) and output.
For example, you can change the display of derivatives to suit the content and audience of your document.
>
Tools→Options→Display tab: Typesetting level = Extended.
>
Tools→Options→Display tab: Typesetting level = Maple Standard.
For more information, see the Typesetting, TypesettingRuleAssist, and OptionsDialogDisplay help pages.
Auto-Execute
The Autoexecute feature allows you to designate regions of a document for automatic execution. These regions are
executed when the document opens or when the restart For more information, refer to the restart help page. command
is executed. This is useful when sharing documents. Important commands can be executed as soon as the user opens
your document. The user is not required to execute all commands.
Regions set to Autoexecute are denoted by exclamation mark symbols in the Markers region (View → Markers), .
238 • 7 Creating Mathematical Documents
For example, to display a plot in your document without saving the plot, making your document use less memory, you
can set a plot command to autoexecute.
1. After the plot instruction, enter a Maple prompt (Insert → Execution Group → After Cursor).
3. Select the plot, then select Edit → Remove Output → From Selection.
4. Place the cursor in the plot command, then select Format → Autoexecute → Set.
5. Save and close the document; on reopening, the command is re-executed.
Result:
Repeating Auto-Execution
To execute all marked groups:
• From the Edit menu, select Execute, and then Repeat Autoexecute.
Security Levels
By default, Maple prompts the user before automatically executing the document.
To set security levels for the autoexecute feature, use the Security tab in the Options dialog. For details, refer to the
OptionsDialogSecurity help page.
7.4 Tables • 239
7.4 Tables
Tables allow you to organize content in a document.
Creating a Table
To create a table:
1. From the Insert menu, select 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-adjustment to 100% of the document width. These
options, as well as the table dimensions, can be modified after table creation.
Create a table with 4 rows and 2 columns at the end of your document. In document mode, the input mode is set to
Math by default; in worksheet mode, the default is Text mode.
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
Enter a heading in both columns of the first row, in 2-D Math. You can use any text formatting features within each
cell; for example, bold and center the headings.
Tab icon on. Allows you to indent in the table using the Tab key.
Tab between the cells of the table and enter the following expressions in the first column. For each function, from the
context panel, select Differentiate → With respect to → x. Cut and paste the resulting expression into the second
column.
240 • 7 Creating Mathematical Documents
Row and column insertion is relative to the table cell that currently contains the cursor. If the document has an active
selection, insertion is relative to the selection boundaries.
• Column insertion can be to the left or right of the document position marker or selection.
• Row insertion can be above or below the marker or selection.
In your table, add a third column on the right to display the plots of these expressions. Add the heading, and insert a
blank plot region in each cell below it, by selecting Insert → Plot → 2-D (or 3-D for the second expression). Then
Ctrl-drag (Control-drag for Macintosh) each expression in the row into its plot region to display it. For details on this
procedure, see Plots and Animations (page 187).
Plot of and
With deleting operations using the Delete key, the Delete Table Contents dialog opens allowing you to specify the
desired behavior. For example, you can delete the selected rows, or delete the contents of the selected cells. See
Figure 7.11.
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. When there is a choice, the Table Paste Mode
dialog opens, allowing you to choose. See Figure 7.12.
242 • 7 Creating Mathematical Documents
Merging Cells
To merge adjacent cells in a table, select the cells you would like to merge. From the Table menu, select Merge Cells.
You can merge cells across row or column borders. See Figure 7.13. The resulting cell must be rectangular. The contents
of the individual cells in the merge operation are concatenated in execution order. See Figure 7.14. For details on cell
execution order, see Execution Order Dependency (page 245).
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.
Alternatively, the size of the table can be controlled from the Table Properties dialog. Select the Table menu and
then Properties. Two sizing modes are supported.
1. Fixed percentage of page width. Using this option, the table width adjusts 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. From the Table menu, select
Properties.
• You can set all, none, or only some of the borders to be visible in a table. Exterior borders are controlled separately.
• You can control the visibility of interior borders by using the Group submenu of the Table menu; grouping rows or
columns suppresses interior borders, provided that the interior border style is set by row and column group.
7.4 Tables • 243
For example, group the columns together, and group rows 2 to 4 together. Then in the Table Properties dialog, select
Exterior Borders: Top and bottom, and Interior Borders: By row and column group.
• Hidden borders are visible when the mouse hovers over a table. Note: 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. This setting applies to all tables in the worksheet. You can also set controls for an individual table from the
Table Properties→Show hidden borders option. Using this option, borders can be hidden in a table even if they
are set to visible on roll over in the Show/Hide Contents dialog.
Alignment Options
The table alignment tools control the horizontal alignment of columns and vertical alignment of rows.
For column alignment, the current selection is expanded to encompass all rows in the selected columns. The alignment
choice applies to all cells within the expanded selection. If the document does not contain a selection, the cursor position
is used to identify the column.
Similarly, the selection is expanded to include all columns in the selected rows for vertical alignment options. The
following table illustrates the vertical alignment options. The baseline option is useful for aligning equations across
multiple cells within a row of a table.
244 • 7 Creating Mathematical Documents
For example, set the Row alignment to Baseline for all rows, and set the Column alignment to Center for all columns.
Cell Color
You can set the background color of any cell or collection of cells to be any color. This coloring is independent of any
highlighting or text color that may also be applied.
To change the color of a cell, place the cursor in the cell, then from the Table menu, select Cell Color.... In the Select
A Color dialog, choose a color from the swatches, the color wheel, or RGB. See the DrawingTools help page for details
on color selection.
7.4 Tables • 245
For example, select the first row of the table and apply a light blue color. This sets the header off from the content below.
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.
Editable Tables
Tables can be marked as editable or non-editable. The editable property for tables is independent of the document ed-
itability, though if a document is marked as non-editable, tables cannot be edited. After a table has been marked as
non-editable, any content stored in the table cannot be modified. It is not possible to add any new content such as em-
bedded components or to run computations in execution groups or document blocks. Existing interactive embedded
components inside of a table will continue to work.
A table can be marked as editable or non-editable in its Table Properties using either the DocumentTools:-SetProperty
command or the Context Panel. To make a table editable or non-editable using the Context Panel, in the Table properties,
select or clear the Editable check box
Additional Examples
For more practice creating and manipulating tables, try creating the following tables at the end of your document.
Table of Values
This example illustrates how to set the visibility options for cell contents to display a table of values.
>
Create a table with 2 rows and 7 columns. Enter the values as below, and then select all table cells. In the Table →
Alignment menu, select Columns, and then Center.
0 1 2 3 4 5 6
7.4 Tables • 247
Table settings:
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:
1. Insert a table with 4 rows and 4 columns and enter the information shown above.
Insert a table with 1 row and 2 columns. Enter the information in text and executable 2-D Math to create the calculation
and plot, as shown.
Table Settings:
7.5 Canvas
Using the drawing tools, you can sketch an idea in a canvas, draw on plots, and draw on images. See Figure 7.15. For
details about the drawing feature, refer to the DrawingTools help page.
7.5 Canvas • 249
Insert a Canvas
To insert a canvas:
1. Place the cursor where the canvas is to be inserted.
2. From the Insert menu, select Canvas. A canvas with grid lines appears in the document at the insertion point. The
Drawing icon is available and associated context bar icons are displayed.
The tools include the following: selection tool, pencil (free style drawing), eraser, text insert, straight line, rectangle,
rounded rectangle, oval, diamond, alignment, drawing outline, drawing fill, drawing linestyle, and drawing canvas
properties.
Drawing
To draw with the pencil tool in the canvas:
1. From the Drawing icons, select the pencil icon.
2. Click and drag your mouse in the canvas to draw lines. Release the mouse to complete the drawing.
In your document, there are three plots, two of which are 2-D plots that can be drawn on. All of the information in the
table you made in the previous section could be drawn onto the plot, putting the information in a more concise layout.
Click on the plot, and notice that the Plot toolbar is open. However, the Drawing toolbar is also available. Click on
Drawing to see the toolbar.
Select the Text icon, , and click on the plot. Enter the expression in one text area, and its derivative in another,
as shown. You can move the text areas around on the plot so that they indicate the correct lines.
For details on the rest of the drawing features, refer to the DrawingTools help page.
Canvas Style
You can alter the Canvas in the following ways:
• Add a grid of horizontal and/or vertical lines. By default, the canvas opens with a grid of horizontal and vertical
lines.
• Change the grid line color.
7.5 Canvas • 251
These options can be changed in the Drawing Properties Canvas Icon. See Figure 7.17.
Figure 7.17: Drawing Properties Canvas Icon - Change the Gridline Color
Inserting Images
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
If the source file is altered, the embedded image does not change because the original object is pasted into the document.
Note: To constrain the proportions of the image as it is resized, press and hold the Shift key as you drag.
252 • 7 Creating Mathematical Documents
You can also draw on images in the same way as the drawing canvas For more information, refer to the worksheet/doc-
umenting/drawingtools help page..
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.
Within Maple, images are represented as dense, rectangular Arrays of 64-bit hardware floating-point numbers. Grayscale
images are 2-D, whereas color images are 3-D (the third dimension representing the color channels).
In addition to the commands in the ImageTools package, many ordinary Array and Matrix operations are useful for
image processing.
For details about this feature, refer to the ImageTools help page.
7.6 Hyperlinks
Use a hyperlink in your document to access any of the following.
• Web Page (URL)
• Email
• Worksheet
• Help Topic
• Task
• Dictionary Topic
• Maplet
3. In the Hyperlink Properties dialog box, the Link Text field is dimmed since the text region you highlighted is
used as the link text. This is demonstrated in Figure 7.18. The highlighted text region, Diff is dimmed.
4. Specify the hyperlink Type and Target as described in the appropriate following section.
Optionally, use an image as the link. Select the Image check box and click Choose Image for the file. In .mw files,
the image appears as the link. You can resize the image as necessary. Click and drag from the corners of the image to
resize.
3. Specify the hyperlink Type and Target as described in the appropriate following section.
Note: For information about email hyperlinks in the Classic Worksheet interface, see Worksheet Compatibility (page 262).
Linking to a Worksheet
To link to a Maple worksheet or document:
1. In the Type drop-down list, select Worksheet.
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.
Note: To link within a single Maple document, leave the Target field blank and choose the bookmark from the
Bookmark drop-down list.
Tip: When linking to another document, the default is to use a relative path. When sharing documents that contain
hyperlinks, ensure that target documents are in the same directory, or use a ZIP file to preserve the directory structure
if you are sharing a large collection of interlinking documents..
3. Click OK.
3. Click OK.
Linking to a Task
To link to a task:
1. In the Type drop-down list, select Task.
2. In the Target field, enter the topic name of the task template (see the status bar at the bottom of the Task Browser
window).
3. Click OK.
If the Maplet application exists, clicking the link launches the Maplet application. If the Maplet application contains
syntax errors, then error messages are displayed in a popup window.
When sharing documents that contain links to Maplet applications, ensure that target Maplet applications are in the
same directory, or use a ZIP file to preserve the directory structure if you are sharing a large collection.
3. Click OK.
Note: To link to a Maplet application available on a MapleNet™ web page, use the URL hyperlink type to link to the
web page. For information on MapleNet, see Embedded Components and Maplets (page 303).
If you want to enter the URI directly into Target field, you should copy the URI first.
6. Click OK.
Example
For this example, link the text "horizontal range" to the dictionary page for domain. As indicated in the section for
Linking to a Dictionary Topic, select Dictionary Topic in the Type drop-down list, and then enter Definition/domain
in the Target field.
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 hyperlinks in other documents.
Note: You can display bookmark properties by holding the pointer over a bookmark indicator. See Figure 7.19.
256 • 7 Creating Mathematical Documents
4. The new bookmark appears in the Bookmark dialog list. Click OK.
Note: You can also rename and delete bookmarks using the Bookmark dialog.
Go to a Bookmark
You can automatically move the cursor to the location of the bookmark in the active document.
1. From the Edit menu, select Go To Bookmark. The Go To Bookmark dialog opens with the current bookmarks
listed.
2. Select the bookmark "parameters" and click OK. The cursor moves to the bookmark, at the beginning of the Para-
meters section.
By default, palettes are displayed when you launch Maple. If palettes are not visible, use the following procedure:
1. From the View menu, select Palettes.
2. Select Expand Dock.
3. If the Components palette is not displayed, right-click (Control-click, for Macintosh) the palette dock. From the
context menu, select Show Palette, and then Components.
To insert the task template, from the Tools menu, select Tasks → Browse. In the table of contents, expand Document
Templates, and select Interactive Application. Click Insert Minimal Content. The following is inserted into your
document.
7.8 Spell Checking • 259
This configuration of components plots a linear function with slope and y-intercept given respectively by the two dials
and , and displays the function on a gauge. For details on how these
components work together, see Embedded Components and Maplets (page 303).
Note: when using the Spellcheck utility, you can fix spelling errors in the dialog, but you cannot change the text in
document. The Spellcheck utility does not check grammar.
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.
7.9 Creating Graded Assignments • 261
Note: Specifications in the Options dialog determine whether this word is recognized in your next Maple session. If
you set your custom dictionary and clicked Apply to Session, then this word will not be recognized in a new Maple
session. If you set your custom dictionary and clicked Apply Globally, then this new word will be recognized.
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 Maple T.A. (page 325).
Creating a Question
To create a question:
1. Open the Task browser (Tools→Tasks→Browse).
2. From the Maple T.A. folder, select the appropriate question type.
3. Insert the question template into a document.
4. Enter the question content as described in the template.
5. Repeat steps 1 to 4 for each question to add to the document.
262 • 7 Creating Mathematical Documents
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 dis-
played.
In both cases the View→Assignment menu is accessible. As such, users (students) can switch between the original
document contents and the displayed assignment.
If you create a document in the Standard Worksheet interface of Maple and then open it in the Classic Worksheet in-
terface, you should note possible changes to your file. For example, a bulleted list in the Standard Worksheet will not
be displayed with bullets in the Classic Worksheet. Many of the graphical features in this manual, especially those in
this chapter, are not available in the Classic Worksheet interface.
If you are creating documents for distribution, refer to the Compatibility help page.
8 Maple Expressions
This chapter provides basic information on using Maple expressions, including an overview of the basic data structures.
Many of the commands described in this chapter are useful for programming. For information on additional Maple
programming concepts, such as looping, conditional execution, and procedures, see Basic Programming (page 287).
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 enclosed in brackets([ ]).
263
264 • 8 Maple Expressions
For example:
>
Using negative integers, you can select an expression from the end of a sequence.
>
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.
>
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:
• Use square brackets.
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 the context panel or the solve command.
>
For more information, see Solving Equations and Inequations (page 86).
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:
>
>
To access entries in an Array, use either square bracket or round bracket notation.
Square bracket notation respects the actual index of an Array, even when the index does not start at 1.
>
>
>
>
Error, Array index out of range
Round bracket indexing normalizes the dimensions to begin at 1. Since this method is relative, you can access the end
of the array by entering
>
>
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. For more information on indexing methods,
refer to the rtable_indexing help page.
Large Arrays
Only one- and two-dimensional Arrays (with at most 10 indices in each dimension) display in the document. Larger
Arrays display as a placeholder.
8.2 Creating and Using Data Structures • 267
>
The Matrix Browser displays the Array. For more information, see Viewing Large Matrices and Vectors (page 124).
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.
>
>
You can also assign anything, for example, a list, to each element.
>
>
>
For information on defining Matrices and Vectors, see Creating Matrices and Vectors (page 122).
268 • 8 Maple Expressions
>
>
>
For more information on these data structures, including how to access entries and perform linear algebra computations,
see Linear Algebra (page 122).
Functional Operators
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 8.1. Maple inserts the function
definition.
2. Replace the placeholders, using Tab to move to the next placeholder. Note: If pressing the Tab key indents the
text, click the Tab icon in the toolbar. This allows you to move between placeholders.
3. Press Enter.
>
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.
8.2 Creating and Using Data Structures • 269
>
>
>
>
>
>
For more information on the eval command, and on using palettes and the context panel to evaluate an expression at
a point, see Substituting a Value for a Subexpression (page 279).
>
270 • 8 Maple Expressions
>
A vector function:
>
>
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.
Plotting:
>
>
Integration:
>
>
For information on integration and other calculus operations, see Calculus (page 134). For information on mathematical
functions, including accessing detailed information on the properties of a function, see Mathematical Functions (page 64)
and the FunctionAdvisor help page.
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.
>
>
>
>
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.
>
>
For information on enclosing keywords in right single quotes ('), see Delaying Evaluation (page 285).
Maple types are not mutually exclusive. An expression can be of more than one type.
>
>
For information on converting an expression to a different type, see Converting (page 277).
>
8.3 Working with Maple Expressions • 273
>
>
>
The has command searches the structure of the expression for an exactly matching subexpression.
>
To return all subexpressions of a particular type, use the indets command. For more information, see
Indeterminates (page 275).
For example:
>
(8.1)
>
(8.2)
>
(8.3)
For the following equation, the left endpoint of the range is the left-hand side of the right-hand side of the equation.
274 • 8 Maple Expressions
>
(8.4)
>
(8.5)
>
If the expression is not in normal form, Maple normalizes the expression before selecting the numerator or denominator.
(For more information on normal form, refer to the normal help page.)
>
>
>
The expression can be any algebraic expression. For information on the behavior for non-rational expressions, refer
to the numer help page.
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:
• Use the indets command.
The indets command returns the indeterminates as a set. Because the expression is expected to be rational, functions
such as sin(x), f(x), and sqrt(x) are considered to be indeterminate.
>
To return all subexpressions of a particular type, specify the type as the second argument. For information on types,
see Testing the Type of an Expression (page 272).
>
To test whether an expressions has subexpressions of a specific type (without returning them), use the has command.
For more information, see Testing for a Subexpression (page 273).
Manipulating Expressions
This section introduces the most commonly used manipulation commands. For additional manipulation commands,
see Iterative Commands (page 295).
Simplifying
To simplify an expression:
• Use the simplify command.
The simplify command applies simplification rules to an expression. Maple has simplification rules for various types
of expressions and forms, including trigonometric functions, radicals, logarithmic functions, exponential functions,
powers, and various special functions. You can also specify custom simplification rules using a set of side relations.
>
>
>
>
You can also use the simplify command with side relations. See Substituting a Value for a Subexpression (page 279).
Factoring
To factor a polynomial:
• Use the factor command.
>
>
Maple can factor polynomials over the domain specified by the coefficients. You can also factor polynomials over al-
gebraic extensions. For details, refer to the factor help page.
To factor an integer:
• Use the ifactor command.
>
Expanding
To expand an expression:
• Use the expand command.
The expand command distributes products over sums and expands expressions within functions.
>
>
8.3 Working with Maple Expressions • 277
Combining
To combine subexpressions in an expression:
• Use the combine command.
The combine command applies transformations that combine terms in sums, products, and powers into a single term.
>
Recall that was previously assigned to represent a two-dimensional array (see Creating and Using Arrays (page 265)).
>
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 110).
>
Converting
To convert an expression:
• Use the convert command.
The convert command converts expressions to a new form, type (see Expression Types (page 272)), or in terms of a
function. For a complete list of conversions, refer to the convert help page.
>
To convert measurements that use units, use the Unit Converter or the convert/units command.
>
For information on the Unit Converter and using units, see Units (page 99).
278 • 8 Maple Expressions
>
Maple has extensive support for converting mathematical expressions to a new function or function class.
>
Find an expression equivalent to the inverse hyperbolic cotangent function in terms of Legendre functions.
>
For more information on converting to a class of functions, refer to the convert/to_special_function help page.
Normalizing
To normalize an expression:
• Use the normal command.
>
You can also use the normal command for zero recognition.
>
>
>
Sorting
To sort the elements of an expression:
• Use the sort command.
>
>
>
Evaluating Expressions
In Worksheet mode, Maple inserts the eval command calling sequence that performs the substitution. 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 substitution.
>
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.
8.3 Working with Maple Expressions • 281
>
>
Maple did not perform the evaluation because is not an operand of For information on operands,
refer to the op help page.
For algebraic substitution, use the algsubs command, or the simplify command with side relations.
>
>
Numerical Approximation
To compute an approximate numerical value of an expression:
• Use the evalf command.
The evalf command returns a floating-point (or complex floating-point) number or 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 ([ ]).
282 • 8 Maple Expressions
>
See also Numerically Computing a Limit (page 135) and Numeric Integration (page 142).
If possible, the evalc command returns the output in the canonical form expr1 + i expr2.
In 2-D Math input, you can enter the imaginary unit using the following two methods.
• In the Common Symbols palette, click the i or j item. See Palettes (page 16).
• Enter i or j, and then press the symbol completion key. See Symbol Names (page 22).
>
>
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.
8.3 Working with Maple Expressions • 283
>
>
>
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.
>
>
Applying an Operation or Function to All Elements in a List, Set, Table, Array, Matrix, or Vector
You can use the tilde character (~) to apply an operation or function to all of the elements in a list, set, table, Array,
Matrix, or Vector.
In the following example, each element in the Matrix M is multiplied by 2 by adding a tilde character after the multi-
plication operator( .
>
(8.6)
>
(8.7)
In the following example, the function sin is applied to each element in the Matrix M.
284 • 8 Maple Expressions
>
(8.8)
The tilde character can also be used to apply a function to multiple data sets, for example,
>
(8.9)
You can use values in one data structure type to compute values in another data structure type, as long as both data
structures are dimensional and contain the same number of elements. In the following example, the values in an Array
are compared to the values in a Matrix that contains the same number of elements.
>
(8.10)
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?
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.
8.3 Working with Maple Expressions • 285
>
>
>
>
For more details on levels of evaluation, refer to the lastnameevaluation, assigned, and evaln help pages.
Delaying Evaluation
To prevent Maple from immediately evaluating an expression:
• Enclose the expression in right single quotes (' ').
Because right single quotes delay evaluation, they are referred to as unevaluation quotes.
>
>
>
>
Error, (in sum) summation variable previously assigned, second argument evaluates to 4 = 1
.. n
Note: In general, it is recommended that you unassign a name to use it as a variable. See Unassigning a Name Using
Unevaluation Quotes (page 286).
>
For example, if you enclose the keyword left in unevaluation quotes, Maple uses the name, not its assigned value.
>
>
>
>
(8.11)
>
(8.12)
>
(8.13)
For information on equation labels and equation label references, see Equation Labels (page 74).
Enclosing an expression in unevaluation quotes delays evaluation, but does not prevent automatic simplification.
>
(8.14)
>
>
You can also unassign a name using the unassign command. For more information, see Unassigning Names (page 73).
9 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 programming
constructs.
In Maple, you can write programs called procedures, and save them in modules. These modules can be used and dis-
tributed in the same way as Maple packages.
Important: It is strongly recommended that you use the Worksheet mode and 1-D Math input when programming or
using programming commands. Hence, all input in this chapter is entered as 1-D Math.
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.
287
288 • 9 Basic Programming
The conditional expressions (conditional_expression1, conditional_expression2, ...) can be any boolean expression.
You can construct boolean expressions using:
• Relational operators - <, <=, =, >=, >, <>
• Logical operators - and, or, xor, implies, not
• Logical names - true, false, FAIL
The statement sequences (statement_sequence1, statement_sequence2, ..., statement_sequenceN) can be any sequence
of Maple statements, including if statements.
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 the conditional expression evaluates to true, the sequence of statements is executed. Otherwise, Maple immediately
exits the if statement.
For example:
> x := 1173:
> if not isprime(x) then
ifactor(x);
end if;
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.
For example:
> if false then
"if statement";
else
"else statement";
end if;
9.2 Flow Control • 289
elif Clauses
In an if statement with elif clauses, Maple evaluates the conditional expressions 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:
> if not type(x, integer) then
printf("%a is not an integer.", x);
elif x >= 10 then
printf("%a is an integer with more than one digit.", x);
elif x >= 0 then
printf("%a is an integer with one digit.", x);
end if;
11 is an integer with more than one digit.
Order of elif Clauses: An elif clause's statement sequence is executed only if the evaluation of all previous conditional
expressions returns false or FAIL, and the evaluation of its conditional expression returns true. This means that
changing the order of elif clauses may change the behavior of the if statement.
In the following if statement, the elif clauses are in the wrong order.
> if not(type(x, integer)) then
printf("%a is not an integer.", x);
elif x >= 0 then
printf("%a is an integer with one digit.", x);
elif x >= 10 then
printf("%a is an integer with more than one digit.", x);
end if;
11 is an integer with one digit.
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.
The from, by, and to clauses are optional and can be in any order between the for clause and the do keyword. Table
9.1 lists the default clause values.
Examples
The following loop returns the square root of the integers 1 to 5 (inclusive).
9.2 Flow Control • 291
> 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.
292 • 9 Basic Programming
Syntax
The for/in loop has the following syntax.
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;
The until loop also repeats a statement sequence until a boolean expression does not hold, but it tests the terminating
condition at the end of each iteration of the loop, instead of the beginning.
Syntax
The while loop has the following syntax.
A while loops repeats until its boolean expression conditional_expression evaluates to false or FAIL. For more in-
formation on boolean expressions, see Conditional Execution (if Statement) (page 287).
Note the difference in syntax: the until clause appears in place of end do
Example
Compare the following loops. In the first one, the terminating condition is met the first time it is tested, and the loop
terminates immediately. In the second one, which uses the until clause, the body of the loop is performed before the
condition is tested, and the loop is used.
> a:=1;
(9.1)
> a:=1;
(9.3)
> do
a:=a+1;
until a mod 7=1:
> a;
(9.4)
The following loop computes the digits of 872,349 in base 7 (in order of increasing significance).
> x := 872349:
> while x > 0 do
irem(x, 7);
x := iquo(x, 7);
end do;
294 • 9 Basic Programming
After testing the loop bound condition at the beginning of each iteration of the for loop, Maple evaluates condition-
al_expression.
• If conditional_expression evaluates to false or FAIL, Maple exits the loop.
• If conditional_expression evaluates to true, Maple executes statement_sequence.
The equivalent general until loops have the same form but with end do replaced with until 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_ex-
pression 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 using the interrupt icon in the toolbar
(in worksheet versions). 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 and the Loops section of the Maple
Statements chapter of the Maple Programming Guide.
Command Description
seq Create sequence
add Compute numeric sum
mul Compute numeric product
select Return operands that satisfy a condition
remove Return operands that do not satisfy a condition
selectremove Return operands that satisfy a condition and separately return operands that do not satisfy a condition
map Apply command to the operands of an expression
zip Apply binary command to the operands of two lists or vectors
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 9.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.
The structure of the output is the same as the structure of the input. See Table 9.5.
For information on optional arguments to the selection commands, refer to the select help page.
An alternative to the map command is to apply a function elementwise, using ~. For more information ~, see Applying
an Operation or Function to All Elements in a List, Set, Table, Array, Matrix, or Vector (page 283). For information
on mapping over the operands of other expressions, optional arguments to the map command, and other mapping
commands, refer to the map help page.
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 9.7.
This is equivalent to
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.
298 • 9 Basic Programming
9.4 Procedures
A Maple procedure is a program consisting of Maple statements. Using procedures, you can quickly execute the contained
sequence of statements.
To improve readability of procedures, it is recommended that you define a procedure using multiple lines, and indent
the lines using space characters. To begin a new line (without evaluating the incomplete procedure definition), press
Shift+Enter. When you have finished entering the procedure, press Enter to create the procedure.
For example:
> p := proc()
sqrt(2);
end proc:
When the user runs the procedure, the parameter names are replaced by the argument values.
> geometric_mean(13, 17);
For more information on writing procedures, including options and local and global variables, refer to the procedure
help page.
> p := proc(a, b)
a + b;
a - b:
end proc:
> p(1, 2);
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(lcm);
To display a Maple library procedure definition, first set the value of the interface verboseproc option to 2. Then re-
execute the print calling sequence.
> interface('verboseproc' = 2):
300 • 9 Basic Programming
> print(lcm);
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.
Objects
Objects take the idea of associating data and procedures beyond what modules provide. With objects, multiple instances
of a class of objects can be created. Each individual object can have its own data, yet share other values and procedures
with the entire class objects. A well implemented class of objects can be used in Maple as naturally as a built-in Maple
type.
For more information on objects, refer to the object help page.
To execute the code within this region, click anywhere in this region, then click the Execute Selection icon ( ) on
the toolbar. (Alternatively, from the Edit menu, select Execute Code.)
You can hide the code in a code edit region by minimizing the region. To minimize, select View → Collapse Code
Edit Region. When the region is minimized, an icon appears with the first line of the code written next to it. It is re-
commended that you make the first line a comment describing the program or programs contained in the region. See
Figure 9.2.
To re-execute the code in the region while it is collapsed, click this icon.
Startup Code
Startup code allows you to define commands and procedures that are executed each time the document is opened and
after restart is called. This code is completely hidden to others reading the document. For example, use this region to
define procedures that will be used throughout the document code but that would take up space and distract readers
from the message of the document.
1. From the Edit menu, select Startup Code. Alternatively, click the startup code icon in the toolbar, .
2. Enter commands to be run each time the worksheet is opened or restart is called.
3. To check the syntax of the entered code while entering your Maple commands or before closing the editor, from
the Edit menu. select Check Syntax Now.
Note: You can also check the Check Syntax Automatically option to enable continuous syntax checking. It is recom-
mended that you check the syntax before saving so that your startup code does not prevent Maple from opening suc-
cessfully.
4. To save the contents, from the File menu, select Save Code. Alternatively, click the save icon, .
5. Close Startup Code.
302 • 9 Basic Programming
The Programming Guide is also available as a PDF on the Maplesoft web site.
http://www.maplesoft.com/documentation_center
10 Embedded Components and Maplets
These graphical components help you to create documents to use and share with colleagues or students, that interact
with Maple code within the document without needing the reader to understand that Maple code. Other methods of
interaction with Maple are described throughout this guide.
Component Descriptions
Check Box - Select or de-select. Change the caption, and enter code to
execute when the value changes.
Combo Box - Select one of the listed options from the drop-down menu.
Change the items listed, and enter code to execute when the value changes.
Data Table - Link this embedded component to a Matrix, Vector, or Array
in your worksheet.
303
304 • 10 Embedded Components and Maplets
Label - Display a label. The value can be updated based on code in the
document or another embedded component.
List Box - Display a list of items. Change the items listed, and enter code
to execute when an item is selected.
Math Expression - Enter or display a mathematical expression. The value
can be updated based on code in the document or another embedded
component.
Radio Button - Use with other radio buttons to select one in a group. Enter
code to execute when the value changes.
Rotary Gauge - Select or display an integer or floating-point value. Change
the display, and enter code to execute when the value changes.
Text Area - Enter or display plain text. The value can be updated based on
code in the document or another embedded component, and you can enter
code to execute when the value changes.
Toggle Button - Select or display one of two options. Change the images
displayed, and enter to code to execute when the value changes.
10.2 Using Embedded Components • 305
Exporting: Exporting a document with embedded components to other formats produces the following results.
• HTML format - components are exported as .gif files.
• RTF format - components are rendered as bitmap images in the .rtf document.
• LaTeX - components are exported as .eps files.
• PDF - components are rendered as static images.
Inserting Components
The graphical interface components can be inserted by using the Components palette (Figure 10.1) or by cutting/copying
and pasting existing components to another area of the document. Although copied components have most of the same
characteristics, they are distinct.
If the Components palette is not visible, see Palettes (page 16) for instructions on viewing palettes.
10.3 Creating Embedded Components • 307
Note: You can also edit embedded component properties and actions that are performed when a value changes by using
Maple worksheet Edit menu options, Edit > Component Properties, and Edit > Component Code, respectively.
For more information on options available in the Edit menu, see Edit menu options.
This simple example inserts a slider with a label that indicates the current value of the slider.
1. Place the cursor in the location where the embedded component is to be inserted.
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.
4. Click the label component. The Label context panel opens. See Figure 10.2.
Do(%SliderLabel(caption)=%Slider0(value));
14. Save the code, and exit the code editor.
As you move the arrow indicator, the value from the slider populates the Label caption field.
The table layout is best done after the components are finished, in case the configuration of the components changes
as you are working.
Create two DialComponents to set the parameters, and , one RotaryGaugeComponent to display the result, ,
one PlotComponent to display the plot, and one MathContainerComponent to display the function. Note that you
do not have to use the dial and rotary gauge components here, you can also use the slider instead.
310 • 10 Embedded Components and Maplets
Open the context panel for the first DialComponent, and notice that it already has a name. This name is used to reference
the component from other components, and is unique. Change the display of each of the components as follows:
• Dial0: no changes.
• Dial1: change the Value at Lowest Position to 1, the Value at Highest Position to 10, the Spacing of Major Tick
Marks to 1, and the Spacing of Minor Tick Marks to 1.
• RotaryGauge0: change the Value at Highest Position to 40, the Spacing of Major Tick Marks to 5, and the
Spacing of Minor Tick Marks to 1.
• Plot0: no changes.
• MathContainer0: change the Width in Pixels to 200, and the Height in Pixels to 45.
Note the names of all of the components, and close each dialog before moving on.
3. Create actions for the components.
Components can perform actions when their values are changed, so the code to execute needs to be in the dials. That
way, whenever one of them is changed, the other components are updated to reflect that change.
The following Maple commands retrieve the values of the parameters and display them in the other three components:
> parameter1:=Do(%Dial0):
> parameter2:=Do(%Dial1):
10.3 Creating Embedded Components • 311
> Do(%RotaryGauge0=parameter1/parameter2);
> Do(%MathContainer0=(y=parameter2*x+parameter1));
4. Test the actions.
To test these commands, first load the DocumentTools package with the following command.
> with(DocumentTools):
After loading the package, execute the commands in the document, and verify that the components you inserted are
updated: the gauge should change to the computed value, a plot should appear in the plot component, and the function
should display in the math container.
5. Troubleshooting.
The first Do command gives an error, because the second parameter is 0. One way to avoid this problem is to change
the range of the second dial. In the Component Properties dialog for the second DialComponent, change the Value
at Lowest Position from 0 to 1. Alternatively, you could change the code to compensate, with an if statement.
6. Copy the actions to the components.
After the commands work as expected, you can copy them into the components.
• Click the first DialComponent and select Edit Value Changed Code from the context panel. Copy and paste the
commands into the space between the use statements.
Create a table, and then cut and paste the components into it, along with explanatory text. Important: you must cut,
not copy, the components, or their names will be changed to avoid duplication. For information on creating and
modifying tables, refer to Tables (page 239).
312 • 10 Embedded Components and Maplets
Maplet applications are launched by executing Maplet code. Maplet code can be saved in a Maplet (.maplet) file or
Maple document (.mw).
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 -q <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.
10.5 Authoring Maplets • 313
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:
1. If present, evaluate user-defined procedures.
Myproc:=proc..
with( Maplets[Elements] );
Maplet_name:=Maplet( Maplet_definition );
Maplets[Display]( Maplet_name );
Important: When a Maplet application is running, you cannot interact with the Maple document.
Designing a Maplet application is similar to constructing a house. When building a house, you first construct the
skeletal structure (that is, foundation, floors, and walls) and then proceed to add the windows and doors. Constructing
a Maplet is no different. First define the rows and columns of the Maplet application and then proceed to add the body
elements (such as buttons, text fields, and plot regions).
Simple Maplet
A Maplet application can be defined using the commands in the Maplets[Elements] package and then launched using
the Maplets[Display] command. The following commands define and run a very simple Maplet application that contains
the text string "Hello World".
> with(Maplets[Elements]):
> MySimpleMaplet:= Maplet([["Hello World"]]):
> Maplets[Display](MySimpleMaplet):
Maplet Builder
To start the Maplet Builder:
• From the Tools menu, select Assistants → Maplet Builder.
Button element
Label element
Plot element
TextField element
For further information on the Maplet Builder, see the MapletBuilder help page. For more examples of designing
Maplets using the Maplet Builder, see examples/MapletBuilder.
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.
For more information on the Maplets package, refer to the MapletsPackage help page. For more examples of
designing Maplets using the Maplets package, see the Maplets/Roadmap help page.
Define the Maplet application. To suppress the display of the data structure associated with the Maplet application,
end the definition with a colon.
> PlottingMaplet:=Maplet(
BoxLayout(
BoxColumn(
# First Box Row
BoxRow(
# Define a Plot region
Plotter('reference' = Plotter1)
# End of first Box Row
318 • 10 Embedded Components and Maplets
),
# 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
):
For further examples using both the MapletBuilder and Maplets package commands, see the Maplets example
worksheets. For a listing, refer to the examples/index help page.
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:
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:
After using Maple to perform a computation, you can save the results to a file for later processing with Maple or another
program.
Note: Make sure you have right access to the directory in order to execute the example in the following subsections.
>
>
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.
319
320 • 11 Input, Output, and Interacting with Other Products
>
(11.1)
>
(11.2)
>
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.
For more information on matrices and vectors, see Linear Algebra (page 122).
>
In this example, small expressions are used. In practice, Maple supports expressions with thousands of terms.
>
(11.3)
>
(11.4)
>
Clear the memory using the restart command and retrieve the expressions using the read command.
>
>
11.3 Reading from Files • 321
>
(11.5)
For more information on writing to files, refer to the save help page.
ImportMatrix Command
The Import Data Assistant provides a graphical interface to the ImportMatrix 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.txt contains the following Maple commands.
S(19);
Note that the file should not contain prompts (>) at the start of lines.
When you read the file, Maple displays the results but not the commands.
(11.6)
>
>
(11.7)
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);
(11.8)
For more information, refer to the read and interface help pages.
11.4 Exporting to Other Formats • 323
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 communication 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 documents 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 distributions 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.
Maple Input
You can export a Maple document as Maple input so that it can be loaded using the Maple Command-line version.
Important: When exporting a document as Maple input for use in Command-line Maple, your document must contain
explicit semicolons in 1-D Math input. If not, the exported .mpl file does not contain semicolons, and Command-line
Maple generates errors.
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 applic-
ations. It displays and runs Maplet applications independently of the Maple Worksheet interface.
Important: When exporting a document as a Maplet Application for use in Command-line Maple or the
MapletViewer, your document must contain explicit semicolons. If not, the exported .maplet file does not contain
semicolons, and Command-line Maple and the MapletViewer generates errors.
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.
324 • 11 Input, Output, and Interacting with Other Products
PDF
Export a Maple document to a Portable Document Format (PDF) file so that you can open the file in a reader such as
Adobe® Acrobat®. The PDF document is formatted as it would appear when the Maple worksheet is printed using the
active printer settings.
Note: Images, plots, and embedded components may be resized in the PDF file.
Plain Text
Export a Maple document as plain text so that you can open the text file in a word processor.
Note: The generated .rtf format is compatible with Microsoft Word and Microsoft WordPad only.
Summary of Translation
Content HTML LaTeX Maple Maplet Maple Text Plain Text Rich Text PDF Format
Input Application Format
Text Maintained Maintained Preceded Preceded by Preceded by Maintained Maintained Maintained
by # # #
1-D Math Maintained Maintained Maintained Maintained Preceded by Preceded by Static image Static image
> >
2-D Math GIF or MathML 1-D Math or 1-D Math 1-D Math 1-D Math or 1-D Math or Static image Either text or
LaTeX 2e (if possible) (if possible) character-based character-based shapes
typesetting typesetting depending on
option
selected
Plot GIF Postscript file Not Not Not Not Static image Static image
exported exported exported exported
Animation Animated GIF Not exported Not Not Not Not Not Static image
exported exported exported exported exported
Hidden content Not exported Not exported Not Not Not Not Not Not exported
exported exported exported exported exported
Manually Not supported Not supported Not Not Not Not RTF page Maintained
inserted page supported supported supported supported break object
break
Hyperlink Links to help Plain text Plain text Plain text Plain text Plain text Plain text Plain text
pages become
plain text. Links
to documents are
renamed and
converted to
HTML links
Embedded GIF Not exported Not Not Not Not Static image Static image
image or exported exported exported exported
sketch output
Spreadsheet HTML table LaTeX tables Not Not Not Not RTF table Static image
exported exported exported exported
11.4 Exporting to Other Formats • 325
Content HTML LaTeX Maple Maplet Maple Text Plain Text Rich Text PDF Format
Input Application Format
Document Approximated LaTeX Not Not Not Not RTF style Maintained
style by HTML style environments exported exported exported exported
attributes and sections,
LaTeX 2e
macro calls
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.
Maple T.A.
Any document content outside Maple T.A. sections (indicated by green section markers) is ignored by the export process.
Additional Information
For more information about Maple resources for Maple T.A., refer to the MapleTAIntegration help page.
11.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, C#, Fortran 77, Java, MATLAB®, Visual
Basic, Perl, and Python.
External Calling
External calling allows you to use compiled C, C#, Fortran 77, or Java code in Maple. Functions written in these lan-
guages can be linked and used as if they were Maple procedures. With external calling you can use pre-written optimized
algorithms without the need to translate them into Maple commands. Access to the NAG library routines and other
numerical algorithms is built into Maple using the external calling mechanism.
External calling can also be applied to functions other than numerical algorithms. 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 package uses external
calling to allow you to query, create, and update databases in Maple. For more information, refer to the Database help
page.
For more information on using external calling, refer to the ExternalCalling help page.
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 ma-
nipulations of the input and output of similar Maple commands.
There is a Maplet interface to the MmaTranslator package. For more information, refer to the MmaToMaple help
page.
Matlab Package
The Matlab package enables you to translate MATLAB® code to Maple, as well as 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 2010, Excel 2013, and Excel 2016:
1. In Excel, click the File menu and select Options.
2. Click Add-ins.
3. In the Manage box select Excel Add-ins, and then Go.
4. Navigate to the Excel subdirectory of your Maple installation and select the appropriate file:
- For 32-bit Windows, select WMIMPLEX.xla (that is, select $MAPLE/Excel/WMIMPLEX.xla), and click
OK.
- For 64-bit Windows, select WMIMPLEX64.xla (that is, select $MAPLE/Excel/WMIMPLEX64.xla), and
click OK.
5. Select the Maple Excel Add-in check box.
6. Click OK.
For further details on enabling the Maple Excel Add-in, refer to the Excel help page.
For information on using this add-in, refer to the Using Maple in Excel 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,
C#, Java, or Visual Basic programs. (This is the reverse of external calling, which allows access to compiled C, C#,
Fortran 77, and Java code from Maple.)
To run your application, Maple must be installed. You can distribute your application to any licensed Maple user. For
additional terms and conditions on the use of OpenMaple, refer to the extern/OpenMapleLicensing.txt file in your
Maple installation.
For more details on using OpenMaple functions, refer to the OpenMaple help page.
MapleSim
MapleSimTM is a complete environment for modeling and simulating multidomain engineering systems. During a
simulation, MapleSim uses the symbolic Maple computation engine to generate the mathematical models that represent
the system behavior.
328 • 11 Input, Output, and Interacting with Other Products
Because both products are tightly integrated, you can use Maple commands and technical document features to edit,
manipulate, and analyze a MapleSim model. For example, you can use Maple commands and tools to manipulate your
model equations, develop custom components based on a mathematical model, and visualize simulation results.
MapleSim software is not included with the Maple software. For more information on MapleSim, visit
http://www.maplesoft.com/maplesim.
For more information on the Maple Player for iPad, visit http://www.maplesoft.com/products/MaplePlayer.
The MapleCloud
You can use the MapleCloud to share or store your Maple documents, worksheets and workbooks. Upload entire Maple
workbooks, standard Maple worksheets or selected content from a worksheet through the MapleCloud palette. Share
with all Maple users, share with a MapleCloud user group, or upload and store content in a user-specific area that only
you can access. For more information about groups, refer to the worksheet,cloud,groups help page.
Users need an internet connection to use the MapleCloud. To share content, create, manage and join user groups; and
view group-specific content, you must log in to the MapleCloud using a Maplesoft.com, Gmail™, or Google Mail™
account name and password.
A Maplesoft.com membership account gives you access to thousands of free Maple resources and MaplePrimes, which
is an active web community for sharing techniques and experiences with Maple and related products. To sign up for
a free Maplesoft.com membership account, visit http://www.maplesoft.com/members/sign_up_form.aspx. The
MapleCloud is integrated with several of these online features, so it is strongly recommended that you use a
Maplesoft.com membership account.
For more information on the MapleCloud, refer to the MapleCloud help page.
alignment format, 225
Index American spelling
spellcheck, 259
and operator, 288
Symbols angle brackets, 122, 124, 158
! toolbar icon, 53 angles, 277
!!! toolbar icon, 53 animations
"", 271 creating, 215
$, 137 customizing, 218
%H, 131 Application Center, 47
%T, 130 applications
&x, 131 sample documents, 46
', 73, 285 apply
(), 298 character styles, 227
->, 73 paragraph styles, 229
., 130 approximation, 81
1-D Math, 62 least-squares, 133
2-D Math, 62 numeric, 281
converting to 1-D, 63 arguments, 298
entering, 5 arithmetic, 52
shortcuts, 7 finite-precision, 80
switching to 1-D, 63 interval, 107
:, 62, 63 matrix and vector, 129
::, 110 modular, 83, 84
:=, 72 polynomial, 116
;, 62, 63 Arrays, 265
<>, 122, 124 indexing, 266
>, 62 large, 266
? arrow operator, 73
help topic, 43 assign command, 92
[], 128, 263, 264 assigned command, 285
^, 6, 85 assignment operator (:=), 72
entering, 85 Assistants
_, 74 Back-Solver, 29
_ZN~, 89 CAD Link, 29
`, 74 Code Generation, 29
{}, 264 Curve Fitting, 28, 121
|, 124 Data Analysis, 29, 151
~, 89, 111 Data Set Search, 29
element-wise operations, 283 eBook Publisher, 29
Equation Manipulator, 29
A Import Data, 29, 321
about command, 111 Installer Builder, 30
abs command, 83 Library Browser, 30
absolute value, 83 Maplet Builder, 30
add ODE Analyzer, 30, 93
word to your dictionary, 261 Optimization, 30, 144
add command, 296 overview, 25
additionally command, 111 Plot Builder, 30, 188
algebra, 121 Scientific Constants, 30
linear, 133 Special Functions, 30
polynomial, 116 Tools menu, 26
algsubs command, 281 Unit Converter, 277
Units Converter, 30, 100
329
330 • Index
W
Web page
adding hyperlink to, 253
Web site
access to Maple help pages, 47
Application Center, 47, 152
MaplePrimes, 47
Student Center, 152
Student Help Center, 47
Teacher Resource Center, 47
Technical Support, 47
Training, 47
Welcome Center, 46
Welcome Center, 46
while loops, 292
Windows
command complete, 7
with command, 65
Workbook Attachment
adding hyperlink to, 254
Workbook File
adding hyperlink to, 255
worksheet
adding hyperlink to, 253
Worksheet Environment, 2
Worksheet Migration Assistant, 30
Worksheet mode, 49, 61
worksheets
running, 9
write
to files, 319
X
xor operator, 288