Runge-Kutta Methods William Wang Faculty of Science and Technology United International College Guangdong, China w.wang-work@outlook.com II. L OCAL T RUNCATION E RROR (LTE) Abstract—A little derivation of fourth degree Runge-Kutta method (RK4). A. Euler’s Method The 1st IVP we are considering is I. P REREQUISITES dy(t) = f (t, y) dt y(0) = y0 A. Uni-variable Taylor Expansion First let’s recall the basic formula of Taylor methods that expand f at x = x0 is: The most basic and never practiced numerical method for IVP is the Euler’s Method. If we truncate the Taylor series at the first term (h ≡ ∆t and ξ is obtained form the Mean Value Theorem, just a representation for the truncated parts) ∞ X f (n) (x0 ) f (x) = (x − x0 )n n! n=0 Substituting x to x + h (h ≡ ∆x) and expand f (x + h) at x = x, we have f (x + h) = y(t + h) = y(t) + hy ′ (t) + ∞ X f (n) (x) n h n! n=0 y(t + h) − y(t) + O(h) h Now we can attempt to solve (2) by replacing the derivative with a difference: y((n + 1)h) ≈ y(nh) + hf (nh, y(nh)) (4) You may interprete this as starting from the previous value point y(nh) and walk for a tiny step h along the tangent line f (nh, y(nh)) to obtain the current value point. Thus we can start with y(0) and step forward to solve for any time. (1st order) = f (t, y) + hft + kfy + . . . C. Chain Rule Next swap all derivative f (n) into partial derivatives by the chain rule, i.e. df = ∂t f + dyDy f . Here the explicit form for f (t, y) where y ′ ≡ f given by the IVP, is: B. Local Truncation Error To be able to evaluate what we expect the order of a method to look like, we look at the one step error (1) LT E(tn+1 ) = |wn+1 − y(tn+1 )| Where w is the numerical approximation to the IVP (4). It is the residue when the exact solution of the ODE (2) is plugged into the numerical scheme. If yn is close to y(tn ) then the LTE is expected to approach zero. Now since Euler’s Method says that and (no needed for 2nd order Runge-Kutta) f ′′ (t, y) = (ft + fy f )t + (ft + fy f )y yt = ftt + 2fty f + ft fy + fyy f 2 + fy2 f .. . and so on for f (3) y ′ (t) = ∞ X ∇(n) f (h||k)n n! n=0 ∂f ∂f dy f ′ (t, y) = + ∂t ∂y dt = ft + fy f h2 ′′ y (ξ) 2 we can rearrange this and solve for y ′ (t) B. Multi-variable Taylor Expansion f (t + h, y + k) = (2) wn+1 = wn + hf (tn , wn ) (n) (5) Substract Eq. (5) from the Taylor Series of y (3) combined the ODE (2), yeilding the LTE for Euler’s Method 1 2) Undetermined Coefficient: k1 = hf (tn , yn ) LT E(tn+1 ) = |wn+1 − y(tn+1 )| k2 = hf (tn + αh, yn + βk1 ) = |yn + hf (tn , yn )− (10) yn+1 = yn + ak1 + bk2 [y(tn ) + hf (tn , yn ) + O(h2 )]| = O(h2 ) let’s see how we can chose the parameters a, b, α, β so that this method has the highest order LTE possible. Let’s reiterate the Taylor expansions from Eq. (6) III. RUNGE -K UTTA M ETHODS h2 h2 ftn + fyn fn + O(h3 ) (11) 2 2 Right here fn is short for f (tn , yn ), ftn = ft (tn , yn ), and so on yn+1 = yn + hfn + The insight of Runge and of Kutta was to realize that as the first derivative of y was equal to f , so other derivatives could be computed by judicious nesting. Let’s first derive RK2 in the perspective of Taylor Expansion of y and f . We will end up with a nice iterating form of the numerical interpretation of the given ODE. • Now use Eq. (11) to expand the yn+1 in the steps (10) at tn , and use Eq. (6) to expand f (tn + αh, yn + βk1 ) in yn+1 at tn , we get A. Second Order Runge-Kutta Methods 1) Forward Deduction: For example, suppose we truncate the expansion of the multi-variable Taylor Expansion of f after the first derivative f (t + h, y + k) ≈ f + hft + kfy (6) Also, we have the second order truncated Taylor Series for y (Eq. (3)) with Eq. (1) inserted in yn+1 = yn + h[afn + (bf (tn + αh, yn + βhfn )] = yn + h[afn + b(fn + αhftn + βhfn fyn ) + O(h2 )] (12) = yn + (a + b)hfn + bαh2 ftn + bβh2 fyn + O(h3 ) To express the LTE: LT E(tn+1 ) = |wn+1 − y(tn+1 )| = |(12) − (11)| h2 y(t + h) = y + hf + (ft + fy f ) + O(h3 ) 2 (7) Note that the expression in parentheses on the right of (7) is very close to the right of (6), excepting a term of f . But this can be inserted simply by writing (7) as y(t + h) ≈ y + h h f + (f + hft + hfy f ) 2 2 = |hfn (a + b − 1)+ (13) 1 h2 ftn (bα − )+ 2 1 2 h fyn fn (bβ − )| 2 Extracting the terms in Eq. (13) with identical h′ s and ′ f s and assigning them vlaues such that they minimize the LTE, yields the following system of equations to determine the parameters: Comparing the final term with (6) we can write h h y(t + h) ≈ y + f + f (t + h, y + hf ) 2 2 (8) Eq. (8) can be written as a sequence of steps, starting with yn = y(tn ): k1 = hf (tn , yn ) k2 = hf (th + h, yn + k1 ) 1 yn+1 = yn + (k1 + k2 ) 2 (9) This is an example of a second-order Runge-Kutta formula, and is equal to a second-order Taylor approximation, but without computing any of the derivatives of f . a+b=1 1 bα = (14) 2 1 bβ = 2 There are infinitely many choices of a, b, α and β that satisfy Eq. (14) because the system is underdetermined. Noticed that if we set a = b = 21 and thus α = β = 1, returning to the solution we obtained in Eq. (9). Remark: • The k1 and k2 are known as stages of the Runge-Kutta method. They correspond to different estimates for the slope of the solution. Note that yn + hk1 corresponds to an Euler step with step size h starting from (tn , yn ). Therefore, k2 corresponds to the slope of the solution one would get by taking one Euler step with stepsize h starting from (tn+1 , yn+1 ). The numerical method now consists of a single step with the average of the slopes k1 and k2 . B. Fourth Order Runge-Kutta Methods The iterative expression for 4t h order of Runge-Kutta Methods can be deducted in a similar manner, that is, • Compute the uni/multi-variable Taylor Series of y and f respectively up to sufficient degree of h • Minimize for LTE, extract terms with the same order, and solve for coefficients Resulting in: k1 = hfn k1 h , yn + ) 2 2 k2 h k3 = hf (tn + , yn + ) 2 2 k4 = hf (tn + h, yn + k3 ) k2 = hf (tn + 1 yn+1 = yn + (k1 + 2k2 + 2k3 + k4 ) 6 R EFERENCES AND F URTHER R EADING References for this note on RK are [1]–[4]. For digging into parameters for n-dimensional RK methods please refer to Butcher tableau method [5]. R EFERENCES [1] “euler’s method, taylor series method, runge kutta ... - brown university,” accessed: 12/22/2022, *wrong results*. [Online]. Available: https://www.cfm.brown.edu/people/sg/AM35odes.pdf [2] “arxiv:1402.3883v1 [math.na] 17 feb 2014,” accessed: 12/22/2022. [Online]. Available: https://arxiv.org/pdf/1402.3883.pdf [3] “runge-kutta methods - iit,” accessed: 12/22/2022. [Online]. Available: http://math.iit.edu/∼fass/478578 Chapter 3.pdf [4] “runge-kutta methods, math 3510 - university of connecticut,” accessed: 12/22/2022. [Online]. Available: https://www.phys.uconn.edu/∼rozman/ Courses/m3510 17f/downloads/runge-kutta.pdf [5] “runge-kutta methods - richard palais,” accessed: 12/22/2022. [Online]. Available: https://vmm.math.uci.edu/ODEandCM/PDF Files/ Appendices/AppendixH.pdf