ASTR45: Problem Se #5 Curran D. Muhlberger Universi of Marland (Daed: April 25, 27) Three ssems of coupled differenial equaions were sudied using inegraors based on Euler s mehod, a fourh-order Runge-Kua mehod, and he mehod. For even a basic ssem of wo smooh equaions, Euler s mehod performed ver poorl and was slow o converge, as he error scaled as O(h). The Runge-Kua mehod performed well for all hree ssems, converging quickl even for moderae ime seps and ehibiing an error ha scaled as O(h 4 ). The mehod, where applicable, also converged quickl o a soluion, alhough he error onl scaled as O(h 2 ). The leapfrog mehod proved o be he mos sable, conserving he energ of an orbi hroughou a long inegraion. Finall, a bisecion echnique was used when suding a Loka-Volerra Predaor-Pre model o deermine ha he minimum huning rae o achieve eincion was q =.24. I. A ONE-DIMENSIONAL SECOND-ORDER ODE Consider he second-order ordinar differenial equaion d 2 = () d2 wih he iniial condiions () =, ẋ =. The soluion is given b () = sin(). Noe ha his is a conservaive equaion, since he second derivaive of is independen of and ẋ. Therefore, he mehod is a valid inegraion scheme. This second-order equaion can be wrien as a ssem of he coupled firs-order equaions d d = d d = (2) wih iniial condiions () =, () =. Here, he eac soluion for is given b () = cos(). This ssem is in a form ha can be inegraed using Euler s mehod or a Runge-Kua mehod. Euler s mehod, he fourh-order Runge-Kua mehod (as described in []), and he mehod can all be used wih a consan sep size h. When solving his equaion numericall, h was chosen o be,.3,.,.3, and., and he equaion was inegraed from = o = 5, represening abou 2.5 periods of he sine wave. The resuls from Euler s mehod are shown in figure, he resuls from he fourh-order Runge-Kua mehod are shown in figure 2, and he resuls from he mehod are shown in figure 3. In all cases, he eac soluion () = sin() is ploed as a dashed curve. Euler s mehod converges o he soluion ver slowl and canno mainain a consan ampliude even wih small values of h. The Runge-Kua mehod does a much beer job a approimaing he soluion, being visuall indisinguishable from he eac soluion as earl as h =.. Furhermore, he ampliude of is soluions does no appear o grow over ime on his ime scale. Finall, he soluions also converge ver quickl, being visuall idenical o he eac soluion b h =. and mainaining a consan ampliude. However, for he ver large ime sep h =, he soluion drifs ou of phase wih he eac soluion fairl quickl. This behavior was no observed for he Runge-Kua soluion using he same ime sep. For each of hese mehods, we epec he error a an ime in he soluion o decrease as some power of he sep size h. To confirm his behavior, (5) sin(5) is ploed agains h on a logarihmic scale in figure 4. For all hree mehods, he slope is consan for h.. In paricular, he slope for Euler s mehod is.2, he slope for he fourh-order Runge-Kua mehod is 3.92, and he slope for he mehod is 2.. From his, we can conclude ha he error in he inegraion is h for Euler s mehod, h 4 for he Runge-Kua mehod, and h 2 for he mehod. These are he epeced dependencies for he error for each of he mehods. Euler s mehod is a firs-order mehod, meaning ha he error in each sep is O(h 2 ). Since he error a f is he accumulaion of he error from ( f )/h seps, his final error is O(h), as was observed above. Similarl, he Runge-Kua mehod used is fourh-order, wih an error in each erm of O(h 5 ). Summed over all seps, he oal error should be O(h 4 ). Finall, he error in each erm of he mehod is O(h 3 ) for a oal accumulaed error of O(h 2 ).
2 Euler Mehod (h =.) Euler Mehod (h =.3) 4 2 8 6-2 4-4 -6 2-8 - -2-2 -4-4 2 4 6 8 2 4 6-6 2 4 6 8 2 4 6 Euler Mehod (h =.) Euler Mehod (h =.3) 2.5.5 2.5.5.5 -.5 -.5 - -.5 - -2 2 4 6 8 2 4 6 -.5 2 4 6 8 2 4 6.5 Euler Mehod (h =.).5 -.5 - -.5 2 4 6 8 2 4 6 FIG. : Soluions of obeing equaion 2 using Euler s mehod for various ime seps h. The eac soluion is represened b he dashed curve.
3 Runge-Kua Mehod (h =.) Runge-Kua Mehod (h =.3).5.5.5.5 -.5 -.5 - - -.5 2 4 6 8 2 4 6 -.5 2 4 6 8 2 4 6 Runge-Kua Mehod (h =.) Runge-Kua Mehod (h =.3).5.5.5.5 -.5 -.5 - - -.5 2 4 6 8 2 4 6 -.5 2 4 6 8 2 4 6.5 Runge-Kua Mehod (h =.).5 -.5 - -.5 2 4 6 8 2 4 6 FIG. 2: Soluions of obeing equaion 2 using he fourh-order Runge-Kua mehod for various ime seps h. The eac soluion is represened b he dashed curve.
4 Mehod (h =.) Mehod (h =.3).5.5.5.5 -.5 -.5 - - -.5 2 4 6 8 2 4 6 -.5 2 4 6 8 2 4 6 Mehod (h =.) Mehod (h =.3).5.5.5.5 -.5 -.5 - - -.5 2 4 6 8 2 4 6 -.5 2 4 6 8 2 4 6.5 Mehod (h =.).5 -.5 - -.5 2 4 6 8 2 4 6 FIG. 3: Soluions of equaion using he mehod for various ime seps h. The eac soluion is represened b he dashed curve.
5 Error in Soluion a = 5 Euler Runge-Kua. Error e-4 e-6 e-8 e-.. h FIG. 4: The error of all hree mehods a = 5 for each ime sep h. II. A TWO-DIMENSIONAL ORBIT Consider he wo-dimensional orbi of a mass in he graviaional poenial given b Φ = ( + 2 2 + 2 2 ) /2 (3) The resuling acceleraion is given b ẍ = Φ. Wriing he componens eplicil, d 2 d 2 d 2 d 2 = dφ d = 2( + 22 + 2 2 ) 3/2 = dφ d = 2( + 22 + 2 2 ) 3/2 (4) This ssem of wo coupled second-order conservaive differenial equaions can be recas ino a ssem of he four coupled firs-order equaions d d = a da d = 2( + 2 2 + 2 2 ) 3/2 d d = b db d = 2( + 2 2 + 2 2 ) 3/2 (5) This equaion was solved using boh he fourh-order Runge-Kua mehod and he Leepfrog mehod. The iniial condiions were aken o be () =, ẋ() =, () =, and ẏ() =., and he soluions were inegraed ou o =. Sep sizes of,.5,.25, and. were used. The soluions using he Runge-Kua mehod are shown in figure 5, and he soluions from he mehod are ploed in figure 6. Neiher mehod achieves good convergence unil h =.25.
6 Runge-Kua Mehod (h =.) Runge-Kua Mehod (h =.5).6.8.4.6.2.4.2 -.2 -.2 -.4 -.4 -.6 -.8 -.6 - -.8 -.6 -.4 -.2.2.4.6.8 - - -.8 -.6 -.4 -.2.2.4.6.8 Runge-Kua Mehod (h =.25) Runge-Kua Mehod (h =.).8.8.6.6.4.4.2.2 -.2 -.2 -.4 -.4 -.6 -.6 -.8 -.8 - - -.8 -.6 -.4 -.2.2.4.6.8 - - -.8 -.6 -.4 -.2.2.4.6.8 FIG. 5: Orbis from he Runge-Kua soluion of equaion 5 for various ime seps h. The energ per uni mass of he paricle is given b ε = ẋ2 + ẏ 2 2 + Φ(, ) (6) The velociies needed o calculae he energ are compued as a and b in he Runge-Kua soluion of equaion 5, bu mus be eraced from he mehod b resncing he offse velociies using half Euler seps. The energ of he orbi is ploed agains for boh solvers in figure 7. The energ for h = is meaningless for boh solvers, as neiher produced sable orbis for his ime sep. However, for all smaller values of h, he energ of he soluion is sead over long periods of ime while he energ of he Runge-Kua soluion seadil decreases wih ime. Thus, while he local variaions in he energ of he soluion ma be much larger han hose of he Runge-Kua soluion, he energ is more sable over long periods of ime, indicaing ha he mehod has auomaicall enforced energ conservaion for his ssem.
7 Mehod (h =.) Mehod (h =.5) 5-5.5 - -5-2 -.5-25 -3-4 -35-3 -25-2 -5 - -5 5 - - -.5.5 Mehod (h =.25) Mehod (h =.).5.5 -.5 -.5 - - -.5.5 - - -.5.5 FIG. 6: Orbis from he soluion of equaion 4 for various ime seps h. III. THE LOTKA-VOLTERRA PREDATOR-PREY MODEL The populaions of wo species in a predaor-pre relaionship, such as rabbis and foes, can be described b he firs-order Loka-Volerra equaions ẋ = (A d) B ẏ = ( C e) + D (7) where and are he populaion densiies of he pre and predaor respecivel. A is he pre s reproducion rae, B is he pre s consumpion rae b he predaor, C is he predaor s deah rae, D is he predaor s populaion growh rae due o consumpion of he pre, and d and e are he huning raes of he pre and predaor respecivel. Here we consider an ecossem conaining rabbis and foes wih parameers A =, B =., C =.5, D =.3, and d = e =. The iniial condiions are aken o be () = 3 and () = 3. The fourh-order Runge-Kua inegraor was used o inegrae he soluion ou o = for ime seps,.5,.25, and.. Phase diagrams for each ime sep are shown in figure 8. Supposing ha boh species are huned a an equal rae q (so d = e = q), here should be some value of q such ha boh populaions become einc b = (where eincion is defined b, < 9 ). To find his value of q, a
8 Energ Conservaion (h =.) Energ Conservaion (h =.5).4.2 Runge-Kua -.56 -.565 -.57 Runge-Kua -.575 -.2 -.58 Energ -.4 Energ -.585 -.59 -.6 -.595 -.6 -.8 -.65-2 4 6 8 -.6 2 4 6 8 Energ Conservaion (h =.25) Energ Conservaion (h =.) -.57 -.572 Runge-Kua -.572 -.5722 -.5724 Runge-Kua -.574 -.5726 Energ -.576 Energ -.5728 -.573 -.578 -.5732 -.5734 -.58 -.5736 -.582 2 4 6 8 -.5738 2 3 4 5 6 7 8 9 FIG. 7: Energ Conservaion. bisecion-sle mehod was used. The value was firs brackeed b observing ha for q =, (), () > 9, and for q = 5, (), () < 9. The ssem was hen solved choosing q a he midpoin of his inerval. If boh species were found o be einc a =, he upper bound was se equal o he midpoin. Oherwise he lower bound was se equal o he midpoin. This procedure was repeaed unil he size of he inerval fell below 4, obaining 4 digis of accurac. Using a ime sep of h =., i was found ha q =.2398 is he minimum huning rae necessar o drive boh species o eincion b =. [] Press, William H., Saul A. Teukolsk, William T. Veerling, Brian P. Flanner. Numerical Recipes in FORTRAN 77: The Ar of Scienific Compuing (Volume of Forran Numerical Recipes). Second Ediion. Cambridge Universi Press, 2.
9 Runge-Kua Mehod (h =.) Runge-Kua Mehod (h =.5) 22 3 2 8 25 Predaor Densi (Foes) 6 4 2 8 Predaor Densi (Foes) 2 5 6 5 4 2 2 3 4 5 6 7 8 9 2 2 3 4 5 6 7 8 9 2 Pre Densi (Rabbis) Pre Densi (Rabbis) Runge-Kua Mehod (h =.25) Runge-Kua Mehod (h =.) 3 3 25 25 Predaor Densi (Foes) 2 5 Predaor Densi (Foes) 2 5 5 5 2 3 4 5 6 7 8 9 2 2 3 4 5 6 7 8 9 2 Pre Densi (Rabbis) Pre Densi (Rabbis) FIG. 8: Phase diagrams for he Loka-Volerra Predaor-Pre model (equaion 7) inegraed using he Runge-Kua mehod wih various ime seps.