Application Center - Maplesoft

App Preview:

Explicit solutions of stochastic differential equations (SDEs)

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Examples of the Maple "stochastic" package

by Sasha Cyganowski, sash@deakin.edu.au

This file contains instructions and examples which demonstrate the package "stochastic", developed by . The package contains commands which can be used to find explicit solutions of Stochastic Differential Equations (SDEs), construct numerical schemes up to strong order 2 and weak order 3.0, check for commutative noise of the first and second kind, and convert SDEs into their coloured noise form.

I would appreciate feedback about this package. Comments can be sent via e-mail to sash@deakin.edu.au.

The user of this file is required to go through and hit <enter> at the end of each Maple command (Maple commands are entered next to the > prompt). In this way the appropriate Maple output is returned interactively.

> restart:
read `stochastic.txt`; # Change to reflect path of your stochastic package
currentdir();

[Maple Math]

The " read" command reads in the necessary file from diskette. The "with" command loads the package "stochastic" into the worksheet.

> with(stochastic);

[Maple Math]

The role of the commands listed above are described below. "explicit" is used to find explicit solutions, "Euler", "Milstein", etc. are used to construct numerical schemes for SDEs, "comm1" and "comm2" check for commutative noise of the first and second kind respectively, and "colour" converts SDEs into coloured noise form.

The format of this demonstration will be to display the Stochastic Differential Equation (SDE) followed by a Maple command. Note that the drift coefficient of the SDE is the first agument entered, and diffusion coefficient is the second argument. Both arguments must be given in the variables x and t. The user is required to hit <enter> at the end of the line containing the Maple command.

EXAMPLE 1

[Maple Math]

> explicit(-x,2);

[Maple Math]

>

EXAMPLE 2

[Maple Math]

> explicit(2*x+3,4*x+5);

[Maple Math]

>

EXAMPLE 3

[Maple Math]

> explicit(1/2*a*(a-1)*x^(1-2/a),a*x^(1-1/a));

[Maple Math]

>

EXAMPLE 4

Numerical Scheme Construction

[Maple Math]

> Euler([-(a*sin(x[1])+2*b*sin(2*x[1]))],[[sigma]]);

[Maple Math]
[Maple Math]
[Maple Math]

>

EXAMPLE 5

[Maple Math]

[Maple Math]

> Milstein([x[2],(x[1]*(alpha-x[1]^2)-x[2])],[[0,0],[sigma*x[1],0]]);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

Note that the arguments entered for the multidimensional case require the drift and diffusion coefficients of the SDE to be entered as vectors and must be given in the variables x[1],..,x[n]. For the general n-dimensional SDE with m-dimensional noise, the correct syntax for numerical scheme procedures is that of

<scheme>([a1(t,X1[t],..,XN[t]),..,aN(t,X1[t],..,XN[t])],[[b11(t,X1[t],..,XN[t]),..,b1M(t,X1[t],..,XN[t])],..,[bN1(t,X1[t],..,XN[t]),..,bNM(t,X1[t],..,XN[t])]]);

Note also that zeros must be inlcuded as arguments if a dimensional component of the SDE does not appear.

EXAMPLE 6

[Maple Math]

[Maple Math]

[Maple Math]

> Taylor1hlf([a*cos(b+x[3]), a*sin(b+x[3]),-beta*x[3]], [[r,0,0],[0,r,0],[0,0,sigma*sqrt(2*beta)]]);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

EXAMPLE 7

[Maple Math]

[Maple Math]

> comm1([1,0],[0,x[1]]);

[Maple Math]

>

The syntax for procedure "comm1" is given below for the general n-dimensional SDE with m-dimensional noise.

comm1([b11(t,X1[t],..,XN[t]),..,b1M(t,X1[t],..,XN[t])],..,[bN1(t,X1[t],..,XN[t]),..,bNM(t,X1[t],..,XN[t])]);

Similarly, "comm2" uses the same syntax as "comm1".


EXAMPLE 8

[Maple Math]

> wktay3([a(t,x[1])],[[b(t,x[1])]]);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

The resultant algebraic expression above demonstrates the usefulness of such Maple procedures.

Finally, I shall demonstrate the use of procedure "colour".

EXAMPLE 9

[Maple Math]

> colour([a(t,x)],[b(t,x)]);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

EXAMPLE 10

[Maple Math]

[Maple Math]

> colour([x[2],x[1]*(alpha-x[1]^2)-x[2]],[0,sigma*x[1]]);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

The syntax for procedure colour is applicable ony to n-dimensional SDEs with scalar noise, and requires the syntax

colour([a1(t,X1[t],..,XN[t]),..,aN(t,X1[t],..,XN[t])],[b1(t,X1[t],..,XN[t]),..,bN(t,X1[t],..,XN[t])]);