PHYSICS 321 – INTERMEDIATE MECHANICS – FALL 2005
Ordinary Differential Equations with MATLAB
Resource 0 – All you really need for most problems you will run into is the solver
“ODE45” which is built into Matlab. If you can figure out how to use it, you are done. In order to figure it out, I recommend you look through as much of the following as you need.
Resource I -- “Computational Physics” (Giordano and Nakanishi)-- Pages 10-15 give general guidance about writing understandable scientific programs.
Resource II -- “Computational Physics” (Giordano and Nakanishi)-- Pages 456-460
explain the general numerical methods used to solve ODE's. The Euler and the Runge-Kutta methods are covered. This book does not explicitly discuss Matlab. However, it is the best text I have yet found for clearly presenting the mathematics behind numerical solution techniques of ODEs. This provides context for the detailed explanations that are Matlab specific.
Resource III – File: QuadraticDrag3.m
This is a script implementing numerical solution of a general quadratic drag problem using ODE45. It is heavily commented to explain the various steps in turning a set of coupled differential equations into something that can be solved numerically. It is written as a “cookbook”, but you still need to have a picture of how the Matlab solvers work if you want to apply it to new situations.
Resource IV-- File: “moler_odes.pdf” -- “Numerical Computing with Matlab” (by Cleve Moler). Ch. 7 “ODE's in Matlab”. Chapter 7 is posted as a .pdf file. Not all of Ch. 7 is necessary to understand how to use the solvers. I recommend the following sections:
7.1 – T he basic theory
– Some examples
-- Irrelevant for what we are up to in this course.
7.4 – Explains the Euler method, Trapezoid method and 4th order Runge-Kutta method acutally used by Matlab's ODE45 and ODE23.
7.5-7.6. Explains a sample version of ODE23 in which you can actually see all the code inside. This could be useful in the future if you want to understand the guts of ODE23 and ODE45. It is probably more than you need to begin. The function he mentions (ODE23TX) can be downloaded from the Mathworks web-site.
Actually walks you through some examples of use of ODE23. Worth doing at Matlab command line.
-7.11 Not necessary on an initial reading. If your solutions fail to converge, this is the sort of thing you need to know. More than likely, your initial failures will be caused by programming errors in your scripts, however.
7.12 – Useful because it lists ALL the ODE solvers in Matlab, and explains the differences.
Resource V – File: “Differential Equations in MATLAB.pdf” This is a file from the Mathworks. Sections 1, 4, 5 and 8 are the most germane.