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
  • Summary:Hough transform is a feature extraction algorithm widely used in digital image analysis. It identifies objects with specified shapes by letting all edge pixels in the image “vote” and extract candidates with the highest votes. The classical Hough transform is associated with the identification of straight lines, but with some modification, the algorithm can be used to detect objects of arbitrary shapes (usually circles, ellipses) in an image. Therefore, Hough transform has various applications in the field of computer vision. Samir and I implemented Hough transform to detect straight lines and circles in real world images and the results are below:

    You can access the applications here for more details and try the algorithm on your own image!

    Line Detection with Hough Transform

    Circle Detection with Hough Transform

    For people who want a bit more of the theory behind:

    The voting procedure in Hough transform starts with an edge detector (we used the sobel edge detector in the applications). After locating all the edge pixels, the program will iterate through each of the pixels and record their “votes”. It is important to address that the voting procedure is completed in parameter space. For example, a straight line is usually in the form of y = a*x+b, the parameter space will be in terms of a and b. Hence y=2*x + 3 will be a point (2,3)  in the a-b space. However, notice that we cannot represent vertical lines with this system; it would take infinite memory to store a vertical line. Thus we use the polar coordinates system x*cos(θ) + y*sin(θ) - p = 0 instead, resulting in a θ -p space. Note that an image pixel (x1,y1) is represented by the intersection of all lines that satisfy x1*cos(θ) + y1*sin(θ) - p = 0, which in θ-p space is denoted as a sinusoidal curve. Hence the intersection of two different sinusoidal curves in θ-p space is essentially a unique, straight line that passes through two different image pixels. An intersection of 500 votes means that specific line passes through 500 edge pixels, implying that it is likely a solid contour line in the original image. In this way, by converting all edge pixels to sinusoidal curves in θ-p space, the algorithm is letting all pixels “vote”. In order to record the sinusoidal curves, we need an accumulator of θ * p dimensions. In the line detection application we used a matrix such that <= θ <= 180 and -sqrt(r2 +c2 ) <= p <= sqrt(r2 +c2 ), where r and c are the height (rows) and width (columns) of the image.

    The voting procedure for circle detection is similar; the difference is in how we construct the accumulator to accommodate different parametrization for circles. Notice that a circle has three essential pieces of information, the x,y coordinates of centre and the radius. This suggests that our accumulator might have to be in three dimensions. In practice, circular Hough transform is usually performed with known or estimated radius, when the radius is not known, the most straightforward solution is indeed to test a range of possible radii with a 3-dimensional accumulator. However, this might be quite expensive, especially for images with high level of details.

    Feel free to leave a comment if you have any question  :)  

    We’re excited to bring you another Meet Your Developers post. This one comes from Senior Developer, Margaret Hinchcliffe.

    Enjoy!

    1. What do you do at Maplesoft?
      I work on the software team that develops the user interface for Maplesoft products. In my time at Maple, I’ve worked on Maple, MapleSim, and MapleNet.

     

    1. What did you study in school?
      I studied Computer Science at the University of Waterloo, in the Co-op program.

     

    1. What area(s) of Maple or MapleSim are you currently focusing on in your development?
      I’m currently working on MapleNet and on ways to bring Maple functionality to the web.

     

    1. What’s the coolest feature of Maple or MapleSim that you’ve had a hand in developing?
      I helped develop the feature that lets you embed videos in a Maple worksheet. I thought that was pretty cool.

     

    1. What do you like most about working at Maplesoft? How long have you worked here?
      I celebrated my twentieth anniversary at Maplesoft this spring. Obviously, I like working here. What I like most is the opportunity to learn new skills in a supportive environment. Our company gym is pretty awesome, too.

     

    1. Favourite hobby?
      I took up boxing a couple of years ago and I really enjoy it. It’s a great workout and there’s always something new to learn.

     

    1. What do you like on your pizza?
      Pepperoni, mushrooms, and fresh basil.

     

    1. What’s your favourite movie?
      The Wizard of Oz. When people say “The book is always better”, I point to this movie as a counterexample.

     

    1. What skill would you love to learn? Why?
      I’d like to try archery. If nothing else, it would come in handy in a zombie apocalypse.

     

    1. Who’s your favourite mathematician?
      Alan Turing. He made important contributions to computer science and he helped fight the Nazis.

     

    Thanks Margaret!

    Hello MaplePrime users,

    Yesterday, I posted my MagicPuzzles package to the MapleCloud. It is a collection of tools I have written for manipulating, solving, and visualizing puzzles like Magic Squares and Magic Stars. Here's a sample solution for each:



    For the Magic Square, the numbers on each horizontal and vertical line, along with the numbers on each of the two diagonals, add up to 65.

    The inaugural version has separate sub-packages for:

    • Magic Annulai (my own name)
    • Magic Hexagons
    • Magic Squares
    • Magic Stars

    Moreover, each sub-package contains these commands:

    • Equations(), to return the linear equations for the variables based on the Magic Sum;
    • Constraints(), to return the conditions that prevent redundant solutions found by reflections and rotations;
    • VerifySolution(), to confirm if a list of numbers is a solution;
    • EquivalentSolutions(), to determine solutions equivalent to a given solution;
    • PrimarySolution(), which takes a solution and returns the associated primary solution;
    • Reflection() and Rotation(), to reflect and rotate a solution; and
    • Draw(), to provide a visualization (like the ones above).

    There is also a command, MagicSolve(), which is used to find solutions, which take the form of permutations of [1,...n] for some positive integer n, to the equations. Essentially, it solves the linear equations, and cycles through all permutations for the free variables, and selects those that give "magic" solutions.

    In future versions, I intend to add:

    • Other specific classes of problems;
    • More sample solutions; and
    • Known algorithms for finding particular solutions.


    To install the package, you can do so from here, or just execute the following within Maple 2017+:

    PackageTools:-Install( 5755630338965504, 'overwrite' );

    There are many examples in the help pages.

    I think others will find this package interesting and useful, and I encourage you to check it out.

    Allow me to introduce the Pauli Algebra package for Maple. This package implements the Clifford Algebra of Physical Space Cl3 through the use of complex paravectors. The syntax of the package is similar to the notation popularized by the work of Dr. William E. Baylis. For more information, check out the Wikipedia entry on Paravectors and the APS workbook available on Dr. Baylis' website

     

    To install the Pauli Algebra package while in a Maple session, type

    PackageTools:-Install("https://maple.cloud/downloadDocument?id=5763496974221312&version=1")

     

    Alternatively, you can find the Pauli Algebra package in the MapleCloud, and choose the install button on the far right.

     

    Upon installation, several help files become available in Maple Help to assist you with the syntax.

     

    As you will see in the Pauli.mpl source code of the package workbook, a number of Maple functions have been overloaded to handle the package's Paravector datatype. If you wish to overload additional Maple functions, let me know, and I'll include them in future updates.

     

    I'll sign off by attaching a Maple worksheet/pdf containing some examples.

    PauliAlgebraDemo.mw

    PauliAlgebraDemo.pdf

    Enjoy!

     

    This is the final installment in a series of three articles outlining new features of Maple's command line (TTY) interface. Today we'll cover improvements to ImageTools:-Preview for use from a terminal.

    Character based terminals are not well suited for displaying graphics, although the earliest Maple plotting support was specifically for such devices because better options were not widely available. But for text-based work such as writing code and documentation, many developers still prefer to work in a terminal, where everything is just a keystroke or two away. A problem arises when working on projects involving graphics. Obviously, it's easy to open an appropriate image viewer for such tasks, but for quick previews where details aren't important, a terminal-based solution can be convenient.

    As a sample image for the first few examples, we'll use this well known public domain test image, commonly referred to as the baboon, although it is actually a mandrill:

    The ImageTools:-Preview function has always been able to render output in a terminal. The output is akin to what one might have seen hanging on a data center wall in the 1970s:

    > interface(screenheight=40,screenwidth=72,plotdevice=char):
    > with(ImageTools):
    > img := Read("../../Pictures/baboon.png");
                         [ 1..512 x 1..512 x 1..3 3-D Array ]
                  img := [ Data Type: float[8]              ]
                         [ Storage: rectangular             ]
                         [ Order: C_order                   ]
    
    > Preview(img);
    oO*O*o++==**+o+=+-+=*o**=++=+*++++o*++~=o===*****==+===+++--~~=~~~+*
    @o*++++~=+~++++++=++**oO*oOOooOOOOOOoo*++ooo*+++====+*++====~~~-==+*
    Ooo++===+==+***o*oo***oooOo*++==**==~~=*oO****ooooooooo***++=~~~~~+*
    @o*+=+~===*+oOo@@@@@@@@@@@@@@oooOOO*oO@@OOO@@@@@@@@@@@@@o*+===~-=++*
    O**==~+=~=+*O@O@@@@@@OO@@O@@@@@@@OOO@@o*o@+=**=+@ooOOOoo+=+==~~~~=++
    o++++=-~~~=++*oOO**O@*=**+o@Oo@@@@@@@o*O@@o===+*@+~+o*+++~===~~=~++*
    +*++==~~==~=+=++*+=o@@@@@@@@ooo@@@@OO*Ooo@@@@OO*+=*oo*+==~~~~--=~++o
    o*+=+~=~~=~~++++*****oo*+**=+O@OOO*o+*oo+++*+=~+*oo**+*+~=~~-~~~~=+=
    O*=*=~=~~===~==+****OOOooooOOOO+O*=+*+Oo=~-~~=OOo**+*++=~~~-~-~-~+=+
    O+++~~+~=~~+==+o**oo@@*~-----O*=@o++=o@=   -~~=*ooo*o+====~~~~-~~+=+
    *o**++===+~=+=*+OOOOo=-~~   -o*=o*=++=o     -~==+oo**o++~~~----~~~++
    o*oo*===+==+=*oo*oO=-=-  -  -*=+o+=++=+    -----=**+++*+~~==~-~-=+~*
    *o**+*=++=~==~=+**O~- ~     -+=+*+=++==       ~~-~++=+~=~~~~-~~~+==+
    ooo*o***+++~+==+oo==-  -    -+=++=+++==      -- -~+=+~~~~~~~=~~===+*
    oo*o*==*+=====oooo-~-  -    -==*+==++==         --~*++=~=--~-=====**
    *oooo*+*+===++=*@*--~-      ~=+*+==++==         ~--+*==+=~~~-=~+++**
    oOOoOo**+*+=+=+O@=- ~-      ~=+*+~~=++~        -- -*o*+====~=+=+*++*
    ++*ooooOo+**+*OoO~~ -~      ~=+*+-~+++~-      -~  ~ooo+=~=~=+=******
    *o+OO@@ooOooO@O@@~=- --     ==++=~~+++~       ~  -+Oo*==++=*+**+***+
    *++*ooOOOO@OOO@@@=-=- -     =+++=-~+++~      ~   -*o***++=++*o*oo*oo
    ~===++**oOOO@@@@@@-~-  -    ~***=- =++-     -   -~oOo**o*oooo***oooo
    ~~~=~~==+O@@@@@@@@=-=  -  - -++*=-~=++     --   ~+@OO*******o**o*OOO
    =~-~-=+oO@@@@@@@@@*~--  -    =+*+==+*~  -  -   -~O@@o*ooo*ooooooooOO
    ----~==+o@@@@@@@@@o+-~  -  - ~**+=++*- -  -- ---=@@@OO**oooooo*ooooo
    -~~~~=+**o@@@@@@@@@+~~~-=- --=**+==++- ~  + -~~~*OOOOoo*ooooo***oOOO
    ---~====*@@@@@@@@@@O+~+=~= -~+*++=+++-~- =+~~~++*oOOOOoooooooo**oooo
    ---~--~=O@@O@@O**oOO++*+~+--++++==+++=~ -+~~=*=***oOoOoooOOOoooooo*o
    -    --+**oo+===*Oooo**+~=++++++==++++=~~~~+++o*+**oOo****oOOoooo*o*
          ~++oO+-~~~+@Oo***+====+++===+++=====+=+++******++**++*oOooo***
    -     ~+***=~~--=ooo**+++oo*~~~~~~~~~+*+===+++=***+++*+++****oo***++
          -=***=~---~+oOo*+++==*o=+=~==+*+===+++**+***+**+=====+oo**+++=
       - --~**===~~-~~=*O*++===++*+===+==+++++++******o**=~~~===+**++++=
     -   --~+====- --~~=+*+++++++++==++==++++++++*****~=+=~~---=+**++===
    -    --~======~~-~~ -===+++++**=++++++++++++=+++~=~~+=-----~=***+===
       -----~~+=*=~-~-~+- --~=++++++++++++++++=+-~- +=++~--~~-~==++*+===
    -----~-~======~~-~~~~--   ~~~~~~==~===~=~~- --=~=o=~~~~~~~=++++++=++
    ~~--~--~~~==+++==~-- ~=-~--~~=~~~---~-~~-~-~~=+*=+=~~~-===++***+++=+
    -~~~~~~~~~==++=++=--    -~~=++++===+=~==+==~**=+=~==~~=+*++****+++++
    ~~=~~~~~~~==++***+=--     --~=====++=~===+~~+~--~~~=++++****o*+****o
    =====~~~~===+***oo*+-        - --------  --     -~=++*o*ooooo*+*oooO
    

    If you squint really hard, you can almost discern the image. As of Maple 2018.1, ImageTools:-Preview now uses color output if interface(ansi) is set to true and interface(plotdevice) is set to colorchar:

    > interface(plotdevice=colorchar):
    > Preview(img);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    In addition to providing quick previews of image files, this feature can also be used to get more information about plots. For example, consider the following 3D plot generated using Maple's color character plot driver:

    > plot3d([1,x,y],x=0..2*Pi,y=0..2*Pi,coords=toroidal(10));
    
                                                                            
                                  ------------                              
                            ----------||-|----------                        
                         --------\-\\-||-|-//-/--------                     
                       ---------\\\\\|||-||/-///---------                   
                     --/-//-----\\\\||||-|||/////---\\\-\--                 
                    -/-//-//-/-\\\\\||||||||//-/--\\\\-\\---                
                   --|-||-||-|--\\\\||||||||////--|/||-||-|--               
                  /--|-\-\-\\---\\\||||||||||///-////-/-/-|--\              
                 //-----\------\\\\\||||||||////-------/-----\              
                 //////--/--------\||||||||||/--------\--\\\\\\             
                /////// //// /-/--/-/-|-|||\-\--\-\ \\\\ \-\\\\\            
                |/////-////-/-//-/-/-|--|-|-\-\-\\-\-\\\\-\ \\\|            
                |//|////-/-// / /--|-|--|-|-|--\ \\-\-\ \\\\|\\|            
                ||| |-/-/  |-/--|-|--|  | | -|-|--\-|| \-\-| |||            
                |||-||| /-|--| |  | -|--|-|- |  | |--|-\ ||-||||            
                |||| |-|  | |--|--|--|  | |--|--|--| |  |-| ||||            
                 |||-| |-||-|  |  |  ---|-|  |  |  |-||-| |-|||             
                  ||-|-| | -|--|--|  |  | || |--|--|- | |-|-||/             
                  \||| |-|- |  |  ---|--|--|--| |  | -|-| |-|/              
                   \-|-| | -|--|-|| |   |  |  | |--|--| |-|//               
                    \|||||- |  |-|--|---|--|--|-|  | -|-|||/                
                     \|\|-|-|--|--| |   |  |  |-|--|-|-|-|/                 
                       \\\|-|- |  |--|--|--|-|  | -|-|-//                   
                         --\-\-|--|--|--|-|--|--|-/-/--                     
                            ----\-|--|--|-|--|-/----                        
                                  -\-|--|-|-/-                              
                                                                            
    

    The output shows the general shape of the plot, but unless you already know what it looks like, it can be hard to visualize, especially since the character drivers don't support shading. One can glean additional insight by generating a high resolution bitmap version of the plot, and then Preview-ing that:

    > interface(plotdevice="bmp",plotoutput="plot.bmp");
                              colorchar, terminal
    
    > plot3d([1,x,y],x=0..2*Pi,y=0..2*Pi,coords=toroidal(10));
    # Revert to colorchar or Preview won't generate a textual preview.
    > interface(plotdevice="colorchar",plotoutput=terminal);
                                 bmp, plot.bmp
    
    > img := Read("plot.bmp");
                         [ 1..360 x 1..480 x 1..3 3-D Array ]
                  img := [ Data Type: float[8]              ]
                         [ Storage: rectangular             ]
                         [ Order: C_order                   ]
    
    > Preview(img);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    By default, Preview uses the extended xterm 256 color mode. The image is resized to fit within the current settings of interface(screenwidth) and interface(screenheight), and then each pixel is plotted using an "@" character over a colored background. The foreground and background colors are chosen so that their weighted average comes as close as possible to the actual RGB value of the pixel. Since this rarely produces exactly the right color, Preview also performs dithering, taking the error from the current pixel and distributing it over surrounding pixels. In effect, this uses spatial resolution to make up for the lack of color resolution.

    ImageTools:-Preview has two keyword options, dither and sixteen, that let you override this behaviour. Passing the option dither=false will tell Preview not to dither. Passing sixteen=true (or just sixteen) will result in Preview using only the sixteen standard colors, of which only eight are used for the background.

    The following examples are based on this Maple logo image:

    By default, ImageTools:-Preview renders this with 256 colors and dithering as follows:

    > img := Read("../../Pictures/logo.png");
                         [ 1..428 x 1..459 x 1..3 3-D Array ]
                  img := [ Data Type: float[8]              ]
                         [ Storage: rectangular             ]
                         [ Order: C_order                   ]
    
    > Preview(img);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@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@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    If we render it without dithering, the result is sharper, but the subtle gradient from lighter to darker blue turns into a series of very obvious concentric rings, as there are not enough distinct colors in the terminal's palette to render it accurately:

    > Preview(img,dither=false);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    In sixteen color mode, the palette is severely reduced, and as a result, the dithering is much more pronounced as the per-pixel errors are larger:

    > Preview(img,sixteen);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@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@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    Finally, here is the image in sixteen color mode, with dithering disabled:

    > Preview(img,sixteen,dither=false);
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    One thing to note is that Maple has no way of knowing what the sixteen "standard" colors of your terminal actually look like, since many terminals let you change the palette. Maple assumes you are using the 16-color VGA palette, since that is close to the actual default palette on most terminals. If you are using a different palette (for example, Solarized), 16-color images will look worse than they are shown above.

    These files contain the kinematics and dynamics of the solid using a new technique (ALT + ENTER) to visualize the results online and thus save space in our Maple worksheet. Seen from a relative approach. For engineering students. In Spanish.

    Equations_of_movement_for_particle.mw  (Intro)

    Kinematics_and_relative_dynamics_of_a_solid.mw

    Flat_kinetic_of_a_rigid_body.mw

    Lenin Araujo Castillo

    Ambassador of Maple

    The video shows the curvilinear components of acceleration in polar coordinates, radial and tangential scalar components. Applied to a structure; in a time interval; to finally be graphed and interpreted. For engineering students.

    Speed_and_Acceleration_with_Cylindrical_Components.mw

    Lenin Araujo Castillo

    Ambassador of Maple

    As you may have already heard, in order accelerate the growth of our different product lines, Maplesoft decided to spin off our online education products into a separate company. Let me introduce you to DigitalEd.

    DigitalEd will focus on online education technology, including online courseware, testing and assessment, and placement testing (i.e. Möbus, Maple T.A., and the Maple T.A. MAA Placement Test Suite). Maplesoft will continue to develop and support Maple, MapleSim, and their related products, for both academic and professional use.  The two companies will maintain close ties, and Maple will continue to supply the mathematical engine to the DigitalEd product line.

    For more information about this change, see https://www.maplesoft.com/digitaled/

    You can take a look at the new DigitalEd web site here:  www.digitaled.com.

    Last week, in the first of a series of three articles, I demonstrated the new color syntax highlighting in the command line (TTY) interface of Maple 2018.1. This week, we'll look at a new facility for manipulating the command line history, the history meta-commands.

    For the series of screen shots in this article, assume that the .maple_history file in your home directory initially contains the following:

        p1 := plot(sin,color="DeepPink"):
        p2 := plot(cos,color="DodgerBlue"):
        plots[display](p1,p2);

    Now we'll start cmaple and execute a series of commands:

        |\^/|     Maple 2018.1 (X86 64 LINUX)
    ._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2018
     \  MAPLE  /  All rights reserved. Maple is a trademark of
     <____ ____>  Waterloo Maple Inc.
          |       Type ? for help.
    > y := 1/(x^4+1);
                                         1
                                  y := ------
                                        4
                                       x  + 1
    
    > int(y,x);
         1/2           1/2             1/2           1/2
    1/4 2    arctan(x 2    + 1) + 1/4 2    arctan(x 2    - 1)
    
                        2      1/2
                1/2    x  + x 2    + 1
         + 1/8 2    ln(---------------)
                        2      1/2
                       x  - x 2    + 1
    
    > diff(%,x);
              1                       1              1/2
    --------------------- + --------------------- + 2
           1/2     2               1/2     2
    2 ((x 2    + 1)  + 1)   2 ((x 2    - 1)  + 1)
    
        /         1/2        2      1/2              1/2 \
        |  2 x + 2         (x  + x 2    + 1) (2 x - 2   )|
        |--------------- - ------------------------------|
        | 2      1/2               2      1/2     2      |
        \x  - x 2    + 1         (x  - x 2    + 1)       /
    
          2      1/2        /      2      1/2
        (x  - x 2    + 1)  /  (8 (x  + x 2    + 1))
                          /
    
    > simplify(%);
    memory used=5.2MB, alloc=41.3MB, time=0.11
                                     4
                                    x  + 1
                     -------------------------------------
                       2      1/2     2     1/2    2     2
                     (x  + x 2    + 1)  (x 2    - x  - 1)
    
    > normal(%,expanded);
                                       1
                                     ------
                                      4
                                     x  + 1
    

    There are two parts to the history:

    1. Session history consists of the commands you've entered in the current session.
    2. Command history consists of all commands from previous sessions, together with the session history (up to a maxium specified by interface(historysize), which is 1000 lines by default).

    History meta-commands all begin with two exclamation marks at the beginning of the line. The !!= meta-command lists the session history:

    > !!=
    << y := 1/(x^4+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    Notice that each displayed line of the history is preceeded by << to differentiate it from Maple input and other Maple output. Each meta-command also has a long form. The long form for !!= is !!list:

    > !!list
    << y := 1/(x^4+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    Most meta-commands can take an argument specifying the amount of history to be affected. For example, a numeric argument refers to the last lines of the command history. Here, !!=8 includes the 3 lines from the previous history, as well as the 5 lines of session history:

    > !!=8
    << p1 := plot(sin,color="DeepPink"):
    << p2 := plot(cos,color="DodgerBlue"):
    << plots[display](p1,p2);
    << y := 1/(x^4+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    An argument beginning with a forward slash ("/") refers to all history lines beginning with the most recent one that contains the text entered after the slash (if the text to be searched for does not begin with a space or a digit, the slash can be omitted):

    > !!=/diff
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    We'll quit Maple and start a new session to illustrate another aspect of the history meta-commands.

    > quit
    memory used=6.4MB, alloc=41.3MB, time=0.14
    

    In the new session, the meta-command !!=/x^4 will list everyting from the previous session starting from the most recent matching line:

        |\^/|     Maple 2018.1 (X86 64 LINUX)
    ._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2018
     \  MAPLE  /  All rights reserved. Maple is a trademark of
     <____ ____>  Waterloo Maple Inc.
          |       Type ? for help.
    > !!=/x^4
    << y := 1/(x^4+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    If a !!= meta-command with a numeric or search argument is executed as the first command in a fresh session, not only is the specified amount of command history listed, but that part of the history is then considered to be session history. Executing just !!= with no argument shows that this is the case:

    > !!=
    << y := 1/(x^4+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    

    The !!! meta-command (long form !!play) re-executes the entire session history:

    > !!!
    >> y := 1/(x^4+1);
                                         1
                                  y := ------
                                        4
                                       x  + 1
    
    >> int(y,x);
         1/2           1/2             1/2           1/2
    1/4 2    arctan(x 2    + 1) + 1/4 2    arctan(x 2    - 1)
    
                        2      1/2
                1/2    x  + x 2    + 1
         + 1/8 2    ln(---------------)
                        2      1/2
                       x  - x 2    + 1
    
    >> diff(%,x);
              1                       1              1/2
    --------------------- + --------------------- + 2
           1/2     2               1/2     2
    2 ((x 2    + 1)  + 1)   2 ((x 2    - 1)  + 1)
    
        /         1/2        2      1/2              1/2 \
        |  2 x + 2         (x  + x 2    + 1) (2 x - 2   )|
        |--------------- - ------------------------------|
        | 2      1/2               2      1/2     2      |
        \x  - x 2    + 1         (x  - x 2    + 1)       /
    
          2      1/2        /      2      1/2
        (x  - x 2    + 1)  /  (8 (x  + x 2    + 1))
                          /
    
    >> simplify(%);
    memory used=5.2MB, alloc=41.3MB, time=0.10
                                     4
                                    x  + 1
                     -------------------------------------
                       2      1/2     2     1/2    2     2
                     (x  + x 2    + 1)  (x 2    - x  - 1)
    
    >> normal(%,expanded);
                                       1
                                     ------
                                      4
                                     x  + 1
    

    Notice that each command is displayed with a >> prompt. This prompt is used whenever a command in the history is being played back.

    History commands can be played back one step at a time using the !!. (or !!step) meta-command. Each command is displayed with the >> prompt, and you are given the opportunity to edit it before pressing Enter to execute it. Here, we've changed the exponent of from 4 to 3 before pressing Enter, and then pressed Enter four more times to re-execute the remaining commands:

    > !!.
    >> y := 1/(x^3+1);
                                         1
                                  y := ------
                                        3
                                       x  + 1
    
    >> int(y,x);
                                                                      1/2
                              2                 1/2        (2 x - 1) 3
      1/3 ln(x + 1) - 1/6 ln(x  - x + 1) + 1/3 3    arctan(--------------)
                                                                 3
    
    >> diff(%,x);
                    1          2 x - 1               2
                --------- - -------------- + ------------------
                3 (x + 1)       2              /         2    \
                            6 (x  - x + 1)     |(2 x - 1)     |
                                             3 |---------- + 1|
                                               \    3         /
    
    >> simplify(%);
                                       1
                              --------------------
                                        2
                              (x + 1) (x  - x + 1)
    
    >> normal(%,expanded);
                                       1
                                     ------
                                      3
                                     x  + 1
    

    When editing a command prefixed with the >> prompt, the command is edited in-place in the history. In other words, the history is permanently modified. History meta-commands are not played back (or infinite loops could result), and lines containing only comments are displayed but not offered for editing.

    Still in the same session, let's use !!. with a search pattern to generate and display the plots from the older history, pressing Enter after each command:

    > !!./p1 :=
    >> p1 := plot(sin,color="DeepPink"):
    >> p2 := plot(cos,color="DodgerBlue"):
    >> plots[display](p1,p2);
    
                                                                            
                                        |                                   
     -*\    /*-*                      1-+*     *-*\                     /*- 
       \   //  \\                    // |\\   /   \                     /   
        \  /    \\                   /  | \  //    \                   /    
        \ /      *                  *   |  * *     \\                  /    
         **      ||                 |   |  |*       *                 *     
         *|       |                |    |   *       ||               ||     
         ||       ||               |    |  |*        |               |      
        |||        |              |     |  | |       |               |      
        | ||       |              |     | || |        |             ||      
        |  |       ||            || 0.5 | |  |        |             |       
       |   |        |            |      | |   |       |             |       
       |   ||       |            |      |||   |        |           ||       
       |    |       ||           |      ||    |        |           |        
      |     |        |          |       ||     |       |           |        
      |     ||       |          |       ||     |        |         ||        
      |      |       ||         |       |      |        |         |         
     ||      |        |        |        |       |       |         |         
     |       ||       |        |        |       |       ||       ||         
     +--------+-------++-------+-------++-------+--------+-------+--------+ 
      -6      |  -4    |    -2|       0||        |2      |   4   |      6|| 
              ||       |      |        ||        |       ||     ||       |  
               |       |      |       | |        |        |     |        |  
               |        |    ||       | |        ||       |     |       ||  
               |        |    |        | |         |       ||    |       |   
                |       |    |       || |         |        |   |        |   
                |        |  ||       |  |         ||       |   |        |   
                |        |  |      -0.5 |          |       ||  |       |    
                 |       |  |       ||  |          |        | |        |    
                 |        |||       |   |          ||       | |       ||    
                 ||       ||        |   |           |       |*|       |     
                  |       **       |    |           |        *        |     
                  |*      |*       |    |            |      **|      *      
                   \     /*\\     *     |            *\     / *      /      
                   \\    /  \    //     |             \    // \\    /       
                    \\  //   \   /      |             \\   /   \\  //       
                     *-*/    \*-*    -1 |              \*-*     *-*/        
                                        |                                   
                                                                            
    
    >> !! y := 1/(x^3+1);
    > _
    

    On the last line above, we typed !! followed by a space (long form !!stop) to tell Maple to stop playing back commands and give a fresh prompt. If we now issue !!=, we see that the session history still contains only the five commands it contained originally. The played back commands were not appended to the history:

    > !!=
    << y := 1/(x^3+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);

    Issuing a new command at the regular > prompt adds it to the end of the session history:

    > sin(Pi/2) + 1;
                                       2
    
    > !!=
    << y := 1/(x^3+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    << sin(Pi/2) + 1;

    The !!- (or !!drop) meta-command deletes one or more commands from the history:

    > !!-
    > !!=
    << y := 1/(x^3+1);
    << int(y,x);
    << diff(%,x);
    << simplify(%);
    << normal(%,expanded);
    > !!-/simpl
    > !!=
    << y := 1/(x^3+1);
    << int(y,x);
    << diff(%,x);
    

    In addition to the meta-commands described above for manipulating the history within a session, there are three meta-commands to copy history to and from files:

    • !!> (or !!save ) writes the session history to the specified file.
    • !!< (or !!read ) replaces the session history with the contents of the specified file.
    • !!+ (or !!append ) appends the contents of the specified file to the session history.

    Used together, these meta-commands let you save important sessions for later examination or reuse without relying on the .maple_history file, or let you make large changes to the current session history using your favorite text editor.

    The !!? (or !!help) meta-command displays a short summary of all the meta-commands:

    > !!?
    
    The sequence "!!" at the beginning of a line introduces a history meta-command.
    Each has a short or long form (shown below in parentheses). The long form name
    may be used instead of the single character appearing after "!!".
    
    !!=specifier    - list session history or specified lines (list)
    !!!specifier    - play back session history or specified lines (play)
    !!.specifier    - step through session history or specified lines (step)
    !!-specifier    - drop one or specified lines from history (drop)
    !!<filename     - read file into session history (read)
    !!+filename     - append file to session history (append)
    !!>filename     - save session history to file (save)
    !!?             - help for history meta-commands (help)
    !!              - stop the single-step playback in progress (stop)
    
    The 'specifier' is optional. If present, it can be an integer, N, referring to
    the N most recent command lines, or a string beginning with a "/" character,
    referring to the lines from the most recent one containing that string. The "/"
    may be omitted if the search string does not begin with a space or digit.

    Detailed information can be found in the ?edit_history help page.

    For the past two years the Queen’s College of Guyana Alumni Association (NY) has been hosting its Queen’s College Summer Maths Institute, and Maplesoft has supported this initiative by giving students access to Maple.   With Dr. Terrence Blackman at its helm, the institute aims to sustainably implement a developmentally appropriate and culturally resonant middle school learning environment that engages Guyanese students in a cognitively rich mathematics learning experience.  The experience is intended to place them securely on pathways to STEM (Science, Technology, Engineering and Math) excellence.

    The program uses a developmentally appropriate approach that combines significant mathematical content with a setting that encourages a sense of discovery and excitement about math through problem solving and exploration. Program Manager Shindy Johnson, a former student of Queens College, noted that by the end of the first week math sceptics fall in love and gained confidence, and math lovers renew their passion.

    As avid Maple users, Dr. Terence Blackman and Cleveland Waddell, one of the main organizers and lecturer,  give the students the opportunity to use Maple. Last year, the students were amazed by Maple's computational power. “It was nothing like they have seen before.  Many students also wrote their first lines of computer code using Maple during the summer camp.  Maple is an invaluable resource for us during the camp,” said Waddell.

    Dr. Terence Blackman and Cleveland Waddell

    Students receive further enrichment through field trips to broaden their appreciation for education and industry in Guyana.  In addition, Guyanese professionals visit the Institute to share their expertise, career journeys and practical applications of math and other STEM disciplines in their professions.

    Field trip to Uitvlugt Sugar Estate

    Students who participate ranged from self-professed math lovers to teens who confessed to fearing and even loathing math. By the end of the first week, math lovers had discovered even greater “beauty in the mathematics” and those who quaked at the thought of math were beginning to commit – with confidence – to improving their math grades. This year’s Queen’s College Summer Maths Institute will take place July 26-August 3, 2018 in Georgetown, Guyana.   

    Recently I looked through an interesting book D. Wells "The Penquin book of Curious and Interesting Geometry" and came across this result, which I did not know about before: starting with a given quadrilateral , construct a square on each side. Van Aubel's theorem states that the two line segments between the centers of opposite squares are of equal lengths and are at right angles to one another. See the picture below:

                                      

    It is interesting that this is true not only for a convex quadrilateral, but for arbitrary one and even self-intersecting one. This post is devoted to proving this result in Maple. The proof was very short and simple. Note that the coordinates of points are given not by lists, but by vectors. This is convenient when using  LinearAlgebra:-DotProduct  and  LinearAlgebra:-Norm  commands.

    The code of the proof (the notation of the points on the picture coincide with their names in the code):

    restart;
    with(LinearAlgebra):
    assign(seq(P||i=<x[i],y[i]>, i=1..4)):
    P||5:=P||1:
    assign(seq(Q||i=(P||i+P||(i+1))/2+<0,1; -1,0>.(P||(i+1)-P||i)/2, i=1..4)):
    expand(DotProduct((Q||3-Q||1),(Q||4-Q||2), conjugate=false));
    is(Norm(Q||3-Q||1, 2)=Norm(Q||4-Q||2, 2));
    
    

    The output:

                                                          0
                                                        true

     

    VA.mw

    The Maple command line interface (cmaple), often referred to as the "TTY interface" for its original use on Teletype terminals, is still the tool of choice for many Maple developers and power users. Maple 2018.1 introduces several new capabilities to this long-lived interface:

    This post, the first in a series of three, will address color syntax highlighting. We'll start with a very short sample session:

        |\^/|     Maple 2018.1 (X86 64 LINUX)
    ._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2018
     \  MAPLE  /  All rights reserved. Maple is a trademark of
     <____ ____>  Waterloo Maple Inc.
          |       Type ? for help.
    > piecewise(4 < x^2 and x < 8, f(x));
                                {                  2
                                { f(x)        4 < x  and x < 8
                                {
                                {  0             otherwise
    
    > p := unapply(%,x);
                                                   2
                          p := x -> piecewise(4 < x  and x < 8, f(x))
    
    > 1/p(1);
    Error, numeric exception: division by zero
    > quit
    memory used=5.3MB, alloc=41.3MB, time=0.07
    

    In the above example, you can see that general keywords are in bold blue, variables in italics (not supported by all terminals), error messages in bold red, control flow interrupting keywords in bold magenta, and memory usage messages in normal blue.

    Color syntax highlighting is turned on by default in cmaple for Linux and OS/X if the terminal you are using (as specified by the TERM environment variable) is known to support it. It is currently turned off by default under Windows. It can be explicitly turned on or off for 2D and message output using interface(ansi=) where is true or false (under Windows, you can put interface(ansi=true) in your maple.ini file to automatically turn it on). Likewise, interface(ansilprint=) controls highlighting for 1D output (such as that produced by lprint), and interface(ansiedit=) for input.

    Not all terminals support all possible highlighting modes. The following two commands show what colors your terminal can display, and how they are used by Maple's syntax highlighting:

    > interface(showtermcolors):
    
    ANSI X3.64 Standard Attributes
    
    Normal  Bold  Italic  Underlined  Reverse  
    
    System Colors (0-15) Using ANSI Escape Sequences
    
    Color00  Color01  Color02  Color03  Color04  Color05  Color06  Color07  
    Color08  Color09  Color10  Color11  Color12  Color13  Color14  Color15  
    
    System Colors (0-15) Using Extended Escape Sequences
    
      0    0    1    1    2    2    3    3    4    4    5    5    6    6    7    7  
      8    8    9    9   10   10   11   11   12   12   13   13   14   14   15   15  
    
    Extended 6x6x6 Color Cube (16-231)
    
     16   16   17   17   18   18   19   19   20   20   21   21  
     22   22   23   23   24   24   25   25   26   26   27   27  
     28   28   29   29   30   30   31   31   32   32   33   33  
     34   34   35   35   36   36   37   37   38   38   39   39  
     40   40   41   41   42   42   43   43   44   44   45   45  
     46   46   47   47   48   48   49   49   50   50   51   51  
    
     52   52   53   53   54   54   55   55   56   56   57   57  
     58   58   59   59   60   60   61   61   62   62   63   63  
     64   64   65   65   66   66   67   67   68   68   69   69  
     70   70   71   71   72   72   73   73   74   74   75   75  
     76   76   77   77   78   78   79   79   80   80   81   81  
     82   82   83   83   84   84   85   85   86   86   87   87  
    
     88   88   89   89   90   90   91   91   92   92   93   93  
     94   94   95   95   96   96   97   97   98   98   99   99  
    100  100  101  101  102  102  103  103  104  104  105  105  
    106  106  107  107  108  108  109  109  110  110  111  111  
    112  112  113  113  114  114  115  115  116  116  117  117  
    118  118  119  119  120  120  121  121  122  122  123  123  
    
    124  124  125  125  126  126  127  127  128  128  129  129  
    130  130  131  131  132  132  133  133  134  134  135  135  
    136  136  137  137  138  138  139  139  140  140  141  141  
    142  142  143  143  144  144  145  145  146  146  147  147  
    148  148  149  149  150  150  151  151  152  152  153  153  
    154  154  155  155  156  156  157  157  158  158  159  159  
    
    160  160  161  161  162  162  163  163  164  164  165  165  
    166  166  167  167  168  168  169  169  170  170  171  171  
    172  172  173  173  174  174  175  175  176  176  177  177  
    178  178  179  179  180  180  181  181  182  182  183  183  
    184  184  185  185  186  186  187  187  188  188  189  189  
    190  190  191  191  192  192  193  193  194  194  195  195  
    
    196  196  197  197  198  198  199  199  200  200  201  201  
    202  202  203  203  204  204  205  205  206  206  207  207  
    208  208  209  209  210  210  211  211  212  212  213  213  
    214  214  215  215  216  216  217  217  218  218  219  219  
    220  220  221  221  222  222  223  223  224  224  225  225  
    226  226  227  227  228  228  229  229  230  230  231  231  
    
    Extended 24-Level Grayscale (232-255)
    
    232  232  233  233  234  234  235  235  236  236  237  237  238  238  239  239  
    240  240  241  241  242  242  243  243  244  244  245  245  246  246  247  247  
    248  248  249  249  250  250  251  251  252  252  253  253  254  254  255  255  
    

    If your terminal does not support 256 color mode, then many of the colored blocks shown above will appear differently or not at all.

    > interface(showcolors):
    
     1 Normal output:           evalf(1/2) = 0.5
     2 Italics (variables):     x, y, z
     3 Symbol text (not used):  symbol
     4 Bold (fallback):         Begin, be bold, and venture to be wise.
     5 Underlined (fallback):   Morality, like art, means drawing a line someplace.
     6 Reversed (not used):      The reverse side also has a reverse side. 
     7 Input prompts:           >  DBG>
     8 User input:              1/(x^4+1);
     9 Userinfo output:         message, x, y
    10 Trace output:            {--> enter f, args = x, y
    11 Warning messages:        Warning, x is implicitly declared local
    12 Error messages:          Error, (in f) invalid subscript selector
    13 Debugger output:         No breakpoints set
    14 General Maple keywords:  for  from  to  while  do  until
    15 Declaration keywords:    local  option  description
    16 Flow interruptions:      break  return
    17 Exception keywords:      error  try  catch
    18 Subexpression labels:    %1  %2
    19 Special & quoted names:  thisproc  `diff/sin`
    20 String literals:         "Hello, world!"
    21 Maple startup message:   Maple 2019
    22 Output from printf:      x=1.234 y=5.678
    23 Status messages:         memory used=1.7MB, alloc=8.3MB, time=0.03
    24 System command output:   1466  4739  43140  myprog.mpl
    25 Maple comments:          # Comments are free but facts are sacred.
    

    The colors used for the different categories of output as listed by the command above are user selectable. The default is to use only the sixteen ANSI X3.64 standard colors (or Windows command prompt standard colors). These may appear differently than shown here depending on the color palette of your terminal window.

    The color settings can be queried or set as follows:

    > currentColors := interface(ansicolor);
    currentColors := [-1, -1, -1, -1, -1, -1, 2, -1, 2, 3, 11, 9, 6, 12, 10, 13, 9, 14, 6,
    
        5, 2, 136, 4, 134, 3]
    
    # Individual colours, as numbered in the output of interface(showcolors), can
    # be changed. Let's make keywords bright yellow:
    > myColors := subsop(14=226,currentColors);
    myColors := [-1, -1, -1, -1, -1, -1, 2, -1, 2, 3, 11, 9, 6, 226, 10, 13, 9, 14, 6, 5,
    
        2, 136, 4, 134, 3]
    
    > interface(ansicolor=myColors);
    [-1, -1, -1, -1, -1, -1, 2, -1, 2, 3, 11, 9, 6, 12, 10, 13, 9, 14, 6, 5, 2, 136, 4,
    
        134, 3]
    
    > piecewise(4 < x^2 and x < 8, f(x));
                                {                  2
                                { f(x)        4 < x  and x < 8
                                {
                                {  0             otherwise

    There are several predefined color schemes that can be selected using interface(ansicolor=), where is an integer from 0 to 6. Scheme 0, the default, should work on any terminal. Of the remaining schemes, the odd numbered ones are designed to look good on light backgrounds, and the even numbered ones on dark backgrounds.

    There is also a new character plot driver, selectable using interface(plotdevice=colorchar), which supports character plotting in color. Colors are mapped to the nearest color supported by the terminal:

    > interface(plotdevice=colorchar):
    > p1 := plot(sin(x),x=-Pi..Pi,thickness=1,color="DeepPink"):
    > p2 := plot(sin(x)+sin(3*x)/3,x=-Pi..Pi,thickness=2,color="LawnGreen"):
    > p3 := plot(sin(x)+sin(5*x)/5,x=-Pi..Pi,thickness=3,color="DodgerBlue"):
    > plots[display](p1,p2,p3);
    
                                                                                           
                                               |                                           
                                               |                  @@@@@                    
                                               |                 @@   @@                   
                                               |                 @     @                   
                                             1 |                *.......*                  
                                               |       *******.*@       @*..******         
                                               |      **    .**@         @**.    **        
                                               |     **   ..  ***       ***  ..   **       
                                               |    **   ..  @@ **** **** @@  ..   **      
                                               |    *   ..  @@     ***     @@  ..   *      
                                               |   *@@@**@@@                 @@@**@@@*     
                                           0.5 |  **@ ..                         .. @**    
                                               |  *@ ..                           .. @*    
                                               | ** .                               . **   
                                               | * .                                 . *   
                                               |**..                                 ..**  
                                               |*..                                   ..*  
                                               |*.                                     .*  
                                               *.                                       .* 
     **---------------------------------------**-----------------------------------------* 
      -3           -2            -1          0*|            1             2            3   
      *..                                   ..*|                                           
      **..                                 ..**|                                           
       * .                                 . * |                                           
       ** ..                              . ** |                                           
        *@ ..                           .. @*  |                                           
        **@ ..                         .. -0.5 |                                           
         *@@@**@@@                 @@@**@@@*   |                                           
          *   ..  @@     ***     @@  ..   *    |                                           
          **   ..  @@ **** **** @@  ..   **    |                                           
           **   ..  @**       **@  ..   **     |                                           
            **    .**@         @**.    **      |                                           
             *******.*@       @*.*******       |                                           
                      *.......*             -1 |                                           
                       @     @                 |                                           
                       @@   @@                 |                                           
                        @@@@@                  |                                           
                                               |                                           
                                                                                           
    
    > plot3d([1,x,y],x=0..2*Pi,y=0..2*Pi,coords=toroidal(10));
    
                                                                                           
                                      -------------------                                  
                                 --------\\\-|-|-|-///--------                             
                              ---------\\\-\-|-|-|-/-///---------                          
                            ----------\\\-\-||-|-||-/-///----------                        
                          /-/-/-/-----\\\\\-|||||-|-/////------------                      
                         -//-/-/-/---\-\\-\||-|||-||/-//-/---\-\-\-\--                     
                       --//-|||-/-/--\\\\\\|||||||-|//////--\-\-|||\|\-\                   
                      /---||-||||-|--\\-\\\|||||||||///-//--|-||||--|---\                  
                     /--|--\-\-\-\\--\\/\\|||||||||||//-//-|-///-/-/--|--\                 
                    //-//--\\-\-----\-\\\\|||||||||||////-///////-//--\\-\\                
                    |//\/\------------\\\|||||||||||||////-------//--/\\\\|                
                   /// / / -- /--- -----\|||||||||||||/---------\ --/\ \\\\\               
                   //\/ /-//-/-//-//-/--/-/--/-|-\--\-\--\-\\-\\-\-\\/\ \/\\               
                   ///\/ /--/ //-// /--/--/-|--|--|-\--\--\ \\-\\ \--\ \/\\\               
                   /||/-// /--/  /--/-//-|  |  |  |  |-\\-\--\  \\-\ \\/\||\               
                   || |-/ /  /--/  /  | -|--|--|--|--|- |  \ -\--\  \ \/| |||              
                  |||| | -/ /  ||--/-||- |  |  |  |  | -||--\  | \\-\- | |/|               
                   |||-| | -/--|  |  |  -|--|--|--|---|  |  |  |--\  | |/|||               
                   |\| |-|  | ||--|- |  |   |  |  |   |  | -|--|| |  |-- |/|               
                   |\||  |-|  |  |  -|--|---|--|---|--|--|-  |  |  |-|  ||/|               
                   \|-| |  |--|- |   |  |  |   |   |  |  |   | -|--| |  |/|/               
                    \||-|- |  |--|--|-  |  |   |   |  |  -|--|--|  | -|-||/                
                    \|-|||-|- |  |  | --|--|---|---|--|-- |  |  |  |-|||/|/                
                     \\|-| |--|--|  |   |  |   |   |  |   |  |--|--| |-|//                 
                      \\ |-|  |  |--|---|  |   |   |  |---|--|  |  |-| //                  
                       -\| |--|  |  |   |--|---|---|--|   |  |  |--| |//                   
                         \|-| |--|--|   |  |   |   |  |   |--|--| |-|/                     
                          \\|\|| |  |---|--|---|---|--|---|  | ||-|//                      
                            -\----|--|  |  |   |   |  |  |--|----/-                        
                              --\-\\ |--|--||--|---|--|--|  /-/--                          
                                 ----\\-||--|--|--|---|--///--                             
                                      \--\--|--|--|--/--/                                  
                                                                                           
    

    For more details, please refer to the help page, ?ansicolor.

    Hi MaplePrimes Users!

    It’s your friendly, neighborhood tech support team; here to share some tips and tricks from issues we help users with on a daily basis.

    A customer contacted us through a Help Page feedback form, asking how to add a row or column in a Matrix. The form came from the Row Operations help page, but the wording of the message suggested that the customer actually wanted to insert a new row or column altogether. Such manipulations can often be accomplished by a command in the ArrayTools package, but the only Insert command currently available is the one for Vectors and 1-D Arrays. Using the Concatenate command from that package, and various commands from the LinearAlgebra package (including the SubMatrix command), we were able to write two custom procedures to perform these manipulations:

    InsertRow := proc (A::rtable, n::integer, v::Vector[row])
        local R, C, top, bottom;
        uses LinearAlgebra;
        R := RowDimension(A); C := ColumnDimension(A);
        top := SubMatrix(A, [1 .. n-1], [1 .. C]);
        bottom := SubMatrix(A, [n .. R], [1 .. C]);
        return ArrayTools:-Concatenate(1, top, v, bottom);
    end proc:
    
    InsertColumn := proc (A::rtable, n::integer, v::Vector[column])
        local R, C, left, right;
        uses LinearAlgebra;
        R := RowDimension(A); C := ColumnDimension(A);
        left := SubMatrix(A, [1 .. R], [1 .. n-1]);
        right := SubMatrix(A, [1 .. R], [n .. C]);
        return ArrayTools:-Concatenate(2, left, v, right)
    end proc:
    
    # test cases:
    
    M := Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]):
    v := Vector[row]([2, 2, 2]):
    v2 := Vector[column]([2, 2, 2]):
    seq(InsertRow(M, i, v), i = 1 .. 4);
    seq(InsertColumn(M, i, v2), i = 1 .. 4);

    We then reworked this problem using some handy indexing and construction notation that allows our previous procedures to save on the variable constructions and syntax:

    InsertRow := proc( A :: rtable, V :: Vector[row], r :: posint )
        return < A[1..r-1,..]; V; A[r..-1,..] >:
    end proc:
    
    InsertColumn := proc( A :: rtable, V :: Vector[column], c :: posint )
        return < A[..,1..c-1] | V | A[..,c..-1] >:
    end proc:
    
    M := Matrix(3, 3, [seq(i, i = 1 .. 9)]);
    A := convert(M, Array);
    U := Vector[row]( [ a, b, c ] );
    V := convert( U, 'Vector[column]' );
    seq(InsertRow( A, U, i ), i=1..4);
    seq(InsertColumn( A, V, i ), i=1..4);
    seq(InsertRow( M, U, i ), i=1..4);
    seq(InsertColumn( M, V, i ), i=1..4);

    In order to explore the use of signal processing package in image processing, @Samir Khan and I created this application that performs discrete Haar wavelet transform on images to achieve both lossy (irreversible) and lossless (reversible) compression.

    Haar wavelet compression modifies the image matrix to increase the number of zero entries in the matrix, which results in a sparse matrix that can be stored more efficiently, thus reducing the file size. A Haar wavelet transform groups adjacent items in the matrix, stores the average and difference of the two numbers. Notice that this computation is reversible since knowing the values of a, b and given that x1-x2 = a; (x1+x2)/2 = b, we can solve for x1 and x2. Haar wavelet compression is taking advantage of the property that neighboring pixels in an image usually share very similar value; hence recursively applying Haar wavelet transform to the rows and columns of an image matrix significantly increases the number of zero entries. In the application we achieved a compression ratio of 1.296 (number of non-zero entries in original: number of non-zero entries in processed matrix).

    The fact that Haar wavelet transform is reversible means that we can use it to perform lossless image compression: the decompressed image will be exactly the same as the image before compression. Transmission and temporary storage of the data would be made more efficient without any loss of details in the image.

    But what if the file size is still too big or we simply don’t need that many details in the image? That is when lossy compression comes into use. By omitting some details/fidelity, lossy compression is able to achieve notably smaller file size. In this application, we apply a filter to the transformed image matrix, setting entries that are close to zeros to actual zeros (i.e. pick a positive number ϵ such that all x < ϵ are changed to 0 in the matrix). The value of ϵ directly impacts the quality of the decompressed image so should be chosen carefully in practice. In this application, we chose ϵ = 0.01, which results in a compression ratio of 19.38, but instead produces a very blurry image after reversing the compression.

    (left: Original image, right: lossy compression with ϵ = 0.01)

    The application can be accessed here for more details.


     

    For Maple 2018.1, there are improvements in pdsolve's ability to solve PDE with boundary and initial conditions. This is work done together with E.S. Cheb-Terrab. The improvements include an extended ability to solve problems involving non-homogeneous PDE and/or non-homogeneous boundary and initial conditions, as well as improved simplification of solutions and better handling of functions such as piecewise in the arguments and in the processing of solutions. This is also an ongoing project, with updates being distributed regularly within the Physics Updates.

    Solving more problems involving non-homogeneous PDE and/or non-homogeneous boundary and initial conditions

     

     

    Example 1: Pinchover and Rubinstein's exercise 6.17: we have a non-homogenous PDE and boundary and initial conditions that are also non-homogeneous:

    pde__1 := diff(u(x, t), t)-(diff(u(x, t), x, x)) = 1+x*cos(t)
    iv__1 := (D[1](u))(0, t) = sin(t), (D[1](u))(1, t) = sin(t), u(x, 0) = 1+cos(2*Pi*x)

    pdsolve([pde__1, iv__1])

    u(x, t) = 1+cos(2*Pi*x)*exp(-4*Pi^2*t)+t+x*sin(t)

    (1)

    How we solve the problem, step by step:

       

     

    Example 2: the PDE is homogeneous but the boundary conditions are not. We solve the problem through the same process, which means we end up solving a nonhomogeneous pde with homogeneous BC as an intermediate step:

    pde__2 := diff(u(x, t), t) = 13*(diff(u(x, t), x, x))
    iv__2 := (D[1](u))(0, t) = 0, (D[1](u))(1, t) = 1, u(x, 0) = (1/2)*x^2+x

    pdsolve([pde__2, iv__2])

    u(x, t) = 1/2+Sum(2*(-1+(-1)^n)*cos(n*Pi*x)*exp(-13*Pi^2*n^2*t)/(Pi^2*n^2), n = 1 .. infinity)+13*t+(1/2)*x^2

    (12)

    How we solve the problem, step by step:

       

     

    Example 3: a wave PDE with a source that does not depend on time:

    pde__3 := (diff(u(x, t), x, x))*a^2+1 = diff(u(x, t), t, t)
    iv__3 := u(0, t) = 0, u(L, t) = 0, u(x, 0) = f(x), (D[2](u))(x, 0) = g(x)

    `assuming`([pdsolve([pde__3, iv__3])], [L > 0])

    u(x, t) = (1/2)*(2*(Sum(sin(n*Pi*x/L)*(2*L*(Int(sin(n*Pi*x/L)*g(x), x = 0 .. L))*sin(a*Pi*t*n/L)*a-Pi*(Int(sin(n*Pi*x/L)*(-2*f(x)*a^2+L*x-x^2), x = 0 .. L))*cos(a*Pi*t*n/L)*n)/(Pi*n*a^2*L), n = 1 .. infinity))*a^2+L*x-x^2)/a^2

    (23)

    How we solve the problem, step by step:

       

     

    Example 4: Pinchover and Rubinstein's exercise 6.23 - we have a non-homogenous PDE and initial condition:

    pde__4 := diff(u(x, t), t)-(diff(u(x, t), x, x)) = g(x, t)
    iv__4 := (D[1](u))(0, t) = 0, (D[1](u))(1, t) = 0, u(x, 0) = f(x)

    pdsolve([pde__4, iv__4], u(x, t))

    u(x, t) = Int(f(tau1), tau1 = 0 .. 1)+Sum(2*(Int(f(tau1)*cos(n*Pi*tau1), tau1 = 0 .. 1))*cos(n*Pi*x)*exp(-Pi^2*n^2*t), n = 1 .. infinity)+Int(Int(g(x, tau1), x = 0 .. 1)+Sum(2*(Int(g(x, tau1)*cos(n1*Pi*x), x = 0 .. 1))*cos(n1*Pi*x)*exp(-Pi^2*n1^2*(t-tau1)), n1 = 1 .. infinity), tau1 = 0 .. t)

    (30)

    If we now make the functions f and g into specific mappings, we can compare pdsolve's solutions to the general and specific problems:

    f := proc (x) options operator, arrow; 3*cos(42*x*Pi) end proc
    g := proc (x, t) options operator, arrow; exp(3*t)*cos(17*x*Pi) end proc

     

    Here is what pdsolve's solution to the general problem looks like when taking into account the new values of f(x) and g(x,t):

    value(simplify(evalindets(u(x, t) = Int(f(tau1), tau1 = 0 .. 1)+Sum(2*(Int(f(tau1)*cos(n*Pi*tau1), tau1 = 0 .. 1))*cos(n*Pi*x)*exp(-Pi^2*n^2*t), n = 1 .. infinity)+Int(Int(g(x, tau1), x = 0 .. 1)+Sum(2*(Int(g(x, tau1)*cos(n1*Pi*x), x = 0 .. 1))*cos(n1*Pi*x)*exp(-Pi^2*n1^2*(t-tau1)), n1 = 1 .. infinity), tau1 = 0 .. t), specfunc(Int), proc (u) options operator, arrow; `PDEtools/int`(op(u), AllSolutions) end proc)))

    u(x, t) = 3*cos(42*Pi*x)*exp(-1764*Pi^2*t)+cos(Pi*x)*(65536*cos(Pi*x)^16-278528*cos(Pi*x)^14+487424*cos(Pi*x)^12-452608*cos(Pi*x)^10+239360*cos(Pi*x)^8-71808*cos(Pi*x)^6+11424*cos(Pi*x)^4-816*cos(Pi*x)^2+17)*(exp(289*Pi^2*t+3*t)-1)*exp(-289*Pi^2*t)/(289*Pi^2+3)

    (31)

     

    Here is pdsolve's solution to the specific problem:

    pdsolve([pde__4, iv__4], u(x, t))

    u(x, t) = ((867*Pi^2+9)*cos(42*Pi*x)*exp(-1764*Pi^2*t)+cos(17*Pi*x)*(exp(3*t)-exp(-289*Pi^2*t)))/(289*Pi^2+3)

    (32)

     

    And the two solutions are equal:

    simplify(combine((u(x, t) = 3*cos(42*x*Pi)*exp(-1764*Pi^2*t)+cos(x*Pi)*(65536*cos(x*Pi)^16-278528*cos(x*Pi)^14+487424*cos(x*Pi)^12-452608*cos(x*Pi)^10+239360*cos(x*Pi)^8-71808*cos(x*Pi)^6+11424*cos(x*Pi)^4-816*cos(x*Pi)^2+17)*(exp(289*Pi^2*t+3*t)-1)*exp(-289*Pi^2*t)/(289*Pi^2+3))-(u(x, t) = ((867*Pi^2+9)*cos(42*x*Pi)*exp(-1764*Pi^2*t)+cos(17*x*Pi)*(exp(3*t)-exp(-289*Pi^2*t)))/(289*Pi^2+3)), trig))

    0 = 0

    (33)

    f := 'f'; g := 'g'

     

    Improved simplification in integrals, piecewise functions, and sums in the solutions returned by pdsolve

     

     

    Example 1: exercise 6.21 from Pinchover and Rubinstein is a non-homogeneous heat problem. Its solution used to include unevaluated integrals and sums, but is now returned in a significantly simpler format.

    pde__5 := diff(u(x, t), t)-(diff(u(x, t), x, x)) = t*cos(2001*x)
    iv__5 := (D[1](u))(0, t) = 0, (D[1](u))(Pi, t) = 0, u(x, 0) = Pi*cos(2*x)

    pdsolve([pde__5, iv__5])

    u(x, t) = (1/16032024008001)*(4004001*t+exp(-4004001*t)-1)*cos(2001*x)+Pi*cos(2*x)*exp(-4*t)

    (34)

    pdetest(%, [pde__5, iv__5])

    [0, 0, 0, 0]

    (35)

     

    Example 2: example 6.46 from Pinchover and Rubinstein is a non-homogeneous heat equation with non-homogeneous boundary and initial conditions. Its solution used to involve two separate sums with unevaluated integrals, but is now returned with only one sum and unevaluated integral.

    pde__6 := diff(u(x, t), t)-(diff(u(x, t), x, x)) = exp(-t)*sin(3*x)
    iv__6 := u(0, t) = 0, u(Pi, t) = 1, u(x, 0) = phi(x)

    pdsolve([pde__6, iv__6], u(x, t))

    u(x, t) = (1/8)*(8*(Sum(2*(Int(-(-phi(x)*Pi+x)*sin(n*x), x = 0 .. Pi))*sin(n*x)*exp(-n^2*t)/Pi^2, n = 1 .. infinity))*Pi-Pi*(exp(-9*t)-exp(-t))*sin(3*x)+8*x)/Pi

    (36)

    pdetest(%, [pde__6, iv__6])

    [0, 0, 0, (-phi(x)*Pi^2+Pi*x+2*(Sum((Int(-(-phi(x)*Pi+x)*sin(n*x), x = 0 .. Pi))*sin(n*x), n = 1 .. infinity)))/Pi^2]

    (37)

     

    More accuracy when returning series solutions that have exceptions for certain values of the summation index or a parameter

     

     

    Example 1: the answer to this problem was previously given with n = 0 .. infinity instead of n = 1 .. infinity as it should be:

    pde__7 := diff(v(x, t), t, t)-(diff(v(x, t), x, x))

    iv__7 := v(0, t) = 0, v(x, 0) = -(exp(2)*x-exp(x+1)-x+exp(1-x))/(exp(2)-1), (D[2](v))(x, 0) = 1+(exp(2)*x-exp(x+1)-x+exp(1-x))/(exp(2)-1), v(1, t) = 0

    pdsolve([pde__7, iv__7])

    v(x, t) = Sum(-2*sin(n*Pi*x)*((Pi^2*(-1)^n*n^2-Pi^2*n^2+2*(-1)^n-1)*sin(Pi*t*n)-(-1)^n*cos(Pi*t*n)*Pi*n)/(Pi^2*n^2*(Pi^2*n^2+1)), n = 1 .. infinity)

    (38)

     

    Example 2: the answer to exercise 6.25 from Pinchover and Rubinstein is now given in a much simpler format, with the special limit case for w = 0 calculated separately:

    pde__8 := diff(u(x, t), t) = k*(diff(u(x, t), x, x))+cos(w*t)
    iv__8 := (D[1](u))(L, t) = 0, (D[1](u))(0, t) = 0, u(x, 0) = x

    `assuming`([pdsolve([pde__8, iv__8], u(x, t))], [L > 0])

    u(x, t) = piecewise(w = 0, (1/2)*L+Sum(2*L*(-1+(-1)^n)*cos(n*Pi*x/L)*exp(-Pi^2*n^2*k*t/L^2)/(n^2*Pi^2), n = 1 .. infinity)+t, (1/2)*(L*w+2*(Sum(2*L*(-1+(-1)^n)*cos(n*Pi*x/L)*exp(-Pi^2*n^2*k*t/L^2)/(n^2*Pi^2), n = 1 .. infinity))*w+2*sin(w*t))/w)

    (39)

     

    Improved handling of piecewise, eval/diff in the given problem

     

     

    Example 1: this problem, which contains a piecewise function in the initial condition, can now be solved:

    pde__9 := diff(f(x, t), t) = diff(f(x, t), x, x)
    iv__9 := f(0, t) = 0, f(1, t) = 1, f(x, 0) = piecewise(x = 0, 0, 1)

    pdsolve([pde__9, iv__9])

    f(x, t) = Sum(2*sin(n*Pi*x)*exp(-Pi^2*n^2*t)/(n*Pi), n = 1 .. infinity)+x

    (40)

     

    Example 2: this problem, which contains a derivative written using eval/diff, can now be solved:

    pde__10 := -(diff(u(x, t), t, t))-(diff(u(x, t), x, x))+u(x, t) = 2*exp(-t)*(x-(1/2)*x^2+(1/2)*t-1)

    iv__10 := u(x, 0) = x^2-2*x, u(x, 1) = u(x, 1/2)+((1/2)*x^2-x)*exp(-1)-((3/4)*x^2-(3/2)*x)*exp(-1/2), u(0, t) = 0, eval(diff(u(x, t), x), {x = 1}) = 0

    pdsolve([pde__10, iv__10], u(x, t))

    u(x, t) = -(1/2)*exp(-t)*x*(x-2)*(t-2)

    (41)

     

    References:

     

    Pinchover, Y. and Rubinstein, J.. An Introduction to Partial Differential Equations. Cambridge UP, 2005.


     

    Download What_is_New_after_Maple_2018.mw

    Katherina von Bülow

    First 47 48 49 50 51 52 53 Last Page 49 of 308