zenterix

405 Reputation

5 Badges

3 years, 126 days

MaplePrimes Activity


These are replies submitted by zenterix

@Jean-Claude Arbaut I created a new Worksheet in Worksheet Mode and wrote out the commands there. Here is the worksheet: MatrixEvalWorksheetMode.mw

Did not work.

I checked with Maple Input. It works. So the issue is the type of input not the worksheet mode.

Having to use Maple Input rather than 2d Input removes at least half the benefit and pleasure of using Maple.

@Carl Love I simply copied your code into a worksheet and pressed Enter. 

If I try to look at the code more closely, I see a proc called Trans. Most of the code (the operators) are beyond my current level of understanding of Maple. I see the following line of code

F := <1,2;3,4>: I:=<1,0;0,1>: `0`:= Matrix(2,3,0):

The correct backticks are being used on the 0 there. I even deleted them and put them in again manually.

I still see the error.

Here is the code in a worksheet: MatrixEval2.mw

@Kitonum The A% part stays that way in the output. MatrixEval.mw

@Scot Gould No, I am not talking about non-executable math.

Now, up to this point I have been using non-executable math, but then I decided it was time to ask the current question, which is about how I can actually see the pretty output of using executable math. I'd like to see the matrices in the usual format that would be used if I were writing this out on paper.

@Carl Love "Error, illegal use of an object as a name" when I run the code above in a Maple worksheet. That is some mindbogglingly  complicated code to accomplish this simple task. 

@Axel Vogt I want to see the actual matrix A then a dot then the actual matrix B

@acer Here is what the Maple research team says about this

"Maple's engine typically has no problem with these animations, but the GUI can easily get overloaded. You can make the simple example work by ending it with a colon instead of a semicolon so that the animation gets computed on the engine side, but not displayed. Unfortunately, you can't really do anything with this animation: both displaying it in the GUI directly, and trying to export it to e.g. GIF (which is done by the GUI, even if you use the command line command for it), fail.

The one approach that they could see working is using an entirely different approach for animation, where the frames are generated on the fly and displayed in a plot component. You can adapt the above example as follows:

with(DocumentTools):
with(Layout):
with(Components):
xml := Worksheet(Group(Input(Textfield(Plot(identity = "P"))))):
tbl := InsertContent(xml, output = table):
P_name := tbl["P"]; r := rand(0 .. 1):
testData := Matrix([seq([r(), r(), r()], i = 1 .. 10^4)], datatype = float[8]):
do_animation := proc() 
   local i:
   global testData, P_name:
   for i to upperbound(testData, 1) do 
      DocumentTools:-SetProperty(P_name, 'value', plots:-pointplot3d(testData[i], symbolsize = 100, view = [(-1 .. 2) $ 3], caption = sprintf("frame %d", i)), refresh = true):
   end do:
end proc:
do_animation():

I just wanted to leave this here in case it interests anyone. I don't know half the commands above yet.

@acer The parallelization is something that happens before this entire discussion of animations. 

In the current discussion, I provided a 10000x3 matrix where each row is a point in a trajectory. This matrix is actually an average of n trajectories. To compute the n trajectories, I use parallelization. That part works. 

Now, given the matrix, I want to create the animation.

Your suggestion of computing each frame on the fly seems to be the way but I am not sure how to do this in Maple. In python or javascript, for example, you pass a function to the animation function, and the former provides the next frame.

I am actually trying the animation in Python right now and it seems quite promising (though it is always a painful learning curve to start doing something in matplotlib after you haven't used it in a long while). 

@acer The trajectory is that of a qubit. Different trajectories are computed for different physical models. The objective is to be able to see the animations and analyze them to obtain insight into the physical modelling. So, it would be great to see it in Maple. It would be great to be able to save a specific animation to see it again later and compare with animations for other parameters/models.

What do you mean "compute each frame if done sequentially"?

@Rouben Rostamian @acer Here is an even simpler example in the sense that all I did was take an example from the docs of plots:-animate that contained the default 25 frames and increased the frames to 5000. Uses a lot of memory and takes forever. EvenSimplerExample.mw

I am inclined to conclude that the issue is with Maple plot procedures. Imagine trying to generate 100000 frames.

@acer @Rouben Rostamian

Here is a way simpler example of the problem: SimpleExample.mw

This just generates a 10000x3 matrix of 0s and 1s. Then it creates a sequence of calls to pointplot3d with one row from the matrix, and displays this insequence. 

This already uses huge amount of memory. This seems to indicate that the problem is not with the code I wrote, it is with the plot procedures, unless I am using the plot procedures themselves in a way that is not ideal.

@Rouben Rostamian  @acer One example of an optimization to memory usage in the code is the following (though i am not sure how to accomplish it).

The animation plots a "trail" of the last 1000 points of the arrow's trajectory on the sphere. If plots:-display would accept a function that would give it the current animation frame, then I could compute such trails on the fly (basically accessing a rolling window of a matrix, computed in the function passed in to plots:-display). But since apparently plots:-display doesn't accept such a function as an argument, the data for each of the 10000 frames of this trail are kept in memory.

However, after a few checks it seems that the arrows themselves are what take up so much memory. I am trying to optimize the arrows. Replacing plots:-arrow with plots:pointplot3d uses a fourth as much memory.

@Rouben Rostamian  Would you be willing to try to run a test animation?

I created this respository for testing animations. All you have to do is run the worksheet and it will animate an arrow on a sphere with 10000 points in the trajectory. The actual animations I want to run will have at least ten times this amount of points. 

However, even this meager 10000 stays stuck "evaluating" on a 16 core 256GB RAM computer. Something clearly is wrong.

I'm going to send the linked repository to Maple's support to see if they can help me figure this out.

As for the heap, is the setting you're referring to the one set by kernelopts(jvmheaplimit)? Mine is already at 65536, but kernelopts(limitjvmheap) is false, so as far as I can tell the limit on the heap isn't applied.

@acer I can now see the result used by Maple on paper.

If f(x)=ax^2+bx+c and g(x)=f(kx), then when we write out the equations for the roots of g(x) we find the expression 

which means that the roots of f(x/2) are the roots of f(x) divided by 2. 

Furthermore, the roots of 4f(x/2) are the same as the roots of f(x/2).

Hence, I understand the result given my Maple now.

@acer in your calculations you reached the equation y^2-2y+4=0. Ie, the that solves the system is a root of this quadratic polynomial. 

Let's solve it (I'm just going to show one of the solutions, the other is with the negative sign)

Discriminant = 4-4*4=-12

y=(2+sqrt(-12))/2

=(2+2sqrt(3)i)/2

=1+sqrt(3)i

Maple on the other hand is telling us that this is the same as 2 times the solution to y^2-y+1=0.

But how did it know that? Like, how would a human have come up with that particular way of expressing the solution, and why?

2 3 4 5 6 7 Page 4 of 7