MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • At PCC Cleaning Services, we offer professional eco-friendly post-construction and residential cleaning in Vancouver and the Lower Mainland, including West and North Vancouver, Kitsilano, False Creek, Downtown Vancouver, Burnaby, Coquitlam, and Port Coquitlam. We understand how important it is to find reliable and efficient cleaners that you can trust. We’ve been servicing our customers for over 5 years, and we pride ourselves in offering a sparkling standard of care with every clean.
     

    A way of cutting holes on an implicit plot. This is from the field of numerical parameterization of surfaces. On the example of the surface  x3 = 0.01*exp (x1) / (0.01 + x1^4 + x2^4 + x3^4)  consider the approach to producing holes. The surface is locally parameterized in some suitable way and the place for the hole and its size are selected. In the first example, the parametrization is performed on the basis of the section of the initial surface by perpendicular planes. In the second example, "round"  parametrization. It is made on the basis of the cylinder and the planes passing through its axis. Holes can be of any size and any shape. In the figures, the cut out surface sections are colored green and are located above their own holes at an equidistant to the original surface.
    HOLE_1.mwHOLE_2.mw

    Hi, 

    The present work is aimed to show how bayesian inference methods can be used to infer (= to assess) the probabilility that a person detected infected by the SARS-Cov2  has to die (remark I did not write "has to die if it" because one never be sure of the reason of the death).
    A lot of details are avaliable in the attached pdf file (I tried to be pedagogic enough so that the people not familiar with bayesian inference can get a global understanding of the subject, many links are provided for quick access to the different notions).

    In particular, I explain why simple mathematics cannot provide a reliable estimate of this probability of death (sometimes referred to as the "death rate") as long as the epidemic continues to spread.

    Even if the approach presented here is rather original, this is not the purpose of this post. 
    Since a long time I had in mind to post here an application concerning bayesian methods. The CoVid19 outbreak has only provided me with the most high-profile topic to do so.
    I will say no more about the inference procedure itself (all the material is given in the attached pdf file) and I will only concentrate on the MAPLE implementation of the solution algorithm.

    Bayesian Inference uses generally simple algorithms such as MCMC (Markov Chain Monte Carlo) or ABC (Approximate Bayesian Computation) to mention a few, and their corresponding pseudo code writes generally upon a few tens of lines.
    This is something I already done with other languages but I found the task comparatively more difficult with Maple. Probably I was to obsess not to code in Maple as you code in Matlab or R for instance.
    At the very end the code I wrote is rather slow, this because of the allocated memory size it uses.
    In a question I posed weeks ago (How can I prevent the creation of random variables...) Preben gave a solution to limit the burst of the memory: the trick works well but I'm still stuked with memory size problems (Acer also poposed a solution but I wasn't capable to make it works... maybe I was too lazzy to modify deeply my code).

    Anyway, the code is there, in case anyone would like to take up the challenge to make it more efficient (in which case I'll take it).

    Note 1: this code contains a small "Maplet" to help you choose any country in the data file on which you would like to run the inference.
    Note 2: Be careful: doing statistics, even bayesian statistics, needs enough data: some countries have history records ranging over a few days , or no recorded death at all; infering something from so loos date will probably be disappointing

    The attached files:

    • The pdf file is the "companion document" where all or most of it is explained.It has been written a few days ago for another purpose and the results it presents were not ontained from the lattest data (march 21, 2020 coronavirus)
    • xls files are data files, they were loaded yesterday (march 28, 2020) from here coronavirus
    • the mw file... well, I guess you know what it is.
       

    Bayesian_inference.pdf

    total-cases-covid-19_NF.xls

    total-deaths-covid-19_NF.xls

    Bayesian_Inference_ABC+MCMC_NF_2.mw


     

     

    In maple plot, very many symbols like, diamond, star, solidcircle are available. Many of them may have been used also for teaching purposes.

    Recently, someone encountered the need to draw graphs with arrowheads and many solutions may be available as well. But it requires a thorough understanding of maple's features which are infinitely many. My feeling was that an arrow symbol also could be added in the symbol feature so that the option can be used as a plot point in the graph at the graph end points very easily. It can be just like adding a solidbox symbol at any point on the curve.

    Hope my suggestions are in order.

    Thanks.

    Ramakrishnan V

    The following puzzle prompted me to write this post: "A figure is drawn on checkered paper that needs to be cut into 2 equal parts (the cuts must pass along the sides of the squares.)" (parts are called equal if, after cutting, they can be superimposed on one another, that is, if one of them can be moved, rotated and (if need to) flip so that they completely coincide) (see the first picture below). 
    I could not solve it manually and wrote a procedure called  CutTwoParts  that does this automatically (of course, this procedure applies to other similar puzzles). This procedure uses my procedure  AreIsometric  published earlier  https://www.mapleprimes.com/posts/200157-Testing-Of-Two-Plane-Sets-For-Isometry  (for convenience, I have included its text here). In the procedure  CutTwoParts  the figure is specified by the coordinates of the centers of the squares of which it consists).

    I advise everyone to first try to solve this puzzle manually in order to feel its non-triviality, and only then load the worksheet with the procedure for automatic solution.


    For some reason, the worksheet did not load and I was only able to insert the link.

    Cuttings.mw



     

    With this application our students of science and engineering in the areas of physics will check the first condition of balance using Maple technology. Only with entering mass and angles we obtain graphs and data for a better interpretation.

    First_equilibrium_condition.zip

    Lenin AC

    Ambassador of Maple

    Until now I have been reading Maple Help files on the MAPLE website.  For convenience and mark-up, I have often dowloaded the help files and printed them on paper, only to find that the text over-runs the margins, and is therefore annoyingly incomplete.  On reflection, this is not surprising as the content is formatted for internet/web display!

    TIP:  Instead, go to the bottom of the MAPLE help webpage of interest, click on the "Download Help Document" link and so download the Maple file:  e.g. pdsolve-numeric.mw.  The helpfile can then be read (& executed) using MAPLE.

    Melvin

    So here's something silly but cool you can do with Maple while you're "working" from home.

    • Record a few seconds of your voice on a microphone that's close to your mouth (probably using a headset). This is your dry audio.
    • On your phone, record a single clap of your hands in an enclosed space, like your shower cubicle or a closet. Trim this audio to the clap, and the reverb created by your enclosed space. This is your impulse response.
    • Send both sound files to whatever computer you have Maple on.
    • Using AudioTools:-Convolution, convolve the dry audio with the impulse response . This your wet audio and should sound a little bit like your voice was recorded in your enclosed space.

    Here's some code. I've also attached my dry audio, an impulse response recorded in my shower (yes, I stood inside my shower, closed the door, and recorded a single clap of my hands on my phone), and the resulting wet audio.

    with( AudioTools ):
    dry_audio := Read( "MaryHadALittleLamb_sc.wav" ):
    impulse_response := Read( "clap_sc.wav" ):
    wet_audio := Normalize( Convolution( dry_audio, impulse_response ) ):
    Write("wet_audio.wav", wet_audio );
    

    A full Maple worksheet is here.

    AudioSamplesForReverb.zip

    Hi,

    Two weeks ago, I started loading data on the CoVid19 outbreak in order to understand, out of any official communication from any country, what is really going on.

    From february 29 to march 9 these data come from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and from 10 march until now from https://www.worldometers.info/coronavirus/#repro.In all cases the loading is done manually (copy-paste onto a LibreOffice spreadsheet plus correction and save into a xls file) for I wasn't capable to find csv data (csv data do exist here https://github.com/CSSEGISandData/COVID-19, by they end febreuary 15th).
    So I copied-pasted the results from the two sources above into a LibreOffice spreadsheet, adjusted the names of some countries for they appeared differently (for instance "United States" instead of "USA"), removed the unnessary commas and saved the result in a xls file.

    I also used data from https://www.worldometers.info/world-population/population-by-country/ to get the populations of more than 260 countries around the world and, finally, csv data from https://ourworldindata.org/coronavirus#covid-19-tests to get synthetic histories of confirmed and death cases (I have discovered this site only yesterday evening and I think it could replace all the data I initially loaded).

    The two worksheet here are aimed to exploratory and visualization only.
    An other one is in progress whose goal is to infer the true death rate (also known as CFR, Case Fatality Rate).

    No analysis is presented, if for no other reason than that the available data (except the numbers of deaths) are extremely dependent on the testing policies in place. But some features can be drawn from the data used here.
    For instance, if you select country = "China" in file Covid19_Evolution_bis.mw, you will observe very well known behaviour which is that the "Apparent Death Rate", I defined as the ratio of the cumulated number of death at time t by the cumulatibe number of confirmed cases at the same time, is always an underestimation of the death rate one can only known once the outbreak has ended. With this in mind, changing the country in this worksheet from China to Italy seems to lead to frightening  scary interpolations... But here again, without knowing the test policy no solid conclusion can be drawn: maybe Italy tests mainly elder people with accute symptoms, thus the huge "Apparent Death Rate" Italy seems to have?


    The work has been done with Maple 2015 and some graphics can be improved if a newer version is used (for instance, as Maple 2015 doesn't allow to change the direction of tickmarks, I overcome this limitation by assigning the date to the vertical axis on some plots).
    The second Explore plot could probably be improved by using newer versions or Maplets or Embeded components.

    Explore data from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and https://www.worldometers.info/coronavirus/#repro
    Files to use
    Covid19_Evolution.mw
    Covid19_Data.m.zip
    Population.xls

    Explore data from  https://ourworldindata.org/coronavirus#covid-19-tests
    Files to use
    Covid19_Evolution_bis.mw
    daily-deaths-covid-19-who.xls
    total-cases-covid-19-who.xls
    Population.xls


    I would be interested by any open collaboration with people interested by this post (it's not in my intention to write papers on the subject, my only motivation is scientific curiosity).

     

    An expression sequence is the underlying data structure for lists, sets, and function call arguments in Maple. Conceptually, a list is just a sequence enclosed in "[" and "]", a set is a sequence (with no duplicate elements) enclosed in "{" and "}", and a function call is a sequence enclosed in "(" and ")". A sequence can also be used as a data structure itself:

    > Q := x, 42, "string", 42;
                               Q := x, 42, "string", 42
    
    > L := [ Q ];
                              L := [x, 42, "string", 42]
    
    > S := { Q };
                                S := {42, "string", x}
    
    > F := f( Q );
                              F := f(x, 42, "string", 42)
    

    A sequence, like most data structures in Maple, is immutable. Once created, it cannot be changed. This means the same sequence can be shared by multiple data structures. In the example above, the list assigned to and the function call assigned to both share the same instance of the sequence assigned to . The set assigned to refers to a different sequence, one with the duplicate 42 removed, and sorted into a canonical order.

    Appending an element to a sequence creates a new sequence. The original remains unaltered, and still referenced by the list and function call:

    > Q := Q, a+b;
                            Q := x, 42, "string", 42, a + b
    
    > L;
                                 [x, 42, "string", 42]
    
    > S;
                                   {42, "string", x}
    
    > F;
                                f(x, 42, "string", 42)
    

    Because appending to a sequence creates a new sequence, building a long sequence by appending one element at a time is very inefficient in both time and space. Building a sequence of length this way creates sequences of lengths 1, 2, ..., -1, . The extra space used will eventually be reclaimed by Maple's garbage collector, but this takes time.

    This leads to the subject of this article, which is how to create long sequences efficiently. For the remainder of this article, the sequence we will use is the Fibonacci numbers, which are defined as follows:

    • Fib(0) = 0
    • Fib(1) = 1
    • Fib() = Fib(-1) + Fib(-2) for all > 1

    In a computer algebra system like Maple, the simplest way to generate individual members of this sequence is with a recursive function. This is also very efficient if option is used (and very inefficient if it is not; computing Fib() requires 2 Fib() - 1 calls, and Fib() grows exponentially):

    > Fib := proc(N)
    >     option remember;
    >     if N = 0 then
    >         0
    >     elif N = 1 then
    >         1
    >     else
    >         Fib(N-1) + Fib(N-2)
    >     end if
    > end proc:
    > Fib(1);
                                           1
    
    > Fib(2);
                                           1
    
    > Fib(5);
                                           5
    
    > Fib(10);
                                          55
    
    > Fib(20);
                                         6765
    
    > Fib(50);
                                      12586269025
    
    > Fib(100);
                                 354224848179261915075
    
    > Fib(200);
                      280571172992510140037611932413038677189525
    

    Let's start with the most straightforward, and most inefficient way to generate a sequence of the first 100 Fibonacci numbers, starting with an empty sequence and using a for-loop to append one member at a time. Part of the output has been elided below in the interests of saving space:

    > Q := ();
                                         Q :=
    
    > for i from 0 to 99 do
    >     Q := Q, Fib(i)
    > end do:
    > Q;
    0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584,
    
        4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811,
    
        ...
    
        51680708854858323072, 83621143489848422977, 135301852344706746049,
    
        218922995834555169026
    

    As mentioned previously, this actually produces 100 sequences of lengths 1 to 100, of which 99 will (eventually) be recovered by the garbage collector. This method is O(2) (Big O Notation) in time and space, meaning that producing a sequence of 200 values this way will take 4 times the time and memory as a sequence of 100 values.

    The traditional Maple wisdom is to use the seq function instead, which produces only the requested sequence, and no intermediate ones:

    > Q := seq(Fib(i),i=0..99);
    Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
    
        2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
    
        ...
    
        51680708854858323072, 83621143489848422977, 135301852344706746049,
    
        218922995834555169026
    

    This is O() in time and space; generating a sequence of 200 elements takes twice the time and memory required for a sequence of 100 elements.

    As of Maple 2019, it is also possible to achieve O() performance by constructing a sequence directly using a for-expression, without the cost of constructing the intermediate sequences that a for-statement would incur:

    > Q := (for i from 0 to 99 do Fib(i) end do);
    Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
    
        2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
    
        ...
    
        51680708854858323072, 83621143489848422977, 135301852344706746049,
    
        218922995834555169026
    

    This method is especially useful when you wish to add a condition to the elements selected for the sequence, since the full capabilities of Maple loops can be used (see The Two Kinds of Loops in Maple). The following two examples produce a sequence containing only the odd members of the first 100 Fibonacci numbers, and the first 100 odd Fibonacci numbers respectively:

    > Q := (for i from 0 to 99 do
    >           f := Fib(i);
    >           if f :: odd then
    >               f
    >           else
    >               NULL
    >           end if
    >       end do);
    Q := 1, 1, 3, 5, 13, 21, 55, 89, 233, 377, 987, 1597, 4181, 6765, 17711, 28657,
    
        75025, 121393, 317811, 514229, 1346269, 2178309, 5702887, 9227465,
    
        ...
    
        19740274219868223167, 31940434634990099905, 83621143489848422977,
    
        135301852344706746049
    
    > count := 0:
    > Q := (for i from 0 while count < 100 do
    >           f := Fib(i);
    >           if f :: odd then
    >               count += 1;
    >               f
    >           else
    >               NULL
    >           end if
    >       end do);
    Q := 1, 1, 3, 5, 13, 21, 55, 89, 233, 377, 987, 1597, 4181, 6765, 17711, 28657,
    
        75025, 121393, 317811, 514229, 1346269, 2178309, 5702887, 9227465,
    
        ...
    
        898923707008479989274290850145, 1454489111232772683678306641953,
    
        3807901929474025356630904134051, 6161314747715278029583501626149
    
    > i;
                                          150
    

    A for-loop used as an expression generates a sequence, producing one member for each iteration of the loop. The value of that member is the last expression computed during the iteration. If the last expression in an iteration is NULL, no value is produced for that iteration.

    Examining after the second loop completes, we can see that 149 Fibonacci numbers were generated to find the first 100 odd ones. (The loop control variable is incremented before the while condition is checked, hence is one more than the number of completed iterations.)

    Until now, we've been using calls to the Fib function to generate the individual Fibonacci numbers. These numbers can of course also be generated by a simple loop which, together with assignment of its initial conditions, can be written as a single sequence:

    > Q := ((f0 := 0),
    >       (f1 := 1),
    >       (for i from 2 to 99 do
    >            f0, f1 := f1, f0 + f1;
    >            f1
    >        end do));
    Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
    
        2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
    
        ...
    
        51680708854858323072, 83621143489848422977, 135301852344706746049,
    
        218922995834555169026
    

    A Maple Array is a mutable data structure. Changing an element of an Array modifies the Array in-place; no new copy is generated:

    > A := Array([a,b,c]);
                                    A := [a, b, c]
    
    > A[2] := d;
                                       A[2] := d
    
    > A;
                                       [a, d, c]
    

    It is also possible to append elements to an array, either by using programmer indexing, or the recently introduced ,= operator:

    > A(numelems(A)+1) := e; # () instead of [] denotes "programmer indexing"
                                   A := [a, d, c, e]
    
    > A;
                                     [a, d, c, e]
    

    Like appending to a sequence, this sometimes causes the existing data to be discarded and new data to be allocated, but this is done in chunks proportional to the current size of the Array, resulting in time and memory usage that is still O(). This can be used to advantage to generate sequences efficiently:

    > A := Array(0..1,[0,1]);
                                  [ 0..1 1-D Array       ]
                             A := [ Data Type: anything  ]
                                  [ Storage: rectangular ]
                                  [ Order: Fortran_order ]
    
    > for i from 2 to 99 do
    >     A ,= A[i-1] + A[i-2]
    > end do:
    > A;
                               [ 0..99 1-D Array      ]
                               [ Data Type: anything  ]
                               [ Storage: rectangular ]
                               [ Order: Fortran_order ]
    
    > Q := seq(A);
    Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
    
        2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
    
        ...
    
        51680708854858323072, 83621143489848422977, 135301852344706746049,
    
        218922995834555169026
    

    Although unrelated specifically to the goal of producing sequences, the same techniques can be used to construct Maple strings efficiently:

    > A := Array("0");
                                       A := [48]
    
    > for i from 1 to 99 do
    >    A ,= " ", String(Fib(i))
    > end do:
    > A;
                               [ 1..1150 1-D Array     ]
                               [ Data Type: integer[1] ]
                               [ Storage: rectangular  ]
                               [ Order: Fortran_order  ]
    
    > A[1..10];
                       [48, 32, 49, 32, 49, 32, 50, 32, 51, 32]
    
    > S := String(A);
    S := "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 \
        10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 134626\
        9 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 1\
        02334155 165580141 267914296 433494437 701408733 1134903170 1836311903 \
        2971215073 4807526976 7778742049 12586269025 20365011074 32951280099 53\
        316291173 86267571272 139583862445 225851433717 365435296162 5912867298\
        79 956722026041 1548008755920 2504730781961 4052739537881 6557470319842\
         10610209857723 17167680177565 27777890035288 44945570212853 7272346024\
        8141 117669030460994 190392490709135 308061521170129 498454011879264 80\
        6515533049393 1304969544928657 2111485077978050 3416454622906707 552793\
        9700884757 8944394323791464 14472334024676221 23416728348467685 3788906\
        2373143906 61305790721611591 99194853094755497 160500643816367088 25969\
        5496911122585 420196140727489673 679891637638612258 1100087778366101931\
         1779979416004714189 2880067194370816120 4660046610375530309 7540113804\
        746346429 12200160415121876738 19740274219868223167 3194043463499009990\
        5 51680708854858323072 83621143489848422977 135301852344706746049 21892\
        2995834555169026"
    

    A call to the Array constructor with a string as an argument produces an array of bytes (Maple data type integer[1]). The ,= operator can then be used to append additional characters or strings, with O() efficiency. Finally, the Array can be converted back into a Maple string.

    Constructing sequences in Maple is a common operation when writing Maple programs. Maple gives you many ways to do this, and it's worthwhile taking the time to choose a method that is efficient, and suitable to the task at hand.

    Maple 2020 offers many improvements motivated and driven by our users.

    Every single update in a new release has a story behind it. It might be a new function that a customer wants, a response to some feedback about usability, or an itch that a developer needs to scratch.

    I’ll end this post with a story about acoustic guitars and how they drove improvements in signal and audio processing. But first, here are some of my personal favorites from Maple 2020.

    Graph theory is a big focus of Maple 2020. The new features include more control over visualization, additional special graphs, new analysis functions, and even an interactive layout tool.

    I’m particularly enamoured by these:

    • We’ve introduced new centrality measures - these help you determine the most influential vertices, based on their connections to other vertices
    • You now have more control over the styling of graphs – for example, you can vary the size or color of a nodebased on its centrality

    I’ve used these two new features to identify the most influential MaplePrimes users. Get the worksheet here.

    @Carl Love – looks like you’re the biggest mover and shaker on MaplePrimes (well, according to the eigenvector centrality of the MaplePrimes interaction graph).

    We’ve also started using graph theory elsewhere in Maple. For example, you can generate static call graph to visualize dependencies between procedures calls in a procedure

    You now get smoother edges for 3d surfaces with non-numeric values. Just look at the difference between Maple 2019 and 2020 for this plot.

    Printing and PDF export has gotten a whole lot better.  We’ve put a lot of work into the proper handling of plots, tables, and interactive components, so the results look better than before.

    For example, plots now maintain their aspect ratio when printed. So your carefully constructed psychrometric chart will not be squashed and stretched when exported to a PDF.

    We’ve overhauled the start page to give it a cleaner, less cluttered look – this is much more digestible for new users (experienced users might find the new look attractive as well!). There’s a link to the Maple Portal, and an updated Maple Fundamentals guide that helps new users learn the product.

    We’ve also linked to a guide that helps you choose between Document and Worksheet, and a link to a new movie.

    New messages also guide new users away from some very common mistakes. For example, students often type “e” when referring to the exponential constant – a warning now appears if that is detected

    We’re always tweaking existing functions to make them faster. For example, you can now compute the natural logarithm of large integers much more quickly and with less memory.

    This calculation is about 50 times faster in Maple 2020 than in prior versions:

    Many of our educators have asked for this – the linear algebra tutorials now return step by step solutions to the main document, so you have a record of what you did after the tutor is closed.

    Continuing with this theme, the Student:-LinearAlgebra context menu features several new linear algebra visualizations to the Student:-LinearAlgebra Context Menu. This, for example, is an eigenvector plot.

    Maple can now numerically evaluate various integral transforms.

    The numerical inversion of integral transforms has application in many branches of science and engineering.

    Maple is the world’s best tool for the symbolic solution of ODEs and PDEs, and in each release we push the boundary back further.

    For example, Maple 2020 has improved tools for find hypergeometric solutions for linear PDEs.

    This might seem like a minor improvement that’s barely worth mentions, but it’s one I now use all the time! You can now reorder worksheet tabs just by clicking and dragging.

    The Hough transform lets you detect straight lines and line segments in images.

    Hough transforms are widely used in automatic lane detection systems for autonomous driving. You can even detect the straight lines on a Sudoku grid!

    The Physics package is always a pleasure to write about because it's something we do far better than the competition.

    The new explore option in TensorArray combines two themes in Maple - Physics and interactive components. It's an intuitive solution to the real problem of viewing the contents of higher dimensional tensorial expressions.

    There are many more updates to Physics in Maple 2020, including a completely rewritten FeynmanDiagrams command.

    The Quantum Chemistry Toolbox has been updated with more analysis tools and curriculum material.

    There’s more teaching content for general chemistry.

    Among the many new analysis functions, you can now visualize transition orbitals.

    I promised you a story about acoustic guitars and Maple 2020, didn’t I?

    I often start a perfectly innocuous conversation about Maple that descends into several weeks of intense, feverish work.

    The work is partly for me, but mostly for my colleagues. They don’t like me for that.

    That conversation usually happens on a Friday afternoon, when we’re least prepared for it. On the plus side, this often means a user has planted a germ of an idea for a new feature or improvement, and we just have to will it into existence.

    One Friday afternoon last year, I was speaking to a user about acoustic guitars. He wanted to synthetically generate guitar chords with reverb, and export the sound to a 32-bit Wave file. All of this, in Maple.

    This started a chain of events that that involved least-square filters, frequency response curves, convolution, Karplus-Strong string synthesis and more. We’ll package up the results of this work, and hand it over to you – our users – over the next one or two releases.

    Let me tell you what made it into Maple 2020.

    Start by listening to this:

    It’s a guitar chord played twice, the second time with reverb, both generated with Maple.

    The reverb was simulated with convolving the artificially generated guitar chord with an impulse response. I had a choice of convolution functions in the SignalProcessing and AudioTools packages.

    Both gave the same results, but we found that SignalProcessing:-Convolution was much faster than its AudioTools counterpart.

    There’s no reason for the speed difference, so R&D modified AudioTools:-Convolution to leverage SignalProcessing:-Convolution for the instances for which their options are compatible. In this application, AudioTools:-Convolution is 25 times faster in Maple 2020 than Maple 2019!

    We also discovered that the underlying library we use for the SignalProcessing package (the Intel IPP) gives two options for convolution that we were previously not using; a method which use an explicit formula and a “fast” method that uses FFTs. We modified SignalProcessing:-Convolution to accept both options (previously, we used just one of the methods),

    That’s the story behind two new features in Maple 2020. Look at the entirety of what’s new in this release – there’s a tale for each new feature. I’d love to tell you more, but I’d run out of ink before I finish.

    To read about everything that’s new in Maple 2020, go to the new features page.

    Today we celebrated International Women's Day at Maplesoft. As part of our celebration, we had a panel of 5 successful women from within the community share their experiences and insights with us. 

    Hearing these women speak has given me the courage to share my personal experience and advice to women in technology. If what I write here helps even one woman, then I will have accomplished something great today. 

    -----

    What do you do at Maplesoft?

    My name is Karishma. I'm the Director, Product Management - Academic. 

     

    Where did you grow up and where did you go to school (Diploma/degree)?

    I was born and raised in Montreal to parents of Indian descent. Like most Indian parents, they “encouraged" me to pursue a career in either Law, Medicine, or Engineering, despite my true calling to pursue a career in theatre (at least that's what I believed it to be at the time)

    Given that I had no siblings to break the ice, and that rebelling wasn't my Modus Operandi (that came much later), I did what any obedient teenager would do: I pursued a career in Electrical Engineering at McGill University. In my mind, this was the fastest way to landing a job and fleeing the proverbial nest. 

    Electrical Engineering was far from glamorous, and after two years, I was ready to switch. It was due to the sheer insistence of my mother that I completed the degree. 

    So how did I end up pursuing a graduate degree in Biomedical Engineering at McGill University? It wasn't the future I envisioned, but the economic downturn in 2001-2002 saw a massive decrease in hiring, and the job that I had held-out patiently for during those four years became a far-off dream. So I did the thing I never imagined I would: I accepted the offer to pursue a Master's and the very generous stipend that came with it. In case you are wondering, I only applied because my father nagged me into submission. (Insistence and nagging are two innate traits of Indian parents)

    Contrary to what I expected, I loved my Master's degree! It gave me the freedom to immerse myself wholly in a topic I found exciting and allowed me to call the shots on my schedule, which led to my involvement in student government as VP Internal. But apart from the research and the independence, pursuing a master's degree opened doors to opportunities that I couldn't have imagined, such as an internship with the International Organization for Migration in Kenya, a job offer in Europe, and the chance to work at Maplesoft. (I guess my parents did know what was best for me.) 

     

    What is the best part of your job?

    It's figuring out how to solve problems our users have as well as the ones they might not realize they have. 

    At Maplesoft, I work with some most brilliant minds I've ever encountered to build a product that makes math more accessible to our users, whether they be a student, researcher, scientist, or engineer. 

    Some of the aspects of my role that I love the most include: 

    • speaking to and learning from our customers, 
    • interpreting the meaning behind their words, facial expressions, vocal intonations, and body language, and
    • collaborating with the sales, marketing, and development teams to turn what was 'said' into tangible actions that will enhance the product and user experience. 

    Most nights, when I leave work, I do so with a sense of excitement because I know my actions and the actions of those I work with will help our users achieve their goals and ambitions. There's no better high. 

     

    What advice do you have for young women interested in a career in your field? 
    Throughout my career, I've had the privilege to work with some amazing women and men who've given me advice that I wish I had known when I was an undergraduate student. If you are a woman pursuing a STEM degree or starting your first job in a tech firm, here are three tips that may help you: 

    1.   Don't be scared of the 'N' word. 
    Don't be scared of NETWORKING. I know it can be intimidating, but it truly is the best way to land a job, advance your career, or meet the person you admire most. Remember that networking can take place anywhere - it's not exclusive to networking events. Some advice that I received that helped me overcome my fear of networking: 

    • Smile - Before you approach a person or enter a networking session, force yourself to smile. It will help you diffuse any tension you are holding and will make you appear more approachable. 
    • Research - Take the time to research the person(s) you would like to meet. Find out as much as you can about them and their company. Prepare some icebreaker questions and other questions to help carry the conversation forward ahead of time. Remember that people like to talk about themselves and their experiences. 
    • Don't take it personally - The person you approach may find networking equally tricky. So if they seem disinterested or aloof, don't take it personally. 
    • Just do it - Networking gets easier with practice. Don't let a failed attempt set you back. The worse thing that will happen is that you don't make a connection. 

     

     2.   It's ok to ask for help.
    If you are a woman in an environment that is dominated by men, you might hesitate to ask for help. DON'T! There's nothing wrong with asking for help. That said, many women ask for help in a way that undermines their confidence and thus erodes others’ perception of them. Next time you need help, have a question or require clarification, take a moment to phrase your request, so you don't inadvertently put yourself down. 

     

    3.   Play to your strengths
    Don't think you need to know everything. Nobody expects it. If you landed a new job or co-op placement, and you are finding yourself doing things you've never done and don't come naturally to you yet, don't let your brain convince you that you don't deserve it. Remember that you earned it because of your qualities and strengths. 

    When discussing Maple programming, we often refer to for-loops, while-loops, until-loops, and do-loops (the latter being an infinite loop). But under the hood, Maple has only two kinds of loop, albeit very flexible and powerful ones that can combine the capabilities of any or all of the above, making it possible to write very concise code in a natural way.

    Before looking at some actual examples, here is the formal definition of the loops' syntax, expressed in Wirth Syntax Notation, where "|" denotes alternatives, "[...]" denotes an optional part, "(...)" denotes grouping, and Maple keywords are in boldface:

    [ for  ] [ from  ] [ by  ] [ to  ]
        [ while  ]
    do
        
    ( end do | until  )
    
    [ for  [ , variable ] ] in 
        [ while  ]
    do
        
    ( end do | until  )
    

    In the first form, every part of the loop syntax is optional, except the do keyword before the body of the loop, and either end do or an until clause after the body. (For those who prefer it, end do can also be written as od.) In the second form, only the in clause is required.

    The simplest loop is just:

    do
        
    end do
    

    This will repeat the forever, unless a break or return statement is executed, or an error occurs.

    One or two loop termination conditions can be added:

    • A while clause can be written before the do, specifying a condition that is tested before each iteration begins. If the condition evaluates to false, the loop ends.
    • An until clause can be written instead of the end do, specifying a condition that is tested after each iteration finishes. If the condition evaluates to true, the loop ends.

    A so-called for-loop is just a loop to which iteration clauses have been added. These can take one of two forms:

    • Any combination of for (with a single variable), from, by, and to clauses. The last three can appear in any order.
    • A for clause with one or two variables, followed by an in clause.

    The following for-loop executes 10 times:

    for  from 1 to 10 do
        
    end do
    

    However, if the doesn't depend on the value of , both the for and from clauses can be omitted:

    to 10 do
        
    end do
    

    In this case, Maple supplies an implicit for clause (with an inaccessible internal variable), as well as an implicit "from 1" clause. In fact, all of the clauses are optional, and the infinite loop shown earlier is understood by Maple in exactly the same way as:

    for  from 1 by 1 to infinity while true do
        
    until false
    

    When looping over the contents of a container, such as a one-dimensional array A, there are several possible approaches. The one closest to how it would be done in most other programming languages is (this example and those that follow can be copied and pasted into a Maple session):

     := Array([,"foo",42]);
    for  from lowerbound() to upperbound() do
        print([],[])
    end do;
    

    If only the entries in the container are of interest, it is not necessary to loop over the indices. Instead, one can write:

     := Array([,"foo",42]);
    for  in  do
        print()
    end do;
    

    If both the indices and values are needed, one can write:

     := Array([,"foo",42]);
    for ,  in  do
        print([],)
    end do;
    

    For a numerically indexed container such as an Array, this is equivalent to the for-from-to example. However, this method also works with arbitrarily indexed containers such as a Matrix or table:

     := LinearAlgebra:-RandomMatrix(2,3);
    for ,  in  do
        print([],)
    end do;
    
     := table({1="one","hello"="world",=42});
    for ,  in eval() do
        print([],)
    end do;
    

    (The second example requires the call to eval due to last-name evaluation of tables in Maple, a topic for another post.)

    As with a simple do-loop, a while and/or until clause can be added. For example, the following finds the first negative entry, if any, in a Matrix (traversing the Matrix in storage order):

     := LinearAlgebra:-RandomMatrix(2,3);
    for ,  in  do
        # nothing to do here
    until  < 0;
    if  < 0 then
        print([],)
    end if;
    

    Notice that the test, < 0, is written twice, since it is possible that the Matrix has no negative entry. Another way to write the same loop but only perform the test once is as follows:

     := LinearAlgebra:-RandomMatrix(2,3);
    for ,  in  do
        if  < 0 then
    	print([],);
    	break
        end if;
    end do;
    

    Here, we perform the test within the loop, perform the desired processing on the found value (just printing in this case), and use a break statement to terminate the loop.

    Sometimes, it is useful to abort the current iteration of the loop and move on to the next one. The next statement does exactly that. The following loop prints all the indices but only the positive values in a Matrix:

     := LinearAlgebra:-RandomMatrix(2,3);
    for ,  in  do
        print(=[]);
        if  < 0 then
    	next
        end if;
        print(=);
    end do;
    

    (Note that a simple example like this would be better written by enclosing the printing of the value in an if-statement instead of using next. The latter is generally only used if the former is not possible.)

    Maple's loop statements are very flexible and powerful, making it possible to write loops with complex combinations of termination conditions in a concise yet readable way. The ability to use while and/or until in conjunction with for means that break statements are often unnecessary, further improving clarity.

    The binary search algorithm is used to obtain the index of a given number by dividing the search bound in half over iteration. If the value entered in the array a message pop up telling that ''value is not present in the array". Please see the code. 
     

    restart; with(ArrayTools); AA := Array(1 .. 10, [20, 2, 30, 4, 50, 7, 60, 8, 90, 100]); AA := sort(AA); KEYVALUE := 200; DUP_KEYVALUE := infinity; low := 1; high := NumElems(AA); while DUP_KEYVALUE <> KEYVALUE do mid := floor((low+high)*(1/2)); if AA[mid] = KEYVALUE then DUP_KEYVALUE := KEYVALUE; printf("%s\n %a\n", "the index is ", mid) elif AA[mid] < KEYVALUE then low := mid+1 elif AA[mid] > KEYVALUE then high := mid-1 end if; if low > high then printf("%s\n", "value not present in the array"); break end if end do


     

    Download BINARY_SEARCH1.mw

     

    1 2 3 4 5 6 7 Last Page 1 of 270