### Computers

What kind: MATLAB, a calculating and plotting program, is available for all engineers in Upson Hall on MACs and in Hollister Hall on PCs. Lecture examples, prelims, and the final exam will use MATLAB. But you may use any computer and program for the parts of homework which are aided by computers or nice plotting. If you do homework successfully with software other than MATLAB we will make alternative arrangements for your exams. Basic, C, Fortran, or Pascal are painful but fine if you know (or learn) how to do matrix operations, solve ODEs and make plots with them. Symbolic packages (eg, Maple, Mathematica, or MACSYMA) are also fine but are perhaps harder to learn than MATLAB.

All engineers can get a MATLAB password for the Upson Macintoshes from the engineering library. People taking this course can use the

```        username       Math293     and
```

## Math 293 MATLAB programs, Fall 1996

These are all just plain text files. They are MATLAB programs that should run on any reasonable computer. To download them, click on the buttons. Once you see them on your screen cut and paste them into files with the names shown. To use them, open them from within MATLAB and then run them.

Windows 95 users have special file naming issues. Click here for some Windows_95_advice prepared by a student in the class.

### Programs:

ODE_samples_for_HW1 This one text file needs to be broken into 2 pairs of files as explaned in the comments of the text. The first pair is a minimalist solution of an ODE with MATLAB. The second pair is a little more thorough version of the same. Look at the first pair to see how easy MATLAB is. Look at the second pair to learn more about what you can do.

dfield.m and dfsolve.m (dfield uses dfsolve. dfield shows slope fields and solutions to first order ODEs). To use these copy the first file (all of it, wait for it all to download) into a file called dfield.m. Copy (all of) the second into a file called dfsolve.m. Then read the directions at the start of dfield.m. Then execute dfield.m by typing >dfield to the MATLAB command window. These are demonstration programs. Students are intended to use them and understand the math they are demonstrating. The MATLAB code is more advanced than the average student should be able to follow.

pplane.m and ppsolve.m (pplane uses ppsolve. pplane shows the phase plane for coupled, autonomous, 1st order ODEs). To use these copy the first file (all of it, wait for it all to download) into a file called pplane.m. Copy (all of) the second into a file called ppsolve.m. Then read the directions at the start of pplane.m. Then execute pplane.m by typing >pplane to the MATLAB command window. These are demonstration programs. Students are intended to use them and understand the math they are demonstrating. The MATLAB code is more advanced than the average student should be able to follow.

Loops_n_plots.m (Loops_n_plots.m is a MATLAB script file that demonstrates the use of FOR and WHILE loops. It shows how to overlay plots using PLOT or HOLD. And it shows how to get the last element of a 'vector' using LENGTH. Some of these things may be useful for coding up Euler's method for homework 4.

systems_driver.m and systems_rhs.m. These two work together. They are a simple example of a numerical solution of a system of ODEs. systems_driver.m is a script file that uses ODE23 and SUBLPLOT to find and graph the solution to a simple system of ODEs. systems_rhs.m is a function file that gets called by ODE23 when systems_driver is run, it contains the description of the right hand sides of the system of ODEs.

matrix_alg_demo.m is a demo script file of many useful matrix commands in MATLAB.

eig_ODE_soln.m is a set of commands that shows how to use eigenvectors to solve sets of linear ODEs in MATLAB. The file corrects a mistake made in lecture (Ruina and Terrell) and in the Homework Solutions (#8 called #7) by Nagy.

Surface_plots_explained describes how to do plots of surfaces in MATLAB. The command MESHGRID is explained (sort of) and three sample plots are presented.

### Bob Terrell's JAVA applet 'de'

de solves 2nd and 3rd order odes numerically. It is sort of like PPlane in philosophy but can handle non-autonomous systems and 3D systems. (To see the scroll bars resize the view window a small amount.)

de solves differential equations. It is for initial value problems for up to three first-order equations using the Runge-Kutta method. There are several examples available by clicking 'Example'. To enter your own you may either edit the examples, or click 'Clear', click in this area, and type your equations. Click 'Go' to calculate and graph the results. Symbols allowed are as shown in the examples, together with sin cos print abs e pi box ^*/+-=(); If you use 'print' the results are printed in columns of t,x,y,z to system output. (Under Netscape you must use a menu option to show this output.) 'delt' is the stepsize. t0 is the time when initial conditions are applied. Defaults are x' = y' = z' = 0, t= 0 to 1, delt = 0.1, x0 = y0 = z0 = 0 at t0 = 0, and box = 2. 'box' is the approximate radius in which we graph, but the graph is redrawn to fit the space once the calculation is done. You may abbreviate box, print, and delt. When solving a system of three equations, the graph may be rotated by clicking in the viewpoint control. The java source code for this applet is available by request from the author. Also available is the C code for a unix style program (fast, text-based, io redirection, crude graphics) with about the same functionality. de was inspired by John Hubbard's MacMath, a set of educational differential equation solvers and other programs for the Macintosh. Please send comments to the author, Bob Terrell, at bterrell@math.cornell.edu