Product Tips & Techniques

Tips and Tricks on how to get the most about Maple and MapleSim

Welcome to Maplesoft Orientation Week!  We know what a difference math software can make when it comes to enhancing student learning, but we also know that everyone is very busy at the beginning of the school year! So our goal for this week is to make it easier for high school and university students to select the best math tool for their needs, and help them get on track for a great math year.  The week’s activities include free training on Maple and Maple Learn, discounts on Student Maple, live events with some of your favorite math TikTok personalities, and even the chance to win an iPad Air!  Check out all the activities now, and plan your week or tell your students.

Orientation week runs Mon. Sept. 20 – Fri. Sept. 24.

Hi everyone! It's been a remarkably long time since I posted on MaplePrimes -- I should probably briefly reintroduce myself to the community here. My name is Erik Postma. I manage the mathematical software group at Maplesoft: the team that writes most of the Maple-language code in the Maple product, also known as the math library. You can find a longer introduction at this link.

One of my tasks at Maplesoft is the following. When a request for tech support comes in, our tech support team can usually answer the request by themselves. But no single person can know everything, and when specialized knowledge of Maple's mathematical library is needed, they ask my team for help. I screen such requests, answer what I can by myself, and send the even more specialized requests to the experts responsible for the appropriate part of the library.

Yesterday I received a request from a user asking how to unwrap angles occurring in an expression. This is the general idea of taking the fact that sin(phi) = 'sin'(phi + 2*Pi), and similarly for the other trig functions; and using it to modify an expression of the form sin(phi) to make it look "nicer" by adding or subtracting a multiple of 2*Pi to the angle. For a constant, real value of phi you would simply make the result be as close to 0 as possible; this is discussed in e.g. this MaplePrimes question, but the expressions that this user was interested in had arguments for the trig functions that involved variables, too.

In such cases, the easiest solution is usually to write a small piece of custom code that the user can use. You might think that we should just add all these bits and pieces to the Maple product, so that everyone can use them -- but there are several reasons why that's not usually a good idea:

  • Such code is often too specialized for general use.
  • Sometimes it is reliable enough to use if we can communicate a particular caveat to the user -- "this will not work if condition XYZ occurs" -- but if it's part of the Maple library, an unsuspecting user might try it under condition XYZ and maybe get a wrong answer.
  • This type of code code generally doesn't undergo the careful interface design, the testing process, and the documentation effort that we apply to the code that we ship as part of the product; to bring it up to the standards required for shipping it as part of Maple might increase the time spent from, say, 15 minutes, to several days.

That said, I thought this case was interesting enough to post on MaplePrimes, so that the community can take a look - maybe there is something here that can help you with your own code.

So here is the concrete question from the user. They have expressions coming from an inverse Laplace transform, such as:

with(inttrans):
F := -0.3000*(-1 + exp(-s))*s/(0.0500*s^2 + 0.1*s + 125);
f := invlaplace(F, s, t)*u(t);
# result: (.1680672269e-1*exp(1.-1.*t)*Heaviside(t-1.)*(7.141428429*sin(49.98999900*t-
#         49.98999900)-357.*cos(49.98999900*t-49.98999900))+.1680672269e-1*(-7.141428429*sin
#         (49.98999900*t)+357.*cos(49.98999900*t))*exp(-1.*t))*u(t)

I interpreted their request for unwrapping these angles as replacing the expressions of the form sin(c1 * t + c0) with versions where the constant term was unwrapped. Thinking a bit about how to be safe if unexpected expressions show up, I came up with the following solution:

unwrap_trig_functions := module()
local ModuleApply := proc(expr :: algebraic, $)
  return evalindets(expr, ':-trig', process_trig);
end proc;

local process_trig := proc(expr :: trig, $)
  local terms := convert(op(expr), ':-list', ':-`+`');
  local const, nonconst;
  const, nonconst := selectremove(type, terms, ':-complexcons');
  const := add(const);
  local result := add(nonconst) + (
    if is(const = 0) then
      0;
    else
      const := evalf(const);
      if type(const, ':-float') then
        frem(const, 2.*Pi);
      else
        frem(Re(const), 2.*Pi) + I*Im(const);
      end if;
    end if);
  return op(0, expr)(result);
end proc;
end module;

# To use this, with f defined as above:
f2 := unwrap_trig_functions(f);
# result: (.1680672269e-1*exp(1.-1.*t)*Heaviside(t-1.)*(7.141428429*sin(49.98999900*t+
#         .27548346)-357.*cos(49.98999900*t+.27548346))+.1680672269e-1*(-7.141428429*sin(
#         49.98999900*t)+357.*cos(49.98999900*t))*exp(-1.*t))*u(t)

Exercise for the reader, in case you expect to encounter very large constant terms: replace the calls to frem above with the code that Alec Mihailovs wrote in the question linked above!

Another series of updates to Maple Learn? It’s almost like we’re constantly working on Maple Learn to add more features and improve based on your feedback! Wild, right? Anyways, here’s some of the latest features we’ve added to Maple Learn.

First, we’re very excited to present our new Example Gallery. Not only does it have a shiny new design, but there are now over 400 example documents in just about every area of mathematics you can think of.  These documents are perfect for seeing how Maple Learn can be used to teach and explore concepts, and you can easily modify them to suit your own needs. We’re still working hard on improving the Example Gallery and its content, so let us know what you want to see!

We’ve also got some shiny new features in Maple Learn itself. Do you ever look at a graph and think, “Wow, this is great and all, but I sure would love if it had fewer straight lines and more circles?” I know I do. Luckily for both of us, Maple Learn now supports polar coordinates! Just click the round globe icon to see your plots transformed to the circular form you’ve always wanted them to be.

Looking to enhance the text portion of your documents, rather than the graphs? We’ve got just the thing for you—Maple Learn now supports bullet lists! Take your pick of numerical lists, alphabetical, or your traditional bullet point. If you’re looking to augment your document with a step-by-step process, a list of your favourite mathematical expressions, or you’re just feeling tired of using pen and paper for grocery lists, Maple Learn now has what you need.

Speaking of improving the layout of your documents, we now have an option for horizontal tables. The vertical tables can get a bit a long, especially for a short document, but with horizontal tables you can keep all your documents cozy and compact.

And as always, this is just a taste of what we’ve been up to. We’ve also improved a variety of features (including our new steps feature!) and fixed an assortment of bugs. And remember, we couldn’t do this without you! Please continue to let us know what you’d like to see in Maple Learn, and someday it could be your request featured in our post!

Maple Learn is a great tool for checking the answer to your math problems, but what happens when your answer is wrong and you don’t know why? Knowing there’s a mistake doesn’t actually tell you what that mistake is. Luckily for you, Maple Learn’s newest feature is here to help you out: steps! Now, with the click of a button, you can see full, step-by-step solutions to a wide variety of problems. Instead of endlessly pouring over your work to find that one misplaced negative sign, you can check the steps to quickly and easily spot where you went wrong. Plus, if you’re having trouble figuring out how to approach a problem, you can sneak a peek at the first few steps to get the ball rolling. Full solutions are an invaluable learning tool, and we’re excited to be able to share them with our users.

A screenshot of Maple Learn showing the derivative of an equation. Next to the derivative is a button labeled Steps, with a graphic of a pair of footsteps.

Getting the steps is simple. When you perform an operation using the Context Panel, you’ll see a “Steps” button appear next to the solution when steps are available. Just click this button! This will take you to a new Maple Learn document showing you a full, detailed solution. Plus, if you want to bring the steps into another document, you can then click the “Copy to Clipboard” button. Checking your solution has never been easier!

What sorts of problems do we have steps for, you might ask? Good question! The answer is a resounding “most of them”. Are you a high schooler? We’ve got steps for factoring, expansion, and solving both equations and linear systems. Doing calculus? Derivatives, integrals, limits, and even solving differential equations all have full solutions available. How about linear algebra? Absolutely! We provide steps for Gauss-Jordan elimination, matrix inversion, finding eigenvalues and eigenvectors, and calculating the determinant! And that’s just a taste of what Maple Learn can do. We’re working constantly to expand our roster of steps, so let us know what you want to see!

I hear what some of you must be thinking: “But what about when I don’t have my computer with me? I never know when I’m going to need a step-by-step solution to a math problem!” If that’s you, then check out the Maple Calculator! The Maple Calculator provides full solutions just like Maple Learn, and you can carry it around in your pocket for math-on-the-go. With Maple Learn and the Maple Calculator on your side, no math problem can stop you now.

Our grand quest to expand and improve Maple Learn is marching steadily along, and we wanted to share with you some of what we’ve been working on! We’ve added some exciting new features that we hope you’ll enjoy.

First up, we’ve added a new command: the Shaded command. This allows you to shade the area beneath a curve—perfect for helping students understand and visualize integrals. It also looks pretty cool, if I do say so myself.

A screenshot of Maple Learn featuring a cosine function with the area under the curve coloured in.

We’ve also added a few new symbols to our roster. You can now enter the not-equals sign through the Numbers and Operators menu, and we’ve added the upper-case Greek alphabet to the Greek symbols menu. Now you can write your documents entirely in Greek! (Or you can just use them as symbols.)

If you’d rather keep the Latin alphabet, but do want to shake things up a bit, we’ve got just the thing for you: you can now choose either a Serif or Sans Serif font. With that and our other text editing tools, you’ll be able to customize the design of your document to your heart’s content.

If you’re one of our users who requested support for mixed fractions, today is your lucky day! Maple Learn now fully supports mixed fractions, and you can convert between mixed and improper fractions using the Context Panel.

A screenshot of Maple Learn showing 3 and 5/7 being converted to 26/7, and 11/9 being converted to 1 and 2/9.

We also wanted to take the time to mention some of the bugs we’ve fixed based on user feedback. Thanks to you, we have now:

  • Fixed tooltips for floor and ceiling functions
  • Resolved the issue of Maple Learn slowing when using asin(x) in equations
  • Fixed typesetting bug when entering inequalities with fractions
  • Added more support for dealing with units in tables and equations

Thank you to everyone who has sent in their feedback. Your reports are what allowed us to fix these issues. If you ever have feedback for us, whether it’s a bug you’ve found or a feature you’d like to see, use the “Flag a Problem” button to let us know. Maybe it’ll be your suggestion you see here next!

A few weeks ago, some of our sales and marketing representatives decided to spice up some emails with some whimsical poetry. We sent them out to a selection of people, but we thought they were too fun not to share with everyone else! After all, what better way to talk about math products than through poetry? So without further ado, we’re proud to present our collection of mathematical verses:

I.

Math teachers and students, hear this tale of mine

Maple Learn will help you, and it’s online

 

The interface is freeform, the plots a delight

With Maple behind it, you know they are right

 

Solve problems from calculus? Easily done!

Algebra, matrices, even trig becomes fun.

 

Solve line by line, or all in one go

With Maple Learn, you work fast or work slow

 

Applications are endless, the basic version is free

Fully unlock it for just a small fee

 

Are you a teacher, from small school or great hall?

Maple Learn Premium is free when you call!

 

II.

Maple Learn is great, as I hope you recall

But when it comes to math products, that’s not all

 

Do you have a math problem right before your eyes?

Pull out your phone, is what I advise

 

A click of your camera, a solution shown to you

Solutions, graphs, and even steps too!

 

Integrals, matrices, factoring, and more

Maple Calculator solves problems galore

 

And when find you have even more to do

The problem in the picture reaches Maple Learn too!

 

Teaching these days can be quite a task

Our products can help you, you’ve only to ask

 

III.

My final approach, I’ll disturb you no more

Just one final poem for you is in store

 

On Maple Learn, there’s much more I could say

But instead, here are examples with which you can play

 

And Maple Calculator too, please don’t forget it

Give it a try, I know you won’t regret it.

 

My poems are now done, my inspiration depleted

Thanks for your patience as by my poems, you were greeted

 

We hope you had as much fun reading that as we did writing it. Stay tuned for next week, where we’ll be posting Maple Learn: The Musical! (Just kidding. Unless…?)

With most software, it can take time to learn all the ins and outs and little tricks that make using the software easier. Have you ever learned a new keyboard shortcut for a software you’ve been using for years and found it so useful that you’re kicking yourself not learning it earlier? I certainly have. We thought we’d take the time to highlight five tips and tricks for using Maple Learn, so that you can skip the kicking stage and go straight to the using the cool trick stage!

 

1. Convert math to text

Here’s the trick that I probably use the most: You can press the spacebar in an empty cell to convert it to text. Just like that! No fiddling with menus, no starting to type and then backtracking as you realize all your words are turning into variables. Just a quick space at then beginning, and then you can type as much text as you’d like. Click the text icon on the left to change it back to math if you change your mind.

An empty math cell in Maple Learn, followed by an arrow and

2. Assigning variables

Have you ever wanted to assign a value to a variable? Who hasn’t? And luckily, Maple Learn makes it easy to do just that. Just use “:=”. For example, you could say “a:=4”. The variable ‘a’ will now have a value of 4 for that group and all subsequent groups. What’s more, a slider will appear, so that you can adjust the value and see how it affects the rest of the document. You can change the range of the slider using the slider settings (that’s the gear) or disable the slider using the Quick Actions menu (that’s the lightbulb). You can also select “Parameterize …” from the Quick Actions menu when you have an expression that contains variables, and sliders will be automatically created for those variables. Another trick to variable assignments is that if you have a table, you can use the header of your table as a variable that contains all the values in that column. No extra work necessary, Maple Learn does this automatically!

A screenshot of Maple Learn showing a parameterized expression with sliders for each variable. There is also a table with a single column. In the next group, the label of that column is shown to be equal to all the values in that column.

3. Order of execution

One handy feature about Maple Learn is that once you’ve assigned values to variables, you can use those variables again for all the groups that come after it. But hold on, I hear you say. How is that order determined? The Maple Learn canvas is dynamic and doesn’t have a set order to it, so which groups are “after”? Well, I’m glad you asked! The small grey number in the top left-hand corner of the group tells you its place in the order. Maple Learn evaluates any assignments according to this order, which means that a variable assigned in group 3 can be used in any group after 3, but not in groups 1 and 2. The order is determined based on where the groups are on the page, starting with 1 in the top-right corner and moving left to right, top to bottom across the page. That means that if you want to change a group’s place to earlier in the order of execution, all you have to do is move the group higher or to the left! The numbers (and thus the order of execution) will update automatically. Handy.

A screenshot of Maple Learn with the group numbers circled in red. The variable defined in group 1 is accessible in groups 2 and 3, and the variable defined in group 2 is accessible in group 3.

4. “Reset document” vs. “Clear document”

You may have noticed two seemingly similar buttons in the toolbar: “Reset document” and “Clear document”. Here’s a little secret: they do actually do different things! Say you’re looking at a shared document, like one of the ones in our Example Gallery. You can mess around with it as much as you’d like: change values, add groups to the canvas, zoom around on the graph, whatever suits your fancy. But, if you decide that you don’t like your changes and want to go back to the original document, you can hit “Reset document” and presto! Back to the original. And “Clear document” will, of course, clear the document.

A labelled screenshot of the Reset and Clear buttons in Maple Learn.

5. Using the keyboard

Are you the type of person who would rather use three keyboard commands to perform a single action than go anywhere near a mouse? Well, you’re in luck, because Maple Learn has several keyboard commands you can use to input functions without even thinking about looking at a menu. You can use standard keyboard math notation and Maple Learn will automatically format it as you would expect: ^ for exponents, * for multiplication, / for division, and so on. What’s more, you can enter “sqrt()” to write a square root symbol, and you can type in any trig function and Maple Learn will treat it as that function! You can see a full list of keyboard shortcuts here. All these things are also available through the palette menus, so a variety of workflows are supported.

An image showing how sqrt(3x^4)/2 is displayed in math notation in Maple Learn.

So there you have it, our top five tricks for using Maple Learn. If you’re looking for a more detailed guide on how to use Maple Learn, check out the How-To pages at the bottom of our Example Gallery. And if you have any tips you’ve found useful for using Maple Learn, let us and your fellow MaplePrimes users know in the comments!

We’ve been working hard on Maple Learn since its release, and we wanted to share some of the many updates we’ve made. If there was a feature you were looking for that we didn’t have, it might be time to check again! Here’s just a taste of some of the things we’ve been working on.

Given its name, perhaps it’s not surprising that our focus with Maple Learn is to help students learn math. That’s why we’ve improved many of Maple Learn’s math capabilities, to give students the best experience we can. We’ve added support for piecewise functions and vector norms/magnitudes, and made many improvements to tables based on user feedback. Are you more of a statistician? Well, you’re in luck, because we’ve also added various statistics options to the Context Panel, which allow you to calculate mean, median, linear regression, and more. We’ve also made a handful of improvements to evaluation and assignment that we hope will make Maple Learn more intuitive for users.

Maple Learn isn’t just about math, though—it’s about making math accessible. That means communicating clearly, so luckily, we’ve added several new text editing features to help you do just that. You can now use bold, italics, underline, hyperlinks, and changeable font sizes and colours. You can even collapse the plot window and Context Panel if you need a larger workspace or if your problem doesn’t require them. Now your documents will be both easy to follow and stylish!

Speaking of stylish documents, we’ve also made various improvements to how functions can be visualized. There are a couple I’d like to point out to you: You can plot points by adding values to a table! What’s more, you can then move these points around the plot and your table will update automatically. You can also add points and other geometric plot primitives like line segments and vectors using the commands Point, Segment, and Vector. As well, if you have multiple functions plotted, you can see the intersection points by clicking the “Show special points” button. If points aren’t your style, we’ve also added support for some more types of plots, such as parametric plots. When working with differential equations, you can also plot the vector field for that equation. To learn how to use these features and more, check out the “How To” section at the bottom of our Example Gallery. We’re working on more help documentation everyday to help you use Maple Learn to its full potential.

Finally, we’ve made a handful of miscellaneous changes that should help improve your overall experience with Maple Learn. For example, users can now save a copy of their document. We’ve also translated many of our examples to different languages, and are working on translating more everyday. We hope that all these changes and updates will help you get the most out of Maple Learn. If there are features you’d like to see, don’t hesitate to let us know. We add improvements to Maple Learn regularly, so keep an eye out for future updates on Primes!

We have just released an update to Maple, Maple 2021.1.

Maple 2021.1 includes improvements to plotting, export to PDF and LaTeX, the user interface, the mathematics engine, and more. We strongly recommend that all Maple 2021 users install these updates.

This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2021.1 download page, where you can also find more details.

In particular, please note that this update includes fixes to the sometimes missing plotting toolbar, the misplaced plot annotations on export, and a workbook saving problem, all reported on MaplePrimes.

Thanks for the feedback!

 

We’re excited to announce the release of MapleSim 2021! The MapleSim 2021 family of products lets you build and explore models more easily than ever, with improved simulation performance and 3-D visualizations, new ways to share models with those who don’t use MapleSim, and a host of new and expanded component libraries. Improvements include:

  • Improved performance for large models that allows you to take advantage of the fastest simulations yet – no matter how complex your design is.
  • More realistic 3-D visualizations with the ability to define dynamic shape sizes, such as spheres and cylinders that expand or contract over the course of the simulation, so components are realistically represented throughout.
  • Expanded modeling scope for machine builders, with a new pneumatics component library and expanded hydraulics support, as well as improved visualizations in the MapleSim Ropes and Pulleys Library add-on.
  • New simulation and analysis features in MapleSim Insight, a standalone product in the MapleSim family that provides anyone in your organization with access to powerful simulation-based debugging and 3-D visualization capabilities that connect directly to common automation platforms.

See What’s New in MapleSim 2021 for more information about these and other improvements!
 

When we first launched Maple Learn in January, there were only a handful of examples in the Example Gallery. Today, due to customer requests, we have 57 examples and the number grows every week. You can check out the gallery here: https://www.maplesoft.com/products/learn/examples/

The gallery is full of both practical and fun examples showing how you can use Maple Learn to work with all kinds of math. One great example is this worksheet on Logarithmic and Archimedean spirals made by our Sales Account Manager, @Oliver K. You can learn a bit about each type of spiral and adjust the sliders to see how the different parameters change the visualization. It’s a great tool for introducing students (or anyone who likes cool graphs!) to these types of spirals and for helping them understand the math behind them.

We’ve got a whole team of people, led by Senior Architect @pchin, who are working every day to make more examples like these. If there’s something you’d like to see, leave us a comment! We’d love to hear your ideas.

If you’re feeling inspired by all these examples and want to try your hand at creating something of your own using Maple Learn, check out the “How to Use Maple Learn” section at the end of the example gallery. Here you’ll find a collection of worksheets that will take you through the basic features of Learn, including “Using Sliders”, “Difference Between Equations and Assignments”, and “What Does the Light Bulb Do?”. With all this knowledge at your fingertips, you’ll be all set to create to your heart’s content!

Yesterday, user @lcz , while responding as a third party to one of my Answers regarding GraphTheory, asked about breadth-first search. So, I decided to write a more-interesting example of it than the relatively simple example that was used in that Answer. I think that this is general enough to be worthy of a Post.

This application generates all maximal paths in a graph that begin with a given vertex. (I'm calling a path maximal if it cannot be extended and remain a path.) This code requires Maple 2019 or later and 1D input. This works for both directed and undirected graphs. Weights, if present. are ignored.

restart:

AllMaximalPaths:= proc(G::GRAPHLN, v)
description 
    "All maximal paths of G starting at v by breadth-first search"
;
option `Author: Carl Love <carl.j.love@gmail.com> 2021-Mar-17`;
uses GT= GraphTheory;
local 
    P:= [rtable([v])], R:= rtable(1..0),
    VL:= GT:-Vertices(G), V:= table(VL=~ [$1..nops(VL)]),
    Departures:= {op}~(GT:-Departures(G))
;
    while nops(P) <> 0 do
        P:= [
            for local p in P do
                local New:= Departures[V[p[-1]]] minus {seq}(p);
                if New={} then R,= [seq](p); next fi;                
                (
                    for local u in New do 
                        local p1:= rtable(p); p1,= u
                    od
                )       
            od
        ]
    od;
    {seq}(R)  
end proc
:
#large example:
GT:= GraphTheory:
K9:= GT:-CompleteGraph(9):
Pa:= CodeTools:-Usage(AllMaximalPaths(K9,1)):
memory used=212.56MiB, alloc change=32.00MiB, 
cpu time=937.00ms, real time=804.00ms, gc time=312.50ms

nops(Pa);
                             40320
#fun example:
P:= GT:-SpecialGraphs:-PetersenGraph():
Pa:= CodeTools:-Usage(AllMaximalPaths(P,1)):
memory used=0.52MiB, alloc change=0 bytes, 
cpu time=0ns, real time=3.00ms, gc time=0ns

nops(Pa);
                               72

Pa[..9]; #sample paths
    {[1, 2, 3, 4, 10, 9, 8, 5], [1, 2, 3, 7, 8, 9, 10, 6], 
      [1, 2, 9, 8, 7, 3, 4, 5], [1, 2, 9, 10, 4, 3, 7, 6], 
      [1, 5, 4, 3, 7, 8, 9, 2], [1, 5, 4, 10, 9, 8, 7, 6], 
      [1, 5, 8, 7, 3, 4, 10, 6], [1, 5, 8, 9, 10, 4, 3, 2], 
      [1, 6, 7, 3, 4, 10, 9, 2]}

Notes on the procedure:

The two dynamic data structures are

  • P: a list of vectors of vertices. Each vector contains a path which we'll attempt to extend.
  • R: a vector of lists of vertices. Each list is a maximal path to be returned.

The static data structures are

  • V: a table mapping vertices (which may be named) to their index numbers.
  • Departures: a list of sets of vertices whose kth set is the possible next vertices from vertex number k.

On each iteration of the outer loop, P is completely reconstructed because each of its entries, a path p, is either determined to be maximal or it's extended. The set New is the vertices that can be appended to the (connected to vertex p[-1]). If New is empty, then p is maximal, and it gets moved to R


The following code constructs an array plot of all the maximal paths in the Petersen graph. I can't post the array plot, but you can see it in the attached worksheet: BreadthFirst.mw

#Do an array plot of each path embedded in the graph:
n:= nops(Pa):
c:= 9: 
plots:-display(
    (PA:= rtable(
        (1..ceil(n/c), 1..c),
        (i,j)-> 
            if (local k:= (i-1)*ceil(n/c) + j) > n then 
                plot(axes= none)
            else 
                GT:-DrawGraph(
                    GT:-HighlightTrail(P, Pa[k], inplace= false), 
                    stylesheet= "legacy", title= typeset(Pa[k])
                )
            fi
    )),
    titlefont= [Times, Bold, 12]
);

#And recast that as an animation so that I can post it:
plots:-display(
    [seq](`$`~(plots:-display~(PA), 5)),
    insequence
); 

 

Wirtinger Derivatives in Maple 2021

Generally speaking, there are two contexts for differentiating complex functions with respect to complex variables. In the first context, called the classical complex analysis, the derivatives of the complex components ( abs , argument , conjugate , Im , Re , signum ) with respect to complex variables do not exist (do not satisfy the Cauchy-Riemann conditions), with the exception of when they are holomorphic functions. All computer algebra systems implement the complex components in this context, and computationally represent all of abs(z), argument(z), conjugate(z), Im(z), Re(z), signum(z) as functions of z . Then, viewed as functions of z, none of them are analytic, so differentiability becomes an issue.

 

In the second context, first introduced by Poincare (also called Wirtinger calculus), in brief z and its conjugate conjugate(z) are taken as independent variables, and all the six derivatives of the complex components become computable, also with respect to conjugate(z). Technically speaking, Wirtinger calculus permits extending complex differentiation to non-holomorphic functions provided that they are ℝ-differentiable (i.e. differentiable functions of real and imaginary parts, taking f(z) = f(x, y) as a mapping "`&Ropf;`^(2)->`&Ropf;`^()").

 

In simpler terms, this subject is relevant because, in mathematical-physics formulations using paper and pencil, we frequently use Wirtinger calculus automatically. We take z and its conjugate conjugate(z) as independent variables, with that d*conjugate(z)*(1/(d*z)) = 0, d*z*(1/(d*conjugate(z))) = 0, and we compute with the operators "(&PartialD;)/(&PartialD; z)", "(&PartialD;)/(&PartialD; (z))" as partial differential operators that behave as ordinary derivatives. With that, all of abs(z), argument(z), conjugate(z), Im(z), Re(z), signum(z), become differentiable, since they are all expressible as functions of z and conjugate(z).

 

 

Wirtinger derivatives were implemented in Maple 18 , years ago, in the context of the Physics package. There is a setting, Physics:-Setup(wirtingerderivatives), that when set to true - an that is the default value when Physics is loaded - redefines the differentiation rules turning on Wirtinger calculus. The implementation, however, was incomplete, and the subject escaped through the cracks till recently mentioned in this Mapleprimes post.

 

Long intro. This post is to present the completion of Wirtinger calculus in Maple, distributed for everybody using Maple 2021 within the Maplesoft Physics Updates v.929 or newer. Load Physics and set the imaginary unit to be represented by I

 

with(Physics); interface(imaginaryunit = I)

 

The complex components are represented by the computer algebra functions

(FunctionAdvisor(complex_components))(z)

[Im(z), Re(z), abs(z), argument(z), conjugate(z), signum(z)]

(1)

They can all be expressed in terms of z and conjugate(z)

map(proc (u) options operator, arrow; u = convert(u, conjugate) end proc, [Im(z), Re(z), abs(z), argument(z), conjugate(z), signum(z)])

[Im(z) = ((1/2)*I)*(-z+conjugate(z)), Re(z) = (1/2)*z+(1/2)*conjugate(z), abs(z) = (z*conjugate(z))^(1/2), argument(z) = -I*ln(z/(z*conjugate(z))^(1/2)), conjugate(z) = conjugate(z), signum(z) = z/(z*conjugate(z))^(1/2)]

(2)

The main differentiation rules in the context of Wirtinger derivatives, that is, taking z and conjugate(z) as independent variables, are

map(%diff = diff, [Im(z), Re(z), abs(z), argument(z), conjugate(z), signum(z)], z)

[%diff(Im(z), z) = -(1/2)*I, %diff(Re(z), z) = 1/2, %diff(abs(z), z) = (1/2)*conjugate(z)/abs(z), %diff(argument(z), z) = -((1/2)*I)/z, %diff(conjugate(z), z) = 0, %diff(signum(z), z) = (1/2)/abs(z)]

(3)

Since in this context conjugate(z) is taken as - say - a mathematically-atomic variable (the computational representation is still the function conjugate(z)) we can differentiate all the complex components also with respect to  conjugate(z)

map(%diff = diff, [Im(z), Re(z), abs(z), argument(z), conjugate(z), signum(z)], conjugate(z))

[%diff(Im(z), conjugate(z)) = (1/2)*I, %diff(Re(z), conjugate(z)) = 1/2, %diff(abs(z), conjugate(z)) = (1/2)*z/abs(z), %diff(argument(z), conjugate(z)) = ((1/2)*I)*z/abs(z)^2, %diff(conjugate(z), conjugate(z)) = 1, %diff(signum(z), conjugate(z)) = -(1/2)*z^2/abs(z)^3]

(4)

For example, consider the following algebraic expression, starting with conjugate

eq__1 := conjugate(z)+z*conjugate(z)^2

conjugate(z)+z*conjugate(z)^2

(5)

Differentiating this expression with respect to z and conjugate(z) taking them as independent variables, is new, and in this example trivial

(%diff = diff)(eq__1, z)

%diff(conjugate(z)+z*conjugate(z)^2, z) = conjugate(z)^2

(6)

(%diff = diff)(eq__1, conjugate(z))

%diff(conjugate(z)+z*conjugate(z)^2, conjugate(z)) = 1+2*z*conjugate(z)

(7)

Switch to something less trivial, replace conjugate by the real part ReNULL

eq__2 := eval(eq__1, conjugate = Re)

Re(z)+z*Re(z)^2

(8)

To verify results further below, also express eq__2 in terms of conjugate

eq__22 := simplify(convert(eq__2, conjugate), size)

(1/4)*(z^2+z*conjugate(z)+2)*(z+conjugate(z))

(9)

New: differentiate eq__2 with respect to z and  conjugate(z)

(%diff = diff)(eq__2, z)

%diff(Re(z)+z*Re(z)^2, z) = 1/2+Re(z)^2+z*Re(z)

(10)

(%diff = diff)(eq__2, conjugate(z))

%diff(Re(z)+z*Re(z)^2, conjugate(z)) = 1/2+z*Re(z)

(11)

Note these results (10) and (11) are expressed in terms of Re(z), not conjugate(z). Let's compare with the derivative of eq__22 where everything is expressed in terms of z and conjugate(z). Take for instance the derivative with respect to z

(%diff = diff)(eq__22, z)

%diff((1/4)*(z^2+z*conjugate(z)+2)*(z+conjugate(z)), z) = (1/4)*(2*z+conjugate(z))*(z+conjugate(z))+(1/4)*z^2+(1/4)*z*conjugate(z)+1/2

(12)

To verify this result is mathematically equal to (10) expressed in terms of Re(z) take the difference of the right-hand sides

rhs((%diff(Re(z)+z*Re(z)^2, z) = 1/2+Re(z)^2+z*Re(z))-(%diff((1/4)*(z^2+z*conjugate(z)+2)*(z+conjugate(z)), z) = (1/4)*(2*z+conjugate(z))*(z+conjugate(z))+(1/4)*z^2+(1/4)*z*conjugate(z)+1/2)) = 0

Re(z)^2+z*Re(z)-(1/4)*(2*z+conjugate(z))*(z+conjugate(z))-(1/4)*z^2-(1/4)*z*conjugate(z) = 0

(13)

One quick way to verify the value of expressions like this one is to replace z = a+I*b and simplify "assuming" a andNULLb are realNULL

`assuming`([eval(Re(z)^2+z*Re(z)-(1/4)*(2*z+conjugate(z))*(z+conjugate(z))-(1/4)*z^2-(1/4)*z*conjugate(z) = 0, z = a+I*b)], [a::real, b::real])

a^2+(a+I*b)*a-(1/2)*(3*a+I*b)*a-(1/4)*(a+I*b)^2-(1/4)*(a+I*b)*(a-I*b) = 0

(14)

normal(a^2+(a+I*b)*a-(1/2)*(3*a+I*b)*a-(1/4)*(a+I*b)^2-(1/4)*(a+I*b)*(a-I*b) = 0)

0 = 0

(15)

The equivalent differentiation, this time replacing in eq__1 conjugate by abs; construct also the equivalent expression in terms of z and  conjugate(z) for verifying results

eq__3 := eval(eq__1, conjugate = abs)

abs(z)+abs(z)^2*z

(16)

eq__33 := simplify(convert(eq__3, conjugate), size)

(z*conjugate(z))^(1/2)+conjugate(z)*z^2

(17)

Since these two expressions are mathematically equal, their derivatives should be too, and the derivatives of eq__33 can be verified by eye since z and  conjugate(z) are taken as independent variables

(%diff = diff)(eq__3, z)

%diff(abs(z)+abs(z)^2*z, z) = (1/2)*conjugate(z)/abs(z)+z*conjugate(z)+abs(z)^2

(18)

(%diff = diff)(eq__33, z)

%diff((z*conjugate(z))^(1/2)+conjugate(z)*z^2, z) = (1/2)*conjugate(z)/(z*conjugate(z))^(1/2)+2*z*conjugate(z)

(19)

Eq (18) is expressed in terms of abs(z) = abs(z) while (19) is in terms of conjugate(z) = conjugate(z). Comparing as done in (14)

rhs((%diff(abs(z)+abs(z)^2*z, z) = (1/2)*conjugate(z)/abs(z)+z*conjugate(z)+abs(z)^2)-(%diff((z*conjugate(z))^(1/2)+conjugate(z)*z^2, z) = (1/2)*conjugate(z)/(z*conjugate(z))^(1/2)+2*z*conjugate(z))) = 0

(1/2)*conjugate(z)/abs(z)-z*conjugate(z)+abs(z)^2-(1/2)*conjugate(z)/(z*conjugate(z))^(1/2) = 0

(20)

`assuming`([eval((1/2)*conjugate(z)/abs(z)-z*conjugate(z)+abs(z)^2-(1/2)*conjugate(z)/(z*conjugate(z))^(1/2) = 0, z = a+I*b)], [a::real, b::real])

(1/2)*(a-I*b)/(a^2+b^2)^(1/2)-(a+I*b)*(a-I*b)+a^2+b^2-(1/2)*(a-I*b)/((a+I*b)*(a-I*b))^(1/2) = 0

(21)

simplify((1/2)*(a-I*b)/(a^2+b^2)^(1/2)-(a+I*b)*(a-I*b)+a^2+b^2-(1/2)*(a-I*b)/((a+I*b)*(a-I*b))^(1/2) = 0)

0 = 0

(22)

To mention but one not so famliar case, consider the derivative of the sign of a complex number, represented in Maple by signum(z). So our testing expression is

eq__4 := eval(eq__1, conjugate = signum)

signum(z)+z*signum(z)^2

(23)

This expression can also be rewritten in terms of z and  conjugate(z) 

eq__44 := simplify(convert(eq__4, conjugate), size)

z/(z*conjugate(z))^(1/2)+z^2/conjugate(z)

(24)

This time differentiate with respect to conjugate(z),

(%diff = diff)(eq__4, conjugate(z))

%diff(signum(z)+z*signum(z)^2, conjugate(z)) = -(1/2)*z^2/abs(z)^3-z^3*signum(z)/abs(z)^3

(25)

Here again, the differentiation of eq__44, that is expressed entirely in terms of z and  conjugate(z), can be computed by eye

(%diff = diff)(eq__44, conjugate(z))

%diff(z/(z*conjugate(z))^(1/2)+z^2/conjugate(z), conjugate(z)) = -(1/2)*z^2/(z*conjugate(z))^(3/2)-z^2/conjugate(z)^2

(26)

Eq (25) is expressed in terms of abs(z) = abs(z) while (26) is in terms of conjugate(z) = conjugate(z). Comparing as done in (14),

rhs((%diff(signum(z)+z*signum(z)^2, conjugate(z)) = -(1/2)*z^2/abs(z)^3-z^3*signum(z)/abs(z)^3)-(%diff(z/(z*conjugate(z))^(1/2)+z^2/conjugate(z), conjugate(z)) = -(1/2)*z^2/(z*conjugate(z))^(3/2)-z^2/conjugate(z)^2)) = 0

-(1/2)*z^2/abs(z)^3-z^3*signum(z)/abs(z)^3+(1/2)*z^2/(z*conjugate(z))^(3/2)+z^2/conjugate(z)^2 = 0

(27)

`assuming`([eval(-(1/2)*z^2/abs(z)^3-z^3*signum(z)/abs(z)^3+(1/2)*z^2/(z*conjugate(z))^(3/2)+z^2/conjugate(z)^2 = 0, z = a+I*b)], [a::real, b::real])

-(1/2)*(a+I*b)^2/(a^2+b^2)^(3/2)-(a+I*b)^4/(a^2+b^2)^2+(1/2)*(a+I*b)^2/((a+I*b)*(a-I*b))^(3/2)+(a+I*b)^2/(a-I*b)^2 = 0

(28)

simplify(-(1/2)*(a+I*b)^2/(a^2+b^2)^(3/2)-(a+I*b)^4/(a^2+b^2)^2+(1/2)*(a+I*b)^2/((a+I*b)*(a-I*b))^(3/2)+(a+I*b)^2/(a-I*b)^2 = 0)

0 = 0

(29)

NULL


 

Download Wirtinger_Derivatives.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

 

I’ll admit it. There are times when I don't fully understand every mathematical advancement each release of Maple brings. Given the breadth of what Maple does, I guess that isn't surprising.

In development meetings, I make the pretence of keeping up by looking serious, nodding knowingly and occasionally asking to go back to the previous slide “for a minute”. I’ve been doing this since 2008 and no one’s caught on yet.

But I do understand

  • the joy on a user’s (Zoom) face when they finally solve a complex problem with a new version of Maple
  • the smiley emojis that students send us when they understand a tricky math concept with the help of an improved Maple tutor
  • and the wry smile on a developer’s face when they get to work on a project they really want to work on, and the bigger smile when that project gets positive feedback

These are all moments that give me that magic dopamine hit.

The job that Karishma and I have is to make users happy. We don’t have to be top-flight mathematicians, engineers or computer scientists to do that. We just have to know what itch to scratch.

Here’s some things I think might give you that dopamine hit when you get your hands on Maple 2021. You can also explore the new release yourself at What’s New in Maple 2021.

Worksheet mode has been my go-to interface for when I just want to get stuff done. This is mostly because worksheet mode always felt like a more structured environment for developing math when I didn’t have all the steps planned out in advance, and I found that structure helpful. I’d use Document mode when I needed to use the Context Panel for math operations and didn’t want to see the commands, or I needed to create a nice looking document without input carets. And this was fine – each mode has its own strengths and uses – but I what I really wanted was the best of both worlds in a single environment.

This year, we’ve made one change that has let me transition far more of my work into Document mode.

In Document Mode, pressing Enter in a document block (math input) now always moves the cursor to the next math input (in previous releases, the cursor may have moved to the start of the next line of text).

This means you can now quickly update parameters and see the downstream effects with just the Enter key – previously, a key benefit of worksheet mode only.

There’s another small change we’ve made - inserting new math inputs.  In previous releases of Maple, you could only insert new document blocks above the in-focus block using a menu item or a three-key shortcut.

In Maple 2021, if you move the insertion point to the left of a document block (Home position), the cursor is now bold, as illustrated here:

Now, if you press Enter, the in-focus prompt is moved down and a new empty math input is created.

Once you get used to this change, Ctrl+Shift+K seems like a distance memory!

@Scot Gould logged a request that Maple numerically solve a group of differential equations collected together in a vector. And now you can!

Before Maple 2021, this expression was unchanged after evaluation. Now, it is satisfyingly simpler.

We’ve dramatically increased the scope of the signal processing package.             

My favorite addition is the MUSIC function. With some careful tuning, you can generate a pseudo power spectrum at frequencies smaller than one sample.

First generate a noisy data set with three frequencies (two frequencies are closer than one DFT bin).

with(SignalProcessing): 
num_points:= 2^8: 
sample_rate := 100.0:
T := Vector( num_points, k -> 2 * Pi * (k-1) / sample_rate, 'datatype' = 'float[8]' ): 
noisy_signal:=Vector( num_points, k -> 5 * sin( 10.25 * T[k] ) + 3 * sin( 10.40 * T[k] ) - 7 * sin( 20.35 * T[k] )) + LinearAlgebra:-RandomVector(num_points, generator=-10..10):
dataplot(noisy_signal, size = [ 800, 400 ], style = line)

 

Now generate a standard periodogram

Periodogram( noisy_signal, samplerate = sample_rate, size = [800, 400] )

This approach can’t discriminate between the two closely spaced frequencies.

And now the MUSIC pseudo spectrum

MUSIC( noisy_signal, samplerate = sample_rate, dimension = 6, output = plot );

The Maple Quantum Chemistry Toolbox from RDMChem, a separate add-on product to Maple, is a powerful environment for the computation and visualization of the electronic structure of molecules. I don’t pretend to understand most of what it does (more knowing nods are required). But I did get a kick out of its new molecular dictionary. Did you know that caffeine binds to adenosine receptors in the central nervous system (CNS), which inhibits adenosine binding? Want to know more about the antiviral drug remdesivir? Apparently it looks like this:

We put a lot of work into resources for students and educators in this release, including incorporating study guides for Calculus, Precalculus, and Multivariate Calculus, a new student package for ODEs, and the ability to obtain step-by-step solutions to even more problems.  But my favourite thing out of all this work is the new SolvePractice command in the Grading Tools package.  Because it lets you build an application that does this:

I like this for three main reasons:

  1. It lets students practise solving equations in a way that actually helps them figure out what they’ve done wrong, saving them from a spiral of frustration and despair
  2. The same application can be shared via Maple Learn for students to use in that environment if they don’t have Maple
  3. The work we did to create that “new math entry box” can also be used to create other Maple applications with unknown numbers of inputs (see DocumentTools). I’m definitely planning on using this feature in my own applications.

Okay, yes, we know. Up until recently, our LaTeX export has been sadly lacking. It definitely got better last year, but we knew it still wasn’t good enough. This year, it’s good. It’s easy. It works.  And it’s not just me saying this. The feedback we got during the beta period on this feature was overwhelmingly positive.

That’s just the tip of the Maple 2021 iceberg of course. You can find out more at What’s New in Maple 2021.  Enjoy!

 

 

Download FeynmanIntegrals.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

First 7 8 9 10 11 12 13 Last Page 9 of 65