Mac Dude

1556 Reputation

17 Badges

12 years, 183 days

MaplePrimes Activity

These are replies submitted by Mac Dude

I'd like to commend Maplesoft for doing his. I'd also like to report that I could put this to good use as I will have a Summer Student this year, and he is putting the time to good use by learning the physics behind his project now. So I was able to point him towards the Maple Student License and also towards the Accelerator Physics course that I and a colleague wrote a number of years ago and held twice at the US Particle Accelerator School ( While I will try to get him a paid Student License so he can keep it; the free license allows us to get a head start until his internship actually starts and allows him to get familiar with the program.

Many thanks,

Mac Dude

PS: I'll point him to Edgardo's course also, which has been quite helpful for my teaching activities.


Harsd to tell without having  the Maple program that generates the plot. Checking one of the example plots in help:plot3d I can see that 2015 generates vector data, i.e. a PostScript program. Maybe 2017 adds a big bitmap? I don't have my 2017 version around so I can't check right now. You could look at the eps files with a suitable editor (emacs, Textwrangler).

There are proggrams around that can compress a pdf; usually at the expense of some quality loss.


If one looks at this naively, it is a 5-dimensional construct; 4 parameters with ranges (x,y,z,t) plus the value u. To do a carpet or a space curve you need to fix two variables. Or you encode the u value in the color onlly and plot against x,y,z (and I don't know how to do this, but I think it can be done). If t is time you could do this as a movie generating one plot for each value of t and then plots:-display(seq of plots,insequence=true).


@acer Yes, I have four different instances of the pair of tables Beams and Beams2. What I did not elaborate on was that they are generated by the same code, but from different input conditions. These runs are proceeding in parallel on different cores of the same machine. I use something like maple -c BeamIndex:=1 <programfile> when I start the runs (with obviously different values for BeamIndex). This is how I generate the filenames. Since these processes run in parallel, using separate files avoids access clashes that would be unavoidable if all processes wrote to the same file.

I suppose I could generate different variable names and use assign to generate them, but I don't like doing that, debugging that is always a PITA.

Yes, I think your suggested additional tables is probably the way to go. I have also been thinking about using doubly indexed tables e.g. BeamTable[procno,turnno]. But your proposal may be easier to do & implement. The reason I asked is so I could avoid missing a nearby solution I wasn't aware of... but it does not look like there is.

Incidentally; this is now going way beyond my original aim. Originally (when I asked my pervious question) I wanted to separate the CPU-heavy part from the graphics (visualization) part. Once I got that going I realized that I had a framework for running the CPU-heavy part in parallel on my MacPro. Splitting the job & running it works; my challenge is to get access to the results (and I know using LibraryTools:-Browse() that the results are there in the way I anticipate them to be).

Anyway, thanks much for your insight,


@acer So I am able to indeed store my Record & retrieve it in an unrelated Maple process. So +1!

There do seem to be weird and undocumented restrictions at to what can be stored: Record: yes. Scalar: yes; Vector: No. Array (of Records): No. Table (of Records): yes. Element of an Array (of Records): No (!). Is there any rhyme or reason to this; or at least documentation? You are absolutely right that I have to collect many Records in a structure under one name, lest they become unmanageable; eventually I want to treat throusands of these Records per run. With a Table this seems feasible.

You mentioned that nested Records may cause issues; I actually have those as well but they have different functions than the ones I am attempting to deal with right now. In time I'll probably get to such things.

Anyway; I can see this as quite a powerful feature of Maple & am looking forward to use it more often.



Well, maybe you could mention your platform (Windows/macOS/Linux, os version), which version of Maple is involved, and under what exact circumstances you experience slowness. I have experienced some slowness of Maple 2019 on macOS Mojave in the presence of anti-virus software.


@acer Ah, the missing piece for me was the ability to reference by its name the content of a .mla file. Thanks much for taking the time making the example.

And I realize I wrote very sloppily equating a .mla file with a package, which I know it isn't. I am using and making packages all the time, which I store in .mla files. I just never considered .mla files for other items. I do wonder if I just overlooked it or the docs indeed nowhere mention how to retrieve something out of a .mla file. Seems like it should be prominent.

I am also quite familiar with Records being special cases of a Module. In some of my packages I even have the same object (object in a generic sense) being implemented as either Record or a Module depending on its detailed properties and behaviours.

Anyway; I think your proposed approach will get me where I need to go, so please accept my thanks,


@acer Interesting idea. I am familiar with .mla libraries for sure; in fact most of the code that makes these Records is in a big .mla library.

If the .mla is a package, then with(); loads it and makes its exports available in the namespace.

With my Records, I am not sure how I can get at them. with() won't work because there is no package. A quick check in Help does not reveal any mechanism how to retrieve stuff; only how to add or remove things from libraries.

So, how can I get at the Records?


@Stretto I am kind-of curious about your remarks regarding memory issues of Maple. I don't think I ever ran into real limits even on 8 GB systems (and I have analyzed datasets that run 100s of MB from a number of experiments in Maple, and I use it to model rather complex physical systems). I have been tripped up by Maple's ability to do symbolic math: if I wanted a numeric result but accidentally haad an unassigned name, Maple would merrily try to create maybe a huge expression, or maybe a Vector with thousands of entries, each one a long expression. So I learned the hard way to e.g. declare dataype=float when I expect an array of numbers. IMHO Maple is qualitatively different than "just another language" (like e.g. Python, C and its descendants, or so). True, with its power come hard-to-find bugs; and sadly the debugging facilities are a bit stone-age. And Maple has bugs for sure, although many a "Maple bug" I would despair over eventually turned out to be my lack of understanding. But, memory usage in itself is not a major issue of Maple.


@Carl Love Your 3rd example can easily be made to work in as far back as Maple 2015:

Last:= module()
local _Last,ModuleApply;
export Init;

ModuleApply:= proc(k::posint)
  _Last:= 4*_Last+k;
end proc;

Init:= proc(N)
 _Last:= N;
end proc;

end module:

seq(Last(k), k= 1..10);

So the principle behind the code already existed in earlier versions of Maple. The important point is that, by declaring Last as a module instead of a proc (and using ModuleApply to invoke it), the variables (i.e. _Last) are local to the module and are persistent. On one hand, this is a powerful technique. On the other hand, reliance on persistence of local variables can make code harder to understand and debug. So I somewhat shy away from ModuleApply in favor of using procs explicitly exported by the module (like Init in the example).

Modules are a powerful feature of Maple that allow creating very large and complex packages in a well structured and maintainable fashion. Since they can be programmatically created, a single command can generate a complete model of e.g. a physical system with chosen parameters and properties, and with methods (i.e. procs) to interact with it. And the same model can run numerically or symbolically depending on the parameters given. It is the feature that got me hooked on Maple.


@Carl Love This (not needing to close the Maple application upon a kernel crash) is my experience as well. It would be even nicer if the worksheet could restart the kernel & attach to it without being closed and re-opened (kind-of like Jupyter); but that does not seem to be the case.


@Stretto What exactly are you trying to achieve?

If it is debugging, I'd typically only print the vars I suspect are not what I would expect. Yes, possibly a ream of lines, but better than nothing.

If a (long) loop errors somewhere in the middle I have had success with putting in print statements printing the loop index at strategic places. This would tell me how far things got an narrows down where the error occurs. Knowing the index at the error allows figuring out what went wrong, since one can then inspect all variables as they are at that point.


I can corroborate this claim. In fact, I was composing an answer to the question. When I hit "submit", I got a "Page not found" error. After that, the question was gone.

Mac Dude

A bit hard to tell what you need since you did not upload the actual sheet (hint: the green up-arrow lets you upload your worksheet), but the _Ci are the constants you will usually find from your initial conditions (assuming you are solving an initial-value problem). E.g. the general solution for phi=0 and its derivative (for a 2nd-order problem).

The term phi=phi in the solution indicates that the solution does not depend on phi. IOW, you can pick any value (angle).

But you really should upload your Maple worksheet.


@HS Yes exactly.

It is actually a nice feature.

However, if you create a worksheet from scratch and then save it somewhere, currentdir is not set to the directory where you save it but remains at its default (Maple's framework directory on macOS). You need to close and reopen  the sheet to get currentdir to change automatically.



2 3 4 5 6 7 8 Last Page 4 of 42