zenterix

405 Reputation

5 Badges

3 years, 126 days

MaplePrimes Activity


These are replies submitted by zenterix

@acer Okay, that option is indeed helpful it gives the same two complex roots that I obtain by hand. 

However, I think my original question was actually about the actual math part. Where does that quadratic 2(y^2-y+1) come from?

@acer Indeed I am actually using the array-style return for rkf45. 

@acer How do we file bug reports?

@Joe Riel 

I was able to reproduce your successful result. Thank you.

@tomleslie 

I have been reading the docs and in particular the user and programming manuals. I think there is a lack of examples and explanation of edge cases and gotchas, of which there are many.

Consider Chapter 11 "Writing Packages" from the programming manual. I spent a ton of time trying to work my way through that and just simply could not. Some commands wouldn't work as expected. I've posted about it before, but for example the following snippet

Note: Maple automatically adds lib subdirectories of directories in HOMEDIR/maple/toolbox as well as your current directory to the predefined variable libname. Therefore, modifying the .mapleinit or maple.ini file is only necessary if you want to designate a directory as the default location in which the savelib command will save your library files.

simply does not seem to be true. I created multiple example directories and tried to go through the examples. The lib directory of my current directory does not seem to be added automatically to libname. I wasted tons of time on this.

And once again, for this post, just to to be absolutely sure of what I am saying I literally just tried it once again for the umpteenth time. Here's what I just did:

I created a directory called PackageTest and inside I created a directory lib with a file called PackageTest.mla (using LibraryTools:-Create). Then I created a file in this newly created PackageTest directory called packageTest.mpl containing the following code

module PackageTest()

     option package:

     export myAdd := proc(a,b)

          a + b:

     end:

end:

Then, in a maple worksheet (PackageTest/packageTest.mw) I read the mpl file and ran the command 

LibraryTools:-Save('PackageTest', cat(kernelopts(homedir), "/maple/Packages/PackageTest/lib/PackageTest.mla"))

At this point, my expectation is that if I open a worksheet that has current working directory as 

cat(kernelopts(homedir), "/maple/Packages/PackageTest)

then Maple should: "automatically adds lib subdirectories of directories in HOMEDIR/maple/toolbox as well as your current directory to the predefined variable libname", ie should add PackageTest/lib to libname and thus the package PackageTest that I defined should be available.

Either I am crazy or dumb or this documentation is badly written or plain wrong or atrocious.

 

Finally, look, I am new to the Maple community and I'd like to learn to use it but having been part of other communities I have to say the documentation here is just... confusing sometimes. Isn't it a goal of a program like this that new users can be up and running quickly and productively? It seems like this isn't an important consideration.

If Maple has been around for so long, how come you don't find that much information on how to do different things and there are seemingly only a handful of very knowledgeable people on using Maple that answer the questions here (like yourself)?

The original point of this entire thread is that hopefully I will be able to write up what I consider better documentation in a few weeks or months that prioritizes being productive.

@tomleslie 

I guess I am starting to complain a lot about Maple in my posts. Coming from the world of Python and Javascript the documentation just seems so not user-friendly. The documentation seems like a big reference manual. This might be nice for someone who already knows Maple (and even for such people I have my doubts given the quality of the writing of these docs), but tutorial-style documentation for common tasks would be much more useful for people trying to learn Maple (and not just learn in an old-fashioned trial-and-error low productivity way, but in an efficient way that draws on someone having produced thoughtful, didactical tutorials).

Take the documentation on the Grid package. It lists out the 18 commands in the package. Am I supposed to go through all of the 18 to find out how this package is usually used? 

There is so much inertia it seems.

Have a look at this page, for Grid:-Run. This page is seemingly abandoned. The formatting of the page runs way to the right. Someone didn't care at all about the reader of this. Like, is this command so unimportant that no one cares to maintain the documentation page for it?

@acer The thing I hadn't understood was that was considered a continuous function in the first case. Now I know.

@mmcdara Sure, there are multiple options. This question isn't very interesting I know. It boils down to not having realized I was using the wrong syntax. However, as I mentioned to @acer, the incorrect syntax seems so natural that it is weird that it is incorrect.

@acer I guess my question was based on the impression that plot(i, i=1..5) seems so very similar to plot(l[i], i=1..5) that I naturally expected it to work. To me, the expected result is obvious: that both plots be exactly the same (given, as I said, l=[1,2,3,4,5]).

I guess the two commands are not the same, though I can't really explain at depth why. The first expression seems to have the function f(i)=i as the first argument. The second expression has an expression that is the accessing of an element of a list.

I think the answer turns out to be that it's just the way the syntax works.

The documentation says that the first argument is either a function as in the following example

plot(x^2, x=1..10)

or we can pass in two vectors/lists/arrays as the first two arguments, representing and y.

The example I asked about doesn't fall into either of these categories I guess. 

@dharr 

As I said initially, the user who executes the mpl file knows where it is located yes, so that person can execute it. 

But then, the code in the mpl file will do things based on its own location. For example, create files and put them in locations relative to its own location.

In my case, the mpl file will create animations and put them in a directory called Animations located in the same directory as the mpl file.

@tomleslie No worries. 

I have an animation such that the size of the resultant .m file is 383 mb.  

The code that generated this file took about four minutes to run. But it seems the real bottleneck is the call to actually display the animation in Maple. This takes forever: like so long that I haven't seen it yet and I've been waiting for fifteen minutes, and decided to write this post.

UPDATE: I had an inefficient computation in a procedure that computed the average of a list of lists. The issue was that a list was being updated in a for loop. Changing it to an Array (which is mutable) seems to have solved the issue of the call to display (which still takes long waaaaay less time).

Also I've run out of memory a few times when trying to display these animations.
 

@dharr But if you just spin up a new worksheet without saving it and read the mpl file then currentDir seems like it will just be the system home directory.

I'd like to get the path to the mpl file programatically from within the mpl file.

Please have a look at the code in this repository.

Specifically the AnimationTest.mpl file. I created this repo for another question I posted here about saving animations to files. But the data for those animations was created partly by a numerical solution to a system of differential equations.

In the aforementioned file, there is a procedure called solveEqs which solves a system of differential equations. Each of the two equations has a random term in it. The solution I found for being able to provide dsolve with such random numbers on each iteration was a table that keeps as entries the times used by dsolve and as a value the corresponding random number.

@acer @tomleslie

I created a package in an .mpl file, saved it to an .mla file, and create a worksheet to show how the package is used.

This package is a slimmed down version of my real code, but I think it shows all the issues that I have asked about. 

Please find the code in this Github repo

Now I want to write a little about what is happening in that repo. AnimationTest.mpl file contains a package called AnimationTest.

The package exports two main things: an object called NumberGenerator and a procedure called animate. For the purposes of my current question about saving animations, the important export is animate.

animate

animate calls computeAverage, which returns a list of lists. This list of lists has Np rows and three columns and represents 3D points of a trajectory.

computeAverage

Uses Grid:-Map to parallelize calls to solveEqs, which solves a differential equation (returned by a procedure called diffEqs) using dsolve, and then performs some calculations on the result, returning a list of lists, called slist. The outer list has length Np, the inner lists have length 3. Each inner list is a 3D point, and the entire outer list represents a trajectory.

Then, computeAverage sums the outputs from the N runs and divides them by N. Thus we have an "average trajectory". That is, the return value of computeAverage is again a lists of lists representing a trajectory.

------------------

Back to animate, after obtaining the list of lists from computeAverage, we convert it to a Matrix which we call q1 and we pass this Matrix to the procedure computeAnimationData.

computeAnimationData

This procedure does exactly what was done in my previous (garbage) worksheet: it calls plot:-arrow and plot:-pointplot3d to get plot objects ptrail and parrow, plus the plot object of a sphere which is the result of calling plottools:-sphere.

------------------

At this point, we can either display the objects or save them to a file. As per acer's example, I am doing this by saving the data to a .m file. 

For this demonstration, at the end of animate I am both saving to a file and displaying in the worksheet.

It works very well and is what I wanted. 

3 4 5 6 7 Page 5 of 7