50 likes | 286 Views
Introduction to the Runge-Kutta algorithm for approximating derivatives. PHYS 361 Spring, 2011. review: Euler method. General form of first-oder Diff Eq:. Example: decay equation. To implement a numerical solution, we must approximate the derivative.
E N D
Introduction to the Runge-Kutta algorithm for approximating derivatives PHYS 361 Spring, 2011
review: Euler method General form of first-oder Diff Eq: Example: decay equation To implement a numerical solution, we must approximate the derivative. The Euler method is the simplest approach: (forward difference) Substituting this into our decay equation, we can solve for xi+1 This is equivalent to linearly extrapolating x(t) from xi to xi+1 or... using the Taylor series expansion for x(t) and cutting out all terms involving Dt2 or higher. This makes the Euler method “first order accurate”
Taylor series Substitute f(x) for dx/dt (from our equation), keep up to 2nd order in dt This approach is fine if we know df/dx and df/dt
Runge-Kutta make use of Mean value theorem Same idea as Euler method, but aim for “exact” solution by using the “mean value” slope, instead of the slope at ti. x xm Approximate the mean value slope by evaluating f(x,t) at xm and tm ti tm ti+1 Use Euler method to approximate xm: Decay example: 2nd order R-K has two steps 4th order R-K has four steps
Runge-Kutta... another approach Approximate mean slope by averaging slopes at ti, ti+1, and ti+1/2 Decay example: x xi xm xi+1 ti tm ti+1 Use weighted average of slopes: