==================== iode.m ==================== /home/brinkman/proj/iode/code/iode.m function iode() $Id: iode.m,v 1.31 2003-02-11 22:38:58+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) iode: a simple function that calls the graphical user interface of Iode if possible and resorts to the text based interface if necessary Usage: iode; This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ==================== iodetxt.m ==================== /home/brinkman/proj/iode/code/iodetxt.m function iodetxt() $Id: iodetxt.m,v 1.6 2003-02-11 22:38:58+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) iodetxt: a simple text menu for Iode Usage: iodetxt; ==================== dfmenu.m ==================== /home/brinkman/proj/iode/code/dfmenu.m function dfmenu() $Id: dfmenu.m,v 1.96 2003-09-24 05:39:39+02 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) dfmenu: text menu for df and friends. Usage: dfmenu; Note: The menu allows the user to change the names of independent and dependent variables. In order to avoid conflicts between those names and the names of internal variables, we adopt the convention that user defined variable names can only have one letter, whereas internal variable names have to have at least two letters. Acknowledgments: - Many thanks to Robert Jerrard and Richard Laugesen for valuable feedback and suggestions. ==================== df.m ==================== /home/brinkman/proj/iode/code/df.m function df(fs,tt,xx,tlab,xlab,ttl,col,clrscr); $Id: df.m,v 1.21.1.11.1.10 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) df: plots direction fields for differential equations of the form dx/dt=f(t,x). Usage example: df(inline('x.*y','x','y'),0:0.1:2,0:0.2:3); Parameters: fs: an inline function f(t,x) defining the direction field, or string containing the name of a function of (t,x) (see .octaverc for the implementation of inline functions under Octave) tt: a row vector of t-coordinates xx: a row vector of x-coordinates tlab,xlab,ttl: label for t-axis and x-axis, title of plot col: optional string indicating the color of the line segments clrscr: optional flag indicating whether df is supposed to clear the screen and set 'ishold' to 1 before plotting its direction field. Default is 1. ==================== solplot.m ==================== /home/brinkman/proj/iode/code/solplot.m function xc=solplot(fs,x0,tc,method,col); $Id: solplot.m,v 1.25 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) solplot: plots solutions of initial value problems of the form dx/dt=f(t,x), x(t0)=x0. (note: t0=tc(0)) Usage: solplot(inline('x.*y','x','y'),3,0:0.01:1,'rk'); Parameters: fs: an inline function f(t,x), or a string containing the name of such a function (see .octaverc for the implementation of inline functions under Octave tc: a row vector of t-coordinates x0: initial x-coordinate method: optional string indicating the method to be used (e.g., Euler, Runge-Kutta,...) The method has to be a function of the form method(fs,x0,tc) where fs is a string containing the name of the function f(t,x), x0 is the initial value, and tc is a range of arguments, e.g., linspace(0,pi,100). col: optional string indicating the color of the graph (method argument is required when using col) Returns: xc: row vector of x-coordinates of solution ==================== euler.m ==================== /home/brinkman/proj/iode/code/euler.m function xc=euler(fs,x0,tc); $Id: euler.m,v 1.23 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) euler: computes numerical solutions of initial value problems of the form dx/dt=f(t,x), x(t0)=x0 (where t0=tc(1)) using Euler's method. x and f can be scalars or vertical vectors of the same dimension. Usage example: xc=euler(inline('x.*y','x','y'), 2.5, 0:0.01:1) Parameters: fs: an inline function f(t,x) or string containing the name of a function of (t,x) (see .octaverc for the implementation of inline functions under Octave) The function given by fs must be of the form f(t,x) and return the value of f when evaluated at (t,x). The function should be able to deal with vector input, i.e., the code should use the vectorized operators .*, ./, etc., instead of *, /, etc. A string that may contain nonvectorized operators can be fed through the function vectorize in order to achieve this. x0: initial coordinate (or vector of initial coordinates; the dimension of x0 must match the dimension of the values computed by fs); tc: a row vector of t-coordinates, indexed from 1 Returns: xc: row vector of x-coordinates of the solution, indexed from 1 (or a matrix of coordinates when solving a system of differential equations) Notes on indexing: matlab and octave start indexing arrays from 1, and so the initial element of the array xc is xc(1). This is unfortunate because people usually denote the initial x-value for the differential equation by x0, so that x0=xc(1). ==================== rk.m ==================== /home/brinkman/proj/iode/code/rk.m function xc=rk(fs,x0,tc); $Id: rk.m,v 1.22 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) rk: computes numerical solutions of initial value problems of the form dx/dt=f(t,x), x(t0)=x0 (where t0=tc(1)) using Runge-Kutta. x and f can be scalars or vertical vectors of the same dimension. Usage: x=rk(inline('x.*y','x','y'), 2.5, 0:0.01:1); Parameters: fs: an inline function f(t,x), or a string containing the name of of such a function (see .octaverc for the implementation of inline functions under Octave) The function given by fs must be of the form f(x,t) and return the value of f when evaluated at (x,t). The function should be able to deal with vector input, i.e., the code should use the vectorized operators .*, ./, etc., instead of *, /, etc. A string that may contain nonvectorized operators can be fed through the function vectorize in order to achieve this. x0: initial coordinate (or vector of initial coordinates; the dimension of x0 must match the dimension of the values computed by fs); tc: a row vector of t-coordinates, indexed from 1 Returns: xc: row vector of x-coordinates of the solution, indexed from 1 (or a matrix of coordinates when solving a system of differential equations) Notes on indexing: matlab and octave start indexing arrays from 1, and so the initial element of the array xc is xc(1). This is unfortunate because people usually denote the initial x-value for the differential equation by x0, so that x0=xc(1). ==================== ppmenu.m ==================== /home/brinkman/proj/iode/code/ppmenu.m function ppmenu() $Id: ppmenu.m,v 1.75 2003-09-24 05:39:39+02 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) ppmenu: text menu for df and friends. Usage: ppmenu; Note: The menu allows the user to change the names of independent and dependent variables. In order to avoid conflicts between those names and the names of internal variables, we adopt the convention that user defined variable names can only have one letter, whereas internal variable names have to have at least two letters. Acknowledgments: - Many thanks to Robert Jerrard and Richard Laugesen for valuable feedback and suggestions. ==================== pp.m ==================== /home/brinkman/proj/iode/code/pp.m function pp(fgs,xx,yy,xlab,ylab,ttl,col,clrscr,t0); $Id: pp.m,v 1.17.1.11 2003-01-13 08:53:28+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) pp: plots phase portraits for systems of differential equations of the form dx/dt=f(t,x,y) dy/dt=g(t,x,y) In most cases, f and g will not depend on t, but if they do, one can specifiy the time t=t0 for which the phase portrait is evaluated. Usage: pp(inline('[xy(1,:)+xy(2,:);xy(1,:)-xy(2,:)]','t','xy'),0:1:9,-8:1:8); Parameters: fgs: inline function F that computes [f(x,y);g(x,y)], or a string containing the name of such a function (see .octaverc for the implementation of inline functions under Octave) This function F must be of the form F=F(t,xy), where t is a time parameter that is ignored by pp but necessary for compatibility with other modules of Iode. The parameter xy is a 2xN matrix whose first row is a vector of x-coordinates, and its second row is a vector of y-coordinates, i.e., x=xy(1,;), and y=xy(2,:). xx: a row vector of x-coordinates yy: a row vector of y-coordinates (not necessarily the same length as xx) xlab,ylab,ttl: label of horizontal/vertical axis, title of plot (optional) col: optional string indicating the color of line segments clrscr: optional flag indicating whether pp is supposed to clear the screen and set 'ishold' to 1 before plotting its direction field. Default is 1. t0: optional number indicating the time t=t0 for which the phase portrait is evaluated; defaults to 0 ==================== trajplot.m ==================== /home/brinkman/proj/iode/code/trajplot.m function xyc=trajplot(fgs,xy0,tc,method,col); $Id: trajplot.m,v 1.26 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) trajplot: plots solutions of initial value problems of the form dx/dt=f(x,y), dy/dt=g(x,y), x(t0)=x0, y(t0)=y0. Usage: trajplot(inline('[xy(1,:)+xy(2,:);xy(1,:)-xy(2,:)]','t','xy'), [3;2.5],linspace(0,1,10)); Parameters: fs: inline function or string, see pp.m for details (see .octaverc for the implementation of inline functions under Octave) xy0: initial value [x0;y0] tc: a row vector of t-coordinates method: (optional) string indicating numerical method The method has to be a function of the form method(fs,xy0,tc) where fgs is a string containing the names of the function that computes (f;g) xy0=(x0,y0) is the initial value, and tc is a range of arguments, e.g., linspace(0,pi,100). col: (optional) string indicating color of plot (method is required when using col) Returns: xyc: matrix of xy-coordinates of solution ==================== subvar.m ==================== /home/brinkman/proj/iode/code/subvar.m function s=subvar(s0,v0,v1) $Id: subvar.m,v 1.4 2003-01-08 10:46:16+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) subvar: substitutes a variable for another in an expression Usage example: subvar('sin(i)','i','x') yields 'sin(x)' Parameters: s0: expression v0: old variable v1: new variable Returns: s: s0 with all occurrences of v0 replaced by v1 v0 must be a variable name. v1 can be almost anything, but the user is responsible for proper use of parentheses. For instance, if v1 is a sum, then it is wise to enclose it in parentheses. subvar will _not_ do this automatically. Note that subvar parses the expression s0 and only replaces occurrences of the _variable_ v0 by v1. In particular, it doesn't blindly substitute the string v1 for any substring v0. Although this function behaves much like Matlab's subs function, I had to reimplement this because (a) Octave has no such substitute function, and (b) the subs function automatically encloses v1 in parentheses, which is undesirable for the purposes of Iode. ==================== fsmenu.m ==================== /home/brinkman/proj/iode/code/fsmenu.m function fsmenu() $Id: fsmenu.m,v 1.81 2003-02-11 22:38:58+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) fsmenu: A text menu for slideshows involving Fourier series Usage: fsmenu; Note: The menu allows the user to change the names of independent and dependent variables. In order to avoid conflicts between those names and the names of internal variables, we adopt the convention that user defined variable names can only have one letter, whereas internal variable names have to have at least two letters. Acknowledgments: - Many thanks to Robert Jerrard and Richard Laugesen for valuable feedback and suggestions. ==================== fs.m ==================== /home/brinkman/proj/iode/code/fs.m function [an,bn,abn]=fs(fcns,t0,t1,n,N) $Id: fs.m,v 1.15 2003-01-05 21:55:46+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) fs: computes coefficients of Fourier series Usage: [an,bn,abn]=fs(inline('sign(x)+abs(x)','x'),-1,1,100); Parameters: fcns: inline function of one variable to be developed into a Fourier series, or a string containing the name of a function of one variable (see .octaverc for the implementation of inline functions under Octave) t0, t1: end points of one period n: number of terms to compute N: (optional) number of points in [t0,t1] at which fcns gets evaluated when computing integrals, defaults to 64*n Return values: an, bn: column vectors of coefficients of Fourier series abn: absolute value of an+i*bn Note: The treatment of the coefficient a0 differs from the textbook (Edwards-Penney), but it's much cleaner from the point of view of software design. The book uses a 0th eigenfunction of 1/2, while we use a 0th eigenfunction of 1. ==================== slideshow.m ==================== /home/brinkman/proj/iode/code/slideshow.m function slideshow(x,y,f,step,fix,hld,ttl,xlab,ylab,tlab,nmin,nmax,col,f2,col2); $Id: slideshow.m,v 1.18 2003-01-27 17:22:44+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) slideshow: shows successive slices of a grid of values Usage: slideshow(0:0.1:1,0:0.1:1,f,1,1,0,'title','x','y','g'); Parameters: x: row vector of x-values y: row vector of y-values f: grid of values f(x,y) Optional parameters: step: nonzero value means step-by-step, 0 means animation (default 1) fix: nonzero value indicates fixed axes (default 1) hld: nonzero value indicates that successive plots are superimposed (default 0) ttl: title string (default 'no title') xlab: label of x-axis (default ' ') ylab: label of y-axis (default ' ') tlab: label of t-axis (default ' ') This is the time axis of the slide show. nmin: index of initial slide (default 1) nmax: index of terminal slide (default length(y)) col: color of plot (default 'r') f2: row vector of values f(x) to be plotted on every slide (default []) col2: color of plot of f2 (default 'b') ==================== partialsum.m ==================== /home/brinkman/proj/iode/code/partialsum.m function f=partialsum(L,an,bn,t,nmax) $Id: partialsum.m,v 1.9.1.12 2003-01-04 10:58:58+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) partialsum: evaluates partial sums of Fourier series. Usage: f=partialsum(pi,0,[3,2,1],[-1,5,1],linspace(-pi,pi,100),3); Parameters: L: half period an, bn: column vectors of Fourier coefficients t: row vector of t-values nmax: (optional) maximal summation index Returns: f: grid of partial sums evaluated at t, i.e., f(i,:)= (i-1)th partial sum evaluated at t ==================== mp.m ==================== /home/brinkman/proj/iode/code/mp.m function tc=mp(t0,t1,t) $Id: mp.m,v 1.12 2003-01-05 21:43:15+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) mp: A helper function for creating periodic functions; the composition of a function f with mp will be periodic with period t1-t0, and f(mp(t))=f(t) if t0<=t df('sample',linspace(-pi,pi,15),linspace(-pi,pi,15)); octave:2> tc=linspace(-pi,pi,100); octave:3> xc=rk('sample',1,tc); octave:4> hold on; octave:5> plot(tc,xc); This session creates a direction field using this function and computes and plots a numerical solution with x(-pi)=0.5. ==================== hat.m ==================== /home/brinkman/proj/iode/code/hat.m function f=hat(x,a,b) $Id: hat.m,v 1.3 2002-12-22 00:38:39+01 brinkman Exp $ (c) 2001, Peter Brinkmann (brinkman@math.uiuc.edu) hat: returns 1 for ab - has a maximum of 1 at x=m Note: This only makes sense for ab - has a maximum of 1 at x=m - is strictly monotone between a and m as well as m and b Note: This only makes sense for a