PACKAGE PLOTDF ============== Plots the direction field of a first-order ordinary equation (ODE) or a system of two autonomous ODE's USAGE ----- load("plotdf.lisp")$ plotdf(expr, ...options...); plotdf([expr1,expr2], ...options...); In Maxima 5.9.0, plotdf will only work from xmaxima and you cannot use the option "trajectory_at". In Maxima 5.9.1, in addition to those two limitations there will also be two options missing from the plot menu: "Integrate" and "Plot vs t". To solve those problems see http://fisica.fe.up.pt/maxima/plotdf/download.html In recent CVS versions plotdf should work fine both from xmaxima and maxima. DESCRIPTION ----------- For one ODE use: plotdf (expr,...,options,..) where expr is an expression depending on x and y, which represents the right-hand side of the ODE: dy -- = expr dx expr can also depend on a set of parameters that must be given numerical values with the "parameters" option and those parameters can be changed interactively with the "sliders" option (see "PLOTDF OPTIONS" below). For numerical values of x, y, and the parameters, float(ev(expr, numer)) must return a number. For a system of two autonomous, first-order ODE's, use: plotdf ([expr1,expr2],...,options,..) Where expr1 and expr2 are two expressions that depend on x and y (but not on t), and represent the right-hand side of the ODE's: dx dy -- = expr1 -- = expr2 dt dt as in the first case, options "parameters" and "sliders" can be used. Several options can be given to the plotdf command, or entered into the menu that will appear when you click on the upper-left corner of the plot window. Integral curves can be obtained by clicking on the plot, or with the option "trajectory_at". The direction of the integration can be controlled with the "direction" option. The number of integration steps is given by "nsteps" and the time interval between them is "tstep". The Adams Moulton method is used for the integration; it is also possible to switch to an adaptive Runge-Kutta 4th order method. PLOTDF MENU ----------- The menu in the plot window has the following options: "Zoom", will change the behavior of the mouse so that it will allow you to zoom in on a region of the plot by clicking with the left button. Each click near a point magnifies the plot, keeping the center at the point where you clicked. Holding the SHIFT key while clicking, zooms out to the previous magnification. To resume computing trajectories when you click on a point, select "Integrate" from the menu. To change the ODE(s) in use, or change other settings, select "Config" in the menu, enter new values in the dialog window, and then click on "Replot" in the main menu bar. If you enter a pair of coordinates in the field "Trajectory at" in the Config dialog menu, and press the "enter" key, a new integral curve will be shown, in addition to the ones already shown. You can change the color before you enter the point coordinates. When you select "Replot" all integral curves, except the last one, will erased. Holding the right mouse button down while you move the cursor allows you to drag (translate) the plot sideways or up and down. Additional parameters such as the number of steps (nsteps), the initial t value (tinitial), and the x and y centers and radii, may be set in the Config menu. You may print to a Postscript printer, or save the plot as a postscript file, with the menu option "Save". To switch between printing and saving to a Postscript file, select the "Print Options" in the dialog window of "Config", change the settings, go back to the main menu ("OK" twice) and select "Save". PLOTDF OPTIONS -------------- [xradius,12.0] Determines the width in x direction of the x values shown by plotdf. [yradius,10.5] Defines the height in y direction of the y values shown by plotdf. [xcenter,0.0],[ycenter,0.0] (xcenter,ycenter) is the origin of the window shown by plotdf. [width,500] Width of plotdf's canvas in pixels. [height,500] Height of plotdf's canvas in pixels. [bbox, -2, -1.2, 3.5, 6] Bounding box (xmin ymin xmax ymax) of the region shown by plotdf. It will override the values o xcenter, ycenter, xradius, yradius. [tinitial,0.0] The intial value of the t variable used by plotdf to compute integral curves. [nsteps,100] Number of steps to do in one pass by the integrator of plotdf. [tstep,0.01] t step size used by plotdf's integrator. [xfun,"x^2;sin(x);exp(x)"] A semicolon separated list of functions that plotdf will plot on top of the direction field. [direction,forward] The direction (in time) that the integral curves will follow in a direction field produced by plotdf. It may be "forward", "backward" or "both". [versus_t,1] Any value different from zero will make plotdf open a window showing the time dependence of the independent variables in the last integral curve computed. [trajectory_at,0.1,3.2] (x,y) coordinates of a point through which an integral curve should be shown by plotdf. [parameters,"k=1.1,m=2.5"] List of parameters, and their numerical values, used in the differential equation(s) given to plotdf. [sliders,"k=0:4,m=1:3"] Ranges of the parameters that plotdf will use to put sliders to accept interactive change of the equations parameters. EXAMPLES -------- To show the direction field of the differential equation y' = exp(-x) + y and the solution that goes through (2, -0.1): plotdf(exp(-x)+y,[trajectory_at,2,-0.1]); To obtain the direction field for the equation diff(y,x) = x - y^2 and the solution with initial condition y(-1) = 3, we can use the command: plotdf(x-y^2,[xfun,"sqrt(x);-sqrt(x)"],[trajectory_at,-1,3], [direction,forward],[yradius,5],[xcenter,6]); The following example shows the direction field of a harmonic oscillator, and the integral curve through (x,y) = (6,0), with a slider that will allow you to change the value of m interactively (k is fixed at 2) plotdf([y,-k*x/m],[parameters,"m=2,k=2"],[sliders,"m=1:5"], [trajectory_at,6,0]); The direction field of a Duffing equation: plotdf([y,-(k*x + c*y + l*x^3)/m],[parameters,"k=-1,m=1.0,c=0,l=1"], [sliders,"k=-2:2,m=-1:1"],[bbox,-3,-3,3,3],[tstep,0.1]); The direction field for a damped pendulum, including the solution for the given initial conditions, and with a slider that can be used to change the value of the mass m: plotdf([y,-g*sin(x)/l - b*y/m/l],[parameters,"g=9.8,l=0.5,m=0.3,b=0.05"], [trajectory_at,1.05,-9],[tstep,0.01],[xradius,6],[yradius,14], [xcenter,-4],[direction,forward],[nsteps,300],[sliders,"m=0.1:1"]); $Id: plotdf.usg,v 1.1 2004/10/28 14:15:41 villate Exp $