MaplePrimes Questions

Encountered new exception using odetest which can't be cought. Is this new one? I do not have earlier version of Maple than 2022.2 to check. On windows 10.

btw, I could not update to latest Physics now, may be server problem.  Attached worksheet


`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`


Error, (in Physics:-Version) unable to determine the Physics Updates version, could you please report the problem to


`The "Physics Updates" version in the MapleCloud is 1351. The version installed in this computer is 1348 created 2022, November 14, 15:59 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2022\Physics Updates\lib\`



sol:=y(x) = -LambertW(x/sin(x)*exp(c[1]/sin(x)))+c[1]/sin(x);
ode:=exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*diff(y(x),x) = 0;

y(x) = -LambertW(x*exp(c[1]/sin(x))/sin(x))+c[1]/sin(x)

exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*(diff(y(x), x)) = 0

Error, (in tools/map) too many levels of recursion

sol:=y(x) = -LambertW(x/sin(x)*exp(c[1]/sin(x)))+c[1]/sin(x);
ode:=exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*diff(y(x),x) = 0;
   print("error in odetest");
end try;

y(x) = -LambertW(x*exp(c[1]/sin(x))/sin(x))+c[1]/sin(x)

exp(y(x))+cos(x)*y(x)+(exp(y(x))*x+sin(x))*(diff(y(x), x)) = 0

Error, (in tools/map) too many levels of recursion



I do not know what to do now, since if I can't catch the exception, the program can't run anymore and just stops.

I am trying to do something which I am almost able to do but I have what seems like a final roadblock.

My goal is to be able to call procedures that dynamically update the maple initialization file (init on a Mac, located at ~/Library/Frameworks/Maple.framework/Versions/2022/lib/init).

Let's say this file starts empty.

I want to be able to use a procedure addPackageDirectoryToLibname that will remove all the contents of init and replace it with a newly constructed string. 

The newly constructed string will be libname: and then the previous libname string (which is just libname while the procedure is executing), prepended with an argument to the procedure, packageDir.

So, something like libname := MyNewDir, libname:

I also want to have a procedure removeEntryFromLibname that removes the entry in libname at the argument index.

Now I can already do all of this EXCEPT I can't remove the contents of the file init. Therefore, I am simply adding ever longer strings to init. I don't want to delete the file and recreate it, though I could do this. How do I wipe the contents of init clean programatically?

A few observations

- I had a working version of addPackageDirectoryToLibname but I realized that it was too limited (for the record, it was just adding a new line to the init file each time. The new line was something like libname := MyNewDirectory, libname:.

There is a problem that for my personal use is minor (but if this were for more widespread use I would want to fix it): if addPackageDirectoryToLibname works, you can't call it twice in a row without a restart:, because it depends on the current value of libname. After adding something to libname if you add something else, this something else will be added to the old libname, not the libname that was updated.

If you'd like to see the code I have so far, you can see it in this Github repository.

MyPackageTools := module()
    option package;

    export addPackageDirectoryToLibname, savePackageToMla;

    addPackageDirectoryToLibname := proc(packageDir)

        local mapleInitFile, newLibname:

        mapleInitFile := "/Library/Frameworks/Maple.framework/Versions/2022/lib/init":

            FileTools:-Text:-Open(mapleInitFile, 'append'):
            return "Failed to open file":

            newLibname := cat("libname := \"", packageDir, "\", libname:" ):
            FileTools:-Text:-WriteLine(mapleInitFile, newLibname):
            return "Failed to write to file.": 

            return "Added to libname successfully. Restart worksheet for changes to come into effect.":
            return "Failed to close file":

    savePackageToMla := proc(mlaPath, mplPath, packageName)


        LibraryTools:-Save(packageName, mlaPath);


I'd like to automate my workflow a bit. I having a hard time making savePackageToMla work. The commands inside it are the ones I would run in a Maple worksheet to save a package to an .mla file.

The error I get when I try to use this is

Error, (in LibraryTools:-Save) 1st variable is not a name or equation |/Users/marcusegues/maple/Packages/MyPackageTools/MyPackageTools.mpl:38|

Note that the goal is to pass in an mla path and an mpl path. The mpl file is read. The package that is read is the same as the argument packageName. 

I invoke this procedure with something like

savePackageToMla(mlaPath, mplPath, 'MyPackage')


mplPath := '/somePath/MyPackage.mpl';
mlaPath := 'somePath/MyPackage.mla';

and MyPackage.mpl contains something like

MyPackage := module()
  option package;

My question is based on this worksheet:

Consider the following procedure

myTest1 := proc()
     local s, gen;
     gen := proc()
          return 5;

     s := seq(['gen()', 'gen()', 'gen()']);
     return s;


If I call this procedure, myTest1(), the result is gen(),gen(),gen() printed out and then also returned from the procedure.

If I change local s to global s, the result changes to 5,5,5. That is, the sequence 5,5,5 is both printed and returned.


In the attached worksheet I have both cases that you can test.

Dear all

I have a function F(x,t) , I would like to get the first asymptotic approximations of this function when t goes to infinity for fixed x

But maple return 

Error, (in asympt) unable to compute series

Thank you 


Of course, I'm not talking about questioning the structure of the data itself.  This is the basic form of data manipulation in packages such as R, Julia, Python. I am asking what is the DataFrame in Maple for?
Importing a file (attachment) containing about 50,000 rows in 13 columns takes nearly 1 minute. Attempting to do any operation using DataFrame is practically impossible due to computer slowdown. (DELL XPS 17 9710, Maple 2022.2).

Whereas ImportMatrix() and matrix operations (select, remove, map, etc.) take a part of one second.

I wanted to give an example of some simple operation on the DataFrame object, but unfortunately, I lost my patience.

I have attached the file that I wanted to load for testing, which is part of the original (250K rows x 13 columns):


It's also possible that I'm doing something wrong..., then I'd like some guidance from you guys. I like the DataFrame concept in Maple. It's just about usability.



I have a problem with the graphic of arcsin((2*x)/(1+x^2)). The domain is IR

Ideas? Thanks

Is their anyway we can find the bond lengths of amolecule using maplesoft given smiles file or mol file etc. any chemistry package

Like we can do do using rdkit or pysmiles in python.

Please help me consider the convergence of this improper integral without using Maple. Thank you so much.

 About 6 years ago I aked  a question on testing types in a package. How to Test Input Typed to a Procedure to Determine what to do? - MaplePrimes.  @Carl Love supplied the very good code below. I never used the answer back then as I really didn't understand what to do with it. I have a somewhat of a better idea now and I really need to be able to use this in general..

 Basically the code checks that all the inputs are of the same type and order (which is what the original question specified).

 Q1:- I now need to check  a mixed input type

         A:: a 2 list , B a 3 list   


           A:: a 2 Vector, and B a 3 Vector.


       I tried modifying the ModuleApply part of the code at the end, but that either causes errors or kernal looses connection.

Q2:-  What is a good way to handle different numbers of inputs to procedures (exported) here eg Proc1(a), Proc2(a,b), ....,                   ProcN(a1,...,aN)

Q3:-    Would the package exports of the module be the procedures inside the Mydispatch? Or does all of MyModule sit inside                the  package module?

  I have three different packages I would like to apply this to in general.



MyModule:= module()
uses TT= TypeTools;
global _T1, _T2L, _T2V, _T3L, _T3V, _MyType;
     MyTypes:= {_T1, _T2L, _T2V, _T3L, _T3V},
     AllMyTypes:= MyTypes union {_MyType},

     ModuleLoad:= proc()
          g, #iterator over module globals
          #op([2,6], ...) of a module is its globals.
          for g in op([2,6], thismodule) do
               e:= eval(g);
               if g <> e and e in AllMyTypes then
                    error "The name %1 must be globally available.", g
               end if
          end do;
          TT:-AddType(_T1, algebraic);
          TT:-AddType(_T2V, 'Vector(2, algebraic)');
          TT:-AddType(_T2L, [algebraic $ 2]);
          TT:-AddType(_T3V, 'Vector(3, algebraic)');
          TT:-AddType(_T3L, [algebraic $ 3]);
          TT:-AddType(_MyType, MyTypes)
     end proc,

     ModuleUnload:= proc()
     local T;
          for T in AllMyTypes do TT:-RemoveType(T) end do
     end proc,

     MyDispatch:= overload([
          proc(A::_T1, B, C)
          option overload;
          local r:= "A, B, C are T1."; #unnecessary; just an example.
               #statements to process this type
          end proc,

          proc(A::_T2L, B, C)
          option overload;
          local r:= "A, B, C are T2L.";
          end proc,

          proc(A::_T2V, B, C)
          option overload;
          local r:= "A, B, C are T2V.";
          end proc,

          proc(A::_T3L, B, C)
          option overload;
          local r:= "A, B, C are T3L.";
          end proc,

          proc(A, B, C)
          local r:= "A, B, C are T3V.";
          end proc,
#I added this
          proc(A, B)
          local r:= "A, B, are mixed.";
          end proc
# I have have  added  'Or'(....(A::_T2L,B::_T3L)
     ModuleApply:= proc(
               satisfies(A-> andmap(T-> A::T implies B::T and C::T, MyTypes) )

          B::_MyType, C::_MyType
     end proc
end module:

#Example usage:


[9, 4]

[5, 7]

[1, 9]

"A, B, C are T2L."

MyModule(x,y);  #Looses kernel connection

[9, 4]

[5, 6, 7]



mpl files for sure are good for committing to a repository, especially if you are collaborating with someone in writing the code in those files. They can be opened in an editor and worked on just like in the normal course of working in other programming languages and collaborating.

Worksheets and Workbooks I would imagine are alright as well, right? In this case, they are meant to be opened in Maple of course, not in a code editor.

Now, what about mla files? I imagine that if someone obtained an .mla file I created (containing a package, say), and saved it in a path contained in their libname then they would have access to that package. Is this the standard way of sharing packages with others?

If I wrote a package and wanted to share it (via a Github repo, for instance, or simply by emailling) would it consist of a single .mla file?

I have a folder called Packages, and I added its path to libname. I have an .mla file in there that I have been experimenting with to learn about writing packages in Maple.

The workflow I have currently developed is as follows.

Imagine I am working on a library that does something specific. Just to give a simple example, let's say I want to write a package that has functions sum, add, multiply.

I create an mpl file and I edit it in VSCode which has a plugin with syntax highlighting. In this file I write my package, procedures, etc. At the end of the file I add a line that tells LibraryTools to save the package to an mla file that I am keeping in the same directory as the mpl file (for organizational purposes, not for any technicality).

So at this point both these files are in the Packages directory.

Now let's say I want to create another package for doing animations. I would do the same thing: an mpl file and an mla file.

At this point all four files are together in the Packages directory, because that is where Maple knows to search for mla files. 

However, this isn't very convenient if I want to use version control for each package individually.

To do this I would need to have the two files of each package in their own directory (like a subdirectory of Packages)

i can do this of course, by adding each of the two resulting directories (each with two files) to libname. 

But is it possible to tell Maple to simply search all subdirectories of the directory Packages?

In other words, in this workflow, must I update libname every time I make a new package (which consists of a directory, an mpl file, an mla file, and a git file)?

Note: It seems in the course of writing this question I found the answer, but I am still interested in any tips on the best workflow to update a library. Here is the original post (annotated ex post in bold):

I have successully created my own package in Maple. I basically used LibraryTools:-Create to create an .mla file and then I used LibraryTools:-Save, passing in the name of my package and the path to the .mla file. I did this in a worksheet.

I can import it with the command with(MyPackage).

I'd like to add code to the package.

I have a package defined in as

module MyPackage()
  option package;
  export MyModule;

  module MyModule()

I would like to add a procedure to be exported inside the package.

I tried to add the procedure, save the file, and then use LibraryTools:-Save again, but the error I get is 

Error (in MyPackage) attempting to assign to 'MyPackage' which is protected. Try declaring local 'MyPackage'; see ?protect for details.

I tried to unprotect the name 'MyPackage' but this gives another error

Error, on line %1, unexpected end of input. Error while reading '%1' (this turned out to be a missing semicolon on the Save command, which was the last command in the mpl file. The error messags are quite unhelpful)

Note: As I mentioned before, I did the initial saving of the package from a worksheet (the package code was in a code editing region in the worksheet). In the current attempt to add the new procedure, I copied the code to an .mpl file so I could edit it in a code editor (VSCode). At the end of this file I added the commands to LibraryTools:-Save the package again to the same .mla file as before.

My attempt to unprotect the name "MyPackage" involved simply adding unprotect('MyPackage') as the first line in this .mpl file.

I then used the command read to execute the mpl file from within a worksheet.

What am I doing wrong, and what is the recommended workflow to be able to work on a package?

If I try to update a simple variable in the .mla file it seems to work.

EDIT: The problem seems to be the use of the named module initially, ie module MyPackage().

If I try the whole process again (write a simple package and save it to the mla file) but this time I use the syntax

MyTestPackage = module()

then I can update it no problem (at least for a simple package that I just wrote; for the actual package with my real code I still get even though Maple is able to read the mpl file without a problem, apparently there is still some issue while trying to save. 

Error, on line %1, unexpected end of input. Error while reading '%1'   (turns out it was the missing semicolon)

In summary: don't used named module syntax.

Hello guys.
I want to solve Laplace's equation for a triangle plate, subject to the following boundary conditions:

For the contour y = x, u(x,y) =20

For the contour y = -x+2, u(x,y) =100




Why is the Maple giving this error. See attched file. Further, how can we eq. of the form "A+B`*sqrt(C) = 0" by eliminating the common denominator.

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