Maple User Manual Copyright © Maplesoft, a division of Waterloo Maple Inc. 2005.
Maple User Manual Copyright Maplesoft, Maple, Maple Application Center, Maple Student Center, Maplet, Maple T.A., and MapleNet are all trademarks of Waterloo Maple Inc. © Maplesoft, a division of Waterloo Maple Inc. 2005. All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transcribed, in any form or by any means — electronic, mechanical, photocopying, recording, or otherwise.
Contents Preface .................................................................................................... xiii 1 Document Mode ...................................................................................... 1 1.1 Introduction ...................................................................................... 1 1.2 In This Chapter ................................................................................ 3 1.3 Simple Mathematical Expressions .......................................
iv • Contents Launching an Assistant or Tutor ...................................................... 48 Example: Using the Interactive Plot Builder ................................... 49 2.7 Task Templates .............................................................................. 51 Viewing Task Templates .................................................................. 51 Inserting a Task Template ................................................................ 52 Performing the Task .................
Contents • v 4 Mathematical Computations .............................................................. 123 4.1 In This Chapter ............................................................................ 125 4.2 Algebra ........................................................................................ 126 Polynomial Algebra ...................................................................... 126 4.3 Linear Algebra ............................................................................
vi • Contents Multiple Plots in the Same Plot Region ......................................... 214 5.3 Customizing Plots ....................................................................... 216 Interactive Plot Builder Options ................................................... 216 Context Menu Options .................................................................. 217 The plot and plot3d Options ......................................................... 220 5.4 Analyzing Plots ........................
Contents • vii Adding Graphical Interface Components ...................................... 268 Editing Component Properties: General Process ........................... 269 Removing Graphical Interface Components .................................. 269 Example Component Properties .................................................... 270 Printing and Exporting a Document with Embedded Components ................................................................................................. 271 6.
viii • Contents Tables ............................................................................................ 290 Matrices and Vectors ..................................................................... 291 Functional Operators ..................................................................... 292 Strings ........................................................................................... 297 7.3 Working with Maple Expressions ................................................
Contents • ix Saving ............................................................................................ 361 10 Input, Output, and Interacting with Other Products ......................... 363 10.1 In This Chapter .......................................................................... 363 10.2 Writing to Files ......................................................................... 363 Saving Data to a File ......................................................................
x • Contents
List of Tables Table 1.1: Shortcuts for Entering Mathematical Expressions .................... 6 Table 1.2: Entering a Definite Integral ..................................................... 13 Table 1.3: Symbol Completion Shortcut Keys ......................................... 17 Table 1.4: Summary of Document Mode Tools ....................................... 31 Table 1.5: Maple Help Resources ............................................................ 32 Table 3.1: Select Integer Commands ..............
xii • List of Tables Table 5.14: Creating Animations Using the Interactive Plot Builder ..... 223 Table 5.15: The animate Command ....................................................... 225 Table 5.16: Animation Options .............................................................. 226 Table 5.17: Customizing Animations Using the Context Menu ............ 229 Table 8.1: Default Clause Values ........................................................... 327 Table 8.2: Iterative Commands .......................
Preface The Maple Software The MapleTM software is a powerful system that you can use to solve complex mathematical problems. You can also create professional quality documents, presentations, and custom interactive computational tools in the Maple environment. You can access the power of the Maple computational engine through a variety of interfaces.
xiv • Preface Interface Description MapletTM Applications Graphical user interface 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 or command-line interfaces. This manual describes how to use the Standard Worksheet interface. Some features are not available in the Classic Worksheet interface and Commandline version.
Preface • xv • File input and output, and using Maple with third party products • Data structures For a complete list of manuals, study guides, toolboxes, and other resources, visit the Maplesoft Web site at http://www.maplesoft.com. Audience The information in this manual is intended for Maple users who have read the Maple Getting Started Guide. Conventions This manual uses the following typographical conventions.
xvi • Preface
1 Document Mode Using the Maple software, you can create powerful interactive documents. You can visualize and animate problems in two and three dimensions. You can solve complex problems with simple point-and-click interfaces or easyto-modify interactive documents. You can also devise custom solutions using the Maple programming language. While you work, you can document your process, providing text descriptions. 1.1 Introduction Maple has two modes: Document mode and Worksheet mode.
2 • 1 Document Mode ing the information in this chapter, see Chapter 2, Worksheet Mode (page 35), for information on using Worksheet mode. Worksheet mode sample: Find the value of the derivative of at . > (1.1) > (1.2) > Integrate over the interval . > Important: In every Maple document, you can use Document mode and Worksheet mode.
1.2 In This Chapter • 3 • You have access to the full mathematical engine. • You can create high quality interactive documents: easy-to-use computational tools, presentations, or publications.
4 • 1 Document Mode Section Topics Evaluating Expressions - How to evaluate expressions • Displaying the Value Inline • Displaying the Value on the Following Line Editing Expressions and Regenerating Output • - How to update expressions and results • • Updating a Single Computation Updating a Group of Computations Updating All Computations in a Document Entering Expressions - Overview of tools for • creating complex mathematical expressions • Palettes Performing Computations - Overview of tools f
1.3 Simple Mathematical Expressions • 5 Entering mathematical expressions, such as , , and natural in Math mode. Rational Expressions (Fractions) To enter a fraction: 1. Enter the numerator. 2. Press the forward slash (/) key. 3. Enter the denominator. 4. To exit the denominator, press the right arrow key. Powers To enter a power: 1. Enter the base. 2. Press the caret (^) key (Shift + 6). 3. Enter the exponent, which displays in math as a superscript. 4.
6 • 1 Document Mode Implied Multiplication In most cases, you do not need to include the multiplication operator, Insert a space character between two quantities to multiply them. . Note: In some cases, you do not need to enter the multiplication operator or a space character. For example, Maple interprets a number followed by a variable as multiplication. Shortcuts for Entering Mathematical Expressions Table 1.1 lists shortcut keys for entering and navigating mathematical expressions. Table 1.
1.3 Simple Mathematical Expressions • 7 Symbol/Format Key Command/symbol • completion • • Automatically Generated in Document Ctrl + Space, Windows Command + Shift + Space, Macintosh Ctrl + Shift + Space, UNIX Navigating an ex- Arrow keys pression For a complete list of shortcut keys, refer to the Math Shortcut and Hints help page. To access this help page in the Maple software, in Math mode enter ?MathShortcuts and then press Enter.
8 • 1 Document Mode 1.4 Evaluating Expressions To evaluate a mathematical expression, place the cursor in the expression and press Ctrl + = (Command + =, for Macintosh). That is, press and hold the Ctrl (or Command) key, and then press the equal sign (=) key. To the right of the expression, Maple inserts an equal sign and then the value of the expression. = You can replace the inserted equal sign with text or mathematical content. To replace the equal sign: 1. Select the equal sign. Press Delete. 2.
1.5 Editing Expressions and Updating Output • 9 In text, pressing Enter inserts a line break. You can use the basic algebraic operators, such as and , with most expressions, including polynomials—see Polynomial Algebra (page 126)—and matrices and vectors—see Linear Algebra (page 135). = = 1.5 Editing Expressions and Updating Output One important feature of Maple is that your documents are live. That is, you can edit expressions and quickly recalculate results. To update one computation: 1.
10 • 1 Document Mode • Click the Execute All toolbar icon . All results in the document are updated. 1.6 Entering Expressions Mathematical expressions can contain the following symbols. • Numbers: integers, rational numbers, complex numbers, floating-point values, finite field elements, , ∞, ... • Operators: • Constants: π, e, ... • Mathematical functions: sin(x), • Names (variables): x, y, z, α, β, ... • Data structures: sets, lists, Arrays, Vectors, Matrices, ... , , , /, , , , , ..
1.6 Entering Expressions • 11 • Layouts, like an item with a superscript and subscript. For example, see the Layout palette (Figure 1.2). • Mathematical operations, like a definite integral with placeholders for the integrand, variable of integration, and endpoints of the interval of integration. For example, see the Expression palette (Figure 1.3). • Specialized tools. For example, see the Matrix palette (Figure 1.4). For information on the Matrix palette, see Creating Matrices (page 135). Figure 1.
12 • 1 Document Mode Figure 1.3: Expression Palette Figure 1.4: Matrix Palette Using Palettes To insert a palette item: 1. In the palette, click the item to insert. The item is inserted at the cursor location. 2. If the item has colored placeholders, specify values for them. • To move to the next placeholder, press the Tab key. Note: You can drag palette items to any location in the document. For example, to insert the constant π: • In the Common Symbols palette, click the π symbol.
1.6 Entering Expressions • 13 Table 1.2: Entering a Definite Integral Action Result in Document 1. In the Expression palette, click the definite integration item . Maple inserts the definite integral. The left endpoint placeholder is selected. 2. Enter 0, and then press Tab. The right endpoint placeholder is selected. 3. Enter 1, and then press Tab. The integrand placeholder is selected. 4. Enter , and then press Tab. The vari- able of integration placeholder is selected. 5. Enter x.
14 • 1 Document Mode Defining a Mathematical Function To define a function of one or two variables: 1. In the Expression palette, click one of the function definition items (Figure 1.5). Maple inserts the function definition. 2. Replace the placeholder f with the function name. Press Tab. 3. Replace the parameter placeholders, x or x1, x2, with the independent variable names. Press Tab. 4. Replace the final placeholder, y, with the expression that defines the function value. Press Enter. Figure 1.
1.6 Entering Expressions • 15 Viewing and Arranging Palettes By default, palettes are displayed in palette docks at the sides of the Maple window. If no palette dock is visible, use the following procedure. To view palette docks: • From the View menu, select Palettes, and then Expand Docks. To expand a palette in a palette dock: • Click the triangle at the left of the palette title. To move a palette in a palette dock: • Drag the palette (by clicking its title) to the new location.
16 • 1 Document Mode Figure 1.6: Symbol Recognition Palette To use the Symbol Recognition palette: 1. With your mouse, draw a symbol in the handwriting recognition region (sketch area). 2. Click the button. A list of potential matching symbols is displayed. To view more symbols (where indicated), click the drop-down arrows associated with the displayed symbols. 3. To insert a symbol, click the displayed symbol. Symbol Names Each symbol has a name, and some have aliases.
1.6 Entering Expressions • 17 Using Symbol Names To insert a symbol by entering its name: 1. In Math mode, enter the symbol name. 2. Press the symbol completion shortcut key. See Table 1.3. Maple inserts the corresponding symbol. Table 1.3: Symbol Completion Shortcut Keys Operating System Shortcut Key Windows Ctrl + Space Macintosh Command + Shift + Space UNIX Ctrl + Shift + Space For example, to find the square root of : 1. Enter sqrt. 2. Press the completion shortcut key.
18 • 1 Document Mode Using Partial Symbol Names To enter a symbol quickly, you can enter the first few characters of its name and then press the completion shortcut key (see Table 1.3). • 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. To select an item, click its name or symbol.
1.7 Performing Computations • 19 1. In Math mode, enter int. Press the completion shortcut key. 2. From the completion list, select the indefinite integral item . 3. Enter sin(x). 4. Enter d. Press the completion shortcut key. 5. From the completion list, select d (differential). 6. Enter x. Note: From the int completion list, you can directly insert . 1.7 Performing Computations Using the Document mode, you can access the power of the advanced Maple mathematical engine without learning Maple syntax.
20 • 1 Document Mode Computing with Palettes As discussed in Palettes (page 10), some palettes contain mathematical operations. To perform a computation using a palette mathematical operation: 1. In a palette that contains operators, such as the Expression palette, click an operator item. 2. In the inserted item, specify values in the placeholders. 3. To execute the operation and display the result, press Ctrl+= (Command+=, for Macintosh) or Enter. For example, to evaluate inline: 1.
1.7 Performing Computations • 21 Figure 1.7: Context Menu To display the context menu for an expression: • Right-click (Control-click, for Macintosh) the expression. The context menu is displayed beside the mouse pointer. You can evaluate expressions using context menus. • The Evaluate and Display Inline operation (see Figure 1.7) is equivalent to pressing Ctrl+= (Command+=, for Macintosh). That is, it inserts an equal sign (=) and then the value of the expression.
22 • 1 Document Mode For example, use the Approximate operation to approximate a fraction: You can perform a sequence of operations by repeatedly using context menus. For example, to compute the second derivative of use the Differentiate operation on the expression, and then again on the output: The following subsections provide detailed instructions on performing a few of the numerous operations available using context menus. Figures in the subsections show related context menus or palettes.
1.7 Performing Computations • 23 Figure 1.8: Approximating the Value of a Fraction You can replace the inserted right arrow with text or mathematical content. To replace the right arrow ( ): 1. Select the arrow. Press Delete. 2. Enter the replacement text or mathematical content. Note: To replace the the right arrow with text, you must first press F5 to switch to Text mode. For example, you can replace the arrow with the text "is approximately equal to" or the symbol ≈.
24 • 1 Document Mode Solving an Equation You can find an exact (symbolic) solution or an approximate (numeric) solution of an equation. For more information on symbolic and numeric computations, see Symbolic and Numeric Computation (page 66). To solve an equation: 1. Enter an equation. 2. Display the context menu. 3. From the context menu, select Solve or Solve Numerically.
1.7 Performing Computations Figure 1.9: FPS Units Palette • 25 Figure 1.10: SI Units Palette To insert an expression with a unit: 1. Enter the expression. 2. In a unit palette, click a unit symbol. Note: To include a reciprocal unit, divide by the unit. To evaluate an expression that contains units: 1. Enter the expression using the units palettes to insert units. 2. Right-click (Control-click, for Macintosh) the expression. 3. From the context menu, select Units and then Simplify.
26 • 1 Document Mode Assistants and Tutors Assistants and tutors provide point-and-click interfaces, with buttons, text input regions, and sliders. Assistants Assistants help you accomplish many tasks, such as solving ordinary differential equations (ODEs) and ODE systems, creating plots and matrices, curve fitting, and performing unit conversions (Figure 1.11). • From the Tools menu, select Assistants, and then one of the topic submenus.
1.7 Performing Computations • 27 Figure 1.11: Unit Converter Assistant Tutors Over 40 interactive tutors help student users gain insight and understanding of topics in courses such as precalculus, calculus, multivariate calculus, vector calculus, and linear algebra. Some tutors help you work through a problem step-by-step. • From the Tools menu, select Tutors, and then one of the topic submenus.
28 • 1 Document Mode Figure 1.12: Function Composition Tutor Using a Context Menu to Launch the Plot Builder You can plot a mathematical expression using the Interactive Plot Builder. The Plot Builder can be launched from the Tools menu or the context menu for an expression. To create a plot using a context menu: 1. Enter or compute a mathematical expression with one or two independent variables. 2. Right-click (Control-click, for Macintosh) the expression to plot.
1.7 Performing Computations • 29 3. From the context menu, select Plots, and then Plot Builder. The Interactive Plot Builder is displayed. See Figure 1.13. 4. In the Select Plot Type dialog, select the plot type, for example, 3-D plot or 2-D contour plot. 5. To immediately create a plot, click the Plot button. To customize the plot before generating it, click the Options button. Figure 1.13: Interactive Plot Builder: Select Plot Type Dialog For example, Figure 1.14 shows a plot of .
30 • 1 Document Mode Figure 1.14: 3-D Plot of an Expression For more information on plots, see Plots and Animations (page 189). 1.8 Document Mode Summary The key features of Document mode are summarized in Table 1.4.
1.8 Document Mode Summary • 31 Table 1.4: Summary of Document Mode Tools Action Methods Entering Mathematical Expressions • For example: • Evaluating Mathematical Expressions (Result Inline)* Math editing shortcut keys, including symbol name completion Palettes • • Ctrl + = (Command + =, for Macintosh) From the context menu, select Evaluate and Display Inline. • Enter key • From the context menu, select Evaluate.
32 • 1 Document Mode * Inline evaluation is available in Document mode and document blocks. For information on document blocks, see Document Blocks (page 247). 1.9 Getting Help The Maple Help System contains resources to help you use Maple. See Table 1.5. Table 1.5: Maple Help Resources Resource Description Maple Tour An interactive overview of Maple. • From the Help menu, select Take a Tour of Maple. Online Manuals Online manuals, including the Maple Getting Started Guide and this manual.
1.9 Getting Help • 33 Resource Description Help Pages Help for Maple features, commands, packages, and more. Help pages include examples and screenshots to help you quickly learn. • From the Help menu, select Maple Help. You can search for a help topic, perform a text search, or browse the Table of Contents. You can also open a help page by entering ? at the input prompt (in Worksheet mode) or in Math mode (in Document mode).
34 • 1 Document Mode
2 Worksheet Mode The Worksheet mode of the Standard Worksheet interface is designed for: • Interactive use through Maple commands, which may offer advanced functionality or customized control not available using context menus or other syntax-free methods • Programming using the powerful Maple language Using Worksheet mode, you have access to most of the Maple features described in Chapter 1 including: • Math and Text modes • Palettes • Context menus • Assistants and tutors For information on the
36 • 2 Worksheet Mode 2.
2.2 Input Prompt • 37 Section Topics Equation Labels - Automatically generated • labels that you can use to refer to expressions • Displaying Equation Labels Referring to a Previous Result • Execution Groups with Multiple Outputs • Label Numbering Schemes • Features of Equation Labels 2.2 Input Prompt In Worksheet mode, you enter input at the Maple input prompt (>). The default mode for input is Math mode (2-D Math). To evaluate input: • Press Enter.
38 • 2 Worksheet Mode Suppressing Output To suppress the output, enter a colon (:) at the end of the input. > A set of Maple input and its output are referred to as an execution group. 1-D Math Input You can also insert input using Text mode (1-D Math). The input is entered as a one-dimensional sequence of characters. 1-D Math input is red. To enter input using 1-D Math: • At the input prompt, press F5 to switch from 2-D Math to 1-D Math.
2.2 Input Prompt • 39 2. On the Display tab, in the Input display drop-down list, select Maple Notation. 3. Click Apply to Session (to set for only the current session) or Apply Globally (to set for all Maple sessions). To convert 2-D Math input to 1-D Math input: 1. Select the 2-D Math input. 2. From the Format menu, select Convert To, and then 1-D Math Input. Important: In Document mode, you can execute a statement only if you enter it in Math mode.
40 • 2 Worksheet Mode 2.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. You must use 1-D Math input when programming in Maple. Basic Programming (page 321) provides an introduction to Maple programming. To learn how to use Maple commands, use task templates. See Task Templates (page 51).
2.3 Commands • 41 For example, to differentiate an expression, use the diff command. The required parameters are the expression to differentiate, which must be specified first, and the independent variable. > For a complete list of functions (commands that implement mathematical functions), for example, BesselI and AiryAi, available in the library, refer to the ?initialfunctions help page. (To display this help page, enter ?initialfunctions at the input prompt.
42 • 2 Worksheet Mode Package Commands To use a package command, the calling sequence must include the package name, and the command name enclosed in brackets ([ ]). package[command](arguments) If you are frequently using the commands in a package, load the package. To load a package: • Use the with command, specifying the package as an argument. The with command returns a list of the package commands loaded (unless you suppress the output by entering a colon at the end of the calling sequence).
2.3 Commands • 43 To unload a package: • Use the unwith command, specifying the package as an argument. > To use the examples in this manual, you may be required to use the unwith command between examples. Some packages contain commands that have the same name as a top-level command. When you load one of these packages, Maple returns a warning. For example, the plots package contains a changecoords command. Maple also contains a top-level changecoords command.
44 • 2 Worksheet Mode 2.4 Palettes Palettes are collections of related items that you can insert by clicking or dragging. See Figure 2.1. Figure 2.1: Expression Palette You can use palettes to enter input. For example, evaluate a definite integral using the definite integration item in the Expression palette. In 2-D Math, clicking the definite integration item inserts: > 1. Enter values in the placeholders. To move to the next placeholder, press Tab.
2.4 Palettes • 45 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=a..b); Specify the problem values (using the Tab to move to the next placeholder), and then press Enter. > int(tanh(x), x = 0..1): Note: Some palette items cannot be inserted into 1-D Math because they are not defined in the Maple language. When the cursor is in 1-D Math input, unavailable palette items are dimmed.
46 • 2 Worksheet Mode 2.5 Context Menus A context menu is a pop-up menu that lists the operations and actions you can perform on a particular expression. See Figure 2.2. Figure 2.2: Integer Context Menu In Worksheet mode, you can use context menus to perform operations on 2D Math and output. To use a context menu: 1. Right-click (Control-click, for Macintosh) the expression. The context menu is displayed. 2. From the context menu, select an operation.
2.5 Context Menus • 47 For example: To determine a rational expression (fraction) that approximates a floating-point number: 1. Right-click (Control-click, for Macintosh) the floating-point number. 2. From the context menu, select Conversions, and then Rational. The inserted calling sequence includes an equation label reference to the number you are converting. > (2.1) > For information on equation labels and equation label references, see Equation Labels (page 59).
48 • 2 Worksheet Mode 2.6 Assistants and Tutors Assistants and tutors provide point-and-click interfaces, with buttons, text input regions, and sliders. See Figure 2.3. Figure 2.3: Interactive Plot Builder: Select Plot Type Dialog Launching an Assistant or Tutor To launch an assistant or tutor: 1. Open the Tools menu. 2. Select Assistants or Tutors. 3. Navigate to and select one of the assistants or tutors.
2.6 Assistants and Tutors • 49 Example: Using the Interactive Plot Builder To plot an expression using the Interactive Plot Builder: 1. From the Tools menu, select Assistants, and then Plot Builder. Maple inserts the following command in the document and launches the Interactive Plot Builder. > 2. In the Interactive Plot Builder: Specify Expressions window (Figure 2.4), click Add. The Add/Edit Expression dialog is displayed. Figure 2.
50 • 2 Worksheet Mode 3. In the Add/Edit Expression dialog, enter the expression to plot using 1D Math. See Figure 2.5. Figure 2.5: Interactive Plot Builder: Add/Edit Expression Dialog 4. Repeat steps 2 and 3 for each expression to add to the plot. 5. After adding the expressions, in the Interactive Plot Builder: Specify Expressions window (Figure 2.4), click Done. 6. In the Interactive Plot Builder: Select Plot Type dialog (Figure 2.
2.7 Task Templates • 51 For more information on assistants and tutors, see Assistants and Tutors (page 26) in Chapter 1. 2.7 Task Templates Maple can solve a diverse set of problems. The task template facility helps you quickly find and use the commands required to perform common tasks. After inserting a task template, specify the parameters of your problem in the placeholders, and then execute the commands, or click a button. Viewing Task Templates The Task Browser (Figure 2.
52 • 2 Worksheet Mode You can also browse the task templates in the Table of Contents of the Maple Help System. Figure 2.6: Task Browser Inserting a Task Template To insert a task template from the Task Browser or Help Navigator: 1. Navigate to the task. 2. Click one of the insertion or copy buttons.
2.7 Task Templates • 53 • Click the Insert Default Content button. Maple inserts the default content. The default content level is set using the Options dialog. For details, see the following steps. • Click the Insert Minimal Content button. Maple inserts only the 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.
54 • 2 Worksheet Mode To use an inserted task template: 1. Specify values for the parameters in placeholders or using graphical interface components. You can move to the next placeholder by pressing Tab. 2. Execute all commands in the task by: • Placing the cursor in the first task command, and then pressing Enter repeatedly to execute each command. • Selecting all the template commands, and then clicking the execute toolbar icon . 3.
2.9 Names • 55 You can format text in a text region. Features include: • Character styles • Paragraph styles • Sections and subsections • Tables For more information on formatting documents, see Creating Mathematical Documents (page 231). 2.9 Names Instead of re-entering an expression every time you need it, you can assign it to a name or add an equation label to it. Then you can quickly refer to the expression using the name or an equation label reference.
56 • 2 Worksheet Mode 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 short cut key. See Shortcuts for Entering Mathematical Expressions (page 6). 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 310).
2.9 Names • 57 For example, define a function that squares its argument. > square := x -> x^2: > square(32); For more information on functions, see Functional Operators (page 292). Protected Names Protected names are valid names that are predefined or reserved. If you attempt to assign to a protected name, Maple returns an error. > Error, attempting to assign to `sin` which is protected For more information, refer to the ?type/protected and ?protect help pages.
58 • 2 Worksheet Mode Unassigning All Names The restart command clears the Maple internal memory. The effects include unassigning all names and unloading all packages. For more information, refer to the ?restart help page. Note: To use the examples in this manual, you may be required to use the unassign or restart command between examples. Valid Names A Maple name must be one of the following. • A sequence of alphanumeric and underscore (_) characters that begins with an alphabetical character.
2.10 Equation Labels • 59 2.10 Equation Labels Maple marks the output of each execution group with a unique equation label. Note: The equation label is displayed to the right of the output. > (2.2) Using equation labels, you can refer to the result in other computations. > (2.3) Displaying Equation Labels Important: By default, equation labels are displayed. If equation label display is turned off, complete both the following operations.
60 • 2 Worksheet Mode To insert an equation label reference: • From the Insert menu, select Label. (Alternatively, press Ctrl+L. For Macintosh, Command+L.) • In the Insert Label dialog, enter the label value, and then click OK. Maple inserts the reference. For example: To integrate the product of (2.2) and (2.3): 1. In the Expression palette, click the indefinite integration item The item is inserted and the cursor moves to the integrand placeholder. 2. Press Ctrl+L (Command+L, for Macintosh). 3.
2.10 Equation Labels • 61 Execution Groups with Multiple Outputs An equation label is associated with the last output within an execution group. > (2.4) > Label Numbering Schemes You can number equation labels in two ways: • Flat - Each label is a single number, for example, 1, 2, or 3. • Sections - Each label is numbered according to the section in which it occurs. For example, 2.1 is the first equation in the second section, and 1.3.
62 • 2 Worksheet Mode Figure 2.7: Format Labels Dialog: Adding a Prefix Features of Equation Labels Although equation labels are not descriptive names, labels offer other important features. • Each label is unique, whereas a name may be inadvertently assigned to more than once for different purposes. • Maple labels the output values sequentially. If you remove or insert an output, Maple automatically renumbers all equation labels and updates the label references.
2.10 Equation Labels • 63 using Worksheet mode. Except where noted, all features are available in both Worksheet mode and Document mode.
64 • 2 Worksheet Mode
3 Performing Computations This chapter discusses key concepts related to performing computations with Maple. It discusses important features that are relevant to all Maple users. After learning about these concepts, you will learn how to use Maple to solve problems in specific areas in the following chapter. 3.
66 • 3 Performing Computations Section Topics Units, Scientific Constants, and Uncertainty Units - How to construct and compute with expres- • Conversions sions that have units, scientific constants, or • Applying Units to an Expression uncertainty • Performing Computations with Units • Changing the Current System of Units • Extensibility Scientific Constants • Scientific Constants • Element and Isotope Properties • Value, Units, and Uncertainty • Performing Computations • Modification and Exte
3.2 Symbolic and Numeric Computation • 67 Numeric computation is the manipulation of expressions in the context of finite-precision arithmetic. Expressions involving 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.
68 • 3 Performing Computations > > > Floating-Point Computations In some situations, a numeric approximation of an exact quantity is required. For example, the plot command requires the expression it is plotting to evaluate to numeric values that can be rendered on the screen: π cannot be so rendered, but can be. Maple distinguishes approximate from exact quantities by the presence or absence of a decimal point: proximate, while 9 is ap- is exact.
3.2 Symbolic and Numeric Computation • 69 If a mathematical function is passed a floating-point argument, it normally attempts to produce a floating-point approximation to the result. > Converting Exact Quantities to Floating-Point Values To convert an exact quantity to a numeric approximation of that quantity, use the evalf command or the Approximate context menu operation (see Approximating the Value of an Expression (page 22)).
70 • 3 Performing Computations > For more information, see the ?evalf and ?Digits help pages. Note: When appropriate, Maple performs floating-point computations directly using your computer's underlying hardware. Sources of Error By its nature, floating-point computation normally involves some error. Controlling the effect of this error is the subject of active research in Numerical Analysis.
3.3 Integer Operations • 71 > For information on evaluating an expression at a point, see Substituting a Value for a Subexpression (page 310). For information on creating a series approximation, see Series (page 161). For more information on floating-point numbers, refer to the ?float and ?type/float help pages. 3.
72 • 3 Performing Computations Figure 3.1: Context Menu for an Integer In Worksheet mode, Maple uses an equation label reference in the ifactor calling sequence. > (3.1) > For more information on equation labels, see Equation Labels (page 59). For more information on using context menus in Worksheet mode, see Context Menus (page 46). For information on using context menus in Document mode, see Context Menus (page 20).
3.3 Integer Operations • 73 You can also enter the ifactor command and specify the integer to factor as an argument. > Maple has many other integer commands, including those listed in Table 3.1. Table 3.
74 • 3 Performing Computations > > > For information on finding integer solutions to equations, see Integer Equations (page 94). Non-Base 10 Numbers and Other Number Systems Maple supports: • Non-base 10 numbers • Finite ring and field arithmetic • Gaussian integers Non-Base 10 Numbers To represent an expression in another base, use the convert command.
3.3 Integer Operations • 75 For information on enclosing keywords in right single quotes ('), see Delaying Evaluation (page 317). You can also use the convert/base command. > Note: The convert/base command returns a list of digit values in order of increasing significance. Finite Rings and Fields Maple supports computations over the integers modulo m. The mod operator evaluates an expression over the integers modulo m. > By default, the mod operator uses positive representation (modp command).
76 • 3 Performing Computations Table 3.2: Modular Arithmetic Operators Operation Operator Example Addition + > Subtraction - > * > ^(-1) > / > &^ > Multiplication (displays in 2-D Math as ) Multiplicative inverse (displays in 2-D Math as a superscript) Division (displays in 2-D Math as Exponentiation1 ) 1 To enter a caret (^) in 2-D Math, enter a backslash character followed by a caret, that is, \^.
3.3 Integer Operations • 77 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. The GIfactor command returns the Gaussian integer factorization. > 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 10). • Enter i or j, and then press the symbol completion key.
78 • 3 Performing Computations 3.4 Solving Equations You can solve a variety of equation types, including those described in Table 3.3. Table 3.
3.4 Solving Equations • 79 Figure 3.2: Context Menu for an Equation In Worksheet mode, Maple inserts a calling sequence that solves the equation followed by the solutions. If you select Solve, Maple computes exact solutions. > (3.2) > If you select Solve Numerically, Maple computes floating-point solutions.
80 • 3 Performing Computations > (3.3) > 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 84). Symbolically Solving Equations and Inequations The solve command is a general solver that determines exact symbolic solutions to equations or inequations.
3.4 Solving Equations • 81 Expressions You can specify expressions instead of equations. The solve command automatically equates them to zero. > W represents the Lambert W function. Multiple Equations To solve multiple equations or inequations, specify them as a set or list. > > Solving for Specific Unknowns By default, the solve command returns solutions for all unknowns. You can specify the unknowns for which to solve.
82 • 3 Performing Computations To solve for multiple unknowns, specify them as a list. > Transcendental Equations In general, the solve command returns one solution to transcendental equations. > > To produce all solutions, set the _EnvAllSolutions environment variable to true. Note: To enter an underscore character (_) in 2-D Math, enter \_. > > Maple uses variables of the form _ZN~ , where N is a positive integer, to represent arbitrary integers.
3.4 Solving Equations • 83 RootOf Structure The solve command may return solutions, for example, to higher order polynomial equations, in an implicit form using RootOf structures. > (3.4) These RootOf structures are placeholders for the roots of the equation . The index parameter numbers and orders the four solutions. Like any symbolic expression, you can convert RootOf structures to a floating-point value using the evalf command. > Some equations are difficult to solve symbolically.
84 • 3 Performing Computations For information on verifying and using solutions returned by the solve command, see Working with Solutions (page 86). Numerically Solving Equations The fsolve command solves equations numerically. The behavior of the fsolve command is similar to that of the solve command. > > (3.5) Note: You can also numerically solve equations using the context menus. See Solving Equations and Inequations (page 78).
3.4 Solving Equations • 85 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.
86 • 3 Performing Computations 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. > (3.6) 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.
3.4 Solving Equations • 87 (3.8) > For more information, see Substituting a Value for a Subexpression (page 310). 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 to equation2 , (3.6), 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.
88 • 3 Performing Computations You can evaluate this function at symbolic or numeric values. > > > For more information on defining and using functions, see Functional Operators (page 292).
3.4 Solving Equations • 89 • Recurrence relations Ordinary Differential Equations (ODEs) Maple can solve ODEs and ODE systems, including initial value and boundary value problems, symbolically and numerically. ODE Analyzer Assistant The ODE Analyzer Assistant is a point-and-click interface to the Maple ODE solving routines. To launch the ODE Analyzer: • From the Tools menu, select Assistants, and then ODE Analyzer. Maple inserts the dsolve[interactive]() calling sequence in the document.
90 • 3 Performing Computations t, t) corresponds to . For more information on the diff command, see The diff Command (page 157). After defining an ODE, you can solve it numerically or symbolically. To solve a system numerically using the ODE Analyzer Assistant: 1. Ensure that the conditions guarantee uniqueness of the solution. 2. Ensure that all parameters have fixed values. 3. Click the Solve Numerically button. 4. In the Solve Numerically window (Figure 3.
3.4 Solving Equations • 91 Figure 3.4: ODE Analyzer Assistant: Solve Numerically Dialog To solve a system symbolically using the ODE Analyzer Assistant: 1. Click the Solve Symbolically button. 2. In the Solve Symbolically window (Figure 3.5), you can specify the method and relevant method-specific options to use for solving the problem. 3. To compute the solution, click the Solve button.
92 • 3 Performing Computations Figure 3.5: ODE Analyzer Assistant: Solve Symbolically 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.
3.4 Solving Equations • 93 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. For more information, refer to the ?ODEAnalyzer help page.
94 • 3 Performing Computations (3.9) > The solution is an arbitrary univariate function applied to . 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. To return all information, set infolevel to 5. > > Checking arguments ... Getting info and details about the PDE ...
3.4 Solving Equations • 95 > Integer Equations in a Finite Field To solve an equation modulo an integer, use the msolve command. For more information, refer to the ?msolve help page. The msolve command finds solutions for all variables. > Solving Linear Systems To solve a linear system, use the LinearAlgebra[LinearSolve] command. For more information, refer to the ?LinearAlgebra[LinearSolve] help page. The LinearSolve command returns the vector x that satisfies A . x = B.
96 • 3 Performing Computations For more information on using Maple to solve linear algebra problems, see Linear Algebra (page 135). Solving Recurrence Relations To solve a recurrence relation, use the rsolve command. For more information, refer to the ?rsolve help page. The rsolve command finds the general term of the function. > 3.5 Units, Scientific Constants, and Uncertainty In addition to manipulating exact symbolic and numeric quantities, Maple can perform computations with units and uncertainties.
3.5 Units, Scientific Constants, and Uncertainty • 97 Maple has a library of hundreds of scientific constants with units, including element and isotope properties. To support computations with uncertainties, Maple propagates errors through computations. Units The Units package in Maple provides a library of units, and facilities for using units in computations. It is fully extensible so that you can add units as required.
98 • 3 Performing Computations Table 3.4: Sample Dimensions Dimension Time Base Dimensions time Example Units second, minute, hour, day, week, month, year, millennium, blink, lune Energy joule, electron volt, erg, watt hour, calorie, Calorie, British thermal unit Electric potential volt, abvolt, statvolt 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.
3.5 Units, Scientific Constants, and Uncertainty • 99 The Unit Converter Assistant (Figure 3.6) opens. Figure 3.6: Unit Converter Assistant To perform a conversion: 1. In the Value text field, enter the numeric value to convert. 2. In the Dimension drop-down list, select the dimensions of the unit. 3. From the From and To menus, select the original unit and the unit to which to convert. 4. Click Insert. Maple inserts the corresponding convert/units command into the document.
100 • 3 Performing Computations • To perform a temperature change conversion, in the Dimension dropdown list, select temperature(relative). To convert temperature changes, the Unit Converter uses the convert/units command. For example, an increase of 32 degrees Fahrenheit corresponds to an increase of almost 18 degrees Celsius. > To convert absolute temperatures, the Unit Converter uses the convert/temperature command. For example, 32 degrees Fahrenheit corresponds to 0 degrees Celsius.
3.5 Units, Scientific Constants, and Uncertainty • 101 Figure 3.7: Units (FPS) Palette Figure 3.8: Units (SI) Palette To insert a unit: • In a Units palette, click a unit symbol. > To insert a unit that is unavailable in the palettes: 1. In a Units palette, click the unit symbol object with the placeholder selected. . Maple inserts a Unit 2. In the placeholder, enter the unit name (or symbol).
102 • 3 Performing Computations The context of a unit is displayed only if it is not the default context. Important: In 1-D Math input, the quantity and unit (entered using the toplevel Unit command) are a product, not a single entity. The following calling sequences define different expressions. > 1*Unit(m)/(2*Unit(s)); > 1*Unit(m)/2*Unit(s); Some units support prefixes. For example, SI units support prefixes to names and symbols. You can specify 1000 meters using kilometer or km.
3.5 Units, Scientific Constants, and Uncertainty • 103 > > (3.10) > (3.11) > For information on differentiation and integration, see Calculus (page 153). Changing the Current System of Units If a computation includes multiple units, all units are expressed using units from the current system of units. > (3.12) By default, Maple uses the SI system of units, in which length is measured in meters and time is measured in seconds.
104 • 3 Performing Computations > To view the name of the default system of units, use the Units[UsingSystem] command. > > To change the system of units, use the Units[UseSystem] command. > > Extensibility You can extend the set of: • Base dimensions and units • Complex dimensions • Complex units • Systems of units For more information, refer to the ?Units[AddBaseUnit], ?Units[AddDimension], ?Units[AddUnit], and ?Units[AddSystem] help pages.
3.5 Units, Scientific Constants, and Uncertainty • 105 Scientific Constants and Element Properties Computations often require not only units (see Units (page 97)), but also the values of scientific constants, including properties of elements and their isotopes. Maple supports computations with scientific constants. You can use the built-in constants and add custom constants.
106 • 3 Performing Computations Table 3.5: 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 You can specify a constant using either its name or symbol. Accessing Constant Definition The GetConstant command in the ScientificConstants package returns the complete definition of a constant.
3.5 Units, Scientific Constants, and Uncertainty • 107 Element Properties Maple also contains element properties and isotope properties. Elements Maple supports the first 112 elements of the periodic table, plus elements number 114 and 116. Each element has a unique name, atomic number, and chemical symbol. You can specify an element using any of these labels. For a complete list of supported elements, refer to the ?ScientificConstants/elements help page.
108 • 3 Performing Computations > > Value, Units, and Uncertainty To use constants or element properties, you must first construct a ScientificConstants object. To construct a scientific constant, use the Constant command.
3.5 Units, Scientific Constants, and Uncertainty • 109 To construct an element (or isotope) property, use the Element command. > Value To obtain the value of a ScientificConstants object, use the evalf command. > > Note: The value returned depends on the current system of units. For information on controlling the system of units, see Changing the Current System of Units (page 103). Units To obtain the units for a ScientificConstants object, use the GetUnit command.
110 • 3 Performing Computations For information on changing the default system of units, for example, from SI to foot-pound-second, see Changing the Current System of Units (page 103). Value and Units If performing computations with units, you can access the value and units for a ScientificConstants object by specifying the units option when constructing the object, and then evaluating the object.
3.5 Units, Scientific Constants, and Uncertainty • 111 Performing Computations You can use constant values in any computation. To use constant values with units, use a Units environment as described in Performing Computations with Units (page 102). For information on computing with quantities that have an uncertainty, see the following section. Modification and Extensibility You can change the definition of a scientific constant or element (or isotope) property.
112 • 3 Performing Computations 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. Quantities with Uncertainty Creating To construct quantities with uncertainty, use the Quantity command. You must specify the value and uncertainty. The uncertainty can be defined absolutely, relatively, or in units of the last digit.
3.5 Units, Scientific Constants, and Uncertainty • 113 > 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.
114 • 3 Performing Computations For information on the correlation between, variance of, and covariance between quantities with uncertainty, refer to the ?ScientificErrorAnalysis help page. Performing Computations with Quantities with Uncertainty Many Maple commands support quantities with uncertainty. > > Compute the value of the derivative of at . > > To convert the solution to a single quantity with uncertainty, use the combine/errors command.
3.6 Restricting the Domain • 115 Additional Information For information on topics including: • Creating new rounding rules • Setting the default rounding rule • Creating a new interface to quantities with uncertainty refer to the ?ScientificErrorAnalysis help page. 3.6 Restricting the Domain By default, Maple computes in the complex number system. Most computations are performed without any restrictions or assumptions on the variables.
116 • 3 Performing Computations After you load the RealDomain package, Maple assumes that all variables are real. Commands return simplified results appropriate to the field of real numbers. > > > Some commands that generally return NULL instead return a numeric result when you use the RealDomain package. > Complex return values are excluded or replaced by undefined.
3.6 Restricting the Domain • 117 Assumptions on Variables To simplify problem solving, it is recommended that you always apply any known assumptions to variables. You can impose assumptions using the assume command. To apply assumptions for a single computation, use the assuming command. Note: The assume and assuming commands are not supported by the RealDomain package.
118 • 3 Performing Computations 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.
3.6 Restricting the Domain • 119 To test whether an expression can satisfy a condition, use the coulditbe command. > Removing Assumptions To remove all assumptions on a variable, unassign its name. > For more information, see Unassigning Names (page 57). For more information on the assume command, refer to the ?assume help page. The assuming Command To perform a single evaluation under assumptions on the names in an expression, use the assuming command.
120 • 3 Performing Computations > 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 338).) You must use the assume command.
3.6 Restricting the Domain • 121 > For more information on the assuming command, refer to the ?assuming help page.
122 • 3 Performing Computations
4 Mathematical Computations As discussed in previous chapters, Maple contains numerous built-in resources for computations. These resources—and others on the Maplesoft Web site—are available for the areas discussed in this chapter, and many more. Your first step in solving a problem should be to review the related Maple resources available. This will help you to quickly and easily solve problems. See Table 4.1. Table 4.
124 • 4 Mathematical Computations Resource Description Maple Help System Over 5000 help pages and example worksheets with an integrated search engine. • From the Help menu, select Maple Help. Package index help page A complete list of the over 100 Maple packages, which contain thousands of commands. • From the Help menu, select Manuals, Dictionary, and more, and then List of Packages. Command index help page A complete list of the over 600 top-level Maple commands.
4.1 In This Chapter • 125 4.
126 • 4 Mathematical Computations 4.2 Algebra Maple contains a variety of commands that perform integer operations, such as factoring and modular arithmetic, as described in Integer Operations (page 71). In addition, it supports polynomial algebra. For information on matrix and vector algebra, see Linear Algebra (page 135). Polynomial Algebra A Maple polynomial is an expression in powers of an unknown. Univariate polynomials are polynomials in one unknown, for example, .
4.2 Algebra • 127 Table 4.2: Polynomial Arithmetic Operators Operation Operator Example Addition > Subtraction > Multiplication1 Division: Quotient and Remainder * > quo rem > > Exponentiation2 ^ > 1 You can specify multiplication explicitly by entering *, which displays in 2-D Math as . In 2-D Math, you can also implicitly multiply by placing a space character between two expressions. In some cases, the space character is optional.
128 • 4 Mathematical Computations To expand a polynomial, use the expand command. > 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, does not divide the single variable .
4.2 Algebra • 129 Sorting Terms To sort the terms of a polynomial, use the sort command. > > Note: The sort command returns the sorted polynomial, and updates the order of the terms in the polynomial. The terms of p1 are sorted. > 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.
130 • 4 Mathematical Computations > > 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.
4.2 Algebra • 131 See Figure 4.1. Figure 4.1: Sorting a Polynomial Using a Context Menu Maple sorts the polynomial. In Worksheet mode, Maple inserts the calling sequence that performs the sort followed by the sorted polynomial.
132 • 4 Mathematical Computations You can use context menus to perform operations on 2-D Math content including output. For more information, see Context Menus (page 20) (for Document mode) or Context Menus (page 46) (for Worksheet mode). Collecting Terms To collect the terms of polynomial, use the collect command. > Coefficients and Degrees Maple has several commands that return coefficient and degree values for a polynomial. See Table 4.3. Table 4.
4.2 Algebra Command Description Example tcoeff Trailing coefficient > coeffs Sequence of all coefficients in increasing degree order. Note: It does not return zero coefficients. > degree (Highest) degree > ldegree Lowest degree term with a non-zero coefficient > • 133 Factorization To express a polynomial in fully factored form, use the factor command. > The factor command factors the polynomial over the ring implied by the coefficients, for example, integers.
134 • 4 Mathematical Computations To solve for the roots of a polynomial, use the solve command. For information on the solve command, see Solving Equations and Inequations (page 78). (The isolve command solves an equation for integer solutions. For more information, see Integer Equations (page 94).) Other Commands Table 4.4 lists other commands available for polynomial operations. Table 4.
4.3 Linear Algebra • 135 Command Description sqrfree Square free factorization (multivariate polynomial) Additional Information Table 4.
136 • 4 Mathematical Computations Figure 4.2: Matrix Palette In the Matrix palette, you can specify the matrix size (see Figure 4.3) and properties. To insert a matrix, click the Insert Matrix button.
4.3 Linear Algebra • 137 Figure 4.3: Matrix Palette: Choosing the Size After inserting the matrix: 1. Enter the values of the entries. To move to the next entry placeholder, press Tab. 2. After specifying all entries, press Enter.
138 • 4 Mathematical Computations > Creating Vectors To create a vector, use angle brackets (< >). To create a column vector, specify a comma-delimited sequence, . The number of elements is inferred from the number of expressions. > To create a row vector, specify a vertical-bar-delimited (|) sequence, . The number of elements is inferred from the number of expressions.
4.3 Linear Algebra • 139 In the Matrix palette: 1. Specify the dimensions: 15 rows and 15 columns. 2. In the Type drop-down list, select a matrix type, for example, Custom values. 3. Click Insert Matrix. Maple inserts a placeholder. > To edit or view a large matrix or vector, double-click the placeholder. This launches the Matrix Browser. See Figure 4.4.
140 • 4 Mathematical Computations Figure 4.4: Matrix Browser To specify the value of entries using the Matrix Browser: 1. Select the Table tab. 2. Double-click an entry, and then edit its value. Press Enter. 3. Repeat for each entry to edit. 4. When you have finished updating entries, click Done. You can view the matrix or vector as a table or as an image, which can be inserted into the document. For more information, refer to the ?MatrixBrowser help page.
4.3 Linear Algebra • 141 To set the maximum dimension of matrices and vectors displayed inline: • Use the interface command with the rtablesize option. For example, interface(rtablesize = 15). For more information, refer to the ?interface help page. Creating Matrices and Vectors for Large Problems By default, matrices and vectors can store any values. To increase the efficiency of linear algebra computations, create matrices and vectors with properties.
142 • 4 Mathematical Computations > Note: To create a matrix with randomly-generated entries, select the Random Type. You cannot specify properties when defining vectors using the anglebracket notation. You must use the Vector constructor. 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.
4.3 Linear Algebra • 143 > > The Matrix palette does not support some properties. To set all properties, use the Matrix constructor. To define a matrix using the Matrix constructor, specify: • The number of rows and columns. If you explicitly specify all element values, these arguments are not required. • A list of lists that define the element values row-wise. • Parameters such as shape, datatype, and fill that set properties of the matrix.
144 • 4 Mathematical Computations For more information on the constructors, including other calling sequence syntaxes and parameters, refer to the ?storage, ?Matrix, and ?Vector help pages. See also Numeric Computations (page 152). Accessing Entries in Matrices and Vectors To select an entry in a vector, enter the vector name with a non-zero integer index. > > Negative integers select entries from the end of the vector.
4.3 Linear Algebra • 145 To create a Vector consisting of multiple entries, specify a list or range of integers in the index. For more information, refer to the ?list and ?range help pages. > > Similarly, you can access submatrices using an index. In the following twodimensional matrix, the first entry selects rows and the second, columns. > > Linear Algebra Computations You can perform matrix and vector computations using context menus and the LinearAlgebra package.
146 • 4 Mathematical Computations Matrix Arithmetic The matrix and vector arithmetic operators are the standard Maple arithmetic operators up to the following two differences. • The scalar multiplication operator is the asterisk (*), which displays in 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 See Table 4.6. > Table 4.
4.3 Linear Algebra Operation Operator • 147 Example Multiplication . > Scalar Multiplication1 * > > 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.
148 • 4 Mathematical Computations Define two column vectors. > Table 4.7: Select Matrix and Vector Operators Operation Operator Transpose ^%T1 Hermitian Transpose ^%H1 Cross Product (3-D vectors only) &x2 Example > > > > 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.
4.3 Linear Algebra • 149 Matrix operations available in the context menu include the following. • Standard operations: determinant, inverse, norm (1, Euclidean, infinity, or Frobenius), transpose, and trace • Compute eigenvalues, eigenvectors, and singular values • Compute the dimension or rank • Convert to the Jordan form, or other forms • Perform Cholesky decomposition and other decompositions For example, compute the infinity norm of a matrix. See Figure 4.5. Figure 4.
150 • 4 Mathematical Computations Figure 4.6: Computing Norm in Document Mode Vector operations available in the context menu include the following. • Compute the dimension • Compute the norm (1, Euclidean, and infinity) • Compute the transpose • Select an element For more information on context menus, see Context Menus (page 20) (for Document mode) or Context Menus (page 46) (for Worksheet mode).
4.3 Linear Algebra Command • 151 Description GaussianElimination Perform Gaussian elimination on a matrix HessenbergForm Reduce a square matrix to Hessenberg form HilbertMatrix Construct a generalized Hilbert matrix IsOrthogonal Test if a matrix is orthogonal LeastSquares Compute the least-squares approximation to A . x = b LinearSolve Solve the linear system A .
152 • 4 Mathematical Computations To express (25, -4, 9) in this basis, use the LinearSolve command. > 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.
4.4 Calculus • 153 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[LinearAlgebra][SetDefault] help page.
154 • 4 Mathematical Computations For example: > The limit Command By default, Maple searches for the real bidirectional limit (unless the limit point is ∞ or -∞). To specify a direction, include one of the options left, right, real, or complex in a call to the limit command. See Table 4.9. Table 4.9: Limits Limit Command Syntax > Output undefined > > Using the limit command, you can also compute multidimensional limits.
4.4 Calculus • 155 Numerically Computing a Limit To numerically compute a limit: • Use the evalf(Limit(arguments)) calling sequence. 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 313). The Limit command does not compute the limit. It returns an unevaluated limit.
156 • 4 Mathematical Computations To differentiate an expression: 1. In the Expression palette, click the differentiation item partial differentiation item or the . 2. Specify the expression and independent variable, and then evaluate it. For example, to differentiate with respect to : > You can also differentiate using context menus. For more information, see Context Menus (page 20). To calculate a higher order or partial derivative, edit the derivative symbol inserted.
4.4 Calculus • 157 The diff Command Maple computes derivatives using the diff command. To directly use the diff command, specify the expression to differentiate and the variable. > (4.1) > For information on equation labels such as (4.1), see Equation Labels (page 59). To calculate a higher order derivative, specify a sequence of differentiation variables. Maple recursively calls the diff command. > To calculate a partial derivative, use the same syntax. Maple assumes that the derivatives commute.
158 • 4 Mathematical Computations To compute the nth derivative of an expression f in the independent variable t, you can use the syntax . 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 293). To find the derivative of a functional operator: • Use the D operator.
4.4 Calculus • 159 > F and G evaluated at return the expected values. > For more information on the D operator, refer to the ?D help page. For a comparison of the diff command and D operator, refer to the ?diffVersusD help page. Directional Derivative To compute and plot a directional derivative, use the Directional Derivative Tutor. The tutor computes a floating-point value for the directional derivative.
160 • 4 Mathematical Computations Figure 4.7: Directional Derivative Tutor To compute a symbolic value for the directional derivative, use the Student[MultivariateCalculus][DirectionalDerivative] command. The first list of numbers specifies the point at which to compute the derivative. The second list of numbers specifies the direction in which to compute the derivative. For example, at the point [1, 2], the gradient of points in the direction [2, 4], which is the direction of greatest increase.
4.4 Calculus • 161 > Series To generate the Taylor series expansion of a function about a point, use the taylor command. > Note: If a Taylor series does not exist, use the series command to find a general series expansion. For example, the cosine integral function does not have a taylor series expansion about 0. For more information, refer to the ?Ci help page.
162 • 4 Mathematical Computations > To set the order for all computations, use the Order environment variable. For information about the Order variable and the ?Order help page. term, refer to the The expansion is of type series. Some commands, for example, plot, do not accept arguments of type series. To use the expansion, you must convert it to a polynomial using the convert/polynom command. > For information on Maple types and type conversions, see Maple Expressions (page 285).
4.4 Calculus • 163 For information on plotting, see Plots and Animations (page 189). Integration Maple can perform symbolic and numeric integration. To compute the indefinite integral of an expression: 1. In the Expression palette, click the indefinite integration item . 2. Specify the integrand and variable of integration, and then evaluate it. For example, to integrate with respect to x: > Recall that you can also enter symbols, including and , using symbol completion.
164 • 4 Mathematical Computations 2. Specify the endpoints of the interval of integration, integrand expression, and variable of integration, and then evaluate it. For example, to integrate over the interval (0, ∞): > Maple treats the parameter a as a complex number. As described in Assumptions on Variables (page 117), you can compute under the assumption that a is a positive, real number using the assuming command. > The int Command and use the int command.
4.4 Calculus • 165 (4.2) > For a definite integration, set the variable of integration equal to the interval of integration. > Numeric Integration To perform numeric integration: • 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.
166 • 4 Mathematical Computations For information on the evalf command, see Numerical Approximation (page 313). For information on numeric integration, including iterated integration and controlling the algorithm, refer to the ?evalf/Int help page. To compute iterated integrals, line integrals, and surface integrals, use the task templates (Tools>Tasks>Browse) in the Multivariate and Vector Calculus folders.
4.4 Calculus • 167 Find the curl of VectorField1. > Find the flux of VectorField1 through a sphere of radius r at the origin. > 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 119). For more information on the VectorCalculus package, including a complete list of commands, refer to the ?VectorCalculus help page.
168 • 4 Mathematical Computations To find other calculus packages, such as VariationalCalculus, refer to the ?index/package help page. Student Calculus Packages The Student package contains subpackages that help instructors teach concepts and allow students to visualize and explore ideas. These subpackages also contain computational commands. The Student calculus subpackages include Calculus1, MultivariateCalculus, and VectorCalculus.
4.5 Optimization • 169 Point-and-Click Interface The primary method for solving optimization problems is the Optimization Assistant. To launch the Optimization Assistant: • From the Tools menu, select Assistants, and then Optimization. Maple inserts the Optimization[Interactive]() calling sequence (in Worksheet mode), and launches the Optimization Assistant. See Figure 4.8. Figure 4.8: Optimization Assistant To solve a problem: 1. Enter the objective function, constraints, and bounds.
170 • 4 Mathematical Computations 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. For example, find the maximum of subject to the constraints . > After finding a solution, you can plot it. To plot a solution: In the Optimization Assistant window, click the Plot button. The Optimization Plotter window is displayed.
4.5 Optimization • 171 Figure 4.9: Optimization Assistant Plotter Window For information on the algorithms used to solve optimization problems, refer to the ?Optimization/Methods help page. Large Optimization Problems The Optimization Assistant accepts input in an algebraic form. You can specify input in other forms, described in the ?Optimization/InputForms help page, in command calling sequences.
172 • 4 Mathematical Computations For example, solve the quadratic program: maximize subject to , where is the vector of problem variables. Define the column vector, c, of the quadratic objective function. > Define the symmetric Hessian matrix, H, of the quadratic objective function. > Define the matrix A, the coefficient matrix for the linear inequality constraints. > Define the column vector b, the linear inequality constraints. > The QPSolve command solves quadratic programs.
4.6 Statistics • 173 MPS(X) File Support To import linear programs from a standard MPS(X) data file, use the ImportMPS command. Additional Information For a complete list of commands and other Optimization package information, refer to the ?Optimization help page. 4.
174 • 4 Mathematical Computations 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 175)). > represents the Dirac delta function. For more information, refer to the ?Dirac help page. Adding Custom Distributions To add a new distribution, specify a probability distribution in a call to the Distribution command.
4.6 Statistics • 175 Calculate the mean value of the random variable. > For more information, refer to the ?Statistics/Distributions help page. 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. Examples Example 1 Compute the average absolute range from the interquartile of the Rayleigh distribution with scale parameter 3.
176 • 4 Mathematical Computations > Example 2 Compute the hazard rate of the Cauchy distribution with location and scale parameters a and b at an arbitrary point t. > You can specify a value for the point t. > You can also specify that Maple compute the result numerically. > For more information, refer to the ?Statistics/DescriptiveStatistics help page.
4.6 Statistics • 177 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.
178 • 4 Mathematical Computations For information on plotting options, such as title, see Plots and Animations (page 189). To fit a curve to the data points, include the optional fit equation parameter.
4.6 Statistics • 179 > > For more information on statistical plots, refer to the ?Statistics/Visualization help page. For an overview of plotting, see Plots and Animations (page 189). Additional Information For more information on the Statistics package, including regression analysis, estimation, data manipulation, and data smoothing, refer to the ?Statistics help page.
180 • 4 Mathematical Computations 4.7 Teaching and Learning with Maple Table 4.10 resources for instructors and students. For additional resources see Table 4.1 (page 123). Table 4.10: Student and Instructor Resources 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.
4.7 Teaching and Learning with Maple • 181 Resource Description Maple Student CenterTM The Maple Student 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.
182 • 4 Mathematical Computations Figure 4.10: Student[Calculus1] Derivatives Tutor Students can: • Perform step-by-step computations, for example, compute a derivative by applying differentiation rules using commands or a tutor (Tools>Tutors>Calculus - Single Variable>Differentiation Methods). See Figure 4.11. • Perform computations. • Visually explore concepts.
4.7 Teaching and Learning with Maple • 183 Figure 4.11: Student[Calculus1] Differentiation Methods Tutor Tutors provide point-and-click interfaces to the Student package functionality. To launch a tutor: 1. From the Tools menu, select Tutors. 2. Select a subject, for example, Calculus - Multi-Variable. 3. Select a tutor, for example, Gradients.
184 • 4 Mathematical Computations 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 4.12) and show the direction of the gradient vector in the x-y plane (see Figure 4.13). Figure 4.
4.7 Teaching and Learning with Maple Figure 4.13: Multivariate Calculus Gradient Tutor Showing x-y Plane When you close the tutor, Maple inserts the 3-D plot.
186 • 4 Mathematical Computations 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.
4.7 Teaching and Learning with Maple • 187 > (4.3) To evaluate the integral returned by the output = integral calling sequence, use the value command. > By default, the LineInt command returns the value of the integral.
188 • 4 Mathematical Computations For more information on the Student package, refer to the ?Student help page.
5 Plots and Animations Maple can generate many forms of plots, allowing you to visualize a problem and further understand concepts. • Maple accepts explicit, implicit, and parametric forms to display 2-D and 3-D plots and animations. • Maple recognizes many coordinate systems. • All plot regions in Maple are active; therefore, you can drag expressions to and from a plot region.
190 • 5 Plots and Animations Section Topics Analyzing Plots - Plot analyzing tools • Point Probe • Rotate • Pan • Scale Creating Animations - Interactive and command- • driven methods to display animations • Interactive Plot Builder Playing Animations - Tools to run animations Animation Context Bar • Customizing Animations - Methods for applying • plot options before and after an animation displays • The plots[animate] Command Interactive Plot Builder Animation Options Context Menu Options
5.2 Creating Plots • 191 Interactive Plot Builder The Interactive Plot Builder is a point-and-click interface to the Maple plotting functionality. The interface displays plot types based on the expression you specify. The available plot types include plots, interactive plots, animations, or interactive animations.
192 • 5 Plots and Animations Table 5.1: Windows of the Interactive Plot Builder 1. Specify Expressions window 3. Plot Options window 2.
5.2 Creating Plots • 193 • Specify Expressions window - Add, edit, or remove expressions and variables. Once finished, you can advance to the Select Plot Type window. • Select Plot Type window - Select the plot type and corresponding plot, and edit the ranges. Once finished, you can display the plot or advance to the Plot Options window. • Plot Options window - Apply plot options. Once finished, you can display the plot or return the command that generates the plot to the document.
194 • 5 Plots and Animations Step Details Enter an expression. 1. In the Specify Expressions window: a. Add the expression, sin(x)/x. b. Click Done.to proceed to the Select Plot Type window. Plot the expression. 1. In the Select Plot Type window, notice the default setting of a 2-D plot type and an x axis range, -10 .. 10. Notice also the various plot types available for this expression. 2. Click Plot.
5.2 Creating Plots • 195 Example 2 - Display a plot of multiple expressions of 1 variable Maple can display multiple expressions in the same plot region to compare and contrast. The Interactive Plot Builder accepts multiple expressions. Table 5.3: Displaying a Plot of Multiple Expressions of 1 Variable Step Details Launch the Interactive Plot Builder and enter the expressions. 1. Launch the Interactive Plot Builder. The Plot Builder accepts expressions and performs basic calculations on expressions.
196 • 5 Plots and Animations Step Details Display the actual plot. Execute the inserted command, that is, display the plot. By default, Maple displays each plot in a plot region using a different color. You can also apply a line style such as solid, dashed, or dotted for each expression in the graph. For more information, refer to the ?plot/options help page.
5.2 Creating Plots Step • 197 Details Launch the Plot Options win- In the Select Plot Type window: dow. a. Notice the available plot types for an expression with 2 variables, as well as the plot objects for each type. b. Click Options. Set plot options. In the Plot Options window: a. From the Variables column, change the Range fields to 0 .. 0.05. b. From the Labels column, enter z. c. From the Color group box, select Light Model, and then green-red. d.
198 • 5 Plots and Animations To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot Builder (page 208) Example 4 - Display a conformal plot Maple can display a conformal plot of a complex expression mapped onto a two-dimensional grid or plotted on the Riemann sphere in 3-D. Table 5.5: Displaying a Conformal Plot Step Details Launch the Interactive Plot Add the expression z^3. Builder and enter an expression.
5.2 Creating Plots Step Details Select a plot type. In the Select Plot Type window: • 199 a. From the Select Plot group box, select 2-D conformal plot of a complex-valued expression. b. Change the range of the z parameter to 0 .. 2+2*I. Set plot options. In the Plot Options window: a. From the Axes group box, select normal. b. From the Miscellaneous group box, select the Grid Size drop-down menu option 30, 30. Plot the expression. Click Plot.
200 • 5 Plots and Animations Example 5 - Display a plot in polar coordinates Cartesian (ordinary) coordinates is the Maple default. Maple also supports numerous other coordinate systems, including hyperbolic, inverse elliptic, logarithmic, parabolic, polar, and rose in two-dimensions, and bipolar cylindrical, bispherical, cylindrical, inverse elliptical cylindrical, logarithmic cosh cylindrical, Maxwell cylindrical, tangent sphere, and toroidal in threedimensional plots.
5.2 Creating Plots • 201 To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot Builder (page 208) Example 6 - Interactive Plotting Using the Interactive Plot Builder, you can plot an expression with several of its variables set to numeric values. The Interactive Parameter window allows you to interactively adjust these numeric values within specified ranges to observe their effect.
202 • 5 Plots and Animations Figure 5.1: Interactive Parameter Window Table 5.7: Interactive Plotting Steps Details Launch the Interactive Plot Add the expression x+3*sin(x*t). Builder and enter an expression.
5.2 Creating Plots Steps Details Select a plot type. In the Select Plot Type window: • 203 a. From the Select Plot group box, select Interactive Plot with 1 parameter. b. Change the range of the x-axis to 0 .. 5. c. Change the t range to 0 .. 10. d. Click Plot to launch the Interactive Parameter window. Note: To apply plot options before interactively adjusting the plot, click Options to launch the Plot Options window.
204 • 5 Plots and Animations To see the Maple syntax used to generate this plot, see Maple commands from Creating Plots: Interactive Plot Builder (page 208) For information on customizing plots using the Interactive Plot Builder, refer to Customizing Plots : Interactive Plot Builder Options (page 216). Context Menu A context menu in Maple displays a list of commands to manipulate, display, or calculate using a Maple expression. The commands in the menu depend on the type of the expression.
5.2 Creating Plots • 205 By invoking the Interactive Plot Builder through the context menu, the expression automatically passes to the builder and Maple does not display the Specify Expression window. One advantage of using the context menu is the simplicity of creating an expression using menus. By using this method, you do not need any knowledge of plot command syntax. 1. Enter and evaluate an expression, for example, 2. Right-click (Control-click for Macintosh) the expression. 3.
206 • 5 Plots and Animations >
5.2 Creating Plots • 207 For information on customizing plots using the context menu, see Context Menu Options (page 217). Dragging to a Plot Region To use the drag-and-drop method, use the plot region created by one of the other methods or insert an empty plot region into the document. Empty plot regions can be two-dimensional or three-dimensional. Advantages of the drag-and-drop method include the ease of adding and removing plots and the independence from plotting command syntax. 1.
208 • 5 Plots and Animations The plot and plot3d Commands The final method for creating plots is entering plotting commands. The main advantages of using plotting commands are the availability of all Maple plot structures and the greater control over the plot output. Plot options are discussed in Customizing Plots (page 216). Table 5.8: The plot and plot3d Commands plot(plotexpression, x=a..b, ...) plot3d(plotexpression, x=a..b, y=a..b, ...) • plotexpression - expression to be plotted • x=a..
5.2 Creating Plots • 209 Example 2 - Display a plot of multiple expressions of 1 variable To display multiple expressions in a plot, include the expressions in a list. To enter and use the Expression palette. For more information, see Entering Expressions (page 10). > Example 3 - Display a plot of a multi-variable expression > Example 4 - Display a conformal plot A collection of specialized plotting routines are available in the plots package.
210 • 5 Plots and Animations For more information on the plot options described in this section, refer to the ?plot/options and ?plot3d/options help pages. Display a Parametric Plot Some graphs cannot be specified explicitly. In other words, you cannot write the dependent variable as a function of the independent variable, y=f(x). One solution is to make both the x-coordinate and the y-coordinate depend upon a parameter.
5.2 Creating Plots • 211 > The plots Package The plots package contains numerous plot commands for specialized plotting. This package includes: animate, contourplot, densityplot, fieldplot, odeplot, matrixplot, spacecurve, textplot, and tubeplot. For details about this package, refer to the ?plots help page. > The pointplot Command To plot numeric data, use the pointplot command in the plots package with the data organized in a list of lists structure of the form [[x1, y1], [x2, y2], ..., [xn, yn]].
212 • 5 Plots and Animations > The matrixplot Command The matrixplot command plots the values of a plot object of type Matrix. The matrixplot command accepts options such as heights and gap to control the appearance of the plot. For more information on Matrices, see Linear Algebra (page 135).
5.
214 • 5 Plots and Animations The contourplot Command The contourplot command generates a topographical map for an expression or function. To create a smoother, more precise plot, increase the number of points using the numpoints option. > Multiple Plots in the Same Plot 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.
5.2 Creating Plots • 215 > The display Command To display different types of plots in the same plot region, use the display command in the plots package. This example plots a curve over a hill with the shadow of the curve projected onto the hill.
216 • 5 Plots and Animations Maple can draw curves in three-dimensional space. > > > > Now that you have seen how easy it is to incorporate a plot into your work, the next section illustrates how to customize plots. 5.3 Customizing Plots Maple provides many plot options to display the most aesthetically pleasing, illustrative results. Plot options include line styles, colors, shadings, axes styles, and titles where applicable.
5.3 Customizing Plots • 217 Table 5.9: Customizing Plots Using Interactive Plot Builder Steps Details Launch the Interactive Plot Add the expression 2*x^5-10*x^3+6*x-1. For information Builder and enter the expres- on interacting with the Interactive Plot Builder, see Exsion. ample 1 - Display a plot of a single variable expression (page 193) Set the x-axis range. In the Select Plot Type window, change the x-axis range to -2 .. 2. Set plot options. In the Plot Options window: a.
218 • 5 Plots and Animations options using the Plot toolbar and Plot menu options. These menus display when a plot region is selected. Regardless of the method used to insert a plot into Maple, you can use the context menu to apply different plot options. For a list of options available when plotting in two and three dimensions, see The plot and plot3d Options (page 220). 2-D Plot Options Some plots do not display as you would expect using default option values.
5.3 Customizing Plots • 219 Steps Details Change the color. Place the mouse pointer on the curve and right-click (Control-click, for Macintosh). Note: The curve is selected when it becomes highlighted. Select Color, and then Green. Change the line style. Select Style, and then Point. 3-D Plot Options By default, Maple displays the graph as a shaded surface and scales the plot to fit the window. To change these options, use the context menu. > Maple has many preselected light source configurations.
220 • 5 Plots and Animations Steps Details Change the axes style. Select Axes, and then Boxed. Alter the glossiness. Select Glossiness. Using the slider, adjust the level of glossiness. The plot and plot3d Options If you are using commands to insert a plot, you can specify plot options as arguments at the end of the calling sequence. You can specify the options in any order.
5.
222 • 5 Plots and Animations > 5.4 Analyzing Plots Point Probe, Rotate, Pan, and Scale Tools To gain further insight into a plot, Maple offers various tools to analyze plot regions. These tools are available in the Plot menu menu, Context Bar and in the context menu under Transform when the plot region is selected. Table 5.
5.5 Creating Animations Name Icon • 223 Description Pan Change the position of the plot in the plot region Scale Change the size of the plot without resampling 5.5 Creating Animations Plotting is an excellent way to represent information. Animations allow you to emphasize certain graphical behavior, such as the deformation of a bouncing ball, clearer then in a static plot. A Maple animation is a number of plot frames displayed in sequence, similar to the action of movie frames.
224 • 5 Plots and Animations Steps Details Set plot options. In the Plot Options window: a. From the Style group box, select patch w/o grid. b. From the Color group box, in the Light Model drop-down menu select red-turquoise. b. From the Color group box, in the Shading drop-down menu select z (grayscale). c. In the View group box, select the Constrained Scaling check box. Plot the expression. Click Plot. For information on playing the animation, see Playing Animations (page 226).
Color Plates Caffeine Atom Model
Julia Set Koch Tetrahedron Conchoid Möbius Strip
Dirichlet Problem for a Circle Fractal Leaf Gauss Map Graphed on a Torus Log Cabin Quilt
Function of Two Variables in Cartesian Coordinates
5.5 Creating Animations • 225 The plots[animate] Command You can also use the animate command, in the plots package, to generate animations. Table 5.15: The animate Command animate(plotcommand, plotarguments, t=a..b, ...) animate(plotcommand, plotarguments, t=L, ...) • plotcommand - Maple procedure that generates a 2-D or 3-D plot • plotarguments - arguments to the plot command • t=a..
226 • 5 Plots and Animations For more information on the animate command, refer to the ?plots[animate] help page. 5.6 Playing Animations Animation Context Bar To run the animation, click the plot to display the Animate context bar. Table 5.16: Animation Options Name Icon Description Previous Frame View the previous frame in the animation. Stop Stop the animation. Play Play the selected animation. Next Frame View the next frame in the animation.
5.6 Playing Animations Name Icon • 227 Description Current Frame Slider control for viewing individual frames of an animated plot. The frame speed in frames per second (FPS) is displayed when increasing or decreasing the animation speed of a plot. Forward Oscillate Backward • Forward - Play the animation forward. • Oscillate - Play the animation forward and backward. • Backward - Play the animation backward. • Single - Run the animation in single cycle mode.
228 • 5 Plots and Animations 5.7 Customizing Animations The display options that are available for static plots are also available for Maple animations. Interactive Plot Builder Animation Options Using the Interactive Plot Builder, you can apply various plot options within the Plot Options window. See the Interactive Plot Builder (page 223) example.
5.7 Customizing Animations • 229 Table 5.17: Customizing Animations Using the Context Menu Step Details Change the line style Right-click the plot region. Select Style, and then Point. Remove the axes Select Axes, and then None. The animate Command Options The animate command offers a few options that are not available for static plots. Refer to the ?animate help page for information on these additional options.
230 • 5 Plots and Animations 5.8 Exporting You can export a generated graph or animation to an image in various file formats, including DXF, EPS, GIF, JPEG/JPG, POV, Windows BMP, and WMF. Exporting an animation to GIF produces an animated image file. The exported images can be included in presentations, Web pages, Microsoft Word, or other software. To export an image: 1. Right-click the plot region (for Macintosh, Control-click). 2. Select Export and the file format. Alternatively: 1. Click the plot. 2.
6 Creating Mathematical Documents Maple allows you to create powerful documents as business and education tools, technical reports, presentations, assignments, and handouts.
232 • 6 Creating Mathematical Documents 6.
6.
234 • 6 Creating Mathematical Documents 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, use the context bar icons. • Font Color Context Bar Icon • Highlight Color Context Icon For font and highlight colors, you can select from Swatches, HSB, or RGB values. See Figure 6.1. Figure 6.
6.2 Document Formatting • 235 Attributes Submenu: Setting Fonts, Character Size, and Attributes You can change various character attributes such as font, character size, style, and color in one dialog. 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 6.2. Figure 6.
236 • 6 Creating Mathematical Documents 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 6.3. • When changing spacing, you must indicate units (inches, centimeters, or points) in the Units drop-down list. Figure 6.
6.2 Document Formatting • 237 2. From the Edit menu, select Copy. 3. Place the cursor at the insertion point. 4. From the Edit menu, select Paste. If you paste into an input region, Maple interprets all the pasted content as input. If you paste into a text region, Maple interprets all the pasted content as text. Note, however, that 2-D Math retains its format in both input and text regions. When you copy and paste to another application, in general, Maple retains the original structure.
238 • 6 Creating Mathematical Documents 3. Enter the section heading. 4. Press the Enter key. 5. Enter the body of the section. Using the Indent and Outdent Toolbar Icons You can shift sections to create or remove subsections.
6.2 Document Formatting • 239 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. Character and Paragraph Styles Maple has predefined styles for characters and paragraphs. A style is a set of formatting characteristics that you can apply to text in your document to change the appearance of that text.
240 • 6 Creating Mathematical Documents • New styles that you have created through the Style Management (Figure 6.4) and Character Style (Figure 6.5) dialogs. To apply a character style to text in your document: 1. Select the text to modify. 2. In the styles drop-down list in the context bar of your document, select an appropriate character style. All character styles are preceded by the letter C. The selected text now reflects the attributes of the character style you have chosen. 3.
6.2 Document Formatting • 241 two check boxes, the other is disabled. You must clear one before selecting the other. Note: A preview of the style is displayed in the Example group box at the bottom of the Character Style dialog. 5. To create the style, click OK or to abandon creation, click Cancel. Figure 6.5: Character Style Dialog Modifying Character Styles To modify character styles: 1. From the Format menu, select Styles. The Style Management dialog opens. See Figure 6.4. 2.
242 • 6 Creating Mathematical Documents 4. Select the properties to modify, such as Font, Size, Attributes, and Color. In the Attributes group box, the Superscript and Subscript check boxes are mutually exclusive. When you select one of the two check boxes, the other is disabled. You must clear one before selecting the other. A preview of the style is displayed in the Example group box at the bottom of the Character Style dialog. 5. To accept changes, click OK or to cancel changes, click Cancel.
6.2 Document Formatting • 243 Creating Paragraph Styles You can create custom paragraph styles to apply to text. New styles are listed in the styles drop-down list in the context bar of your document. 1. From the Format menu, select Styles. The Style Management dialog opens. See Figure 6.4. 2. Click Create Paragraph Style. The Paragraph Style dialog opens. See Figure 6.6. 3. In the Style group box, enter the new paragraph style name in the blank text field. 4.
244 • 6 Creating Mathematical Documents Figure 6.6: Paragraph Style Dialog Modifying Paragraph Styles To modify a paragraph style: 1. From the Format menu, select Styles. The Style Management dialog opens. See Figure 6.4. 2. Select a paragraph style to modify, and click Modify. The Paragraph Style dialog opens with the current attributes displayed. 3. Select the properties you want to modify, such as Spacing, Indent, Justification, and Bullet, Linebreak, and Units. 4.
6.2 Document Formatting • 245 Style Set Management: Saving Styles for Future Use You can use the style set of a particular document as the default style for all documents. Figure 6.7: Style Set Management Dialog Creating and Applying Style Sets • Task 1 - Create Styles • Task 2 - Create a New Style Set • Task 3 - Apply a (New) Style Set TASK 1 - Create Styles: • Create paragraph or character styles for the current document. TASK 2 - Create a New Style Set: 1.
246 • 6 Creating Mathematical Documents Figure 6.8: Choose Styles Dialog 3. Select all the styles that are part of your document style set. For example, if you modified the Author paragraph style to justify left versus the default style of centered, ensure that you have selected the Author check box in the Choose Styles dialog. 4. Click OK. The Choose Filename dialog opens. 5. Save your style set. The style is now available for future use in other documents. TASK 3 - Apply a (New) Style Set: 1.
6.2 Document Formatting • 247 To revert to a style set: 1. From the Format menu, select Manage Style Sets. The Style Set Management dialog opens. 2. In the Current Style Set group box, select the Default Maple Style Set or User-defined Style Set. For user-defined style sets, navigate (click Browse) to the file (Choose Filename dialog) and open the file (click Open). 3. In the Style Set Operations group box, click Revert to StyleSet. 4.
248 • 6 Creating Mathematical Documents Applying Document Blocks: General Process To apply a document block to selected content: 1. Enter input at the Maple command prompt, creating input that can be referenced elsewhere in the document. See the ?EquationLabels help page. 2. Execute the area, creating output that can be referenced elsewhere in the document. 3. Intersperse the area with content that is to remain visible, adding references to the input and output in the appropriate locations. 4.
6.2 Document Formatting • 249 Working in Document Mode You can work directly in a document block in Worksheet mode, or you can work directly in Document mode, entering text and expressions, and then evaluating expressions. To start a document in Document mode: 1. From the File menu, select New, and then Document Mode. A document opens with the Document mode markers indicated in the left margin. Note that margin markers are visible if you select View>Markers. 2. Enter text and an expression to evaluate. 3.
250 • 6 Creating Mathematical Documents Before After Figure 6.9: Working in Document Mode View Document Code To view the contents, that is, all code and expanded execution groups within a document block, you must expand the document block. 1. Place the cursor in the document block region. 2. From the View menu, select Expand Document Block. 3. To hide code again, select View>Collapse Document Block.
6.2 Document Formatting • 251 As document blocks can contain many execution groups, you can select to expand an execution group within a document block. 1. Place the cursor in the document block region. 2. From the View menu, select Expand Execution Group. 3. To hide the group, select View>Collapse Execution Group. Switch between Input and Output 1. Place the cursor in the document block region. 2. From the View menu, select Toggle Input-Output Display.
252 • 6 Creating Mathematical Documents Typesetting You can control typesetting and 2-D Math equation parsing options in the Standard Worksheet interface. Extended typesetting uses a customizable set of rules for displaying expressions. The rule-based typesetting functionality is available when Typesettinglevel is set to Extended (Tools>Options>Display tab). This parsing functionality applies to 2-D Math editing (Math mode) only. To specify rules, use the Typesetting Rule Assistant.
6.2 Document Formatting • 253 dimensions, can be modified after table creation. The following is an example table using the default settings. 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 Navigating Table Cells Use the Tab key to move to the next cell. Tab icon off.
254 • 6 Creating Mathematical Documents • 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. Deleting Rows and Columns 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.
6.2 Document Formatting • 255 Alternatively, the size of the table can be controlled from the Table Properties dialog. Select Tables>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.
256 • 6 Creating Mathematical Documents 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.
6.2 Document Formatting • 257 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. Execution Order Dependency The order in which cells are executed is set in the Table Properties dialog. The following tables illustrate the effect of execution order.
258 • 6 Creating Mathematical Documents Tables and the Classic Worksheet Tables are flattened on export to the Classic Worksheet interface. For example, the following table in the Standard Worksheet appears as one column in the Classic Worksheet interface. Table in Standard Worksheet Table in Classic Worksheet Examples Table of Values This example illustrates how to set the visibility options for cell contents to display a table of values.
6.2 Document Formatting • 259 t [s] 0 1 2 3 4 5 6 y(t) [m] Formatting Table Headers The following table uses cell merging for formatting row and column headers, and row and column grouping to control the visibility of cell boundaries. 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.
260 • 6 Creating Mathematical Documents 6. (Optional) Change Table Size Mode size option to Scale with zoom factor. Using the Table menu: 7. Set Alignment of columns 3 and 4 to Center. 2-D Math and Plots The following example illustrates the use of tables to display 2-D Math and plots side by side. Table Settings: In the Properties dialog (Table>Properties menu): 1. Set Exterior and Interior Borders to None. 2.
6.2 Document Formatting • 261 3. Change row Alignment to Center. Table of Mathematical Expressions This example illustrates using the baseline alignment option to align equations across columns in a table. f(x) Table Settings: In the Properties dialog (Table>Properties menu): 1. Set Exterior Border to Top and Bottom. Using the Table menu: 2. Group columns 1 and 2. 3. Group rows 2 to 4. Using the Table menu: 4. Set row Alignment to Baseline for all rows.
262 • 6 Creating Mathematical Documents Formatting Lists: Bullets, Numbers, and Indent Bullet, numbered, and indented lists provide an easy way to organize information in your document. Formatting Lists Using the Context Bar To arrange content in a bullet list using the context bar drop-down list: 1. Select the text to be arranged. 2. In the character and paragraph style drop-down list, select P Bullet Item. The selected text is displayed as a (dot) bullet list.
6.2 Document Formatting • 263 Figure 6.12: Ordered List Styles To arrange content in an indented list using the context bar drop-down list: 1. Select the text to be arranged. 2. In the character and paragraph style drop-down list, select P List Item. The selected text is displayed as an indented list.
264 • 6 Creating Mathematical Documents 4. If you have selected one of the numbered styles (number, letters, Roman numerals), set an initial list value. 5. To continue numbering this list from a previous list in your document, select the Linked to Previous List check box. 6. Click OK to accept this style. 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.
6.2 Document Formatting • 265 Go to a Bookmark You can automatically move the cursor to the location of the bookmark in the active document. 1. From the Edit menu, select Go To Bookmark. The Go To Bookmark dialog opens with the current bookmarks listed. 2. Select the bookmark and click OK. The cursor moves to the bookmark. Inserting Images Images help illustrate ideas and enhance presentations. You can insert images in your document at a cursor location or in a table.
266 • 6 Creating Mathematical Documents If the source file is altered, the embedded image does not change because the original object is pasted into the document. To resize an inserted image: 1. Click the image. Resizing anchors appear at the sides and corners of the image. 2. Move the mouse over the resize anchor. Resizing arrows appear. 3. Click and drag the image to the desired size. ImageTools Package You can manipulate image data using the ImageTools package.
6.2 Document Formatting • 267 Using the Show Contents Dialog A check mark beside the item indicates that all document elements of that type are displayed for the current document. 1. From the View menu, select Show/Hide Contents. The Show Contents dialog opens with all items selected for display. 2. Clear the check box associated with the document components or ranges to hide. By clearing the Input check box, only Maple Input and 2-D Math input, that is, 2-D Math content that has been evaluated, are hidden.
268 • 6 Creating Mathematical Documents 6.3 Embedded Components You can embed simple graphical interface components, for example, a button, in your document. These components can then be associated with actions that are to be executed. For example, the value of a slider component can be assigned to a document variable, or a text field can be part of an input equation. Adding Graphical Interface Components The graphical interface components can be inserted by using the Components palette (Figure 6.
6.3 Embedded Components • 269 Figure 6.13: Components Palette Editing Component Properties: General Process To edit properties of components embedded in the document: 1. Right-click (Control-click, for Macintosh) the component to display the context menu. 2. Select Component Properties. The related dialog opens. 3. Enter values and contents in the fields as necessary. 4. For actions, such as Action When Value Changes in the Slider component dialog, click Edit.
270 • 6 Creating Mathematical Documents Example Component Properties The following example inserts a slider, and 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. Right-click (Control-click, for Macintosh) the label component.
6.4 Creating Graded Assignments • 271 For details on these commands, refer to the ?DocumentTools/SetProperty and the ?DocumentTools/GetProperty help pages. Printing and Exporting a Document with Embedded Components Printing: When printing a document, embedded components are rendered as they appear on screen. Exporting: Exporting a document with embedded components to other formats produces the following results. • HTML format - components are exported as .gif files.
272 • 6 Creating Mathematical Documents Viewing Questions in Maple To view and test your questions in Maple: • From the View menu, select Assignment. This view displays all of the questions in your assignment with access to hints, plotting, and grading. After answering your questions, you can test the grading function by clicking the Grade button. A Maplet dialog is displayed indicating if the question was answered correctly. If hints were provided in the question, these are also displayed.
6.5 Auto-Execute • 273 The Autoexecute feature allows you to designate regions of a document for automatic execution. These regions are executed when the document opens. 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. Setting the Auto-Execute Feature 1. Select the region that must be automatically executed when the document opens. 2. From the Format menu, select Autoexecute, and then Set.
274 • 6 Creating Mathematical Documents 6.6 Sketch Regions A sketch pad in your document allows you to quickly sketch ideas or concepts. See Figure 6.14. Figure 6.14: Sketch Canvas and Sketch Tools Insert a Sketch Pad To insert a sketch pad: 1. Place the cursor where the sketch pad is to be inserted. 2. From the Insert menu, select Sketch. A sketch pad with grid lines appears in the document at the insertion point. The Sketch menu is available and associated context bar icons are displayed.
6.6 Sketch Regions • 275 Drawing To draw with a pencil or highlighter in the sketch pad: 1. From the Sketch menu, select Pencil or Highlighter. 2. Select a line thickness in the toolbar drop-down list. 3. With your mouse, draw lines in the sketch canvas. To adjust the color and width of the pencil and highlighter tools: 1. From the Sketch menu, select Stroke Style Presets. The Stroke Styles dialog opens. 2. Click the Pencil or Highlighter tab. The current styles are displayed. 3.
276 • 6 Creating Mathematical Documents To alter the canvas style: 1. From the Sketch menu, select Canvas Style. The Canvas Style dialog opens. 2. For grid lines, select the appropriate grid check boxes and adjust spacing as required using the slider. 3. For colors, click the Grid Color or Background Color buttons. The Select Color dialog opens. Select from various colors. 4. Click OK to accept changes in each dialog.
6.7 Spell Checking • 277 Selection Tool The Selection tool allows you to select a region in the sketch pad and move the contents of that selection to another area in the sketch pad. To select a region: 1. From the Sketch menu, select Selection. 2. In the sketch pad, click the mouse and drag the cursor across the region to be selected. 3. Release the mouse. The area is highlighted. 4. As necessary, move the contents of the region by clicking and dragging the mouse. 6.
278 • 6 Creating Mathematical Documents Figure 6.15: Spellcheck Dialog How to Use the Spellcheck Utility 1. From the Tools menu, select Spellcheck. Alternatively, press the F7. The Spellcheck dialog appears. It automatically begins checking the document for potential spelling mistakes. 2. If the Spellcheck utility finds a word that it does not recognize, that word is displayed in the Not Found text box. You have six choices: • To ignore the word, click Ignore.
6.7 Spell Checking • 279 • To add the word to your dictionary, click Add. For details, see the following User Dictionary section. • To close the Spellcheck dialog, that is, quit the Spellcheck utility, click Cancel. 3. When the Spellcheck is complete, a dialog containing the message "spellchecking complete" appears. Click OK to close this dialog. Selecting a Suggestion To select one of the suggestions as the correct spelling, click the appropriate word from the list in the Suggestions text box.
280 • 6 Creating Mathematical Documents • It does not require manual maintenance. You build your dictionary file by using the Add functionality of the Spellcheck. However, you can manually edit the file if an error is introduced. To specify a custom dictionary to be used with the Maple Spellcheck utility: 1. Create a .txt file using your favorite text editor in a directory/folder of your choice. 2. In Maple, open the Options dialog, Tools>Options, and select the General tab. 3.
6.8 Hyperlinks • 281 Maple session. If you set your custom dictionary use to Apply Globally, then this new word will be recognized. See User Dictionary (page 279). 6.8 Hyperlinks Use a hyperlink in your document to access any of the following. • Email • Dictionary Topic • Help Topic • Maplet Application • Web Page (URL) • Document Figure 6.16: Hyperlink Properties Dialog Inserting a Hyperlink in a Document To insert a hyperlink in the document: 1.
282 • 6 Creating Mathematical Documents 3. In the Hyperlink Properties dialog box, enter the text of the hyperlink name in the Link Text edit field. See Figure 6.16. 4. Optionally, use an image as the link. Select the Include an Image check box and Browse for the correct file. In .mw files, the image appears as the link, while in .mws files, the Link Text you entered appears as the link. You can resize the image as necessary. Click the image. Resizing anchors appear at the sides and corners of the image. 5.
6.8 Hyperlinks • 283 2. In the Target field, enter the topic of the help page. (Optional) In the Bookmark drop-down list, enter or select a bookmark. 3. Click OK. Linking to a Maplet Application To link to a Maplet application: 1. In the Type drop-down list, select Maplet . 2. In the Target field, enter the local path to a file with the .maplet extension. Optionally, click Browse to locate the file. If the Maplet application exists, clicking the link launches the Maplet application.
284 • 6 Creating Mathematical Documents Linking to a Document To link to a 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: When linking to a custom document, the path is absolute. When sharing documents that contain hyperlinks, ensure that target documents are in the same directory. 3. Click OK. 6.
7 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 321). 7.
286 • 7 Maple Expressions This section describes the key data structures: • Expression sequences • Sets • Lists • Tables • Arrays • Matrices and Vectors • Functional operators • Strings Expression Sequences The fundamental Maple data structure is the expression sequence. It is a group of expressions separated by commas. > Accessing Elements To access one of the expressions: • Enter the sequence name followed by the position of the expression enclosed in brackets([ ]).
7.2 Creating and Using Data Structures • 287 > You can select multiple expressions by specifying a range using the range operator (..). > Note: This syntax is valid for most data structures. Sets A set is an expression sequence enclosed in curly braces ({ }). > A Maple set has the basic properties of a mathematical set. • Each element is unique. Repeated elements are stored only once. • The order of elements is not stored.
288 • 7 Maple Expressions Note: The union operator is available in 1-D Math input as union. For more information, refer to the ?union help page. For more information on sets, refer to the ?set help page. Lists A list is an expression sequence enclosed in brackets ([ ]). > Note: Lists preserve both the order and repetition of elements. Accessing Entries To refer to an element in a list: • Use square brackets. For example: > For more information, see Accessing Elements (page 286).
7.2 Creating and Using Data Structures • 289 > For more information, see Solving Equations and Inequations (page 78). For more information on sets and lists, refer to the ?set help page. Arrays Conceptually, the Array data structure is a generalized list. Each element has an index that you can use to access it. The two important differences are: • The indices can be any integers. • The dimension can be greater than one. Creating and Using Arrays To define an Array, use the Array constructor.
290 • 7 Maple Expressions > The Array constructor supports other syntaxes. It also supports many options. For more information on the Array constructor and the Array data structure, refer to the ?Array help page. Large Arrays Only one- and two-dimensional Arrays (with at most 10 indices in each dimension) display in the document. Larger Arrays display as a placeholder. > To view large Arrays: • Double-click the placeholder. The Matrix Browser displays the Array.
7.2 Creating and Using Data Structures • 291 Defining Tables and Accessing Entries > > You can also assign anything, for example, a list, to each element. > > For more information on tables, refer to the ?table help page. Matrices and Vectors Matrices and Vectors are specialized data structures used in linear algebra and vector calculus computations. > For information on defining Matrices and Vectors, see Creating Matrices and Vectors (page 135).
292 • 7 Maple Expressions > > For more information on these data structures, including how to access entries and perform linear algebra computations, see Linear Algebra (page 135). Functional Operators A functional operator is a mapping result of evaluating . The value of is the . Using functional operators, you can define mathematical functions. Defining a Function To define a function of one or two variables: 1. In the Expression palette, click one of the function definition items. See Figure 7.1.
7.2 Creating and Using Data Structures • 293 Figure 7.1: Function Definition Palette Items For example, define a function that adds 1 to its input. > 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.
294 • 7 Maple Expressions > To evaluate the expression g at a value of x: • You must use the eval command. > For more information on the eval command, and using palettes and context menus to evaluate an expression at a point, see Substituting a Value for a Subexpression (page 310). Multivariate and Vector Functions To define a multivariate or vector function: • Enclose coordinates or coordinate functions in parentheses (( )).
7.2 Creating and Using Data Structures • 295 > Using Operators To perform an operation on a functional operator, specify arguments to the operator. For example, for the operator f, specify f(x), which Maple evaluates as an expression. See the following examples. Plot an Operator as an Expression Plot a three-dimensional function using the plot3d command.
296 • 7 Maple Expressions For information on plotting, see Plots and Animations (page 189). Integration Integrate a function using the int command. > > represents the Struve function. For more information, refer to the ?StruveH help page. For information on integration and other calculus operations, see Calculus (page 153).
7.2 Creating and Using Data Structures • 297 Strings A string is a sequence of characters enclosed in double quotes (" "). > Accessing Characters You can access characters in a string using brackets. > Using Strings The StringTools package is an advanced set of tools for manipulating and using strings.
298 • 7 Maple Expressions 7.3 Working with Maple Expressions This section describes how to manipulate expressions using context menus, palette items, and the underlying commands. To display the context menu for an expression: • Right-click (Control-click, for Macintosh) the expression. To view the palettes: • From the View menu, select Palettes, and then Expand Docks. Low-Level Operations Expression Types A Maple type is a broad class of expressions that share common properties.
7.3 Working with Maple Expressions • 299 Testing the Type of an Expression To test whether an expression is of a specified type: • Use the type command. > > For information on enclosing keywords in right single quotes ('), see Delaying Evaluation (page 317). 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 307).
300 • 7 Maple Expressions Testing for a Subexpression To test whether an expression contains an instance of a specified subexpression: • Use the has command. > > > The has command searches the structure of the expression for an exactly matching subexpression. For example, the following calling sequence returns false. > To return all subexpressions of a particular type, use the indets command. For more information, see Indeterminates (page 303).
7.3 Working with Maple Expressions • 301 Accessing Expression Components Left and Right-Hand Side The lhs and rhs commands return the left and right-hand side of an equation, inequality, or range. To extract the left-hand side of an expression: • Use the lhs command. To extract the right-hand side of an expression: • Use the rhs command. For example: > (7.1) > > For the following equation, the left endpoint of the range is the left-hand side of the right-hand side of the equation. > (7.
302 • 7 Maple Expressions Numerator and Denominator To extract the numerator of an expression: • Use the numer command. To extract the denominator of an expression: • Use the denom command. > 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.
7.3 Working with Maple Expressions • 303 Components of an Expression The components of an expression are called its operands. To count the number of operands in an expression: • Use the nops command. For example, construct a list of solutions to an equation. > Using the nops command, count the number of solutions. > 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.
304 • 7 Maple Expressions 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 299). > 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 300). Manipulating Expressions This section introduces the most commonly used manipulation commands.
7.3 Working with Maple Expressions • 305 To limit the simplification, specify the type of simplification to be performed. > > You can also use the simplify command with side relations. See Substituting a Value for a Subexpression (page 310). 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 algebraic extensions. For details, refer to the ?factor help page.
306 • 7 Maple Expressions • Use the ifactor command. > For more information on integers, see Integer Operations (page 71). Expanding To expand an expression: • Use the expand command. The expand command distributes products over sums and expands expressions within functions. > > 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.
7.3 Working with Maple Expressions • 307 > The combine command applies only transformations that are valid for all possible values of names in the expression. > To perform the operation under assumptions on the names, use the assuming command. For more information about assumptions, see Assumptions on Variables (page 117). > Converting To convert an expression: • Use the convert command.
308 • 7 Maple Expressions 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 97). Convert a list to a set: > 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. > represents the Legendre function of the second kind.
7.3 Working with Maple Expressions • 309 Normalizing To normalize an expression: • Use the normal command. The normal command converts expressions into factored normal form. > You can also use the normal command for zero recognition. > To expand the numerator and denominator, use the expanded option.
310 • 7 Maple Expressions • Use the sort command. The sort command orders a list of values or terms of a polynomial. > > > For information on sorting polynomials, see Sorting Terms (page 129). For more information on sorting, refer to the ?sort help page. Evaluating Expressions Substituting a Value for a Subexpression To evaluate an expression at a point, you must substitute a value for a variable. To substitute a value for a variable: 1. Right-click (Control-click, for Macintosh) the expression.
7.3 Working with Maple Expressions • 311 Maple inserts the eval command calling sequence that performs the substitution. This is the most common use of the eval command. For example, substitute in the following polynomial. > > To substitute a value for a variable using palettes: 1. In the Expression palette, click the evaluation at a point item . 2. Specify the expression, variable, and value to be substituted.
312 • 7 Maple Expressions If the left-hand side of the substitution is not a name, Maple performs the substitution only if the left-hand side of the substitution is an operand of the expression. > > 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.
7.3 Working with Maple Expressions • 313 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 ([ ]). > For more information, refer to the ?evalf help page.
314 • 7 Maple Expressions Evaluating Complex Expressions To evaluate a complex expression: • Use the evalc command. If possible, the evalc command returns the output in the canonical form expr1 + i expr2. You can enter the imaginary unit using the following two methods. • In the Common Symbols palette, click the i or j item. See Palettes (page 10). • Enter i or j, and then press the symbol completion key. See Symbol Names (page 16).
7.3 Working with Maple Expressions • 315 Note: In 1-D Math input, enter >= operators. , , and using the <>, <=, and The evalb command uses a three-valued logic system. The return values are true, false, and FAIL. If evaluation is not possible, an unevaluated expression is returned. > > > Important: The evalb command does not perform arithmetic for inequalities involving <, , >, or , and does not simplify expressions. Ensure that you perform these operations before using the evalb command.
316 • 7 Maple Expressions At the top-level, Maple fully evaluates names. That is, Maple checks if the name or symbol has an assigned value. If it has a value, Maple substitutes the value for the name. If this value has an assigned value, Maple performs a substitution, recursively, until no more substitutions are possible. For example: > > > Maple fully evaluates the name x, and returns the value 5.
7.3 Working with Maple Expressions • 317 > 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.
318 • 7 Maple Expressions Error, (in sum) summation variable previously assigned, second argument evaluates to 4 = 1 .. 5 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 319). To use an assigned name as a variable: • Enclose the name in unevaluation quotes. Maple passes the name to the command. > Important: It is recommended that you enclose keywords in unevaluation quotes.
7.3 Working with Maple Expressions • 319 (7.3) > (7.4) > For information on equation labels and equation label references, see Equation Labels (page 59). Enclosing an expression in unevaluation quotes delays evaluation, but does not prevent automatic simplification. > Unassigning a Name Using Unevaluation Quotes To unassign a name: • Assign the name enclosed in unevaluation quotes to itself. > > You can also unassign a name using the unassign command.
320 • 7 Maple Expressions
8 Basic Programming You have used Maple interactively in the previous chapters, sequentially performing operations such as executing a single command. Because Maple has a complete programming language, you can also use sophisticated programming constructs. 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. 8.
322 • 8 Basic Programming 8.2 Flow Control Two basic programming constructs in Maple are the if statement, which controls the conditional execution of statement sequences, and the for statement, which controls the repeated execution of a statement sequence. Conditional Execution (if Statement) You can specify that Maple perform an action only if a condition holds. You can also perform an action, from a set of many, depending on which conditions hold.
8.2 Flow Control • 323 • 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. The else clause is optional. Simple if Statements The simplest if statement has only one conditional expression.
324 • 8 Basic Programming For example: > if false then "if statement"; else "else statement"; end if; elif Clauses In an if statement with elif clauses, Maple evaluates the conditional 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.
8.2 Flow Control • 325 > 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. elif and else Clauses In an if statement with elif and else clauses, Maple evaluates the conditional expressions in order until one returns true. Maple executes the corresponding statement sequence, and then exits the if statement.
326 • 8 Basic Programming • Until a counter variable value exceeds a limit (for/from loop) • For each operand of an expression (for/in loop) • Until a boolean condition does not hold (while loop) for/from Loop The for/from loop statement repeats a statement sequence until a counter variable value exceeds a limit. Syntax The for/from loop has the following syntax. > for counter from initial by increment to final do statement_sequence end do; The behavior of the for/from loop is: 1.
8.2 Flow Control • 327 Table 8.1: Default Clause Values Clause Default Value from initial 1 by increment 1 to final infinity (∞) Examples The following loop returns the square root of the integers 1 to 5 (inclusive). > for n to 5 do evalf(sqrt(n)); end do; When the value of the counter variable n is strictly greater than 5, Maple exits the loop. > n; The previous loop is equivalent to the following for/from statement.
328 • 8 Basic Programming > for n from 1 by 1 to 5 do evalf(sqrt(n)); end do; The by value can be negative. The loop repeats until the value of the counter variable is strictly less than the final value. > for n from 10 by -1 to 3 do if isprime(n) then print(n); end if; end do; > n; for/in Loop The for/in loop statement repeats a statement sequence for each component (operand) of an expression, for example, the elements of a list. Syntax The for/in loop has the following syntax.
8.2 Flow Control • 329 The for clause must appear first. The behavior of the for/in loop is: 1. Assign the first operand of expression to the name variable. 2. Execute the statement_sequence. 3. Assign the next operand of expression to variable. 4. Repeat steps 2 and 3 for each operand in expression. If there are no more operands, exit the loop. (This is the loop bound test.
330 • 8 Basic Programming Syntax The while loop has the following syntax. > while conditional_expression do statement_sequence end do; A while loops repeats until its boolean expression conditional_expression evaluates to false or FAIL. For more information on boolean expressions, see Conditional Execution (if Statement) (page 322). Example The following loop computes the digits of 872, 349 in base 7 (in order of increasing significance).
8.2 Flow Control • 331 To perform such conversions efficiently, use the convert/base command. > convert(872349, base, 7); For information on non-base 10 numbers, see Non-Base 10 Numbers (page 74). General Loop Statements You can include a while statement in a for/from or for/in loop. The general for/from loop has the following syntax.
332 • 8 Basic Programming > for counter from initial by increment to final while conditional_expression do statement_sequence end do; The general for/in loop has the following syntax. > for variable in expression while conditional_expression do statement_sequence end do; After testing the loop bound condition at the beginning of each iteration of the for loop, Maple evaluates conditional_expression. • If conditional_expression evaluates to false or FAIL, Maple exits the loop.
8.3 Iterative Commands • 333 8.3 Iterative Commands Maple has commands that perform common selection and repetition operations. These commands are more efficient than similar algorithms implemented using library commands. Table 8.2 lists the iterative commands. Table 8.
334 • 8 Basic Programming Calling Sequence Syntax Examples seq(expression, name in expression); > seq(u, u in [Pi/4, Pi^2/2, 1/Pi]); Adding and Multiplying Expressions The add and mul commands add and multiply sequences of expressions over a range of index values or the operands of an expression. See Table 8.4. Table 8.4: The add and mul Commands Calling Sequence Syntax Examples add(expression, name = initial .. final); > add(exp(x), x = 2..4); mul(expression, name = initial ..
8.3 Iterative Commands • 335 Selecting Expression Operands The select, remove, and selectremove commands apply a boolean-valued procedure or command to the operands of an expression. For information on operands, refer to the ?op help page. • The select command returns the operands for which the procedure or command returns true. • The remove command returns the operands for which the procedure or command returns false.
336 • 8 Basic Programming Calling Sequence Syntax Examples selectremove(proc_cmd, expression); > selectremove(x -> evalb(x > round(x)), [sin(0.), sin(1.), sin(3.)]); For information on optional arguments to the selection commands, refer to the ?select help page. Mapping a Command over a Set or List The map command applies a name, procedure, or command to each element in a set or list. See Table 8.6. Table 8.
8.3 Iterative Commands • 337 By default, the length of the returned object is that of the shorter list or vector. If you specify a value as the (optional) fourth argument, it is used as the value of the missing elements of the shorter list or vector. In this case, the length of the return value is that of the longer list or vector. See Table 8.7. Table 8.
338 • 8 Basic Programming 8.4 Procedures A Maple procedure is a program consisting of Maple statements. Using procedures, you can quickly execute the contained sequence of statements. Defining and Running Simple Procedures To define a procedure, enclose a sequence of statements between proc(...) and end proc statements. In general, you assign a procedure definition to a name. The following procedure returns the square root of 2.
8.4 Procedures • 339 Procedures with Inputs You can define a procedure that accepts user input. In the parentheses of the proc statement, specify the parameter names. For multiple parameters, separate the names with commas. > geometric_mean := proc(x, y) sqrt(x*y); end proc: When the user runs the procedure, the parameter names are replaced by the argument values. > geometric_mean(13, 17); > geometric_mean(13.5, 17.
340 • 8 Basic Programming > p(1, 2); Displaying Procedure Definitions Unlike simple Maple objects, you cannot display the value of a procedure by entering its name. > geometric_mean; You must evaluate the name of the procedure using the print (or eval) command. > print(geometric_mean); Displaying Maple Library Procedure Definitions Maple procedure definitions are a valuable learning tool. To learn how to program in Maple, it is recommended that you examine the procedures available in the Maple library.
8.4 Procedures > interface('verboseproc' = 2): Figure 8.
342 • 8 Basic Programming 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.
9 Maplets A Maplet is a graphical user interface that provides interactive access to the Maple engine through buttons, text regions, slider bars, and other visual interfaces. You can design custom Maplet applications to use and share with colleagues or students, or you can take advantage of the built-in Maplets that cover numerous academic and specialized topics.
344 • 9 Maplets > MySimpleMaplet:= Maplet([["Hello World"]]): > Maplets[Display](MySimpleMaplet): Figure 9.1: A Simple Maplet For more information on creating Maplets, including an overview of the point-and-click Maplet Builder Assistant, see Authoring Maplets (page 345). 9.3 Using Maplets Maplet applications are launched by executing Maplet code. Maplet code can be saved in a Maplet (.maplet) file or Maple document (.mw).
9.4 Authoring Maplets • 345 Maple Document To launch a Maplet application for which the Maple code is contained in a Maple document, you need to execute the Maplet code. To display the Maplet application, you must use the Maplets[Display] command. Note: The Maplet code may be quite large if the Maplet application is complex. In this case, execute the document to ensure user-defined procedures that are referenced in the Maplet application are also defined. Typical procedure: 1.
346 • 9 Maplets simple Maplets. The Maplets package offers more capabilities, control and options when designing complicated Maplet applications. 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.
9.4 Authoring Maplets • 347 • The Palette pane displays palettes, which contain Maplet elements, organized by category. For a description of the elements, see the ?MapletBuilder/Palette help page. The Body palette contains the most popular elements. • The Layout pane displays the visual elements of the Maplet. • The Command pane displays the commands and corresponding actions defined in the Maplet. • The Properties pane displays the properties of an instance of a defined element in the Maplet.
348 • 9 Maplets Button element Label element Plotter element TextField element Figure 9.4: Body Elements Used When Defining This Maplet Define the number of rows in the Maplet 1. In the Properties pane: a. In the drop-down list, select BoxColumn1. b. Change the numrows field to 2. Figure 9.
9.4 Authoring Maplets • 349 Add a plot region to row 1 1. From the Body palette, drag the Plotter element to the first row in the Layout pane. Figure 9.
350 • 9 Maplets Add columns to row 2 1. In the Properties pane: a. In the drop-down list, select BoxRow2. b. Change the numcolumns field to 3. Figure 9.
9.4 Authoring Maplets • 351 Add a label to row 2 1. From the Body palette, drag the Label element to the left column in the Layout pane. 2. In the Properties pane: a. In the drop-down list, select Label1. b. Change the caption field to Enter a function of x. Figure 9.
352 • 9 Maplets Add a text region to row 2 1. From the Body palette, drag the TextField element to the middle column. The TextField element allows the Maplet user to enter input that can be retrieved in an action. 2. If necessary, resize the Maplet Builder to display the entire Layout pane. Figure 9.
9.4 Authoring Maplets • 353 Add a button to row 2 1. From the Body palette, drag the Button element to the right column in the Layout pane. 2. In the Properties pane: a. In the drop-down list, select Button1. b. Change the caption field to Plot. c. In the onclick property drop-down list, select . Figure 9.
354 • 9 Maplets 3. In the Evaluate Expression dialog that displays, the Target drop-down list contains the defined elements to which you can send information, in this case, Plotter1 and TextField1. The List group box, located below the Expression group box, displays the defined elements to which you can retrieve information, in this case, TextField1. a. In the Target drop-down list, select Plotter1. b. In the Command Form tab, enter plot(TextField1, x=-10..10) in the Expression group box.
9.4 Authoring Maplets • 355 Figure 9.11: Evaluate Expression Dialog Run the Maplet 1. From the File menu, select Run. You are prompted to save the Maplet. Maplets created with the Maplet Builder are saved as .maplet files. 2. Click Yes and navigate to a location to save this Maplet. For further information on the Maplet Builder, see the ?MapletBuilder help page. For more examples of designing Maplets using the Maplet Builder, see ?MapletBuilder/examples.
356 • 9 Maplets Example 1 - Design a Maplet Using the Maplets Package To introduce the structure of designing Maplets using the Maplets package, this example illustrates the equivalent syntax for the Design a Maplet Using the Maplet Builder (page 347). Load the Maplets[Elements] package. > with(Maplets[Elements]): Define the Maplet application. To suppress the display of the data structure associated with the Maplet application, end the definition with a colon.
9.4 Authoring Maplets • 357 > PlottingMaplet:=Maplet( BoxLayout( BoxColumn( # First Box Row BoxRow( # Define a Plot region Plotter('reference' = Plotter1) # End of first Box Row ), # Second Box Row BoxRow( # Define a Label Label("Enter a function of x "), # Define a Text Field TextField('reference' = TextField1), # Define a Button Button(caption="Plot", Evaluate(value = 'plot(TextField1, x = -10..
358 • 9 Maplets Example 2 - Accessing User-Defined Procedures When designing a Maplet, you can access user-designed procedures and send information bi-directionally to the Maplet. In this example, shown in Figure 9.12, the user enters a function in a MathML editor region, optionally selects a color from a color dialog, and plots the result. Figure 9.
9.4 Authoring Maplets User-Defined Procedure and Maplet Code Define a procedure to be accessed in the Maplet. > GetColor:=proc() local R, G, B, result; use Maplets[Tools] in # Convert the color value defined in the Color dialog result:=Get(ColorDialog1); # The result format is "#RRGGBB" in hexadecimal(base 16) # Convert to values in the range 0..1 R:=convert(result[2..3], 'decimal', 16)/255; G:=convert(result[4..5], 'decimal', 16)/255; B:=convert(result[6..
360 • 9 Maplets > PlottingMaplet2:= Maplet( 'onstartup' = Action(RunWindow(Window1)), Window('reference' = Window1, BoxLayout( BoxColumn( BoxRow( Plotter('reference' = Plotter1)), BoxRow( MathMLEditor('reference' = MathMLEditor1)), BoxRow( # Access the GetColor procedure and plot the result Button("Plot", Evaluate('function' = 'GetColor', 'target' = 'Plotter1')), # Launch the Color dialog Button("Color", RunDialog('dialog' = 'ColorDialog1')), # Close the Maplet Button("Close", Shutdown())) ) ) ), Action('re
9.4 Authoring Maplets • 361 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: 1. From the File menu, select Save. 2. Navigate to the save location. 3. Enter a filename. 4. Click Save. If the document contains only Maplet code, it is recommended that you export the document as a .maplet file. Maplet File To export the Maplet code as a .maplet file: 1.
362 • 9 Maplets
10 Input, Output, and Interacting with Other Products 10.
364 • 10 Input, Output, and Interacting with Other Products to a file, allowing you to import the numbers into another program. To convert a list or a list of lists to a Matrix, use the Matrix constructor. For more information, refer to the ?Matrix help page. > > If the data is a Vector or any object that can be converted to type Vector, use the ExportVector command. To convert lists to Vectors, use the Vector constructor. For more information, refer to the ?Vector help page.
10.2 Writing to Files • 365 For more information on matrices and vectors, see Linear Algebra (page 135). Saving Expressions to a File If you construct a complicated expression or procedure, you can save them for future use in Maple. If you save the expression or procedure in the Maple internal format, Maple can retrieve it more efficiently than from a document. Use the save command to write the expression to a .m file. For more information on Maple internal file formats, refer to the ?file help page.
366 • 10 Input, Output, and Interacting with Other Products > > > For more information on writing to files, refer to the ?save help page. 10.3 Reading from Files The most common reason for reading files is to load data, for example, data generated in an experiment. You can store data in a text file, and then read it into Maple using the Import Data Assistant. Reading Data from a File Import Data Assistant If you generate data outside Maple, you must read it into Maple before manipulating it.
10.3 Reading from Files • 367 Figure 10.1: Import Data Assistant (Detail) From the main window, you can preview the selected file, and specify the source format, source form, and behavior on close. You can also select a different file to be imported. Additional help is available from the Help menu of the Import Data window. ImportMatrix Command The Import Data Assistant provides a graphical interface to the ImportMatrix command.
368 • 10 Input, Output, and Interacting with Other Products When you read a file with the read command, Maple treats each line in the file as a command. Maple executes the commands and displays the results in your document but it does not, by default, insert the commands from the file in your document. For example, the file ks.tst contains the following Maple commands. S:= n -> sum( binomial( n, beta ) * ( ( 2*beta )! / 2^beta - beta!*beta ), beta=1..
10.4 Exporting to Other Formats • 369 For more information, refer to the ?read and ?interface help pages. 10.4 Exporting to Other Formats Exporting Documents You can save your documents by selecting Save or Save As from the File menu. By selecting Export As from the File menu, you can also export a document in the following formats: HTML, LaTeX, Maple input, Maplet application, Maple text, plain text, and Rich Text Format. This allows you to access your work outside Maple. HTML The .
370 • 10 Input, Output, and Interacting with Other Products Maple Input You can export a Maple document as Maple input so that it can be loaded using the Maple Command-line version. Important: When exporting a document as Maple input for use in Commandline Maple, your document must contain explicit semicolons in 1-D Math input. If not, the exported .mpl file will not contain semicolons, and Command-line Maple will generate errors.
10.4 Exporting to Other Formats • 371 Rich Text Format (RTF) The .rtf file generated by Maple can be loaded into any word processor that supports RTF. Summary of Translation Table 10.
372 • 10 Input, Output, and Interacting with Other Products Content HTML LaTeX Hyperlink Links to help Plain text pages become plain text.
10.4 Exporting to Other Formats • 373 MapleNet Documents and Maplets After you upload your Maple documents to the MapleNet server, it can be accessed by anyone in the world using a Web browser. Even if viewers do not have a copy of Maple installed, they can view documents and Maplets, manipulate 3-D plots, and execute code at the click of a button.
374 • 10 Input, Output, and Interacting with Other Products Any document content outside Maple T.A. sections (indicated by green section markers) is ignored by the export process. For more details, refer to the ?exporttoMapleTA help page. 10.5 Connectivity Translating Maple Code To Other Programming Languages Code Generation The CodeGeneration package is a collection of commands and subpackages that enable the translation of Maple code to other programming languages.
10.5 Connectivity • 375 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.
376 • 10 Input, Output, and Interacting with Other Products • Maple Function Wizard to step you through the creation of a Maple function call To enable the Maple Excel Add-in in Excel 2000, Excel 2003, or Excel XP: 1. From the Tools menu, choose Add-Ins. 2. If the Maple Excel Add-in is not listed: • Click Browse and navigate to the directory in which Maple is installed. • In the Excel directory, select the WMIMPLEX.xla file. • Click OK. 3. Select the Maple Excel Add-in check box. 4. Click OK.
10.5 Connectivity • 377 For more details on using OpenMaple functions, refer to the ?OpenMaple help page.
378 • 10 Input, Output, and Interacting with Other Products
converting to 1-D, 39 shortcuts, 6 switching to 1-D, 38 Index Symbols _, 58 entering, 58 _EnvAllSolutions environment variable, 82 _ZN~, 82 ;, 38–39 :, 38–39 ::, 117 :=, 55 !!! toolbar icon, 10 ! toolbar icon, 9 .
380 • Index finite-precision, 67 interval, 111 matrix and vector, 146 modular, 73, 75 polynomial, 126 Arrays, 289 large, 290 arrow operator, 56 assign command, 87 assigned command, 317 assignment operator (:=), 55 Assistants, 26, 123 Curve Fitting, 134 Data Analysis, 173 Import Data, 366 menu access, 26 ODE Analyzer, 89 Optimization, 169 Plot Builder, 28, 49, 191 Unit Converter, 26, 98, 308 assume command, 117 adding assumptions, 118 and procedure variables, 120 imposing multiple assumptions, 118 removing a
Index • 381 C calculus, 153 multivariate, 166 Student package, 168 of variations, 168 packages, 166 study guides, 181 teaching, 168, 181 vector, 166 Student package, 168 canvas style sketch pad, 275 caret entering, 76 central tendency, 112 character styles creating, 240 description, 239 Cholesky decomposition, 149 choose styles dialog, 245 Classic Worksheet, xiii tables, 258 coeff command, 132 coefficients polynomials, 132 coeffs command, 133 collect command, 132 colon, 38–39 color of plots, 220 combine co
382 • Index updating, 9 with uncertainty, 114 with units, 102 conditional execution, 322 constants, 10 content command, 134 context of unit, 98 context menus, 20, 46, 123, 148, 298 customizing animations, 228 equation, 78 integer, 46, 71 Plot Builder, 28 convert command, 307 base option, 75, 331 degrees option, 307 mathematical functions, 308 polynom option, 162 set option, 308 temperature option, 100 units option, 99, 308 copy, 236 correlation, 114 coulditbe command, 119 covariance, 114 cross product, 148
Index • 383 probability, 173 divide command, 128 divisors, 73 document blocks, 32, 247 Document mode, 1 summary, 30 D operator, 158 double colon operator, 117 dsolve command, 93 E eigenvalues, 149 eigenvectors, 149 elementary charge, 106 elements, 105 definition, 107 isotopes, 107 definition, 107 properties, 107 list, 107 properties list, 107 uncertainty, 110 units, 109 using, 107 value, 109 value and units, 110 elif clauses, 324 order, 324 else clause, 323 email adding hyperlink to, 282 embedded component
384 • Index of expression at a point, 310 output below, 8, 21, 31 output inline, 8, 21, 31 updated computations, 9 exact computation, 67 numbers, 66 quantities converting to floating-point, 69 example worksheets, 33 execution group, 38 auto-execute, 272 expand command, 306 document block, 250 execution group, 251 series, 161 exponents entering, 5 export, 342 to HTML, 369 to LaTeX, 369 to Maple input, 370 to Maple T.A.
Index • 385 formal power series solutions, 93 format lists using paragraph styles, 263 Format menu bookmarks, 264 document blocks, 248 quick formatting, 233 frac command, 119 fractions approximating, 22 entering, 5 frequency plot, 177 Frobenius form matrix, 150 from clause, 326 excluding, 327 fsolve command, 84 full evaluation, 316, 318 FunctionAdvisor command, 41, 123 functional operators, 14, 292 differentiating, 158 plotting, 295 versus expressions, 293 Function Composition Tutor, 27 functions converting
386 • Index Hilbert Matrix, 151 histogram, 177 hyperlinks in worksheet, 281 I i entering, 18, 77 ifactor command, 71, 73, 306 if statement, 322 igcd command, 73 images adding hyperlink to, 282 file format, 265 inserting, 265 imaginary unit entering, 18, 77 implies operator, 323 Import Data Assistant, 366 indent format, 236 list, 262 indeterminates, 303 indets command, 303 indices, 40, 144 inequations solving, 78 for real solutions, 115 symbolically, 80 infinite loops, 332 infolevel command, 94 input 1-D Ma
Index • 387 interface command rtablesize option, 141 verboseproc option, 340 international system (SI), 98 InterquartileRange command, 175 interval arithmetic, 111 iquo command, 73 irem command, 73 iroot command, 73 is command, 118 isprime command, 73 isqrt command, 73 italic format, 233 J j entering, 77 Jordan form, 149 L labels, 59 last name evaluation, 317 Layout palette, 11 lcm command, 134 lcoeff command, 132 ldegree command, 133 least-squares, 151 left-hand side, 301 left single quotes, 58 levels of
388 • Index launching, 346 Maplet authoring, 346 Maplets adding hyperlink to, 283 authoring, 345 Maplet Builder, 346 Maplets package, 355 launching Maplet file type, 344 Maple worksheet, 345 Maplets package Display command, 355 Elements subpackage, 355 Maplet authoring, 355 saving maplet file, 361 Maple worksheet, 361 using, 344 markers bookmarks, 264 displaying, 238 for document blocks, 247 mathematical functions list, 41 mathematics computations, 123 teaching and learning, 180 Math mode, 4 shortcuts, 6 ma
Index • 389 mod operator, 75 modp command, 75 mods command, 75 modular arithmetic, 73, 75 modules, 342 MPS(X) files, 173 msolve command, 95 mul command, 334 multiplication implied, 6 N names, 10, 55 adding assumptions, 117 and symbols, 16 assigned, 317 assigning values to, 55 logical, 323 previously assigned, 317 protected, 57 removing assumptions, 119 reserved, 57 unassigning, 57, 119, 319 valid, 58 versus equation labels, 62 with assumptions, 117 new style set, 245 nops command, 303 normal command, 309 n
390 • Index unloading, 43, 58 warnings, 43 page break, 236 palettes, 10, 20, 44, 123, 298, 311 Common Symbols, 11 docks, 15 adding palettes, 15 expanding, 15 Expression, 12 finding items, 15 inserting items, 12 Layout, 11 Matrix, 12, 135, 141 moving, 15 Symbol Recognition, 15 Units, 24, 100 viewing, 15 paragraph styles creating, 243 description, 239 format lists, 263 parameters, 339 parametric solutions, 83 partial differential equations solving, 93 paste, 237 PDEs, 93 pdsolve command, 93 pencil sketch pad,
Index • 391 numeric solution, 91 symbolic solution, 92 optimization problem, 170 playing animations, 226 plots package animate command, 225 contourplot command, 214 display command, 215 matrixplot command, 212 pointplot command, 211 series, 162 statistics, 177 viewing animations animate context bar, 226 polynomial equations solving, 83 numerically, 84 polynomials algebra, 126 arithmetic, 126 coefficients, 132 collecting terms, 132 degree, 132 division, 126, 128 efficient arithmetic, 135 expanding, 128 facto
392 • Index Q QPSolve command, 172 QR factorization, 151 quadratic programs, 172 quantities with uncertainty, 112 accessing error, 112 accessing value, 112 computing with, 114 constructing, 112 element properties, 113 rounding the error, 113 scientific constants, 113 with units, 113 quick character formatting, 233 help, 32 paragraph formatting, 235 reference card, 32 quit statement, 332 quo command, 126 quotes double, 297 left single, 58 right single, 57, 317 unevaluation, 317 quotient integer, 73 R rando
Index • 393 list, 105 name, 106 symbol, 106 uncertainty, 110 units, 109 using, 106 value, 109 value and units, 110 ScientificConstants package, 105 extensibility, 111 objects, 108 ScientificErrorAnalysis package, 111 extensibility, 115 objects, 112 sections in worksheet, 237 security levels auto-execute, 273 security tab options dialog, 273 select command, 335 selectremove command, 335 semicolon, 38–39 seq command, 333 series, 161 command, 161 plotting, 162 Taylor, 161 type, 162 sets, 287 shape option, 142
394 • Index real solutions, 115 solving procedures, 83 sort lists, 310 polynomials, 129, 310 sort command, 129, 310 plex option, 130 spacing format, 236 spellcheck, 277 American spelling, 277 dictionary, 280 sqrfree command, 135 square roots entering, 6, 17 standard content, 53 Standard Units environment, 102 Standard Worksheet, xiii statements multiple lines, 338 Statistics package, 173 continuous distributions, 173 discrete distributions, 173 plots, 177 strings, 297 StringTools package, 297 Student packag
Index • 395 task templates, 51, 71, 97, 123, 135, 153 default content, 53 inserting, 52 taylor command, 161 Taylor series, 161 tcoeff command, 133 teach, 180 temperature conversion, 99 text field embedding, 268 Text mode, 4 text regions, 54 third-party products, 124 tilde, 82, 117 to clause, 326 excluding, 327 Tolerances package, 111 toolbar, 4 toolbox Global Optimization, 124 toolboxes Database Integration, 374 Global Optimization, 168 Tools menu Assistants and Tutors, 26, 48 Tasks, 51 Torsion command, 167
396 • Index prefixes, 102 system of controlling, 103 systems of, 98 Units package, 97 environments, 102 extensibility, 104 UseSystem command, 104 UsingSystem command, 104 Units palettes, 24, 100 universal gravitational constant, 106 UNIX command/symbol completion, 7 unwith command, 43 URL adding hyperlink to, 283 user-defined style set, 247 V variables, 10 variance, 114 VariationalCalculus package, 168 Vector constructor vectorfield attribute, 166 data structure, 135 VectorCalculus package, 166 Student ver
Index • 397 zip command, 336
398 • Index