Lecture 3: Backward Error Analysis
Total Page:16
File Type:pdf, Size:1020Kb
Geometric Numerical Integration TU M¨unchen Ernst Hairer January – February 2010 Lecture 3: Backward error analysis Table of contents 1 Modified differential equation 1 2 Modified Hamiltonian for symplectic integrators 5 3 Near conservation of the total energy 6 4 Counter-example: Takahashi–Imada integrator 10 5 ExistenceofglobalmodifiedHamiltonian 13 6 CompletelyintegrableHamiltoniansystems 15 7 Linear error growth for integrable systems 17 8 Exercises 20 Backward error analysis is the most powerful tool for the study of the long-time behaviour of numerical integrators. 1 Modified differential equation ¨* ϕ (y ) Consider an ordinary differential ¨¨ t 0 ¨exact¨ ¨ equation numerical y˙ = f(y), y˙ = f(y) H HH HHHj and a numerical method Φh(y) which y = Φ (y ) ¨¨¨* n+1 h n produces the approximations ¨exact¨ ˙ ¨ y = fh(y ) y0,y1,y2,... A forward error analysis consists of the studye of thee errors y ϕ (y ) (local error) 1 − h 0 and yn ϕnh(y0) (global error) in the solution space. The idea of backward error − ˙ analysis is to search for a modified differential equation y = fh(y ) of the form ˙ 2 y = f(y )+ hf2(y )+ h f3(y )+ ...,e e (1) such that yn = y(nh)e, and toe study thee differencee of the vector fields f(y) and fh(y). We remark that the series in (1) usually diverges and that one has to truncate it suitably for ae rigorous analysis. For the moment we content ourselves with a formal analysis without taking care of convergence issues. 1 For the computation of the modified equation (1) we put y := y(t) for a fixed t, and we expand the solution of (1) into a Taylor series e 2 y(t + h) = y + h f(y)+ hf2(y)+ h f3(y)+ . h2 (2) e + f ′(y)+ hf ′ (y)+ . f(y)+ hf (y)+ . + ... 2! 2 2 We assume that the numerical method Φh(y) can be expanded as 2 3 Φh(y)= y + hf(y)+ h d2(y)+ h d3(y)+ . (3) (the coefficient of h is f(y) for consistent methods). The functions dj(y) are known and are typically composed of f(y) and its derivatives. To get y(nh)= yn for all n, we must have y(t + h) = Φh(y). Comparing like powers of h in the e expressions (2) and (3) yields recurrence relations for the functions fj(y): e 1 f (y) = d (y) f ′f(y) (4) 2 2 − 2! 1 ′′ ′ ′ 1 ′ ′ f3(y) = d3(y) f (f, f)(y)+ f f f(y) f f2(y)+ f2f(y) . − 3! − 2! Example 1 Consider the scalar differential equation y˙ = y2, y(0) = 1 with exact solution y(t)=1/(1 t). It has a singularity at t = 1. We apply the explicit − Euler method yn+1 = yn + hf(yn) with step size h =0.02. The above procedure for the computation of the modified equation is implemented as a Maple script > fcn := y -> yˆ2: > nn := 6: > fcoe[1] := fcn(y): > for n from 2 by 1 to nn do > modeq := sum(hˆj*fcoe[j+1], j=0..n-2): > diffy[0] := y: > fori from1 by 1 to n do > diffy[i] := diff(diffy[i-1],y)*modeq: > od: > ytilde := sum(hˆk*diffy[k]/k!, k=0..n): > res := ytilde-y-h*fcn(y): > tay := convert(series(res,h=0,n+1),polynom): > fcoe[n] := -coeff(tay,h,n): > od: > simplify(sum(hˆj*fcoe[j+1], j=0..nn-1)); 2 20 exact solution solutions of truncated modified equations 10 .6 .8 1.0 Figure 1: Solutions of the modified equation for the problem y˙ = y2, y(0) = 1. Its output is 3 8 31 157 y˙ = y 2 hy 3 + h2 y 4 h3 y 5 + h4 y 6 h5 y 7 ... (5) − 2 − 3 6 − 15 ± Figure 1e presentse thee exact solutione (dashede curve),e the numericale solution (thick dots), and the solution of the modified equation, when truncated after 1, 2, 3, and 4 terms. We observe an excellent agreement of the numerical solution with the exact solution of the modified equation. A similar program for the implicit midpoint rule computes the modified equa- tion 1 1 11 3 y˙ = y 2 + h2 y 4 + h4 y 6 + h6 y 8 + h8 y 10 ... , (6) 4 8 192 128 ± and for thee classicale (explicit)e Runge–Kuttae methode of ordere4 1 65 17 19 y˙ = y 2 h4 y 6 + h6 y 8 h7 y 9 + h8 y 10 ... (7) − 24 576 − 96 144 ± We observee e that the perturbatione e terms in thee modified equatie on are of size (hr), where r is the order of the method. This is true in general. O Theorem 1 Suppose that the method yn+1 = Φh(yn) is of order r, i.e., Φ (y)= ϕ (y)+ hr+1δ (y)+ (hr+2), h h r+1 O r+1 where ϕt(y) denotes the exact flow of y˙ = f(y), and h δr+1(y) the leading term of the local truncation error. The modified equation then satisfies ˙ r r+1 y = f(y )+ h fr+1(y )+ h fr+2(y )+ ..., y(0) = y0 (8) with fr+1(ey)= δre+1(y). e e e Proof. The construction of the functions fj(y) (see the beginning of this section) shows that f (y)=0 for 2 j r if and only if Φ (y) ϕ (y)= (hr+1). j ≤ ≤ h − h O 3 Example 2 We next consider the Lotka–Volterra equations q˙ = q(p 1), p˙ = p(2 q), − − and we apply (a) the explicit Euler method, and (b) the symplectic Euler method, both with constant step size h = 0.1. The first terms of their modified equations are h (a) q˙ = q(p 1) q(p2 pq +1)+ (h2), − − 2 − O h p˙ = p(q 2) p(q2 pq 3q +4)+ (h2), − − − 2 − − O h (b) q˙ = q(p 1) q(p2 + pq 4p +1)+ (h2), − − 2 − O h p˙ = p(q 2) + p(q2 + pq 5q +4)+ (h2). − − 2 − O Figure 2 shows the numerical solutions for initial values indicated by a thick dot. In the pictures to the left they are embedded in the exact flow of the differential equation, in those to the right they are embedded in the flow of the modified dif- ferential equation, truncated after the h2 terms. For the symplectic Euler method, the solutions of the truncated modified equation are periodic, as is the case for the unperturbed problem. (a) explicit Euler, h =0.1 p p exact modified 4 flow 4 flow 3 3 2 2 1 1 2 4 6 q 2 4 6 q (b) symplectic Euler, h =0.1 p p exact modified 4 flow 4 flow 3 3 2 2 1 1 2 4 6 q 2 4 6 q Figure 2: Numerical solution compared to the exact and modified flows 4 p Euler, h =0.12 p sympl. Euler, h =0.12 4 solutions of 4 solutions of modified modified 3 diff. equ. 3 diff. equ. 2 2 1 1 2 4 6 q 2 4 6 q Figure 3: Study of the truncation in the modified equation In Figure 3 we present the numerical solution and the exact solution of the modified equation, once truncated after the h terms (dashed-dotted), and once truncated after the h2 terms (dotted). The exact solution of the problem is included as a solid curve. Example 3 For a linear differential equation with constant coefficients y˙ = Ay, y(0) = y0 we consider numerical methods which yield yn+1 = R(hA)yn, where R(z) is the n stability function of the method. In this case we get yn = R(hA) y0, so that t/h t yn = y(nh), where y(t) = R(hA) y0 = exp h ln R(hA) y0 is the solution of the modified differential equation e 1e y˙ = ln R(hA) y =(A + hb A2 + h2b A3 + . .) y (9) h 2 3 2 with suitable constantse b2, b3,...e . Since R(z) =1+ z + (ez ) and ln(1 + x)= x x2/2+ (x3) both have a positive radius of convergence,O the series (9) − O converges for h < h with some h > 0. This is an exceptional situation. | | 0 0 2 Modified Hamiltonian for symplectic integrators We consider a Hamiltonian system y˙ = J −1 H(y) with smooth H(y), and we show that the modified equation of symplectic∇ methods is also Hamiltonian. Theorem 2 (Existence of a local modified Hamiltonian) If a symplectic method Φ (y) is applied to a Hamiltonian system y˙ = J −1 H(y) with a smooth Hamil- h ∇ tonian H : U R , then the modified equation (1) is locally Hamiltonian. → More precisely, for every y0 U and for all j there exist smooth functions H (y), such that f (y)= J −1 H∈(y) on a suitable neighborhood of y . j j ∇ j 0 5 1 2 −1 Proof. Assume that fj(y)= J Hj(y) for j =1, 2,...,r (this is satisfied for r =1, because f (y)= f(y)= J −∇1 H(y)). We have to prove the existence of a 1 ∇ Hamiltonian Hr+1(y). The idea is to consider the truncated modified equation ˙ r−1 y = f(y )+ hf2(y )+ . + h fr(y ), (10) r−1 which is a Hamiltoniane systeme with Hamiltoniane H(y)+hHe 2(y)+. .+h Hr(y). Its flow ϕr,t(y0), compared to that of (1), satisfies Φ (y )= ϕ (y )+ hr+1f (y )+ (hr+2), h 0 r,h 0 r+1 0 O and also Φ′ (y )= ϕ′ (y )+ hr+1f ′ (y )+ (hr+2).