Introductory Programming Fall 2005 Evaluation 7 on Tuesday Second order systems -------------------- The nice people in Natick have given us a tool that can estimate the solution to any first order diff EQ; that is, anything that can be expressed as y' = f(t, y) All we have to do is write a function that implements f It takes t and y as input variables and produces the value of y' at t and y as a result. So what do we do with second order systems? y'' = f(t, y, y') ode45 can't handle them like that. One solution is to replace y with r and y' with v Then we can write a = f(t, y, y') dv/dt = y'' = a dr/dt = v And then define a vector [r, v], now dX/dt = [dr/dt, dv/dt] = [v, a] And ode45 can handle that fine. We just have to write a function that takes t and X, and computes dX/dt. Everywhere there used to be a scalar y, we use a vector X. Punchline: you can write an nth-order diff EQ as a system of n first-order diff EQs