Classroom Tips and Techniques: Yet More Gems from the Little Red Book of Maple Magic
Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft
Introduction
Each of the previous two articles contained five "gems" from my Little Red Book of Maple Magic, a red ring-binder in which I record those wonderful bits of Maple functionality that I glean from interacting with the Maple programmers in the building. This month, I'm sharing yet another five gems.
Gem 11 - Picard Iterates
A basic existence and uniqueness theorem for the initial value problem , is based on the convergence of the Picard iterates . For example, the initial value problem
whose solution is
has Picard iterates given by the task template in Table 1.
Tools_Tasks_Browse
Differential Equations_ODEs_Picard Iterates
Picard Iterates for the IVP
The function
Set
Number of iterates
Picard Iterates
Table 1 Picard iterates for
The limit of these iterates is not easy to deduce. However, the guessgf function in the gfun package provides the following resolution, which is the essence of this gem.
Experiment shows that is the first iterate for which guessgf can determine the exact solution.
Gem 12 - Combining Radicals
The task template in Table 2 implements the command interface(imaginaryunit=i); that sets in place of the default . Clicking the OK button collapses the display.
Algebra_Complex Arithmetic_Set Imaginary Unit
Notation for Imaginary Unit
Table 2 Task template for setting the imaginary unit
For real , is an identity. One way to verify this algebraically in Maple is
=
because evalc treats all names as real, even though throughout the rest of Maple names are assumed to be complex. However, it is not obvious that this equation is an identity over a certain portion of the complex plane. Figures 1 and 2 demonstrate one method of determining this region. Figure 1 is a graph of the real part of the difference between
and
while Figure 2 is a graph of the imaginary part of the difference.
Figure 1 Real part
Figure 2 Imaginary part
Aligning Figures 1 and 2 show that the real and imaginary parts of the difference between the left and right sides of the equation are zero over the "T-shaped" region that is the union of the right-half plane (open along the imaginary axis), the semi-infinite strip , the line and the line .
The gem is the use of graphs of the real and imaginary parts of a complex expression to determine its behavior over the complex plane. In this instance, because the validity of an equality is being tested, a single graph of magnitude of the difference would lead to the same conclusion.
Gem 13 - A Factoring Trick
By hand, it is trivial to factor as . Simply factor the first three terms, ignoring the additive . In fact, my first attempts at this amounted to subtracting the , factoring, then adding back the . However, my colleagues provided the gem
The collect command admits as an argument, a function that is to be applied to the coefficients after collection takes place. Using collect to apply factor to the first three terms is, indeed, a gem.
Gem 14 - A Sum-to-Product Trig Identity
For a basic trig identity such as
Maple converts the left side to the right via
and the right side to the left via
However, for the identity
Maple converts the right side to the left via
but struggles to convert the left side to the right. Table 3 summarizes calculations suggested for the conversion of the sum to the product.
Table 3 Conversion of a trig sum to a product
Alternatives I hope my readers explore include applyrule and simplify (with side relations). I'll be sure to include (with attribution and admiration), the best of these in my Little Red Book.
Gem 15 - Sort Strategies
Over the years, I've dabbled with the sort command, using it to sort lists or real numbers, polynomials, and lists containing both real and complex numbers. Here's a summary of what I've learned about sort.
By default, sort can sort real numbers that are of type numeric. A number such as is not of type numeric! (The following command verifies this assertion.)
Hence, sort will not work on a list containing such exact expressions. Table 4 shows two lists, one with, and one without numbers that are all of type numeric. The sort command works naively on the first, but requires an auxiliary function for the second. For the second list, the second argument to sort must be a function that returns true if a comparison between two elements is ordered "correctly" and false if not.
Table 4 Sorting lists of real numbers
Sorting a list containing both real and complex numbers presents more of a challenge. Of course, the complex field is not ordered, but if, say, the zeros of an equation are both real and complex and a unique ordering of these zeros is needed for the continuing computations, then some method of sorting the list of zeros has to be devised. Suppose the zeros are to be sorted in ascending order of the real parts, and if there are zeros with the same real part but different imaginary parts, sort these in ascending order of the imaginary part. This would give a unique order of such a list of zeros.
The procedure defined below is a function that implements the appropriate comparisons.
If we use this function to sort the list
we get
Sorting the powers in a polynomial is actually easier than sorting "numbers", as we see in the following example.
Sorting a list of reciprocal powers of , such as
yields to a sort on degree (here, negative integers), as we see from
Legal Notice: © Maplesoft, a division of Waterloo Maple Inc. 2011. 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 non-commercial, non-profit use only. Contact Maplesoft for permission if you wish to use this application in for-profit activities.