Mac Dude

1561 Reputation

17 Badges

12 years, 262 days

MaplePrimes Activity

These are replies submitted by Mac Dude

@Rouben Rostamian  Let's see... assume t counts the iterations.

Then the first equation calculates y[t+2] as a function of y[t+1] and x[t].

The second one calculates x[t+2] as function of x[t] and y[t+1]...??

Turns out when you play this through you can's do the next iteration as x[1] never gets calculated. You can chose x[1] of course also, but then this becomes a rather weird system. It seems to need an internal state to work.


I am also hopelessly confused by the OP's writing of the function e(x). It seems it is being redefined as E(x)..?? and e is declared global... a mess.

To the OP: First, make sure your map equations are written correctly. The way you have them does not look right.

Then you need to write the procedure that gets handed to DataPlot as Map. Obviously z refers to either a two-element Vector or to a complex number, so the mapping functions have to be rewritten accordingly. There is probably someone here who can help with that, but with the way the mapping equations are written it seems not right. If this is really to be something like a phase-space plot for a dynamic system then Map should only depend no x[t] and y[t].

Then: Rewrite your e(x) function so it can be understood. DON'T USE GLOBALS!! The only global for which there is justification would be N as it is basically a constant. Anything else needs to be an argument if really necessary. And what is this business of e and E (which are declared as globals in some functions)??




@nm you are absolutely correct; this issue will occur when there are Maple-generated symbols involved. As I said; I haven't run into this, but I do see your point and it is a valid one.



You are not telling us what u is. But in the call to NonlinearFit you enclose u in square brackets which makes it a list; that seems fishy. For NonlinearFit to work, the function has to evaluate to values that can be compared to the dependent values of your data set (i.e. veloc in your case). If these are anything else than simple numbers I don't know whether NonlinearFit will work; you may need to use one of the other optimization routines and build your "penalty function" (i.e. the sum of the squares of the differences) yourself.

You also don't give us your data set so we cannot try this ourselves.




@optoabhi Attachment? Also, read the addition I just edited into my answer.



@leafgreen Actually, it is the other way around. First there were indices. Printing them as subscripts is actually quite a natural way and how it is often done in paper-pencil math. But sometimes people want to use a subscript that is not an index. Maple only fairly recently addressed that typesetting desire by introducing the double underscore. Since a single underscore is a valid character in a name they pretty much could not use a single underscore for that, lest they would break tons of extant code. Double-underscored names are what Maple calls atomic, meaning these are just names as any other one.

The reason your original function definition fails actually makes a lot of sense: a parameter to a function is either a Vector (say) or a scalar. For a scalar argument the indexing makes little sense; it only would acquire an index by being called in that way. So you can call your parameters x1, x2 etc. without any loss. When you call the function you can say f(x[1],x[2],...). and get it pretty-printed nicely. Or you define the arglist in terms of x and y and use x[1], x[2] etc. in the formula; that works also.

BTW, do not use a name as both indexed name (x[1]) and non-indexed name (x). Confusion will arise as Maple will treat x as a table & x[1] as an entry.

Maple has weirdnesses. This is not one of them. It is quite logical, dear Watson.


@DSkoog Thanks much again. You are right, Install has an option where, which can be either the users homedir or the Maple installation directory. Feels slightly restrictive but is ok for my purposes. I actually now agree with your recommendation about the location for the libraries except that historically I have put them into Maple's installation directory for a long time so I'd need to move stuff... maybe I am too lazy to do this... it is actually not so difficult since I set libname anyway... oh, well.

So, now I need Maple2017.2 with the page-break issue fixed. Until then I cannot really upload my package to MapleCloud since I don't want to carry around two different users guides, one with & one without the page breaks. Think that will actually happen?

Anyway, thanks much, I have learned a few things.


@DSkoog Ok, so I was able to create a Lattice.maple file by omitting the Users Guide and removing the continuation characters from the PackageTools:-Create command. Putting that into a directory known in libname indeed allows with() to work. Good. (I realize now that I did not check the help files...).

From what you wrote it appears that PackageTools:-Install creates a new, hard-wired directory structure in my home directory (maple/toolbox/...). What if I want this to be somewhere else? What is this guy "%USERFOLDER%"? Can I set this to some folder I chose? I am familiar with the kernelopts() directories and with currentdir() and libname; but this is a new one for me.



@dharr Hmm... thanks much for finding this out.

The page breaks I have in the file are there for reason of structuring the document esp. when printed to a pdf and looked at in this way, and I am not really interested in removing them. I don't know what a "child page break" is supposed to be; but this will prevent me from creating a workbook of Lattice. It is actually a real issue: Maple has the unique ability to allow typesetting text; adding things like page breaks and line breaks etc. are a fairly fundamental part of it. For our accelerator physics course I practically wrote a book in Maple. If workbooks do not support this it mars the concept.

And I cannot even fathom why the workbook even cares about these.

Anyway, needs to get fixed pronto. SCR incoming.



@nm if the fopen() call fails, Maple stops unless you catch the error using try...catch. If it does not stop, the fopen was successfull & you can rely on the filehandle being valid.

Does not seem to be that bad to me. If you want to get fancy, try...catch allows you to parse the error message & catch only specific errors, so you can take specific actions. E.g. if you try to fopen an already open file, fopen will fail as well (per the help page) and you can catch that. Although I have had trouble with this mechanism & gave up on being fancy.

High-level, but in my view not so bad. Incidentally, I do not fund the help page that bad. It explains all this pretty much.


@MTata94 @phil2 The FAQ phil2 mentions seems to address mostly issues where the Maple GUI cannot connect to the kernel. This is not the case for you MTata94, if I understand correctly.

Independent of that, however, you should have the files mentioned in the FAQ; these are the main Maple binaries. Without them you would not have a working installation. Note that on OS X, there is a /Library, sitting in Macintosh HD (your boot disk) and a ~/Library, sitting in your home directory. The Maple frameworks will be in /Library.

What are the general settings of your Firewall?


@John Fredsted Probably not, as when Maple hangs it will never get to the time statement.

I have used a variation on your theme, however: In a lengthy piece of code I would store the values of time()-t after each specific step in an array with the index counting up as the code goes along. When it got stuck I would break out & examine the array & see how far the code got. If it goes around the loop then you look for the value going down with increasing index; that is where the previous iteration values are still present & Maple hung.

When the code runs the overhead at least in my case was insignificant.

Another thing I would do for lengthy loops is to setup a gauge indicator that increments each iteration of the loop. This gives a nice visual clue of progress.

I do like acer's suggestion, however.

Mac Dude


Your post resonated with me. I occasionally teach a course in Advanced Accelerator Physics at the US Particle Accelerator School (, together with a colleague from CERN, and it is done just in the same way you describe: highly intensive 1- or 2-week courses, in essence cramming a whole semester's worth of material into two weeks. Two lectures a day and exercises in the evening. Classes are relatively small and lots of hands-on and 1:1 contact.  Students (which in our case are mostly either graduate students or those working in the field e.g. as operators or engineers wanting to deepen their understanding) are highly motivated and boy, do they hold their teachers accountable (in a good way)! It is a very rewarding endeavour, even if we are pretty drained by the end.

We do use scripts; in essence we wrote a textbook in Maple, with all the calculations live, obviously. Even though I curse regularly at Mape's 2-D input & printing, it is actually a big kudos to Maple that this is practical. As part of the tuition the students get student-licenses for Maple that they can keep, which I consider an essential element of the course, and which we know to be attractive.

We are still a bit struggling with keeping the lectures as interactive as possible. We added a sidebar to the script files where students could do their own explorations but the feedback on that was mixed: there just isn't enough room on a laptop screen for doing this in a nice way. The next time we may try putting a field below certain sections in the script where students can work on a given aspect. Lenin Araujo Castillo has just posted here one of his worksheets, and I like his layout, maybe we can experiment with that.

I visited IHEP in Beijing two years ago (as visitor-scientist, not as teacher). Your experience sounds very familiar.

For me personally, Maple opened up a path to teaching that I may not have gone otherwise. Using Maple allowed us to create a better course, and feedback we have gotten recently validates this impression. We do work hard on our course, using Maple in itself certainly does not guarantee a good learning experience (as I am sure you & everyone else who uses Maple in teaching already knows).

Thanks again for your post, much appreciated.

Uli Wienands
Argonne National Laboratory.

Any chance you have a beta license that is expiring lying around, that your version of Maple picks up? I had the same thing happen when I installed Maple 2017 beta, which would get in the way before my regular Maple 2016 got a chance.


@9009134 Ok, what is it you want? If you just want a solution to ode1; Maple will do this at least numerically; read up on dsolve(). Maybe it can even be solved analytically.

If you want to program a numeric solution (e.g. for homework) then you'd need to go back to your classroom material to figure out where to begin. I haven't programmed a d.e. solver in a long time so I m not in a position to write the solution down for you. There are many articles on the web about such mehods (look up e.g. Runge Kutta).

And Kitonum of course is correct, to define a function you need to put the arguments in (). But I think this is only a small part of your problem. I find the eval in your assignment to eq problematic. Syntactically you can make it more correct by writing f[i,j](x,y) and maybe include these in the argument list in the F1xx etc.  but I do not really understand your code. Also, while putting indicaes as arguments (to the F1xx etc) may be syntactically ok in Maple, it certainly does not smell right.

My apologies, but I would need more of an explanation what it is you are trying to do and the steps you are going to take before I can do anything for you.


Please give an example of what you have and what you want it to look like.


First 9 10 11 12 13 14 15 Last Page 11 of 42