Numerical Mehods for Sochasic Differenial Equaions Joshua Wilkie Deparmen of Chemisry, Simon Fraser Universiy, Burnaby, Briish Columbia V5A 1S6, Canada Sochasic differenial equaions (sdes) play an imporan role in physics bu exising numerical mehods for solving such equaions are of low accuracy and poor sabiliy. A general sraegy for developing accurae and efficien schemes for solving sochasic equaions in oulined here. High order numerical mehods are developed for inegraion of sochasic differenial equaions wih srong soluions. We demonsrae he accuracy of he resuling inegraion schemes by compuing he errors in approximae soluions for sdes which have known exac soluions. PACS numbers: 3.65.-w, 2.5.-r, 2.7.-c arxiv:quan-ph/4739v1 5 Jul 24 Sochasic differenial equaions (sdes) have a long hisory in physics[1] and play an imporan role in many oher areas of science, engineering and finance[1, 2, 3]. Recenly a number of compuaional echniques have been developed in which high dimensional deerminisic equaions are decomposed ino lower dimensional sochasic equaions. Gisin and Percival[4], for example, reduced a deerminisic maser equaion for he densiy marix ino sochasic equaions for a wavefuncion. Similar approaches are being used o solve he quanum many-body problem for bosons[5], fermions[6] and vibraions[7]. These laer mehods give rise o large ses of coupled sdes which require fas and efficien numerical inegraion schemes. Unforunaely, and in spie of heir widespread use, he available numerical echniques[3] for solving such equaions are far less accurae han comparable mehods for soluion of ordinary differenial equaions (odes). In his manuscrip we show how classical mehods for solving odes, such as Runge-Kua, can be adaped for he soluion of a class of sdes which should include many of he equaions which arise in physical problems. Consider a finie se of sdes, dx j = aj (X, ) d + b j k (X, ) dw k, (1) represened in Iô[1, 2, 3] form, where j = 1,...,n. Here X = (X 1,..., Xn ) and he dw k are independen and normally disribued sochasic differenials wih zero mean and variance d (i.e. sampled N(, d)). The sochasic variables W k are Wiener processes. Now assume ha he coefficiens a j and b j k have regulariy properies which guaranee srong soluions, i.e. ha X j are some fixed funcions of he Wiener processes, and ha hey are differeniable o high order. [Sufficien condiions for srong soluions are discussed in Ref. [3].] We may hen view he soluions of (1) as funcions X j = X j (, W 1,...,W m ) of ime and he Wiener processes. The soluions can herefore be expanded in Taylor series. Keeping erms of order d or less hen gives X j +d = X j + Xj d + X j W k dw k k,l=1 2 X j W k W l dw k dw l. (2) In a mean square sense he produc of differenials dw kdw l is equivalen o δ k,ld in he Iô[1, 2, 3] formulaion of sochasic calculus. Making his replacemen hen yields dx j +d = X j +d Xj = [ Xj X j + W k 2 X j ] d W k2 dw k (3) which when compared o (1) allows us o idenify he firs derivaives X j W k X j = b j k (X, ) (4) = a j (X, ) 1 2 = a j (X, ) 1 2 2 X j W k2 n b i k(x, ) bj k (X, ) X i.(5) i=1 Now ha hese firs order derivaives are expressed in erms of a j and b j k, higher order derivaives can be compued. Thus a Taylor expansion of he soluions X j + = X j + Xj + m k,l=1 X j W k W k 2 X j W k W l W k W l +... (6) can be obained for finie displacemens and W k. This Taylor expansion can hen be employed o develop Runge-Kua algorihms and oher inegraion schemes. We illusrae he use of his approach by developing a Runge-Kua mehod for sdes which is closely relaed o he classical Runge-Kua scheme for odes. For given displacemens and W k define f j (X, ) = Xj + m X j W k W k
2 = [a j (X, ) 1 2 + n i=1 b i k (X, ) bj k (X, ) X i ] b j k (X, ) W k (7) and consider he following four sage approximaion K 1 j = f j (X i, i ) Figure 1: log 1 X X approximae vs ime for Eq. (9) K 2 j K 3 j = f j (X i K1, i ) = f j (X i K2, i ) K 4 j = f j (X i + K 3, i+1 ) X i+1 = X i + 1 6 (K1 + 2K 2 + 2K 3 + K 4 ) (8) where i is he iniial ime and i+1 = i +. Taylor expansion of his scheme shows ha X i+1 differs from he exac soluion by erms of order higher han 2 (i.e. erms of higher order han 2, ( W k)2, ( W k)4, ( W k ) 2 ( W) l 2, and ( W k ) 2 W W l i ). Thus, his sochasic Runge-Kua algorihm plays a role very similar o is classical counerpar excep ha is order is reduced from four o wo. Generalizaions o higher order Runge-Kua schemes are sraighforward, and we will employ one such scheme in example calculaions, bu deails will no be presened here. While his approach is no compleely general, since i will fail for sdes wih weak soluions or non-differeniable a j and b j k, i should be applicable o a wide range of problems. I can for example be used o solve every one of he equaions wih known soluions abulaed in secion 4.4 of Ref. [3]. To illusrae he accuracy of he mehod and is improvemen over oher known echniques for solving sdes we now consider a number of hese examples. We compare known exac soluions wih numerical soluions obained using he Euler-Maruyama scheme[8], a derivaive free version of he Milsein scheme due o Kloeden and Plaen[9], he classical Runge-Kua scheme (8), and anoher Runge-Kua scheme obained in he manner oulined above from an eighh order welve sep mehod for odes due o Hairer and Wanner[1] (his reproduces he sochasic Taylor expansion up o and including erms of order 4 ). Sochasic differenials were sampled using he rouines gasdev and ran2[11]. As a firs es of hese mehods consider an auonomous nonlinear scalar equaion dx = (1 + X )(1 + X 2 )d + (1 + X2 )dw (9) wih jus one Wiener process. In his example and in all subsequen examples we assume all Wiener processes are iniially zero. The exac soluion o his equaion is[3] X = an( + W + arcan(x )) (1) as can be readily verified using Iô[1, 2, 3] calculus. In Fig. 1 we plo he error log 1 X X approximae vs.1.2.3.4.5.6.7.8.9 1 Figure 2: log 1 X X approximae vs ime for Eq. (11) 2 2 4 6 8 1 12 14 16 18 2 ime compued wih a ime sep of 2.5 1 5 for a single sochasic rajecory wih iniial condiion X = 1 for he four differen approximaion schemes. The Milsein scheme (long-dashed curve) shows some improvemen over he primiive Euler-Maruyama mehod (solid curve) bu he order wo Runge-Kua scheme (shordashed curve) and order four Runge-Kua scheme (doed curve) perform very much beer. The second example equaion, also from Ref. [3], is an auonomous linear scalar equaion in wo Wiener processes dx = a X d + b 1 X dw 1 + b 2 X dw 2 (11) which has an exac soluion X = X exp{[a 1 2 (b2 1 + b2 2 )] + b 1W 1 + b 2W 2 }. (12) The logarihm base en of he error for he differen schemes, calculaed for iniial condiion X = 1 and ime
3 Figure 3: log 1 X 1 X 1 approximae vs ime for Eq. (13) Figure 4: log 1 X X approximae vs ime for Eq. (15) -5-7 -9-11 -13 1 2 3 4 5 6 7 8 9 1 2 4 6 8 1 12 14 16 18 2 sep.1, is ploed in Fig. 2. Here he Milsein scheme (long-dashed curve) performs no beer han he Euler- Maruyama mehod (solid curve) bu again he order wo Runge-Kua scheme (shor-dashed curve) and order four Runge-Kua scheme (doed curve) show grealy improved accuracy. [Noe ha he apparen improvemen in performance of all schemes a long ime is a resul of he fac ha he soluion decays o zero.] Example 3 is a se of wo coupled linear auonomous sdes Figure 5: log 1 X X approximae vs ime for Eq. (17) dx 1 = 3 2 X1 d + X1 dw 1 X1 dw 2 X2 dw 3 dx 2 = 3 2 X2 d + X2 dw 1 X2 dw 2 + X1 dw 3 (13) wih hree Wiener processes. Here he soluions are X 1 = exp{ 2 + W 1 W 2 } cosw 3 X 2 = exp{ 2 + W 1 W 2 } sinw3. (14) Numerical soluions were calculaed wih a ime sep of.1 and errors in X 1 are represened in Fig. 3. The order wo Runge-Kua scheme (long-dashed curve) and order four Runge-Kua scheme (shor-dashed curve) show improvemen over he Milsein scheme (solid curve). Similar resuls were obained for X 2. The examples we have considered so far have no had explicily ime dependen a j and b j k. Example 4 is a scalar non-auonomous sde 2 dx = [ 1 + X (1 + )2 ]d (1 + )2 dw (15) wih known soluion[3] ( ) 2 1 + X = X + 1 1 + 2 (1 + )2 (W + ). (16) Numerical soluions were calculaed using he order wo Runge-Kua scheme and a ime sep of.1, = -16-18.5 1 1.5 2 2.5 3 3.5 4 4.5 5 and X = 1. The error is represened in Fig. 4. As in previous examples a high accuracy is achieved in spie of he rapid growh of he soluion. The comparaive smoohness of he error curve reflecs he fac he he deerminisic par of he soluion dominaes. We now consider an example for which an exac soluion is known bu which is expressed in erms a sochasic inegral. Consider he sochasic Ginzburg-Landau equaion dx = [ X 3 + (α σ2 )X ]d + σx dw (17) wih soluion[3] exp{α + σw } X = X. (18) 1 + 2X 2 exp{2αs + 2σW s}ds We chose α =.1, σ = 4, X = 1 and d = 5 1 6. The sochasic inegral was compued using a Riemann sum
4 Figure 6: log 1 X X approximae vs ime for Eq. (19).5-7 -7.5 wih exac soluion[3] ) X = arcsinh (e a sinhx + e a e as dw s. (2).5-9 -9.5.5-11 -11.5 1 2 3 4 5 6 7 8 9 1 Figure 7: log 1 n n approximae vs ime for Eq. (21) -1.5.5-3 We se a =.2, b = 1, X = 1 and d = 1 1 5. The sochasic inegral in he exac soluion was calculaed using he Iô[1, 2, 3] inegral formula wih he same ime sep. The error in he soluion calculaed wih he order wo Runge-Kua scheme is ploed in Fig. 6. As in all previous cases considered he accuracy is very good. Thus, he approach o solving sdes advocaed here works very well for he wide range of examples we have considered. The order 4 Runge-Kua mehod is clearly much more accurae han he order 2 Runge- Kua scheme. I also has an embedded lower order Runge-Kua scheme which can be employed o obain an error esimae suiable for sepsize conrol[1]. Hence is should be possible o use variable sepsizes o ensure he accuracy of he soluion. This sor of implemenaion is essenial for solving equaions which do no have known exac soluions. The only subley in developing such a mehod is ensuring ha he correc Wiener pah is mainained even when a sep mus be rejeced. This is achieved[12] by dividing he rejeced differenials d and dw k in wo segmens; d/2 and dw k /2 y followed by d/2 and dw k /2 + y where y is sampled N(, d/2). To illusrae he accuracy of he resuling variable sepsize algorihm we solve he Gisin-Percival[4] sochasic wave equaion for he nonlinear absorber (Eq. 4.2 of Ref. [4]) -3.5 5 1 15 2 d ψ =.1(a a) ψ d + (2a 2 a 2 a 2 a 2 a 2 a 2 ) ψ d + 2(a 2 a 2 ) ψ dw (21) wih he same ime sep. Error in he soluion calculaed wih he order wo Runge-Kua scheme is ploed in Fig. 5. Good accuracy is again obained. Finally, we consider an example in which he exac soluion is expressed in erms of a Iô[1, 2, 3] sochasic inegral. Consider he sde dx = anhx (a b2 sech 2 X )d+bsechx dw (19) wih iniial sae ψ() >=. In Fig. 7 we plo he error in mean occupaion number n = M[ ψ a a ψ ] vs ime (Fig. 5 of Ref. [4]) where M[ ] denoes an average over sochasic realisaions. 1, 1, and 2 rajecories were used o calculae he solid curve, dashed curve and doed curve, respecively. Convergence o he exac resul is good. The auhor acknowledges he suppor of he Naural Sciences and Engineering Research Council of Canada. [1] C.W. Gardiner, Handbook of sochasic mehods, (Springer, Berlin, 1983). [2] H. Hasegawa, H. Ezawa, Suppl. Prog. Theor. Phys. 69, 11 (198). [3] P.E. Kloeden and E. Plaen, Numerical soluion of sochasic differenial equaions, (Springer, Berlin, 1995). [4] N. Gisin and I.C. Percival, J. Phys. A 25, 5677 (1992). [5] I. Carusoo and Y. Casin, Laser Physics 13, 59 (23); I. Carusoo, Y. Casin, and J. Dalibard, Phys. Rev. A 63, 2366 (21). [6] O. Juille, Ph. Chomaz, Phys. Rev. Le. 88, 14253 (22). [7] J. Wilkie, Phys. Rev. E 67, 1712 (23). [8] See for example secion 1 of chaper 9 in Ref. [3]. [9] See Eq. (1.7) of chaper 11 in Ref. [3]. [1] E. Hairer and G. Wanner, DOP853.f available a
5 hp://elib.zib.de/pub/elib/hairer-wanner/nonsiff/. [11] W.H. Press, S.A. Teukolsky, W.T. Veerling and B.P. Flannery, Numerical recipes, (Cambridge Universiy Press, Cambridge, 1992). [12] J.G. Gaines and T.J. Lyons, SIAM J. Appl. Mah. 57, 1455 (1997).