The MATLAB code for the solution to example 6 in the slides for sections 6.3-4 requires to files. Create a function m-file “g.m” with content:
function g=g( t )
g=1/5+exp(-t).*(-1/10*sin(2*t)+4/5*cos(2*t));
end
For the script m-file, discontinuous is the file as a “doc” (change to “m” file after download).
For the Euler method (examples referred to are from the slides):
- MATLAB code: euler_example1, euler_example2 and (new!!) improved_euler (note: only computes the approximations and not the relative errors)
- MS Excel: euler_examples; examples 1 and 2 are in separate sheets (click on tabs at bottom left).
- JODE: euler_jode_example1, done as screen shots and commentary.
To do much of the homework from the book, you must have access to technology tools to display such things as the slope or direction field and sample solutions. On the first day of class, I recommended the use of the JAVA version of dfield. However, for certain equations such as the homogeneous equations, it seems to get itself into an infinite loop. The MATLAB version works somewhat better and those of you who are using MATLAB, should use the mfile.
For the majority of you, I recommend that you try another JAVA applet called JOde (click on Slopefields). Some recommendations:
- Switch the numeric solver to RKF with step .001
- Unlike webwork, you must put in a * for every multiplication in your formula.
- Press “enter” after you have keyed-in the function in its field to check it. Look for error message.
- To print, you can read the documentation or use print screen (just the window please). Paste into word and then use the cropping tool.