Asymptotic Error Analysis of the Aaptive Verlet Metho Stephane Cirilli, Ernst Hairer Beneict Leimkuhler y May 3, 999 Abstract The Aaptive Verlet metho [7] an variants [6] are time-reversible schemes for treating Hamiltonian systems subject to a Sunman time transformation. These methos have been observe in computer experiments to exhibit superior numerical stability when implemente in a counterintuitive \reciprocal" formulation. Here we give a theoretical explanation of this behavior by examining the leaing terms of the moie equation (backwar error analysis) an those of the asymptotic error expansion. With this insight we are able to improve the algorithm by simply correcting the starting stepsize. keywors: Aaptive Verlet metho, time-reversible variable stepsizes, Hamiltonian systems, Sunman time-transformations, backwar error analysis, asymptotic expansions Introuction Consier a mechanical Hamiltonian system of the form t q = M p; q(t 0 ) = q 0 ; () t p = F (q); p(t 0) = p 0 ; () where q; p R N, M R N N is a positive enite matrix, an F = r q V for some smooth, real-value potential function V. If ierent time-scales are present in Section e mathematiques, Universite e Geneve, -4 rue e Lievre, CH- Geneve 4, Switzerlan. Stephane.Cirilli@math.unige.ch, Ernst.Hairer@math.unige.ch y Dept. of Mathematics, 405 Snow Hall, University of Kansas, Lawrence, KS 66045, USA. leimkuhl@math.ukans.eu. Visiting DAMTP, Cambrige University, AY 996-97. Research supporte by NSF grant No. 967330 an DAMTP.
the solution of ()-(), an ecient numerical treatment requires variable steps. An alternative approach is to apply a time transformation of the form t = G(q; p); with G a smooth, positive function (also calle Sunman transformation) so that, by viewing q an p as functions of the new variable, the equations of motion become q = gm p; (3) p = gf (q); (4) where g = G(q; p). Applying a numerical metho with constant stepsize h to (3)- (4) is essentially equivalent to applying the metho with stepsize hg n to ()-(). If G(q; p) = G(q; p), the change of the time variable preserves the reversing symmetry associate to ()-(), a property that has been foun to be important for recovering realistic qualitative behavior of the original system in numerical simulations [0, 8]. In this article we consier a variant of Verlet's metho written in the form q n+= = q n + h g nm p n+= ; (5) p n+= = p n + h g nf (q n ); (6) q n+ = q n+= + h g n+m p n+= ; (7) p n+ = p n+= + h g n+f (q n+ ): (8) Here h represents the ctive timestep (i.e. stepsize in ), an the inices inicate the timestep. The most obvious choice of g n is g n = G(q n ; p n ); (9) which, however, results in an implicit algorithm. In orer to avoi this implicitness, it was suggeste in [7] to put g 0 = G(q 0 ; p 0 ), an to upate the time-scaling factor g from a two-term recurrence relation (g n ; g n+ ; q n ; q n+= ; q n+ ; p n ; p n+= ; p n+ ) = 0 with symmetry preserving. Obviously, the latter equation has to be consistent with the equation g( n ) = G(q( n ); p( n )) in the limit of small h. A natural choice of is = g n+ + g n G(q n+= ; p n+= ); (0) but in experiments this has been foun to behave unreliably, particularly in the presence of large forces. A more robust approach is to use the corresponing equation for the reciprocal of g [6], = + g n+ g n G(q n+= ; p n+= ) : ()
Various semi-explicit an implicit variants of Aaptive Verlet propose in [7] also use the reciprocal relation. Until now, the reason for this counterintuitive moication of the recurrence relation has not been explaine. In Sect., we stuy for the various methos the leaing terms of the moie equation (backwar error analysis) an those of the asymptotic error expansions. Each of these has a (nonphysical) oscillating part etermine from a certain ierential or algebraic equation; a simple analysis of this leaing oscillatory term explains the observe ierences in stability of the methos. As an outcome of this analysis, we show in Sect. 3 how the oscillations can be attenuate by correcting the starting stepsize. Another extension of the Verlet scheme to variable stepsizes has recently been propose inepenently in [3] an in [9]. In aition to being symmetric, it is a symplectic metho, but it has the isavantage of being implicit in g n+. A comparison of the ierent extensions is given in []. Backwar Error Analysis an Asymptotic Expansions For the choice g n = G(q n ; p n ), the metho is a symmetric one-step metho applie to an orinary ierential equation. It is a classical result that the numerical solution can then be formally written as the exact solution of a moie ierential equation, an that the global error possesses an expansion in even powers of h (see [5, pp. 555-559] an [4, Sect. II.8]). We now turn to the more interesting case where g n is given by a two-term recursion, which allows the algorithm to be completely explicit. The following theorem shows that in this case the numerical solution is a superposition of a smooth function with oscillatory terms. Such a phenomenon is similar to the weak instability of two-step methos (see [4, Sect. III.9]). Theorem The numerical solution of the Aaptive Verlet metho (5)-(8) can formally be written as q n = eq( n )+( ) n bq( n ); p n = ep( n )+( ) n bp( n ); g n = eg( n )+( ) n bg( n ); () where n = nh an eq 0 = egm ep + h e Q () + : : : ; bq = h b Q () + : : : ; (3) ep 0 = egf (eq ) + h e P () + : : : ; bp = h b P () + : : : ; (4) eg = G(eq; ep ) + h e G () + : : : ; bg 0 = b G() + h b G () + : : : ; (5) with uniquely etermine initial values satisfying q 0 = eq(0) + bq(0); p 0 = ep(0) + bp(0); g 0 = eg(0) + bg(0): (6) All of the above expansions are formal an in even powers of h. The functions in (3)-(5) epen only on eq; ep an bg. The functions G; b G b ; : : : an also Q b ; P b ; : : : contain bg as factor, an bg(0) = O(h ). 3
Remark. The right han sie of the ierential equation for bg (5) contains bg as a factor, an bg(0) = O(h ); these facts imply that bg() = O(h ) for on compact intervals. Since, the functions Q b an P b also contain bg as factor, we have in aition bq() = O(h 4 ) an bp() = O(h 4 ). Proof. The iea is to insert () into the metho (5)-(8), to expan, an to compare like powers of h. This computation is signicantly simplie if we exploit the symmetric structure of the metho an if we expan the resulting expressions aroun := n +h=. Neglecting terms of orer O(h 4 ) an those of the form O(h bq ), O(h bp ), O(bq ), O(bq bp ), O( bp )) an omitting the obvious argument, we get (p n+ + p n ) = ep + h 8 ep 00 ( ) n h bp 0 + : : : h 4 (g n g n+ ) = h 4 eg h 0 + ( ) n h3 00 bg + bg + : : : : 6 Using these an similar relations for other variables, we obtain for the intermeiate approximations q n+= an p n+= the expansions p n+= = (p n+ + p n ) + h 4 g n F (q n ) g n+ F (q n+ ) = ep + h ep 00 (eg F (eq )) 0 (7) 8 ( ) h n bp 0 bgf (eq ) egf q (eq )bq + ( ) n h3 6 (bgf (eq ))00 + : : : ; q n+= = (q n+ + q n ) + h 4 (g n g n+ )M p n+= = eq + h eq 00 eg 0 M ep + bg M F (eq ) ( ) h n bq 0 bgm ep 8 +( ) n h3 6 bgm ep 00 + bg 00 M ep bg(eg M F (eq )) 0 bg eg 0 M F (eq ) + : : : ; (8) where F q (q) enotes the erivative of F with repect to q, an 0 enotes the erivative with respect to. We now write the main formulas of the metho (with the choice (0) for g n ) as q n+ q n = h (g n + g n+ )M p n+= ; (9) p n+ p n = h g n F (q n ) + g n+ F (q n+ ) ; (0) (g n+ + g n ) = G(q n+= ; p n+= ): () Inserting the relations () an (7)-(8), we get 4
heq 0 + h3 4 eq 000 ( ) n bq + : : : () = h eg + h 8 eg 00 ( ) h n M bg 0 ep + h 8 ( ep 00 (eg F (eq )) 0 ) +( ) n h bgf (eq ) + : : : ; h ep 0 + h3 4 ep 000 ( ) n bp + : : : (3) = h egf (eq ) + bgf q (eq )bq + h3 8 (egf (eq ))00 ( ) n h (bgf (eq ))0 + : : : ; eg + h 8 eg 00 ( ) n h bg 0 ( ) n h3 48 bg 000 + : : : (4) = G(eq; ep ) + G q (eq; ep )(q n+= eq ) + G p (eq; ep )(p n+= ep ) + : : : ; where G q an G p enote partial erivatives. Comparing the non-oscillating an oscillating parts in ()-(4) yiels equations for eq 0 ; ep 0 ; eg an bq; bp; bg 0, respectively. The higher erivatives appearing in the right-han sie have to be eliminate iteratively. This gives the moie equations (3)-(5). We obtain for example bg(eq; ep; bg ) = bg G q (eq; ep )M ep + G p (eq; ep )F (eq ) : (5) The algebraic relations for bq; bp; eg in (3)-(5) together with (6) constitute a set of six equations for the unknowns eq(0); bq(0); ep(0); bp(0); eg(0); bg(0). By the implicit function theorem they have a unique solution close to (q 0 ; 0; p 0 ; 0; g 0 ; 0),which can be written as a formal series in powers of h. Remark. For the choice () only the equations () an (4) have to be aapte, an one gets bg(eq; ep; bg ) = +bg G q (eq; ep )M ep + G p (eq; ep )F (eq ) ; (6) instea of (5). For the more general situation L(g n+ ) + L(g n ) = L G(q n+= ; p n+= ) ; which inclues (0) an () as special cases, we get bg(eq; ep; bg ) = bg + L gg(eg )eg G q (eq; ep )M ep + G p (eq; ep )F (eq ) : (7) L g (eg ) Corollary (Asymptotic Expansions) The functions eq(), bq(), ep(), bp(), eg(), bg() of Theorem all have asymptotic expansions in even powers of h. In particular, eg() = g() + h g () + O(h 4 ); bg() = h bg () + h 4 bg 4 () + O(h 6 ); (8) where g() = G(q(); p()) with (q(); p()) the solution of (3)-(4). 5
For the choice (0) of g n with G(q) only epening on q, bg () = G(q 0) G(q 0 )G qq (q 0 )(M p 0 ; M p 0 ) + (G q (q 0 )M p 0 ) ; (9) 8g() an for the choice () we have: bg () = g() 8 G(q 0)G qq (q 0 )(M p 0 ; M p 0 ): (30) Proof. We insert the formulas (8) an similar equations for eq(), bq(), ep(), bp() into the moie ierential-algebraic system (3)-(5), then compare like powers of h. This yiels ierential equations for eq i (), ep i (), bg i (), an algebraic relations for bq i (), bp i (), eg i (). A straightforwar computation gives (for (0)): g () = 8 g00 () + G q (q(); p()) 8 q00 () + q () 4 g0 ()M p() +G p (q(); p()) p () 8 p00 () ; (3) bg 0 () = bg ()g 0 ()=g(): (3) The ierential equation (3) can be solve for bg (), an we obtain bg ()g() = bg (0)g(0). Since q (0) = p (0) = 0, we get g (0) from (3) an then bg (0) from (6). This yiels the formula (9) for bg (). Formula (30) is obtaine in the same way. Example For an illustration of the oscillatory terms in the numerical solution an in the stepsizes we consier the problem q 0 = p; p 0 = =q ; G(q) = q ; with initial values q 0 = ; p 0 =. We apply the aaptive Verlet metho with ctive stepsize h = 0:08. The picture on the left in Fig. shows the values of g n as a function of the time t n, (i) for the choice (0) (inicate by small circles), an (ii) for the choice () (small squares). The secon an thir pictures of Fig. show the values g n g(t n ) together with the smooth curves h bg (t). For the choice (0) we observe increasing oscillations, an for t 0: the numerical solution becomes meaningless an the stepsizes hg n even become negative. We have joine consecutive points of fg n g by a polygon in orer to better illustrate this phenomenon. For the choice () the oscillations are very small (they can be observe only in the scale of the thir picture) an they are ecreasing. This can be explaine by the fact that bg (t) is inversely proportional to g(t) for the choice (0), whereas it is proportional to g(t) for the choice (), an g(t) = q(t) is approaching zero. The secon an thir pictures show excellent agreement of g n with the expansion g(t n )+h g (t n )+( ) n h bg (t n )+O(h 4 ), even for the rather large value h = 0:08 (observe that in the last two pictures the term h g (t) is not inclue in the smooth function). 6
.0...3.5...3.0...3.0 Figure : The values of g n (left picture) an g n g(t n ) (secon an thir pictures) as a function of time t n ; circles inicate the results for the choice (0), an squares for the choice (). 3 Elimination of the Dominant Oscillatory Terms In the proof of Corollary, we have seen that the function bg () is the solution of a linear autonomous ierential equation. If we are able to achieve bg (0) = 0, the function bg () will remain zero for all an the ominant term in bg() will be eliminate, implying bg() = O(h 4 ). Since bg is a factor in the algebraic relations (3)-(4) for bq an bp, this will also imply that bq() = O(h 6 ) an bp() = O(h 6 ). The iea is to use g 0 = G(q 0 ; p 0 ) + h + 4 h 4 + : : : (33) for the initial stepsize instea of g 0 = G(q 0 ; p 0 ). Such a choice neither aects the moie ierential-algebraic system (3)-(5) nor the relations (6) for its initial values. If (33) is an expansion in even powers of h, the symmetry of the metho will not be estroye. If g 0 is compute from (33), the value of bg (0) is given by = g (0) + bg (0): Therefore, the choice = g (0) with g (0) given by (3) implies bg (0) = 0. Example For the problem of Example it is not icult to compute g (0) from (3). We have g (0) = 5 for the choice (0) an g (0) = for (). With the same ctive stepsize h = 0:08 an with the same initial values as before we apply the aaptive Verlet scheme, but we use g 0 = G(q 0 ) + h g (0) instea of g 0 = G(q 0 ). The result is shown in Fig.. The values of g n (rst picture) an g n g(t n ) for the choice (0) (secon picture) still show an oscillating behaviour, but the magnitue of the oscillations is smaller an proportional to h 4. For the choice () (small squares) the oscillations are completely eliminate. For general problems, the computation of the value g (0) with the help of a formula like (3) can be cumbersome, in particular if G also epens on p. It is of course possible to use automatic ierentiation []. Another possibility is to apply the aaptive Verlet scheme with g 0 = G(q 0 ; p 0 ) two steps with positive ctive stepsize 7
.0...3.5...3.0...3.0 Figure : The same interpretation as in Fig., but with g 0 = G(q 0 ) + h g (0) instea of g 0 = G(q 0 ). an two steps with (for something like eps =4, where eps is the machine precision, the rouno an truncation errors are of the same orer). From the values g ; g ; g 0 ; g ; g, obtaine in this way, we then compute the fourth central ierence 4 = g 4g + 6g 0 4g + g ; which eliminates the smooth terms up to orer four an yiels 4 = 6 bg (0)+O( 4 ). With the starting stepsize g 0 = G(q 0 ; p 0 ) h 6 4 (34) we therefore eliminate the ominant oscillatory terms. We repeate the numerical experiment of Example with g 0 from (34) an observe the same eect as with g 0 = G(q 0 ) + h g (0). Acknowlegement. We are grateful to Gerhar Wanner for his useful comments on an earlier version of this paper. References [] M.P. Calvo, M.A. Lopez-Marcos an J.M. Sanz-Serna, Variable Step Implementation of Geometric Integrators, Appl. Numer. Math., to appear. [] G.F. Corliss an A. Griewank (es), Automatic Dierentiation of Algorithms. Theory, Implementation, an Application, SIAM, Philaelphia, PA, 99. [3] E. Hairer, Variable Timestep Integration with Symplectic Methos, Appl. Numer. Math. 5, 9-7, 997. [4] E. Hairer, S.P. Nrsett an G. Wanner, Solving Orinary Dierential Equations I. Nonsti Problems, Springer Series in Comput. Math., vol. 8, n eition, Springer-Verlag, 993. 8
[5] E. Hairer an G. Wanner, Solving Orinary Dierential Equations II. Sti an Dierential-Algebraic Problems, Springer Series in Comput. Math., vol. 4, n eition, Springer-Verlag, 996. [6] Th. Holer, B. Leimkuhler an S. Reich, Explicit, Variable Stepsize, an Timereversible Integration, preprint, submitte, 998. [7] W. Huang an B. Leimkuhler, The Aaptive Verlet Metho, SIAM J. Sci. Comput. 8, 39-56, 997. [8] B. Leimkuhler, Reversible Aaptive Regularization I: Perturbe Kepler Motion an Classical Atomic Trajectories, Report 997/NA-08, DAMTP, University of Cambrige, 997. [9] S. Reich, Backwar Error Analysis for Numerical Integrators, SIAM J. Numer. Anal., to appear. [0] D. Stoer, Variable Steps for Reversible Integration Methos, Computing 55,-, 995. 9