The code below creates animated phaseportraits for arbitrary, autonomous system of ODEs. Using the Lorenz equations as an example, I take the user through the creation of the animation so that he or she knows what they are really looking at when the code compiles and runs. There are two signiﬁcant problems with the code that reduce the power of the program, but in the main it works.
Please see my statements of these problems, inserted in the code below. Note that code lines begin with '>' and comment lines do not.
Programming Problem: Phaseportrait, the function in Maple that this worksheet will make the most use of, creates a two-dimensional phaseportrait for a given system of ODEs for a given set of initial conditions. You can give the program a list of initial conditions to create phaseportraits for and the program will draw the trajectories all on the same graph, but it is diﬃcult and perhaps impossible to create a small procedure that generates a set of initial conditions for this function (maybe you can get it to work: see initialconditions or maybe DEtools. You might also try DEtools[phaseportrait]).
I would love to see a small procedure that could specify arbitrarily many initial conditions in an arbitrarily small neighborhood (or ball/cell)–it would greatly aid in the analysis of sensitive dependence on initial conditions for the system.
Programming Problem: As hard as I have tried, I can’t get the display command to take a generated list (as opposed to a written list, such as lzlistxy above) of phaseportraits for input.
I’d like to be able to generate a list of phaseportraits to display based on a starting time t1 and an ending time t2 and a stepsize (e.g. if t1 = 1 and t2 =2 and the stepsize is 0.25, I’d like Maple to generate the phaseportraits Lxz(1), Lxz(1.25), Lxz(1.5), Lxz(1.75), and Lxz(2)).
The problem I have encountered is not getting the computer to generate such a list–the problem mainly seems to lie in the format of the elements of the list.
Instead of holding the elements in the list as actual plots, Maple holds them as instructions for plots. Unfortunately, the display command does not accept a list of instructions for plots as an input, so I’m at an impasse.
A small procedure that gets around this problem would greatly increase the usability of this program since it would give the user the ability to create arbitrarily smooth animation for an arbitrary length of time.
One solution, applicable elsewhere, is to have a procedure to generate an arbitrary linear sequence. Thus
You can then apply it to your problem in the following manner
I really can’t see what you ﬁnd diﬃcult here. Both problems seem quite straightforward to me.
First, here’s a procedure to randomly generate n initial conditions within epsilon (in each coordinate) of [x0,y0,z0]:
So to produce such a set of initial conditions, you can say e.g.
And to generate a list of phaseportraits, all you need is something like this:
You can avoid having to type that long list by using a construction like this
It seems to me that a lot of unnecessary computation is going on, though. Here is a quick attempt at handling the problem diﬀerently. The idea is to compute only Lxz(30), and then make an animation out of that plot structure.
The procedure animatePLOT below is made to handle a 2-dimensional PLOT structure containing only one curve. It calls one of two subprocedures.
One of these (animatePLOT1) handles a PLOT structure containing one list of points (the typical output from plotting one curve), the other (animatePLOT2) handles a PLOT structure containing a sequence of lists of points, which is the output from phaseportrait, when linecolor has been speciﬁed.
The PLOT structure that can be input to animatePLOT2 must be of the form PLOT(CURVES(...),..). The syntax is
animatePLOT( p, n );
where p is the PLOT structure and the optional n is the number of frames (default=number of points in the list (or members of the sequence)).
Needless to say, this procedure is rather raw and needs improvement. I’m aware of animatecurve, but that seems to use the same number of points for each frame, which doesn’t produce good pictures at the end unless numpoints is set to a high value.