~ubuntu-branches/ubuntu/karmic/maxima/karmic

« back to all changes in this revision

Viewing changes to share/contrib/plotdf.usg

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-06 17:04:52 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060706170452-j9ypoqc1kjfnz221
Tags: 5.9.3-1ubuntu1
* Re-sync with Debian
* Comment out backward-delete-char-untabify in maxima.el (Closes Malone #5273)
* debian/control: build-dep automake -> automake1.9 (Closes BTS: #374663)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
PACKAGE PLOTDF
3
 
==============
4
 
 
5
 
Plots the direction field of a first-order ordinary equation (ODE) or
6
 
a system of two autonomous ODE's
7
 
 
8
 
USAGE
9
 
-----
10
 
 
11
 
   load("plotdf.lisp")$
12
 
   plotdf(expr, ...options...);
13
 
   plotdf([expr1,expr2], ...options...);
14
 
 
15
 
In  Maxima 5.9.0, plotdf will only work from xmaxima and you cannot use
16
 
the option "trajectory_at". In Maxima 5.9.1, in addition to those two
17
 
limitations there will also be two options missing from the plot menu:
18
 
"Integrate" and "Plot vs t". To solve those problems see
19
 
http://fisica.fe.up.pt/maxima/plotdf/download.html
20
 
 
21
 
In recent CVS versions plotdf should work fine both from xmaxima and maxima. 
22
 
 
23
 
 
24
 
DESCRIPTION
25
 
-----------
26
 
 
27
 
For one ODE use:
28
 
 
29
 
  plotdf (expr,...,options,..) 
30
 
 
31
 
where expr is an expression depending on x and y, which represents the
32
 
right-hand side of the ODE:
33
 
 
34
 
       dy
35
 
       -- = expr
36
 
       dx
37
 
 
38
 
expr can also depend on a set of parameters that must be given numerical
39
 
values with the "parameters" option and those parameters can be changed
40
 
interactively with the "sliders" option (see "PLOTDF OPTIONS" below).
41
 
 
42
 
For numerical values of x, y, and the parameters, float(ev(expr, numer))
43
 
must return a number.
44
 
 
45
 
For a system of two autonomous, first-order ODE's, use:
46
 
 
47
 
  plotdf ([expr1,expr2],...,options,..)
48
 
 
49
 
Where expr1 and expr2 are two expressions that depend on x and y (but not
50
 
on t), and represent the right-hand side of the ODE's:
51
 
 
52
 
       dx             dy
53
 
       -- = expr1     -- = expr2 
54
 
       dt             dt
55
 
 
56
 
as in the first case, options "parameters" and "sliders" can be used.
57
 
 
58
 
Several options can be given to the plotdf command, or entered into
59
 
the menu that will appear when you click on the upper-left corner of
60
 
the plot window. Integral curves can be obtained by clicking on the
61
 
plot, or with the option "trajectory_at". The direction of the
62
 
integration can be controlled with the "direction" option. The number of
63
 
integration steps is given by "nsteps" and the time interval between
64
 
them is "tstep". The Adams Moulton method is used for the integration;
65
 
it is also possible to switch to an adaptive Runge-Kutta 4th order
66
 
method.
67
 
 
68
 
 
69
 
PLOTDF MENU
70
 
-----------
71
 
 
72
 
The menu in the plot window has the following options: "Zoom", will
73
 
change the behavior of the mouse so that it will allow you to zoom in
74
 
on a region of the plot by clicking with the left button. Each click
75
 
near a point magnifies the plot, keeping the center at the point where
76
 
you clicked. Holding the SHIFT key while clicking, zooms out to the
77
 
previous magnification. To resume computing trajectories when you
78
 
click on a point, select "Integrate" from the menu.
79
 
 
80
 
To change the ODE(s) in use, or change other settings, select "Config"
81
 
in the menu, enter new values in the dialog window, and then click on
82
 
"Replot" in the main menu bar. If you enter a pair of coordinates in
83
 
the field "Trajectory at" in the Config dialog menu, and press the
84
 
"enter" key, a new integral curve will be shown, in addition to the
85
 
ones already shown. You can change the color before you enter the
86
 
point coordinates. When you select "Replot" all integral curves, except
87
 
the last one, will erased.
88
 
 
89
 
Holding the right mouse button down while you move the cursor allows
90
 
you to drag (translate) the plot sideways or up and down. Additional
91
 
parameters such as the number of steps (nsteps), the initial t value
92
 
(tinitial), and the x and y centers and radii, may be set in the
93
 
Config menu.
94
 
 
95
 
You may print to a Postscript printer, or save the plot as a
96
 
postscript file, with the menu option "Save". To switch between
97
 
printing and saving to a Postscript file, select the "Print Options"
98
 
in the dialog window of "Config", change the settings, go back to
99
 
the main menu ("OK" twice) and select "Save".
100
 
 
101
 
PLOTDF OPTIONS
102
 
--------------
103
 
 
104
 
[xradius,12.0]
105
 
 
106
 
Determines the width in x direction of the x values shown by plotdf.
107
 
 
108
 
 
109
 
[yradius,10.5]
110
 
 
111
 
Defines the height in y direction of the y values shown by plotdf.
112
 
 
113
 
 
114
 
[xcenter,0.0],[ycenter,0.0]
115
 
 
116
 
(xcenter,ycenter) is the origin of the window shown by plotdf.
117
 
 
118
 
 
119
 
[width,500]
120
 
 
121
 
Width of plotdf's canvas in pixels.
122
 
 
123
 
 
124
 
[height,500]
125
 
 
126
 
Height of plotdf's canvas in pixels.
127
 
 
128
 
 
129
 
[bbox, -2, -1.2, 3.5, 6]
130
 
 
131
 
Bounding box (xmin ymin xmax ymax) of the region shown by plotdf. It
132
 
will override the values o xcenter, ycenter, xradius, yradius.
133
 
 
134
 
 
135
 
[tinitial,0.0]
136
 
 
137
 
The intial value of the t variable used by plotdf to compute integral
138
 
curves.
139
 
 
140
 
 
141
 
[nsteps,100]
142
 
 
143
 
Number of steps to do in one pass by the integrator of plotdf.
144
 
 
145
 
 
146
 
[tstep,0.01]
147
 
 
148
 
t step size used by plotdf's integrator.
149
 
 
150
 
 
151
 
[xfun,"x^2;sin(x);exp(x)"]
152
 
 
153
 
A semicolon separated list of functions that plotdf will plot on top
154
 
of the direction field.
155
 
 
156
 
 
157
 
[direction,forward]
158
 
 
159
 
The direction (in time) that the integral curves will follow in a
160
 
direction field produced by plotdf. It may be "forward",
161
 
"backward" or "both".
162
 
 
163
 
 
164
 
[versus_t,1]
165
 
 
166
 
Any value different from zero will make plotdf open a window showing
167
 
the time dependence of the independent variables in the last integral
168
 
curve computed.
169
 
 
170
 
 
171
 
[trajectory_at,0.1,3.2]
172
 
 
173
 
(x,y) coordinates of a point through which an integral curve
174
 
should be shown by plotdf.
175
 
 
176
 
 
177
 
[parameters,"k=1.1,m=2.5"]
178
 
 
179
 
List of parameters, and their numerical values, used in the
180
 
differential equation(s) given to plotdf.
181
 
 
182
 
 
183
 
[sliders,"k=0:4,m=1:3"]
184
 
 
185
 
Ranges of the parameters that plotdf will use to put sliders to
186
 
accept interactive change of the equations parameters.
187
 
 
188
 
 
189
 
 
190
 
EXAMPLES
191
 
--------
192
 
 
193
 
To show the direction field of the differential equation
194
 
  y' = exp(-x) + y
195
 
and the solution that goes through (2, -0.1):
196
 
 
197
 
  plotdf(exp(-x)+y,[trajectory_at,2,-0.1]);
198
 
 
199
 
 
200
 
To obtain the direction field for the equation
201
 
  diff(y,x) = x - y^2
202
 
and the solution with initial condition y(-1) = 3, we can use the
203
 
command:
204
 
 
205
 
  plotdf(x-y^2,[xfun,"sqrt(x);-sqrt(x)"],[trajectory_at,-1,3],
206
 
                        [direction,forward],[yradius,5],[xcenter,6]);
207
 
 
208
 
 
209
 
The following example shows the direction field of a harmonic oscillator,
210
 
and the integral curve through (x,y) = (6,0), with a slider that
211
 
will allow you to change the value of m interactively (k is fixed at
212
 
2)
213
 
 
214
 
  plotdf([y,-k*x/m],[parameters,"m=2,k=2"],[sliders,"m=1:5"],
215
 
                                                   [trajectory_at,6,0]);
216
 
 
217
 
 
218
 
The direction field of a Duffing equation:
219
 
 
220
 
  plotdf([y,-(k*x + c*y + l*x^3)/m],[parameters,"k=-1,m=1.0,c=0,l=1"],
221
 
                 [sliders,"k=-2:2,m=-1:1"],[bbox,-3,-3,3,3],[tstep,0.1]);
222
 
 
223
 
 
224
 
The direction field for a damped pendulum, including the
225
 
solution for the given initial conditions, and with a slider that
226
 
can be used to change the value of the mass m:
227
 
 
228
 
  plotdf([y,-g*sin(x)/l - b*y/m/l],[parameters,"g=9.8,l=0.5,m=0.3,b=0.05"],
229
 
         [trajectory_at,1.05,-9],[tstep,0.01],[xradius,6],[yradius,14],
230
 
         [xcenter,-4],[direction,forward],[nsteps,300],[sliders,"m=0.1:1"]);
231
 
 
232
 
 
233
 
 
234
 
$Id: plotdf.usg,v 1.1 2004/10/30 08:21:08 vvzhy Exp $
 
 
b'\\ No newline at end of file'