Maple - SolvingSolving stochastic differential equations in Maple Stochastic Differential Equations...

3

Click here to load reader

description

Solving stochastic differential equations in Maple

Transcript of Maple - SolvingSolving stochastic differential equations in Maple Stochastic Differential Equations...

Page 1: Maple - SolvingSolving stochastic differential equations in Maple Stochastic Differential Equations in Maple

Solving Stochastic Differential Equations withMapleSasha Cyganowski

IntroductionThe effects of intrinsic noise within physical phenomena isignored when mathematical models of their behavior are con-structed using deterministic differential equations. Such equa-tions describe what is occurring on average to the system.However, more information is often required to obtain a fullpicture of the behavior of the model, especially when non-linearities are involved. In these circumstances a stochasticmodel is used. Stochastic Differential Equations (SDEs) in-clude a random term which describes the intrinsic noise, orrandomness, within dynamical systems. SDEs have foundmany applications in areas such as Chemistry, Physics, andMathematical Biology. A general, one-dimensional SDE takesthe form ��������� ������������������ �����������������

(1)

where�� ���������

is the drift coefficient and�������� �!�

is the dif-fusion coefficient.

�"�is a Wiener process which represents

intrinsic noise in the dynamical system, and is often referredto as white noise. The subscript

�denotes time-dependence.

The drift coefficient models the dominant action of the sys-tem whilst the diffusion coefficient represents randomnessalong the dominant curve.

The Wiener process is the simplest random or stochasticprocess which provides an adequate model for Brownian mo-tion. Details of the Wiener process can be found in Kloedenand Platen [3]. This random “function” is of significance asit is the starting point of stochastic calculus. Now, the Wienerprocess is not of bounded variation, thus if we write equation(1) as an integral equation of the form

�����#$�%� ���'&��#$�(��) ��'& ��* +,��� -,�#$�/.��0+� ) �� & ��* +,��� - #$�!.���� - �#1�2� (2)

the second integral is not defined by the rules of classical cal-culus. This problem was overcome in the early 1950s whenIto formulated his definition of the Ito integral, for which thesecond integral is defined. Ito stochastic calculus exhibitsmany peculiarities and does not conform to the rules of clas-sical calculus, so care must be taken when constructing meth-ods to solve SDEs. Efficient methods are now available andcan be found in Kloeden and Platen [3].3

School of Computing and Mathematics, Deakin University, Geelong,Vic 3217, Australia. [email protected]

The author has developed a Maple package, called “stochas-tic”, containing routines which return explicit solutions tothose SDEs known to have such solutions. This paper willconcentrate on these particular routines. The package alsocontains routines which construct efficient, high order stochas-tic numerical schemes. Readers wishing to approximate so-lutions to SDEs via numerical methods will benefit from read-ing Cyganowski [1].

Explicit Solutions to SDEs through MapleIn the subsections below, specific forms of SDEs that areknown to have explicit solutions will be introduced and pro-cedures from the “stochastic” package will be provided whichautomate the solving of such SDEs. General solutions aresimply given, as found from Kloeden and Platen [3]. Firstly,linear SDEs will be considered followed by non-linear SDEsthat are reducible to linear form.

LINEAR SDES

Linear SDEs are explicitly solvable, exhibiting the generalform�,���4�5/�� ���!������6� ���������7�8/������!�����9��������������!�

(3)

with general solution

���:� ;<�!= �'&�'���'&�� ) �� & ;$>@?-2= �'& !6�!+A�CBD��!+A����!+�������+�") �� & ; >@?-2= � & ��!+������ - �E� (4)

where

;<��= � &<�GFIHKJL!) ��'& !��/+��4BNMO �EP�/+����Q�0+R��)�� & ��/+������S-E� (5)

is the fundamental solution. A suitable Maple procedure forsolving such SDEs is given below.

1

Page 2: Maple - SolvingSolving stochastic differential equations in Maple Stochastic Differential Equations in Maple

Stochastic DEs with Maple

� linear:=proc(a:algebraic,b:algebraic)� local temp1,alpha,beta,gamma,delta,fundsoln,� fundsoln2,soln,default1,default2,default3;� if diff(a,x,x) <> 0� or diff(b,x,x) <> 0 then� ERROR(`SDE not linear, try a reducible� procedure`)� else� alpha := diff(a,x);� alpha := subs(t = s,alpha);� beta := diff(b,x);� beta := subs(t = s,beta);� if diff(beta,s) = 0 then� temp1 := beta*W;� else temp1 := Int(beta,W = 0 .. t);� fi;� gamma := coeff(a,x,0);� gamma := subs(t = s,gamma);� delta := coeff(b,x,0);� delta := subs(t = s,delta);� fundsoln := exp(int(alpha-1/2*(beta**2),� s = 0 .. t)+temp1);� fundsoln2 := subs(t = s,fundsoln);� if beta = 0 then� soln := fundsoln*(X[0]+� int(1/fundsoln2*� (gamma-beta*delta),s = 0 .. t)� +Int(1/fundsoln2*delta,W = 0 .. t))� else soln := fundsoln*(X[0]+� Int(1/fundsoln2*� (gamma-beta*delta),s = 0 .. t)� +Int(1/fundsoln2*delta,W = 0 .. t))� fi;� default1 := Int(0,W = 0 .. t) = 0;� default2 := Int(0,W = 0 .. s) = 0;� default3 := Int(0,s = 0 .. t) = 0;� soln := X[t] = subs(default1,default2,� default3,soln)� fi� end:

To invoke such a procedure we use the following command.

linear(a(t,x),b(t,x));

Figure 1 Syntax for procedure “linear”.

In Figure 1,�������H@�

and�������H��

denote the drift and diffusioncoefficients of the SDE, respectively. Note that both argu-ments must be given in the variables

Hand

�. This syntax

will be required for all the procedures in this paper.

REDUCIBLE SDES

SDEs are in this category if they have the general form

�����L�5��L��'������� � MO ��'��������� '�����������7����'������������� (6)

with general solution

������� >@? �� ��� � �C ���I�C�������� � ) �� ���� > � - ���S-E�2�(7)

where � � )�� ��+��/+���� (8)

A suitable Maple procedure for solving such SDEs is givenbelow.

� reducible:=proc(a:algebraic,b:algebraic)� local beta,temp1,h,alpha,soln,soln1;� h := int(1/b,x);� temp1 := alpha*b*h+1/2*b*� simplify(diff(b,x));� temp1 = a;� alpha := simplify(solve(",alpha));� beta := alpha*h;� if diff(alpha,x) = 0 then� if alpha=0 then� soln:=h=subs(x=X[0],h)+W;� X[t]=simplify(solve(soln,x));� else� soln1 := h = exp(alpha*t)*� subs(x = X[0],h)� +exp(alpha*t)*Int(exp(-alpha*s),� W = 0 .. t);� X[t] = solve(soln1,x);� fi� elif diff(beta,x) = 0 then� X[t] = simplify(solve(h=beta*t+W+� subs(x=X[0],h),x));� else ERROR(`non-linear SDE not reducible`)� fi� end:

GENERAL MAPLE PROCEDURE FOR FINDING

EXPLICIT SOLUTIONS.The Maple procedure “explicit” is given below, which is acombination of procedures “linear” and “reducible”. Thisprocedure determines whether an SDE is reducible or linear,and solves it accordingly. If the SDE does not fall into oneof the above categories, the user is returned with an errormessage.� explicit:=proc(a:algebraic,b:algebraic)� if diff(a,x,x) = 0 and diff(b,x,x) = 0 then� linear(a,b)� else� reducible(a,b)� fi� end:

The procedure “explicit” is more user-friendly than “lin-ear” or “reducible” as it is not necessary for the user to pre-determine which category the SDE belongs to.

Applications(I) Consider the SDE�����L�G����� O � ���!�0� � � (9)

Here we see how the procedure “explicit” can be used to findthe explicit solution of equation (9).

2

Page 3: Maple - SolvingSolving stochastic differential equations in Maple Stochastic Differential Equations in Maple

Stochastic DEs with Maple

� explicit(1,2*sqrt(x));����� O � ����� �9�GP � ���(II) Consider the SDE�����L�����<���!���C� ������� � � (10)

In this example the SDE is reported to have no knownexplicit solution.

� explicit(ln(x),x);

Error, (in reducible) non-linear SDE not reducible

ConclusionStochastic calculus has been introduced in this paper throughthe computer algebra system Maple. Procedures were pre-sented and used to find solutions to SDEs. It should be notedthat the methods provided here for solving SDEs are suit-able for real-valued, one-dimensional SDEs with real-valued,one-dimensional Wiener processes.

Symbolic computation in stochastic analysis has been in-vestigated by Kendall [2] and Valkeila [6], while Maple codesuitable for use in stochastic numerics has been developedby Cyganowski [1] and Kloeden and Scott [5]. PreviouslyMaple had not been used in stochastic calculus for findingexplicit solutions to SDEs.

The procedures in this paper are part of the Maple pack-age “stochastic” which has been developed by the authorand recently accepted into Maple's share library. It will be-come publicly available when the next electronic update ofthe share library occurs. Those who are interested in acquir-ing the package now are welcome to contact the author fora free copy, complete with help files and installation instruc-tions. Alternatively, the package can be obtained via the In-ternet at http://www.cm.deakin.edu.au/� sash/maple.html.

Other functions contained in the “stochastic” package in-clude procedures which construct strong stochastic numeri-cal schemes up to order 2, weak stochastic numerical schemesup to order 3, as well as procedures which check for com-mutative noise of the first and second kind, and a procedurewhich converts SDEs with white noise into colored noiseform. Additional procedures are included within the packageso that users can easily construct numerical schemes otherthan those already available.

Future extensions to this package will include a set ofprocedures which plot approximate solutions to SDEs. Theinput required for these “graphical” procedures will be eas-ily obtainable as it will be the output from the “algebraic”procedures discussed in this paper.

References[1] Cyganowski, S.O., A MAPLE Package for Stochas-

tic Differential Equations, Computational Techniquesand Applications: CTAC95, editors A. Easton, R. May,World Scientific, (to appear).

[2] Kendall, W.S., Computer algebra and stochastic calcu-lus, Notices Amer. Math. Soc., 37, 1990, 1254–1256.

[3] Kloeden, P.E. and Platen, E., Numerical Solutionof Stochastic Differential Equations, Springer-Verlag,1992.

[4] Kloeden, P.E., Platen, E. and Schurz, H., Numerical So-lution of Stochastic Differential Equations through Com-puter Experiments, Springer-Verlag, 1993.

[5] Kloeden, P.E. and Scott, W.D., Construction of Stochas-tic Numerical Schemes through Maple, Maple TechnicalNewsletter, 10, 1993, 60–65.

[6] Valkeila, E., Computer algebra and stochastic analysis,some possibilities, CWI Quarterly, 4, 1991, 229–238.

3