Classroom Tips and Techniques: Gems 3135 from the Red Book of Maple Magic
Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft

Introduction


Five of the Tips & Techniques articles in 2011 were "Maple Magic" articles, each containing five "gems" gleaned from interactions with Maple and the Maplesoft programmers. The Tips & Techniques article in the December 2012 Reporter contained five more additions to the Red Book. Here are five recent revelations (at least to me) that now populate my Red Book of Maple Magic.


Gem 31


An example in the helppage worksheet shows how to combine a numeric solution for an initial value problem with parameters and the new Explore command for generating graphs with sliders to control those parameters. Earlier in the development cycle, the developer of the Explore update emailed me a simpler form of the example now in the help page, and that is what I'd like to present here as Gem 31.
Recall that at one time solving an IVP numerically required all parameters to be numeric. Then, functionality was added to keep the parameters as names within the procedures produced by the call to dsolve, but before these procedures could be invoked, values would have to be passed to the parameters. An example of this, a simple driven damped harmonic oscillator started with inert initial conditions, is given in Table 31.1 Of course, this model can be solved symbolically, but for simplicity, seek a strictly numeric solution.
•

Enter a differential equation in which and are parameters.



•

Apply the dsolve command with the appropriate syntax for a numeric solution with parameters.



•

Pass parameter values to the procedure .





Table 31.1 Numeric solution of an IVP containing parameters



Table 31.2 shows how to write a procedure that continually passes parameter values to the procedure , and how to apply the Explore command to that procedure.


•

Apply the Explore command with ranges and initial values for the parameters.



Table 31.2 The Explore command used to draw a graph with two sliders controlling parameter values



The sliders now control the values of the parameters for the given IVP that is solved numerically.


Gem 32


The content of Table 321, entered into the Red Book of Maple Magic on February 20, 2013, represents some recentlydiscovered (for me) manipulations with lists.
Some history: I first taught with Maple in 1988 (probably Release 2). In 1995 when RHIT introduced laptops into the classroom, I can recall preparing material in Release 3. In the summer of 1996 I visited Maplesoft and recall asking questions about Release 4. I continued using Release 4 to complete my Advanced Engineering Math text with Addison Wesley. I started working on the manuscript in the fall of 1997 and the text (with a 2001 copyright date) was available in November of 2000. By this time Releases 5 and 6 had appeared, and the worksheets that accompanied the text had been updated to those versions.
Prior to Release 5, the Maple notation would generate the sequence of names . In Release 5, the dot was sequestered for the noncommutative operator of linear algebra, and its role in generating sequences of names was taken by a double slash, and in . This doesn't look too bad in typeset math, but it looks terrible when typed in the text that Maple calls 1D math. I hated this new notation, and found its alternative, the use of table entries x[k] with the concomitant to be more typing than I wanted to burden my students with.
On March 19, 2013 I added the contents of Table 322 to the Red Book.
•

Assign to two "subscripted" variables.
( becomes the name of a table, and the subscripts refer to entries in this table.)



•

Use the $ character as the sequence operator, and generate a sequence of values for the "subscripted" names.



Table 322 Forming a sequence of indexed names



I guess the surprise is that it took me 15 years to see this.


Gem 33


Example 18.5.2 from my Advanced Engineering Math ebook explores the equipotentials of the electric field set up by two equal positive charges, one at the origin and one at in the Cartesian plane. The potential is
The AddisonWesley 2001 version of my AEM text was originally written with Maple V Release 4, and the worksheets that accompanied it have been updated to every version of Maple since. At Maple 10, having gone out of print, it became the ebook. Now the contour plot of the potential function (Figure 18.5.2 in the ebook) was last obtained in Maple 16 with the following code, which I advise against executing in Maple 17!
Worked fine in Maple 16, but in Maple 17 it produced the image shown in Figure 331.

Figure 33.1 Contour plot produced by Maple 17



One of my goto guys, Dr. Allan Wittkopf, provided me with the following analysis. The 70×70 grid implies a nodal spacing of = 5/23, which makes the points and nodes. But is singular at these points. Hence, very large values are computed at these points and "the values of the function are considered relative to the maximum value of the function computed on the grid."
Clearly, then, I could modify the grid slightly so the singularities are not nodes. But Allan suggested a better alternative: "You can always get a good plot at any resolution by capping the value of the function to something sane." He suggested the code that results in Figure 33.2.

Figure 33.2 Contour plot for



I have no idea why code that fails in Maple 17 should have worked in Maple 16, but the "gem" of graphing is one that I must try to remember.


Gem 34


Back on October 3, 2012, our graphics developer clarified a misconception I had long held about the sample option in the plot command. I had always believed that the list of points provided to this option had to be inclusive of all the points that would be used to generate the graph. Not so, I learned. Giving the option a list of the form and letting adaptive plotting fill in between the two endpoints would force the sample points into the plot data structure that would also contain the additional adaptive points.
As an example, consider the graph of the ellipse defined by the equation , and drawn in Figure 34.1 by the implicitplot command.

Figure 34.1 Ellipse graphed with the implicitplot command



Solving for explicitly produces the two branches
whose graph, naively drawn, appears in Figure 34.2.

Figure 34.2 Naive graph of the separate branches of an ellipse



Note the small gap between the branches. This occurs because Maple does not sample either branch of exactly at the last value for which remains real. The plot command with the option
produces the graph in Figure 34.3. Of course, the endpoints are the zeros of .

Figure 34.3 Branches of ellipse graphed with the sample option



(The actual graphing commands are hidden input for the tables in which the graphs are displayed.)


Gem 35


Corresponding elements of vectors and lists can be set equal to each other by the Equate command, which has a counterpart in the Context Menu system. There is also a keyboard equivalent to this functionality. Table 35.1 lists the possibilities.
The Equate command

•

The Equate command applied to any combination of list and vector returns a list of equations.


0

0

0

0

Context Menu

•

If at least one of the two objects is a vector, then the Context Menu will only contain the Equate option for the output form of the objects.

•

The return is a list of equations.


=

=

=

•

The Context Menu for a pair of lists provides the Equate option for input as well as output.



Keyboard

•

The help page for "tilde" brings up a list of "elementwise operators," one of which is the elementwise equal operator, =~.

•

Placing the "elementwise equal operator" between two objects, one of which is a vector, results in a vector of equations.


0

0

0

•

Placing the "elementwise equal operator" between two lists results in a list of equations.


0

Table 35.1 The Equate command, the Equate option in the Context Menu, and the elementwise equal operator



There are Maple commands that require expressions, not equations. In particular, these expressions would be the lefthand sides of an equation in which all terms were moved to the left. If any of the devices in Table 35.1 were used, additional processing would be needed to turn each equation into an expression. The alternatives are shown in Table 35.2.

Legal Notice: © Maplesoft, a division of Waterloo Maple Inc. 2013. Maplesoft and Maple are trademarks of Waterloo Maple Inc. This application may contain errors and Maplesoft is not liable for any damages resulting from the use of this material. This application is intended for noncommercial, nonprofit use only. Contact Maplesoft for permission if you wish to use this application in forprofit activities.
