Mac Dude

1506 Reputation

17 Badges

10 years, 247 days

MaplePrimes Activity

These are replies submitted by Mac Dude

I would love to use MapleSim, but I find the price (something like 5  or 6 k$, in addition to about $2k for the Maple license) prohibitive, even to ask my employer for it. Esp. given that MapleSim is based on Modelica, which in itself is open source. Of course since I don't use it I don't know wether the interface Maplesoft has built around Modelica is worth the money. Presumably for some applications (automotive, car design?) it is.


@Rouben Rostamian  

Programmatically, the debugger can be invoked by issuing


before calling f1. It will drop you into the debugger, cracking a window where f1 halts at the first executable statement. You can then push buttons like "next", "step" and others to single-step through the code, examine variables and such.

The trickiness lies in the various forms of single-stepping: step at the level you are at, which means subroutines get executed; step into a subroutine and other variants. The debugger definitely has a learning curve, and with only one window examining variables means you can quickly lose track of where you are, but it has its benefits, too. Personally, I would find it more useful if it had a window showing (dynamically) the values of the local variables, in the same fashion the Maple GUI has it.

Often, though, I just sprinkle a few print statements in the code to figure out where the issues are.


I have seen crap like this before. Typically, I will first try the recalculate button to flush out everything (and you do begin your sheet with restart;, don't you?). In sticky cases I have had to close down Maple and start anew. I never had this in a reproduceable manner; but then, I don't use 2-d input mode unless I am writing a book or report.

You can also disable any .mapleinit intilazition file you may have.



It depends a bit on the details. A sum with a numeric range (e.g. 1..10) will often get expanded to an expression of type +; then you may be able to use op(n,xpr) to get at the nth summand. If the range is not numeric I think your option is to use op() to get at the arguments in the sum and substitute whatever you want for the index.

Why don't you upload an example?


For a long time, plots:-display() would have trouble with log plots when gridlines are on & I submitted SCRs and even had exchanges with Maplesoft Tech Support on this issue. Often I had to turn the gridlines off to get at least a proper log plot.

It appears that Maple2019 has at least improved the situation: I was pleasantly surprised today to get a correct log plot, with the correct gridlines. I haven't done exhaustive testing, but that particular code does not plot the log gridlines on Maple 2018.

Kudos for fixing this!

Mac Dude.


@Mac Dude 

In my .mapleinit I pre-pend my own directory where I keep my packages in libname to Maple's directory (on macOS that happens to be "/Library/Frameworks/Maple.framework/Versions/2018/lib"). So my libname usually looks like this:

"/Users/uli/Maple/My_Maple_Libraries", "/Library/Frameworks/Maple.framework/Versions/2018/lib"

When I remove the first entry (my own directory) then all is well.

This actually is an issue: I need this so Maple loads my packages. Even the actual code where I ran into this problem needs this. I thought I could be smart and use PDEtools:-Solve, but no such luck: same error. Trying infolevel[pdsolve]:=3: It prints the expected when it works; when it doesn't there is no print-out whatsoever.

Trying trace(pdsolve), I get:

{--> enter pdsolve, args = [diff(f(x, xp), x) = -(1/2)*(L*xp+2*x)*kl, diff(f(x, xp), xp) = -(1/4)*kl*L*(L*xp+2*x)]

zz := [], [[diff(f(x, xp), x) = -(1/2)*(L*xp+2*x)*kl, diff(f(x, xp), xp) = -(1/4)*kl*L*(L*xp+2*x)]]
<-- ERROR in pdsolve (now at top level) = too many arguments; some or all of the following are wrong: %1, [{f(x, xp)}, handlenonrationalfunctionsofdependentvariables = false]}
Error, (in pdsolve/sys) too many arguments; some or all of the following are wrong: [{f(x, xp)}, handlenonrationalfunctionsofdependentvariables = false]

When it works, I get a second entry into pdsolve with different arguments and build=true and it runs.

The short-term way out appears to be to reverse the order in libname: put my own directory after Maple's. This does not quite sound right as in general one wants the user-specific directory first, to be followed by the main one.

The bottom line is that there appears to be a naming conflict: something I have must be (unintentionally) masking something in Maple's libraries.

Is there a general way to track down such naming conflicts? I suppose I can try the debugger on pdsolve; but that seems to be going down a rabbit-hole fast (meaning I lost track where I was).



@ecterrab and all others.

I now tried on my work machine (using the file I uploaded and running Maple 2018) and I get exactly the same error as I got at home on my laptop.

Since I appear to be the only person in the (Maple-) world who is running into this error I will scrutinize my .mapleinit file, even though I nowadays only have things like changing plot parameters in there... If I learn something I'll report back.

Rouben is correct, this particular system can be solved by hand (and I did so, getting the same answer as Rouben and tomleslie got [they are the same even if they look different]); but I gave a mwe; the real case has twice as many equations and variables and is more messy... beyond what I want to do manually.

Puzzled, but thanks again.

Mac Dude


It appears quadratic interpolation, which ignores the initial value, may be used. Check the docs on NLPsolve. You can specify a different method. As an aside, specifying the initial point at the end of the range is not a good strategy. I'd pick some point more in the middle.

You are not providing enough detail to go beyond these generalities. If your cost function should not go negative, the function should be written in a way that it cannot.



Not really. G has everything; the rest is just to make it more explicit.

You do need to be aware of the assumptions Maple puts on the generated variables _Z2 and _B2, which you get using about(_Z2) and about(_B2). In this case, _Z2 is assumed to be an integer; _B2 is assumed to be 0 or 1.


Read the Maple Programming Guide (can be found on Maplesoft's Manuals' page).

Program whatever it is you want to program.

If it works and is fast/accurate enough, you are done.

If not, come back and post the code you want to improve.

Mac Dude


Hi, have you tried printing the workbook to pdf (i.e doing it the old-fashioned way before ebooktools came along)? I have done this extensively and the only issue I could not fix was that the plots came out relatively large. But they never overlapped or such nonsense.

Mac Dude

@acer Many thanks for this exhaustive analysis. I actually was not all that aware of the floatPi kernelopt. The behaviour of evalf is a bit counterintuitive to say the least.

But it is good to have a better idea of what is going on.

Thanks again,


@acer Ah, an oversight. Here is the file (with your name but modified). I did not touch your kernelopts. And as downloaded your original sheet evaluates exacly the same on my Maple as on yours even though I run 2015.1 and you run 2015.2.


@acer Ah, I had forgotten about trace... maybe I wasn't even aware that trace can trace Maple's library functions like sin... anyway, I played with your file & I think I get why evalf() changes your result (4):

execute sin, args = 704000000.*Pi
{--> enter sin, args = 704000000.*Pi
                         7.04000000 10
<-- exit sin (now at top level) = 0}

so sin() gets a (-n integer) number times Pi as an argument and presumably knows that that is always 0.

The use of the variable (R in your file) prevents this and sin() gets passed the floating point argument so a round-off error appears.

Why are these different?




I had (actually still have, sort-of) a similar issue for one of my large packages (Lattice, a beam-optics code available on the Maple Application Center). I originally tried to use an export for this purpose only to quickly realize that it did not work as intended. Presently I use a "Set" method to set certain parameters in the package, which works, sort-of.

Some requirements for any such mechanism I think are pertinent:

* Reasonable initial defaults so one is not forced to set the package defaults before every use (e.g. for small and simple sheets that use a package).

* Allowing to set only a subset of parameters, leaving the others at their original default setting.

* The ability to set or change such parameters after first use of the package in a worksheet without getting inconsistent results.

The last item can introduce a non-trivial complication in large sheets as any change needs to be communicated throughout the package. For in-part this reason I settled on using a Setter method with named parameters; this allows to do any kind of manipulation needed. Setting e.g. a member of a record implies any module-local routine affected would need to check the parameter(s) upon each execution. A Setter method also allows any kind of type-checking desired. I do like your name "Configure" however, as it implies a larger scope that "Set".

I don't like the use of globals. Modules are a great way of protecting the module-local variables; the use of globals penetrates that protection.

I am less concerned about name clashes. E.g. the "Set" method has a short name that may clash, but I can (and do) give other procs a longer more descriptive name.

I do not understand your comment about the configuration object needing to be separate form the package or module. If you do not use a certain package, why would you want to bother setting its defaults? On the other hand, would you want to always have to load your default-setting module? Maybe I am not getting something here...

My third requirement (changeability after first use of a package) can be debated. It stems from my need to set the beam energy in the Lattice package, which for many cases is not needed and the definition of which, in some cases, triggers extra and potentially time-consuming evaluations in the package. By setting it later I can avoid spending such time. It is not an entirely clean way of doing things, however, and I may want to change my approach to this issue in a later version.

Thanks for sharing your thoughts,

Mac Dude


4 5 6 7 8 9 10 Last Page 6 of 42