Explicit Runge–Kutta methods for the preservation of invariants M. Calvo 1 , D. Hern´andez-Abreu 2 , J.I Montijano1 and L. R´andez1 December 17, 2004
1
Departamento Matem´ atica Aplicada Universidad de Zaragoza. 50009-Zaragoza, Spain. email: calvo,monti,
[email protected] 2
Departamento de An´ alisis Matem´ atico Universidad de La Laguna,38271 La Laguna, Spain. email:
[email protected]
Abstract
1
Introduction and basic definitions.
First integrals and invariants of (autonomous) differential systems y 0 = f (y),
(1)
where f : D ⊂ Rm → Rm is a sufficiently smooth function play an important role both in qualitative and quantitative studies of the flow of (1). Consider e.g. the angular momentum and the energy integrals in the gravitational twobody problem which allow to describe the geometry of the orbits and also to check the accuracy of numerical integrators of the corresponding differential equation. b ⊂ Rm → Rl of class C 1 (D), b D b ⊂ D, is called an A function G = G(y) : D b (see [13],pp. 61) if l–invariant system of (1) in D b such that G(y 0 ) = 0. i) There exists some y 0 ∈ D ∗
This work was supported by project BFM2001-2562 and grant AP2002-2761.
1
∗
ii) For all solution y = y(t) of (1), G(y(t)) = 0 either holds for every t or for no t in the interval of definition of y(t). In such a case we may consider the flow defined by (1) restricted to the (n−l)– b G(y) = 0} as a differential equation on dimensional manifold M = {y ∈ D; M. In the case l = 1, the invariant system is called an invariant relation. In connection with the above concept, it is worth to remark that for l > 1 the l scalar relations which constitute the invariant system need not be invariant relations. On the other hand an l–invariant system is also called a weak invariant (see [5]). Further it is easy to see that G(y) is a weak invariant of (1) iff b such that G(y 0 ) = 0. i) There exists some y 0 ∈ D ii) ∇G(y)T f (y) = 0 for all y ∈ M. As an elementary example of invariant relation, consider the two dimensional system y10 = y2 + γ (1 − y12 − y22 ),
y20 = −y1 + γ (1 − y12 − y22 ),
(2)
where γ = γ(y1 , y2 ) : R2 → R is a smooth function. This system possesses the invariant relation G(y) ≡ y12 + y22 − 1 = 0, because the solution y(t) = (y1 (t), y2 (t)) of (2) fulfilling G(y(t0 )) = 0 for some t0 , i.e. y(t) = (y1 (t), y2 (t)) = (sin(t − t0 + θ0 ), cos(t − t0 + θ0 )), is contained in the unit circle M = {(y1 , y2 ); G(y) = 0} for all t ∈ R. Further, if y(t0 ) does not belong to the unit circle, then the corresponding solution will not intersect it for all t in its maximal interval of definition. In this example, by introducing the parametrization on the invariant manifold M = {y = (sin θ, cos θ), θ ∈ R}, the differential equation (2) restricted to M is given by θ0 = 1. b : Rm → R of class C 1 (D), b D b⊂ On the other hand, a scalar function F ⊂ D D, is a first integral (or a conserved quantity) of (1) if F (y(t)) is a constant along any solution path y = y(t) of (1). In such a case, since 0= it follows that
dF (y(t)) = ∇F (y(t))T · f (y(t)), dt ∇F (y)T · f (y) = 0,
for all y(t),
b for all y ∈ D.
(3)
b the solution y = y(t) of (1) such that y(0) = y 0 is Now for all y 0 ∈ D contained in the hypersurface My0 = {y ∈ Rm ; F (y) = F (y 0 )}. Moreover 2
it is known that there exist (locally) m − 1 independent first integrals at any point y 0 ∈ int(D), for any differential system (1) with f (y) 6≡ 0. First integrals are also called strong invariants (see [5, 7]) and, as a consequence, quadratic integrals G(y) = y T Sy, where S ∈ Rm×m is a constant symmetric matrix, are strong invariants of (1) iff y T S f (y) = 0,
for all y ∈ D.
(4)
In particular, it is not difficult to see that a two dimensional system y 0 = f (y) possesses a quadratic integral G(y) = y T Sy iff f has the form f (y) = Σ(y) S y, where µ ¶ 0 σ Σ = Σ(y) = , −σ 0 with a smooth scalar function σ = σ(y). Hence, upon a linear transformation, two dimensional linear systems possessing a quadratic integral can be written in the form y 0 = Σ(y)y,
with the integral G(y(t)) = y(t)T y(t) = y(t0 )T y(t0 ).
In order to simplify the presentation, we will use in the following the term invariant of the differential system (1) either for a first integral or for an invariant system (or relation) of (1). Note that the structure of the flow of systems with strong or weak invariants may be completely different. Thus, the flow around the invariant manifold is very stiff in the two dimensional system (2) with the weak invariant G(y) = y T y − 1 = 0, for γ constant and large; whereas this is not the case for the above two-dimensional systems with quadratic integrals. Since many general numerical integrators do not preserve first integrals or invariants of their corresponding differential systems, these functions have been used as a tool to measure the accuracy and the long term behaviour of these integrators. Thus, in the N –body gravitational problem the angular momentum and the energy are used customary to check the quality of the integrators. On the other hand, in the last two decades there has been an increasing interest in numerical integrators that preserve as far as possible the qualitative properties of the underlying differential systems. In particular, a natural requirement is to consider those numerical Runge–Kutta (RK) methods that preserve first integrals or invariants. It was proved by Cooper [2] that all RK methods conserve linear invariants. However an irreducible RK method preserve all quadratic invariants G(y) = y T Sy + µT y + ν with constants S ∈ Rm×m , µ ∈ Rm , ν ∈ R if and only if their coefficients (A ∈ Rs×s , b ∈ Rs ) satisfy mij ≡ bi aij + bj aji − bi bj = 0, 3
(1 ≤ i ≤ j ≤ s).
(5)
These conditions, which also imply that (A, b) is a symplectic method, pose strong requirements on the coefficients of the method which are satisfied only by some implicit RK methods and have been extensively studied in connection with symplectic methods. Moreover, it can be seen (see e.g. [5], Th 3.3, pp. 102 ) that for n ≥ 3 no RK method can conserve all polynomial invariants of degree n. Further studies on the preservation of algebraic invariants by RK methods have been carried out by Iserles and Zanna [7]. An alternative attempt to preserve invariants in numerical integrations is proposed by Schropp [9]. This author modifies the original flow of (1) by stabilizing the invariant set My0 = {y ∈ Rm ; G(y) = G(y 0 )} and considers the modified problem y 0 = f (y) − ∇G(y) a(y)(G(y) − G(y 0 )), where a(y) is a suitably chosen smooth function so that My0 is an exponentially attracting set for the modified problem. In view of this, the numerical solutions generated by the method are expected to approach to this attracting set; however, the modified problem may become very stiff depending on the choice of a(y). In view of the above limitations several techniques have been proposed to preserve invariants with practical numerical integrators . Thus, Buono and Mastroserio in [1], starting with explicit s–stage RK methods (A = (aij ), b = (bi )) given by the equations ϕh (yn ) = yn + h
s X
bj f (Yn,j ),
(6)
j=1
with Yn,1 = yn ,
Yn,i = yn + h
i−1 X
aij f (Yn,j ) (2 ≤ i ≤ s)
(7)
j=1
modify the advancing solution (6) of the method by introducing at each step a scalar γn = γn (yn , h), so that the new method ϕ bh defined by (7) and ϕ bh (yn ) = yn + hγn
s X
bj f (Yn,j ),
(8)
j=1
preserves a given invariant G, i.e. G(ϕ bh (yn )) = G(yn ). Clearly, this requirement implies that γn will be a problem dependent scalar such that γn → 1 when h → 0 that may vary from step to step. These authors [1] have proved that for all differential system (1) possessing a quadratic invariant G(y) = y T Sy with a symmetric S, there exist four–order explicit RK methods ϕh with four stages such that the modified method ϕ bh given by (7) and (8) preserves the quadratic invariant and has order three 4
for a suitable value γn . Further, it is seen that ϕ bh attains order four at tn + hγn , and therefore ϕ bh would get (global) order four at the non uniform b b b grid {b tn }N n=0 with t0 = t0 and tn+1 = tn + hγn . To compute γn at each step, the authors [1] use the formula γn = 1 − (δn /ηn ) with ηn =
4 X
bi bj hf (Yn,i ), f (Yn,j )i,
δn = ηn − 2
i,j=1
4 X i−1 X
bi aij hf (Yn,i ), f (Yn,j )i,
i=2 j=1
where hu, vi ≡ uT Sv for u, v ∈ Rm , is the bilinear form associated to the invariant G(y) = y T Sy. This means that the computational cost of ϕ bh at each step includes s(s − 1)/2 = 6 scalar products hf (Yn,i ), f (Yn,j )i, apart from the function evaluations of (7). Note that (8) can be written as ϕ bh (yn ) = ϕh (yn ) + (γn − 1)(ϕh (yn ) − yn ),
(9)
and then ϕ bh (yn ) can be considered as the projection of ϕh (yn ) onto the invariant manifold Myn = {y ; G(y) = G(yn )} along the direction ϕh (yn ) − yn of the increment function of ϕh at yn . In the remainder of this paper this technique will be called the incremental direction technique. An alternative technique (see [5], pp. 106), known as the standard projection method, consists of combining a standard RK method ϕh (or any one step method) together with an orthogonal projection P onto the invariant manifold Myn at each step (tn , yn ) → (tn+1 = tn + h, yn+1 ). In this way, for the Euclidean norm, the method would be given by yn+1 = (P · ϕh )(yn ) with yn+1 defined by yn+1 = ϕh (yn ) + ∇G(yn+1 )T λn ,
with G(yn+1 ) = G(yn ).
Due to the implicitness, the above system is replaced in [5] by yn+1 = ϕh (yn ) + ∇G(ϕh (yn ))T λn ,
with G(yn+1 ) = G(yn ).
(10)
and the calculation of λn at each step is carried out applying a simplified Newton iteration to the nonlinear equation obtained by substituting the first of (10) into the invariant. As remarked in [5], since λn is small, taking the starting value λn,0 = 0, one simplified Newton iteration is usually enough for practical purposes. Thus, in this technique, that will be called thereafter the simplified projection, ϕ bh (yn ) is obtained projecting ϕh (yn ) along the orthogonal direction to G(y) at ϕh (yn ). Such a projection has the same order as the original method but it requires the computation of ∇G at each step and further some qualitative properties of the underling numerical integrator may be destroyed. 5
As follows from (9) and (10), the above projection techniques can be included into the general form ϕ bh (yn ) = ϕh (yn ) − λn Φn ,
(11)
m
where the vector Φn ∈ R defines the direction of projection and λn is a scalar chosen so that ϕ bh (yn ) belongs to the invariant manifold. In the case (9), λn = 1 − γn and the direction Φn = ϕh (yn ) − yn is defined by the original method and a zero order method. In the case (10) of the simplified projection, Φn is orthogonal to the invariant at ϕh (yn ). Clearly, other possible directions Φn may be considered; in particular, taking into account that for many explicit RK methods several low order approximations s X ebj f (Yn,j ) ϕ eh (yn ) = yn + h j=1
are usually available without additional cost, one is tempted to take Φn = ϕh (yn ) − ϕ eh (yn ),
(12)
and then the resulting projected method (11) ϕ bh (yn ) = yn + h
s X
((1 − λn )bj + λnebj )f (Yn,j ),
(13)
j=1
has the form of a RK method with (variable) weights bbj = (1 − λn )bj + λnebj and retains some properties of these methods such as the preservation of linear invariants and also has a low computational cost. The aim of this paper is to study projected methods of type (13) that preserve quadratic (or more general) invariants. In section 2, a revision of the case ϕ eh (yn ) = yn , in which the companion method has order zero, is presented with the purpose to generalize the results given in [1] and also to show a more efficient way of computing λn . In section 3, a general study for quadratic invariants and embedded methods ϕ eh with order q (1 ≤ q < p) is presented. Next, in section 4, this study is generalized to non quadratic scalar invariants and to the case of several scalar invariants. Finally, in section 5, some numerical experiments with the classical embedded pairs of explicit Runge-Kutta methods of orders 5 and 4, DoPri5(4) and RKFehlberg5(4) [3, 4], are presented in order to show the effect of different projections on several test problems.
2
The incremental direction technique revisited.
In [1] Buono and Mastroserio propose to advance the integration tn → tn+1 = tn + h with the RK method ϕ bh given by (8), where γn is properly chosen so 6
that the method preserves a fixed quadratic invariant G(y) = y T S y = hy, yi. Here we will write ϕ bh in the equivalent form ϕ bh (yn ) = ϕh (yn ) − λn (ϕh (yn ) − yn ) = (1 − λn )ϕh (yn ) + λn yn ,
(14)
so that the scalar λn = 1 − γn will be a small quantity at each step. Next it will be seen that for all RK method ϕh with order p ≥ 2 the projected method ϕ bh has order p − 1. This result generalizes Proposition 4 of [1] in two directions: firstly, it extends the statement on fourth order RK methods to any order p ≥ 2; secondly, there are no restrictions on the coefficients of the method ϕh in contrast with the situation in [1]. Finally, we will show that for any order p, λn (or γn ) can be computed with two bilinear form evaluations h·, ·i per step. With the notation (14) and putting ϕh (yn ) − yn = h∆n , the preservation of the quadratic invariant G(y) = y T Sy = hy, yi holds iff λn satisfies 2(1 − λn )hyn , h∆n i + (1 − λn )2 hh∆n , h∆n i = 0. Since λn 6= 1, this is equivalent to 2hyn , h∆n i + (1 − λn )hh∆n , h∆n i = 0.
(15)
If hyn , h∆n i = hh∆n , h∆n i = 0 then hϕ bh (yn ), ϕ bh (yn )i = hyn , yn i for all λn , and therefore it would be enough to take λn = 0 (i.e. the original method ϕh ) to preserve the invariant. If either hyn , h∆n i = 0 or else hh∆n , h∆n i = 0, the equation (15) cannot be satisfied by λn 6= 1 and therefore it is not possible to preserve the invariant. Hence the following condition hyn , ∆n i h∆n , ∆n i 6= 0,
(16)
must be satisfied in order to make (15) solvable. Observe that if ϕh is Euler’s method, since ∆n = f (yn ) we have hyn , f (yn )i = ynT Sf (yn ) = 0, and condition (16) does not hold. Thus, only methods with order p ≥ 2 will be considered and we have the following: Theorem 2.1 Let ϕh a method with order p ≥ 2 and suppose that (16) holds. bh given by (14) preserves the quadratic invariant i) The projected method ϕ G(y) = hy, yi provided that λn is chosen as λn =
hϕh (yn ), ϕh (yn )i − hyn , yn i h2yn + h∆n , h∆n i = . hh∆n , h∆n i hϕh (yn ) − yn , ϕh (yn ) − yn i 7
(17)
ii) If hf (yn ), f (yn )i 6= 0 then the projected method ϕ bh has order p − 1. Proof. Under the assumption (16) the equation (15) has the solution λn given by (17) and therefore the method ϕ bh preserves the quadratic invariant. On the other hand, since ϕh has order p we have ϕh (yn ) = yn + h∆n = y(tn + h) + ²n+1 , where ²n+1 = Cp+1 hp+1 + O(hp+2 ) is the local error of ϕh at yn with step size h and y(tn +t) is the local solution of (1) at (tn , yn ), i.e., it satisfies y(tn ) = yn and hy(tn + h), y(tn + h)i = hy(tn ), y(tn )i = hyn , yn i, for all h. Then, for the numerator of λn in (17) we have hϕh (yn ), ϕh (yn )i − hyn , yn i = hy(tn + h) + ²n+1 , y(tn + h) + ²n+1 i − hyn , yn i = 2hy(tn + h), ²n+1 i + h²n+1 , ²n+1 i = 2hyn , Cp+1 ihp+1 + O(hp+2 ), which is of order p + 1. For the denominator of (17) we have hh∆n , h∆n i = hy(tn + h) − yn + ²n+1 , y(tn + h) − yn + ²n+1 i = h2 hy 0 (tn ), y 0 (tn )i + O(h3 ) which is of order O(h2 ) providing that hy 0 (tn ), y 0 (tn )i = hf (yn ), f (yn )i 6= 0. Then, λn behaves as O(hp−1 ) and, according to (14), this implies that ϕ bh is a method of order p − 1. ¤ To end this section, observe that it follows from (17) that the computation of λn requires only two bilinear forms per step in contrast with [1] which needs 6 bilinear forms for s = 4. Moreover, since the two required bilinear forms are hϕh (yn ), ϕh (yn )i, hϕh (yn ), yn i, only one matrix–vector product is necessary.
3
A general projection technique
Let ϕh be an explicit s–stage RK method (A, b) with order p defined by the equations (6)–(7), and let ϕ eh be an embedded method with order q (1 ≤ q < p) defined by the weights ebi , i = 1, . . . , s, so that ϕ eh (yn ) = yn + h
s X
ebi f (Yn,i ).
i=1
As remarked above, practical RK methods possess embedded methods with several orders (1 ≤ q ≤ p−1), so that we have a wide freedom in the choice of 8
ϕ eh and, further, the computation of the embedded method does not require additional function evaluations. Suppose that (1) possesses a quadratic invariant G(y(t)) = y(t)T Sy(t) − y(0)T Sy(0) = hy(t), y(t)i − hy(0), y(0)i. We propose to complete the step tn → tn+1 projecting ϕh (yn ) onto the manifold defined by the invariant Myn = {y ∈ Rm ; hy, yi = hyn , yn i} along the direction ϕh (yn ) − ϕ eh (yn ). Then the projected method ϕ bh is given by ϕ bh (yn ) = ϕh (yn ) − λn (ϕh (yn ) − ϕ eh (yn )),
(18)
with λn = λn (h, yn ) scalar such that G(ϕ bh (yn )) − G(yn ) ≡ hϕ bh (yn ), ϕ bh (yn )i − hyn , yn i = 0.
(19)
Substituting (18) into (19), λn must satisfy αn λ2n − 2βn λn + δn = 0,
(20)
αn = hϕh (yn ) − ϕ eh (yn ), ϕh (yn ) − ϕ eh (yn )i, βn = hϕh (yn ), ϕh (yn ) − ϕ eh (yn )i, δn = hϕh (yn ), ϕh (yn )i − hyn , yn i.
(21)
with
For a given h, the original method preserves the quadratic invariant if δn = 0, and then we will take λn = 0. On the other hand, βn2 − αn δn ≥ 0 must be required in order to ensure the existence of a real solution of (20) if δn 6= 0. As a first result on the existence of solution of (20), observe that the function g(λn ) : [0, 1] → R given by the left hand side of (19), g(λn ) = G(ϕ bh (yn )) − G(yn ), is a continuous function such that g(0) = G(ϕh (yn )) − G(yn ) = hϕh (yn ), ϕh (yn )i − hyn , yn i = δn g(1) = G(ϕ eh (yn )) − G(yn ) = hϕ eh (yn ), ϕ eh (yn )i − hyn , yn i = δen are the defects of the invariant for the embedded solutions of orders p and q, respectively. Therefore, if sign g(0) 6= sign g(1), there exists a unique λ ∈ (0, 1) such that g(λ) = 0, since g(λ) is a quadratic function. By introducing the “mixed” defect δn∗ = hϕh (yn ), ϕ eh (yn )i − hyn , yn i, the coefficients of (20) can be expressed in terms of the defects δn , δen , δn∗ as αn = δn + δen − 2δn∗ , 9
βn = δn − δn∗ .
We choose λn as the real root of g(λ) = 0 closest to λ = 0. For βn 6= 0, it can be written as δn δn p q λn = = , (22) βn + sigβn βn2 − αn δn ∗ ∗ 2 e (δ − δ ) + sig(β ) (δ ) − δ δ n
and if βn = 0
n
n
n
n n
¶1/2 µ ¶1/2 −δn −δn = λn = . αn δen − δn To study the order of the projected method observe that µ
ϕh (yn ) = y(tn + h) + ²n+1 ,
ϕ eh (yn ) = y(tn + h) + e ²n+1 ,
(23)
where y(tn + t) is the local solution at (tn , yn ) and ²n+1 , e ²n+1 are the local errors of the corresponding solutions that satisfy eq+1 hq+1 + O(hq+2 ). e ²n+1 = C
²n+1 = Cp+1 hp+1 + O(hp+2 ),
The asymptotic behaviour of the defects δn , δen , δn∗ are δn = 2hy(tn + h), ²n+1 i + h²n+1 , ²n+1 i = 2hyn , Cp+1 ihp+1 + O(hp+2 ), eq+1 ihq+1 + O(hq+2 ), δen = 2hy(tn + h), e ²n+1 i + he ²n+1 , e ²n+1 i = 2hyn , C eq+1 ihq+1 + O(hq+2 ). δn∗ = hy(tn + h), ²n+1 + e ²n+1 i + h²n+1 , e ²n+1 i = hyn , C Therefore if r (≥ q) is the maximum integer such that βn = B(yn )hr+1 + O(hr+2 ),
B(yn ) 6= 0,
(24)
it follows from (22) that λn behaves as O(hp−r ) and the associated projected method has order ≥ pb = p − r + q. More generally, we get a projected method ϕ bh with order pb by choosing 2 λn = λn (h) as the real solution (22), if βn − αn δn = (δn∗ )2 − δn δen ≥ 0, for all h ∈ [0, h∗ ]. Further, observe that if (24) holds and p + 2q − 2r + 1 ≥ 0, then the asymptotic behaviour of βn2 − αn δn implies that there exists h∗ > 0 such that this quantity is positive for all h ∈ (0, h∗ ]. In fact, since p > q, it follows from (21) and (23) that αn = hϕh (yn ) − ϕ eh (yn ), ϕh (yn ) − ϕ eh (yn )i = hεn+1 − εen+1 , εn+1 − εen+1 i = O(h2q+2 ) and δn = O(hp+1 ). Therefore αn δn = O(hp+2q+3 ) and from (24) ¡ ¢ βn2 − αn δn = h2r+2 B(yn )2 − O(hp+2q−2r+1 ) , which implies the existence of h∗ > 0 above. In conclusion, we may state the following 10
Theorem 3.1 Let ϕh and ϕ eh two embedded RK methods with orders p and q (1 ≤ q ≤ p − 1) . i) If there exists h∗ > 0 such that (δn∗ )2 − δn δen ≥ 0 for all h ∈ [0, h∗ ], then the projected method ϕ bh with λn = λn (h) given by (22) has order ≥ pb = p − r + q, with r given by (24). ii) If p+2q −2r +1 > 0, then there exists h∗ > 0 such that (δn∗ )2 −δn δen ≥ 0 for all h ∈ (0, h∗ ]. ¤ In practical application of the above projection technique (18), given an explicit RK method ϕh of order p, we usually have the freedom to choose several embedded methods ϕ eh with different orders (1 ≤ q ≤ p−1). Then the question is how to choose ϕ eh . It will be seen that the simplest choice, namely Euler’s method, provides (in general) a projected method with order ≥ p. In fact, for ϕ eh (yn ) = yn + hf (yn ), we have q = 1 and εen+1 = (1/2)y 00 (tn )h2 + 3 e2 = (1/2)y 00 (tn ) and from (21) O(h ); therefore, C 1 βn = hy(tn + h) + εn+1 , εn+1 − εen+1 i = − h2 hy(tn ), y 00 (tn )i + O(h3 ), 2 and
αn = O(h4 ),
δn = O(hp+1 ).
From here, if B(yn ) = hy(tn ), y 00 (tn )i 6= 0, then βn2 − αn δn is positive for h in some interval [0, h∗ ], and, from (22), λn = O(hp−1 ). Now, according to Theorem 3.1, the order of the projected method is ≥ p. Finally, observe that the condition B(yn ) = hy(tn ), y 00 (tn )i 6= 0 can be easily checked, because the existence of the invariant hy(t), y(t)i = hy(tn ), y(tn )i, implies and then
hy(t), y 0 (t)i = 0,
hy(t), y 00 (t)i + hy 0 (t), y 0 (t)i = 0,
B(yn ) = −hy 0 (tn ), y 0 (tn )i = −hf (yn ), f (yn )i.
Remark. The above theory extends easily to more general invariants which include both quadratic and linear terms with the form G(y(t)) = y(t)T Sy(t) + dT y(t) − y(0)T Sy(0) − dT y(0), where S is a symmetric constant matrix and d a constant vector. In fact, for ϕ bh given by (18), (19) holds iff λn satisfies αn λ2n − 2βn0 λn + δn0 = 0, 11
(25)
with βn0 = βn + (1/2)dT ϕh (yn ) − (1/2)dT ϕ eh (yn ), 0 T T δn = δn + d ϕh (yn ) − d yn . For a given h, if δn0 = 0 then the original method ϕh preserves the invariant and we take λn = 0. Otherwise, the existence of a real solution of the quadratic equation (25) depends on the sign of (βn0 )2 − αn δn0 and sufficient conditions similar to those in Theorem 3.1 can be given in order to guarantee the solvability.
4
General invariants
In this section we extend our approach to non quadratic scalar invariants and to the case of several scalar invariants. For a general scalar invariant given by a smooth function G = G(y) : b D ⊂ Rm → R the proposed projection technique reduces to the solution of the nonlinear scalar equation ³ ´ g(λn ) ≡ G ϕh (yn ) − λn (ϕh (yn ) − ϕ eh (yn )) − G(yn ) = 0. (26) In this case, the existence of solution λn is guaranteed under the conditions of the following Theorem 4.1 Let ϕh and ϕ eh be two embedded RK methods with orders p and q (1 ≤ q ≤ p − 1), respectively, and let r ≥ q be the maximum integer such that ∇G(ϕh (yn ))T [ϕ eh (yn ) − ϕh (yn )] = Cr+1 (yn )hr+1 + O(hr+2 ) with Cr+1 (yn ) 6= 0. If r ≤ min{p − 1, 2q + 1} then there exists h∗ > 0 such that for all h ∈ [0, h∗ ] the equation g(λn ) = 0 defines a unique function λn = λn (h, yn ) satisfying λn (h, yn ) → 0 when h → 0. Moreover, the projected method ϕ(y b n) has order pˆ = p − r + q. Proof. For λ, h ∈ R let us define the function g : R × R → R given by ³ ´ g(λ, h) ≡ G ϕh (yn ) + λ(ϕ eh (yn ) − ϕh (yn )) − G(yn ). Taking into account that g(0, h) = O(hp+1 ) and ϕ eh (yn ) − ϕh (yn ) = q+1 −(r+1) O(h ), it is not difficult to see that z(λ, h) ≡ h g(λ, h) behaves in
12
neighbourhoods of (λ = 0, h = 0) like z(λ, h) =
h h λ
¢ ¤ 1 £ ¡ G ϕ (y ) + λ( ϕ e (y ) − ϕ (y )) − G(y ) = h n h n h n n r+1 ¡ ¢ [G ϕ (y ) − G(yn )]+ h n r+1 1
1 hr+1
[∇G(ϕh (yn ))T (ϕ eh (yn ) − ϕh (yn ))]+
λ2 O(h2q+1−r ), and so it defines a smooth function in a neighbourhood of (λ = 0, h = 0) if r ≤ min{p − 1, 2q + 1}. In addition, ∂z (0, 0) = Cr+1 (yn ) 6= 0, ∂λ and the implicit function theorem ensures the existence of neighbourhoods Vλ0 of λ = 0 and Vh0 of h = 0 such that for all h ∈ Vh0 there exists a unique λ = λ(h, yn ) ∈ Vλ0 satisfying z(λ, h) = 0. Then, since g(λ, h) = hr+1 z(λ, h) there exists h∗ > 0 such that for all h ∈ (0, h∗ ] the equation g(λ) = 0 has a unique solution λn (h, yn ) fulfilling λn (h, yn ) → 0 when h → 0. On the other hand, let us suppose that λn (h, yn ) = O(hα ) with α > 0. We can expand 0 = g(λn ) = g(0) + g 0 (0)λn + ², with g(0) = G(ϕh (yn )) − G(yn ) = O(hp+1 ) g 0 (0)λn = λn ∇G(ϕh (yn ))T [ϕ eh (yn ) − ϕh (yn )] = O(hr+1+α ) ² = O(λ2n h2q+2 ) = O(h2q+2+2α ), and taking into account that r + 1 + α < 2q + 2 + 2α, it can be concluded that p + 1 ≤ r + 1 + α and therefore λn = O(hp−r ). Consequently ϕˆh (yn ) = ϕh (yn ) + λn [ϕ˜h (yn ) − ϕh (yn )] has order pˆ = p − r + q. ¤ Note that for quadratic invariants, the condition in the above theorem reduces to ∇G(ϕh (yn ))T [ϕh (yn ) − ϕ eh (yn )] = hϕh (yn ), ϕh (yn ) − ϕ eh (yn )i = Cr+1 (yn )hr+1 + O(hr+2 ), which is equivalent to the condition βn = O(hr+1 ). If explicit Euler is taken as embedded method, ϕ eh (yn ) = yn + hf (yn ), we get the following eh (yn ) = yn + Corollary 4.1 Let ϕh be a RK method with order p and ϕ T 00 ∗ hf (yn ). If ∇G(y(tn + h)) y (tn ) 6= 0 then there exists h > 0 such that for all h ∈ [0, h∗ ] the equation g(λn ) = 0 defines a unique function λn = λn (h, yn ) that satisfies λn (h, yn ) = O(hp−q ), and the projection method has order p. 13
Proof. It is enough to consider that ∇G(ϕh (yn ))T [ϕh (yn ) − ϕ eh (yn )] = 1 00 2 3 ∇G(y(t + h))y (t )h + O(h ). Theorem 4.1 immediately gives the result. n n 2 ¤ Suppose now that the differential system (1) possesses l ≥ 1 smooth invariants G1 (y), . . . , Gl (y) defined in D ⊂ Rm and let G = (G1 , . . . , Gl )T : D ⊂ Rm → Rl . Together with the starting method ϕh of order p we consider l linearly (1) (l) independent embedded methods ϕ eh , . . . , ϕ eh with orders q1 ≤ q2 ≤ . . . ≤ ql < p. Then, generalizing (18), the projected method ϕ bh will be defined by ϕ bh (yn ) = ϕh (yn ) −
l X
³ λi ϕh (yn ) −
´
(i) ϕ eh (yn )
,
(27)
i=1
where λi = λi (yn , h), i = 1, . . . , l, are problem depending scalars that will be chosen so that G(ϕ bh (yn )) = G(yn ). (28) We also introduce the m × l matrix Tn defined by its column vectors h i (1) (l) Tn = ϕ eh (yn ) − ϕh (yn )| . . . |ϕ eh (yn ) − ϕh (yn ) , and let r (≥ q1 ) be the maximum integer so that (∇G(ϕh (yn )))T Tn = Mr+1 hr+1 + O(hr+2 ),
(29)
with Mr+1 = Mr+1 (yn ) ∈ Rl×l so that det Mr+1 6= 0. With these notations we have Theorem 4.2 If r ≤ min{p − 1, 2q1 + 1} then there exist h∗ > 0 and a unique set (λ1 (h, yn ), . . . , λl (h, yn )) such that the projected method ϕ bh defined by (27) preserves the l invariants Gi , i = 1, . . . , l, for all h ∈ [0, h∗ ]. Proof. Consider λ = (λ1 , . . . , λl )T and g(λ, h) defined by à ! l ³ ´ X (i) g(λ, h) = G ϕh (yn ) − λi ϕh (yn ) − ϕ eh (yn ) − G(yn ). i=1
By the assumed smoothness of G and f , g(λ, h) can be written for all λ in a neighbourhood of the origin in terms of the Fr´echet derivatives in the form Z 1 0 g(λ, h) = g(0, h) + g (0, h)[λ] + (1 − s)g 00 (sλ, h)[λ, λ] ds. (30) 0
14
Here and
g(0, h) = G(ϕh (yn )) − G(yn ) = O(hp+1 ), Z
1
00
(1 − s)g (s, h)[λ, λ] = 0
l X
h → 0,
λi λj O(hqi +qj +2 ).
i,j=1
Further, taking (29) into account, we have g 0 (0, h)[λ] = (∇G(ϕh (yn )))T Tn λ = Mr+1 λhr+1 + O(hr+2 ). Hence the function z : Rl × R → Rl defined by z(λ, h) = h−(r+1) g(λ, h) is smooth in a neighbourhood of the origin provided that all qi + qj + 2 > r + 1 and p + 1 > r + 1, and it satisfies ∇λ z(0, 0) = Mr+1 . Thus, from the implicit function theorem, the equation z(λ, h) = 0 defines in a neighbourhood of h = 0 a unique λ = λ(h) such that z(λ(h), h) = 0, and therefore the projected method (27) is well defined for h in a neighbourhood of the origin. Finally, taking the above expansions into account, it follows from (30) that λ = O(hp−r ). From the local error expression ϕ bh (yn ) − yn (tn+1 ) = (ϕh (yn ) − yn (tn+1 )) +
l X
³ ´ (i) λi ϕ eh (yn ) − ϕh (yn )
i=1
= O(hp+1 ) +
l X
¡ ¢ O(hp−r )O(hqi +1 ) = O hpb+1
i=1
with pb = p − r + q1 . ¤ To end this section, the following result is given in order to ensure that Newton-Type iterations applied to the equations (26)-(28) provide numerical sequences which converge in small neighbourhoods of the origin. In fact, we have the following Corollary 4.2 Under the same conditions of Theorem 4.2 above, there exists h∗ > 0 such that for all 0 < h < h∗ the sequence {λ(k) } defined by Newton’s method applied to the equation (28), with λ(0) := 0, converges to the unique zero of this equation in a sufficiently small neighbourhood of the origin λ = 0. Proof. Considering, as in Theorem 4.2 above, the function à ! l ³ ´ X (i) g(λ) = G ϕh (yn ) − λi ϕh (yn ) − ϕ eh (yn ) − G(yn ). i=1
15
it is not difficult to see that γ :=
k ∇g(λ) − ∇g(µ) k = O(h2q1 +1 ), kλ−µk λ,µ∈Λ0 sup λ6=µ
α := k ∇g(0)−1 g(0) k= O(hp−r ), β := k ∇g(0)−1 k= O(h−r−1 ), where Λ0 ⊂ Rl stands for a sufficiently small neighbourhood of λ = 0. Thus, there exists h∗ > 0 such that for all 0 < h < h∗ 1 τ := γαβ = O(hp+2q1 −2r+1 ) ≤ 2 is fulfilled. Then, the statement follows from the Newton-Kantorovich Theorem (see, e.g., Theorem 5.3.6 in [12]). ¤ It is worth to remark that in case of unidimensional invariants the asymptotic behaviour τ = O(hp+2q−2r+1 ) also imply that explicit Euler method as embedded method provides in general a less stringent bound τ = O(hp+1 ) ≤ 1 for the stepsize selection when solving the corresponding nonlinear equa2 tions. This is particularly interesting when considering a variable stepsize strategy in order to integrate differential systems with invariants, and it could also explain why in practice embedding explicit Euler gives in general better results than embedding other high order methods.
5
Numerical Experiments
Here we present some numerical experiments in order to assess the theoretical results presented in the previous sections. The aim of this experiments is to show numerically both the preservation of the selected invariants of the problem into consideration and the maintenance of the highest order of consistency of the underlying pair of embedded explicit methods. The classical pairs of Dormand and Prince (1980) DoPri5(4) and Fehlberg (1969) RKF5(4) (see, e.g., [3, 4] for details on the coefficients of these methods) have been considered as numerical integrators in order to test the efficiency of the projection technique (18)-(27). Some practical examples, not just academic test problems, have been considered in order to illustrate how the projection technique performs on this kind of problems with first integrals. More precisely, we will show here some results related to the following problems: Problem 1: A problem of micromagnetism, ([10]). f (y) := Hef f × y + λy × (Hef f × y), with λ = 1/20.1 and Hef f , y ∈ R3 . We have chosen the initial value y(0) = (y0 [1], y0 [2], y0 [3]) = (sin θ0 cos ϕ0 , − sin θ0 sin ϕ0 , cos θ0 )T , where ϕ0 = π/4 and θ0 = π/3. 16
This kind of equations appear in micromagnetism problems when solving the Landau-Lifshitz-Gilbert equation (see, e.g., [8, 10, 11]). Since y 0 (t) is orthogonal to the exact solution y(t), it is clear that the euclidean norm k y(t) k2 remains constant. In case of Hef f := (1, 0, 0)T , the exact solution is given by µ y(t) =
¶T a(t) 2 2 , (y0 [2] cos t − y0 [3] sin t), (y0 [2] sin t + y0 [3] cos t) , b(t) b(t) b(t)
with a(t) = eλt (1 + y0 [1]) − e−λt (1 − y0 [1]), b(t) = eλt (1 + y0 [1]) + e−λt (1 − y0 [1]). Problem 2: Two-Body problem, (see, e.g., [5, pp. 7–8]). µ
¶T y1 y2 f (y) := y3 , y4 , − 2 ,− , (y1 + y22 )3/2 (y12 + y22 )3/2 √ with y = (y1 , y2 , y3 , y4 )T and y(0) = (0.5, 0, 0, 3)T . This system provides a periodic solution with a minimal period T2 = 2π. The angular momentum is considered here as a quadratic invariant for the exact solution. The total energy will be also considered as a first integral. (i) y1 y4 − y2 y3 = const.,
(ii)
1 2 1 (y3 + y42 ) − p 2 = const. 2 y1 + y22
Problem 3: The restricted three body problem, (see, e.g., [6, pp. 129–130]). µ f (y) :=
y1 + µ y1 − µ ¯ y2 y2 y3 , y4 , y1 + 2y4 − µ ¯ −µ , y2 − 2y3 − µ ¯ −µ D1 D2 D1 D2
¶T ,
with D1 := ((y1 +µ)2 +y22 )3/2 , D2 := ((y1 −¯ µ)2 +y22 )3/2 , y = (y1 , y2 , y3 , y4 )T and y(0) = (0.994, 0, 0, −2.00158510637908252240537862224)T , where µ ¯ = 1−µ and µ = 0.012277471. For this initial values we get a periodic solution with a minimal period T3 := 17.0652165601579625588917206249. The total energy is a first integral and the exact solution fulfils 1 2 (y3 + y42 − y12 − y22 ) − µ ¯((y1 + µ)2 + y22 )−1/2 − µ((y1 − µ ¯)2 + y22 )−1/2 = const. 2 Problem 4: Euler equations, (see, e.g., [1]). ¢T ¡ f (y) := (α − β)y2 y3 , (1 − α)y3 y1 , (β − 1)y1 y2 , 17
with y = (y1 , y2 , y3 )T and y(0) = (0, 1, 1)T , where α = 1 + . Thus, the exact solution is given by 1 − √0.51 1.51 µ y(t) =
√
√1 1.51
and β =
¶T 1.51sn(t, 0.51), cn(t, 0.51), dn(t, 0.51) ,
where sn,cn,dn stand for the elliptic Jacobi functions. Then, given I1 , I2 , I3 by the relations α − β = (I2 − I3 )/(I2 I3 ), 1 − α = (I3 − I1 )/(I1 I3 ), and β − 1 = (I1 − I2 )/(I1 I2 ), we have for the exact solution µ ¶ 1 y12 y22 y32 2 2 2 (ii) (i) y1 + y2 + y3 = const., + + = const. 2 I1 I2 I3 Problem 5: Pendulum equation in cartesian coordinates, (see, e.g., [5, pp. 106]). µ ¶T y32 + y42 − y2 y32 + y42 − y2 f (y) := y3 , y4 , −y1 , −1 − y2 , y12 + y22 y12 + y22 with y = (y1 , y2 , y3 , y4 )T and y(0) = (1, 0, 0, 1)T . The exact solution is periodic with a minimal period T5 = 8.6260625899985729417546999952016 and it fulfils the quadratic relations (i) y1 (t)y3 (t) + y2 (t)y4 (t) = 0,
(ii) y1 (t)2 + y2 (t)2 = 1,
∀t ≥ 0.
The parameter γn defining the projected method (18) can be directly computed from (22), in case the problem into consideration possesses a unidimensional quadratic invariant. For more general invariants, this parameter can be accurately estimated by solving the nonlinear equation (28) by means of Newton-type iterations with initial guess γn,0 = 0, being the convergence of the corresponding iteration guaranteed by virtue of Corollary 4.2 in section 4. As mentioned above, given an explicit RK method of order p, we usually have the freedom to choose several embedded methods with different orders. In particular, it was shown that considering explicit Euler as embedded method provides in general a projected method which preserve both the invariant of the problem and the order of consistency of the original method. In this way, we have integrated those problems above by considering the original pair of embedded methods with consecutive orders p(p − 1), and also by considering explicit Euler as embedded method to the highest order method in the original pair. Given one stepsize h = 1/2i , 1 ≤ i ≤ 5, we have displayed in tables 1–4 below some representative values for the integration of problems 1,2 listed above (only the total energy was considered as invariant in tables 18
3–4): GE(h) stands for the global error of the highest order method in d d eul (h) the underlying pair at the advancing point, whereas GE(h) and GE denote the global error of the projected method when considering the classical pair with orders p(p − 1) and also when embedding explicit Euler to the highest order method in the original pair, respectively. As it can be seen in Tables 1–4 below, the projected method is seen to preserve both the order of consistency and the invariant when considering both strategies, but, in general, embedding explicit Euler gives a slightly better approximation to the exact solution. The value corresponding to the error when measuring the preservation of the invariant, i.e. IE(h), has been also displayed for the highest order method in the original pair of embedded methods. This value has not been presented here for the projected method because it was, in all cases, close to the precision machine (eps = 2.2204e − 16 for Matlab). Table 1: Problem 1. DoPri5(4) & DoPri5-Eul. i 1 2 3 4 5
GE(h) 0.2895D − 05 0.4270D − 07 0.7031D − 09 0.1128D − 10 0.1785D − 12
d GE(h) 0.7791D − 05 0.1966D − 06 0.5941D − 08 0.2262D − 09 0.1886D − 10
d eul (h) GE 0.1468D − 05 0.1133D − 07 0.9434D − 10 0.9255D − 12 0.1799D − 13
IE(h) −0.64D − 05 −0.99D − 07 −0.15D − 08 −0.22D − 10 −0.33D − 12
Table 2: Problem 1. RKF5(4) & RKF5-Eul. i 1 2 3 4 5
GE(h) 0.1052D − 04 0.1600D − 06 0.2462D − 08 0.3815D − 10 0.5936D − 12
d GE(h) 0.1528D − 04 0.5049D − 06 0.1737D − 07 0.7043D − 09 0.5885D − 10
d eul (h) GE 0.2615D − 05 0.1974D − 07 0.2305D − 09 0.3916D − 11 0.6573D − 13
IE(h) 0.14D − 04 0.26D − 06 0.42D − 08 0.67D − 10 0.11D − 11
In figures 1–12 below, we have restricted ourselves to compare the classical pair Dopri5(4) and the associated projected methods when integrating those problems listed above. It must be taken into account that two methods must be embedded to the highest order method when two invariants are required to be preserved. Thus, for problems 4-5, we have embedded explicit Euler to the original pair DoPri5(4) obtaining a triple of methods, DoPri5(4)+Euler, which preserve both invariants. Note that the projected method with explicit Euler does not require the use of the fourth order method when conserving just one invariant with a 19
Table 3: Problem 2. DoPri5(4) & DoPri5-Eul (conserving the energy). i 1 2 3 4 5
GE(h) 0.1833D0 0.1481D − 02 0.1396D − 04 0.1460D − 06 0.1225D − 08
d GE(h) 0.1282D + 01 0.3485D − 02 0.1924D − 04 0.1335D − 06 0.4499D − 08
d eul (h) GE IE(h) 0.1065D0 −0.20D0 0.9209D − 03 −0.21D − 02 0.1515D − 04 −0.10D − 04 0.1463D − 06 −0.68D − 08 0.1208D − 08 0.62D − 09
Table 4: Problem 2. RKF5(4) & RKF5-Eul (conserving the energy). i 1 2 3 4 5
GE(h) 0.1136D0 0.1267D − 02 0.2951D − 04 0.3457D − 06 0.6687D − 08
d GE(h) 0.4490D + 01 0.6414D − 02 0.3029D − 04 0.4824D − 06 0.1907D − 07
d eul (h) GE IE(h) 0.6438D − 01 −0.13D0 0.1548D − 02 −0.18D − 02 0.2958D − 04 −0.58D − 04 0.2986D − 06 0.24D − 06 0.4954D − 08 0.50D − 08
fixed stepsize strategy. However, we prefer to denote this projected method by DoPri5(4)+Euler, and not by DoPri5+Euler, because the original fourth order method is used to estimate the local error when considering a variable stepsize integration of problem 3 above. To start with, problems 1,2,4 have been integrated by considering each invariant independently with a fixed stepsize strategy by means of the original pair DoPri5(4) and the associated projected method DoPri5(4)+Euler. The end point was taken in each problem as Tend = 16π, 4T2 , 100, respectively. The global and invariant errors (ge and ie, resp.) for these problems and different stepsizes are plotted in figures 1,2,3,7,8. On the other hand, problems 3,4,5 were integrated with a standar variable stepsize strategy also by means of the original pair DoPri5(4) and the projected method DoPri5(4)+Euler (in this case, the fourth order embedded method was consider in order to estimate the local error at each point in the non uniform grid). The end point was taken in each problem as Tend = 3T3 , 100, 10T5 , respectively. Figures 4-5 plot the numerical solution to the problem 3 given by DoPri5(4) and DoPri5(4)+Euler, respectively. The projected method is seen to give a better qualitative behaviour than the original pair when considering three times the minimal period and, what is more, it preserves the corresponding first integral (see figure 6). It must be remarked that some round-off errors came up when solving the non-linear equations defining the projected method in neighbourhoods of the singularities of the underlying 20
−2
10
DoPri5(4) ge DoPri5(4) ie DoPri5(4)+Euler ge DoPri5(4)+Euler ie
−4
10
−6
10
−8
errors
10
−10
10
−12
10
−14
10
−16
10
0
200
400
600
800 nstep
1000
1200
1400
1600
Figure 1: Problem 1 integrated with DoPri5(4) and DoPri5(4)+Euler.
0
10
DoPri5(4) ge DoPri5(4) ie DoPri5(4)+Euler ge DoPri5(4)+Euler ie
−2
10
−4
10
−6
errors
10
−8
10
−10
10
−12
10
−14
10
−16
10
0
200
400
600
800 nstep
1000
1200
1400
1600
Figure 2: Problem 2 integrated with DoPri5(4) and DoPri5(4)+Euler conserving the angular momentum.
21
0
10
DoPri5(4) ge DoPri5(4) ie DoPri5(4)+Euler ge DoPri5(4)+Euler ie
−2
10
−4
10
−6
errors
10
−8
10
−10
10
−12
10
−14
10
−16
10
0
200
400
600
800 nstep
1000
1200
1400
1600
Figure 3: Problem 2 integrated with DoPri5(4) and DoPri5(4)+Euler conserving the total energy.
1.5
1
y
2
0.5
0
−0.5
−1
−1.5 −1.5
−1
−0.5
0
0.5
1
y1
Figure 4: Problem 3 integrated with DoPri5(4).
22
1.5
1
2
0.5
y
0
−0.5
−1
−1.5 −1.5
−1
−0.5
0
0.5
1
y1
Figure 5: Problem 3 integrated with DoPri5(4)+Euler.
−7
10
−8
10
−9
10
−10
10
invariant error
−11
10
−12
10
−13
10
−14
10
−15
10
−16
10
−17
10
0
200
400
600 nstep
800
1000
1200
Figure 6: Problem 3 integrated with DoPri5(4) and DoPri5(4)+Euler. Invariant error.
23
−2
10
DoPri5(4) ge DoPri5(4) ie DoPri5(4)+Euler ge DoPri5(4)+Euler ie
−4
10
−6
10
−8
errors
10
−10
10
−12
10
−14
10
−16
10
0
200
400
600
800 nstep
1000
1200
1400
1600
Figure 7: Problem 4 integrated with DoPri5(4) and DoPri5(4)+Euler conserving the first invariant. Fixed stepsize.
−2
10
DoPri5(4) ge DoPri5(4) ie DoPri5(4)+Euler ge DoPri5(4)+Euler ie
−4
10
−6
10
−8
errors
10
−10
10
−12
10
−14
10
−16
10
0
200
400
600
800 nstep
1000
1200
1400
1600
Figure 8: Problem 4 integrated with DoPri5(4) and DoPri5(4)+Euler conserving the second invariant. Fixed stepsize.
24
0
10
DoPri5(4) DoPri5(4)+Euler −1
10
−2
10
global error
−3
10
−4
10
−5
10
−6
10
−7
10
0
1000
2000
3000
4000
5000
6000
7000
nfcn
Figure 9: Problem 4 integrated with DoPri5(4) and DoPri5(4)+Euler. Global error. Variable stepsize.
0
10
DoPri5(4) inv1 DoPri5(4) inv2 DoPri5(4)+Euler inv1 DoPri5(4)+Euler inv2
−2
10
−4
10
−6
invariant errors
10
−8
10
−10
10
−12
10
−14
10
−16
10
0
1000
2000
3000
4000
5000
6000
7000
nfcn
Figure 10: Problem 4 integrated with DoPri5(4) and DoPri5(4)+Euler. Invariant errors. Variable stepsize.
25
1
10
DoPri5(4) DoPri5(4)+Euler 0
10
−1
global error
10
−2
10
−3
10
−4
10
−5
10
0
1000
2000
3000
4000
5000 nfcn
6000
7000
8000
9000
10000
Figure 11: Problem 5 integrated with DoPri5(4) and DoPri5(4)+Euler. Global error. Variable stepsize.
2
10
DoPri5(4) inv1 DoPri5(4) inv2 DoPri5(4)+Euler inv1 DoPri5(4)+Euler inv2
0
10
−2
10
−4
invariant errors
10
−6
10
−8
10
−10
10
−12
10
−14
10
−16
10
0
1000
2000
3000
4000
5000 nfcn
6000
7000
8000
9000
10000
Figure 12: Problem 5 integrated with DoPri5(4) and DoPri5(4)+Euler. Invariant errors. Variable stepsize.
26
problem, and this is the reason why the projected method do not preserve properly the invariant in neighbourhoods of the singularities (see figure 6). Figures 9-12 correspond the integration of problems 4-5 with the classical pair DoPri5(4) and the projected method DoPri5(4)+Euler, both implemented with a standard variable stepsize strategy. In fact, figures 9,11 plot the global error produced by the classical pair and the projected method in relation with the number of function evaluations, whereas figures 10,12 plot the error in both invariants by considering the same methods. As a conclusion, we have proposed a new and simple strategy in order to preserve first integrals for a given autonomous problem when considering pairs of embedded explicit methods. This strategy is seen to maintain the order of consistency of the original method and also to have a really cheap implementation.
References [1] N. del Buono and C. Mastroserio, Explicit methods based on a class of four stage fourth order Runge–Kutta methods for preserving quadratic laws, J. Comput. Appl. Math., 140 (2002), pp. 231–243. [2] G.J. Cooper, Stability of Runge–Kutta methods for trajectory problems, IMA J. Numer. Anal., 7 (1987), pp. 1–13. [3] J.R. Dormand and P.J. Prince, A family of embedded Runge-Kutta formulae, J. Comp. Appl. Math., 6 (1980), pp. 19-26. [4] E. Fehlberg, Classical fifth-, sixth-, seventh- and eight-order Runge-Kutta formulas with step size control, Computing, 4 (1969), pp. 93-106. [5] E. Hairer, C. Lubich and G. Wanner, Geometric Numerical Integration: Structure Preserving algorithms for Ordinary Differential Equations, Springer Verlag, Berlin, 2002. [6] E. Hairer, S.P. Nørsett and G. Wanner, Solving Ordinary Differential Equations I. Nonstiff Problems, Springer Series in Computational Mathematics 8, Springer Berlin 1993. [7] A. Iserles and A. Zanna, Preserving algebraic invariants with Runge-Kutta methods, J. Comput. Appl. Math., 1–2 (2000), pp. 69–81. [8] D. Lewis, N. Nigam, Geometric integration on spheres and some interesting applications, J. Comput. Appl. Math., 151 (2003), pp. 141–170. [9] J. Schropp, Conserving first integrals under discretization with variable step size integration procedures, J. Comput. Appl. Math., 115 (2000), pp. 503–517.
27
[10] M. Slodi˘ cka, I. Cimr´ak, An iterative approximation scheme for the LandauLifshitz-gilbert equation, J. Comput. Appl. Math., 169 (2004), pp. 17–32. [11] M. Slodi˘ cka, I. Cimr´ak, Numerical study of nonlinear ferromagnetic materials, Appl. Numer. Math., 46 (2003), pp. 95–111. [12] J. Stoer, R. Bulirsch, Introduction to Numerical Analysis, Springer Verlag New York Inc., 1983. [13] A. Wintner, The Analytical Foundations of Celestial Mechanics, Princeton University Press, 1941.
28