File: DNE97OWN.doc (c) July 1997 H.E. Nusse and J.A. Yorke This text is based on Chapter 13 in DYNAMICS: NUMERICAL EXPLORATIONS, Second, Revised and Expanded Edition (Springer-Verlag, New York, 1997) by H.E. Nusse and J.A. Yorke ADDING YOUR OWN PROCESS TO DYNAMICS Contents: 1. Introduction 2. Adding a new map 3. Adding a new differential equation 4. Storing pictures of an OWN process 5. Functions added since the second edition went to the printer 1. INTRODUCTION Although there is a variety of maps and differential equations in the menus of Dynamics, you may want to study a process that is not in the menus. You can add your own processes to the program as follows. We first describe how to add a map. Start the program as usual. Type dynamics and the first menu that appears will have the line: OWN - enter your OWN process When you select this entry, four windows will appear on your screen, presenting an example of how to add a new process. Simply change what is in these four windows to define your process. When adding adding a process, the following keys are important for carrying out this task: hit to cancel the option of adding a new process to Dynamics; hit to go to the next window; hit to compile after you have inserted the new process; hit for adding a map to Dynamics; hit for adding a differential equation to Dynamics; use for erasing text in any of the windows; use for erasing a line of text; use for erasing all text in a window. 2. ADDING A NEW MAP When you select the entry "OWN" from the map menu, four windows will appear on your screen, in approximately the following format, presenting an example of how to add a map to Dynamics. First some general comments. * In each window, the `!' means that the rest of the line is a comment. Delete superfluous text using , or . Note. For deleting text, does not work. * The equations are not case sensitive. Use either upper or lower case letters. * The computer screen shows only 4-6 lines of each window. You may use more than the number of lines shown. However, if you use more lines, then a part of the information will be hidden whenever you switch to another window, but can be accessed with the arrow keys. * In the windows you can have more than one equation per line or more than one line per equation. Temporary variables need not be initialized. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Henon map | | (x,y) --> (rho - x*x + c1*y, x) | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := rho - x*x + c1*y | | y := x | | | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | x := 0 | | y := 2 | | c1 := -0.3 | | rho := 2.12 | | x_lower := -2.5 x_upper := 2.5 | | y_lower := -2.5 y_upper := 2.5 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | x := y | | y := (x - rho + y*y) / c1 ! Warning: do not use c1 = 0 | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== Simply change what is in these four windows to define your map. Of course, there are some rules which are described later. We first describe the contents of the windows followed by some detailed examples. DOCUMENTATION WINDOW The Documentation window provides text that will appear whenever you call either the Main Menu or the Parameter Menu. It will also be part of printed copies of pictures, when you print them using Text Level 2 or 3. * Document your work! Generally it is best to use four lines of text or less. * All the text in the Documentation window will appear on the screen when the Main Menu or the Parameter Menu is called. It will also be part of printed copies of pictures, when you print them using Text Level 2 or 3. MAP WINDOW The map that you want to add must be defined in the Map window. * Allowed process parameters: c1, ..., c9, phi, rho, sigma, beta. * Allowed main variables: r, s, t, ..., z. The value of the main variables that are used are inserted into y[0], y[1], etc. You can find their values using the command YV. The program makes a list in alphabetical order of the r, s, t, ..., z variables you use and assigns them to y[0], y[1], y[2], ... . If you use r, x, and y (listing them alphabetically), their values will be inserted into y[0], y[1], and y[2], respectively. * Allowed phase space variables: u, ..., z. These variables have a special role. When the quasi-Newton method is used, for example, numerical partial derivatives are computed with respect to these variables, and the Lyapunov exponents indicate how fast these variables move apart. In practice, these six variables will be the only ones used for maps, unless you use r, s, and t for plotting. You might, for example, define r and s to be variables that give a better plot. * Each main variable used must appear on the left side of an equation exactly once in the Map window. INITIALIZATION WINDOW The initial values that are listed in the Initialization window alert the program to the elements used in your process. Notice that you can have more than one equation per line. * All the main variables and parameters that appear in the Map window are initialized with value 0 unless you initialize them here. * C1,..., C9, phi, rho, sigma, beta are the only parameters permitted in equations. Their values will appear in the Parameter Menu PM. * As described above, the program makes a list in alphabetical order of the variables you use and assigns to them y[0], y[1], y[2], ... . If you use two or more phase space variables, then the first two phase space variables when listed alphabetically are assigned to XCO and YCO. If you use only w and z, then w corresponds to y[0] and z to y[1]. If you wish to plot w horizontally and z vertically, then the Initialization window would include XCO := 0 ! w is variable # 0 YCO := 1 ! z is variable # 1 Actually the above assignment is automatic and does not have to made explicitly. If you use x, y and z, then x corresponds to y[0], y to [y1] and z to y[2]. If you wish to plot y horizontally and z vertically, then the Initialization window would include XCO := 1 ! y is variable # 1 YCO := 2 ! z is variable # 2 * The default scale both horizontally and vertically is 0 to 1. If you wish to change one of these, then as in the example above define the variables x_lower x_upper and/or y_lower y_upper Their values will appear in the Parameter Menu PM. * You may even wish to define Z_lower Z_upper and ZCO if you plan use three dimensional plots. * Anything defined in this window can be changed by using standard commands of the program. For example, if you choose the defaults, then you can redefine the scale using the X Scale and Y Scale commands XS and YS, which are in the Parameter Menu PM. INVERSE MAP WINDOW Using the Inverse map window is optional. The inverse is used in calculating stable manifolds and in going backwards in time for DE's (see the inVerse command V). If you want to make use of the inverse (provided it exists) then you must define the inverse in the Inverse map window. * The program does not check to verify that the map you provide is in fact the inverse. See command V (inVerse map). NO TEXT IN THE INITIALIZATION WINDOW FOR MAPS If you erase all text in the Initialization window of the Henon map, then after you have compiled this process, the Parameter Menu is of approximately the following format ================================================= | PM -- PARAMETER MENU | | | | OK - parameters are fine as set | | XCO - X COordinate to be plotted: y[0] | | XS - X Scale: from 0 to 1 | | YCO - Y COordinate to be plotted: y[1] | | YS - Y Scale: from 0 to 1 | | C1 - C1 = 0.00000000 | | RHO - rho = 0.00000000 | | SD - Screen Diameters: 1.00 | | | | MENUS | | VM - Vector Menu for initializations, etc. | | WWM - When and What to plot Menu | ================================================= The Y Vectors are set as follows: ============================================================= | YV -- Y VECTORS | | | | Vectors -- y0 = y = current state, y1 = cursor position | | state vec y storage vec y1 storage vec y2 | | y[0] = 0; y1[0] = 0; y2[0] = NOT SET | | y[1] = 0; y1[1] = 0; y2[1] = NOT SET | | | | storage vec ya storage vec yb storage vec ye | | ya[0] = 0; yb[0] = 0; ye[0] = NOT SET | | ya[1] = 0; yb[1] = 0; ye[1] = NOT SET | ============================================================= For the case of the Henon map and other maps, you can set parameters like C1 and RHO, coordinates XCO and YCO, and scales XS and YS as you wish. You also may set the vectors. Hence, you may leave the Initialization window empty. EXAMPLE 1. ADDING THE HOLMES MAP TO DYNAMICS The objective of this example is to show how to add the Holmes map, a cubic map in the plane, (X,Y) --> (RHO*X - X*X*X + C1*Y, X) to Dynamics using the OWN-feature. For our convenience, we use "Own-Holmes map" in the Documentation window. See also Section 4, entitled "Storing data and pictures of an OWN-process". Start Dynamics and select OWN, and add the equations as indicated below. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-Holmes map | | (x,y) --> (rho*x - x*x*x + c1*y, x) | | | | | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := rho*x - x*x*x + c1*y | | y := x | | | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | c1 := 0.95 | | rho := 1.5 | | x_lower := -2.0 x_upper := 2.0 | | y_lower := -2.0 y_upper := 2.0 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | x := y | | y := (x - rho*y + y*y*y) / c1 ! Warning: do not use c1 = 0 | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. Plot the unstable manifold of the fixed point (0,0) (command UM). The resulting picture is shown in Figure 13-1a in "Dynamics: Numerical Explorations" (Edition 1997). To store the picture on disk, we recommend to have the file easily recognized as being a picture file created by a process that has been added to Dynamics by the OWN feature. For example, store this picture under the file name O-Ho-um.pic. Note. As discussed above, you may leave the Initialization window empty. Then C1 = rho = 0 = y1[0] = y1[1] and scales are from 0 to 1. Note. You can create a picture of a chaotic saddle by entering command SST; see Figure 13-1b in "Dynamics: Numerical Explorations" (Edition 1997). EXAMPLE 2. ADDING A ONE-DIMENSIONAL MAP TO DYNAMICS The purpose of this example is showing how to add a one-dimensional real cubic map X --> X*X*X + C1*X + RHO to Dynamics using the OWN-feature. For our convenience, we use "Own-RealCubic map" in the Documentation window. See also Section 4, entitled "Storing data and pictures of an OWN-process". Start Dynamics and select OWN, and add the equations as indicated below. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-RealCubic map | | x --> x*x*x + c1*x + rho | | Plot x at time n (horizontally) against x at time n+1 (vertically) | | | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := x*x*x + c1*x + rho | | | | | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | x := 0.5 | | c1 := -0.5 | | rho := 1.0 | | x_lower := -1.0 x_upper := 1.0 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. Note. Since there is one phase space variable, Dynamics will plot x vertically and horizontally it will plot x at the previous time, that is, at time n it plots (x[n-1],x[n]) where x[n] denotes the value of x at time n. Note. As discussed above, you may leave the Initialization window empty. Then C1 = rho = 0 = y1 = y0 and the scales are from 0 to 1. EXAMPLE 3. ADDING A PIECEWISE LINEAR MAP TO DYNAMICS In this example we want to show how to add the Piecewise Linear map (X,Y) --> (C1*X + Y + RHO, C2*X) if X <= 0 (X,Y) --> (C3*X + Y + RHO, C4*X) if X > 0 to Dynamics using the OWN-feature. Although the Piecewise Linear map is a process of Dynamics, we carry out this example, because it is of different type than, for example, the Henon map. For our convenience, we use "Own- Piecewise Linear map" in the Documentation window. See also Section 4, entitled "Storing data and pictures of an OWN-process". Start Dynamics and select OWN, and add the equations as indicated below. You will find out that on PC's, this "OWN" version runs slightly slower than PL. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-Piecewise Linear map | | (x,y) --> (c1*x + y + rho, c2*x) if x < 0 or x = 0 | | (x,y) --> (c3*x + y + rho, c4*x) if x > 0 | | | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := if (x <= 0 ) then (C1*x + y + rho) else (C3*x + y + rho) | | y := if (x <= 0 ) then (C2*x) else (C4*x) | | | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | c1 := -1.25 c2 := -0.1 c3 := -2 c4 := -2 | | rho := 0.4 | | x_lower := -1.0 x_upper := 1.0 | | y_lower := -1.0 y_upper := 1.0 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. Note. You may leave the Initialization window empty. Then C1 = C2 = C3 = C4 = rho = 0, and the scales are from 0 to 1. EXAMPLE 4. ADDING A ONE-DIMENSIONAL PIECEWISE LINEAR MAP TO DYNAMICS This example exhibits how to add the one-dimensional 3PL map X --> C1*X + rho if X <= beta X --> C2*X + (C1-C2)*beta + rho if beta < X <= sigma X --> C3*X + (C2-C3)*sigma + (C1-C2)*beta + rho if X > sigma to Dynamics using the OWN-feature. For our convenience, we use "Own-3PL map" in the Documentation window. See also Section 4, entitled "Storing data and pictures of an OWN-process". Start Dynamics and select OWN, and add the equations as indicated below. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-3PL map | | X --> C1*X + rho if X <= beta | | X --> C2*X + (C1-C2)*beta + rho if beta < X <= sigma | | X --> C3*X + (C2-C3)*sigma + (C1-C2)*beta + rho if X > sigma | | Plot x at time n (horizontally) against x at time n+1 (vertically) | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := if x <= sigma then | | (if x <= beta then C1*x + rho else C2*x + (C1-C2)*beta + rho) | | else C3*X + (C2-C3)*sigma + (C1-C2)*beta + rho | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | c1 := 0.9 c2 := -7 c3 := 0.5 | | beta := 0.2 sigma := 0.8 | | x_lower := -4.0 x_upper := 4.0 ! scale for horizontal plot | | y_lower := -4.0 y_upper := 4.0 ! scale for vertical plot | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. A bifurcation diagram for this map (BIFS) is shown in Figure 13-2 in "Dynamics: Numerical Explorations" (Edition 1997). Note. As discussed above, you may leave the Initialization window empty. In that case, c1 = c2 = c3 = beta = sigma = 0. EXAMPLE 5. ADDING A SQUARE ROOT MAP TO DYNAMICS In this example we demonstrate how to add the square root map (X,Y) --> (C1*X + Y + RHO, C2*X) if X <= 0 (X,Y) --> (C3*sqrt(X) + Y + RHO, C4*X) if X > 0 using the OWN-feature. For our convenience, we use "Own-Square root map" in the Documentation window. See also Section 4, entitled "Storing data and pictures of an OWN-process". Start Dynamics and select OWN, and add the equations as indicated below. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-Square root map | | (x,y) - -> (c1*x + y + rho, c2*x) if x < 0 or x = 0 | | (x,y) - -> (c3*sqrt(x) + y + rho, c4*x) if x > 0 | | | =========================================================================== | Map window | --------------------------------------------------------------------------- | x := if (x <= 0 ) then (C1*x+y+rho) else (C3*sqrt(x)+y+rho) | | y := if (x <= 0 ) then (C2*x) else (C4*x) | | | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | x := 1 y := 1 | | c1 := 1 c2 := -0.2 c3 := -2 c4 := -0.2 | | rho := 0.1 | | x_lower := -1.0 x_upper := 0.5 | | y_lower := -0.15 y_upper := 0.25 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit and compile. Plot the trajectory. The resulting picture is similar to Figure 12-1 in "Dynamics: Numerical Explorations" (Edition 1997). Note. As discussed above, you may leave the Initialization window empty. Then C1 = C2 = C3 = C4 = rho = 0 and scales are from 0 to 1. EXAMPLE 6. USING TEMPORARY VARIABLES: ADDING THE GUMOWSKI/MIRA MAP TO DYNAMICS In this example we demonstrate how to add the Gumowski/Mira map (X,Y) --> (C1*(1+C2*Y*Y)*Y + F(X), -X + F(Xnew)) F(u) = rho*u + 2*(1-rho)*u*u/(1+u*u) using the OWN-feature. Although the Gumowski/Mira map is a process of Dynamics, we carry out this example, because it demonstrates when temporary variables might be used. For our convenience, we use "Own-Gumowski/Mira map" in the Documentation window. See also Section 4 for storing data and pictures. Start Dynamics and select OWN, and add the equations as indicated below. In this example, the temporary variables are F0, F1, and xNew. These do not appear in the Initialization window. See below for the rules for temporary variables. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-Gumowski/Mira map | | (x,y) --> (c1*(1+c2*y*y)*y + F(x), -x + F(xNew)) | | F(u) = rho*u + 2*(1-rho)*u*u/(1+u*u) | | | =========================================================================== | Map window | --------------------------------------------------------------------------- | F0 := rho*x + 2*(1-rho)*x*x/(1+x*x) | | xNew := c1*(1+c2*y*y)*y + F0 | | F1 := rho*xNew + 2*(1-rho)*xNew*xNew/(1+xNew*xNew) | | y := -x + F1 | | x := xNew | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | x := 1 y := 1 | | c1 := 1 c2 := 0 rho := 0.3 | | x_lower := -20 x_upper := 20 | | y_lower := -20 y_upper := 20 | =========================================================================== | Inverse map window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. Note. As discussed above, the Initialization window can be empty. BASIC RULES FOR ADDING A NEW MAP TO DYNAMICS Simply change what is in these four windows to define your map. Of course, there are some rules. Standard algebraic expressions are allowed. * Use * to denote multiplication * Arithmetic operators (* / + -) have their conventional precedence. * Expressions can use the usual algebraic expressions as well the number pi (pi = 3.14...) and the following functions: sin, cos, tan, atan, sqrt, exp, mod, log (log base e), log10 (log base 10), rand as well as absolute value |E| of an expression E and power E^G, where either E is positive or G is an integer. * If you are in doubt as to whether you need parentheses in an expression, they do no harm so they can be added. * First, the values of the main variables (r, s, ..., z) are first inserted into the right hand side of all the equations, and then the equations are evaluated sequentially. Consider the case where x and y both have initial values of 0.0 and the process is defined by x := y + 1 y := x First, the value 0.0 is inserted for x and y in the right hand side of both equations. The x in the second equation is the initial value. Hence after one iterate, x is 1 and y is 0. The sequential evaluation is only important if temporary variables are used. * See below for a discussion of temporary variables. Such variables must be defined in each window in which it is used, so temp := temp+1 cannot be the first line of a window. RANDOM NUMBER RAND( ) The function rand( ) selects a pseudo-random number between -1 and 1. For example, temp := rand( ). Notice that rand( ) is a function with no arguments! MOD FUNCTIONS The function mod has two formats, one with two arguments and one with three. The expression mod(E,G) (where G > 0) means some integer multiple of G is added to or subtracted from E so that the result lies in the interval [0,G). The standard mathematical way of writing this is E mod(G), but that terminology won't work for Dynamics. The expression mod(E,G,H) where G < H means some integer multiple of H-G is added to or subtracted from E so that the result lies in the interval [G,H). For example, mod(4,2*pi) = 4 while mod(4, -pi, pi) = 4 - 2*pi. Note. mod(E,0,H) is equivalent to mod(E,H). IF ( ) THEN ( ) ELSE ( ) The expression "If (E) then (F) else (G)" denotes a function, since it returns a value. The expression E is a logical expression using =, <, >, <> (not equal), <=, >= . Here are some examples. Example a. The following line declares x to be the maximum of y and z. x := if (y > z) then y else z ! notice that x is the maximum of y and z Example b. The following Map window defines the Piecewise Linear map PL. =========================================================================== | Map window | --------------------------------------------------------------------------- | x := if (x <= 0 ) then (C1*x + y + rho) else (C3*x + y + rho) | | y := if (x <= 0 ) then (C2*x) else (C4*x) | =========================================================================== The following example uses "if ( ) then ( ) else ( )" and mod. Notice that if ( ) then ( ) else ( ) is a function of three arguments that has a value. In particular the "else" argument cannot be omitted. Example c. The following Map window defines the Rotor map R. =========================================================================== | Map window | --------------------------------------------------------------------------- | x := mod(x+y, -pi, pi) | | y := if (c1 <> 1 ) then (y + rho*sin(x+y)) | | else (mod(y + rho*sin(x+y), -pi, pi)) | =========================================================================== Note the last equation occupies two lines, but that is not a problem for the compiler. It can be rewritten: y := if (c1 = 1) then (mod(y + rho*sin(x+y), -pi, pi)) else (y +rho*sin(x+y)) IF( ) AND LOGICAL DECISIONS For more complicated logical decisions, "if ( )" uses key words AND, OR, and NOT. Hence (x <= 0) OR (y < 0) and (x^2 + y^2 > 1) AND NOT (x^3 + y^3 < 2) are legitimate arguments for "if ( )". 3. ADDING A NEW DIFFERENTIAL EQUATION Equation entry can be in one of two modes, called Map Mode or Differential Equation Mode. Each accepts three windows of inputs in addition to the Documentation window. In Map Mode these are called the map, inverse map, and initialization. In DE Mode these are called vector field, modulo, and initialization. After selecting OWN, you will be in the Map Mode. To switch to the Differential Equation, press and four windows will appear on your screen, in approximately the following format, presenting an example of how to add a differential equation to Dynamics. In each of the four windows, the `!' means that the rest of the line is a comment. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | forced damped Pendulum | | x'' + c1*x' + c2*sin(x) = rho*(c3 + cos(phi*t)) | | | | | =========================================================================== | Vector field window | --------------------------------------------------------------------------- | s' := 1 ! this is time | | t' := 1 ! this is time mod 2*pi/phi (see Modulo window) | | x' := y | | y' := rho*(c3 + cos(phi*t)) - c1*y - c2*sin(x) | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | t := 0 x := 1 y := 0 | | x_upper := pi x_lower := -pi y_upper := 4 y_lower := -2 | | c1 := 0.2 c2 := 1.0 c3 := 0.0 rho := 2.5 phi := 1 | | spc := 30 ipp := 30 ! Take 30 steps per 2*pi/phi and | | ! plot once in 30 steps | =========================================================================== | Modulo window | --------------------------------------------------------------------------- | t := mod (t, 2*pi) | | x := mod (x, -pi, pi) | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== Using the pendulum process P to create a basins picture is slightly faster on PC's than the corresponding picture made with OWN. For most purposes however, the difference in speed is less important than the convenience of getting the program running. Simply change what is in these four windows to define your map. Of course, there are some rules which are described later. We first describe the contents of the windows followed by some detailed examples. The four windows follow essentially the same rules as for maps, and use the same variables and functions and parameters. See Section 2 for details. VECTOR FIELD WINDOW Differential equations to be added are written in the Vector field window. INITIALIZATION WINDOW The step sized used by the differential equation solver is specified in this window. MODULO WINDOW Using the Modulo window is optional. The equation(s) in this window are applied after each time step of the differential equation solver. TEXT IN THE INITIALIZATION WINDOW FOR DIFFERENTIAL EQUATIONS For maps it has been discussed that you are allowed not to enter anything in the Initialization window. All the parameters are set to be zero and the scales run from 0 to 1. The same holds for differential equations like the Lotka/Volterra equations. In addition to these settings of parameters, the step size is set to be 0.01. For the forced damped pendulum and other periodically forced differential equations, it is required that the "spc := 30" is included. However, it may be better to include "ipp := 30". Since the forced damped Pendulum equation is in fact acting on a cylinder, you should also include "x_upper := pi x_lower := -pi". Therefore, the minimal contents of the Initialization window for the forced damped pendulum is the following: ============================================================ | Initialization window | ------------------------------------------------------------ | x_upper := pi x_lower := -pi | | spc := 30 ipp := 30 ! Take 30 steps per 2*pi/phi and | | ! plot once in 30 steps | ============================================================ EXAMPLE 7. ADDING THE LOTKA/VOLTERRA EQS. TO DYNAMICS In this example we add the Lotka/Volterra eqs. X' = (C1 + C3*X + C5*Y)*X Y' = (C2 + C4*Y + C6*X)*Y to Dynamics using the OWN-feature. Although the Lotka/Volterra equations are a process of Dynamics, we will carry out this example. For our convenience, we use "Own-Lotka/Volterra DE" in the Documentation window. See also Section 4 for storing data and pictures. Start Dynamics and select OWN, hit and add the equations as indicated. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-Lotka/Volterra DE | | x' = (c1 + c3*x + c5*y)*x | | y' = (c2 + c4*y + c6*x)*y | | | =========================================================================== | Vector field window | --------------------------------------------------------------------------- | t' := 1 ! this is time | | x' := (c1 + c3*x + c5*y)*x | | y' := (c2 + c4*y + c6*x)*y | | | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | step := 0.01 | | x_lower := 0 x_upper := 1000 | | y_lower := 0 y_upper := 1000 | | x := 10 | | y := 100 | | c1 := 0.5 c3 := -0.0005 c5 := -0.00025 | | c2 := 0.5 c4 := -0.0005 c6 := -0.00025 | =========================================================================== | Modulo window | --------------------------------------------------------------------------- | | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. The differential equation solver will use the "step" that is specified in the Initialization window. You may change its value, which is listed in the menu DEM. EXAMPLE 8. ADDING THE GOODWIN EQUATION TO DYNAMICS In this example we add the GoodwiN equation x'' + c1*((x^2 -1)/(x^2 +1))*x' - c2*x + c3*x^3 = rho*sin(phi*t) to Dynamics using the OWN-feature. Although the GoodwiN equation is a process of Dynamics, we will carry out this example for comparison. For our convenience, we use "Own-GoodwiN DE" in the Documentation window. See also Section 4. Start Dynamics and select OWN, hit , erase the example provided, and add the equations as indicated. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | Own-GoodwiN DE | | x'' + c1*((x^2 -1)/(x^2 +1))*x' - c2*x + c3*x^3 = rho*sin(phi*t) | | | | | =========================================================================== | Vector field window | --------------------------------------------------------------------------- | s' := 1 ! this is time | | t' := 1 ! this is time mod 2*pi/phi (see Modulo window) | | x' := y | | y' := -c1*((x*x-1)/(x*x+1))*y + c2*x - c3*x*x*x + rho*sin(phi*t) | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | t := 0 x := 1 y := 0 | | x_upper := 6 x_lower := -6 y_upper := 17 y_lower := -7 | | c1 := 0.1 c2 := 0.5 c3 := 0.5 rho := 37 phi := 1 | | spc := 80 ipp := 80 ! Take 80 steps per 2*pi/phi and | | ! plot once in 80 steps | =========================================================================== | Modulo window | --------------------------------------------------------------------------- | t := mod (t, 2*pi) | | | | | | | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== After completing the typing, hit to compile. Plot the trajectory and the resulting picture is shown in Figure 13-3 in "Dynamics: Numerical Explorations" (Edition 1997). Note. The variable phi is a special variable used in time-periodic differential equations; see below. We could use temporary variable x2 replacing the y'-equation with two equations: x2 := x*x y' := -c1*((x2-1)/(x2+1))*y + c2*x - c3*x*x2 + rho*sin(phi*t) BASIC RULES FOR ADDING A DIFFERENTIAL EQ. TO DYNAMICS The rules are essentially the same as for maps; see Section 2. In addition: * For each main variable used, there must be precisely one differential equation. TEMPORARY VARIABLES In writing equations, you can also use temporary variables. They can have any name beginning with a letter using up to 8 letters and digits, except the names cannot be the names of parameters c1, ..., c9 or main variables r, s, t, ..., z or function names sin, exp, .. or reserved words pi, AND, NOT, ... mentioned earlier in this chapter. For an example, see xNew in Example 6. Each temporary variable must be defined in each window in which it is used, so "temp := temp+1" can not be the first line of a window. SPECIAL PARAMETER PHI Adding a differential equation is quite similar to the process for adding a map. Here the parameter phi has a special role and should be used only when there is a time dependent periodic forcing. It appears in arguments of periodic forcing functions. The forced damped Pendulum and the GoodwiN equation are examples of these of these type. The program knows that a differential equation is going to be used when it finds the differential equation step size has been set, that is the variable "step" (for example, step = .01). The Lotka/Volterra equations is an example of this type. See also "Rules for periodically forced differential equations" below. RULES FOR PERIODICALLY FORCED DIFFERENTIAL EQUATIONS The pendulum example above has a time periodic term rho * (C3 + cos(phi * T)) in its equation X'' + C1 * X' + C2 * sin(X) = rho * (C3 + cos(phi * T)) For such examples, it is common to plot points once every period. The program allows such plotting only if the variable phi is defined. The period is assumed to be 2*pi/phi. Hence even if you have a fixed period in your example, phi should be defined. In the Initialization window you may also assign SPC (steps_per_cycle). If phi is defined and SPC is not, it is given the default values 50, and the time step STEP is given the value STEP = 2*PI/(PHI*SPC) for differential equations. The default values are .01 and 50. If you set PHI, it should be greater than 0. Another variable that can be set in the Initialization window is IPP It has a default value of 1. If you wish the trajectory to plotted once each period, give it the same value you give to PHI. Do NOT write IPP = PHI because PHI does not have a value in the Initialization window. EXAMPLE 9: PLOTTING A DIFFERENTIAL EQUATION IN POLAR COORDINATES This example shows how to choose coordinates for plotting which are not usual coordinates. Here we add two coordinates r and s purely for the purpose of plotting. Since they are coordinates, they must be initialized and be given differential equations. Since they are assigned explicit values in the Modulo window, their initializations and differential equations have no influence on their values after each time step. Notice below that in the Modulo window we make the following assignments: =========================================================================== | Modulo window | --------------------------------------------------------------------------- | r := (y + 2)*sin(x) | | s := (y + 2)*cos(x) | =========================================================================== The variables used are r, s, t, x, y in alphabetical order, so r and s correspond to y[0] and y[1]. To plot these, the Initialization window sets: Xco := 0 Yco := 1 Then trajectories will plot (r,s). Notice that since they are variables, they must be initialized and must have differential equations even though these initializations and equations do not affect the values of r and s when they are plotted. Start Dynamics and select OWN, hit and add the equations as indicated below. Warning: In this example, the variables r and s are not the variables of the differential equations and some routines may behave strangely. In the above example changing r and s with arrow keys does not affect x and y. =========================================================================== | Documentation window | --------------------------------------------------------------------------- | forced damped Pendulum | | x'' + c1*x' + c2*sin(x) = rho*(c3 + cos(phi*t)) | | Polar coordinate plot: x is an angle and | | y + 2 is the distance to the origin; | | r = y[0] s = y[1] t = time = y[2] x = y[3] y = y[4] | =========================================================================== | Vector field window | --------------------------------------------------------------------------- | r' := 0 s' := 0 ! these are dummy equations; | | ! they don't affect plots. | | t' := 1 ! this is time mod 2*pi/phi (see Modulo window) | | x' := y | | y' := rho*(c3 + cos(phi*t)) - c1*y - c2*sin(x) | =========================================================================== | Initialization window | --------------------------------------------------------------------------- | t := 0 x := 1 y := 0 | | r := 0 s:= 0 ! r and s must be initialized | | ! even though the values do not affect plots. | | x_upper := 6 x_lower := -6 y_upper := 5.5 y_lower := -4.5 | | c1 := 0.2 c2 := 1.0 c3 := 0.0 rho := 2.5 phi := 1 | | spc := 30 ipp := 30 ! Take 30 steps per 2*pi/phi and | | ! plot once in 30 steps | =========================================================================== | Modulo window | --------------------------------------------------------------------------- | t := mod (t, 2*pi) | | x := mod (x, -pi, pi) | | r := (y + 2)*sin(x) | | s := (y + 2)*cos(x) | =========================================================================== | Esc=Cancel Tab=Next F4=DiffEqs F1=Compile Ctrl-K=EraseLine Ctrl-W=EraseW| =========================================================================== 4 STORING DATA AND PICTURES OF AN OWN-PROCESS After tapping and successfully entering the stage for iteration, you can store your equations using the Dump Data command DD or the TO Disk TD (which stores the picture you have created as well as the data). Here's how this might appear in a DD file. Each window is encapsulated by quotes. The DD file continues on (not shown here) with additional changes you have made, such as changes in parameters or scales, etc. These are not reflected in the map but are contained in the file. See "Dynamics: Numerical Explorations" (Edition 1997), Section 4.4 for the use of the *.dd and *.pic files. own /* process from map menu */ 1 "The Henon Map (x,y) --> (rho - x*x + c1*y,x) " "x := rho - x*x + c1*y y := x" "x := 0 y := 2 c1 := -0.3 rho := 2.12 x_lower := -2.5 x_upper := 2.5 y_lower := -2.5 y_upper := 2.5" "x := y y := (x - rho + y*y) / c1" Here's how the pendulum equation might appear in a DD file: own /* process from map menu */ 0 "Forced damped pendulum X'' + C1 * X' + C2 * sin(X) = rho * (C3 + cos(phi * T)) " "s' := 1 ! this is time t' := 1 ! this is time mod 2 pi/ phi x' := y y' := rho * (C3 + cos(phi * t)) - C1 * y - C2 * sin(x) "t := 0 x := 1 y := 0 X_upper := pi X_lower := -pi Y_upper := 4 Y_lower := -2 C1 := 0.2 C2 := 1.0 C3 := 0.0 rho := 2.5 phi := 1 spc := 30 ipp := 30" "t := mod(t, 0, 2*pi / phi) x := mod(x, -pi, pi)" ROOT NAME If you have created your own process using Dynamics's OWN feature, the the default root name is "own". Hence, if you save data using command DD, then the data is saved in file OWN.DD. If you store a picture that has been created by this process, then it is stored in file OWN.PIC. We recommend to change, for example, the root name of the Holmes map to O-HO, and the root name of the GoodwiN equation to O-GN. Of course, you may want variants for these. As an example, the picture that has been created in Example 1 (Figure 13-1a in "Dynamics: Numerical Explorations" (Edition 1997) can be stored in the file "o-ho.pic", but a file name like "o-ho-um.pic" might be better to indicate that the picture is an unstable manifold for the Holmes map that was created by the own-feature of Dynamics. 5. Functions added since the second edition went to the printer The following functions have been introduced into OWN. 8/27/97 They are also described in yhelp.txt under OWN. The book mentions that the following functions that can be used with own: rand(),sin(),cos(),tan(),atan(),sqrt(),log(),exp(),| |(abs.val.), x^y, if()then()else(), and mod() [that is, both mod(x,a) and mod(x,a,b)]. The following functions have been introduced into OWN, but are not in the book. The are most useful for maps rather than differential equations; to use them for the latter, it is usually best to use them in the Modulo window. The format of OWN requires everything be in an equation. Most of these functions (like beep() have no real role in a function so it is necessary to artificially include it in one; e.g. a := beep() Here a is a dummy variable that will not be used. All of the functions do return a value so such equations are well defined, and that value is 0 unless otherwise specified below. ** New Functions beep() Tells the computer to beep once. c() Clear the screen. con() It is like the command CON. It tells the program to connect successive points with a straight line. dis() This turns CON off; it is like the command DIS. dot() or dot(number) returns "dot". If there is an argument "number", then dot is set to be that number, and the new value of dot is returned. getcolor(x,y) This checks to see what the color is of the pixel containing x,y. If it is outside the screen, it returns -1. ** i() This is equivalent to command I; initialize y[]. i1() This is equivalent to command I1; change y1 to be at y[]. int(num) returns the greatest integer <= num. This is the same as num - mod(num,1). kk() kk() is the same as KK; plot a cross at current point y[]. kkk(0 or non-zero value) This function is like the command KKK which is a toggle. Here however kkk has an argument, essentially "on" or "off". kkk(value) turns off KKK if value is 0; otherwise it turns KKK on (plot crosses at each dot. kks(5,5) This is the same as the command KKS. It sets the size of the arms of the cross, horizontal and height, in screen pixels; hence after kks(5,6), all crosses plotted will be 11 pixels by 13 wide. ** line(x1,y1,x2,y2) Here line must have 4 arguments (or none, see below). It connects x1,y1 to x2,y2 with a straight line. pause(seconds) pause for the specified number of seconds. Actually, the number of seconds is only a guideline; you must experiment to get the length pause you want. ** noplot() suppresses the program's automatic plot routine for one iterate of the process. Hence all the plotting can be done from within own. if own calls plot() or line(), then noplot() is automatically turned ON. Sometimes you may wish to have the routine plot something only on some of the iterates and still you want the automatic routine suppressed. Then noplot() should be called. plot(x,y) After the map is applied, the program plots a point (or line). This command is for more flexibility in plotting. If this is applied by the map, then the program will not automatically plot a point after that iterate. The point x,y can be plotted by using a line like inscreen := plot(x,y) . Plot returns a value of +1 if the point is in the screen area and 0 otherwise; hence it is possible to keep track of the number of points actually plotted. quit() This says quit iterating the map and go back to menus. This function would usually be used with the function if()then()else(). ** save() equal to command SAVE (i.e., TD) except that you will not be prompted for a file name. Whatever name has been set using RN will be used. setcolor(num) This sets the color used for plotting, namely "num" in the case shown. The color can be set to 0 if you want to obliterate something by plotting over it. It returns the old value. Hence by using it twice, you can get the current value of color without changing it. print(num) prints the number on row 1; the top line of the screen is row 1. print(num,row) prints the number on row "row" . ** Example of printing output on lines 1 and 2 x := rho - x*x + c1*y y := x d := dot() e := print(d,1) + print(int(d/100),2)" This example prints the regular Henon map incrementing colors and also a flipped version in color 12; the use of xx illustrates that whenever x or y appears on the right hand side, it is the original value which is not updated until the evaluations of the map or DE are complete, xx := rho - x*x + c1*y x :=xx yy := x y := yy a := setcolor(12) + plot(y,x) a := setcolor(getcolor(xx,yy)+1) + if dot() = 10000 then quit() else 0 ------------------------------------------------------------------------