MATH 3510 Fall 2017

runge-kutta methods

http://www.phys.uconn.edu/˜rozman/Courses/m3510_17f/

Last modified: November 28, 2017

We are interested in the numerical solution of the initial value problem (IVP)

dy = f (t,y), y(t = 0) = y . (1) dt 0

We denote the time at the nth time step by tn and the computed solution at the nth time step by yn, yn = y(tn). The step size h (assumed to be constant for the sake of simplicity) is − given by h = tn tn 1. − The error that is induced at every time-step due to the truncation of the , n this is referred to as the local truncation error (LTE) of the method. The local truncation error is different from the global error gn, which is defined as the absolute value of the | − | difference between the true solution and the computed solution, gn = yexact(tn) yn . In most cases, we do not know the exact solution and hence cannot evaluate the global error. However, if we neglect roundoff errors, it is reasonable to assume that the global 1 error at the nth time step is n times the LTE. Since n is proportional to h , gn should be n k+1 proportional to h . A method with O(h ) LTE is said to be of kth order. This implies that for a kth order method, the global error scales as hk. In the forward Euler method, we used the information on the or the derivative of y at the given time step to obtain the solution at the next time step. Runge-Kutta (RK) methods is a class of methods that uses the information on the slope at more than one point to find the solution at the future time step.

Page 1 of3 MATH 3510 Runge-Kutta methods Fall 2017

The local truncation error for the Euler’s method is O(h2), resulting in a first order numeri- cal technique. Let’s derive the second order RK method where the local truncation error is O(h3).

Given the IVP of Eq. (1), the time step h, and the solution yn at the nth time step, we wish to compute yn+1 in the following form:

yn+1 = yn + ahf (tn,yn) + bhf (tn + αh,yn + βh), (2) where the constants α, β, a and b have to be selected so that the resulting method has a local truncation error O(h3). Note that if b = 0 and a = 1, then Eq. (2) reduces to the forward Euler method. 2 Now, the Taylor series expansion of y(tn+1) about tn correct up to the h term is as following,

dy h2 d2y 3 y(tn+1) = y(tn) + h + 2 + O(h ). (3) dt t 2 dt n tn From Eq. (1), d2y d dy d ∂f ∂f dy ∂f ∂f = = f (t,y) = + = + f . (4) dt2 dt dt dt ∂t ∂y dt ∂t ∂y From Eqs. (1), (3), and (4)

1 2 ∂f 1 2 ∂f 3 yn+1 = yn + hf (tn,yn) + h + h f (tn,yn) + O(h ). (5) 2 ∂t 2 ∂y tn,yn tn,yn

On the other hand, the Taylor series expansion of the expression Eq. (2) about tn correct up to the h2 term is as following,

2 ∂f 2 ∂f 3 yn+1 = yn + (a + b)hf (tn,yn) + bα h + bβ h + O(h ). (6) ∂t ∂y tn,yn tn,yn Comparing the terms with identical powers of h in Eqs. (5) and (6), gives us the following system of equations to determine the constants:

a + b = 1, 1 αb = , (7) 2 1 βb = f (t ,y ). 2 n n

Page 2 of3 MATH 3510 Runge-Kutta methods Fall 2017

There are infinitely many choices of a, b, α and β which satisfy Eq. (7). If we choose 1 a = b = 2 , α = 1, and β = f (tn,yn) we get the classical second order accurate Runge-Kutta method (RK2) which is summarized as follows:

k1 = hf (tn,yn), k2 = hf (tn + h,yn + k1), (8) 1 y = y + (k + k ). n+1 n 2 1 2

1 1 If we choose a = 0, b = 1, α = 2 , and β = 2 f (tn,yn) we get the second order accurate Runge-Kutta method known as :

k1 = hf (tn,yn), h k k = hf (t + ,y + 1 ), (9) 2 n 2 n 2 yn+1 = yn + k2.

Runge-Kutta methods of higher order can be derived in a similar manner. For the reference, the fourth order Runge-Kutta technique (RK4) is as following:

k1 = hf (tn,yn), h k k = hf (t + ,y + 1 ), 2 n 2 n 2 h k k = hf (t + ,y + 2 ), (10) 3 n 2 n 2 k4 = hf (tn + h,yn + k3), 1 y = y + (k + 2k + 2k + k ). n+1 n 6 1 2 3 4

Page 3 of3