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
  • Maple 2015 has a new command, dataplot, for plotting datasets. It was designed to be easy to use and it offers several new features that are not available in Maple's other plotting commands. A few months ago, I recorded a video that gives an overview of the command. If you have any questions or comments about dataplot, feel free to post here. I'm also including the worksheet that is shown in the video: DataplotWebinar.mw

    Maple’s Code Generation makes it possible to translate your Maple code to various other programming languages including C, Python, and several others. In Maple 2015, we added a new Code Generation target to one of my other personal favourite languages, R. R is a programming language designed for statistical computing and graphics, so no code translation from Maple to R would be complete without attempting to translate as many commands as possible from Maple’s Statistics package. 

    Translating code from one language to another is tricky business. Maple 2015 represented the first time that any Code Generation target language added the ability to translate commands from the Statistics package. With R, we found that many common statistics commands had almost a one-to-one mapping, such as Statistics:-Mean = mean, but several others were much more complicated, including several commands for dealing with probability functions that did not have direct mappings due to differences in how the systems handle symbolic probability functions.

    A list of statistics commands that can be translated from Maple to R can be found here.

    In addition to assisting me recall the correct syntax in R, having worked with CodeGeneration[R] for several months now, I find that one of my most common uses for Maple’s code generation to R is simply to pass data between the systems. A simple example:

     CodeGeneration:-R( LinearAlgebra:-RandomMatrix( 5, 2 ) );

    translates to the following in R:

     cg <- matrix(c(-4,27,8,69,99,29,44,92,-31,67),nrow=5,ncol=2)

    To see a couple more short examples, here’s a short video that I recorded on Code Generation to R:

    A little known fact about Code Generation is that the translation files can be viewed in from the “samples” directory in your Maple install directory. Similar to many of Maple’s packages, you can view all of the source code that Code Generation uses for its translations. For example, you can view the translations for the commands that I mentioned above from the “FunctionTable.mm” file inside of your “%MapleInstallDir%/ samples/CodeGeneration/R” directory.

    Should you have any feedback on this translation, or any other, please feel free to contact us. We’re also on the hunt for our next code generation targets, so let us know what other languages you would like to see added as Code Generation targets.

    A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

    Before I begin, a quick note that the content below was primarily created by one of our summer interns, Pia, with guidance and advice from me.

    MaplePrimes member Thomas Dean wanted 1/2*x^(1/2) + 1/13*x^(1/3) + 1/26*x^(45/37)  to become  0.5*x^0.500000 + 0.07692307692*x^0.333333 + 0.03846153846*x^1.216216216  using the evalf command.

    Here you can see the piece of code that Thomas Dean wrote in Maple:

    eq:=1/2*x^(1/2) + 1/13*x^(1/3) + 1/26*x^(45/37);
    evalf(eq);

    Carl Love replied simply and effectively with a piece of code, using the evalindets command instead:

    evalindets(eq, fraction, evalf);

    As always, Love provided an accurate response, and it is absolutely correct. But for those just learning Maple, I wanted to provide some additional explanation.

    The evalindets command, evalindets( expr, atype, transformer, rest ), is a particular combination of calls to eval and indets that allows you to efficiently transform all subexpressions of a given type by some algorithm. It encapsulates a common "pattern" used in expression manipulation and transformation.

    Each subexpression of type atype is transformed by the supplied transformer procedure. Then, each subexpression is replaced in the original expression, using eval, with the corresponding transformed expression.

     

    Note: the parameter restis an optional expression sequence of extra arguments to be passed to transformer. In this example it was not used.

    I hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let me know. 

    I happen to just have a look at mathematica's imagedeconvolve function http://reference.wolfram.com/language/ref/ImageDeconvolve.html .  I had a look at the Examples and saw how a very blurred image of Neil Armstrong standing on the moon with the lunar lander was deconvolved into some really amazing detail. 

    I don't believe that image could deconvolve into what they show on that page, It's somewhat misleading.

    The only way that deconvolved image could have such great detail is the blurred image used was most likely convolved from the detailed image.  

    Here the potential of maple 2015 to the quantitative study of the decomposition of a vector table is shown in two dimensions. Application for the exclusive use of engineering students, which was implemented with embedded components.

    Atte.

    Lenin Araujo Castillo

    Archivo Corregido:  Decomposición_Vectorial_Corregido.mw

    LL_104)_NASDAQ.mw
    Portfolio_Optimization.txt

    Portfolio Optimization with Google Spreadsheet and Maple
     

    I will in this post show how to manage data and do portfolio optimization in Maple by using google spreadsheet.

    You can either use a direct link to the data:

    https://docs.google.com/spreadsheets/d/1L5-yUB0EWeBdJNMdELKBRmBQ1JJ0QymrtDLkVhHCVn8/pub?gid=649021574&single=true&output=csv

    or you can set up your own google spreadsheet. If you choice to set up your own spreedsheet follow the below road map:

    1) select which market you want to follow:

    NASDAQ

    http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download

    NYSE

    http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NYSE&render=download

    AMEX

    http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=AMEX&render=download


    2) Create a new google spreadsheet and name two sheets Blad1 and Panel. In the first cell of Blad1 you put the formula:

    =IMPORTDATA("http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download")

    you need to change the url to match your selection in 1).


    3) In the first cell of Panel you put the name "Ticker" and then you copy all the ticker names from Blad1.

    4) In the script editor you put in the below java script code:


    function PanelCreation_Stock() 

    {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sourceSheet = ss.getSheetByName("Blad1");
    var dstSheet = ss.getSheetByName("Panel");
    var curDat = new Date();
    var day1 = curDat.getDay();
    if(day1 == 0 || day1 == 1)
    {
    return;
    }
    var lCol = dstSheet.getLastColumn();
    var srcdate = dstSheet.getRange(1, 1, 1, lCol).getValues();

    for(var k=1;k<=srcdate[0].length-1;k++)
    {
    if(Utilities.formatDate(srcdate[0][k],"GMT", "dd-MMM-yy") == Utilities.formatDate(curDat,"GMT", "dd-MMM-yy"))
    {
    return;
    }
    }
    var snRows = sourceSheet.getLastRow();
    var dnRows = dstSheet.getLastRow();

    var srcStock = sourceSheet.getRange("A2:A" + snRows).getValues();
    var srcLastSale = sourceSheet.getRange("C2:C" + snRows).getValues();

    var dstStock = dstSheet.getRange("A2:A" + dnRows).getValues();
    var dstLastSale = dstSheet.getRange("Z2:Z" + dnRows).getValues();

    for(var j=0;j<dnRows-1;j++)
    {
    dstLastSale[j][0]="n/a";
    }
    var flag = "true";
    var foundStock;
    for(var i=0;i<snRows-1;i++) //snRows
    {
    var sStockVal = srcStock[i][0];

    //var foundStock = ArrayLib.indexOf(dstStock,0, sStockVal);

    flag="false";
    for(var j=0;j<dnRows-1;j++)
    {
    if(dstStock[j][0].toString().toUpperCase() == srcStock[i][0].toString().toUpperCase())
    {
    flag = "true";
    foundStock = j;
    break;
    }
    }
    if(flag=="true")
    {
    dstLastSale[foundStock][0] = srcLastSale[i][0];
    }
    else
    {
    var dnRows1 = dstSheet.getLastRow()+1;
    dstSheet.getRange("A" + dnRows1).setValue(srcStock[i][0]);
    dstSheet.getRange(dnRows1,lCol+1,1,1).setValue(srcLastSale[i][0]);
    for(var k=2;k<=lCol;k++)
    {
    if(dstSheet.getRange(dnRows1, k).getValue()=="")
    {
    dstSheet.getRange(dnRows1, k).setValue("n/a");
    }
    }
    }
    }
    dstSheet.getRange(1,lCol+1).setValue(curDat);
    dstSheet.getRange(2, lCol+1, dstLastSale.length, 1).setValues(dstLastSale);
    }

     
    5) Set it to run each day at 12:00. The code will save the new last sale price for monday to friday with one days lag.

    Now we can move on to Maple.


    In Maple run the following code to load the data:

     

    X := proc (Url) local theDLL, URLDownloadToFile, myDirectory, myFile, Destination, DL;

     

    theDLL := "C:\\WINDOWS\\SYSTEM32\\urlmon.dll";

     

    URLDownloadToFile := define_external('URLDownloadToFileA', pCaller::(integer[4]), szURL::string, szFileName::string, dwReserved::(integer[4]), lpfnCB::(integer[4]), 'RETURN'::(integer[4]), LIB = theDLL);

     

    if FileTools[Exists]("C:\\mydir") = true then FileTools:-RemoveDirectory("C:\\mydir", recurse = true, forceremove = true) else end if;

     

    FileTools:-MakeDirectory("C:\\mydir");
    myDirectory := "C:\\mydir";
    myFile := "data1.csv";
    Destination := cat(myDirectory, "\\", myFile);

     

    DL := proc () local M;

     

    URLDownloadToFile(0, Url, Destination, 0, 0);
    M := ImportMatrix("C:\\mydir\\data1.csv", delimiter = ",", datatype = string);
    M := Matrix(M, datatype = anything)

     

    end proc;

     

    return DL()

     

    end proc:

     

    data := X("https://docs.google.com/spreadsheets/d/1L5-yUB0EWeBdJNMdELKBRmBQ1JJ0QymrtDLkVhHCVn8/pub?gid=649021574&single=true&output=csv");
    L := LinearAlgebra:-Transpose(data);

    If you use your own spreadsheet you need to change the url to match that spreadsheet.
    Select File -> Publish to the web in google spreadsheet

    We can now run the portfolio optimization in Maple:

    with(Statistics):
    with(ListTools):
    with(LinearAlgebra):
    with(Optimization):
    with(plots):

     

    Nr, Nc := ArrayTools:-Size(L):
    symb := L[1 .. 1, 2 .. Nc]:
    LL := L[2 .. Nr, 2 .. Nc]:
    Nr, Nc := ArrayTools:-Size(LL):

     

    # Removing stocks with missing observations
    for i to Nc do if Occurrences("n/a", convert(Column(LL, i), list)) >= 1 then AA[i] := i else AA[i] := 0 end if
    end do;

     

    DD := RemoveInRange([seq(AA[i], i = 1 .. Nc)], 0 .. 1):
    symbb := DeleteColumn(symb, DD):
    LLL := map(parse, DeleteColumn(LL, DD)):
    Nr, Nc := ArrayTools:-Size(LLL):

     

    # Calculate Return
    for j to Nc do
    for i from 2 to Nr do

     

    r[i, j] := (LLL[i, j]-LLL[i-1, j])/LLL[i-1, j]

     

    end do
    end do;

     

    RR := Matrix([seq([seq(r[i, j], j = 1 .. Nc)], i = 2 .. Nr)], datatype = float[8]);
    n, nstock := ArrayTools:-Size(RR):

     

    # Portfolio Optimization
    W := Vector(nstock, symbol = w):
    y := Vector(n, fill = 2, datatype = float[8]):
    s1 := Optimization[LSSolve]([y, RR])[2];
    Nr, Nc := ArrayTools:-Size(s1):

     

    j := 0:
    for i to Nr do if s1[i] <> 0 then j := j+1; ss1[j] := symbb[1, i] = s1[i] end if end do;

     

    Vector(j, proc (i) options operator, arrow; ss1[i] end proc);
    LineChart(s1);

     

     

     

    Here are some tips and tricks - ranging from keyboard shortcuts to the newest features - that will help you get the most out of MapleSim 2015.

    1. Quickly run your simulation by pressing F5. Similarly, toggle between the Main Window and Visualization Window by press F6.

    2. Maintaining an organized and clean model layout is made easier by using the Reroute Connections tool. Select the connection lines or components and press CTRL+D (or using the Edit menu, Reroute Connections) to have MapleSim automatically reroute the connections.

    3. While creating your MapleSim model, components and connections can be enabled or disabled by selecting the desired item(s) and using the disable/enable button (  ) or the keyboard shortcut CTRL+E.

    4. Use the Model Tree palette in MapleSim to help manage, navigate, and search a model quickly. Items within the model tree include: components, probes, parameters, and attachments. Simply select the desired view using the drop-down menu. The Model Tree palette is found under the Project tab.

    5. Automatically remove any unreferenced subsystems or custom components using the Prune Model tool. Especially useful for large models or models with multiple modifications, this tool will automatically identify and removes unused shared subsystems or custom components that appear within the Definitions tab, Components palette. The Prune Model function can be performed by clicking the Edit menu, and selecting Prune Model.

    6. Set the MapleSim’s Visualization Window to always on top by toggling the anchor button (  ) in the upper left corner of the Visualization Window.

    7. Automatically scale the model diagram to fit in the viewable area by pressing CTRL+T to gain a complete look at the model. Then return to a default zoom by pressing CTRL+0 (zero). This is also accessible using the View menu.

    8. To group components into a subsystem, select the desired components, right-click and select Create Subsystem or press CTRL+G.

    9. For quick access to get help on a particular component, right-click on it and select help. Similarly, selecting a component within the workspace and pressing F2 will bring up the help page for that component.

    10. View the Modelica code behind the visible system/subsystem/component, click Code View (  ) in the Navigation Tool bar. Then, to switch back to Diagram Mode click the icon (  ) in the Navigation Tool bar.

    11. Automatically compare two models by using the compare tool, found under the Tools menu Compare Models.

    12. Attach important files to a MapleSim model to keep content in one place. Attachments can be Maple worksheets or others such as pdfs, Excel, Word, STL files, etc. These files are found under the Project Tab, Attachments palette. Attach a file by, right-clicking the category and selecting Attach File or clicking the Edit menu Attach File.

    I hope you find these useful! Do you have any tips that you would add to this list?


    The PDE & BC project , a very nice and challenging one, also one where Maple is pioneer in all computer algebra systems, has restarted, including now also the collaboration of Katherina von Bülow.

    Recapping, the PDE & BC project started 5 years ago implementing some of the basic methods found in textbooks to match arbitrary functions and constants to given PDE boundary conditions of different kinds. At this point we aim to fill gaps, and the first one we tackled is the case of 1st order PDE that can be solved without boundary conditions in terms of an arbitrary function, and where a single boundary condition (BC) is given for the PDE unknown function, and this BC does not depend on the independent variables of the problem. It looks simple ... It can be rather tricky though. The method we implemented is a simple however ingenious use of differential invariants  to match the boundary condition.


    The resulting new code, the portion already tested, is available for download in the Maplesoft R&D webpage for Differential Equations and Mathematical Functions (the development itself is bundled within the library that contains the new developments for the Physics package, in turn within the zip linked in the webpage).


    The examples that can now be handled, although restricted in generality to "only one 1st order linear or nonlinear PDE and only one boundary condition for the unknown function itself", illustrate well how powerful it can be to use more advanced methods to tackle these tricky situations where we need to match an arbitrary function to a boundary condition.


    To illustrate the idea, consider first a linear example, among the simplest one could imagine:

    PDEtools:-declare(f(x, y, z))

    f(x, y, z)*`will now be displayed as`*f

    (1)

    pde := diff(f(x, y, z), x)+diff(f(x, y, z), y)+diff(f(x, y, z), z) = f(x, y, z)

    diff(f(x, y, z), x)+diff(f(x, y, z), y)+diff(f(x, y, z), z) = f(x, y, z)

    (2)

    Input now a boundary condition (bc) for the unknownf(x, y, z) such that this bc does not depend on the independent variables {x, y, z}; this bc can however depend on arbitrary symbolic parameters, for instance

    bc := f(alpha+beta, alpha-beta, 1) = alpha*beta

    f(alpha+beta, alpha-beta, 1) = alpha*beta

    (3)

    With the recent development, this kind of problem can now be solved in one go:

    sol := pdsolve([pde, bc])

    f(x, y, z) = (1/4)*(x-2*z+2+y)*(x-y)*exp(z-1)

    (4)

    Nice! And how do you verify this result for correctness? With pdetest , which actually also tests the solution against the boundary conditions:

    pdetest(sol, [pde, bc])

    [0, 0]

    (5)

    And what has been done to obtain the solution (4)? First the PDE was solved regardless of the boundary condition, so in general, obtaining:

    pdsolve(pde)

    f(x, y, z) = _F1(-x+y, -x+z)*exp(x)

    (6)

    In a second step, the arbitrary function _F1(-x+y, -x+z) got determined such that the boundary condition f(alpha+beta, alpha-beta, 1) = alpha*beta is matched. Concretely, the mapping _F1 is what got determined. You can see this mapping reversing the solving process in two steps. Start taking the difference between the general solution (6) and the solution (4) that matches the boundary condition

    (f(x, y, z) = _F1(-x+y, -x+z)*exp(x))-(f(x, y, z) = (1/4)*(x-2*z+2+y)*(x-y)*exp(z-1))

    0 = _F1(-x+y, -x+z)*exp(x)-(1/4)*(x-2*z+2+y)*(x-y)*exp(z-1)

    (7)

    and isolate here _F1(-x+y, -x+z)

    PDEtools:-Solve(0 = _F1(-x+y, -x+z)*exp(x)-(1/4)*(x-2*z+2+y)*(x-y)*exp(z-1), _F1(-x+y, -x+z))

    _F1(-x+y, -x+z) = (1/4)*exp(-x+z-1)*(x^2-2*x*z-y^2+2*y*z+2*x-2*y)

    (8)

    So this is the value _F1(-x+y, -x+z) that got determined. To see now the actual solving mapping _F1, that takes for arguments -x+y and -x+z and returns the right-hand side of (8), one can perform a change of variables introducing the two parameters `&tau;__1` and `&tau;__2` of the _F1 mapping:

    {tau__1 = -x+y, tau__2 = -x+z, tau__3 = z}

    {tau__1 = -x+y, tau__2 = -x+z, tau__3 = z}

    (9)

    solve({tau__1 = -x+y, tau__2 = -x+z, tau__3 = z}, {x, y, z})

    {x = -tau__2+tau__3, y = -tau__2+tau__1+tau__3, z = tau__3}

    (10)

    PDEtools:-dchange({x = -tau__2+tau__3, y = -tau__2+tau__1+tau__3, z = tau__3}, _F1(-x+y, -x+z) = (1/4)*exp(-x+z-1)*(x^2-2*x*z-y^2+2*y*z+2*x-2*y), proc (u) options operator, arrow; simplify(u, size) end proc)

    _F1(tau__1, tau__2) = -(1/4)*exp(tau__2-1)*tau__1*(tau__1-2*tau__2+2)

    (11)

    So the solving mapping _F1 is

    _F1 = unapply(rhs(_F1(tau__1, tau__2) = -(1/4)*exp(tau__2-1)*tau__1*(tau__1-2*tau__2+2)), tau__1, tau__2)

    _F1 = (proc (tau__1, tau__2) options operator, arrow; -(1/4)*exp(tau__2-1)*tau__1*(tau__1-2*tau__2+2) end proc)

    (12)

    Wow! Although this pde & bc problem really look very simple, this solution (12) is highly non-obvious, as is the way to get it just from the boundary condition f(alpha+beta, alpha-beta, 1) = alpha*beta and the solution (6) too. Let's first verify that this mapping is correct (even when we know, by construction, that it is correct). For that, apply (12) to the arguments of the arbitrary function and we should obtain (8)

    (_F1 = (proc (tau__1, tau__2) options operator, arrow; -(1/4)*exp(tau__2-1)*tau__1*(tau__1-2*tau__2+2) end proc))(-x+y, -x+z)

    _F1(-x+y, -x+z) = -(1/4)*exp(-x+z-1)*(-x+y)*(x-2*z+2+y)

    (13)

    Indeed this is equal to (8)

    normal((_F1(-x+y, -x+z) = -(1/4)*exp(-x+z-1)*(-x+y)*(x-2*z+2+y))-(_F1(-x+y, -x+z) = (1/4)*exp(-x+z-1)*(x^2-2*x*z-y^2+2*y*z+2*x-2*y)))

    0 = 0

    (14)

    Skipping the technical details, the key observation to compute a solving mapping is that, given a 1st order PDE where the unknown depends on k independent variables, if the boundary condition depends on k-1 arbitrary symbolic parameters alpha, beta, one can always seek a "relationship between these k-1parameters and the k-1differential invariants that enter as arguments in the arbitrary function _F1 of the solution", and get the form of the mapping _F1 from this relationship and the bc. The method works in general. Change for instance the bc (3) making its right-hand side be a sum instead of a product

    bc := f(alpha+beta, alpha-beta, 1) = alpha+beta

    f(alpha+beta, alpha-beta, 1) = alpha+beta

    (15)

    sol := pdsolve([pde, bc])

    f(x, y, z) = (x-z+1)*exp(z-1)

    (16)

    pdetest(sol, [pde, bc])

    [0, 0]

    (17)

    An interesting case happens when the boundary condition depends on less than k-1 parameters, for instance:

    bc__1 := subs(beta = alpha, bc)

    f(2*alpha, 0, 1) = 2*alpha

    (18)

    sol__1 := pdsolve([pde, bc__1])

    f(x, y, z) = ((x-z+1)*_C1+x-y)*exp(((z-1)*_C1+y)/(1+_C1))/(1+_C1)

    (19)

    As we see in this result, the additional difficulty represented by having few parameters got tackled by introducing an arbitrary constant _C1 (this is likely to evolve into something more general...)

    pdetest(sol__1, [pde, bc__1])

    [0, 0]

    (20)

    Finally, consider a nonlinear example

    PDEtools:-declare(u(x, y))

    u(x, y)*`will now be displayed as`*u

    (21)

    pde := 3*(u(x, y)-y)^2*(diff(u(x, y), x))-(diff(u(x, y), y)) = 0

    3*(u(x, y)-y)^2*(diff(u(x, y), x))-(diff(u(x, y), y)) = 0

    (22)

    Here we have 2 independent variables, so for illustration purposes use a boundary condition that depends on only one arbitrary parameter

    bc := u(0, alpha) = alpha

    u(0, alpha) = alpha

    (23)

    All looks OK, but we still have another problem: check the arbitrary function _F1 entering the general solution of pde when tackled without any boundary condition:

    pdsolve(pde)

    u(x, y) = RootOf(-y^3+3*y^2*_Z-3*y*_Z^2+_Z^3-_F1(_Z)-x)

    (24)

    Remove this RootOf to see the underlying algebraic expression

    DEtools[remove_RootOf](u(x, y) = RootOf(-y^3+3*y^2*_Z-3*y*_Z^2+_Z^3-_F1(_Z)-x))

    -y^3+3*y^2*u(x, y)-3*y*u(x, y)^2+u(x, y)^3-_F1(u(x, y))-x = 0

    (25)

    So this is a pde where the general solution is implicit, actually depending on an arbitrary function of the unknown u(x, y) The code handles this problem in the same way, just that in cases like this there may be more than one solution. For this very particular bc (23) there are actually three solutions:

    pdsolve([pde, bc])

    u(x, y) = x^(1/3)+y, u(x, y) = -(1/2)*x^(1/3)-((1/2)*I)*3^(1/2)*x^(1/3)+y, u(x, y) = -(1/2)*x^(1/3)+((1/2)*I)*3^(1/2)*x^(1/3)+y

    (26)

    Verify these three solutions against the pde and the boundary condition

    map(pdetest, [u(x, y) = x^(1/3)+y, u(x, y) = -(1/2)*x^(1/3)-((1/2)*I)*3^(1/2)*x^(1/3)+y, u(x, y) = -(1/2)*x^(1/3)+((1/2)*I)*3^(1/2)*x^(1/3)+y], [pde, bc])

    [[0, 0], [0, 0], [0, 0]]

    (27)

    :)


    Download PDEs_and_Boundary_Conditions.mw

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

    The first instalment in the Hollywood Math webinar series will be returning live this September 17th! It will be presented by Daniel Skoog, our Maple Product Manager.

    Over its storied and intriguing history, Hollywood has entertained us with many mathematical moments in film. John Nash in “A Beautiful Mind,” the brilliant janitor in “Good Will Hunting,” the number theory genius in “Pi,” and even Abbott and Costello are just a few of the Hollywood “mathematicians” that come to mind.

    During this webinar we will present a number of examples of mathematics in film, including those done capably, as well as questionable and downright “creative” treatments. See relevant, exciting examples that you can use to engage your students, or attend this webinar simply for its entertainment value. Have you ever wondered if the bus could really have jumped the gap in “Speed?” We’ve got the answer! Anyone with an interest in mathematics, especially high school and early college math educators, will be both entertained and informed by attending this webinar.

    To join us for the live presentation, click here to register.

    A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

    Before I begin, a quick note that the content below was primarily created by one of our summer interns, Pia, with guidance and advice from me.

    The Question: why is 2*cos(x)^2-1 simpler than 1-2*sin(x)^2

    The author, nm, asked why 2*cos(x)^2-1  was simpler than 1-2*sin(x)^2 according to Maple. nm wrote:

    I looked at help trying to understand why Maple thinks 2*cos(x)^2-1 is simpler than 1-2*sin(x)^2 but did not see it. I was expecting to see cos(2*x) as a result.

    Preben Alsholm answered nm’s question by recommending the use of the combine command to obtain the result he was expecting to see, as well as a further explanation on how the simplify command works. Alsholm wrote:

    Use combine to obtain what you want:
    combine(1-2*sin(x)^2);

    simplify has a general preference for cos over sin. That doesn't mean however, that it turns sin into cos at all costs:

    simplify(sin(x));
    ##Try also
    simplify(1-2*sin(x)^2,size);

    simplify doesn't necessarily get you the simplest result in the common sense of the word 'simplify'. Try as another example

    expand((x+y)^3);
    simplify(%);
    factor(%);

    As always, Alsholm provided an accurate, thoughtful response. But for those just learning Maple, I thought some additional explanation could be helpful.

    Let’s talk more about the simplify command and combine function

    The simplify command applies simplification rules to an expression. Its parameters can be any expression.

    The combine function applies transformations which combine terms in sums, products, and powers into a single term. For many functions, the transformations applied by combine are the inverse of the transformations that are applied by expand. For example, consider the well-known identity:

    sin(a + b) = sin(a) cos(b) + cos(a) sin(b)

    The combine function applies the identity from right to left, whereas the expand function does the reverse.

     

    I hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please feel free to contact me.

     


    In connection with recent developments for symbolic sequences, a number of improvements were implemented regarding symbolic differentiation, that is the computation of n^th order derivatives were n is a symbol, the simplest example being the n^th derivative of the exponential, which of course is the exponential itself. This post is about these developments, done in collaboration with Katherina von Bülow, and available for download as usual from the Maplesoft R&D web page for Differential Equations and Mathematical functions (the update itself is bundled with the official updates of the Maple Physics package).

     

    It is important to note that Maple is pioneer in having an actual implementation of symbolic differentiation, something that works for real, since several releases.  The development, however, was somewhat stuck because we were unable to compute the symbolic n^th derivative of a composite function f(g(z)). A formula for this problem is actually known, it is the Faà di Bruno formula, but, in order to implement it, first we were missing the incomplete Bell functions , that got implemented in Maple 15, nice, but then we were still missing differentiating symbolic sequences, and functions whose arguments are symbolic sequences (i.e. the number of arguments of the function is n, a symbol, of unknown value at the time of differentiating). All this got implemented now within the new MathematicalFunctions:-Sequence package, opening the door widely to these improvements in n^th differentiation.

     

    The symbolic differentiation code works as mostly all other computer algebra code, by mapping complicated problems into a composition of simpler problems all of which are tractable; what follows is then an illustration of these basic cases.

     

    Among the simplest new case that can now be handled there is that of a power where the exponent is linear in the differentiation variable. This is actually an easy problem

    (%diff = diff)(f^(alpha*z+beta), `$`(z, n))

    %diff(f^(alpha*z+beta), `$`(z, n)) = alpha^n*f^(alpha*z+beta)*ln(f)^n

    (1)

    More complicated, consider the k^th power of a generic function; the corresponding symbolic derivative can be mapped into a sum of symbolic derivatives of powers of g(z) with lower degree

    (%diff = diff)(g(z)^k, `$`(z, n))

    %diff(g(z)^k, `$`(z, n)) = k*binomial(n-k, n)*(Sum((-1)^_k1*binomial(n, _k1)*g(z)^(k-_k1)*(Diff(g(z)^_k1, [`$`(z, n)]))/(k-_k1), _k1 = 0 .. n))

    (2)

    In some cases where g(z) is a known function, the computation can be carried on furthermore. For example, for g = ln the result can be expressed using Stirling numbers of the first kind

    (%diff = diff)(ln(alpha*z+beta)^k, `$`(z, n))

    %diff(ln(alpha*z+beta)^k, `$`(z, n)) = alpha^n*(Sum(pochhammer(k-_k1+1, _k1)*Stirling1(n, _k1)*ln(alpha*z+beta)^(k-_k1), _k1 = 0 .. n))/(alpha*z+beta)^n

    (3)

    The case of sin and cos are relatively simpler, but then assumptions on the exponent are required in order to proceed further ahead from (2), for example

    `assuming`([(%diff = diff)(sin(alpha*z+beta)^k, `$`(z, n))], [k::posint])

    %diff(sin(alpha*z+beta)^k, `$`(z, n)) = (-1)^k*piecewise(n = 0, (-sin(alpha*z+beta))^k, alpha^n*I^n*(Sum(binomial(k, _k1)*(2*_k1-k)^n*exp(I*(2*_k1-k)*(alpha*z+beta+(1/2)*Pi)), _k1 = 0 .. k))/2^k)

    (4)

    The case of functions of arbitrary number of variables (typical situation where symbolic sequences are required) is now handled properly. This is the pFq hypergeometric function of symbolic order p and q 

    (%diff = diff)(hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[j], j = 1 .. q)], z), `$`(z, n))

    %diff(hypergeom([`$`(a[i], i = 1 .. p)], [`$`(b[j], j = 1 .. q)], z), `$`(z, n)) = (product(pochhammer(a[i], n), i = 1 .. p))*hypergeom([`$`(a[i]+n, i = 1 .. p)], [`$`(b[j]+n, j = 1 .. q)], z)/(product(pochhammer(b[j], n), j = 1 .. q))

    (5)

    The case of the MeijerG function is more complicated, but in practice, for the computer, once it knows how to handle symbolic sequences, the more involved problem becomes computable

    (%diff = diff)(MeijerG([[`$`(a[i], i = 1 .. n)], [`$`(b[i], i = n+1 .. p)]], [[`$`(b[i], i = 1 .. m)], [`$`(b[i], i = m+1 .. q)]], z), `$`(z, k))

    %diff(MeijerG([[`$`(a[i], i = 1 .. n)], [`$`(b[i], i = n+1 .. p)]], [[`$`(b[i], i = 1 .. m)], [`$`(b[i], i = m+1 .. q)]], z), `$`(z, k)) = MeijerG([[-k, `$`(a[i]-k, i = 1 .. n)], [`$`(b[i]-k, i = n+1 .. p)]], [[`$`(b[i]-k, i = 1 .. m)], [0, `$`(b[i]-k, i = m+1 .. q)]], z)

    (6)

    Not only the mathematics of this result is correct: the object returned is actually computable to the end (if you provide the values of n, p, m and q), and the typesetting is actually fully readable, as in textbooks, including copy and paste working properly; all this is new.

    The n^th derivative of a number of mathematical functions that were not implemented before, are now also implemented, covering the gaps, for example:

    (%diff = diff)(BellB(a, z), `$`(z, n))

    %diff(BellB(a, z), `$`(z, n)) = Sum(Stirling2(a, _k1)*pochhammer(_k1-n+1, n)*z^(_k1-n), _k1 = 0 .. a)

    (7)

    (%diff = diff)(bernoulli(z), `$`(z, n))

    %diff(bernoulli(z), `$`(z, n)) = pochhammer(nu-n+1, n)*bernoulli(nu-n, z)

    (8)

    (%diff = diff)(binomial(z, m), `$`(z, n))

    %diff(binomial(z, m), `$`(z, n)) = (Sum((-1)^(_k1+m)*Stirling1(m, _k1)*pochhammer(_k1-n+1, n)*(z-m+1)^(_k1-n), _k1 = 1 .. m))/factorial(m)

    (9)

    (%diff = diff)(euler(a, z), `$`(z, n))

    %diff(euler(a, z), `$`(z, n)) = pochhammer(a-n+1, n)*euler(a-n, z)

    (10)

    In the same way the fundamental formulas for the n^th derivative of all the 12 elliptic Jacobi functions  as well as the four elliptic JacobiTheta functions,  the LambertW , LegendreP  and some others are now all implemented.

    Finally there is the "holy grail" of this problem: the n^th derivative of a composite function f(g(z)) - this always-unreachable implementation of Faa di Bruno formula. We now have it :)

    (%diff = diff)(f(g(z)), `$`(z, n))

    %diff(f(g(z)), `$`(z, n)) = Sum(((D@@k)(f))(g(z))*IncompleteBellB(n, k, `$`(diff(g(z), [`$`(z, j)]), j = 1 .. n-k+1)), k = 0 .. n)

    (11)

    Note the symbolic sequence of symbolic order derivatives of lower degree, both of of f and g, also within the arguments of the IncompleteBellB function. This is a very abstract formula ... And does this really work? Of course it does :). Consider, for instance, a case where the n^th derivatives of f(z) and g(z) can both be computed by the system:

    sin(cos(alpha*z+beta))

    sin(cos(alpha*z+beta))

    (12)

    This is the n^th derivative expressed using Faa di Bruno's formula, in turn expressed using symbolic sequences within the IncompleteBellB  function

    (%diff = diff)(sin(cos(alpha*z+beta)), `$`(z, n))

    %diff(sin(cos(alpha*z+beta)), `$`(z, n)) = Sum(sin(cos(alpha*z+beta)+(1/2)*k*Pi)*IncompleteBellB(n, k, `$`(cos(alpha*z+beta+(1/2)*j*Pi)*alpha^j, j = 1 .. n-k+1)), k = 0 .. n)

    (13)

    These results can all be verified. Take for instance n = 3

    eval(%diff(sin(cos(alpha*z+beta)), `$`(z, n)) = Sum(sin(cos(alpha*z+beta)+(1/2)*k*Pi)*IncompleteBellB(n, k, `$`(cos(alpha*z+beta+(1/2)*j*Pi)*alpha^j, j = 1 .. n-k+1)), k = 0 .. n), n = 3)

    %diff(sin(cos(alpha*z+beta)), z, z, z) = Sum(sin(cos(alpha*z+beta)+(1/2)*k*Pi)*IncompleteBellB(3, k, `$`(cos(alpha*z+beta+(1/2)*j*Pi)*alpha^j, j = 1 .. 4-k)), k = 0 .. 3)

    (14)

    Compute now the inert functions: on the left-hand side this is just the (now explicit) 3rd order derivative, while on the right-hand side we have a sum of IncompleteBellB  functions, where the number of arguments, expressed in (13) using symbolic sequences that depend on the summation index k and the differentiation order n, now in (14) depend only on k, and get transformed into explicit sequences of arguments when the summation is performed and k assumes integer values

    value(%diff(sin(cos(alpha*z+beta)), z, z, z) = Sum(sin(cos(alpha*z+beta)+(1/2)*k*Pi)*IncompleteBellB(3, k, `$`(cos(alpha*z+beta+(1/2)*j*Pi)*alpha^j, j = 1 .. 4-k)), k = 0 .. 3))

    alpha^3*sin(alpha*z+beta)*cos(cos(alpha*z+beta))-3*alpha^3*cos(alpha*z+beta)*sin(alpha*z+beta)*sin(cos(alpha*z+beta))+alpha^3*sin(alpha*z+beta)^3*cos(cos(alpha*z+beta)) = alpha^3*sin(alpha*z+beta)*cos(cos(alpha*z+beta))-3*alpha^3*cos(alpha*z+beta)*sin(alpha*z+beta)*sin(cos(alpha*z+beta))+alpha^3*sin(alpha*z+beta)^3*cos(cos(alpha*z+beta))

    (15)

    Take left-hand side minus right-hand side

    simplify((lhs-rhs)(alpha^3*sin(alpha*z+beta)*cos(cos(alpha*z+beta))-3*alpha^3*cos(alpha*z+beta)*sin(alpha*z+beta)*sin(cos(alpha*z+beta))+alpha^3*sin(alpha*z+beta)^3*cos(cos(alpha*z+beta)) = alpha^3*sin(alpha*z+beta)*cos(cos(alpha*z+beta))-3*alpha^3*cos(alpha*z+beta)*sin(alpha*z+beta)*sin(cos(alpha*z+beta))+alpha^3*sin(alpha*z+beta)^3*cos(cos(alpha*z+beta))))

    0

    (16)

    NULL

    :)


    Download SymbolicOrderDifferentiation.mw


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

    My desk was covered with papers, a glass of water, and a big shipping container. Even though my chair was there, I was sitting on the floor with my laptop, having a bad hair day, and a robot was seated next to me.  This was a typical day at Maplesoft for an engineering co-op student.

    For this project, at the request of my manager, I left my duties as Spanish translator and marketing assistant and I started to work with the robot NAO from Aldebaran Robotics. The purpose of this project was to program NAO using Aldebaran’s Choreographe software to make new movements and dances that I would later use to create new MapleSim models for Maplesoft’s Model Gallery. Maplesoft’s marketing team would then use these models in some of their promotional activities.

    Given that NAO was going to travel to Taiwan in a short period of time, I wanted to focus on doing one elaborate dance and a couple of simple movements.Thanks to F.U.N. lab from the University of Notre Dame, I was able to focus on the detailed dance because they had an amazing Choreographe database of behaviour/movement code.   

    I started this project with zero knowledge about Choreographe, but with a good understanding of NAO´s MapleSim model that the Maplesoft engineers had previously created. After a few weeks with NAO and some YouTube tutorials, I discovered that programming NAO was really easy. I would move NAO’s joints to the positions I wanted to, and then I would tap its head to record and save them. I did this for a couple of weeks making sure that the sequence of movements wouldn’t make NAO fall or break a finger. At this point I was already a NAO expert.

    After finishing up all the movements and dances it was time to move on to the next phase of the project: obtaining the data for the MapleSim model. The MapleSim model was created using the Denavit-Hartenberg (DH) convention; therefore, I needed the values of the degrees of rotation of each joint while the robot performed a dance. These numbers were easily obtained using the “record” button in Choreographe and exporting them into a CSV file. This file was later attached to the MapleSim model, so it could be used in a time look up table. The input of NAO´s joints were then specified by using the values within this table.

    I started by recording the simplest movements: NAO blowing kisses and doing the sprinkler. These were the best ones to start working on because in these examples, the robot only needs to move its upper body, meaning that the lower body didn’t need any flexibility. This gave me and Abtin Athari, Application Engineer at Maplesoft, the freedom to simplify the original model by removing unnecessary degrees of freedom on the lower body. Abtin and I also realized that at the beginning of some of the new movements the robot would have too much torque, so we extended some of the recorded position of the rotational joints so the robot could stay in the same position for a longer time. These modifications ensured that the model wouldn´t have any problems during any of the simulations.

    To finish the project, I worked with the Marketing team to create some videos where we could display the real robot next to the MapleSim model doing the same movements. The purpose of these videos was to showcase the essence of the high-fidelity models that MapleSim allowed us to create. It was amazing to see how the MapleSim model corresponded so closely to the physical robot.

    After three weeks of intense work and meetings, my days as a robot whisperer ended. I learned new things about robots, how to build models with MapleSim, and the processes behind developing videos. It was a project that allowed me to wear both an engineer’s and a marketer’s shoes.  I was able to put into practice my technical knowledge and problem solving skills; and at the same time I was able to enhance my creative and analytical skills by evaluating the quality and impact of my work.

    Philip Yasskin, a long-time Maple user and professor at Texas A&M University is passionate about getting young people engaged in mathematics. One of his programs is SEE-Math: a two-week summer day camp for gifted middle school children interested in math. Maplesoft has been a long-standing supporter of SEE-Math, providing software and prizes for the campers.

    A major project in SEE-Math is developing computer animations using Maple. Students spend their time creating various animations, in hopes of taking the top prize at the end of the workshop. A slew of animations are submitted, some with pop-culture references, elaborate plot lines, and incredible detail. The top animations take home prizes, while all animations from that year are featured on the SEE-Math website.

    Maplesoft proudly sponsors this event, and many like it, to promote interest in STEM education. To see all of the animations from this year’s SEE-Math camp, please visit: http://see-math.math.tamu.edu/2015/. You can find the animations listed under “Euler,” “Godel,” “Noether,” and “Ramanujan,” found halfway down the page.

    On this week I asked Maplesoft Customer Service for help. Here is our correspondence
    (Only the purchase code and e-mail addresses are censored. PS. Also the last name of Kari was deleted by Bryon Thur on 28.08.2015.).
    I think this is of interest for many Maple users. I have got some experience contacting
    with Kaspersky Antivirus (They helped me by the use of indices of my comp.) and ABBYYLingvo
    (They helped to install an ABBYYLingvo vocabulary on my phone.) so I can compare and
    make conclusions.


    From:
    Sent: August-15-15 4:44 AM
    To: Maplesoft Customer Service
    Subject: Customer Service Request: (Web) Installation questions

    Hello,
    After upgrading my Windows 7 HB 32-bit to Windows 10 I cannot uninstall my Maple 16 PE.
     It cannot be uninstalled by neither Start/Parameters/System/Applications nor
    Uninstall in C/ProgramFiles/Maple 16.
    The Uninstall option is not seen in Maple 16 as application.
    Also the overinstallation of Maple 16 does not work.
    Waiting for your feedback.
    Sincerely,
    Markiyan Hirnyk
    ------------------------------------------------------------------------------------------------------

    Dear Markiyan Hirnyk,

    Thank you for contacting Maplesoft.

    Maple 16 is not officially supported on Windows 10 but I have added an activation to your
    existing Maple 16 Personal Edition purchase code: XXXXXXXXXXXXXXXX to see if reactivating
    your license fixes the issue.  If reactivating doesn't give you access to Maple 16, please
    send me the exact wording of any error messages that you receive so that I can send
     the information to our Technical Support Team so that they can investigate further.

    Kind regards,

    Kari
    Maplesoft
    Customer Service
    -----------------------------------------------------------------------------------------------------------
    Hello Kari,
    Unfortunately, neither the  reactivation of my Maple 16 PE by XXXXXXXXXX nor its uninstallation
    do not succeed for me. See the error communications in the attached screens (both in one file) screens_1_2.docx.
    It should be noticed that Maple V Release 4 works on Windows 10 of my comp without any problems.
    Regards,
    Markiyan Hirnyk

    --------------------------------------------------------------------------------------------------------
    Hi Markiyan Hirnyk,

    Thanks for your response.
    I am forwarding your information to our Technical Support Team.
    A representative will contact you soon.
    Kind regards, Kari
    Maplesoft Customer Service
    ------------------------------------------------------------------------------------------------------------
    Hello Markiyan,

    This error is usually caused by a Windows permissions setting. To fix this, please do the following:

    1. Ensure that all Maple programs are completely closed.
    2. Click on your Start Menu and go to the 'Programs' > 'Maple 16' > 'Tools' folder.
    3. Right click the 'Activate Maple' icon and choose 'Run as administrator'.
    4. Activate Maple using your purchase code and this should fix your issue.

    Please let me know if you continue to experience any troubles.

    Regards,

    Chris
    Technical Support Analyst
    --------------------------------------------------------------------------------------------------------
    Hello Chris,
    Following your directions, I have just reactivated Maple 16, but my problem is not solved.
    To shed light on the situation, my Maple 16.02 works properly,
    but I cannot uninstall it after upgrading to Windows 10 Home 32bit.
    See the screens in the attached file screen.docx .
    Regards,
    Markiyan Hirnyk
    ----------------------------------------------------------------------------------------
    Hello Markiyan,
    If you are seeing error messages about Maple still being open,
     I would suggest you try to restart your PC and then attempt the uninstall again to ensure
    that you do not have any lingering Maple programs running. Please let me know
    if you still see this message after restarting.

    Regards,

    Chris
    Technical Support Analyst
    ------------------------------------------------------------------------------------------------------
    Hello Chris,
    This does not help too. My guess is execution failure when Maple 16 was installing.
    Because of that reason the Maple 16 installer did not create Maple uninstaller in my Maple 16.
     See the attached screen of the uninstall folder in C:/ Program Files/ screen_3.docx.
    Regards,
    Markiyan Hirnyk
    --------------------------------------------------------------------------------------------------------
    Hello,
    If you think that you have a corrupted installation, I recommend that you reinstall Maple
    using the new Maple 16.02 installer link provided below.
     This version of the installer was created to get around the Windows 8 installation issues and
     may be of help to you in Windows 10 as well, though again please be aware that
     we do not officially support Windows 10 yet.
    Here are the steps to reinstall Maple:
    1. Click on the Start Menu > Control Panel > Programs and Features ( or Add/Remove Programs).
     Find ‘Maple 16’ in the list and uninstall it. If this is not possible, move on to the next step and continue.
    2. Restart your computer.
    3. Click on the Start Menu > Computer > Local Disk C: > Program Files.
    If there is a folder here called ‘Maple 16’, please delete it.
    4. Download the installer for Maple 16 from the following link:
            http://www.maplesoft.com/downloads/?d=C75DEBEC838C08BB1DCCED0440B49503&pr=Maple16
    5. Make sure to download the correct version for your operating system, i.e. Windows version and 32 or 64-bit.
    6. Install Maple by right clicking the installation file and choosing ‘Run as administrator’.
    I hope that this helps to resolve the issues that you’re having and if it does not,
    contact us and we can further investigate for you.

    Regards,
    Chris
    Technical Support Analyst
    --------------------------------------------------------------------------------------------------------
     Hi Chris,
    My problem with Maple 16 is solved. I completely uninstalled it by Uninstall Tool 3.4, not using brute force. After that I installed Maple 16 by the distributive suggested by you. That's all right.
    Regards,
    Markiyan Hirnyk
    ---------------------------------------------------------------------------------------------------------
    Alright, that is good to hear. Please let us know if you run into any further issues with your installation.
    Regards,
    Chris
    Technical Support Analyst

    In addition to providing access to powerful tools for mathematical computation, Maple has been designed to help you work quickly and efficiently. Here are 10 useful short-cuts when working with Maple:

    1. Use F5 to switch between Text and 2D Math input modes in Maple.

    2. Use F2 (Control+? for Macintosh) to quickly bring up Maple Help information for anything that you have typed in your document.

    3.  Automatic Command Completion can be used when you don't want to type in the full name of a Maple command. To use, begin typing the first few letters of the command name, and press CTRL+Space (Esc or Command+Shift+Space for Macintosh, CTRL+Shift+Space for Linux).  A list of possible completions will display; click the one you want.

     

    4. The Shift+Enter key combination lets you continue entering math or commands on a new line without executing that line. 

    5. If you want more than a single command to be executed at once, you must separate them with a semi-colon or colon.

    6. When you click inside a set of commands in Math mode, the dash line indicates the boundaries of the input region; all commands in this region will execute together in sequence.

    7. To increase the size of a piecewise function, add a new row.  Place the cursor on the last row, and press CTRL+Shift+R (Command+Shift+R for Macintosh). These shortcut keys also work to add rows to matrices.

    8. An easy way to insert a Greek letter is to first press CTRL+Shift+G (Command+Shift+G for the Macintosh). The next letter typed will appear in Greek.

    9. Sometimes you may want to insert symbols above or below another character, for example, to enter a vector arrow. To insert a symbol above (called "overscript"), press CTRL+Shift+["] (Command+Shift+["] for Macintosh) and then type in your symbol (or insert it from a palette).

    For example, typing "x" then holding down CTRL+Shift and pressing ["] allows you to insert a symbol above the x, such as 

    10. Compute or recompute the entire Maple worksheet when you have changed expressions that affect subsequent Maple commands.  Press Ctrl + Shift + Enter (Command + Shift + Enter in Macintosh) or click the execute worksheet icon. 

    Are there any short-cuts that you would add to this list?

    First 73 74 75 76 77 78 79 Last Page 75 of 305