Mac Dude

1122 Reputation

13 Badges

7 years, 207 days

MaplePrimes Activity


These are replies submitted by Mac Dude

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.

FWIW

M.D.

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?

M.D.

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:

pdsolve(PDE);
{--> 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).

M.D.

 

@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.

M.D.

@ 

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.

M.D.

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,

M.D.

@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.

M.D.

floatPiEqnLabel2.mw

@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):

evalf(sin(2*Pi*(4)));
execute sin, args = 704000000.*Pi
{--> enter sin, args = 704000000.*Pi
                                      8
                         7.04000000 10
                               0.
                               0
                               0
<-- exit sin (now at top level) = 0}
                               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?

M.D.

 

Joe,

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

 

From the way the question is phrased I take it that you know how to specify starting values for fsolve. Do you want to know what Maple uses if you do not specify the initial guess(es)? Why do you care? If it gets stuck at an unwanted solution (quite possible) the Help pages explain how to use the "avoid" option.

I certainly do not claim to know how Maple derives initial guesses. One way is to start at 0. Another way is to find the values where the function crosses 0 (potentially time consuming). For more complicated problems I practically always specify the starting values to help Maple along.

Mac Dude

@Joe Riel and acer: Thanks both of you for the comprehensive answers. I believe I get faster processing of numeric data at least in certain cases when UseHardwareFloats is true, as it prevents Maple from falling back to software floats, although I'd be pressed if I had to come up with an example right now. But I would guess the effect of "true" is there for a reason so I am a bit sceptical of acer's assertion that "true" is a dubious setting. If it isn't working or useful, then why is the option even there? And Maple's default settings are not always optimal, e.g. I don't understand at all why Digits is 10 by default and not 15, which is the highest setting allowing hardware fpp and close to the accuracy of many calculational tools (programs, calculators etc.).

I understand that UseHardwareFloats:=true restricts what Maple can do. I fail to understand, however, why e.g. fsolve croaks reliably with this setting, even with relatively straightforward tasks. In my book that is a bug and not understandable at all.

Anyway, I do understand now the behaviour I am seeing, so thanks for enlightening me.

Mac Dude.

1 2 3 4 5 6 7 Last Page 1 of 37