MAPLE Examples and Tips

Introductory videos

For the new user one can watch a three minute Clickable Math video get acquainted introduction to Maple. For a little more payoff, there is a 37 minute Maple Fundamentals Guide. [For a whole list see this training videos link.]

To begin to become familiar with the Maple interface when opening Maple for the first time, browse this document.

 

MAT1500-1505-2500-2705 [Calc1,2,3, DiffEqWLinAlg]

Maple is a required tool for this sequence of math courses for science and engineering students. Examples of how to use Maple for every topic in this sequence may be found below on this page.

 

Maple worksheets on the web?

If Maple is installed locally on your machine or network, you can just click on the link to a Maple worksheet and it will open. Try it below.

Tips to Remember

Remember this if nothing else

  • "e" is not Euler's number, use the Expression palette; "exp(1)" wjhen you need it in popup applet windows
  • "Pi" is the 3.14159 number when you need it in popup applet windows.
  • Variable names or expressions to be multiplied must be separated by a space or explicit asterisk or will be interpreted as a new variable name:  x y, not xy, and x (x+2) not x(x+2); hard numbers require an asterisk: 2.3*2.718, not 2.3 2.718.

Getting Started

  • Worksheets versus Documents.
    Maple opens with a workspace that allows the choice of New Document or New Worksheet (or start by using the File menu, and selecting New  then Document Mode or Worksheet Mode). Document mode is a blank document with no input prompts just white space, but usually we want to work in the more structured worksheet mode, which has input prompts and separate output regions, and shows the user what Maple commands are used by the right click menus, which can often be edited to modify easily without foreknowledge of the command.
    [One can include document blocks in worksheet mode as well through Format Menu, Document Block, which removes the left margin execution grouping line. One can switch to worksheet mode from document mode simply by introducing a prompt. View, Expand Document Block will show the underlying computations hidden in Document mode.]
    Right-clicking on output expressions once entered with the Enter key opens a menu of operations that can be applied to the expression. Maple then inserts the underlying command and the result in a new input/output pair of regions.

    If you choose to start with a New Document instead, there are no input prompts, and results of right-clicking on expressions follow them after an arrow and commands are suppressed. [A short 3 minute training video helps the new user understand how to use the Clickable Calculus interface of Maple Document mode: clickable calculus.]
     
  • 2d math movements
    An important tip for Maple 2d math input (black, math italic) is that you must use the right arrow key to continue inputting an expression after raising to an exponent or dividing by a denominator (using the forward slash for division, asterisk for multiplication), in fact you can use all 4 arrows to move around an expression to edit its various pieces, while when entering from the palette, the tab key moves you through the placeholder characters to be replaced. Right clicking on expressions gives you menus to select operations you wish to perform.

    [The input mode "1d math = bold red character input" like in help pages) is not the default in Maple (you can change it in Tools, Options, Input Display for the session), but each time you enter a blank input region after the Maple prompt ">" you can click on the leftmost "Text" button on the inside window toolbar to switch to it, while the "Math" button switches back to 2d math input. This can be useful for inputting little Maple programs in a more organized way than the 2d math line breaking spacing rules allow.]

  • Popup menu 1d input
    The very helpful Tutors require 1d math input in the insertion windows, so one has to remember to use "*" for multiplication, Pi for "pi", "exp(x)" or exp(1) for the exponential function or number e, power notation (...)^(1/3), etc.

Pallette use and display

  • Initially close all palettes (click on triangle in header) and left-click drag Expressions, Common Symbols, Calculus, Matrices to the top of the list in this order, then open the top two for ready use.
  • When the cursor is in an input or even math mode text region, clicking on an icon will insert it with its placeholders to fill in moving between them with the Tab key. It is relatively easy to learn how to combine palette input with typing to create any mathematical expression or equation. If it is in an input region, entering it to produce an output allows the user to right click on that output and take actions from the context sensitive menu. In a math mode text region, one can directly right click on the expression/equation to select an action, like execute in-line (Cntrl =).

Predefined Constants and Variable Names

  • Maple is case-sensitive like mathematics, distinguish uppercase and lowercase letters and be consistent.
    D
    is reserved for Maple function differentiation.
  • Pi is the number π, exp(x) is ex, exp(1) is e
    but in typing Maple,  e or e  is never the Euler number and e^x is never the exponential function
    [use the Common Symbol palette or the Greek letter palette; both entries for
    π now correspond to the 1d math symbol Pi standing for 3.14159...].
    The complex number i = sqrt(-1) is represented by the uppercase letter I in Maple, also available from the Common Symbol palette.
    You still need to know these 1d math names to enter them in the pop up interactive windows, like the plot range in the plot builder for trig functions where ranges like 0.. 2*Pi are frequently required.
  • A variable name in its simplest form is a letter followed by zero or more letters, digits, underscore characters (_) and question marks (?), with lowercase and uppercase letters distinct. Any convenient string that conveys meaning about its interpretation is useful.

Delimiters, spaces, ranges

  • All Maple commands or functions obey function notation with rounded parentheses (,) enclosing their inputs separated by commas, as in "plot(x,...)" or "cos(x)" with no space before the left parenthesis. All groupings overriding the usual rules for order of performing the basic operations are done using matching rounded parentheses only (no brackets or braces of any kind).
  • Square brackets [,] enclose a list of objects (numbers, functions, color names) whose order is to be maintained, like vector components, or a list of functions to coordinate with a list of colors in a plot command.
    [Square brackets are also used for subscripts on vectors or matrices: v[1] becomes v1, A[1,2] becomes A1,2.]
    Curly brackets
    {,} are used to enclose sets of objects whose order is unimportant, as in a set of equations to be solved.
    Triangle brackets < , > are used for listing vector components with entries separated by commas, which appear in the output as column matrices.
  • % stands for the last output in time (not necessarily the previous output in position in the worksheet). When a series of inputs using "%" goes bad and has to be re-edited and executed, you must re-execute from the first statement to which they refer to reset the sequence. %% stands for the next to last output in time.
  • Shift Enter. Holding the Shift key and pressing the Enter key at the end of a Maple input allows you to go to the next line.
    If you wish to put two Maple inputs together in 2d math notation, they must be separated by a semicolon ";"
    (or a colon ":" to suppress the output of the preceding command).
  • In 2d math mode input, spaces are needed between variables to imply multiplication:
    spaces
    between variables or between a variable and a constant (x y or 2 x or 3 I but not 2 2) imply multiplication but an asterisk "*" or centered dot from the Common Symbols palette is required in 1d mode and between hard numbers like 2 and 31/2 in 2d input as well as before parentheses: x (x+2) must have a space before the "(" or Maple will misbehave, xy will be interpreted as a new variable name, not as the product x y of two variables.
    The right arrow key is needed to climb down from a superscript and continue or climb up from a denominator (use / for division and fractions) and continue entering input. Always use parentheses ( ) when needed for grouping! All 4 arrow keys and the Tab key can be used to move around in 2d math input.

  • When you give a range of values for a variable: x = 1..4, but when decimals are entered do x = 0.1..0.4 for clarity but x = .1...4 will also work correctly now.

HELP!

  • F1 gives you the short list of keystroke hints.
         [The long list is under Help, Table of Contents, Advanced Features, Worksheet Interface, Windows. Like Control +4 for zoom 4 times.]
    Control F2
    gives you the Quick Reference Card summary of Maple interface help.
    When you put the cursor on a Maple command,
    F2
    gives you the Maple help for that command, or you can then go to the Help menu and find "Help on ..." listed to release the mouse on to achieve the same result.
    When a command is in a package like plots, or Student[Calculus1], by loading the package with no punctuation or a semicolon first, one can click on the desired command in the list and hit F2. Then you can suppress the list by inserting a colon after the input line as in  "> with(plots): ".
  • Control Space invokes auto-complete when entering Maple commands to choose from a popup menu of all commands which begin with the typed letters. This is really useful for "ReducedRowEchelonForm" and "BackwardsSubstitute" from the LinearAlgebra package.
  • If the output of a worksheet on the web has been removed (Edit Menu, bottom, Remove Output, from entire worksheet), it can be restored by Edit Menu, Execute Worksheet or by clicking on the !!! icon on the upper tool bar. You may also select a region and execute it with the ! icon.
  • After deleting a range of Maple stuff, you must use the Edit Menu, Delete Element to get rid of the last input/output/text region of the selected stuff.

2d plotting: multiple function graphs versus parametrized curves

  • Right-clicking on an output expression with no unevaluated constants to plot it, choose Plots, Plot Builder to predecide the window range of the independent variable and get more control over what you see [the other plot choices are sometimes problematic with students].
  • Square brackets around a list of expressions maintains their order, while curly "set" braces do not, since sets are not supposed to have a preferred order.
    > plot([x2,x3], x=0..1)    will plot two power functions,
    > plot([x2,x3, x=0..1])    will plot the second expression versus the first as a parametrized curve, equivalent to graphing the function y = x3/2. [Note you need the surd command to plot odd fractional roots for negative inputs.]
    Alternatively just entering
    > [t2,t3]
    allows you to right click and choose plot builder and parametric plot.
     
  • If you enter an expression for a real function that you want to plot (or a sequence of functions separated by commas and surrounded by curly set braces), choose plot builder from the right click menu, not 2d plots (where you have to further right click on the smartplot and choose axes, range to reset the window). If you click on an equation say y = f(x) you must right click and first choose right hand side to get the expression to then plot with plot builder.
  • To 2d plot multiple expressions by right-click menu, one can also enter one expression and plot it by right-clicking on the output and selecting plot builder, then enter the other expressions in a new input region and select and drag them one by one from their output onto the plot. Avoid smartplot, it is not smart enough.

2d plotting: new features

There are a few new features that are useful to know for plots. First click on a plot to make it "live" (you see the resize box border). Then:

  • Right click on the plot and choose "Probe Info, Cursor Position" from the context menu to get two crosshair lines centered on the cursor in the plot with a numerical readout of the cursor position. You can also zoom into any plot with a right click choice, but you might need "pan" to recenter the zoom window.
  • Click on the black grid icon on the plot context toolbar line that appears when the plot is live to get gridlines on the plot, very helpful for understanding how points on curves relate to the axis tickmarks. [Or use the plot option "gridlines = true" when using the plot command.]

sections and restart

  • When doing multiple independent problems in a single worksheet, it might be helpful to "indent" each one into a section, and include "restart" at the beginning of each one to prevent assignments from interfering in different problems. You can also insert a new section from the insert menu. These are opened and closed by clicking on the arrow in the section title. Subsection allows more structure to your document.

 

Matrices or Vectors (1 row or 1 column):

  • Matrices and Vectors can be entered with the Matrix palette in 2d math input mode. A superscript of -1 will produce the inverse of a square matrix, while a space " " between matrices will multiply them, without loading the LinearAlgebra or Student[LinearAlgebra] packages. Matrices and Vectors can also be directly entered using < > to enclose a row or list of rows, commas to separate entries in a Vector or separate entries vertically in a column and " | " the vertical symbol to separate entries horizontally in a row. To "augment" a set of Vectors into a matrix, use Matrix([u1,u2]). Vectors are treated by default as column matrices and are shown as column matrices in Maple output.

    To retain this column matrix output when using the Student[VectorCalculus] package, you need an extra command:
    > with(Student[VectorCalculus]): BasisFormat(false)
    Without it a basis vector notation a1ex +a2ey +a3ez is the default for Maple output.

    Note: <<1|2|3>,<4|5|6>> and <<1,4>|<2,5>|<3,6>> are the same 2x3 matrix, first input as 2 rows, then as 3 columns. [Commas are vertical separators, "verticals" are horizontal separators.]

    The LinearAlgebra or Student[Linearalgebra] package should be loaded: > with(LinearAlgebra):
    when doing anything more than right click menu operations on matrices. Transpose then converts between row and column matrices.

  • Right-clicking on a matrix and selecting Standard Operations allows the determinant to be evaluated. Selecting Eigenvalues, etc allows one to get the eigenvalues and eigenvectors, or the preliminary characteristic polynomial. Selecting Solvers and Forms, Row Echelon Form, Reduced is also a right click away. Then right clicking on the rref matrix allows Solvers and Forms, Linear Solve to solve the linear system for which it is the rref augmented matrix.
     
  • evalf (evaluate to floating point number) can be applied to a single expression, to a Vector or Matrix of expressions, or to a list of expressions [..., ..., ...], but not to a sequence of expressions ... , ... , ... (no delimiters); evalf(...,5) will limit the evaluation to 5 significant figures, so if it matters in the internal evaluation procedures, do   evalf(...):  evalf(...,5) so that the 10 digit final number is then rounded off to 5 significant figures, for example. Alternately just right clicking on an expression allows you to approximate it to various numbers of decimal places.
     
  • [Advanced: To add a row or column to an existing matrix in input mode: Control Shift R (for Row) or Control Shift C (for Column). The former also works to add lines to the Expression palette piecewise template: another row for each extra condition.

  • Sometimes in rare cases it is not enough to place a space between matrices to multiply them (rtable error), in which case a period between the matrices will do the job.

Subscripts

  • Maple has literal subscripts "x__1" for part of a symbol name (appropriate for indexing variable names in equations or as in "x__h" for symbolic subscripts which are not positive integers) and indexed subscripts "a[1]" or "A[1,2]" to indicate an entry in an array (vector or matrix), both of which appear in 2D math mode as subscripts; the Expression palette has both icons for insertion.

    There are still no literal superscripts for tensor notation.

Prime derivative notation and Maple function notation:

  • Standard function notation holds once a Maple function arrow function is defined: f:= t → t4 , then f ''(t) is the second derivative, (4)(t) is the 4th derivative, etc. For partial derivatives the D[1,2](f) notation is preferable for Maple functions.
  • Using unapply instead of the arrow Maple function definition:
    Although in most cases the arrow definition available in the Expression palette is sufficient, one must occasionally use an alternative approach:
    > f := t→ t2; g := t → f '(t)/t; g(1)      here g(1) does not work since first t = 1 is substituted, after which the derivative does not work
    > f := t→ t2; g := unapply(f '(t)/t,t); g(1) here t = 1 is substituted at the end of the procedure and it works
    One "unapplies" the formula to the variable to create a function independent of the dummy variable used in the formula.

    Alternatively, unapply fully evaluates an expression by substituting the values of all variables at the moment it is executed, while the arrow definition leaves the variables unevaluated until the function is called. See this example:
    > p:=2:  f := x → xp; f(x); p:=3; f(x)  [change: f(x) = x3]
    > p:=2:  f := unapply(xp,x); f(x); p:=3; f(x)  [no change, f(x) =x2]
    The arrow definition is convenient if you wish to update the value of a parameter in the Maple function after its definition.unapply is convenient if you want to finalize a function at its present form for present values of all parameters etc that may be present.
     
  • The default differentiation variable x for prime notation in 2d input can be changed by the View Menu, Typesetting Rules selection, lower left Differential Options section, prime derivative variable (change from x to t, for example): the default is that y' stands for dy/dx, but when t is the independent variable (time) it is often convenient to change the default, which can be done by the command:
    > Typesetting:-Settings(prime = t):
  • For stating differential equations using prime notation, the default differentiation variable is assumed. Input a list of differential equations and initial conditions separated by commas,  and right-clicking on the output allows Solve DE to solve the system
    >  x1''=x2, x2''=x1,x1(0)=1,x1'(0)=0,x2(0)=0,x2'(0)=1
    Omitting the initial conditions gives the general solution.
  • If you want a different default differentiation variable without being bothered to change it (students especially!), simply use explicit function notation with the desired variable:
    >   x1''(t)=x2(t), x2''(t)=x1(t),x1(0)=1,x1'(0)=0,x2(0)=0,x2'(0)=1
  • Don't waste time using subscripted variables like x1 with prime notation, just call it x1 unless you like being elegant. Such subscripts should be literal: "x__1" since you are naming the variable and niot indexing it as a vector.

 

Advanced Users Only

  • Want to include text or math formulas in your plots? It is easy with Maple's plot Drawing tools. See the example file.
  • Want to include plots with sliders to change the parameters in a family of functions?
    See the example file.
  • You can display vectors or matrices with more than 10 rows by for example:
    > interface(rtablesize=50)
  • To show datapoints plotted by plot as a 2 column matrix:
    > A:=plot(x^2,x=0..1): N := nops(convert(A, listlist)); interface(rtablesize = N); A
  • You can show the code; for example, to see the code for "plot" do:
    > interface(verboseproc=2);
    > readlib(plot);
    To read code of a command in a package use something like:
    > readlib(linalg:-charpoly);
  • To update an older Classic .mws worksheet with 1d math inputs, open it in Standard Maple and save it as a Standard worksheet, then go to Format, Styles, C 2d input, Modify, Restore to Default, OK, OK. Then you can select each range of only 1d inputs (avoiding text regions) and do Format, Convert to, 2d math input. This requires some fiddling, since the autolinebreaking feature is not perfect and there are a few other possible minor glitches. Remove final semicolons from a single input or from the final input of a multiple input line execution group; they are now only needed to separate multiple inputs.
  • To put a figure and text side by side in a document block region, just insert a 2x1 Table from the Insert Menu [turn off the exterior and interior borders in Properties] and copy and paste your plot into one of the two table cells, and type your text into the other cell. In a worksheet, you must first introduce a document block with the Format Menu, Create Document Block. Center the figure with the text center icon.
  • View Menu, Palettes, Arrange Palettes lets you put the most used palettes first: Expressions, Common Symbols, Matrix, Greek, Operators (for cross product symbol), Punctuation (for underscore in 2d math input).
  • To extract contents of the various tutors [Tools Menu, Tutors] which are not inserted as the final output of the applets into the worksheet, one must select contents of internal applet windows with the mouse, and then Control C copy and then paste into the worksheet after exiting the applet.
  • You can convert a document block to a worksheet block to reveal the underlying Maple commands which generated it. Select View menu, Show Markers to show a left strip marking off the individual document blocks, the right clicking on the marker for a given block allows it to be expanded, and then collapsed.

Please share your tips by emailing robert.jantzen@villanova.edu.

 

MAT1500-1505-2500-2705 Example Files

For the Engineering and Science Calculus course sequence there are example files (perhaps most useful for instructors):

To save these files, please right-click on them and choose Save Link As.

  • MAT1500 Calculus 1 for Science and Engineering - cmdlist1.mw
  • MAT1505 Calculus 2 for Science and Engineering - cmdlist2.mw
  • MAT2500 Calculus 3 for Science and Engineering - cmdlist3.mw
  • MAT2705 Differential Equations with Linear Algebra - cmdlist4.mw

The first example worksheet has many live tips on using 2d math, palettes and right-click menus before starting the calculus examples. You are free to type literally old style 1d math (character mode) found in textbook examples right into the 2d input mode, but you can also take advantage of 2d features while doing so, mixing 1d and 2d entry. Fortunately the Maple "Clickable Calculus" approach makes it very easy to use palette entry and context sensitive right click menus to do most of what is needed in these courses without special instruction!

These files have their output removed [Edit Menu, Remove Output, All] and must be re-executed by clicking on the Execute Worksheet icon "!!!" on the toolbar. This saves a lot of server space since the executed files can be much larger, especially when 3d graphics are present. However, when executing with "!!!" instead of step by step, sometimes help pages pop up, leading to many simultaneous open windows [Window menu, first file in list is original], or pop up Java applet interactive windows appear (from Tutor commands), each of which must be closed in turn before the worksheet can proceed executing. To execute step by step, just hit the Enter key for each execution of an input group to see its output appear. Then move on to the next step.

Maple Student Help Center

For some of you, the Maple Student Help Center might prove useful. It offers on-line help: "Get real answers from real people" "within hours" for homework problems by posting your questions on the on-line Forum. Free registration at Maple Primes is required for access.

Common Mistakes

Remember to include a space between quantities that are supposed to be multiplied in input expressions, even before a parenthesis! And the letter "e" in Maple is not assigned to Euler's number, you must use the Palette entry or function notation "exp(x)" for the exponential function. See the tips page if you are serious about using Maple.

Teaching Concepts with Maple

Learn how to do specific tasks with Maple in all levels of Calculus and Differential Equations and Linear Algebra with Clickable Calculus:

Maple Teaching Site

Learn to use Maple

by watching a 3 minute video on clickable calculus.