г
DIFFERENTIAL EQUATIONS AND
CONTROL PROCESSES N. 1, 2021 Electronic Journal, reg. N $C77-39410 at 15.04.2010 ISSN 1817-2172
http:// diffjournal.spbu.ru/ e-mail: [email protected]
Computer software for the investigation of differential equations, dynamical systems, and control processes
Stochastic differential equations Numerical methods Computer modeling in dynamical and control systems
SDE-MATH: A software package for the implementation of strong high-order numerical methods for Ito SDEs with multidimensional non-commutative noise based on multiple Fourier—Legendre series
Mikhail D. Kuznetsov1, Dmitriy F. Kuznetsov2
1 Faculty of Computer Technologies and Informatics, St. Petersburg Electrotechnical University, Saint-Petersburg, Russia 2Institute of Applied Mathematics and Mechanics, Peter the Great St.
Petersburg Polytechnic University e-mail: [email protected]
Abstract. The article is devoted to the implementation of strong numerical methods with convergence orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito stochastic differential equations with multidimensional non-commutative noise based on multiple Fourier-Legendre series and unified Taylor-Ito and Taylor-Stratonovich expansions. Algorithms for the implementation of these methods are constructed and a package of programs in the Python programming language is presented. An important part of this software package concerning the
Differential Equations and Control Processes, N. 1, 2021
mean-square approximation of iterated Ito and Stratonovich stochastic integrals of multiplicities 1 to 6 with respect to components of the multidimensional Wiener process is based on the method of generalized multiple Fourier series. More precisely, we used multiple Fourier-Legendre series converging in the sense of norm in Hilbert space for the mean-square approximation of iterated Ito and Stratonovich stochastic integrals.
Key words: Software package, Python programming language, numerical method, strong convergence, Ito stochastic differential equation, multidimensional Wiener process, non-commutative noise, unified Taylor-Ito expansion, unified Taylor-Stratonovich expansion, Milstein scheme, high-order strong numerical scheme, iterated Ito stochastic integral, iterated Stratonovich stochastic integral, mean-square approximation, generalized multiple Fourier series, multiple Fourier-Legendre series, Legendre polynomial.
Contents
1 Introduction |94
2 Theoretical Results Underlying the SDE-MATH Software Package |98
2.1 Strong Numerical Methods with Convergence Orders 0.5, 1.0, 1.5, 2.0, 2.5, and
3.0 for Ito SDEs Based on the Unified Taylor-Ito Expansion...............|98
2.2 Strong Numerical Methods with Convergence Orders 1.0, 1.5, 2.0, 2.5, and 3.0
for Ito SDEs Based on the Unified Taylor-Stratonovich Expansion..........|106
2.3 Method of Expansion and Approximation of Iterated Ito and Stratonovich
Stochastic Integrals Based on Generalized Multiple Fourier Series........|113
2.4 Approximations of Iterated Ito Stochastic Integrals from the Numerical Schemes
(11)-(16) Using Legendre Polynomials ....................................1123
2.5 Optimization of Approximations of Iterated Ito Stochastic Integrals from the
Numerical Schemes (12)-(16) ............................................1132
2.6 Approximations of Iterated Stratonovich Stochastic Integrals from the Numerical
Schemes (24)-(28) Using Legendre Polynomials ............................1141
2.7 Numerical Algorithm for Linear Stationary Systems of Ito SDEs Based on Spectral Decomposition....................................................|147
Electronic Journal. http://diffjournal.spbu.ru/ 94
Differential Equations and Control Processes, N. 1, 2021
3 The Structure of the SDE-MATH Software Package |148
3.1 Development Tools.........................................................|148
3.2 Dependency Libraries......................................................|149
3.3 Architecture..............................................................|149
3.3.1 Integration with SymPy.............................................1151
3.3.2 Purpose of NumPy...................................................|151
3.3.3 Purpose of SQLite Database.........................................|152
3.3.4 Purpose of Matplotlib .............................................|153
3.4 Implementation Plan.......................................................1153
3.4.1 Calculation of the Fourier-Legendre Coefficients...................|153
3.4.2 Differential Operators L, L, G0\ i = 1,... ,m......................1154
3.4.3 Approximations of Iterated Stochastic Integrals....................|154
3.4.4 Strong Numerical Schemes for Ito SDEs .............................|154
3.4.5 Graphical User Interface...........................................1154
4 Software Package Graphical User Interface 154
4.1 Information Model of The Graphical User Interface.........................|154
4.1.1 Processing Screens.................................................|156
4.1.2 Greetings Dialog...................................................|156
4.1.3 Main Menu Dialog...................................................|156
4.1.4 Visualization Tool.................................................|156
4.1.5 Data Input Dialogs.................................................|156
4.2 The User Experience and Implementation Results............................1157
5 The Results Obtained Using the SDE-MATH Software Package |175
5.1 The Calculated Fourier-Legendre Coefficients .............................|175
5.2 Accuracy Settings.........................................................|176
5.3 Testing Example (Nonlinear System of Ito SDEs)............................1179
5.4 Visualization and Numerical Results for Nonlinear System of Ito SDEs Obtained
via the SDE-MATH Software Package.........................................|18()
5.5 Example of Linear System of Ito SDEs (Solar Activity).....................|211
Electronic Journal. http://diffjournal.spbu.ru/ 95
Differential Equations and Control Processes, N. 1, 2021
5.6 Visualization and Numerical Results for Solar Activity Model ..............|211
5.7 Example of Abstract Linear System of Ito SDEs..............................|214
5.8 Visualization and Numerical Results for Abstract Linear System of Ito SDEs
Obtained via the SDE-MATH Software Package.....................................|215
6 Source Codes of the SDE-MATH Software Package in the Python Programming Language 217
6.1 Source Codes of Graphical User Interface.................................|217
6.1.1 Source Codes of Main Menu.........................................|217
6.1.2 Source Codes of Charts Window.....................................|230
6.1.3 Source Codes of Input for Nonlinear Systems of Ito SDEs...........|240
6.1.4 Source Codes of Input for Linear Systems of Ito SDEs.............|255
6.2 Source Codes for Nonlinear Systems of Ito SDEs...........................|275
6.2.1 Source Codes for Calculation of the Fourier-Legendre Coefficients .... |275
6.2.2 Source Codes for Supplementary Differential Operators and Functions . . |299
6.2.3 Source Codes for Iterated Ito Stochastic Integrals Approximations Subprograms ..................................................... 303
6.2.4 Source Codes for Iterated Stratonovich Stochastic Integrals Approximations Subprograms.........................................................|329
6.2.5 Source Codes for Calculation of the Numbers q, qi,..., q\5 ........|351
6.2.6 Source Codes for Strong Taylor-Ito Numerical Schemes with Convergence
Orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs...............|359
6.2.7 Source Codes for Strong Taylor-Stratonovich Numerical Schemes with
Convergence Orders 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs........|381
6.3 Source Codes for Linear Stationary Systems of Ito SDEs...................|400
6.4 Source Codes for Utilities and Initialization ...........................|407
7 Future Work |412
References 413
Electronic Journal. http://diffjournal.spbu.ru/ 96
Differential Equations and Control Processes, N. 1, 2021
1 Introduction
As known, Ito stochastic differential equations (SDEs) have appeared in the theory of random processes relatively recently [1] (1951). Nevertheless, to date, a large number of mathematical models for dynamical systems of different physical nature under the influence of random perturbations have been built on the basis of such equations [2]-[16]. Among them we note mathematical models in stochastic financial mathematics [5]-[7], [10]-[12], geophysics [2], [4], genetics 13], hydrology [2], epidemiology [9], chemical kinetics [2], [9], biology [8], [15], seismology [2], electrodynamics [16] and many other fields [2], [9], [14]. In addition, Ito SDEs arise when solving a number of mathematical problems, such as filtration [2], [3], [17]-[21] , stochastic control [2], [17], stochastic stability [2], parameter estimation of stochastic systems [2], [3], [22].
Exact solutions of Ito SDEs are known in rare cases. For this reason, it becomes necessary to construct numerical methods for Ito SDEs. Moreover, the problem of numerical solution of Ito SDEs often occurs even in cases when the exact solution of Ito SDE is known. This means that in some cases, knowing the exact solution of the Ito SDE does not allow us to simulate it numerically in a simple way.
This article is devoted to the implementation of high-order strong numerical methods for systems of Ito SDEs with multidimensional non-commutative noise. More precisely, we consider strong numerical methods with convergence orders 1.0, 1.5, 2.0, 2.5, and 3.0. The article also considers the Euler method, which under suitable conditions [2] has the order 0.5 of strong convergence. To construct the mentioned numerical methods in this article, we use the so-called
unified Taylor-Ito and Taylor-Stratonovich expansions [24], [25] (also see [26
Chapter 4). The important components of these expansions are the iterated Ito and Stratonovich stochastic integrals, which are functionals of a complex structure with respect to the components of a multidimensional Wiener process.
It should be noted that it is impossible to construct a numerical method for Ito SDE in a general case (multidimensional non-commutative noise) that includes only increments of the multidimensional Wiener processes, but has a higher order of convergence (in the mean-square sense) than the Euler method (simplest numerical method for Ito SDEs). This result is known as the ”Clark-Cameron paradox” [23] (1980) and well explains the need to use high-order numerical methods for Ito SDEs, since the accuracy of the Euler method is insufficient for solving a number of practical problems related to Ito SDEs [2].
Electronic Journal. http://diffjournal.spbu.ru/ 97
Differential Equations and Control Processes, N. 1, 2021
According to the ” Clark-Cameron paradox” [23], avoidance of the problem of mean-square approximation of the mentioned iterated stochastic integrals is impossible in the general case when constructing high-order strong numerical methods for Ito SDEs.
The problem of mean-square approximation of iterated Ito and Stratonovich stochastic integrals in the context of the numerical integration of Ito SDEs was considered in a number of works [2], [3], [7], [8], [27]-[39 .
It should be explained why the results of these works are insufficient for constructing effective procedures for the implementation of strong numerical methods of order 1.5 and higher for Ito SDEs.
There exists an approach to the mean-square approximation of iterated stochastic integrals based on integral sums [27], [34], [35]. Note that one of the variants of this method is based on reducing the problem of mean-square approximation of iterated stochastic integrals to the numerical integration of systems of linear Ito SDEs by the Euler method [39]. However, this approach 27], [34], [35], [39] implies the partitioning of the interval of integration for iterated stochastic integrals. It should be noted that the length of this interval is an integration step for numerical methods for Ito SDEs, which is already a fairly small value even without additional partitioning. Computational experiments show that the numerical modeling of iterated stochastic integrals by the method of integral sums [27], [34], [35], [39] leads to unacceptably high computational
[42]
cost and accumulation of computation errors
More efficient approach of the mean-square approximation of iterated stochastic integrals is based on the expansion of the so-called Brownian bridge process into the trigonometric Fourier series with random terms (version of the so-called Karhunen-Loeve expansion) [2], [3], [7], [27], [28], [33], [34], [37], [38.
However, in [27], [33], [34], [38], this approach was used to approximate only iterated stochastic integrals of multiplicities 1 and 2, which makes it possible to implement numerical method with order 1.0 of strong convergence for Ito SDEs (Milstein method [27]). In papers [2], [3], [7], [28], the approximation of iterated stochastic integrals of multiplicities 1 to 3 was considered by the above approach, which makes it possible to implement numerical methods with orders
1.0 and 1.5 of strong convergence for Ito SDEs. However, formulas concerning integrals of multiplicity 3 turned out to be too complicated and did not find wide application in practice. Moreover, these formulas (for iterated stochastic integrals of multiplicity 3) were obtained without strict theoretical justification and exclude the possibility of effective estimation of the mean-square error of
Electronic Journal. http://diffjournal.spbu.ru/ 98
Differential Equations and Control Processes, N. 1, 2021
approximation (see discussion in [26] (Sections 2.6.2, 6.2) for details).
It should be noted that in papers [29], [30], a similar approach was used to approximate iterated stochastic integrals of multiplicities 1 to 3 based on the series expansion of the Wiener process using trigonometric functions and Haar functions. In [40] orthonormal expansions of functions in terms of Walsh series were used to represent the iterated stochastic integrals.
Note that the iterated stochastic integrals under consideration are the random variables with unknown density functions. The only exception is the iterated Ito stochastic integral with multiplicity 2 [31]. However, the knowledge of density function of the mentioned stochastic integral gives no simple way of its approximation [31 .
In this work, we use a more efficient method of the mean-square approximation of iterated Ito and Stratonovich stochastic integrals than the methods considered above. This method (the so-called method of generalized multiple Fourier series) is based on the theory constructed in Chapters 1, 2, and 5 of monograph [26] (also see bibliography therein). The method of generalized multiple Fourier series made it possible in this work to successfully implement the procedures for the mean-square approximation of iterated Ito and Stratonovich stochastic integrals of multiplicities 1 to 6. In this case, we use multiple Fourier-Legendre series, that is, we have chosen Legendre polynomials as a basis system of functions for approximating iterated stochastic integrals. It is important to note that the Legendre polynomials were first applied in the context of this problem in [43] (1997), while in the works of other authors Legendre polynomials were not considered as a system of basis functions for approximating iterated stochastic integrals (an exception is work [36]). As shown in [44], the Legendre polynomials are an optimal system of basis functions for approximating iterated Ito and Stratonovich stochastic integrals.
In this article, to build the SDE-MATH software package in the Python programming language, we use a database with 270,000 exactly calculated Fourier-Legendre coefficients to approximate iterated Ito and Stratonovich stochastic integrals of multiplicities 1 to 6. It should be noted that the procedures for the mean-square approximation of iterated stochastic integrals of multiplicities 4, 5, and 6 constructed in this work have no analogues in the literature. At the same time, we propose a much more convenient procedure for the mean-square approximation of iterated stochastic integrals of multiplicity 3 than in works [2], [3], [7], [28]. This procedure provides an accurate calculation of the mean-square error of approximation of the mentioned stochastic integrals.
Electronic Journal. http://diffjournal.spbu.ru/ 99
Differential Equations and Control Processes, N. 1, 2021
Another important feature of the presented software package is the use of unified Taylor-Ito and Taylor-Stratonovich expansions [24], [25] (also see [26], Chapter 4) for constructing strong numerical methods with convergence orders
1.5, 2.0, 2.5, and 3.0 for Ito SDEs. Unified Taylor-Ito and Taylor—Stratonovich expansions make it possible (in contrast with its classical analogues [2]) to use the minimal sets of iterated Ito and Stratonovich stochastic integrals. This property well explains the motive for using the mentioned unified expansions.
The results of this work on the approximation of iterated stochastic integrals can be used to numerically solve various types of SDEs. For example, for
semilinear SPDEs with multiplicative trace class noise [26] (Chapter 7), [45], 46]. This is due to the fact that iterated stochastic integrals are a universal
tool for constructing high-order strong numerical methods for various types of SDEs. In recent years, the mentioned numerical methods have been constructed for SDEs with jumps [7], SPDEs with multiplicative trace class noise 47]-[49], McKean SDEs [50], SDEs with switchings [51], mean-field SDEs [52], Ito-Volterra stochastic integral equations [49], etc.
There are many publications in which codes of programs in various programming languages are given for the numerical solution of SDEs [3], [9], [14], Among them, we note the software described in [3], [54], [56
61
60
Some of the mentioned works [3], [54], [56], [57], [60] are based on the results of monograph [2] on the approximation of iterated stochastic integrals (see above discusson on the disadvantages of approach [2]). Other publications [9], [14], 53], [55] do not use the modeling of iterated stochastic integrals for the case of
multidimensional non-commutative noise at all.
In this article, we develop software for the numerical integration of Ito SDEs based on theoretical results and MATLAB codes from monographs [58], 61] for modeling iterated stochastic integrals of multiplicities 1 to 6 (the case of multidimensional non-commutative noise). In addition, we provide software (as a part of the SDE-MATH software package) for the numerical integration of linear stationary systems of Ito SDEs based on the results of article [62] and MATLAB codes from monographs [58], [61 .
In Section 7 we discuss possible directions for the development of the SDE-MATH software package. In particular, the parallelization of computations, the implementation of methods of the Runge-Kutta type [2], [7], [42], [61] and multistep numerical methods for Ito SDEs [2], [7], [42], [61], the development of a part of the software package for solving filtering problem and stochastic optimal control problem [2], as well as improvement of the graphical user interface.
Electronic Journal. http://diffjournal.spbu.ru/ 100
Differential Equations and Control Processes, N. 1, 2021
2 Theoretical Results Underlying the SDE-MATH Software Package
2.1 Strong Numerical Methods with Convergence Orders 0.5, 1.0,
1.5, 2.0, 2.5, and 3.0 for Ito SDEs Based on the Unified Taylor— Ito Expansion
Let (Q, F, P) be a complete probability space and let {Ft, t £ [0,T]} be a nondecreasing right-continuous family of n-algebras of F. Let wt be a standard m-dimensional Wiener stochastic process with independent components wt(i) (i = 1,... ,m), which is Ft-measurable for any t £ [0,T]. Consider an Ito SDE in the integral form
Xt = Xo +
tt
/Ш
a(xT, т )dr + Bi (xT
i=l
, т)dw(i), Xo = x(0,w), (1)
where xt £ Rn is a solution of the Ito SDE (1), the nonrandom functions a(x,t) : Rn x [0,T] ^ Rn, B(x,t) : Rn x [0,T] ^ Knxm guarantee the existence and uniqueness up to stochastic equivalence of a solution of (1) [63], the second integral on the right-hand side of (1) is interpreted as an Ito stochastic integral, Bi(x,t) is the ith colomn of the matrix function B(x,t), x0 is an n-dimensional and F0-measurable random variable, M |x0| < to (M is an
expectation operator). We assume that x0 and wt — w0 are independent when t > 0.
It is well known that one of the effective approaches to the numerical integration of Ito SDEs is an approach based on the Taylor-Ito and Taylor-Stratonovich expansions [2], [7], [42]. The essential feature of such expansions are the so-called iterated Ito and Stratonovich stochastic integrals, which have the form
T t2
J [£k)b = J Щ (tk).. J ... dwtik >,
tt
*T *t2
J*[£k)]T,t = f (tk) ...jmodwC ...dwt
tt
where every (т) (l = 1,..., k) is a continuous nonrandom function on [t,T],
, ( ik)
'tk ,
(2)
(3)
Electronic Journal. http://diffjournal.spbu.ru/ 101
Differential Equations and Control Processes, N. 1, 2021
w(i) (i = 1,... , m) are independent standard Wiener processes and w<0) = t,
and
denote ItO and Stratonovich stochastic integrals, respectively; A,...,ik = 0,1,..., m.
Note that Ф1 (t ) = 1 (l = 1,... ,k) and i1,... ,ik = 0,1,..., m in the classical Taylor-Ito and Taylor-Stratonovich expansions [2]. At the same time Ф1 (t) = (t - t )qi (l = 1,...,k; qi ,...,qk = 0,1, 2,...) and ii,...,ik = 1,...,m in the
unified Taylor-Ito and Taylor-Stratonovich expansions [24], [25] (also see [26], Chapter 4).
Let C2,1(Rn x [0, T]) be the space of functions R(x, t) : Rn x [0, T] ^ R1 with the following property: these functions are twice continuously differentiable in x and have one continuous derivative in t. Let us consider the following differential operators on the space C2,1 (Rn x [0,T])
n m n 2
L = ^ + Y a<*)(x,t)+ 2 YY B(,j)<x’t)B(*i)(x’t)
j= l,i=1
i=1
dx(l)dx(i) ’
A = Y B t) ФФ), 1 = 1>..., m
d
j=1
d x<j)
(4)
(5)
where a(i) (x, t) is the ith component of the vector function a(x, t) and B<ij) (x, t) is the ijth component of the matrix function B(x,t).
Consider the following sequence of differential operators 1 (^
Tp-1L LGp-1
Gp? = 1 (Gp-L - LGP-1) , p =1,2,..., i = 1,...,m,
p
where L and g0^, i = 1,... ,m are defined by (4), (5).
For the further consideration, we need to introduce the following set of iterated Ito stochastic integrals
t2
I
<ii***ife)
<l1 •••lk )s,t
= I (t - tk )lk... /(t - гl)ll dw/1’... dw(/ ^,
(6)
t t
where 11,..., 1k = 0,1,... and i1,..., ik = 1,..., m.
s
Electronic Journal. http://diffjournal.spbu.ru/ 102
Differential Equations and Control Processes, N. 1, 2021
Assume that R(x,t), a(x,t), and B^x, t), i = 1,... , m are enough smooth functions with respect to the variables x and t. Then for all s,t £ [0,T] such that s > t we can write the following unified Taylor-Ito expansion [24] (also see 26], Chapter 4)
R(xs,s) =
R(xt,t) + E E
(s - t)j
q 1 (k,j,Z1 ,***,1fc )£Dq
j!
E G
(ii)
li
G((ik )Lj R(x*,t)
T(i1---ik) i
J(1i ...Zfc )s,t +
i 1 ,...,ik =
1
+ (Hr+1 )s,t w. p. 1,
(7)
where
Lj R(x,t) =
L . „ L R(x, t)
j
<
for j > 1
5
R(x, t) for j = 0
Dq (k,j,/l,...,/k) • k + 2 j + ^ ^ q; k, j, l1, . . . , lk 0, 1, . . .
and (Hr+1)st is the remainder term in integral form [26].
Consider the partition {тр}^0 of the interval [0, T] such that
(8)
0 = то <-л < ... < tn = T, An = max |t,-+1 — Tj | . (9)
о<j<N—1 j+ j
Let yTj = yj, j = 0,1,...,N be a time discrete approximation of the process xt, t £ [0,T], which is a solution of the Ito SDE (1).
Definiton 1 [2]. We will say that a time discrete approximation yj, j = 0,1,..., N, corresponding to the maximal step of discretization AN, converges strongly with order 7 > 0 at time moment T to the process xt, t £ [0,T], if there exists a constant C > 0, which does not depend on AN, and a 5 > 0 such that M{|xT — yT|} < C(An)y for each AN £ (0, 5).
From (7) for s = тр+1 and t = тр we obtain the following representation of explicit one-step strong numerical scheme for the Ito SDE (1)
Ур+1 = Ур +
q 1 (k,j,Z1 ,...,Zk )£Dq
(тр+1 трУ
j!
E
G
(ii)
Z1
G(kk)LjУр 0
(ii...ik)
(Z1 ...Zk )Tp+1,Tp
i
,ik 1
Electronic Journal. http://diffjournal.spbu.ru/ 103
Differential Equations and Control Processes, N. 1, 2021
+ 1 (7>+1 - тр)(Г+1)/2 (r+1)/2y
+ 1{r=2d-i,d&n} ((r + i)/2)! L yp’
(10)
where -^(/11"/*fcfc))T +1 T is an approximation of the iterated Ito stochastic integral (6) and 1A is the indicator of the set A. Note that we understand the equality (10) componentwise with respect to the components yP of the column yp. Also for simplicity we put Tp = pA, A = T/N, p = 0,1,..., N.
Under the appropriate conditions [2] the numerical scheme (10) has strong order r/2 (r G N) of convergence.
Below we consider particular cases of the numerical scheme (10) for r = 1, 2,3,4, 5, and 6, i.e. explicit one-step strong numerical schemes with convergence orders 0.5,1.0,1.5, 2.0, 2.5, and 3.0 for the Ito SDE (1) [26], [64], [65]. At that for simplicity we will write a, La, B*, G0*)Bj etc. instead of a(yp,Tp), La(yp,Tp), B*(yp,Tp), G0*)Bj(yp,Tp) etc. correspondingly. Moreover, the operators L and G0*), i = 1,... ,m are defined by (4), (5).
Scheme with strong order 0.5 (Euler scheme)
yp+i=yp+E B*i Aw* + Aa.
*1=1
Scheme with strong order 1.0 (Milstein scheme)
(11)
yp+1 = yp + E B*10(0)bi,Tp + Aa + E G0 0B*2°(00)Li,r,. (12)
*1=1
*1,*2 = 1
Scheme with strong order 1.5
yp+1 = yp + E B*1 °0)lp+1,rp + Aa + E G0 0 B*2 feP+1 ,Tp +
*1=1
*1,*2 = 1
+ G0n)a (AL(i1) _ + 1 - LB*. o
*1=1
o(*1) ^
(0)tP+1,tP (1)tP+1,tP
(*1)
*1 1(1)G+bG
+
+ \ ' G(*1)G(*2) B О(*1*2*3)
+ G0 G0 B*31(000)rp+1,rp 1 2
A2
+ — La.
*1,*2,*3 = 1
(13)
Electronic Journal. http://diffjournal.spbu.ru/ 104
Differential Equations and Control Processes, N. 1, 2021
Scheme with strong order 2.0
Ур+I - + J2 ВчЩ]Тр+ъТр + Aa + G01 Bn 1{щ2;р+1 ,Tp+
*1=1
*1,*2 = 1
[Go
i1 =1
(il)a (AI™ + /IV ) - LB*1 №
(0)TP+i,TP (1)Tp+1,TW 41 (1)Tp+1,Tp
+
m , , A 2
I \ Л ГА(*1^А(*2) n I (*1*2*3) |____1„ I
+ / . G0 G0 B*3 ^(pnnW . ^ ^ La+
*1,*2,*3 = 1
■(000)Tp+1,Tp ~ 2
m
+ £ [g0,1)lb,2 (I
Г (*1*2) _ I (*1*2) A LG(*1)B I (*1*2) +
L(10)Tp+1,Tp J(01)Tp+1,TW 0 *2/(10)Tp+1,Tp +
*1 ,*2 = 1
_i_/^(*1 V',(*2 A / Г (*1*2)
+ G0 G0 a lJ(01)Tp+1,7
+ AI
(*1*2)
(00)Tp+1 ,Tp
+
\ G(*1)G(*2)G(*3) в Г(*1*2*3*4)
+ G0 G0 G0 B*4 J(0000)Tp+1,Tp •
*1 ,*2,*3,*4 = 1
Scheme with strong order 2.5
yp+1=yp+^2 b*1 /(0)Tp+1,Tp+Aa + S G01 B*21(00)2Tp+1 ,Tp+
*1=1
*1,*2 = 1
+Y1 [G0
*1=1
(*1)
a AI
(*1)
(0)tp+1,t
+ /,(n)
(1)tp+1,
- LB. I
(*1)
+ \ ' G(*1)G(*2) в I (*1*2*3)
+ Z_^ G0 G0 B*31 (000)Tp+1,Tp 1 2
41 (1)tp+1,tp
A2
+—~ La+
+
*1,*2,*3 = 1
m
+ £ [Gf>LB!2 (/
I (*1*2)
[(10)Tp+1,7
-I.
(*1*2)
(01)tp+1,
*1,*2 = 1
-lgJVb*. i(i\\2} _ +
(i1) (i2) (i1i2)
+G041)G042)a (I
(01)tp+1 ,t
+AI
(i1i2)
(00)tp+1 ,Tp
0 *2 (10)tp+1,tp
+
(i1) (i2) (i3) (i1i2i3i4)
+ G0 G0 G0 Bi4I
'0 G0 G0 B*4 J(0000)Tp+1,Tp +
*1,*2,*3,*4 = 1
p
p
p
p
(14)
Electronic Journal. http://diffjournal.spbu.ru/ 105
Differential Equations and Control Processes, N. 1, 2021
G(ii)La ( ^I,
+£
*i=i
+—LLBi, I.
1
Кч)
+ ДI
(ii)
+Д lii ’ V
2 (2)TP+i,TP (1)tp+i,tp 2 (0)rp+i,T)
(ii)
(*iU ( I(ii)
2
i (2)tp+i ,Tp
- LG0n)a( I
(2)tp+i,tp
+ Д1
(ii)
(1)Tp+i,Tp
+
+ £
*i,*2,i3 = l
G!,*i)LGi*2]B„, 11
__ I(iii2i3)
0 Bi3 \ff (l00)Tp+i,Tp J(0l0)Tp+i,r?
(iii2i3)
+
+G<ii)G<i2)LB,, (I
_ I(iii2i3)
i3 V I(0l0)Tp+i,Tp J(00l)rp+i,r3
(iii2i3)
+
+G0ii)G0i2)G0i3)a ^I(iii2i3)
+1
(iii2i3)
'(000)rp+i,Tp (00l)rp+i,r3
_LG(ii)G(i2)B I(iii2i3)
+
0 0 i3 (l00)Tp+i,Tp
(ii^'»(i2^'f(i3^'f(i4) Г? I(iii2i3i4i5)
I \ л /^4(ii^4(i2^'f(i3^'f(i4) TD I = »=3'4'5/ I
+ G0 G0 G0 G0 Bi5 J(00000)Tp+i,Tp +
ii,*2,*3,i4,i5=l
Д3
+ — LLa. 6
(15)
Scheme with strong order 3.0
УР+1 - yP+^2 Bii-I(0)Tp+i,Tp+Да + G0i Bi2I(00)2rP+i,Tp+
ii=l
ii,i2=l
+Y1 [G0
ii=l
(ii)
а ДТ,
(ii)
(0)tp+i,t
+ I(ii)
(1)tp+i>
- LBr I
(ii)
+ \ ' G(ii)G(i2) B I(iii2i3)
+ 2^ G0 G0 Bi3 J(000)rp+i,rp 1 2
ii (1)tp+i,tp
Д2
+—~ La+
+
ii,i2,i3 = l
m
+ £ [Gf>LB!2 (I
(iii2)
___ I(iii2) \ ____ LG(ii)B I(iii2) +
L(l0)Tp+i,Tp 1 (0l)Tp+i,Tp у 0 i2 J(l0)Tp+i,Tp +
ii,i2=l
(ii)^1(i2ff f I(iii2)
+G0fi)G0i2)a (I
(0l)Tp+i,7
+ Д/,
(iii2)
(00)Tp+i ,гг
+
\ Л /^4(ii)^4(i2)^'f(i3) D I(iii2i3i4)
+ G0 G0 G0 Bi4
ii ,i2 ,i3,i4 = l
(0000)rp+ilrp + qp+l,p + rp+l,p,
(16)
P
P
Electronic Journal. http://diffjournal.spbu.ru/ 106
Differential Equations and Control Processes, N. 1, 2021
where
qp+i,p
E
*1=1
G^La ( ^I
1
(*i)
r0
+ AI
(*i)
+ A1
(ii)
2 (2)rP+i,T^ (1)rp+i,r^ 2 (0)tp+i,tp
+
+1 LLB* 112;E- iG0-'^ в . + AI
*(*d. (Iff + A/dd
(2)Tp+i,Tp (1)Tp+i,Tp
+
+ E
*i,*2,*3 = 1
G^LGl*2>B*. 11
__ I(*i*2*3)
0 B*3 \ J(100)rp+i,Tp J(010)Tp+i,r?
(i1i2i3)
+
+G0‘i)G',‘2)LB„ (I
(i1i2i3)
(i1i2i3)
r0 G° LB*3 l J(010)Tp+i,Tp I(001)Tp+i,Tp
+
+G0*i)G0*2)G0*3)a (A/^i*^ , _ + I
+ I ( 1 2 3)
(000)Tp+bTp + J(001)rp+i,Tp
and
r
_LG(*i)G(*2)B I(*i* 2*3)
+
0 0 *3 (100)Tp+i,Tp
(*d^d*2)^'f(*3)^'f(*4) Г) I(*i* 2* 3* 4* 5)
I \ л /=f(* ih*( *2ff'1(*3ff'1( *4) n I-i-2-3-4-5/
+ G0 G0 G0 G0 B * 5 1(00000)тр+ьтр +
*i, * 2,* 3, *4, *5 = 1
A3
+ LLa, 6 ’
’p+1,p
E
*i, *2 = 1
g0* i * G0* 2)La( 1I( *i,2)
, +AI(* ^2) +—T('' 1 +
2 (02)Tp+i,Tp + 1 (01)Tp+i,Tp + 2 1 (00)rp+i,rp
A I*i* 2)
1
+-LLG0* "B*,1
(*i) D I(*i*2)
2
0 * 2 (20)Tp+bT?
+
+G0*i)LG0*2)a (I(*^ 2)
( 1 2)
(11)Tp+i,Tp 1 (02)Tp+i,Tp
I(*i* 2) _ j(*i* 2)
d10)rp+i,rp 1 (01)tp+i,tp
_ J(*i* 2) + A ( I(*i*2) _ Ц,"=2/ | | +
+LG0*i)LB*0 fI(*^ 2)
___ I(*i*2) 1 +
* 2 V1 (11)tp+i,tp 1 (20)tp+i,t^
+G(*i) LLB ( 1 I(*i* 2) +1 I(*i* 2) __ I(*i* 2)
0 * 21 21 (02)tp+i,tp + 21 (20)tp+i,tp 1 (11)rp+i,rp
- LG0*i) g0* 2)a (A I
i(* i* 2) I(10)rp+i,7
+ I
( 1 2)
(11)Tp+i,Tp
+
p
Electronic Journal. http://diffjournal.spbu.ru/ 107
Differential Equations and Control Processes, N. 1, 2021
+ L
*1,*2,*3,*4 — 1
(*l) (*2) (*3) (*4) T
txq Gq Gq Gq a /-Л.1,
T(*1*2*3*4)
i(QQQQ)tp+i,7
+ I
(*1*2*3*4)
(0001)Tp+i,Tf
+
+ G(*1)G(*2)LG(*3)B I(*1*2*3*4)
Q *4 (Q1QQ)Tp+1,Tp
1T
(*1*2*3*4)
(QQ1Q)Tp+1,Tp
_LG(*1)G(*2)G(*3)B I(*1*2*3*4) +
*4J (1QQQ)Tp+1,T
+ G(*1)LG(*2)G(*3)B f I(*1*2*3*4)
__ T(*1*2*3*4) 1
(1QQQ)Tp+1,Tp 1(Q1QQ)tp+1,tp ' +
+gQ‘1)gQ‘2)g!,!3)lb! i
'0 w0
0
*4
r(*1*2*3*4)
IT
(*1*2*3*4)
■(QQ1Q)Tp+1,Tp (QQQ1)Tp+1,Tp
+
+
L
(*1) (*2 ) (*3) (*4) (*5) I( * 1 * 2 * 3 * 4 * 5 * 6)
G G G G G 1,
r0 vjq vjq vjq
*6 (QQQQQQ)Tp+1 ,Tp
*1 ,*2,*3,*4,*5,*6 — 1
Under the suitable conditions [2] the numerical schemes (12)-(16) have strong orders 1.0, 1.5, 2.0, 2.5, and 3.0 of convergence correspondingly. Among these conditions we consider only the condition for approximations of iterated Itl stochastic integrals from (12)-(16) [2] (also see
M
I.
(*1...*fc)
IT
(*1 ...*k)
(11 ..Ik )Tp+1,Tp (11 ..Ik )Tp+1,Tp
< CД’’+1,
(17)
p
p
2
where constant C is independent of Д and r/2 are the strong convergence orders for the numerical schemes (12)-(16), i.e. r/2 = 1.0,1.5, 2.0, 2.5, and 3.0.
Note that the numerical schemes (12)-(16) are unrealizable in practice without procedures for the numerical simulation of iterated Itl stochastic integrals from (10). In Section 2.3 we give a brief overview of the effective method of the mean-square approximation of iterated Ito and Stratonovich stochastic integrals of arbitrary multiplicity k (k £ N).
2.2 Strong Numerical Methods with Convergence Orders 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs Based on the Unified Taylor—Stra-tonovich Expansion
Let us consider the following differential operator on the space C2,1(Rn x [0,T])
Electronic Journal. http://diffjournal.spbu.ru/ 108
Differential Equations and Control Processes, N. 1, 2021
т _ L _ _ \ л G(i)G(i)
L _ L 2 G° G° ’
(18)
i=1
where operators L and G°i), i _ 1,... ,m are defined by (4), (5). Define the following sequence of differential operators
£(,) _f _ fgW^L - L (3p-1) , p _1,2,..., i _ 1,... ,m,
■Г p P-1'
(19)
where G°i) _f G°i), i _ 1,... ,m. The operators L and G°i), i _ 1,... ,m are defined by (18) and (5) correspondingly.
For the further consideration, we need to introduce the following set of iterated Stratonovich stochastic integrals
l
*t2
*(il"'ifc) _ [ (t - tk )lk... [ (t - f1)/l dwt(il)... dw((ik),
'-(h...ik)s,t _ J (t tk) .. J (t t1) dwti ...dwtk , (20)
t t
where l1,..., lk _ 0,1,... and i1,... ,ik _ 1,...,m.
Assume that R(x,t), a(x,t), and Bi(x,t), i _ 1,... ,m are enough smooth functions with respect to the variables x and t. Then for all s,t £ [0,T] such that s > t we can write the following unified Taylor-Stratonovich expansion [25] (also see [26], Chapter 4)
R(xs,s) _
R(xt,t) + ^ ^
(s - t)j
q 1 (k,j,l1 ?***,lk )£Dq
j!
E G
i1,...,ik=1
(ii> ..G(ik>LjR(x(,t)
l1
+ (Hr+0 st w. p. 1,
(21)
where
Lj R(x,t) =
. ..L R(x, t) for j > 1
R(x, t)
for j _ 0
the set Dq is defined by the equality (8) and (Hr+1) st is the remainder term i integral form [25] (also see [26], Chapter 4).
in
Electronic Journal. http://diffjournal.spbu.ru/ 109
Differential Equations and Control Processes, N. 1, 2021
Consider the partition (9) of the interval [0, T]. From (21) for s = rp+\ and t = Tp we obtain the following representation of explicit one-step strong numerical scheme for the Ito SDE (1)
Ур+1 = Ур +
q 1 ,...,1k )GDq
(tP+1 ТрУ
j!
E G
;...;*fc 1
(ii)
li
..G(ik)Ljyp ГГ1;\K) +
lk p (li ...Ik )Tp+1,Tp
r*(*1...*k )
+1
{r=2d-l,deN }
(tP+1 - Tp)(r+l)/2 L(r+l)/2y
((r + 1)/2)! L Ур’
(22)
where In ’1'1"/1, ^ is an approximation of the iterated Stratonovich stochastic
integral (20) and 1A is the indicator of the set A. Note that we understand the equality (22) componentwise with respect to the components yP^ of the column yp. Also for simplicity we put tP = pA, A = T/N, p = 0,1,..., N.
Under the appropriate conditions [2] the numerical scheme (22) has strong order r/2 (r G N) of convergence.
Denote
m
a(x,t) = a(x,t) - ^ E Goj)Bj(x,t),
j=i
where Bj(x, t) is the jth column of the matrix function B(x,t).
It is not difficult to show that (see (18))
L
d_
dt
+ E aM(x,t)
i=l
d
dx(i),
(23)
where a(i)(x,t) is the ith component of the vector function a(x,t).
Below we consider particular cases of the numerical scheme (22) for r = 2,3,4, 5, and 6, i.e. explicit one-step strong numerical schemes with convergence orders 1.0,1.5, 2.0, 2.5, and 3.0 for the Ito SDE (1) [26], [66], [67]. At that for simplicity we will write a, La, La, Bi, G0i)Bj etc. instead of a(yp, tP), La(yp, tP), La(yp,Tp), Bi(yp,Tp), G0i)Bj(yp,Tp) etc. correspondingly.
Scheme with strong order 1.0
yp+i yp
= yp + Bi11
i 1=l
n(i1)
'(0)Tp+1,Tp
+ Aa+ E G0*^ Bi21
n(i1i2)
(00)Tp+1,Tp
(24)
i 1 ,i 2 =
Electronic Journal. http://diffjournal.spbu.ru/ 110
Differential Equations and Control Processes, N. 1, 2021
yP+1
+
yP+1
+
m
+ E
*Ъ*2 =
УР+1
+
Scheme with strong order 1.5
yp + J2 B*1 I(0)rp+1,rp + Aa + G01 B*21^+1 ,Tp +
* 1=1
*1,*2=1
У2 |G0':,)a (a/(*(,1)
1=1
+ I
*(*1)
(0)tp+1,tp (1)Tp+1,Tp
ТЭ T*(i 1*2*з)
- L B' I
*(*1)
11 (1)Tp+1,Tp
+
+ E G;0‘ G0“2>В'з.
1, 2, з=1
A _
(000)Tp+1,Tp + 2 a‘
(25)
Scheme with strong order 2.0
yp + ^2 B“ 1 I(0)1Tp+1,Tp + Aa + ^2 G01 B*2 .(o0)Tp+1 ,Tp +
1 =1
1, 2=1
У2 |g0“‘’a (aI(*(,1)
1=1
+I
*(* 1)
(°)tp+1,tp (1)tp+1,t?
- L B* 11
*(* 1)
(1)tp+1,Tp
+
+ E gCg^B'31
1, 2, 3=1
A2
(* 1^(* 2) p, I *(* 1“ 2* 3) 1 A Ta I
(000)Tp+1,Tp +2 +
__ I(i 1* 2) 5 T G(i 1) B I*(* 1“2) +
*2 VI(10)tp+1,tp I(01)tp+1,tW 0 *2I(10)tp+1,tp +
g0* 1)lb*. (I*(* 1i2)
_i_/^(* /" I(i 1 “2)
+ G0 G0 L lI(01)Tp+1,7
+ AI
*(*1*2)
(00)Tp+1 ,Tp
+
I \ л г~1(*1) r~1(*2) r~1 (*3) D I *(* 1 *2*3*4)
+ 2-^ G0 G0 G0 B*41|
*1 ,*2,*3,*4 = 1
0 ^0 ^0 ^*4J (0000)tp+1,tp-
(26)
p
Scheme with strong order 2.5
yp + ^2 B*1 I(*0)Tp+1,Tp + Aa + ^ G^ B*2 I(00)Tp+1 ,Tp +
i1 =1
*1,*2 = 1
riG'*11 a(Al;0',1) + I//
| 0 V (0)tp+1,tp (1)tp+1,tp
- L В*. I
*(*1)
41 (1)Tp+1,Tp
+
1=,
Electronic Journal. http://diffjournal.spbu.ru/ 111
Differential Equations and Control Processes, N. 1, 2021
+ £ g0,i)g<*j)b,3I
*1,*2,*3 = 1
A2
(*1)^'f(*2) Д. ;*(*1*2*3) | A Га |
(000)Tp+i,Tp +2 +
m
+ £ [g/Ab,, (/,
K*1*2)
=(*1*2)
'(10)rp+1,Tp (01)Tp+bTp
- T g0,1)b,2 i
;(*1*2)
(10)tp+1,t
|
*1,*2=1
+ G(*1)G(*2)T ( T*(i 1*2) + A f*(* 1*2)
0 0 V (01)tp+1,tp + 1(00)tp+1 ,TP
I \ л G'f(*1)G'f(*2)^'f(*3) TD f*(*1*2*3*4)
+ 2-^ G0 G0 G0 B*41
*1 ,*2 ,*3,*4 = 1
|
0 G0 G0 B*41 (0000)rp+1,rp +
+£
*1=1
G(n)La ( =-1,
1
*(*1)
0
2 (2)tP+1,TP
+ A I
*(*1)
+ A1
*(*1)
+1 LLB4- м0*1)^II*1) + AI(1)
2 1 (2)tP+1 ,TP 0 V (2)tP+1,tP (1)tP+1,tP
(1)tp+1,tp 2 (0)tp+1,tp
*(i1)
|
|
|£
i1,i2,i3=1
G(*1)LG(*2)B (I*(*1*2*3)
-I,
*(i1i2i3)
■(100)Tp+1,Tp (010)rp+1,r3
|
+Gi*1)Gi*2)LB^ (I
*(i1i2i3)
*(i1i2i3)
'0 G0 LB*3 l J(010)rp+1,Tp 1(001)Tp+1,Tp
|
(i1) (i2) (i3) *(i1i2i3)
+G041)G0t2)G0t3)a ( AI
+1
*(i1i2i3)
■(000)rp+1,Tp ~ (001)rp+1,r3
__ T r'i(*1)G4(*2) ]Э I *(* 1 *2*3)
LG0 G0 B*3 J(100)Tp+1,Tp
|
I \ л G4(*2) ^'f(*3) A'f (*4) TD I*(*1*2*3*4*5)
+ 2_^ G0 G0 G0 G0 B*5 J(
i1,i2,i3,i4,i5=1
0 G0 G0 G0 B*51 (00000)rp+1,rp +
A3
+ — LLa. 6
(27)
Scheme with strong order 3.0
yp+1 - yp + ^ B*11(0()1P+1,Tp + Aa + ^ G0 0 B*2 1
(*1) 0
*(*1*2) t(00)Tp+1 ,tj
|
*1=1
*1,*2=1
+Y^ [G0
*1=1
(*1)
a AI
*(*1)
(0)7p+b7
+ I
*(*1)
(1)Tp+1,Tp
- L B*11
*(*1)
(1)Tp+1,Tp
|
p
p
Electronic Journal. http://diffjournal.spbu.ru/ 112
Differential Equations and Control Processes, N. 1, 2021
*1,*2,*3 = 1
A2
(*1)^'f(*2) Д. f*(*1*2*3) | A Га |
(000)Tp+i,Tp +2 +
*1,*2 = 1
(10)tp+1,tp (01)tp+1,tp
+ £ [g0,1)LB!2 (/‘А2’ _ - I*'*1*2’
+g0!1)g0‘2)a f Л'1!2 A + A/;(,1!2)
(i1) 70 f*(* 1 *2)
L G((1) Bn I
(01)Tp+1,7
(00)tP+1 ,Tp
0 *2 (10)Tp+1,Tp
|
|
(*1)G'f(*2)W'(*3) D f*(*1*2*3*4) + q + r
(0000)tp+1,tp + qP+1,P + rP+1,P,
_i_ \ л GO(*1 А^(*2 A(*3 A f
+ 2_^ G0 G0 G0 B*41|
*1 ,*2,*3,*4 = 1
where
qp+1,p —
*1=1
G0*1)La f 1 /Г(!1)
+ AI*(*1) +— f*-1' | +
2 (2)tp+1,tp + I(1)tp+1,tp + 2 I(0)tp+1,tW +
A f*(*1)
+~L L Bu I.
*(*1)
hda ( f*(*1)
2
1 (2)tP+1 ,Tp
- LG01) a( I
+ AI
*(*1)
(2)tp+1,tp (1)tp+1,tp
|
+ £
*1,*2,*3=1
G0!1)LGi!2>B*„ II,
0 ^*3
f*(*1*2*3) __ I*(*1*2*3) 1 +
■(100)Tp+1,Tp (010)tp+1,t3
+g0,1)g0,2)l b„ (I
__ f*(*1*2*3)
*3 V i(010)tp+1,tp I(001)tp+1,t)
Г*(*1*2*3)
|
(*1)п(*2)г<(*3)~ ( A f*(*1*2*3)
+G041)G0t2)G0t3) a(AI
+1
*(*1*2*3)
■(000)Tp+1,Tp ^ (001)tp+1,t3
__ T W*(*1)G'1(*2) TD f*(*1*2*3)
LG0 G0 B*31(100)Tp+1,Tp
|
and
r
I \ л G'1(*1^'1(*2A'f(*3A'f(*4) 70 f*(*1*2*3*4*5)
+ 2_^ G0 G0 G0 G0 B*5 J(
i1,i2,i3,i4,i5=1
0 G0 G0 G0 B*51 (00000)Tp+1,Tp +
A3--_ + L La,
6 ’
p+1,p
£
i1,i2=1
G^G^Lal
1
(i1i2)
00
+ AI
(i1i2)
+ A1
(i1i2)
2 (02)tp+1,tp (01)tp+1,tp 2 (00)tp+1,tp
I1 T T П(*1) R f*(* 1 *2) 1
+ 2 LLG0 B*21(20)Tp+1,Tp +
P
(28)
|
Electronic Journal. http://diffjournal.spbu.ru/ 113
Differential Equations and Control Processes, N. 1, 2021
_ ,*(*1*2) + Д J*(*1*2) _ J*(*1*2) +
*(*1*2)
(ll)Tp+i,Tp 1(02)Tp+i,Tp
(10)TP+b
(01)Tp+1,7
+LG0*1)LBin (/*(i1*2)
_ f*(*1*2) 1
*2 I(11)TP+1,TP I(20)TP+1,TP *
I G(*1) T T B 1 f*(*1*2) 1 1 f*(*1*2)
0 *2 2 J(02)rp+1,rp + 21(20)Tp+1,Tp I(11)rp+1,rp
-i;
=(*1*2)
_T g0*° G0*2)a(A/,
*(*1*2)
I(10)rP+b7
+;
(*1*2)
(11)Tp+1,Tp
I
+ z
*1 ,*2,*3,*4 — 1
G^^G^G^G^a f A/*(*1 *2*3*4) + ;*(*1*2*3*4) 1 +
■(0000)rp+1,7
■(0001)rp+1,Tp
+Gi,1)Gi,2)LG,(,!3)B! Z
00
___ f*(*1*2*3*4)
0 B*4 J(0100)rp+1,Tp 1 (0010)тр+1,тг
г *(*1*2*3*4)
_£G(*1)G(*2)G(*3)B ;*(*1*2*3*4) |
(1000)rp+1,7
+G(*1) t g(*2)g(*3) в (* 1*2 *3*4) _;*(*1*2 *3*4) +
+G0 LG0 G0 B*4 J(1000)rp+1,Tp J(0100)Tp+1,Tp 1 +
+g<*1)g<*2)g0*3)Zb,, (I,
r*(*1*2*3*4)
*4 *(0010)rp+1,rf
-I;
*(*1*2*3*4)
(0001)Tp+1,Tp
+
+
z
G(*1)G(*2)G(*3)G(*4)G(*s) B ;*(* 1 *2*3*4*5*6)
G0 G0 G0 G0 G0 B*61 (000000) Tp+1 ,Tp •
*1 ,*2,*3,*4,*5,*6 — 1
Under the suitable conditions [2] the numerical schemes (24)-(28) have strong orders 1.0, 1.5, 2.0, 2.5, and 3.0 of convergence correspondingly. Among these conditions we consider only the condition for approximations of iterated Stratonovich stochastic integrals from (24)-(28) [2] (also see [42])
M
1
*(*1...*fc)
-I,
*(*1...*fc)
(11 ..Ik )тр+1,тр (11 ..Ik )тр+1,тр
< C Ar+1,
(29)
P
P
P
P
2
where constant C is independent of A and r/2 are the strong convergence orders for the numerical schemes (24)-(28), i.e. r/2 = 1.0,1.5, 2.0, 2.5, and 3.0.
Note that the numerical schemes (24)-(28) are unrealizable in practice without procedures for the numerical simulation of iterated Stratonovich stochastic
Electronic Journal. http://diffjournal.spbu.ru/ 114
Differential Equations and Control Processes, N. 1, 2021
integrals from (22). The next section is devoted to the effective method of the mean-square approximation of iterated Ito and Stratonovich stochastic integrals of arbitrary multiplicity k (k £ N).
2.3 Method of Expansion and Approximation of Iterated Ito and Stratonovich Stochastic Integrals Based on Generalized Multiple Fourier Series
Let us consider the effective approach to expansion of iterated Ito stochastic
integrals [42] (2006) (also see [26], [44]-[46], [58], [61], [67], [68]). This method
is reffered to as the method of generalized multiple Fourier series.
Suppose that every ф1 (t) (l = 1,..., k) is a continuous nonrandom function on [t,T]. Define the following function on the hypercube [t,T]k
i^i(ti). ..фк (tk) for ti < ... <tk
, ti,... , tk £ [t, T],
0 otherwise
(30)
where k > 2 and K(t1) = ффФ) for t1 £ [t,T].
Suppose that (ф-(ж)}°=0 is a complete orthonormal system of functions in the space L2([t, T]).
The function K(t1,... ,tk) is piecewise continuous in the hypercube [t,T]k. At this situation it is well known that the generalized multiple Fourier series of K(t1,..., tk) £ L2([t, T]k) is converging to K(t1,..., tk) in the hypercube [t, T]k in the mean-square sense, i.e.
lim
pi,...,pk
pi
pk
k ^...^k) -^2 ...^2 C-k ...ji П(ti)
j 1=0 jk=0
l=1
L2([t,T ]k)
where
k
c-k ..j = K (tl,..., tk) п(ti)dt 1.
[t,T]k l=1
is the Fourier coefficient and
. . dtk
(t \
f IL2([t,T]k) = f 2(t1,. . ,tk)dt1 . . . dtk
\t,T ]k /
0,
(31)
Electronic Journal. http://diffjournal.spbu.ru/ 115
Differential Equations and Control Processes, N. 1, 2021
Consider the partition [tj}N=0 of the interval [t,T] such that t = t0 < ... < tn = T, AN = max Arj ^ 0 if N ^ ж, Atj = Tj+1 — Tj.
0 <j<N—1
(32)
Theorem 1 [42] (2006) (also see [26],[44]-[46], [58], [61], [67], [68]). Suppose
that every Ф1 (t) (l = 1,...,k) is a continuous nonrandom function on [t,T] and [fj(x)}j=0 is a complete orthonormal system of continuous functions in the space L2([t,T]). Then
Pi Pk /к
J[
^ = c/pm» .. • Cjkj
ji=0 jk=0 1=1
(il)
jl
lim. T jС)Aw//...j(T‘k)Aw/k) ,
N^“ (ii. -.Ik)€Gk
(33)
where J[^(k)]T,t is defined by (2),
Gk = Hk\Lk, Hk = [ (li,..., Ik)• li,...,lk = 0,1,...,N — 1},
Lk = [(l1, . . . , lk) • l1, . . . , lk = 0, 1, . . . , N 1, lg = lr (g = r); 9,r = 1, . . . , k},
l.i.m. is a limit in the mean-square sense, i1,... ,ik = 0,1,... ,m,
T
j = / Фj(s)dw(i) (34)
are independent standard Gaussian random variables for various i or j (in the case when i = 0), Cjk...j is the Fourier coefficient (31), Aw(j = wj+1 — w(j (i = 0,1,... ,m), [tj}N=0 is a partition of the interval [t,T], which satisfies the condition (32).
Note that a number of modifications and generalizations of Theorem 1 can be found in [26], [67].
Consider transformed particular cases of (33) for k = 1,..., 6 [26], [58], [61],
[67], [68]
P1
J[^(1)]T,t = U.m. £ Cjij0,
P 1^Ж
(35)
ji =0
Electronic Journal. http://diffjournal.spbu.ru/ 116
Differential Equations and Control Processes, N. 1, 2021
p i p 2
T,t =
'is, E £«, C(:i,zi22) -1
Р1,Р2^ГО
{*1=*2=0}1{,1=,2} I ,
,1=0 ,2=0
(36)
Р1 Р2 Р3
Ji(3)b=Р,1:^, E £ E «-3,2,3 zjll)ci,2)c<:3)-
,1=0 ,2=0 ,3 =0
1{*1=*2=0}1{,i=,2}C73 — 1{*2 = *3 =0}1{,2 =,3}Cji — 1{*1=*3=0}1{,i=,3}C72 I , (37)
J ^(4) ]T,t = 1:1:Ш:
Р1,...,Р4
Р1
Р4
Li;S;, Е ...£C',4..,1 П с
•31
,1=0 ,4=0
./=1
__1 1 /^(*з£(*4) __ 1 1 Z(*2)Z(*4)__
1{*1=*2=0} 1{,1=,2}Z,3 Z,4 1{*1=*3=0} 1{,1=,3}Z,2 Z,4
__1 1 Z(*2)Z(*3) __ -I 1 Z(*1)Z(*4)__
1{*1=*4=0} 1{,1=,4}Z,2 Z,3 1{*2=*3=0} 1{,2=,3}Z,1 Z,4
1{*2=*4=0} 1{,2=,4}Z,1 Z,3 1{*3 = *4=0}1{,3=,4}Z,1 Z,2 1
|1{*1=*2=0} 1 {,1 =,2 } 1{*3=*4=0} 1{,3=,4} 1 1{*1 = *3=0}1{,1=,з} 1{*2=*4=0} 1{,2=,4}1
1 1{H=*4=0}1{,1=,4}1{*2 = *3=0}1{,2=,3} I ,
(38)
Р1
J [^(5) ]T,t = l:i:S: E
Р1,...,Р5 Z--'
,1 =0
__1 1 Z (i3)Z (i4) Z (i5) _
1{*1 = *2 =0}1{,1=,2}Z,3 Z,4 Z,5
1 1 Z(i2) Z(i3)Z(i5) _
1{*1 = *4 =0}1{,1=,4}Z,2 Z,3 Z,5
__-| -| Z(*1E(*4E(*5)
1{*2 = *3 =0}1{,2=,3}Z,1 Z,4 Z,5
__1 1 Z(i1)Z(i3)Z(i4) _____
1{*2 = *5 =0}1{,2=,5}S,1 Z,3 Z,4
__1 1 f Z(i1)Z(i2) Z(i4)
1{*3=*5=0}1{,3=,5}S,1 Z,2 Z,4
= (i5)
П Z
/=1
Ы
3i
1{*1=*3=0} 1{,1: 1{*1=*5=0}1{,1 1{*2=*4=0} 1{,2: 1{*3=*4=0} 1{,3: 1 {*4 = 75=0} 1 {,4:
Z(*2)Z(*4) Z(*5)____
=,3}Z,2 Z,4 Z,5
Z (*2)Z (*3) Z (*4)_
=,5}Z,2 Z,3 Z,4
Z (*1)Z (*3) Z (*5)_
=,4}Z,1 Z,3 Z,5
Z (*1)Z (*2) Z (*5)_
=,4}Z,1 Z,2 Z,5
Z (*1)Z (*2)Z (*3) I =,5}Z,1 Z,2 Z,3 +
E1{*1=*2=0}1{,1=,2}1{*3=*4=0}1{,3=,4} Z,5 1 1{*1 = *2=0}1{,1=,2}1{*3=*5=0}1{,3=,5}C,4 1
E1{*1=*2=0}1{,1=,2}1{*4=*5=0}1{,4=,5} C,3 1 1{*1 = *3=0}1{,1=,3}1{*2=*4=0}1{,2=,4}C,5 1
= (*5)
E1{*1=*3=0}1{,1=,3}1{*2 =*5=0}1{,2=,5} Z,4 1 1{*1 = *3=0}1{,1=,3}1{*4=*5=0}1{,4=,5}C,2 1
= (i2)
E1{*1=*4=0}1{,1=,4}1{*2 =*3=0}1{,2=,3} Z,5 1 1{*1 = *4=0}1{,1=,4}1{*2=*5=0}1{,2=,5}C,3 1
= (*3)
Electronic Journal. http://diffjournal.spbu.ru/ 117
Differential Equations and Control Processes, N. 1, 2021
+ 1{*i=*4=0}1{j’i=j4}1{*3=*5=0}1{j3=j5} Cj2 + 1{*i = *5=0}1{j’i=j5}1{*2=*3=0}1{j2=j3}Zj'4 +
+ 1{*i=*5=0}1{j’i=j5}1{*2 =*4=0}1{j2=j4} j + 1{*i = *5=0}1{j’i=j5}1{*3=*4=0}1{j3=j4}Zj'2 +
+ 1{*2=*3=0}1{j2=j3}1{*4=*5=0}1{j4=j5} j + 1 {*2 = *4=0} 1 {j2=j4} 1 {*3=*5=0} ^ j3=j5 } j +
+ 1 { *2 = *5 =0} 1 {j2 = j5 } 1 { *3=*4 =0 } 1 {j3 = j4 } C
(il)
ji
(39)
pi ре /6
J[^(6)b = ,1.!:^ £ £ C'e...ji (n cf-
ji=0 je=0 \/=1
__1 I # Z(*2) Z(*3)Z(*4) Z(*5) _____ -I -I # Z(*1)Z(*3) Z(*4) Z(*5)____
1{*i=*e=0} 1{j’i=j’e}Zj2 Zj3 Zj4 Zj5 i{*2=*e=0}1{j2=je}Zj'i j j j
__1 1 Z (*i)Z (*2) Z (*4) Z (*5) _ 1 1 Z (*i)Z (*2) Z (*3)Z (*5)_
1{*3=*е=0} 1{j3=je} Zj'i Zj2 Zj4 Zj5 1{*4=*e=0} 1{j4=je}Zj'i j Zj3 Zj5
__1 1 Z(*i)Z(*2) z(*3)z(*4) ______ I I z(*3)z(*4) z(*5)z(*e)_____
i{*5=*e=0}1{j5=je}Zj'i Zj2 Zj3 Zj4 1{*i=*2=0}1{j'i=j2}Zj3 Zj4 Zj5 Zj'e
__1 1 f Z(*2)Z(*4) Z(*5)Z(*е) ______ 1 1 f Z(*2)Z(*3) Z(*5)Z(*e)_____
1{*i=*3=0}1{j'i=j'3}Zj2 Zj4 Zj5 Zje 1{*i=*4=0}1{j'i=j4}Zj2 Zj3 Zj5 Zj'e
__1 1 z (*2)z (*3)Z (*4) z (*e) __ I n z (*i)z (*4) z (*5)z (*e)_
1{*i=*5=0}1{j'i=j5}Zj2 Zj3 Zj4 Zj6 1{*2=*3=0}1{j2=j3}Zj'i Zj4 Zj5 Zj'e
__1 1 z (*i)z (*3)z (*5)z (*e) ___ I I z (*i)z (*3) z (*4)z (*e)_
i{*2=*4=0}1{j2=j4}Zj'i Zj3 Zj5 Zj6 1{*2=*5=0}i{j2=j5}Zj'i Zj3 Zj4 Zj'e
__1 1 f z(*i)z(*2) z(*5)z(*e) ______ 1 1 f z(*i)z(*2) z(*4)z(*e)_____
i{*3=*4=0}1{j3=j4}Zj'i Zj2 zj5 Zje 1{*3=*5=0}i{j3=j5}Zj'i Zj2 Zj4 Zj'e
__1 , 1 , Z (*i )Z (*2)Z (*3)Z (*б) I
1{*4 = *5 =0}1{j4 =j5 }Zj'i Zj2 zj3 Zj6 +
+ 1{*i=*2=0}1{ji=j2}1{*3=*4=0}1{j3=j4}Cj^ ^ +
+ 1{*i=*2=0}1{j’i=j2}1{*3=*5=0}1{j3=j5}Cj'4 Cjg +
+ 1{*i=*2=0}1{j’i=j2}1{*4=*5=0}1{j4=j5}Cj'3 Cjg +
+ 1{*i=*3=0}1{ji=j3}1{*2=*4=0}1{j2=j4}Cj^ +
+ 1{*i=*3=0}1{j'i=j3}1{*2=*5=0}1{j2=j5}Zj'4 Zj'e +
+ 1{*i=*3=0}1{j'i=j3}1{*4=*5=0}1{j4=j5}Zj'2 Zj'g +
+ 1{*i=*4=0} 1{j'i=j'4} 1{*2=*3=0} 1{j'2=j<3} Zj5^ (je^ +
+ 1{*i=*4=0}1{j’i=j4}1{*2=*5=0}1{j2=j5}Zj'3 Zj'g +
+ 1{*i=*4=0}1{j'i=j4}1{*3=*5=0}1{j3=j5}Zj'2 Zj'g +
Electronic Journal. http://diffjournal.spbu.ru/ 118
Differential Equations and Control Processes, N. 1, 2021
+1{г1= + !{*! = + !{*! = + 1{*2 = + 1{*2 = + 1{*2 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 = + 1{*6 =
:*5=0}l{j'1=j5} 1{*2 = :*5=0}l{j'1=j5} 1{*2 =
=*5=0} 1{j1=j5} ±{*3=*4=0} ±{j3=.
h
:*3=0}1{j2:
=*4=0}1{j2: - 1 -f jo
:*3=0} 1{j2=j3} 1{*4 = :*4=0}1{j2=j4} h{*3 = :*5=0}1{j2=j5} h{*3 =
=*1=0} 1{j6=jl} h{*3=*4=0} 1{j3=.
h
=*5=0}1{j4: =*5=0}1{j3: =*4=0}1{j3: - 1 -T jo
:*1=0} 1{j6=j1} 1{*3 = :*1=0}1{j6=j'l} h{*2 = :*1=0} 1{j6=j1} 1{*2 =
=*1=0} 1{j6=j1} 1{*4=*5=0} 1{j4=.
h
=*5=0}1{j3:
=*5=0}1{j2:
=*4=0}1{j2: - l I j A
:*1=0} 1{j6=j1} 1{*2 = :*2=0} 1{j6=j2} 1{*3 = :*2=0} 1{j6=j2} 1{*4 =
=*2=0} 1{j6=j2} 1{*3=*4=0} 1{j3=.
h
=*3=0}1{j2: :*5=0}1{j3: =*5=0}1{j4: hj
:*2=0} 1{j6=j2} 1{*1 = :*2=0}1{j6=j2} h{*1 = :*2=0} 1{j6=j2} 1{*1 =
=*3=0} 1{j6=j3} 1{*2=*5=0} 1{j2=.
h
=*5=0}1{j1:
=*4=0}1{j1:
=*3=0}1{j1:
hj
:*3=0} 1{j6=j3} 1{*4 = :*3=0} 1{j6=j3} 1{*2 = :*3=0} 1{j6=j3} 1{*1 = :*3=0} 1{j6=j3} 1{*1 = :*3=0} 1{j6=j3} 1{*1 = :*4=0} 1{j6=j4} 1{*3 =
=*5=0}1{j4:
=*4=0}1{j2:
=*5=0}1{j1:
=*4=0}1{j1:
=*2=0}1{j1:
=*5=0}1{j3
Z (*4)z (*6) 1
=j3} Zj4 zj6 +
Z(*3)z(*6) I =j4}Zj3 Zj6 +
Z (*2)Z (*6) I =j4 } Zj2 Zj6 +
Z(*1)z(*6) i
=j5} Zj 1 j +
Z (*1)z (*6) _i_
=j5 } zj 1 Zj6 +
Z(*1)z(*6) I =j4 } Zj 1 Zj6 +
Z (*2)Z (*5) +
=j4 } Z j2 Zj5 +
Z (*2)Z (*4) I =j5} Zj2 Zj4 +
Z (*3)Z (*4) I
=j5} Zj3 Z j4 '
Z (*3)Z (*5) I
=j4} Zj3 Z j5 '
Z (*2)Z (*3)I
=j5} Zj2 Zj3 '
Z(*4) Z(*5) I
=j3} Zj4 Z j5 ^
Z (*1)Z (*4) I
=j5 } Zj 1 Zj4 ^
Z(*1)z(*3) I
=j5 } Zj 1 Zj3 ^
Z (*1)Z (*5) I
=j4 } Z j 1 Zj5 _l_
Z (*3)Z (*4) I
=j5} Zj3 Z j4 ^
Z (*3)Z (*5) I
=j4} Zj3 Z j5 '
Z(*4) Z(*5) I
=j3} Zj4 Z j5 ^
Z (*1)Z (*4) I
=j5 } Zj 1 Zj4 ^
Z (*1)Z (*2) I =j5 } Z j 1 Zj2 ^
Z (*1)Z (*5) I
=j4 } Z j 1 Zj5 ^
Z (*2)Z (*4) I =j5 } Z j2 Zj4 ^
Z (*2)Z (*5) I
=j4 } Z j2 Zj5 ^
Z(*4) Z(*5) I
=j2} Zj4 Z j5 ^
(*1) (*2)
=j5
Z (*1)Z (*2) I
'5}Zj1 Z j2 ^
Electronic Journal. http://diffjournal.spbu.ru/ 119
Differential Equations and Control Processes, N. 1, 2021
+ 1{*6=*4=0}1{j6=j4} 1{*2=*5=0}1{j2=j5}Cj1 Cj3 +
+ I{*6=*4=0}l{j6=j4} 1{*2=*3=0}1{j2=j3}Cj1 Cj'5 +
+ 1{*6=*4=0}1{j6=j4} 1{*1=*5=0}1{j1=j5}Cj2 Cj'3 +
+ 1{*6=*4=0}1{j6=j4} 1{*1=*3=0}1{j1=j3}Cj2 Cj'5 +
+ 1{*6=*4=0}1{j6=j4} 1{*1=*2=0}1{j1=j2}Cj3 Cj’5 +
+ 1{*6=*5=0}1{j6=j5} 1{*3=*4=0}1{j3=j4}Cj1 Cj'2 +
+ 1{*6=*5=0}1{j6=j5} 1{*2=*4=0}1{j2=j4}Cj1 Cj3 +
+ 1{*6=*5=0}1{j6=j5} 1{*2=*3=0}1{j2=j3}Cj1 Cj4 +
+ 1{*6=*5=0}1{j6=j5} 1{*1=*4=0}1{j1=j4}Cj2 Cj’3 +
+ 1{*6=*5=0}1{j6=j5} 1{*1=*3=0}1{j1=j3}Cj’2 Cj4 +
+ 1{i6=*5=0}1{j6=j5}1{*1 = *2=0}1{j1=j2}Cj3 Cj’4 —
h
{*6 = *1=0}1{j6=j'l} 1{*2=*5=0} ±{j2=j5} Х{*3=*4=0} ±{j3=j4} ' " 1{*6 = *1=0} 1{j6=j1} 1{*2=*4=0} 1{j2=j4} 1{*3=*5=0} 1{j3=j5} " "1{*6 = *1=0}1{j6=j’l}1{*2=*3=0}1{j2=j3}1{*4=*5=0}1{j4=j5}" '1{*6 = *2=0}1{j6=j2}1{*1=*5=0}1{j'l=j5}1{*3=*4=0}1{j3=j4}' '1{*6 = *2=0}1{j6=j2}1{*1=*4=0}1{j'l=j4}1{*3=*5=0}1{j3=j5}' "1{*6 = *2=0}1{j6=j2}1{*1=*3=0}1{j'l=j3}1{*4=*5=0}1{j4=j5}" '1{*6 = *3=0}1{j6=j3}1{*1=*5=0}1{j'l=j5}1{*2=*4=0}1{j2=j4}' '1{*6 = *3=0}1{j6=j3}1{*1=*4=0}1{j'l=j4}1{*2=*5=0}1{j2=j5}' "1{*3 = *6=0}1{j3=j6}1{*1=*2=0}1{j'l=j2}1{*4=*5=0}1{j4=j5}" 'I{*6 = *4=0}1{j6=j4}1{*1=*5=0}1{j'l=j5}1{*2=*3=0}1{j2=j3}' 'I{*6 = *4=0}1{j6=j4}1{*1=*3=0}1{j'l=j3}1{*2=*5=0}1{j2=j5}' "1{*6 = *4=0}1{j6=j4}1{*1=*2=0}1{j'l=j2}1{*3=*5=0}1{j3=j5}" ' 1{*6 = *5=0} 1{j6=j5} 1{*1=*4=0} 1{j'l=j4} 1{*2=*3=0} 1{j2=j3} ' '1{*6 = *5=0}1{j6=j5}1{*1=*2=0}1{j'l=j2}1{*3=*4=0}1{j3=j4}'
h
h
- 1 -f jo
"1{*6=*5=0}1{j6=j5}1{*1=*3=0}1{j'l=j3}1{*2 = *4=0}1{j2 =j4} I ,
(40)
Electronic Journal. http://diffjournal.spbu.ru/ 120
Differential Equations and Control Processes, N. 1, 2021
where 1A is the indicator of the set A.
A detailed discussion of advantages of the method based on Theorem 1 over the approximation methods from works [2], [3], [7], [8], [27]-[35], [37]-[39] can be found in [26] (Section 1.1.10) or in [67].
As it turned out, Theorem 1 can be adapted for the iterated Stratonovich stochastic integrals (3) of multiplicities 1 to 5 [26], [67]-[69] (also see bibliography therein). Let as collect some of these results in the following theorem.
Theorem 2 [26], [67]-[69]. Suppose that {ф (x)}°=0 is a complete orthonormal system of Legendre polynomials or trigonometric functions in the space L2([t,T]). At the same time i2(s) is a continuously differentiable function on [t,T] and iff (s), 'фз(в) are twice continuously differentiable functions on [t,T]. Then
Pl P2
- (D/dk)
C j2jl Z
jl=0 j2=0 Pl P2 P3
Лф(3)Ь = hum. ^ ^ ^ Cjj 1 (ib i2, га = 0, 1,...,m),
Pl,P2,P3^^ 123
ji=0 j2=0 j3=0
(42)
^ Cj3j2ji Cj(il)Cj22)Cj(33) (гь г2, га = 1,...,m), (43)
J *
T,t =
LLm. ££Cj2nj1 j2 (ii,г2 = l,...,m), (41)
1 p 12
Pl ,P 2^^
J *
T,t = l.i.m.
P^-IXI
j1, j2 j3=0 P
J*[i(4)]t, t = Lhm. Cj4j3j2ji(гь ..., г4 = 0, 1,...,m),
j1,...,j4=0
(44)
P
J*0/,(5)l„ _ 1 \ ™ \ л ..piaffAffAffAffiA
T,t =
l.i.m. C
A(*im(*2m(*3m(*4m(*5)
j5j4j3j2j1 j j j j j (гl, . . . , г5 0 L . . . , m),
j1,...,j5=0
(45)
where J *[i(k)]T,t is defined by (3), and ф/ (s) = 1 (l = 1,..., 5) in (42),
(45); another notations are the same as in Theorem 1.
Consider the following Hypothesis on expansion of the iterated Stratonovich stochastic integrals (3) of arbitrary multiplicity k (k £ N).
Hypothesis 1 [26], [67], [68]. Assume that {ф(x)}°=0 is a complete orthonormal system of Legendre polynomials or trigonometric functions in the
Electronic Journal. http://diffjournal.spbu.ru/ 121
Differential Equations and Control Processes, N. 1, 2021
space L2([t,T]). Moreover, every ф1 (t) (l = 1,..., k) is an enough smooth nonrandom function on [t,T]. Then, for the iterated Stratonovich stochastic integral
(3) of multiplicity k the following expansion
P k
J *№<‘>b = lpi;m. E C..j П A (46)
ji,...jk =0 1=1
that converges in the mean-square sense is valid, where notations are the same as in Theorem 1.
Hypothesis 1 allows to approximate the iterated Stratonovich stochastic integral J*[^(k)]T,t by the sum
J *[Г’]У =
E Cv..ji П4“’’
ji,...jk=0 1=1
(47)
where
lim M JЧф(к’]т,, - J
p^><Xi
*U ,(k)| P T,t
= 0.
Assume that J[^(k)]T t is the approximation of (2), which is the expression in (33) before passing to the limit for the case p1 = ... = pk = p, i.e.
J
p
t, t =
ji,...,jk =0 1=1
Ы.
ji
u.m. j (tii )a4;)... j (Tik)Aw(;
r(ik ’
N—>00
(l;,...,lk )eGk
(48)
Let us denote
MJ
T,t
J
p
T,t
= EP,
IK
def
A([t,T ]k)
K 2(tb... ,tk) dt 1 ...dtk = Ik.
[t,T ]k
For the futher consideration, we need the following useful estimate [26], [67
EP <k! /k - E C?k„.ji
(49)
j1,...,jk =0
2
k
2
2
Electronic Journal. http://diffjournal.spbu.ru/ 122
Differential Equations and Control Processes, N. 1, 2021
where i1,... ,ik = 1,... ,m for T — t £ (0, to) and i1,..., ik = 0,1,... ,m for T — t £ (0,1); another notations are the same as in Theorem 1.
The value Ep can be calculated exactly.
Theorem 3 [26], [67], [70]. Suppose that the conditions of Theorem 1 are satisfied. Then
Ep = Ip — E x
ji,...,jh =0
{T t2
J[^(p)b E / j(tk)...f j(ti)dwt!l}...dwtlfc^, (50)
{ji,...,3k) t t
where ii, . . . , ik = 1, . . . , m; expression
E
(j 1 ,...,jk )
means the sum with respect to all possible permutations (jl,... ,jk). At the same time if jr swapped with jq in the permutation (jl,... ,jk), then ir swapped with iq in the permutation (il,..., ik); another notations are the same as in Theorem
1.
Note that
м|т[^(к)]т,^ j (tk) ...j Фп (ti)dw(il) ...dwtlk)| = Cjk ...ji.
Then from Theorem 3 we obtain
p
Ep = Ik — E Cj...j (i1, . . . ,ik are pairwise different), (51)
ji,.--,jk=0
Ep = Ik — Cjkj I Cjk...ji I (ii = ... = ik). (52)
j1,...,jk=0 (j1 ,.--,jk)
Consider some examples of the application of Theorem 3 (il,...,i5 =
1,... ,m):
pp
EP = I2 — E j — E C/2jiCjij (il = г2), (53)
jl,j2=0 j 1 ,j 2 =0
Electronic Journal. http://diffjournal.spbu.ru/ 123
Differential Equations and Control Processes, N. 1, 2021
P P
i2
j3,j2 ,j1=0 j3,j2,j1=0
E3 — h 53 Cj3j2ji 53 Cj3jij2Cj3j2ji — "2 — га),
PP 2
У j3j2j1
j3,j2 ,j'l=0 j3,j2,j1=0
El — ^3 Cj3j2jl E Cj2j3j 1 Cj3j2j1 (i1 — г2 — га),
PP 2
j3j2j1
j3,j2 ,j1=0 j3,j2,j1=0
El — 53 Cj3j2j1 53 Cj3j2j 1 Cj1 j2 j3 (i1 — га — г2),
P
EP — /4 - £ I E Cj4...j1
j1,--,j4=0 \(j1,j2)
(i1 — "2 — г4; га — г4^
EP — I4 - E Cj4...j1 I E Cj4...j1
j1,...,j4=0 \(j1,j3)
(i1 — "l — ^, г4; г2 — г4),
EP — /4 - E Cv.j I E Cj-4...j1
j1,...,j4=0 \(j2,j3)
(i2 — "l — i1, г4; г1 — "4^
E\ — /4 - E С,^ I E Cj4...j1
j1,...,j4=0 \(j1,j4)
(ii — "4 — ^,"a, "2 — "a),
rn — /4 - E c,4..,. I E I E с,4...,111 ("i — ч—"2—*a)i
j1,...,j4=0 \(j1,j4) \(j2,j3)
P
EP — /4 - E C,4...j1 I E C,4...j1 I ("1 — "2 — "a — "4),
j1,...,j4=0 \(j1,j2,j3)
j1
EP — /5 - E Cj5...j. I E Cj,...
j1,...,j5=0 \(j1,j2)
where "1 — "2 — "a, "4, "5 and "a, "4, "5 are pairwise different,
EP — /5 - E Cj5..j I E Cj5...
j1,...,j5=0 \(j2,j3)
j1
where "2 — "a — "1, "4, "5 and "1, "4, "5 are pairwise different,
(54)
(55)
(56)
(57)
(58)
(59)
(60) (61) (62)
(63)
(64)
Electronic Journal. http://diffjournal.spbu.ru/ 124
Differential Equations and Control Processes, N. 1, 2021
ji
E — /5 - с*..л I Cj-,...
j1,--,j5=0 (j4,j5)
where 24 = i5 — i\,i2,h and 21,22,23 are pairwise different,
(65)
EP = /5 - Cj-5...j, I I Cj5...ji
j1,--,j5=0 (j2,j4) (j3,j5)
(21 = 22 — 24 = 23 — 25 = ii).
(66)
2.4 Approximations of Iterated Ito Stochastic Integrals from the Numerical Schemes (11)—(16) Using Legendre Polynomials
This section is devoted to approximation of the iterated Ito stochastic integrals (6) of multiplicities 1 to 6 based on Theorem 1. At that we will use multiple Fourier-Legendre series for approximation of the mentioned stochastic integrals.
The numerical schemes (11)-(16) contain the following set (see (6)) of iterated Ito stochastic integrals
/(*1) T(il) T(il) /(*1*2) /(*1*2)
1(0)T,t, 1(1)T,t, T (2)T,t, T(00)T,V T(10)T,t,
/(*1*2*30*5) / (*1*2) /(*1*2) / (*1*2)
T(00000)T,t , T (02)T,t, T (20)T,t, T(11 )T,0
/(*1*2*3*4) /(*1*2*3*4) /(*1*2*3*4)
/(0001)T,t, /(0010)T,t, /(0100)T,t,
/(*1*2) T(01)T,t, T(i1i2i3) , /(000)T,t, T(i1i2i3i4) T(0000)T,t
T(i1i2i3) , /(100)T,t, T(i1i2i3) , /(010)T,t, T(i1 i2 i3) T(001)T,t
/ (*1*2*3*4) / (*1*2*3*4*5*6)
T (1000)^0 T(000000)T,t .
(67)
(68) (69)
Let us consider the complete orthonormal system of Legendre polynomials in the space L2([t,T])
Фj (x)
x - T±l)
T -1 Pj 2 T -1
j — 0,1, 2,...,
(70)
where Pj (x) is the Legendre polynomial
Pj(x)
1 dj 2j j! dxj
4Y>
L
Using Theorem 1 and well known properties of the Legendre polynomials, we obtain the following formulas for numerical modeling of the stochastic integrals (67)-(69) [26], [42]-[46], [58], [61], [67], [68], [70]-[72]
T(*1)
T(0)T,t
(71)
Electronic Journal. http://diffjournal.spbu.ru/ 125
Differential Equations and Control Processes, N. 1, 2021
T(*1) __
1(1)T,t _
(T - t)3/^„(i.)
i
r(*1) \ __r(
Z0 + Z3Zl )'
r(.i) (t —1)5/2
L(2 )T,t
r(*i) _ ^ ~> i A*.) i v “zv*.) i - z(
^' _ ' ' Zo + " Zl + 2^5Z'2
^iM^ An АСА
V3 z (i.) 2
-(ii)
i
-(ii)
T
(ii*2)q
(00)T,t
T - ‘'zW + E 1
*=1
л/4 i2 — 1
2л/б
(*i)z(*2) Z(ii)Z(*2M _ i r. ^ 1
i—1Zi Zi Zi —1 / 1{*i=i2} I ’
(72)
(73)
qi
T
-(iib(i2b(i3)
4*з)
(iii2*з)qi \ л c000 | z(ii)Z(i2)z(*з) I i ^ z(*з)
(000)T,t _ / V Cj3j2ji l Zji Zj2 Zj3 1{ii=i2}±{j'i=j2}Zj3
Jbj2,j3=0
___1 1 z(ii) I i z(i2)
1 {i2 =*3} X{j2=j3}zji 1 {i 1 = *3} X{j’i=j3}Zj2
(74)
(75)
T
(iii2)q2
(10)T,t
q2
EC 10 I Z (ii)Z (i2) 1 1 |
Cj2ji I Zji Z j2 1{ii=i2} 1{ji=j2} ’
T
(iii2)q2
(01)T,t
J1,J2=0
q2
EC 01 I Z (ii)Z (i2) 1 1 |
Cj2ji I Zji Zj2 1{ii=i2} 1{ji=j2} ’
JbJ2=0
(76)
(77)
T
(*1*2*з*4^з
(0000)T,t
q3
EC0000 I Z (*i) Z (i2) Z (*3)z (i 4)_
Cj4j3j2j1 I Zji Zj2 Zj3 Zj4
Jbj2,j3,j4=0
__1 1 f Z(i3)Z(i4) _______ 1 1 f Z(i2)Z(i4)______
1{ii=i2} 1{ji=j2}Zj3 Zj4 1{*1=*3} 1{ji=j3}Zj2 Zj4
—Is■ ■ i1r ■ ■ iZ(i2)Z(i3) — is■ ■ ■ ■ t,Z(ii)Z(i4) —
1{i1=i4} 1{ji=j4} Zj2 Z j3 1{*2=*3}1{?2=?3}Чп Zj4
— 1s ^ ^ \1r ■ ■ \Z(ii) Z(i3) — 1s ^ ^ i1r ■ ■ iZ (ii)Z (i2) +
1{*2=*4}1{?2=?4}Ул ■ 1 {*3 = *4 } 1 {^3=^4} Z■i ■ +
+ 1{*1=*2}1{31=32}1{*3=*4}1{33=34} + 1{*1 = *з} 1{?1=?’з} 1{i2=i4} 1{^2=^4} +
+ 1{i1 = i4} 1{ji=j4} 1 {*2 = *3} 1{j2=j3} ) ’
(78)
T
(*1*2*з*4*5^4
(00000)T,t
q4
C
00000 / ТТ z(i).
■5j4.73.72.711 X X ■
J1,J2,J3,J4,J5=0 Vl = 1
E
= (*зЕ(*4Е(*5) 1 1 Z(i2E(i4E(i5)
1 1 Z(*3)Z(i4) Z(i5) 1 1 Z(i2 ) Z(i4) Z
1{ii=i2} 1 {■ 1 = ■ 2} z ■з Eh Eh 1 {*1=*з} 1{Ji=j3} Eh E'4 Z.
■5
Electronic Journal. http://diffjournal.spbu.ru/ 126
Differential Equations and Control Processes, N. 1, 2021
+ l{i + l{i + l{i + l{i + l{i + l{i
+ 1 i
1
1
1
1
= *2}1{j1: = *2} 1{j1: = *3}1{j1: = *4}1{j1 =
1 Z (*2)z (*s) _ 1 r. 1 Z (i2 ) Z (i3)z (*4)_
{*1 = *4 }1{j1=j4}Zj2 Zj3 Zj5 i{*1=*5}i{j1=j5}Zj2 Zj3 Zj4
1 f Z (i1)Z (i4) Z (i5) _ 1 1 f Z (i1)Z (i3)Z (i5)___
{*2 = *3 }1{j2=j3}Zj1 Zj4 Zj5 i{*2=*4}i{j2=j4}Zj1 Zj3 Zj5
1 Z (i1)Z (i3)Z (i4) __ 1 1 z (i1)Z (i2) Z (i5 )_
{*2 = *5 }1{j2=j5}Zj1 Zj3 Zj4 1{i3=*4} 1{j3=j4}Zj1 Zj2 Zj5
1 f Z (i1)Z (i2) Z (i4) _ 1 1 f Z (i1)Z (i2)Z (i3) I
{*3=*5}i{j3=j5}Zj1 Zj2 Zj4 i{*4 = *5}i{j4=j5}Zj1 Zj2 Zj3 +
1 1 Z (i5) I 1 , .1. , 1 . . 1 , Z (i4) I
=j2} 1{i3=i4} 1{j3=j4} Zj5 + 1{i1 = i2} 1{j1=j2} 1{i3=i5} 1{j3=j5} Zj4 +
1 1 Z (i3) 1111 Z (i5) I
=j2} 1{i4=i5} 1{j4=j5} Zj3 + 1{i1 = i3} 1{j1=j3} 1{i2=i4} 1{j2=j4} Zj5 +
1 1 Z (i4) I 1. 1 , 1 . . 1 , Z (i2) I
=j3} 1{i2=*5} 1{j2=j5} Zj4 ^ 1{i1 = *3} 1{j1=j3} 1{i4=*5} 1{j4=j5} Zj2 ^
1 1 Z (i5) I 1 , 1 , 1 . -1- Z (i3) I
=j4} 1{i2=i3} 1{j2=j3} Zj5 ^ 1{i1 = i4} 1{j1=j4} 1{i2=i5} 1{j2=j5} Zj3 ^
= *4}1{j1=j4}1{i3=i5}1{j3=j5} Zj2 ^ 1{*1 = *5}1{j1=j5}1{i2=i3}1{j2=j3} Zj4 ^
= *5} 1{j1: = *3} 1 {j2:
1 1 Z (i3) I 1. 1 , 1 . . 1 , Z (i2) I
=j5} 1{i2=i4} 1{j2=j4} Zj3 ^ 1{i1 = i5} 1{j1=j5} 1{i3=i4} 1{j3=j4} Zj2 _l_
1 1 Z (i1) I 1 . , 1 , , 1 . -1- Z (i1) I
=j3} 1{*4=*5} i{j4=j5} Zj1 ^ 1{i2 = i4} 1{j2=j4} 1{i3=i5} 1{j3=j5} Zj1 ^
_I_ 1 { *2 =*5 } 1 {j2 = j5 } 1 { *3=*4 } 1 {j3 = j4 } Z
(i1)
j1
(79)
I
(*1*2)95
(20)T,t
95
V C20 I Z(n)Z(*2) — 1 r. . , 1 r. -ii
/ V Cj2j1 1 Zj1 Z j2 i{*1=*2}i{j1=j2} h
I
(*1*2)96
(11)T,t
j1,j2=0
96
EC 11 I z (*1)Z (*2) 1 1 1
Cj2j1 I Zj1 Z j2 i{*1=*2}i{j1=j2}
I(*1 *2)q7 \ л C02 I Z(*1)Z(
1 (02)T,t _ Cj2jM Zj1 Zi
j1,j2=0
97
02 Z(*1)Z(*2)
j2j1 I Zj1 Zj2
1{*1=*2}1{j1=j2} I ,
j1,j2=0
1
(*1*2*3)98
(001)T,t
98
E
j1,j2,j3 0
C001 I z(*1)Z(*2)z(*3)
Cj3j2j1 I Zj1 Zj2 Zj3
1 1 Z (*3)
1{*1 = *2 }i{j1=j2}Zj3
__1 1 Z(*1) 1 1 Z(*2)
1{*2 =*3} i{j2=j3}Zj1 1{*1 = *3} i{j1=j3}Zj2
(80)
(81)
(82)
(83)
Electronic Journal. http://diffjournal.spbu.ru/ 127
Differential Equations and Control Processes, N. 1, 2021
T(*1*2*3)99
T(010)T,t
99
E
jbj2,j3=0
Coio I z(il)z(i2)г(*з)
Cj3j2j1 I zj 1 z j2 j
1 1 z(i3)
Х{*1 = *2 }i{j1=j2}Sj3
1 1 z (i1) 1 1 z(i2)
1{i2 =*3} 1{j2=j3} zj1 i{*1 = *3} i{j1=j3}zj2
(84)
t (*1*2*3)910 T(100 )T,t
910
E
j1,j2,j3=0
C100 I z(*i)z(*2)z(*3) _ 1 1 , z(*3)
Cj3j2j1 I zjl zj2 j i{*1=*2}i{j1=j2}zj3
1 1 z(*1) __________ 1 1 z(*2)
1{*2 =*3} 1{j2=j3} zji 1{*1 = *3} i{j1=j3}zj2
(85)
T
(*1*2*3*4)911 (0001)T,t
911
E
j 1,j 2 ,j3 ,j4 =0
C
0001
j4j3j2j1
z (*1)z (*2) z (*3)z (*4)_
zj1 j j j
__1 1 f z(*3)z(*4) 1 1 f z(*2)z(*4)
i{*1=*2}i{j1=j2}Sj3 j i{*1=*3}i{j1=j3}Sj2 j
1 1 z(*2)z(*3) 1 1 z(*1)z(*4)
i{*1=*4}i{j1=j4}Sj2 j i{*2=*3}i{j2=j3}Sj1 j
—1 ■ ■ E(*1)z(*3) — 1 • • x1( ■ . тz(*1)z(*2)+
X{*2=*4}X{j2=j4}Zj1 j X{*3 = *4}X{j3=j4}Zj1 j +
+1 {*1 =*2 } 1{j1=j2} 1 {*3=*4} 1{j3=j4} + 1{*1 = *3} 1{j1=j3} 1 {*2 =*4 } 1{j2=j4} +
+ 1{*1 = *4} 1{j1=j4} 1{*2 = *3} 1{j2=j3} I ,
(86)
T(*1*2*3*4)912 C0010 z(*1)z(*2)z(*3)z(*4)
T(0010)T.t / V Cj4j3 j2j1 I zj1 j j j
j 1 ,j2 ,j3 ,j4=0 V
1 1 z(*3)z(*4) 1 1 z(*2)z(*4)
'1{*1=*2} 1{j1=j2} zj3 j 1 {*1=*3} 1{j1=j3} zj2 j
1 * =* 1 j =j z(*2)z(*3) 1 * =* 1 j =j z(*1)z(*4)
'1{*1=*4} 1{j1=j4} zj2 zj3 '1{*2=*3} 1{j2=j3} zj1 j
___1 1 # z (*1) z (*3) 1 1 # z (*1)z (*2) I
1 {*2=*4} 1 {j2=j4} zj1 j -1{*3 = *4} j +
+1 {*1 =*2 } 1 {j1 =j2 } 1{*3=*4} 1{j3=j4} + 1{*1 = *3} 1{j1=j3} 1 {*2 =*4 } 1{j2=j4} 1
I1
{*1 = *4} 1{j1=j4} 1{*2 = *3} 1{j2=j3}
(87)
Electronic Journal. http://diffjournal.spbu.ru/ 128
Differential Equations and Control Processes, N. 1, 2021
T(*1*2*3*4)qi3
T(0100)T,t
qi3
E
j1,j2,j3,j4=0
C 0100
Cj4j3j2j1
Z (i1)Z (i2) Z (i3)Z (i4)_
E1 Zj2 ■ Zj4
—1 • • iL■ ■ T.Z(*3)Z(*4) — 1 • • Л;■ . iz(*2)Z(*4) —
X{*1=*2}X{j1=j2}Zj3 Z j4 X{*1=*3}X{j1=j3}Zj2 Z j4
__X X Z(i2)z(i3) ____x 1 Z(i1)Z(i4)___
X{*1=*4}X{j1=j4}Zj2 Z .3 X{*2=*3}X{j2=j3}Zj1 Zj4
—1 • • il ■ ■ iZ(n) Z(*3) — 1 • • T.1 ■ ■ тZ (n)Z (*2)+
X{*2=*4}X{j2=j4}Zj1 Z33 X {*3 = *4} X{^3=^4} Z^1 ■ +
+ X{*1=*2} X{.?1=.?2} X{*3=*4} X{.?3=.?4} + X{*1 = *3} X{.?1=.?3} X{*2=*4} X{.?2=.?4} +
+ X
{*1 = *4} X{j1=.?4} X{*2 = *3} X{.?2=.?3}
(88)
T
(*1*2*3*4)?14
(1000)T,t
914
, E
■ 1J2 J3j4=0
C1000 1 z (i1)z (*2) z (*3)z (*4)
C4.4„4„4. I S71 Z72 Z 73 Z74
■4.?3.?2.?1
___X X . Z(*3)z(*4) ________X X . Z(*2)z(*4)________
X{*1=*2}X{j1=j2}Z7з ZJ4 ■
___X X Z(*2)z(*3) __x X Z(*1)Z(*4)____
X{^1=^4}X{j1=j4}Z72 ■ X{*2=*3}X{j2=j3}Z7'l ZJ4
—1 • • il ■ ■ iZ(n) Z(*3) — 1 • • T.1 ■ ■ тZ (n)Z (*2)+
X{*2=*4}X{j2=j4}Z7l ■ X{*3 = *4}X{j3=j4}Z7l ■ +
+ X{*1=*2} X{.?1=.?2} X{*3=*4} X{.?3=.?4} + X{*1 = *3} X{.?1=.?3} X{*2=*4} X{.?2=.?4} +
+ X{*1 = *4}X{.?’1=.?4}X{*2 = *3} Х{92=.?3} I ,
(89)
915 / 6
T(*1*2*3*4*5*6)915 \ л c000000 I I I z(*i)
T (000000)T,t _ / J M 1 ■
■ 1J2 J3 J4 J5J6=0 V 1=1
X X . Z (*2)Z (*3)Z (*4) Z (*5)
X{j1=j6}X{*1=*6}Z72 Z 93 ■ ■
X X Z (*1)Z (*2) Z (*4) z (*5)
X{j3=j6}X{*3=*6}Z7'l ZJ2 ■ ■
X X r . Z(*1)Z(*2) Z(*3)Z(*4)
X{*5=*6} Eh ZJ2 ■ ■
X X . Z(*2)Z(*4) Z(*5)Z(*6)
■
X X . Z (*2)Z (*3)Z (*4) Z (*6)
X{j1=j5}X{*1=*5}Z72 ■ ■ ■
X x r. z (*1)Z (*3)Z (*5)Z (*6)
X{j2=j4}X{*2=*4}Z7'l ZJ3 ZJ5 ■
X X . Z (*1)Z (*3)Z (*4) Z (*5)
X{j2=j6}X{*2=*6}Z7'l ZJ3 ZJ4 ■
X X . Z (*1)Z (*2) Z (*3)Z (*5)
X{■ 4 = ■ 6} X{*4=*6} Z■ 1 ZJ2 ■ ■
X X . Z (*3)Z (*4) Z (*5)Z (*6)
ХШ=.ЫХ{*1=*2}Е3 ■ ■ Ч?6
X X . Z(*2)Z(*3)Z(*5)Z(*6)
X{■ 1 = ■ 4} X{*1=*4} Z■ ■ 8?6
X X . Z (*1)Z (*4) Z (*5)z (*6)
X{j2=j3}X{*2=*3}Z7'l ZJ4 ZJ5 8?6
X X . Z (*1)Z (*3)Z (*4) Z (*6)
X{j2=j5}X{*2=*5}Z7'l ■ ZJ4 Ч?6
Electronic Journal. http://diffjournal.spbu.ru/ 129
Differential Equations and Control Processes, N. 1, 2021
1
{j3:
+1{ji=j2 } X{*i + 1{jl=j2} 1{*i + 1{ji=j3} 1{ii + 1{ji=j4} 1{ii + 1{ji=j4} 1{ii +1{ji=j5 } 1{ii + 1 {j2 =j3 } X{*2 + 1{j2=j5} 1{i2 + 1{j6=ji} X{*6 + 1{j6=ji} 1{*6 + 1{j6=ji} 1{*6 + 1{j6=j2} 1{*6 + 1{j6=j2} 1{*6 + 1{j6=j2} 1{*6 + 1{j6=j3} 1{*6 + 1{j6=j3} 1{*6 + 1{j6=j3} 1{*6 + 1{j6=j4} 1{*6 + 1{j6=j4} 1{*6 + 1{j6=j4} 1{*6 + 1{j6=j5} 1{*6 + 1{j6=j5} 1{*6
1 Z(*i)z(*2) Z(*5) Z(*6) _ 1 1 Z(*i) Z(*2) Z(*4) Z(*6)_
=j4}X{*3=*4}Zji Zj2 Zj5 Zj6 X{j3=j5}X{*3=*5}Zji Zj2 Zj4 Zj6
__1 1 _ Z(*i)Z(*2) Z(*3)Z(*6) I
X{j4=j5}X{*4=*5}Zji Z j2 Zj3 Zj6 +
1 1 _ Z (*5) Z (*6) I 1 1 . 1 , -1- . Z (*4)Z (*6) I
=*2} 1{j3=j4} 1{*3=*4} Zj5 Zj6 + X{ji=j2} X{*i = *2} X{j3=j5} X{*3 = *5} Zj4 Zj6 +
1 1 Z(*3) Z(*6) I 1 1 1 1 Z(*5) Z(*6) I
=*2}X{j4=j5}X{*4=*5}Zj3 Zj6 ^ X{ji=j3}X{*i = *3}X{j2=j4}X{*2 = *4} Zj5 Zj6 ^
1 1 _ Z (*4) Z (*6) I 1 1 . 1 , -1- . Z (*2)Z (*6) I
=*3} X{j2=j5} X{*2=*5}Zj4 Zj6 _l_ X{ji=j3} X{*i = *3} X{j4=j5} X{*4 = *5} Zj2 Zj6 _l_
1 1 Z (*5) Z (*6) I 1 1 1 1 Z (*3)Z (*6) I
=*4}X{j2=j3}X{*2=*3}Zj5 Zj6 ^ X{ji=j4}X{*i = *4}X{j2=j5}X{*2 = *5} Zj3 Zj6 ^
1 1 _ Z (*2) Z (*6) I 1 1 . 1 , -1- . Z (*4)Z (*6) I
=*4} X{j3=j5} X{*3=*5}Zj2 Zj6 _l_ X{ji=j5} X{*i = *5} X{j2=j3} X{*2 = *3} Zj4 Zj6 ^
1 1 Z(*3) Z(*6) I 1 1 1 1 Z(*2) Z(*6) I
=*5}X{j2=j4}X{*2=*4}Zj3 Zj6 ' X{ji=j5}X{*i = *5}X{j3=j4}X{*3 = *4} Zj2 Zj6 '
1 1 _ z (*i) z (*6) I 1 .1. . 1 , , 1 . . Z (*i)Z (*6) I
=*3} X{j4=j5} X{*4=*5}Zji Zj6 _l_ X{j2=j4} X{*2 = *4} X{j3=j5} X{*3 = *5} Zji Zj6 ^
1 1 _ Z (*i) Z (*6) I 1 1 -1- . Z (*2)Z (*5) I
=*5} X{j3=j4} X{*3=*4}Zji Zj6 ^ X{j6=ji} X{*6 = *i} X{j3=j4} X{*3 = *4} Zj2 Zj5 ^
1 1 _ Z (*2) Z (*4) I - - - . Z (*3)Z (*4) I
=*i} X{j3=j5} X{*3=*5}Zj2 Zj4 ^ X{j6=ji} X{*6 = *i} X{j2=j5} X{*2 = *5} Zj3 Zj4 ^
1 1 _ Z (*3) Z (*5) I -1- - . Z (*2)Z (*3) I
=*i} X{j2=j4} X{*2=*4}Zj3 Zj5 ^ X{j6=ji} X{*6 = *i} X{j4=j5} X{*4 = *5} Zj2 Zj3 ^
1 1 _ Z (*4) Z (*5) I - - - . Z (*i)Z (*4) I
=*i} X{j2=j3} X{*2=*3}Zj4 Zj5 ^ X{j6=j2} X{*6 = *2} X{j3=j5} X{*3 = *5} Zji Zj4 '
1 1 _ Z (*i) Z (*3) I 1 .1. - . Z (*i)Z (*5) I
=*2} X{j4=j5} X{*4=*5}Zji Zj3 ^ X{j6=j2} X{*6 = *2} X{j3=j4} X{*3 = *4} Zji Zj5 ^
1 1 _ Z (*3) Z (*4) I - -1- . Z (*3)Z (*5) I
=*2} X{ji=j5} X{*i=*5}Zj3 Zj4 ^ X{j6=j2} X{*6 = *2} X{ji=j4} X{*i = *4} Zj3 Zj5 ^
1 1 _ Z (*4) Z (*5) I - - . Z (*i)Z (*4) I
=*2} X{ji=j3} X{*i=*3}Zj4 Zj5 ^ X{j6=j3} X{*6 = *3} X{j2=j5} X{*2 = *5} Zji Zj4 ^
1 1 _ Z (*i) Z (*2) I -1- - . Z (*i)Z (*5) I
=*3} X{j4=j5} X{*4=*5}Zji Zj2 ^ X{j6=j3} X{*6 = *3} X{j2=j4} X{*2 = *4} Zji Zj5 ^
1 1 _ Z (*2) Z (*4) I 1 1 - . Z (*2)Z (*5) I
=*3} X{ji=j5} X{*i=*5}Zj2 Zj4 ^ X{j6=j3} X{*6 = *3} X{ji=j4} X{*i = *4} Zj2 Zj5 _l_
1 1 _ Z (*4) Z (*5) I -1- - . Z (*i)Z (*2) I
=*3} X{ji=j2} X{*i=*2}Zj4 Zj5 ^ X{j6=j4} X{*6 = *4} X{j3=j5} X{*3 = *5} Zji Zj2 ^
1 1 _ Z (*i) Z (*3) I 1 , Z (*i)Z (*5) I
=*4} X{j2=j5} X{*2=*5}Zji Zj3 ^ X{j6=j4} X{*6 = *4} X{j2=j3} X{*2 = *3} Zji Zj5 ^
1 1 _ Z (*2) Z (*3) I - - . Z (*2)Z (*5) I
=*4} X{ji=j5} X{*i=*5}Zj2 Zj3 ^ X{j6=j4} X{*6 = *4} X{ji=j3} X{*i = *3} Zj2 Zj5 ^
1 1 _ Z (*3) Z (*5) I - - . Z (*i)Z (*2) I
=*4} X{ji=j2} X{*i=*2}Zj3 Zj5 ^ X{j6=j5} X{*6 = *5} X{j3=j4} X{*3 = *4} Zji Zj2 ^
1 1 _ Z (*i) Z (*3) I 1 . Z (*i)Z (*4) I
=*5} X{j2=j4} X{*2=*4}Zji Zj3 ^ X{j6=j5} X{*6 = *5} X{j2=j3} X{*2 = *3} Zji Zj4 ^
1 1 _ Z (*2) Z (*3) I 1 1 - . Z (*2)Z (*4) I
=*5} X{ji=j4} X{*i=*4}Zj2 Zj3 ^ X{j6=j5} X{*6 = *5} X{ji=j3} X{*i = *3} Zj2 Zj4 _l_
I 1 1 1 1 _ Z (*3 )Z (*4)_
^ X{j6=j5} X{*6=*5} X{ji=j2} X{*i = *2}Zj3 Zj4
Electronic Journal. http://diffjournal.spbu.ru/ 130
Differential Equations and Control Processes, N. 1, 2021
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
{j6=j’i}1{*6
{j6=j’i}1{*6
{j6=ji}1{*6
{36=j2}1{*6
=*1}1{j2 = =*1}1{j2 = =*l}1{j2 = =*2}1{j1 =
{36=j2}1{*6=*2}1{j’l = {36=j2}1{*6=*2}1{j’l =
{36=33}1{*6=Ы ±{j1=j5} ±{*1=*б} ±{j2=j4} ±{*2 = *4}
1
=j5}1{*2 = =34}1{*2 = =33}1{*2 = 35}1{*1 = 34}1{*1 =
=33}1{*1 = 1
=*5}1{j3 = :*4}1{j3 = =*3}1{j4 = =*5}1{j3 =
34}1{*3 = *4 }" j5}1{*3 = *5 }" j5} 1{*4 = *5 } j4}1{*3 = *4 }"
=*4}1{j3=j5}1{*3 = *5 }" =*3}1{j4=j5}1{*4 = *5 }"
1
1
{36=j3}1{*6 {33=j6}1{*3 {36=j4}1{*6 {j6=j4} 1{i6
=*3}1{j’l = =*6}1{j1 = =*4}1{j1 = =*4}1{j1 =
{36=j4}1{*6=*4}1{j’l = {j6=j5}1{*6=*5}1{j1 =
{j6=j5}1{*6=*5} ±{j1=j2} ±{*1=*2} ±{j3=j4} Х{*3 = *4}
1
34}1{*1 = =32}1{*1 = 35}1{*1 = 33}1{*1 = =32}1{*1 =
34}1{*1 = 1
:*4}1{j2 = :*2}1{j4 = =*5}1{j2 = :*3} 1{j2 =
j5}1{*2 = *5 }" j5} 1{*4 = *5 } 33 } 1{*2 = *3 } j5}1{*2 = *5 }"
=*2} 1{j3=j5} 1{*3 = *5 } :*4} 1{j2=j3} 1{*2 = *3 }
1
1
1
{j6=j5}1{*6=*5}1{j1=j3}1{*1 = *3} 1{j2=j4}1{*2=*4}
(90)
where 1A is the indicator of the set A and
c000 _ V(2j1 + 1)(2j2 + 1)(2j3 + 1) (T _ , )3/2C000
Cj3j2jl 8 (T b) Cj3j2jl ’
C01 _ V(2j1 + 1)(2j2 + !) (T _ .)2C01
Cj2j1 8 (T t) Cj2j1 ’
C10 _ V(2j1 + 1)(2j2 + !) (T <)2C 10
Cj2j1 8 (T t) Cj2j1 ’
(91)
(92)
(93)
0000 _ л/(2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + !) (t _ ,)2C0000
‘34333231 _ 16 (T l) Cj4j3j2jl ’
(94)
C02 \/(2j1 + 1)(2j2 +T) ,T _ ,>3C.0'2
Cj2ji 16 (T О Cj23i ’
(95)
Electronic Journal. http://diffjournal.spbu.ru/ 131
Differential Equations and Control Processes, N. 1, 2021
c20 л/(2jl + 1)(2j2 + 1) (T _ ,)3C20
Cj2j1 _ IQ (T Cj2j1 ’
(96)
Cll _ \/(23l + 1)(2j2 + 1) (T _ ,)3cll cj2j1 16 (T b) Cj2j1 ’
(97)
C.
00l
j3j2j1
-y/(2jl + 1)(2j2 + 1)(2j3 + 1) (T_
t)5/2C^'
16
00l
j3j2j1 ,
(98)
C 0l0 -y/(2jl + 1)(2j2 + 1)(2j3 + 1) ,T_
<)5/2C
Cj3j2j1 _ 16 (T _ t) C
0l0,
j3j2j1 ,
(99)
C
l00
j3j2j1
V(2jl + 1)(2j2 + 1)(2j3 + !) (T _ t)5/2(C 16
l00,
j3j2j1 ,
(100)
C
00000
j5j4j3j2j1
\/(2jl + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + !)
32
(T _ t)5/2C
00000,
j5j4j3j2j1-
(101)
C oool ____ л/(2jl + 1)(2j2 + 1)(2j3 + 1)(2j4 + !) (T _ t)3c^000l (102)
j4j3j2j1
32
C ooio л/(2jl + 1)(2j2 + 1)(2j3 + 1)(2j4 + (T _ t)3C ooio (103)
j4 j3 j2 j 1
j3j2j1
32
CO™, _ ^ + 1)(2j2 + 1)(2j3 + 1)(2j4 (T _ t)3C'°™ , (104)
j4j3j2jl
32
C iooo ____ л/(2jl + 1)(2j2 + 1)(2j3 + 1)(2j4 + (T _ t)3C iooo (105)
j4 j3 j2 j1
j4j3j2j1
32
C
000000
j6j5j4j3j2j1
\/(2jl + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1)(2j6 + (T _ t)3C000000
64 (T l) Cj6j5j4j3j2j1 ’
(106)
Electronic Journal. http://diffjournal.spbu.ru/ 132
Differential Equations and Control Processes, N. 1, 2021
where
= / pj3(z) / Pj2 M / Pji {x)dxdydz,
-i -i -i
1 y
j = - I(1 + y)pj2 (yW pji (x)dxdy,
-1 -1 l y
Cj = - J Pj2 (y) J (1 + x)Pn (x)dxdy,
-1 -1
1 u z y
C0000„^ = f Pj4(u) f Pj3(z) f Pj2 (y) [ Pji(x)dxdydzdu,
j4j3j2ji
-1 -1 -1 -1
1 У
jji = У Pj2 (y)(y + 1)2 j Pji (x)dxdУ, -1 -1
1 У
Cjj = J Pj2 (y) J Pji (x)(x + 1 )2dxdy,
-1 -1
1 y
j = / Pj2(y)(y + 1) I Pji(x)(x + 1)dxdУ,
-1
1
-1
z y
= - I Pj3(z )(z + 1) I Pj2 (y) I Pji (x)dxdУdz, (114)
-1 -1 -1 1 z y
= - / j(z) I Pj2 (y)(y + 1) I Pji (x)dxdУdz, (115)
-1 -1 -1 1 z y
jL = - I j(z) I Pj2 (у) / Pji (x)(x + 1)dxdydz, (116)
(107)
(108)
(109)
(110)
(111)
(112)
(113)
111
v u
= I Pj5 И / Pj4 (u) / Pj3 (z) I Pj2 (y) I Pji (x)dxdУdzdudv, (117)
-1 -1 -1 -1 -1
1
y
z
1
y
z
Electronic Journal. http://diffjournal.spbu.ru/ 133
Differential Equations and Control Processes, N. 1, 2021
c 1000
Cj4j3j2 j 1
c 0100
Cj4j3j2j'l
1 u z y
I pj4(u) J pj(z) J pj2(y) pji(x)(x + 1)dxdydz, (118)
-1 -1 -1 -1
1 u z y
j Pj4 (U) j Pj3 (Z )j Pj2 (У)(У + 1) Pjl (x)dxdУdz, (119)
1 1 1 1
C 0010
Cj4j3 j2j'l
1 u z y
pj4(u) pj3(z )(z + 1) pj2 (y) pji (x)dxdУdz, (120)
11
11
= - pj4 (U)(U +1W pj3 (z ) / pj2 Ы / pj1 (x)dxdydz, (121)
1
11
1
000000 _
j6j5j4j3j2jl _
u z
1 w v u z y
= pAM pj5(v) j (u) pj3 (z) pj2(y) pji (x)dxdydzdudvdw\
1 11111
(122)
another notations are the same as in Theorem 1.
1
y
u
z
2.5 Optimization of Approximations of Iterated Ito Stochastic Integrals from the Numerical Schemes (12)—(16)
This section is devoted to the optimization of approximations of iterated Ito stochastic integrals from the numerical schemes (12)-(16). More precisely, we discuss how to minimize the numbers q, q1, q2,..., q15 from Section 2.4.
Suppose that £ > 0 is the mean-square accuracy of approximation of the iterated Ito stochastic integrals (6), i.e.
E(*i...*fc)p _f
E(h...lk)T,t _
M
I (i 1 -..i k) J(li...lk )T,t
I(ii...*k )p 2
J(li...lk )T,t
< £,
where 1((/11"/ifck))pt, P £ N is the approximation of the iterated Ito stochastic integral 1((li11"/ifck))Tt. Then from (74) and (49) we obtain the following conditions
Electronic Journal. http://diffjournal.spbu.ru/ 134
Differential Equations and Control Processes, N. 1, 2021
for choosing the numbers q,q\,q2,..., q15 for approximations of the iterated Ito stochastic integrals (67)-(69) [26], [67]
d*i*2)q _ (T t)2 ( 1
2(00)T,t _ 2
q
1
(Ъ1Ъ2)Ч
~ 2 4i2 — 1
- e,
E (*i*2*3)qi 6 ■
E(000)T,t < 6 6
i=1 qi
CSE2 < e,
j1 ,j2 ,j3 =0
E616^2 ^ (T t)
4 q2
(0i)T,t - - \ 4
E (iii2)q2 2 (T — t)
E(10)T,t < 2 12
(T — t)4
Cj)2 - e,
j1,j2=0
q2
j,)2 - e,
j1,j2=0
E(ii...i4)q3 24
E(0000)T,t < 24
E (ii ...i5 )q4 120
E(00000)T,t < 120
q3
24
(T — t)5 120
E (iii2)q5 2 (T — t)6
E(20)T,t < 2 30
E (iii2)q6 2 (T — t)6
E(ii)T,t < 2 18
E (iii2)qr 2 (T — t)6
E(02)T,t < 2 6
(*ii2*3)qe
E(001)T,t < 6 10
(*li2*3)q9
E(010)T,t < 6 20
(iii2i3)qi0 ■
E(100)T,t <6 60
E (CSE) d - e,
j1,j2,j3 ,j4 0
q4
E/C00000 2
Cj5j4j3j2j1 <
j1 ,j2 ,j3 ,j4 ,j5=0
q5
Cj2 - e,
j2jl=°
q6
CE2 - e,
j2,j1=0
q7
Cj2 - e,
j2,j1=0
qs
2 - e,
j1,j2,j3 =0
q9
j0j.)2 - e,
j1,j2,j3 =0
q10
E (CE) d - e,
j1,j2,j3 0
(123)
(124)
(125)
(126)
(127)
(128)
(129)
(130)
(131)
(132)
(133)
(134)
e
Electronic Journal. http://diffjournal.spbu.ru/ 135
Differential Equations and Control Processes, N. 1, 2021
E (*i...*4)qn 24
E(0001)T,t — 24
(T -t)6 36
y0001 \2
j4 j3 j2 j 1
j1 ,j2 ,j3 ,j4=0
— E
E (*i...*4)qi2 24
E(0010)T,t — 24
(T -t)6 60
y0010 \2
j4 j3 j2 j 1
j1,j2 ,j3 ,j4=0
— E
E (*i...*4)qi3 24
E(0100)T,t — 24
(T -t)6 120
y0100 \2
j4 j3 j2 j 1
j1,j2 ,j3 ,j4=0
— E
E (*1...*4)q14 24
E(1000)T,t — 24
(T -t)6 360
y1000 \2
j4 j3 j2 j 1
j1,j2 ,j3 ,j4=0
— E
(135)
(136)
(137)
(138)
E (*1...*e)q15 E(000000)T,t
720
(T -t)6 720
E
j1 ,j2 J3j4 ,j5 ,j6
(C
j6j5j4j3 j2jb
2
0
£.
(139)
Taking into account (17) and (91)-(122), (123)-(139), we obtain the following conditions for choosing the numbers q,q1,q2,... ,q15 for the numerical schemes (12)-(16) (constant C is independent of T -t (see below)).
Milstein scheme (12)
1 1 2 2
E 4^ — C(T - ‘).
*=1
Strong Taylor—Ito scheme (13) with convergence order 1.5
6
1
6
1 1 2 2
1
— C(T - t)2,
1
64
q1
E (2 j1 + 1)(2j2 + 1)(2j3 + 1) (jE)
j1,j2,j3=0
— C(T-t). (140)
Strong Taylor—Ito scheme (14) with convergence order 2.0
1 1 2 2
i=1
1
4i2
1
— C(T - t)3,
Electronic Journal. http://diffjournal.spbu.ru/ 136
Differential Equations and Control Processes, N. 1, 2021
6
24
6
24
1 1
6 - 64
qi
E (2л + 1)(2j2 + 1)(2j3 + 1) (Cj )2 ) < C (T -1)2, (141)
jbj2,j3=0
11
q2
21 4 - 64 (2jl + 1)(2j2 + 1) j2 < C(T - t),
j1,j2=0
11
q2
2'^ - 64 (j + 1)(2j2 + 1) j2 < C (T - t),
j1,j2=0
(142)
(143)
11
q3
УУ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (C200O(5'J ) <
24 256
j1,...,j4=0
< C(T - t).
(144)
Strong Taylor—Ito scheme (15) with convergence order 2.5
1 1 q 1
Ёттг^-1 < C(T - t)\
М2 4i2 - 1
i = 1
1 1
6 - 64
q i
E (2ji + 1)(2j2 + 1)(2j3 + 1) (jj)2 < C(T - t)3, (145)
j1j2 j3=0 11
q2
2 1 - ((4 E (2ji + 0(2?2 + 1) (j)2 < C(T - t)\ (l46)
4 64
11
j1,j2=0 q2
2 4; - (1т E 0У1 + 1)(2j2 +1) j)2 < C(T -1)2, (147)
12 64
j1,j2=0
11
q3
24 256
УУ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) ((Cj)40)O(j'J ) <
j1,...,j4=0
< C(T - t)2,
(148)
11
qs
6
S (2ji +1)(2j2 +1)(2j3 +1) (jj <
10 256
j1,j2,j3=0
< C(T - t),
(149)
Electronic Journal. http://diffjournal.spbu.ru/ 137
Differential Equations and Control Processes, N. 1, 2021
6
24
1 1
20 256
(1 1
60 256
1 1
120 322 .
99
(2j1 + l)(2j2 + l)(2j3 + 1) (jj <
j1j2j3=0
< C(T - t), (150)
910
(2jl + 1)(2j2 + 1)(2j3 + 1) ( <
j1j2j3=0
< C(T - t), (151)
94
1201 T^r - (2ji + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1)x
j1,...,j5=0
x (CO0‘*)2) < C(T -1).
(152)
Strong Taylor—Ito scheme (16) with convergence order 3.0
9
1 1 1
1 £ -r^l < C(T -1)5,
М2 4i2 - 1
i = 1
1 1
6 - 64
91
£ (2ji + 1)(2j2 + 1)(2j3 + 1) (CO30L) < C(T - t)4, (153)
j1 j2 j3=0
214 i £ (2л + 1)(2j2 +1) (j )2) < C(T -1)3.
j1,j2=0
11
92
2'^ - 64 (2Л + 1)(2j2 + 1) 2 < C(T - t)3.
j1,j2=0
(154)
(155)
11
93
УУ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) ) <
24 256
j1,..),j4=0
< C(T - t)3,
(156)
11
98
6
X] (2jl + 1)(2j2 + 1)(2j3 + 1) (jj <
10 256
j1 j2 j3=0
< C(T -1)2,
(157)
Electronic Journal. http://diffjournal.spbu.ru/ 138
Differential Equations and Control Processes, N. 1, 2021
6 (20 - 256 £ (2j1 + 1)(2j2 + 1)(2j3 + ^ ) -
V jl,j2,j3=0 /
- C(T - t)2,
/11 910 \
Мб0 - 256 £ (2j1 + 1)(2j2 + 1)(2j3 + 1) (jj )-
V j1,j2,j3=0 /
- C(T - t)2,
(158)
(159)
120
1
120
94
322
(2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1)x
j1,...,j5=0
1
2
2
2
1
30
1
18
6
1
256
1
256
1
256
.. I i00000
X lCj5...j1
95
■ £ (2j1 +1)(2j2 +1) (CSJ
j1,j2=0
96
■ £ (2j1 +1)(2j2 +1) (Cj2j 1)
j1,j2=0
97 ^
£ (2j1 + 1)(2j2 + 1) (CjSl)
j1,j2=0 2
Г - C(T - t)2,
- C(T - t),
- C(T - t),
- C(T - t),
(160)
(161)
(162)
(163)
24
1
36
24
1
60
24
1
120
1 911 \
322 £ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (Cj4[)0jJ j -
j1 ,)..,j4=0 /
- C(T - t), (164)
1 912 \
322 £ (2j1 + 1)(2j2 + 1)(2j3 +1)(2j4 + 1) (Cj4')101) j-
j1 ,)..,j4=0 /
- C(T - t), (165)
1 913 \
322 £ (2j1 + 1)(2j2 +1)(2j3 +1)(2j4 + 1) (j.j j-
j1, . . . ,j4 =0 /
- C(T - t), (166)
Electronic Journal. http://diffjournal.spbu.ru/ 139
Differential Equations and Control Processes, N. 1, 2021
24
1 1
qi4
УУ (2j1 +1)(2j2 +1)(2j3 +1)(2j4 + 1) (С)™1 <
360 322
720
11
3lvj4 =0
qi5
< C(T - t),
(167)
720 642
У^ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1)(2j6 + 1)x
31 ■ ■ ■ J6=°
x (3T)2 < C(T - t).
(168)
Taking into account Theorem 3 and the results of Listings 5 and |6 (see Section 5) we decided to exclude the multiplier factors k! from the left-hand sides of (140), (141)-(144), (145)-(152), (153)-(168). The detailed numerical confirmation of the mentioned possibility can be found in [73]. This means that we will use the following conditions for choosing the numbers q,q1,q2,... ,q15 for the numerical schemes (12)-(16) (constant C is independent of T — t (see below)).
Milstein scheme (12)
11
q
£
1
М2 4i2 — 1
i=1
< C(T — t).
(169)
Strong Taylor—Ito scheme (13) with convergence order 1.5
1 1 — у y_
2 2 4i2 — 1
i=1
< C(T — t)2,
(170)
1 1
6 — 64
qi
£ (2j1 + 1)<2J2 + 1)(2j3 + 1) (C0L)2 < C(T — t). (171)
3b32j3=0
Strong Taylor—Ito scheme (14) with convergence order 2.0
11 — у !_
2 2 4i2 — 1
i=1
< C(T — t)3,
(172)
1 1
6 — 64
qi
£ (2j1 + 1)(2j2 + 1)(2j3 + 1) (C3 )2 < C(T — t)2, (173)
3i,32,33 =0
Electronic Journal. http://diffjournal.spbu.ru/ 140
Differential Equations and Control Processes, N. 1, 2021
1 1 42
4 - й E (2ji + l)(2j2 + 1) (C,)2 < C(T - t), (174)
,'l,2=0
11 42
E (2ji + 1)(2J2 + 1) (C,)2 < c(T - t) (Г75)
,'l,2=0
11 43
24 - ^ E (2ji + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (CT,,.)2 < C(T-1). (176)
,'lv,4=0
Strong Taylor—Ito scheme (15) with convergence order 2.5
1 1 _ 4 1
E 4i^l < c(T -1)4,
2 \ 2 4i2 - 1
i = 1
(177)
1 1
6 - 64
qi
E (2ji + 1)(2j2 + 1)(2j3 + 1) (Cj. )2 < C (T - t)3, (178)
1 1
j 1,2,3 ="
1 1
4 - 64
1 1
12 - 64
43
42
E (2ji + 1)(2j2 + 1) (C,)2 < C(T - t)2,
,'l,2=0
42
E (2ji + 1)(2j2 + 1) (C2,1 )2 < c(T - t)2,
(179)
(180)
j1,2=0
E (2ji + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (C”™)2 < C(T-1)2, (181)
24 256
1 1
10 256
1 1
20 256
1 1
60 256
1 1
120 322
,'lv,4=0 48
E (2ji + 1)(2j2 + 1)(2j3 + 1) (C,)2 < C(T - t), (182)
,’l,2,3=0
49
E (2ji + 1)(2j2 + 1)(2j3 + 1) (<30,2< C(T - t), (183)
,’l,2,3=0
410
E (2ji + 1)(2j2 + 1)(2j3 + 1) (C,)2 < C(T - t), (184)
,’l,2,3=0
44
(2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1) (C,500°0) <
,'lv,5=0
< C(T - t), (185)
Electronic Journal. http://diffjournal.spbu.ru/ 141
Differential Equations and Control Processes, N. 1, 2021
Strong Taylor—Ito scheme (16) with convergence order 3.0
q
<C(t-t)i
М2 4 i2 - 1
i = 1
(186)
1 1
6 - 64
q i
E (2ji + 1X2.72 + 1)(2j3 + 1) (Cj )2 < C(T -t)4, (187)
11
jbj2,j3 =0
1 1
4 - 64
1 1 12 - 64
q3
q2
E (2ji + 1)(2j2 + 1) (C0ji)2 < C(T - t)3,
j1,j2=0
q2
E (2ji + 1)(2j2 + 1) (Cj)2 < C(T - t)3,
(188)
(189)
j1,j2=0
E (2ji + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (jj )2 < C(T -1)3, (190)
24 : 256
jlv
1 1
10 256
1 1
20 256
1 1
60 256
1 1
120 322
qs
E (2ji + 1)(2j2 + 1)(2j3 + 1) (Cj)2 < C(T - t)2, (191)
j’l,j2,j3=0
qo
E (2л + 1)(2j2 + 1)(2j3 + 1) (COj < C (T - t)2, (192)
j’l,j2,j3=0
qio
E (2л + 1)(2j2 + 1)(2j3 + 1) (C?j3j°2j,)2 < C(T - t)2, (193)
j’l,j2,j3=0
q4
УУ (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1) (j^)
<
jlv,j5=0
1 1
30 256
1 1
18 256
1 1
6~ 256
< C(T - t)2,
q5
E (2Л + 1)(2j2 + 1) (Cjj)2 < C(T - t),
jl,j2=0
qe
E (2л + 1)(2j2 + 1) (Cj)2 < C(T - t),
jl,j2=0
47
(2ji + 1)(2j2 + 1) (C?°2jJ2 < C(T - t),
jl,j2=0
(194)
(195)
(196)
(197)
Electronic Journal. http://diffjournal.spbu.ru/ 142
Differential Equations and Control Processes, N. 1, 2021
1 1 q11
36 - 322 + 1)(2j2 + 1)(2j3 + l)(2j4 + 1) (C2j)4(0OjJ - C(T-t), (I98)
j1,...,j4=0 1 1 qi2
60 - 322 (2j1 +1)(2j2 + 1)(2j3 + 1)(2j4 + 1) — C(T - t), (199)
j1,...,j4=0
1 1 q13
120 - 322 (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) (j.j - C(T-t), (200)
j1,...,j4=0 1 1 q14
360 - 322 (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1) - C (T -t), (201)
j1,...,j4=0 1 1 q15
720 - 642 (2j1 + 1)(2j2 + 1)(2j3 + 1)(2j4 + 1)(2j5 + 1)(2j6 + 1)x
ji,...,j6=0
x (jj0)2 - C (T - t). (202)
2.6 Approximations of Iterated Stratonovich Stochastic Integrals from the Numerical Schemes (24)—(28) Using Legendre Polynomials
This section is devoted to approximation of the Stratonovich stochastic integrals (20) of multiplicities 1 to 6 based on Theorem 2 and Hypothesis 1. At that we will use multiple Fourier-Legendre series for approximation of the mentioned stochastic integrals.
The numerical schemes (24)-(28) contain the following set (see (20)) of iterated Stratonovich stochastic integrals
I*(*1) I*(*1) J(0)T,t, J(1)T,t 1 *(*1) , 1 (2)T,t, 1 *(*1*2) ^TO)^ 1*(*1*2) J(10)T,t
I*(*1*2*3*4*5) 1 (00000)T,t , 1 *(*1*2) 1 (02)T,t, 1 *(*1*2) 1 (20)T,t, 1 *(*1*2) J(11)T,t,
I *(*1*20*4) WnPon) WnPon)
J(0001)T,t , J(0010)T,t , J(0100)T,t ,
i*(* 1*2) i*(* 1*2*3) I * (* 1 i 2 *3 *4) (203)
J(01)T,t, J(000)T,t , J(0000)T,t , (203)
I *(*1*2*3) I *(*1*2*3) r*(*1*2*3) (204)
J(100)T,t , J(010)T,t , J(001)T,t , (204)
1*(*1*2*3*4) r*(*1*2*3*4*5*6) (205)
J(1000)T,t , J(000000)T,t . (205)
Using Theorem 2, Hypothesis 1, and well known properties of the Legendre polynomials, we obtain the following formulas for numerical modeling of the stochastic integrals (203)-(205) [26], [42]-[46], [58], [61], [67]
'68], [70]-[72]
I *(*1)
>)T,t
y/T—zt'K
(206)
Electronic Journal. http://diffjournal.spbu.ru/ 143
Differential Equations and Control Processes, N. 1, 2021
I *(*1*2)9 i (00 )T,t
i*(* i) _
J(1)T,t _
(T - t)3/^„(i.)
1
/4*1) i /4
Zo + 43Zl )’
_ (T -1)5/2
L(2)T,t
izu. = i c0!l) + -yd'1' + ttNz2
V3 j{
('1)
('1)
1
('1)
2л/5
T - 1 t z(*i)z('2) + ^ 1 />(*i)z('2) z(*i)z(*2)
z0 z0 + / j ^ :т V z*-1z* z* z*-1
2 r° w Tii2-!
I*(*i*2*3)qi _ V"^ c000 z(*i)z(*2)z(*3)
i(000)T,t _ / V Cj3j2j1 471 zj2 zj3 ’
j1,j2,j3=0
92
i*(*1*2)92 \ л c 10 z(*i)z(*2)
i(10)T,t _ 2-^ Chk 471 zj2 ’
ji,j2=0
92
i*(*1*2)92 \ л c01 z(*i)z(*2)
i(01)T,t _ 2-^ Chk 471 zj2 ’
ji,j2=0
93
i(*i*2*3*4)93 \ л c0000 z(*i)z(*2)z(*3)z(*4)
i(0000)T,t _ / J Cj4j3j2ji 471 zj2 zj3 zj4 ’
ji,j2,j3,j4=0
94
i (*i*2*3*4*5)94 \ л c00000 z (*i) z (*2 ) z (*3)z (*4)z (*5)
i(00000)T,t _ / V Cj5j4j3j2ji 471 472 zj3 zj4 zj5 ’
ji,j2,j3,j4,j5=0
95
i*(*i*2)95 _ C20 z(*i)z(*2)
i(20)T,t / V Cj2ji 471 zj2 ’
ji,j2=0
96
i(*i*2)96 __ \ л c 11 z(*i)z(*2)
i(11)T,t _ / v Cj2ji 471 472 ’
ji,j2=0
97
i(*i*2)97 _ c02 z(*i)z(*2)
i(02)T,t Cj2ji 471 472 ’
ji,j2=0
98
i*(*i*2*3)98 \ л c001 z(*i) z (*2) z(*3)
i(001)T,t _ / J cj3j2ji 47i 472 473 ’
ji,j2,j3=0
99
i(*i*2*3)99 \ л c010 z (*i)z (*2) z (*3)
i(010)T,t _ / J C7'3j2ji 471 472 473 ’
ji,j2,j3=0
(207)
(208)
, (209) (210) (211) (212)
(213)
(214)
(215)
(216)
(217)
(218) (219)
Electronic Journal. http://diffjournal.spbu.ru/ 144
Differential Equations and Control Processes, N. 1, 2021
qw
I(n*2*3)qio \ л c 100 z(*!)z
j (100)T,t _ Cj3j2ji Zjl Zj2 Zj3 ’
j1 ,j2 j3=0
qn
j(*1*2*3*4)qn _ V"^ c0001 z(i^Z(i2)z(i3)z(*4)
1 (0001)T,t _ Cj4j3j2jl Zjl zj2 Zj3 Z j4 ’
j1 ,j2 J3j4=0
qi2
j (*1*2*3*4)qi2 c0010 Z (*l) z (*2) z (*3)z (*4)
J(0010)T,t Cj4j3j2j1 zjl z j2 zj3 zj4 ’
j1,j2 ,j3 ,j4=0
qi3
j(*1 *2*3*4)qi3 __________ \ л c0100 z(*1)z(*2)z(*3)z(*4)
J(0100)T,t _ Cj4j3j2j1 zj1 zj2 zj3 z j4 ’
j1 ,j2 J3j4=0
q14
j (*1 * 2 * 3 * 4 ) q 14 _ \ л c 1000 z (*1) z (*2 ) z (*3)z (*4)
J(1000)T,t _ Cj4j3j2j1 zj1 zj2 zj3 z j4 ’
j1 ,j2 J3j4=0
q15
j(*1*2 *3*4*5*6^15 \ л C000000 z(*1)z(*2)z(*3)z(*4)z(*5)z(*6)
J(000000)T,t _ Cj6j5j4j3j2j1 zj1 z j2 zj3 z j4 zj5 j ’
j1 ,j2 J3j4j5 j6=0
(220)
(221)
(222)
(223)
(224)
(225)
where 1A is the indicator of the set A; another notations are the same as in Section 2.4.
The question on choosing the numbers q1 , q2 ,..., q15 in (210)-(225) turned out to be nontrivial [26] (Chapter 5). The expansions (210)-(225) for iterated Stratonovich stochastic integrals are simpler than their analogues (75)-(90) for iterated Ito stochastic integrals. However, the calculation of the mean-square approximation error for iterated Stratonovich stochastic integrals turns out to be much more difficult than for iterated Ito stochastic integrals [26] (Chapter 5). Below we give some reasoning regarding this problem.
Denote
E*(*1...*fc)p _f у j*(*1...*fc) _ j*(*1...*fc)p 2
E(h...ik)T,t _ M 1(h..h)T,t j(h...ik)T,t
where .^Tt, P £ N is the approximation of the iterated Stratonovich stochas-
tic rntegral /(С/А
From (209) for i1 _ i2 we obtain [26], [67
E *(*1*2)q E(00)T,t
(T - t)2 ^ 1
2 4i2 - 1
*=q+1
<
(T -1)2 1
2 4x2 -
q
1
dx _
Electronic Journal. http://diffjournal.spbu.ru/ 145
Differential Equations and Control Processes, N. 1, 2021
(T -t)2 8
ln
1
2
2 q + 1
< c , q
where constant C\ is independent of q.
(226)
It is easy to notice that for a sufficiently small T — t (recall that T — t ^ 1 since it is a step of integration for numerical schemes for Ito SDEs) there exists a constant C2 such that
Ec E*(*i*2)q E(h...lk)T,t < C2E(00)T,t •
(227)
From (226) and (227) we finally obtain
E *(*i-*fc )q E(ii...ifc )T,t
< c (T—7!, q
(228)
where constant C does not depend on T—t. The same idea can be found in [2] in the framework of the method of approximation of iterated Stratonovich stochastic integrals based on the trigonometric expansion of the Brownian bridge process.
Obviously, we can get more information about the numbers qi, q2,..., qi5 (these numbers are different for different iterated Stratonovich stochastic integrals) using the another approach. Since
J *
T,t
= J
T,t w. p. 1
for pairwise different i1,... ,ik = 1,... , m, where J[^(k)]T,t, J*[^(k)]T,t are defined by (2) and (3) correspondingly, then for pairwise different i1 ,...,i6 =
1,..., m from (51) we obtain [26], [67
E *(*i*2)q E(00)T,t
E *(*i*2*3)qi
E(000)T,t
E *(*02)92 E(01)T,t
E *(*1*2)42 E(10)T,t
(T -1)2
(T -1)3 6
(T -1)4 “ 4
(T -1)4 “ 12
1
2
1
5
qi
Ei c000 )2
VCj3j2j'i ,
j3,j2,j’i=0
92
- £ (c&)2,
ji,j2=0
92
- £ (Cj)2,
ji,j2=0
(229)
(230)
(231)
(232)
Electronic Journal. http://diffjournal.spbu.ru/ 146
Differential Equations and Control Processes, N. 1, 2021
E
s(*i...*4)q3 _ (T -1)‘
13
E
(oooo )T,t 24
(*1...*б)14 _ (T — t)5
(00000)T,t
E
120
Etc 0000 \2
V £74030201/ ’
0b02j3,04=0
14
E(c00000 ) 2
£05*4 *3*201/ ’
E
E
£*1*2)15 (T — t)6
(20)T,t _ 30
£*1*2)16 (T — t)6
(11)T,t _ 18
£*1*2)17 (T — t)6
(02)T,t _ 6
j1,j2,j3,j4,j5=0 15
£ (£)2.
02 ,01=0
16
£ (0)2.
02 ,01=0
E
*(*1*2*3)18 _ (T — t)5
E
(001)T,t io
(*1*2*3)19 _ (T — *)5
- £ (0)2,
02 ,01=0
18 ( )
E(C 001 )2
£030201/ ’
0b02j3=0
19 )
010 )2
(010)T,t
E
E/C010 у
\C030201/ ’
j1,j2,j3=0
(*1*2*3)110 _ (T — t)5 110
(100)T,t
60
E
*(*1 ...*4)111 _ (T — t)
E
E
(0001)T,t 36
*(*1 ...*4)112 (t -t)6
(0010)T,t 60
*(*1 ...*4)113 _ (T — t)
E/c 100 \2
£030201/ ’
01,02,03 =0
111 ( )
E(c0001 )2
lc0403020'j ’
01,02,03,04=0
112 ( )
E(c0010 )2
£04030201/ ’
01,02,03,04=0
6 £3 2
0100 2
E
(0100)T,t 120
E*(*1 ...*4)114 _ (T — t)6
E(1000)T,t _ 360
*(*1...*6)115 _ (T — t)6
(000000)T,t
720
E/c0100 \ 2
£04030201/ ’
01,02,03,04=0
114 ( )
E(c 1000 )2
c04030201
01,02,03,04=0
115 ( )
£060504030201/ ■
01,02,03,04,05J6=0
(233)
(234)
(235)
(236)
(237)
(238)
(239)
(240)
(241)
(242)
(243)
(244)
(245)
Electronic Journal. http://diffjournal.spbu.ru/ 147
Differential Equations and Control Processes, N. 1, 2021
Table 1. High-order strong Taylor-Stratonovich schemes.
Order of convergence Scheme Conditions for choosing the numbers q, q1, ..., q15
1.0 (24) (169)
1.5 (25) (170), (171)
2.0 (26) (172)-(176)
2.5 (27) (177)-(185)
3.0 (28) (186)-(202)
Taking into account (229)-(245) and the results of paper [73], we use in the SDE-MATH software package the conditions from Table 1 for choosing the numbers q, q1, q2,..., q15 for the numerical schemes (24)-(28).
Note that in the SDE-MATH software package, which is presented in the following sections, we use the following upper bounds b on the numbers qi,..., qi5
b =56 for qi, b =15 for q2, qs, b = 6 for q4, q8, q9, qw,
b = 2 for q5, qe, q7, qn, qu, qis, qi4, qi5.
This means that for the implementing of the numerical methods (13)-(16) and (25)-(28) we use in the SDE-MATH software package the following quantities of the exactly calculated Fourier-Legendre coefficients
573 =185,193 for 33,
163 = 4,096 for each of Cij, C01,,
3231 '
164 = 65,536 for C0000
3
yi00 0i0 00i
34333231'
73 = 343 for each of C%3, , C^,,
75 = 16,807 for C33 3,,
32 = 9 for each of , C02,, ,
C 0i00 c 00i0 c'
, , C34333231, C
34 = 81 for each of Ci00)0 -0100 -00i0 -000i
j4j3j2j1 j4j3j2j1
,6 ^on /-/000000
j4j3j2j1
36 = 729 for C
363534333231■
It should be noted that unlike the method based on Theorems 1-3, existing and well-known approaches to the mean-square approximation of iterated stochastic integrals based on the trigonometric basis functions [2], [3], [7], [27],
Electronic Journal. http://diffjournal.spbu.ru/ 148
Differential Equations and Control Processes, N. 1, 2021
28], [34], [37] do not allow choosing theoretically different numbers q for approximations of different iterated stochastic integrals (starting form the multiplicity 2 of stochastic integrals). Moreover, the noted approaches [2], [3], [7], [27], [28]
34
37] exclude the possibility for obtaining of approximate and exact expressions for the mean-square approximation error similar to the formulas 49), (50).
2.7 Numerical Algorithm for Linear Stationary Systems of Ito SDEs Based on Spectral Decomposition
Consider the following linear stationary system of Ito SDEs
dxt = (Axt + Bu(t)) dt + Fdwt, x0 = x(0), t £ [0,T], (246)
where xt £ Rn is a solution of the system (246), u(t) : [0,T] ^ Rk is a nonrandom function, A £ Rnxn, F £ Rnxm, B £ Rnxk, and wt is a standard m-dimensional Wiener process with independent components wt(i), i = 1,... ,m. Also we suppose that n, m, k > 1. The process yt = Hxt £ R1 is interpreted as an output process of the system (246), where H £ R1xn.
It is well-known that the solution of (246) has the form [4]
xt =
= eA(t-to)xt0 + eA(t—s)Bu(s)ds + eA(t—s)Fdws, 0 < to < t < T, (247)
where eC is a matrix exponent
EC def C
= e
j=0
j!
C is a square matrix, and C° =f I is a unity matrix.
Consider the partition {тр}^=0 of [0,T] such that Tp = pA, A > 0. For simplicity, we will suppose that u(s), s £ [0,T] can be approximated by the step function, i.e. u(s) « u(s), s £ [0,T], where u(s) = u(tp) for s £ [tp,tp+1), p = 0,1,..., N — 1 (more accurate approximations of u(s) are discussed in [62
(also see [58], [61])). Substituting t = Tp+1, t0 = Tp, and u(s) instead of u(s)
into (247), we obtain
xo
p+1
=e
АД
xop
+ A-^ eAД — I)B u(pA) + wp+] (A), x0 = x(0), (248)
t
t
Electronic Journal. http://diffjournal.spbu.ru/ 149
Differential Equations and Control Processes, N. 1, 2021
where xp is the approximation of xT and
д
еА(Д s)Fdws+pД = wp+i(A).
Also we assume that yp = HXp, where yp is the approximation of y7 random column Wp+1(A) admits the following representation [4]
Wp+i(A) = SD (A)Ad (A)wp+i,
The
(249)
where wp G
n is a column of independent standard Gaussian random variables such that M {WpWT) = O for p = q, O is a zero matrix of size n x n, SD(A) is a matrix of orthonormal eigenvectors of the matrix Df (A) and (A) is a diagonal matrix on the main diagonal of which are the eigenvalues of the matrix Df (A), the matrix Df (A) is defined by
д
Df (A) = M {Wp+i(A)Wp+i(A)} = exp(A(A - s))FF Texp(AT(A - s))ds,
where CT is a transposed matrix C. Moreover, Df (A) = Df (t)\t=^ where Df (t) is a solution of the following Cauchy problem [4]
dD
-f (t) = ADf (t) + Df (t)AT + FFT, Df (0) = O.
In the SDE-MATH software package, we implement the numerical modeling of the system (246) by the formulas (248), (249). At that we use Algorithms 2.3-2.6 from [62] (also see [61], Chapter 11) for the implemetation of
V
3 The Structure of the SDE-MATH SoftWare Package
3.1 Development Tools
The software package was implemented with Python programming language. The main reason to use it is a huge community and significant amount of helpful libraries for calculations and mathematics. The development was performed in free to use Atom text editori.
1 All programs in Python programming language from this paper were written by the first author
Electronic Journal. http://diffjournal.spbu.ru/ 150
Differential Equations and Control Processes, N. 1, 2021
3.2 Dependency Libraries
In the development of the SDE-MATH software package such libraries as SymPy, NumPy, PyQt5, and Matplotlib were involved. All these libraries and tools are free and open source.
• SymPy is a Python library able to perform symbolic algebra calculations.
• NumPy is a library which specialization is efficient mathematical calculations. Most part of this library is written in C programming language that guarantees high calculation performance.
• The database is SQLite3. This is a tiny database for a local usage on one machine.
• Matplotlib library is a piece of software used to present obtained results in a best way.
• PyQt5 is a library used to build graphical user interface for the SDE-MATH software package.
3.3 Architecture
Taking into account, that the SDE-MATH software package is oriented on a numerical modeling its architecture is clear. There are two main statements. The first is that mathematical formulas are strongly integrated with SymPy library. By that we mean that they completely rely on SymPy. And the second is usage of database to make some calculations able for caching. The architecture itself is provided on Figure 1. Here all parts of the software package can be seen.
The main package is responsible for startup, so it decides which part of the software package must be started. The software package has several modes of operation. The objectives now are
• Run program to calculate and store the Fourier-Legendre coefficients in few text files with further loading in database.
• Run program with graphical user interface. This is the main program entry for the SDE-MATH software package.
Electronic Journal. http://diffjournal.spbu.ru/ 151
Differential Equations and Control Processes, N. 1, 2021
Figure 1: The SDE-MATH software package architecture
Electronic Journal. http://diffjournal.spbu.ru/ 152
Differential Equations and Control Processes, N. 1, 2021
On the current state of development the main entry package booting up PyQt5 library with all necessary widgets. More detailed description of this process will be provided later.
Moving further, the modeling package comes up. This package responsible for all work referenced to modeling including initialization of modeling environment, calculations loops and more. Also, it depends on accuracy calculation module deciding which amount of members in each approximation of iterated stochastic integral should be used in modeling of the Ito SDE (1) solution.
Accuracy calculation module accepts the order of strong numerical scheme for the Ito SDE (1) and its integration step and then calculates necessary amount of members in approximations of iterated Ito and Stratonovich stochastic integrals.
Symbolic algebra module is the construction part which combines many supplementary differential operators with strong numerical schemes for the Ito SDE (1). Having these components combined this module performs simplification of resulting formula so the modeling package can do its modeling work.
Tools module provides some functionality related to bootstrap of runtime environment and external instruments such as database and file system.
3.3.1 Integration with SymPy
Class inheritance tree was extended to implement strong numerical schemes for Ito SDEs. While numerical schemes for Ito SDEs were being implemented it was also necessary to implement supplementary subprograms. SymPy is a Python library able to perform symbolic algebra calculations. This is a core part of the project since it is differentiates input functions, builds and simplifies strong numerical schemes for Ito SDEs to model the Ito SDE (1) solution. Without this part the program package cannot be able to provide such flexible input of data.
3.3.2 Purpose of NumPy
NumPy is a library that helps with calculation optimizations in this project. The library specialization is efficient mathematical calculations. The main usage case is to calculate compiled symbolic formulas with it. It has integration with SymPy to replace symbolic functions with high performance numerical functions.
Electronic Journal. http://diffjournal.spbu.ru/ 153
Differential Equations and Control Processes, N. 1, 2021
3.3.3 Purpose of SQLite Database
The database was used to store the precalculated Fourier-Legendre coefficients, so getting them from there made numerical modeling much faster, because calculation process for these Fourier-Legendre coefficients involve high-cost symbolic operations. The database contains only one table, and might be thought redundant, but modeling needs hundreds (or even thousands) of precalculated coefficients. Obviously, calculation of them at runtime is terribly inefficient, but text files also not the best choice. Text files provide a sequential access memory and combining different accuracy values q1,..., q15 it causes sequential search which extends time to give the result. That is where database comes up. The random access allows to get any Fourier-Legendre coefficient or any quantity of them which makes solution as flexible as it possible.
The download of precalculated Fourier-Legendre coefficients is built in supplemental subprograms to provide fluent calculation pipeline. Having the precalculated Fourier-Legendre coefficient not found, subprogram initiates calculation for it with following store in the database.
Figure 2: Fourier-Legendre coefficients calculations explanation
Electronic Journal. http://diffjournal.spbu.ru/ 154
Differential Equations and Control Processes, N. 1, 2021
It is an interesting note that having mentioned earlier optimization done, the calculations performance were increased in several times. Now the most heavy operation is symbolic simplifications before modeling. The actual modeling takes seconds, for thousands of iterations on m components of stochastic process, so it is not such important how long modeling period of time, as the accuracy that needs to be accomplished.
The scheme of calculation process is presented on Figure 2.
3.3.4 Purpose of Matplotlib
Matplotlib library is a piece of software used to present obtained results in a best way. This library has many features, but feature that needed in this project is to print charts with modeling results in a PyQt5 widget. Thus the data visualization is integrated in graphical user interface.
3.4 Implementation Plan
The implementation of SDE-MATH software package was performed sequentially. The components of SDE-MATH software package were implemented in order of their necessity for calculation pipeline completion.
3.4.1 Calculation of the Fourier—Legendre Coefficients
The Fourier-Legendre coefficients for the approximations of iterated Ito and Stratonovich stochastic integrals were implemented and placed in Listings 0361. This was the first step since the Fourier-Legendre coefficients involved almost in every strong numerical scheme for the Ito SDE (1).
Also it is important to note that the SDE-MATH software package contains a Python script intended for generating of Fourier-Legendre coefficients using multiprocessing. This script placed in Listing 62 and already contains tasks that were performed to generate about 300,000 Fourier-Legendre coefficients. Similarly, user can run and calculate additional Fourier-Legendre coefficients if they are needed. To determine which Fourier-Legendre coefficients will be calculated user must specify pairs of starting and ending values of components in lower multi-index and specify upper multi-index of the Fourier-Legendre coefficient. For example (((0,15), (0,15), (0,15)), (0,1,0)). This means that
Electronic Journal. http://diffjournal.spbu.ru/ 155
Differential Equations and Control Processes, N. 1, 2021
program calculates the Fourier-Legendre coefficients Cjjj, where ji,j2,j3 £ {0,1,..., 14}.
3.4.2 Differential Operators L, L, Gq\ i = 1,... , m
Moving further, strong numerical schemes for ItO SDEs rely on the differential operators (4), (5), and (23). They were implemented and placed in Listings 64-67.
3.4.3 Approximations of Iterated Stochastic Integrals
The next step is implementation of approximations of iterated Ito and Stratono-vich stochastic integrals for the numerical schemes (12)-(16), (24)-(28). They are implemented and definition of their classes are placed in Listings 69-1081.
3.4.4 Strong Numerical Schemes for Ito SDEs
The strong numerical schemes (12)-(16), (24)-(28) for Ito SDEs were implemented. They are placed in Listings 1110-1311.
3.4.5 Graphical User Interface
Finally, the graphical user interface was implemented. The source codes referenced to graphical user interface are placed in Listings 7-42.
4 Software Package Graphical User Interface
For the SDE-MATH software package mentioned above the graphical user interface was developed. The graphical user interface is important and massive part of SDE-MATH software package because it allows user to perform modeling experiments without programming skills and understanding of program package architecture and principles of work.
4.1 Information Model of The Graphical User Interface
The development of graphical user interface was started from consideration of
Electronic Journal. http://diffjournal.spbu.ru/ 156
Differential Equations and Control Processes, N. 1, 2021
SDE math: software package
G
Preparing Database..
2
SDE math: software package |----| I I | X
Welcome to SDE-MATH Software Package
Greeting Message
Z\
SDE malh: software package
The modeling is being performed...
Modeling Logs
SDE math: charts window X
Curves ZtomRsS Save ||Move
SDE math: software package 1 —I □ I X
Charts window
SDE's strong numerical schemes
Taylor-Stratonovich Taylor-Ito Other
1 Convergence Order 1.0 1 1 Euler Linear Systems
1 Convergence Order 1.5 1 1 Milstein
1 Convergence Order 2.0 1 1 Convergence Order 1.5
1 Convergence Order 2.5 1 1 Convergence Order 2.0
1 Convergence Order 3.0 1 1 Convergence Order 2.5
1 Convergence Order 3.0
4
SDE math: software package 1 —1 □ 1 X
X
3
Ok
7
6
X
Charts
window
Ok
Figure 3: Information model of graphical user interface
experiments and routines which can be performed with the SDE-MATH software package. The graphical user interface is aimed on provision of user capabilities to perform nonlinear and linear systems of Ito SDEs modeling experi-
Electronic Journal. http://diffjournal.spbu.m/ 157
Differential Equations and Control Processes, N. 1, 2021
ments. The information model which schematically describes the graphical user interface structure is presented on Figure 3.
4.1.1 Processing Screens
To represent long duration processes the graphical user interface has two dialogs which can be seen on Figure 3, in Windows 1 and 6. The first one represents database preparing process on application very first run. During this process the Fourier-Legendre coefficients are being loaded into the SQLite database. This screen appears also when user calculates new Fourier-Legendre coefficients. The other screen shows logs during modeling experiment.
4.1.2 Greetings Dialog
After the SDE-MATH software package has completed the database preparation, it shows greeting dialog which represents short information about its purposes. The greeting dialog can be seen on Figure 3 in Window 2.
4.1.3 Main Menu Dialog
In the main menu of the SDE-MATH software package user can choose one of strong numerical schemes for Ito SDEs to perform modeling experiments. The main menu dialog can be seen on Figure 3 in Window 3.
4.1.4 Visualization Tool
It is important to note that the main SDE-MATH software package window has a checkbox in right upper corner which do switching on and off charts window. In any time user can call this window or hide it if it is not needed. The charts window is universal utility for modeling experiments results visualization. This window has few instruments on it. The left side bar contains all curves labels, and control elements for hiding, showing, and deleting curves. On the right side of the window there are plot which draws the curves. The charts window can be seen on Figure 3, it is Window 3.
4.1.5 Data Input Dialogs
Since the software package has options to perform linear Ito SDEs modeling experiments it is necessary to provide user with input fields for numerical data
Electronic Journal. http://diffjournal.spbu.ru/ 158
Differential Equations and Control Processes, N. 1, 2021
both scalar and matrix. On the other side, for nonlinear Ito SDEs it is necessary to provide symbolic input. The choice of control elements is conditioned by the above obstacles. On Figure 3, and especially in Windows 4 and 5, these input controls can be seen. There are ”LineEditWidget” and ”TableWidget” which are sufficient to provide input abilities. The topic of input data validation is also important but to be more accurate referenced to user experience rather than to information model, so it will be described further.
4.2 The User Experience and Implementation Results
The above part represents the structure of software package but not the dynamics and user experience of it. Let us discuss the SDE-MATH software package user experience on few examples provided further on Figures 141361 This examples represent two scenarios of the SDE-MATH software package use.
The database preparation screen is presented on Figure |4. During the database preparation this screen displays informational message and spinning visualizer of process continuation.
The screen that presented on Figure 5 appears every time when software package runs unless user presses ”Ok” button with marked checkbox. In such case this message screen will not be shown again.
On Figure 6 the main menu dialog is presented. In this dialog user can choose any strong numerical scheme for Ito SDEs to perform modeling experiment.
The tooltip example can be seen on Figure 7. Such tooltips displayed with characteristic icon are placed all over software package interface to help user with explanations.
As noted earlier, the dedicated charts window is universal tool for visualization. The specific examples of such visualization are presented on Figure 8,19, 34-36.
The initial state of input dialogs for nonlinear and linear Ito SDEs are displayed on Figures 9 and 20. At that moment user can start to input the data.
The example of wrong scalar data input is presented on Figures 10, 15, 21, and 31. When user input wrong data the error message appears and ”Next” or ’’Perform modeling” button is blocked. The input field is being checked all the user data input process, and as soon as wrong character is entered notification
Electronic Journal. http://diffjournal.spbu.ru/ 159
Differential Equations and Control Processes, N. 1, 2021
pops up.
If scalar data is correct the ”Next” button is automatically unblocked. On Figures 11, 16, 22, and 32 the examples of scenario are displayed.
On Figures 112, 13, and [28 the example of correct matrix data input is presented. In this particular case the input is symbolic. Symbolic algebra input errors are much harder to determine so this is done on further stages, in modeling runtime.
In the other case when matrix input data are numerical, the validation is performed right after user has finished input. The examples of incorrect matrix numerical input can be found on Figure 24.
When user finishes input with a success the ”Next” or ’’Perform modeling” button is automatically unblocked. On Figures 123,I25H27, Щ and 30 that can be clearly seen.
The Figures 17, 18, and 33 displays sequence of log messages emerged during the modeling process.
After modeling has been done the focus moves to the charts window where obtained modeling results can be seen. The results of modeling is displayed on Figures 19, 34H30. On Figures 35 and 36 the expectations and variances of obtained components of solution are displayed.
Figure 4: Fourier-Legendre coefficients database preparation screen
Electronic Journal. http://diffjournal.spbu.ru/ 160
Differential Equations and Control Processes, N. 1, 2021
Figure 5: Greetings screen
Figure 6: Main menu dialog
Electronic Journal. http://diffjournal.spbu.ru/ 161
Differential Equations and Control Processes, N. 1, 2021
Figure 7: Tooltip
Electronic Journal. http://diffjournal.spbu.ru/ 162
Differential Equations and Control Processes, N. 1, 2021
Figure 9: Nonlinear system of Ito SDEs data input
Figure 10: Wrong data input
Electronic Journal. http://diffjournal.spbu.ru/ 163
Differential Equations and Control Processes, N. 1, 2021
Figure 11: Correct data input
Figure 12: Vector function a(x, t) input
Electronic Journal. http://diffjournal.spbu.ru/ 164
Differential Equations and Control Processes, N. 1, 2021
Figure 13: Matrix function B(x, t) input
Figure 14: Initial data input
Electronic Journal. http://diffjournal.spbu.ru/ 165
Differential Equations and Control Processes, N. 1, 2021
Figure 15: Wrong data input
Figure 16: Correct data input
Electronic Journal. http://diffjournal.spbu.ru/ 166
Differential Equations and Control Processes, N. 1, 2021
Figure 17: Modeling logs
Figure 18: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 167
Differential Equations and Control Processes, N. 1, 2021
Figure 20: Linear system of Ito SDEs data input
Electronic Journal. http://diffjournal.spbu.ru/ 168
Differential Equations and Control Processes, N. 1, 2021
Figure 21: Wrong data input
Figure 22: Correct data input
Electronic Journal. http://diffjournal.spbu.ru/ 169
Differential Equations and Control Processes, N. 1, 2021
Figure 23: Matrix A input
SDE-MATH: software package О Back Linear Systems of Ito SDEs
©Setting of matrix A© Wrong values in matrix!
1 2 3 4
1 -1 0 0 0
2 0 -2 0 0
3 0 0 -3 0
4 0 0 0 a
О Back О Next
Figure 24: Wrong matrix A input
Electronic Journal. http://diffjournal.spbu.ru/ 170
Differential Equations and Control Processes, N. 1, 2021
Figure 25: Correct matrix A input
Figure 26: Matrix B input
Electronic Journal. http://diffjournal.spbu.ru/ 171
Differential Equations and Control Processes, N. 1, 2021
Figure 27: Matrix F input
Figure 28: Vector function u(t) input
Electronic Journal. http://diffjournal.spbu.ru/ 172
Differential Equations and Control Processes, N. 1, 2021
Figure 29: Matrix H input
Figure 30: Initial data input
Electronic Journal. http://diffjournal.spbu.ru/ 173
Differential Equations and Control Processes, N. 1, 2021
Figure 31: Wrong data input
Figure 32: Correct data input
Electronic Journal. http://diffjournal.spbu.ru/ 174
Differential Equations and Control Processes, N. 1, 2021
Figure 33: Modeling logs
Figure 34: Modeling results (components of solution)
Electronic Journal. http://diffjournal.spbu.ru/ 175
Differential Equations and Control Processes, N. 1, 2021
Figure 35: Modeling results (expectations)
Figure 36: Modeling results (variances)
Electronic Journal. http://diffjournal.spbu.ru/ 176
Differential Equations and Control Processes, N. 1, 2021
5 The Results Obtained Using the SDE-MATH Software Package
This section represents the results that were obtained with the SDE-MATH software package at the current stage of the development.
5.1 The Calculated Fourier—Legendre Coefficients
When application runs first time it performs loading of Fourier-Legendre coefficients basic pack in the database from the files. Further, in Listings Ш-Й few examples of them can be seen.
Listing 1: The Fourier—Legendre coefficients Cjj j examples
1 C _0 : 0:0 = 4/3
2 C _0 : 0:1 = -2/3
3 C _0 : 0:2 = 2/15
4 C _0 : 0:3 = 0
5
6 C _0 : 6:4 = -4/429
7 C _0 : 6:5 = 2/143
8 C _0 : 6:6 = 2/2145
9 C _1 : 0:0 = 2/3
10
11 C _47 :33 44 = 3874457388633368/31334948307735906710660485
12 C _47 :33 45 = 0
13 C _47 :33 46 = 52892292737827468/2224781329849249376456894435
14 C _47 :34 :0 = 0
15 C _47 :34 :1 = 0
Listing 2: The Fourier—Legendre coefficients Cjjm examples
1 C_0 : 0:0: 0= = 2/3
2 C_0 : 0:0: 1= = -2/5
3 C_0 : 0:0: 2= = 2/15
4 C_0 : 0:1: 0= = -2/15
5 C_0 : 0:1: 1= = 2/15
6
7 C_1 : 1:0: 1= = -2/35
8 C_1 : 1:0: 2= = 0
9 C_1 : 1:1: 0= = 2/105
10 C_1 : 1:1: 1= = 0
11
12 C_20 :20 20 1 = -2401828/165607444685315115
13 C_20 :20 20 2=0
14 C_20 :20 20 3 = -1241929832/77669891557412788935
15 C_20 :20 20 4=0
Electronic Journal. http://diffjournal.spbu.ru/ 177
Differential Equations and Control Processes, N. 1, 2021
Listing 3: The Fourier—Legendre coefficients J2J1 examples
1 C _0 : 0:0 0: 0 = 4/15
2 C _0 : 0:0 0: 1 = -8/45
3 C _0 : 0:0 1: 0 = -4/45
4 C _0 : 0:0 1: 1 = 8/105
5 C _0 : 0:1 0: 0 = 0
6 C _0 : 0:1 0: 1 = 4/315
7
8 C _1 : 1:0 1: 0 = -4/315
9 C _1 : 1:0 1: 1 = 4/315
10 C _1 : 1:1 0: 0 = 2/105
11 C _1 : 1:1 0: 1 = -8/945
12 C _1 : 1:1 1: 0 = 2/945
13 C _1 : 1:1 1: 1 = 0
14
15 C _20 : 2 0 :20: 20: 1 = 0
16 C _20 : 2 0 :20: 20: 2 = - 249877207023610010/10969028984480026752856704371
17 C _20 : 2 0 :20: 20: 3=0
18 C _20 : 2 0 :20: 20: 4 = - 307937246954575016/571102494076952592887484313076115
Listing 4: The Fourier—Legendre coefficients Cjjjjjj examples
1 C .0 : 0:0: 0: 0:0 = 4/45
2 C .0 : 0:0: 0: 0:1 = -4/63
3 C .0 : 0:0: 0: 0:2 = 2/63
4 C .0 : 0:0: 0: 1:0 = -4/105
5
6 C .2 : 1:0: 1: 0:2 = -2/1575
7 C .2 : 1:0: 1: 1:0 = 38/22275
8 C _2 : 1:0: 1: 1:1 = -2/1575
9 C .2 : 1:0: 1: 1:2 = 68/81081
10
11 C _15 :15 15 : 1 5 15 : 15 = 0
12 C _15 :15 15 : 1 5 15 :16 = - 798538765964/243076352242280511713913783475
13 C _15 :15 15 : 1 5 15 : 17 = 0
14 C _15 :15 15 : 1 5 15 :18 = -59075427603328/17302616709609603697454044769175
5.2 Accuracy Settings
From Theorem 3 (see formulas (51)-(66)) it follows that the number p in the formula (48) should be chosen individually for various combinations of indices i\,... ,ik E {1,...,m}. As follows from Listing 5 (see below) and the results of work [73], these numbers p in the overwhelming majority of cases do not exceed the number p from the formula (51). Moreover, all the mentioned numbers p are many times less than the number p selected using the formula (49) (due to the presence of the multiplier factor k! on the left-hand side of (49)).
In this work, we have replaced the mentioned numbers p for all possible
Electronic Journal. http://diffjournal.spbu.ru/ 178
Differential Equations and Control Processes, N. 1, 2021
combinations of indices i1,... ,ik E {1,...,m} with the number p according to the formula (51). This is possible due to the results of Listing 6. This listing shows that the above replacement does not lead to noticeable accuracy loss of the mean square approximation of iterated Ito stochastic integrals (for more details see [73]).
Thus, in this paper we decided to exclude the multiplier factor k! in the conditions for choosing the numbers q\,... , q15 (see (169)-(202)). Recall that these numbers are used to construct the approximations of iterated Ito and Stratonovich stochastic integrals from the numerical schemes (13)-(16), (25)-(28). The test script was written. The results of its work are presented in Listings 5 and 6, where
1. dt is the integration step;
2. q1(1,2) means p from (54), q1(2,3) means p from (55), q1(1,3) means p from (56), q1 means p from (51) for k = 3;
3. C = 1 (see (17) and (29));
4. error 1 means the left-hand side of (171);
5. error 2 means the left-hand side of (54) divided by (T — t)3;
6. error 3 means the left-hand side of (56) divided by (T — t)3;
7. error 4 means the left-hand side of (55) divided by (T — t)3.
The above idea of calculation of the numbers qi,..., qi5 is described in Listing 109.
Listing 5: Accuracy calculation module
1
2 dt = 0.011
3 q1 = 12
4 q1 (1, 2) = 6
5 q1 (1 , 3) = 12
6 q1 (2, 3) = 6
7
8 dt = 0.008
9 q1 = 16
10 q1 (1, 2) = 8
11 q1 (1 , 3) = 16
12 q1 (2, 3) = 8
Electronic Journal. http://diffjournal.spbu.ru/ 179
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Differential Equations and Control Processes, N. 1, 2021
dt = 0.0045 q1 = 28
q1 (1, 2) = 14
q1 (1, 3) = 28
q1 (2, 3) = 14
dt = 0.0035
q1 = 36
q1 (1, 2) = 18
q1 (1, 3) = 36
q1 (2, 3) = 18
dt = 0.0027
q1 = 47
q1 (1, 2) = 23
q1 (1, 3) = 47
q1 (2, 3) = 23
dt = 0.0025
q1 = 50
q1 (1, 2) = 25
q1 (1, 3) = 51
q1 (2, 3) = 25
Process finished with exit code 0
Listing 6: Accuracy calculation module
dt = 0.011 error 1 = 0.010153888451696458
q1 = 12
error 2 = 0.005076944225848201
q1 (1, 2) = 12
error 3 = 0.010307776903394072
q1 (1, 3) = 12
error 4 = 0.005076944225848284
q1 (2, 3) = 12
dt = 0.008 error 1 = 0.007681193827577537
q1 = 16
error 2 = 0.003840596913789046
q1 (1, 2) = 16
error 3 = 0.0077866300793989485
q1 (1, 3) = 16
error 4 = 0.003840596913789157
q1 (2, 3) = 16
dt = 0.0045
Electronic Journal. http://diffjournal.spbu.ru/ 180
Differential Equations and Control Processes, N. 1, 2021
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61 62 63
err or 1= 0. .004432832059862973
q1 = 28
err or 2= 0. .0022164160299319446
q1 (1, 2) = 28
err or 3= 0. .004479699207443705
q1 (1, 3) = 28
err or 4= 0. .002216416029932139
q1 (2, 3) = 28
dt = 0.0035
error 1 = 0.0034564405520411956 q1 = 36
error 2 = 0.0017282202760207088 q1 (1, 2) = 36
error 3 = 0.003488223569838411 q1 (1, 3) = 36
error 4 = 0.0017282202760210141 q1 (2, 3) = 36
dt = 0.0027
error 1 = 0. .0026523659377455377
q1 = 47
error 2 = 0. .00132618296887127
q1 (1, 2) = 47
error 3 = 0. .0026731529281250332
q1 (1, 3) = 47
error 4 = 0. .0013261829688714366
q1 to co = 47
dt = 0.0025 error 1 = q1 = 50 error 2 =
q1 (1, 2) :
error 3 = q1 (1 , 3) error 4 = q1 (2 , 3)
0.002494053620431952
0.0012470268102122428
= 50
0.0025128597161119537
= 50
0.0012470268102123538
= 50
Process finished with exit code 0
5.3 Testing Example (Nonlinear System of Ito SDEs)
The input data for testing of the SDE-MATH software package correspond to the autonomous variant of nonlinear system of Ito SDE (1) with multidimensional non-commutative noise. More precisely, we choose n = 2, m = 2,
x01} = 1, x02) = 1.5,
(2)
Electronic Journal. http://diffjournal.spbu.ru/ 181
Differential Equations and Control Processes, N. 1, 2021
—5x(1)
ax , x
(1) x(2)
0.5 • sin x
x(1)
x
(2)
B (x(1),x(2))
x
x(2) 0.5 • cos (x(1)
Figures 37-92 related to the strong high-order Taylor-Ito and Taylor-Stra-tonovich schemes (T21)-(T6). (241)-(I28) for the Ito SDE (T) represent modeling
Test machine specifications are CPU with maximum core frequency 4.2 GHz and T6GB of RAM.
5.4 Visualization and Numerical Results for Nonlinear System of Ito SDEs Obtained via the SDE-MATH Software Package
This subsection is fully devoted to modeling logs and results visualization. They are presented on Figures 37-9T
results
□ X
The modeling has been completed!
18:19:50 - SQLite Database is successfully connected 18:19:50 SQlite Database Version is: 3.33.0 18:19.54 -10.001 seconds] MJstein start 18:19 54 10001 seconds] Using C = 500 18 19 54 -10001 seconds] Using dt - 0.001 18:1954 - (0 001 seconds) Using q = (3.)
18:19 55 - (0.069 seconds) MJstein subs are finished 18:1955 - (0.825 seconds] MJstein calculations ate fntshed 18:1955 - The SQlite connection is closed
□ X
18:18:52 - SQlite Database is successfiily connected 18:18:52 SQlite Database Version is: 3.33.0 18:18.52 - (0.000 seconds] Euler start 18:18 52 - (0 004 seconds] Euler subs are finished 18:18 52 - (0 168 seconds] Euler calculations are finished 18:18 52 - The SQlite connection is closed
Euler scheme (dt = 0.001)
Milstein scheme (C = 50, dt = 0.001)
Figure 37: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ T82
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package - □ X
The modeling has been completed!
18:20:10 SQlite Database is successfully connected
18:2ft 10 - SQlite Database Version is: 3.33.0 18:20-14 10.000 seconds] Strong Taylor-Ito 1.5 start 18:2015 10723 seconds] Using C = 500 18:20 15 - [0.723 seconds] Using dt - 0.001 18:2015 -10728 seconds] Using q = (2500, 3)
18:2144 (90.186 seconds) Strong Taylor-Ito 1.5 subs are finished 18:25.20 - [306.154 seconds) Strong Taytor-lto 1.5 calculations are finished 18:25:20 - The SQlite connection is closed
Figure 38: Strong Taylor-Ito scheme of order 1.5 (C = 50, dt = 0.001)
Figure 39: Strong Taylor-Ito schemes of orders 0.5, 1.0, and 1.5 (x(1) component, C = 50, dt = 0.001)
Electronic Journal. http://diffjournal.spbu.ru/ 183
Differential Equations and Control Processes, N. 1, 2021
Figure 40: Strong Taylor-Ito schemes of orders 0.5, 1.0, and 1.5 (x(2) component, C = 50, dt = 0.001)
Euler scheme (dt = 0.005) Milstein scheme (C = 500, dt = 0.005)
Figure 41: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 184
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
18:37:10 - SQlite Database is successfiily connected 18:37:10 SQlite Database Version is: 3.33.0 18:37.14 10.000 seconds] strong Taylor-lto 1.5 Start 18:37 14 10001 seconds] Using C = 5000 18:37 14 -10001 seconds] Using dt - 0.005 18:37 14 - (0006 seconds) Using q = (10.0>
18:37:14 - (0.262 seconds) Strong Taylor-lto 1.S subs are finished 18:37:15 - (0.830 seconds) Strong Taylor-lto 1.5 calculations ore finished 18:37:15 - The SQlite connection is closed
✓Ok
SDE-MATH: software package - □ X
The modeling has been completed!
19:34:09 SQlite Database is successfully connected
19:34:09 SQlite Database Version is: 3.33.0 19:34.15 - (0.000 seconds) Strong Taylor-lto 2.0 start 19:3415 (0.475 seconds] Using C = 500.0 19 34 15 - (0 475 seconds] Using dt - 0.005 19:34 15 - (0 481 seconds) Using q = (2000. 10. 0. 0)
19:36:53 - (158.104 seconds] Strong Taylor-lto 2.0 subs are finished 19:38:13 - (238335 seconds] Strong Taylor-lto 2.0 calculations are finshed 19:38:13 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 1.5 (C = 500, dt = 0.005)
Strong Taylor-Ito scheme of order 2.0 (C = 500, dt = 0.005)
Figure 42: Modeling logs
Figure 43: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, and 2.0 (x(1) component, C = 500, dt = 0.005)
Electronic Journal. http://diffjournal.spbu.ru/ 185
Differential Equations and Control Processes, N. 1, 2021
Figure 44: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, and 2.0 (x(2) component, C = 500, dt = 0.005)
Figure 45: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, and 2.5 (x(1) component, C = 7500, dt = 0.01)
Electronic Journal. http://diffjournal.spbu.ru/ 186
Differential Equations and Control Processes, N. 1, 2021
Euler scheme (dt = 0.01) Milstein scheme (C = 7500, dt = 0.01)
SDE-MATH software package — □ X
The modeling has been completed!
18:51 10 - SQlite Database is successfiily connected 18:51:10 SQlite Database Version is: 3.33.0 18.51.14 10.000 seconds] Strong Taylor-lto 1.5 start 18:51 14 10000 seconds] Using C = 7500.0 18 51 14 -10 001 seconds] Using dt - 0.01 18:51 14 - (0005 seconds) Using q = (0. 0)
18:51:14 - (0.141 seconds) Strong Taylor-lto 1.S subs are finished 18:51:15 - (0.338 seconds) Strong Taylor-lto 1.5 calculations ore finished 18:51:15 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
18:51:31 - SQlite Database is successfiily connected 18:51:31 SQlite Database Version is: 3.33.0 18.51 35 - (0.000 seconds) Strong Taylor-lto 2.0 start 18:51 35 (0000 seconds] Using C = 7500.0 18 51 35 - (0000 seconds) Using dt = 0.01 18:51 35 - (0001 seconds) Using q = (17. 0. 0.0)
18:51:36 - (0.910 seconds) Strong Taylor-lto 2.0 subs are finished 18:51:37 - (2.051 seconds) Strong Taylor-lto 2.0 calculations ore finished 18:51:37 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 1.5 (C = Strong Taylor-Ito scheme of order 2.0 (C = 7500, dt = 0.01) 7500, dt = 0.01)
SDE-MATH software package - □ X
The modeling has been completed!
18:52:35 SQlite Database is successfully connected
18:52:35 - SQlite Database Version is: 3.33.0 18:52.39 - (0.000 seconds] Strong Taylor-lto 2.5 start 18:5240 (0.384 seconds] Using C = 7500.0 18 5240 - (0 384 seconds) Using dt = 0.01 18:5240 - (0 384 seconds) Using q = (1667. 17. 0. 0. 0. 0, 0. 0)
18:56:32 - (232.859 secondsj Strong Taylor-lto 2.5 subs are finished 18:57:45 (305.366 seconds! Strong Taylor-lto 2.5 calculations are finshed 18:57 45 The SQlite connection is closed
Strong Taylor-Itoo scheme of order 2.5 (C = 7500, dt = 0.01)
Figure 46: Modeling logs
Electronic Journal. http://diffiournal.spbu.ru/ 187
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH charts window
О Trajectories Expectations variances #|
Taytor-Ito 1.5, xl
v Curves
«- ■> f В
V Mtlstetn,x2
V Teytar-Ito 1.5, x2 *
тауиг 1102 o. xi
V Tavtor-ito 2 o. x2 *
Taytar-Ito 2.5, xl X
✓ Taytor-ItO 2.5, x2 X
Figure 47: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, and 2.5 (x(2) component, C = 7500, dt = 0.01)
Figure 48: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 (x(1) component, C = 14000, dt = 0.025)
Electronic Journal. http://diffjournal.spbu.ru/ 188
Differential Equations and Control Processes, N. 1, 2021
Euler scheme (dt = 0.025) Milstein scheme (C = 14000, dt = 0.025)
SDE-MATH software package — □ X
The modeling has been completed!
19:10:07 - SQlite Database is successfiily connected 19:10:07 SQlite Database Version is: 3.33.0 19:1011 -(0.000 seconds] Strong Taylor-lto 1.5 start 19:1011 [0000 seconds] Using C = 140000 19 Ю 11 - [0000 seconds] Using dt = 0.025 19:Ю 11 - [0005 seconds) Using q = (0. 0)
19:10:12 - (0.145 seconds) Strong Taylor-lto 1.S subs are finished 19:10:12 - (0.224 seconds] Strong Tayior-lto 1.5 calculations are fnished 19:10:12 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:1023 - SQlite Database is successfiily connected 19:10:23 SQlite Database Version is: 3.33.0 19:10.27 - [0.000 seconds) Strong Taylor-lto 2.0 start 19:10.27 - [0000 seconds] Using C = 140000 19:1027 - [0 001 seconds] Using dt = 0.025 19:1027 - (0 006 seconds) Using q = (1, 0, 0. 0)
19:10:28 - (0.547 seconds) Strong Taylor-lto 2.0 subs are finished 19:10:28 - (0.899 seconds) Strong Taylor-lto 2.0 calculations are fnished 19:1028 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 1.5 (C = Strong Taylor-Ito scheme of order 2.0 (C = 14000, dt = 0.025) 14000, dt = 0.025)
SDE-MATH software package - □ X
The modeling has been completed!
19:11:05 SQlite Database is successfully connected
19:11:05 SQlite Database Version is: 3.33.0 19:11.09 - [0.000 seconds) Strong Taylor-lto 3.0 start 19:11 10 [0.264 seconds] Using C ^ 140000 19:11 10 - [0.265 seconds) Using dt = 0.025
19:11:10 - (0 265 seconds) Using q = (914. 23.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0, 0. 0) 19:17:00 - (350.567 seconds; Strong Taylor-lto 3.0 subs are finished 19:17:53 - (403.822 seconds] Strong Taylor-lto 3.0 calculations are finshed 19:17:53 - The SQlite connection is closed
Strong Taylor-Ito scheme of order 2.5 (C = Strong Taylor-Ito scheme of order 3.0 (C = 14000, dt = 0.025) 14000, dt = 0.025)
Figure 49: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 189
Differential Equations and Control Processes, N. 1, 2021
Figure 50: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 (x(2) component, C = 14000, dt = 0.025)
SDE-MATH. software package
□ X
The modeling has been completed!
18:28:36 - SQLite Database is successfully connected 18:28:36 SQlite Database Version is: 3.33.0 18:28.40 -10.000 seconds) Taytor-Stratonovich 1.0 start 18:2840 10000 seconds] Using C = 500 18:2840 -10001 seconds! Using dt = 0.001 18:2840 - (0001 seconds) Using q = (3.)
18:28:40 - (0.080 seconds) Strong Tayfor-Stratonovich 1.0 subs are finished 18:28:41 - (0.916 seconds) Strong Taylor-Sbatonovich 1.0 calculations are finished 18:28:41 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
18:29:04 - SQlite Database is successfiily connected
18:2904 SQlite Database Version is: 3.33.0
18:2908 - (0.000 seconds) Strong Taylor-Stratonovkh 1.5 start
18:2909 - (0726 seconds) Using C = 500
18:29 09 - (0.727 seconds) Using dt = 0.001
18:29 09 - (0.727 seconds) Using q = (2500. 3)
18:3940 - (91.427 seconds) Strong Taylor-Stratonovich 1.5 subs ore finished 18:34.16 - (307.814 seconds) Strong Tayior-Strotonovich 15 calculations ore finished 18:3416 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
1.0 (C = 50, dt = 0.001) 1.5 (C = 50, dt = 0.001)
Figure 51: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 190
Differential Equations and Control Processes, N. 1, 2021
Figure 52: Strong Taylor-Stratonovich schemes of orders 1.0 and 1.5 (x(1) component, C = 50, dt = 0.001)
Figure 53: Strong Taylor-Stratonovich schemes of orders 1.0 and 1.5 (x(2) component, C = 50, dt = 0.001)
Electronic Journal. http://diffjournal.spbu.ru/ 191
Differential Equations and Control Processes, N. 1, 2021
Figure 54: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, and 2.0 (x(1) component, C = 500, dt = 0.005)
SDE-MATH. software package
□ X
The modeling has been completed!
18:42:35 - SQlite Database is successfiily connected 18:42:35 SQlite Database Version is: 3.33.0 18:42.39 -10.000 seconds) Taytor-Stratonovich 1.0 start 18:42 39 *0-000 seconds] Using C = 500 0 18.42 39 -10000 seconds] Using dt = 0005 18:42 39 -(0006 seconds) Using q = (0.)
18:42:39 - (0.043 seconds) Strong Taylor-Stratonovich 1.0 subs are finished 18:42.40 (0.153 seconds) Strong Taylor-Stratonovich 1.0 calculations are finished 18:42 40 - The SQLrte connection is closed
SDE-MATH: software package — □ X
The modeling has been completed!
18:42:58 - SQlite Database is successfiily connected
18:42:58 SQlite Database Version is: 3.33.0
18:43-04 (0.000 seconds) Strong Taylor-Stratonovkh 1.5 start
18:43 04 (0000 seconds] Using C = 500.0
18 43 04 - (0 000 seconds] Using dt - 0005
1843 04 - (0005 seconds) Using q = (10.0>
18:43 04 - (0.227 seconds) Strong Taylor-Stratonovich 1.5 subs are finished 18:43 04 - (0.819 seconds) Strong Taylor-Stratonovich 1.5 calculations are finished 18:43:04 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order
1.0 (C = 500, dt = 0.005)
Strong Taylor-Stratonovich scheme of order
1.5 (C = 500, dt = 0.005)
Figure 55: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 192
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
18:43:36 - SQlite Database is successfiily connected
18:43:36 SQlite Database Version is: 3.33.0
18:43.41 -10.000 seconds] Strong Taylor-Strato no v*ch 2.0 start
18:4342 [0 481 seconds] Using C = 500 0
18 43 42 - [0 481 seconds] Using dt - 0.005
1843 42 * [0.482 seconds] Using q = (2000. 10. 0. 0)
18:46:22 - [160.880 seconds] Strong Taytor-Stiatonovich 2.0 subs are finished 18:47:42 [240279 seconds] Strong Taylor-Strotonovich 2.0 calculations ore finished 18:47 42 - The SQlite connection is closed
✓Ok
Figure 56: Strong Taylor-Stratonovich scheme of order 2.0 (C = 500, dt = 0.005)
(2)
Figure 57: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, and 2.0 (x( ’ component, C = 500, dt = 0.005)
Electronic Journal. http://diffjournal.spbu.ru/ 193
Differential Equations and Control Processes, N. 1, 2021
Figure 58: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, and 2.5 (x(1) component, C = 7500, dt = 0.01)
SDE-MATH software package — □ X
The modeling has been completed!
19:01 25 - SQlite Database is successfiily connected 19:01:25 SQlite Database Version is: 3.33.0 19.01.30 -10.000 seconds] Taytor-Stratonovich 1.0 start 19:01 30 10 001 seconds] Using C = 7500.0 19 01 30 -10001 seconds] Using dt = 0.01 19:01 30 - (0 001 seconds) Using q = (0.)
19:01:30 - (0.039 seconds) Strong Taylor-Stratonovich 1.0 subs are finished 19:01:30 - (0.098 seconds) Strong Taylor-Stratonovich 1.0 calculations are finished 19:01:30 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:01 42 - SQlite Database is successfiily connected
19:01:42 SQlite Database Version is: 3.33.0
19.01.46 - (0.000 seconds) Strong Taylor-Stratonovich 1.5 start
19 01 46 - (0.000 seconds] Using C = 7500.0
1901 46 - (0000 seconds] Using dt = 0.01
19:01 46 - (0 006 seconds) Using q = (0. 0)
19:01.46 - (0.110 seconds) Strong Taylor-Stratonovich 1.5 subs are finished 19:01.46 - (0.317 seconds) Strong Taylor-Stratonovich 1.5 cakulafions are finished 19:01 46 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
1.0 (C = 7500, dt = 0.01) 1.5 (C = 7500, dt = 0.01)
Figure 59: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 194
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
19:02.01 - SQlite Database is successfiily connected
19:02:01 SQlite Database Version is: 3.33.0
19.02.05 -10.000 seconds] Strong Taylor-Stratonovkh 2.0 start
19:02 05 [0 000 seconds] Using C = 7500.0
19 02 05 -10 000 seconds] Using dt = 0.01
19:02 05 -10.005 seconds) Using q = (17.0.0.0)
19:0205 - (0.667 seconds) Strong Tayfor-Stratonovich 2.0 subs are finished 19:02:07 - (1.773 seconds) Strong Taylor-Stratonovich 2.0 calculations are finished 19:02:07 - The SQlite connection is closed
✓Ok
SDE-MATH: software package - □ X
The modeling has been completed!
19:0223 SQlite Database is successfully connected
19:02:23 SQlite Database Version is: 3.33.0
19.0227 - (0.000 seconds) Strong Taylor-Strato no vkh 2.5 start
19:02 28 (0.380 seconds] Using C = 7500.0
19 02 28 -10.380 seconds) Using dt = 0.01
19:02 28 • (0.381 seconds) Using q = (1667. 17, 0. 0.0. 0, 0. 0)
19:05:55 - (207.453 seconds; Strong Taylor-Stratonovich 25 subs are fmihed 19:07:06 - (279.034 seconds) Strong Taylor-Stratonovich 25 calculations ore finished 19:07:06 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
2.0 (C = 7500, dt = 0.01) 2.5 (C = 7500, dt = 0.01)
Figure 60: Modeling logs
(2)
Figure 61: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, and 2.5 (x( ’ component, C = 7500, dt = 0.01)
Electronic Journal. http://diffjournal.spbu.ru/ 195
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
19:21:13 - SQlite Database is successfiily connected 19:21:13 - SQlite Database Version is: 3.33.0 19:21.17 -10.000 seconds) Taytor-Stratonovich 1.0 start 19:21 17 - [0 000 seconds] Using C = 14000 0 19:21 17 -10001 seconds) Using dt = 0.025 1921 17 - (0001 seconds) Using q = (0.)
19:21:17 - (0.037 seconds) Strong Taylor-Stratonovich 1.0 subs are finished 19:21:17 - (0.061 seconds) Strong Taytor-Sbatonovich 1.0 calculations are finished 19:21:17 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:21:34 - SQlite Database is successfiily connected
19:21:34 SQlite Database Version is: 3.33.0
19:21.38 - (0.000 seconds) Strong Taylor-Stratonovkh 1.5 start
19:21 38 (0000 seconds] Using C = 140000
19:21 38 - (0 000 seconds] Using dt = 0.025
1921 38 - (0.007 seconds) Using q = (0. 0)
19:21:38 (0.113 seconds) Strong Taylor-Stratonovich 1.5 subs are finished 19:21:38 - (0.196 seconds) Strong Taytor-Sbatonovich 1.5 calculations are finished 19:21:38 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order 1.0 (C = 14000, dt = 0.025) 1.5 (C = 14000, dt = 0.025)
SDE-MATH: software package — □ X
The modeling has been completed!
19:21 56 - SQlite Database is successfiily connected
19:21:56 SQlite Database Version is: 3.33.0
19:22.00 - (0.000 seconds) Strong Taylor-Strato no vkh 2.0 start
19:22 00 (0001 seconds] Using C = 140000
19:22 00 - (0001 seconds) Using dt = 0.025
19 22 00 - (0 006 seconds) Using q = (1, 0, 0. 0)
19:22:00 - (0.331 seconds) Strong Taylor-Stratonovich 2.0 subs are finished 19:22:01 - (0.669 seconds) Strong Taylor-Stratonovich 2.0 calculations are finished 19:22:01 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:22:29 - SQlite Database is successfiily connected
19:22:29 - SQlite Database Version is: 3.33.0
19:22.33 -10.000 seconds) Strong Taylor-Strato no vkh 2.5 start
19:22 33 - (0001 seconds] Using C = 140000
19:22 33 - (0001 seconds) Using dt = 0.025
19:22 33 • (0006 seconds) Using q = (23,0.0.0. 0. 0.0. 0)
19:22:35 - (1.773 seconds) Strong Tayfor-Stratonovich 2.5 subs are finished 19:22:37 (3.471 seconds) Strong Taytor-Sbatonovich 2.5 calculations are finished 19:22:37 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order 2.0 (C = 14000, dt = 0.025) 2.5 (C = 14000, dt = 0.025)
SDE-MATH: software package — □ X
The modeling has been completed!
19:23:17 - SQlite Database is successfiily connected
19:23:17 - SQlite Database Version is: 3.33.0
19:23:21 -10.001 seconds) Strong Taylor-Strato no vkh 3.0 start
19:23 21 (0.261 seconds] Using C = 140000
19:2321 * (0.262 seconds) Using dt = 0.025
19 23 21 - (0.266 seconds) Using q = (914. 23.0. 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0, 0. 0)
19:27:47 - (266.455 seconds; Strong Taylor-Stratonovich 3.0 subs are (inched 19:28:37 - (316.214 seconds] Strong Taylor-Stratonovich 3.0 calculations are finished 19:28:37 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order 3.0 (C = 14000, dt = 0.025)
Figure 62: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 196
Differential Equations and Control Processes, N. 1, 2021
Figure 63: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, 2.5, and 3.0 (x(1) component, C = 14000, dt = 0.025)
Figure 64: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, 2.5, and 3.0 (x( ’ component, C = 14000, dt = 0.025)
Electronic Journal. http://diffjournal.spbu.ru/ 197
Differential Equations and Control Processes, N. 1, 2021
Figure 65: Strong Taylor-Ito schemes of orders 0.5, 1.0, and 1.5 (x(1) component, C = 0.1, dt = 0.07)
Euler scheme (dt = 0.07) Milstein scheme (C = 0.1, dt = 0.07)
Figure 66: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 198
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
19:4029 - SQlite Database is successfiily connected 19:4029 SQlite Database Version is: 3.33.0 19:40.34 -10.000 seconds] Strong Taylor-lto 1.5 start 19 40 34 {0 074 seconds] Using C = 01 19 40 34 - Ю 074 seconds] Using dt - 0.07 19:40 34 - (0.074 seconds] Using q = (25S. 18)
19:41.47 - [73.360 seconds) Strong Taylor-lto 15 subs are finished 19:41:51 - (77.021 seconds) Strong Taylor-lto 1.5 calculations are finished 19:41:51 - The SQlite connection is closed
✓Ok
Figure 67: Strong Taylor-Ito scheme of order 1.5 (C = 0.1, dt = 0.07)
(2)
Figure 68: Strong Taylor-Ito schemes of orders 0.5, 1.0, and 1.5 (x() component, C = 0.1, dt = 0.07)
Electronic Journal. http://diffjournal.spbu.ru/ 199
Differential Equations and Control Processes, N. 1, 2021
Figure 69: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, and 2.0 (x(1) component, C = 0.5, dt = 0.15)
Euler scheme (dt = 0.15)
Milstein scheme (C = 0.5, dt = 0.15)
Figure 70: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 200
Differential Equations and Control Processes, N. 1, 2021
Strong Taylor-Ito scheme of order 1.5 (C = Strong Taylor-Ito scheme of order 2.0 (C 0.5, dt = 0.15) 0.5, dt = 0.15)
Figure 71: Modeling logs
(2)
Figure 72: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, and 2.0 (x( ’ component, C = 0.5, dt = 0.15)
Electronic Journal. http://diffjournal.spbu.ru/ 201
Differential Equations and Control Processes, N. 1, 2021
Euler scheme (dt = 0.2) Milstein scheme (C = 0.8, dt = 0.2)
SDE-MATH software package — □ X
The modeling has been completed!
19:54:10 - SQlite Database is successfiily connected 19:54:10 SQlite Database Version is: 3.33.0 19.54.14 10.000 seconds] Strong Taylor-lto 1.5 start 19 5414 10000 seconds] Using C = 0.8 19:54 14 -10 000 seconds] Using dt - 0.2 19:54 14 - (0 000 seconds] Using q = (4. 0)
19:54.14 - (0.205 seconds) Strong Taylor-lto 1.5 subs are finished 19:54.14 - (0.217 seconds) Strong Taylor-lto 1.5 calculations ore finished 19:5414 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:54:36 - SQlite Database is successfiily connected 19:54:36 SQlite Database Version is: 3.33.0 19.54.40 - (0.000 seconds) Strong Taylor-lto 2.0 start 19:5440 (0001 seconds] Using C =• 0.8 19:5440 - (0001 seconds] Using dt = 0.2 19:54 40 - (0 001 seconds) Using q = (20. 4. 0.0)
19:54:42 - (1.860 seconds) Strong Taylor-lto 2.0 subs are finished 19:54.42 - (1.958 seconds) Strong Taylor-lto 2.0 calculations ore fnished 19:54:42 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 1.5 (C = Strong Taylor-Ito scheme of order 2.0 (C = 0.8, dt = 0.2) 0.8, dt = 0.2)
SDE-MATH: software package — □ X
The modeling has been completed!
19:55:19 - SQlite Database is successfiily connected
19:55:19 - SQlite Database Version is: 3.33.0
19:55.23 - (0.000 seconds) Strong Taylor-lto 2.5 start
19:55 23 - (0 101 seconds] Using C =• 0.8
19:55 23 - (0 101 seconds) Using dt = 0.2
19:55 23 - (0 Ю2 seconds) Using q = (98. 20. г 1.0. 0. 0.0)
19:58:39 - (196-216 seconds; Strong Taylor-lto 2.5 subs are finished 19:58:43 - (199.719 seconds] Strong Taylor-lto 2.5 calculations are finshed 19:58:43 - The SQlite connection is closed
✓Ok
Strong Taylor-Itoo scheme of order 2.5 (C = 0.8, dt = 0.2)
Figure 73: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 202
Differential Equations and Control Processes, N. 1, 2021
Figure 74: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, and 2.5 (x(1) component, C = 0.8, dt = 0.2)
Figure 75: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, and 2.5 (x(2) component, C = 0.8, dt = 0.2)
Electronic Journal. http://diffjournal.spbu.ru/ 203
Differential Equations and Control Processes, N. 1, 2021
Euler scheme (dt = 0.2)
Milstein scheme (C = 4, dt = 0.2)
SDE-MATH software package — □ X
The modeling has been completed!
20:10:08 - SQlite Database is successfiily connected 20:10:08 SQlite Database Version is: 3.33.0 20:Ю12 -10.000 seconds] Strong Taylor-lto 1.5 start 20:1012 -10000 seconds] Using C = 4.0 20:1012 -10000 seconds] Using dt = 0.2 20:1012 - (0000 seconds) Using q = (1,0)
20:10:12 - (0.167 seconds] Strong Taylor-lto 1.S subs are finished 20:10:12 (0.178 seconds) Strong Taylor-lto 1.5 calculations ore finished 20:10:12 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:10:41 - SQlite Database is successfiily connected 20:10:41 SQlite Database Version is: 3.33.0 20:10.46 - (0.000 seconds) Strong Taylor-lto 2.0 start 20:1046 (0001 seconds] Using C = 4.0 20.Ю46 - (0006 seconds] Using dt = 0.2 20:1046 - (0006 seconds) Using q = (4, 0. 0. 0)
20:1046 - (0.583 seconds] Strong Taylor-lto 2.0 subs are finished 20:1046 - (0.630 seconds) Strong Taylor-lto 2.0 calculabons ore finished 20:1046 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 1.5 (C = 4, Strong Taylor-Ito scheme of order 2.0 (C = 4, dt = 0.2) dt = 0.2)
SDE-MATH: software package — □ X
The modeling has been completed!
20:11:17 - SQlite Database is successfiily connected
20:11:17 - SQlite Database Version is: 3.33.0
20:11.21 - (0.000 seconds) Strong Taylor-lto 2.5 start
20:11 21 (0 001 seconds] Using C = 4.0
20.11 21 - (0 002 seconds] Using dt = 0.2
20:11 21 - (0 002 seconds) Using q = (20.4. 0,0. 0.0, 0. 0)
20:11:25 - (4.343 seconds) Strong Taylor-lto 2.5 subs are finished 20:11:26 - (4.670 seconds) Strong Taylor-lto 2.5 calculabons ore finished 20:11 26 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:12:38 - SQlite Database is successfiily connected 20:12:38 SQlite Database Version is: 3.33.0 20:12.43 - (0.000 seconds) Strong Taylor-lto 3.0 start 20:1243 (0 100 seconds] Using C = 4.0 20:1243 - (0 100 seconds) Using dt = 0.2
20:1243 - (0.101 seconds) Using q = (98. 20. г 1. 0, 0. 0. 0. 0. 0. 0. 0.0. 0. 0. 0)
20:16:16 - (213.005 secondsj Strong Taylor-lto 3.0 subs are finished 20:16:20 - (217.631 seconds] Strong Taylor-lto 3.0 calculations are finshed 20:16:20 - The SQlite connection is closed
✓Ok
Strong Taylor-Ito scheme of order 2.5 (C = 4, Strong Taylor-Ito scheme of order 3.0 (C = 4, dt = 0.2) dt = 0.2)
Figure 76: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 204
Differential Equations and Control Processes, N. 1, 2021
Figure 77: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 (x(1) component, C = 4, dt = 0.2)
Figure 78: Strong Taylor-Ito schemes of orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 (x(2) component, C = 4, dt = 0.2)
Electronic Journal. http://diffjournal.spbu.ru/ 205
Differential Equations and Control Processes, N. 1, 2021
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
1.0 (C = 0.1, dt = 0.07) 1.5 (C = 0.1, dt = 0.07)
Figure 79: Modeling logs
Figure 80: Strong Taylor-Stratonovich schemes of orders 1.0 and 1.5 (x(1) component, C = 0.1, dt = 0.07)
Electronic Journal. http://diffjournal.spbu.ru/ 206
Differential Equations and Control Processes, N. 1, 2021
Figure 81: Strong Taylor-Stratonovich schemes of orders 1.0 and 1.5 (x(2) component, C = 0.1, dt = 0.07)
SDE-MATH software package — □ X
The modeling has been completed!
19:49:24 - SQLite Database is successfiily connected 19:4924 SQlite Database Version is: 3.33.0 19:49.28 -10.000 seconds) Taytor-Stratonovich 1.0 start 19 4928 )0 000 seconds] Using C =• 0.5 194928 -10001 seconds) Using dt = 0 15 1949 28 -10.006 seconds) Using q = (2.)
19:49:28 - (0.066 seconds) Strong Taylor-Stratonovich 1.0 subs are finished 19:49.28 - (0.071 seconds) Strong Taylor-Stratonovich 1.0 calculations are finished 19:4928 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
19:4956 - SQlite Database is successfiily connected
19:4956 SQlite Database Version is: 3.33.0
19.50.00 - (0.000 seconds) Strong Taylor-Stratonovich 1.5 start
19:5000 (0001 seconds] Using C = 0.5
19:5000 - (0001 seconds) Using dt = 0 15
19:50 00 - (0.005 seconds) Using q * (11.2)
19:50:01 - (0.431 seconds) Strong Taylor-Stratonovich 1.5 subs are finished 19:5001 - (0.464 seconds) Strong Taylor-Stratonovich 1.5 calculations are finished 19:5001 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
1.0 (C = 0.5, dt = 0.15) 1.5 (C = 0.5, dt = 0.15)
Figure 82: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 207
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
19:50:53 - SQlite Database is successfiily connected
19:50:53 SQlite Database Version is: 3.33.0
19:50.57 -10.000 seconds] Strong Taylor-Strato no v*ch 2.0 start
19:5057 - [0013 seconds] Using C = 0.5
19:5057 - [0013 seconds] Using dt = 0 15
19:5057 - [0013 seconds] Using q = (74.11,1.0)
19:51:14 - [16.905 seconds) Strong Taylor-Stratonovich 2.0 subs are finished 19:51:14 - (17.509 seconds) Strong Taylor-Stratonovidi 2.0 calculations are finished 19:51:14 - The SQlite connection is closed
✓Ok
Figure 83: Strong Taylor-Stratonovich scheme of order 2.0 (C = 0.5, dt
0.15)
Figure 84: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, and 2.0 (x(1) component, C = 0.5, dt = 0.15)
Electronic Journal. http://diffjournal.spbu.ru/ 208
Differential Equations and Control Processes, N. 1, 2021
Figure 85: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, and 2.0 (x(2) component, C = 0.5, dt = 0.15)
SDE-MATH software package — □ X
The modeling has been completed!
19:59:58 - SQlite Database is successfiily connected 19:59:58 SQlite Database Version is: 3.33.0 20:00.02 -10.001 seconds) Taytor-Stratonovich 1.0 start 20:0002 [0001 seconds] Using C =• 0.8 20:0002 - [0001 seconds] Using dt - 0.2 200002 - [0007 seconds) Using q = (1.)
20:00:02 - (0.058 seconds] Strong Taylor-Stratonovich 1.0 subs are finished 20:0002 - [0.060 seconds) Strong Taylor-Stratonovich 1.0 calculations are finished 20:0002 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:0036 - SQlite Database is successfiily connected
20:0036 SQlite Database Version is: 3.33.0
20:00.41 [0.000 seconds] Strong Taylor-Stratonovkh 1.5 start
200041 [0 001 seconds] Using C =• 0.8
200041 - [0001 seconds] Using dt = 0.2
20 0041 - [0.001 seconds) Using q = (4. 0)
20:0041 - (0.164 seconds] Strong Taylor-Stratonovich 1.5 subs are finished 20:0041 - (0.176 seconds) Strong Taylor-Stratonovich 1.5 calculations are finished 20:0041 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
1.0 (C = 0.8, dt = 0.2) 1.5 (C = 0.8, dt = 0.2)
Figure 86: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 209
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
20:02:54 - SQLite Database is successfiily connected
20:02:54 SQlite Database Version is: 3.33.0
20:02.59 -10.000 seconds] Strong Taylor-Stratonovkh 2.0 start
20:02 59 - [0 001 seconds] Using C = 0.8
20:02 59 - (0.001 seconds] Using dt = 0.2
20:02 59 - (0 001 seconds) Using q = (20.4. 0.0)
20:03:00 - (1.723 seconds) Strong Taylor-Stratonovich 2.0 subs are finished 20:03:00 - (1.817 seconds) Strong Tayior-Stratonovich 2.0 calculations are finished 20:03:00 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:04:01 - SQlite Database is successfiily connected
20:04:01 SQlite Database Version is: 3.33.0
20:04.06 - (0.000 seconds) Strong Taylor-Strato no vkh 2.5 start
20 04 06 (0 099 seconds] Using C = 0.8
20:04 06 - (0 099 seconds) Using dt = 0.2
20 04 06 - (0.100 seconds) Using q = (98. 20. 2. V 0, 0. 0.0)
20:06:39 - (153.082 seconds; Strong Taytor-Stiatonovich 22b subs are finished 20:06:42 - (156.496 seconds] Strong Taylor-Stratonovich 2.5 calculations ore finished 20:06:42 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order
2.0 (C = 0.8, dt = 0.2) 2.5 (C = 0.8, dt = 0.2)
Figure 87: Modeling logs
Figure 88: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, and 2.5 (x(1) component, C = 0.8, dt = 0.2)
Electronic Journal. http://diffjournal.spbu.ru/ 210
Differential Equations and Control Processes, N. 1, 2021
Figure 89: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, and 2.5 (x(2) component, C = 0.8, dt = 0.2)
Figure 90: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, 2.5, and 3.0 (x(1) component, C = 4, dt = 0.2)
Electronic Journal. http://diffjournal.spbu.ru/ 211
Differential Equations and Control Processes, N. 1, 2021
SDE-MATH software package — □ X
The modeling has been completed!
20:17:57 - SQlite Database is successfiily connected 20:17:57 - SQlite Database Version is: 3.33.0 20:18.01 -(0.000 seconds) Taylor-Stratonovich 1.0 start 20:1801 10001 seconds] Using C = 4 0 20.1801 -10001 seconds] Using dt - 0.2 20:1801 - (0007 seconds) Using q = (0.)
20:18:01 - (0.043 seconds] Strong Tayior-Stratonovich 1.0 subs are finished 20:18:01 - (0.047 seconds) Strong Tayior-Stratonovich 1.0 calculations are finished 20:18:01 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:18:48 - SQlite Database is successfiily connected
20:18:48 SQlite Database Version is: 3.33.0
20:18.52 - (0.000 seconds] Strong Taylor-Stratonovkh 1.5 start
20:18 52 - (0 001 seconds] Using C = 4.0
20.18 52 - (0001 seconds] Using dt = 0.2
20:18 52 - (0.007 seconds) Using q = (1, 0)
20:18:52 - (0.131 seconds] Strong Tayior-Stratonovich 1.5 subs are finished 20:18:52 - (0.142 seconds) Strong Tayior-Stratonovich 1.5 calculations are finished 20:18:52 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Tayior-Stratonovich scheme of order 1.0 (C = 4, dt = 0.2) 1.5 (C = 4, dt = 0.2)
SDE-MATH: software package — □ X
The modeling has been completed!
20:19:08 - SQlite Database is successfiily connected
20:19:08 SQlite Database Version is: 3.33.0
20:19.12 - (0.000 seconds] Strong Taylor-Stratonovkh 2.0 start
20:1912 - (0001 seconds] Using C = 4.0
20:1912 - (0001 seconds] Using dt = 0.2
20:1912 - (0.005 seconds) Using q = (4, 0, 0. 0)
20:19:12 - (0.380 seconds] Strong Tayior-Stratonovich 2.0 subs are finished 20:1912 - (0.426 seconds) Strong Tayior-Stratonovich 2.0 calculations are finished 20:1912 - The SQlite connection is closed
✓Ok
SDE-MATH: software package — □ X
The modeling has been completed!
20:1926 - SQlite Database is successfiily connected
20:1926 SQlite Database Version is: 3.33.0
20:1930 - (0.000 seconds] Strong Taylor-Stratonovkh 2.5 start
20:19 30 (0001 seconds] Using C = 4.0
20:19 30 - (0001 seconds] Using dt = 0.2
20:19 30 - (0 001 seconds) Using q = (20.4, 0.0. 0. 0.0. 0)
20:1934 - (3.549 seconds) Strong Tayior-Stratonovich 2.5 subs are finished 20:1934 - (3.833 seconds) Strong Tayior-Stratonovich 2.5 calculations are finished 20:1934 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order Strong Taylor-Stratonovich scheme of order 2.0 (C = 4, dt = 0.2) 2.5 (C = 4, dt = 0.2)
SDE-MATH: software package — □ X
The modeling has been completed!
20:20:06 - SQlite Database is successfiily connected
20:2906 SQlite Database Version is: 3.33.0
20:20.10 - (0.000 seconds] Strong Taylor-Stratonovkh 3.0 start
20:2010 - (0 104 seconds] Using C = 4.0
20:2010 - (0 104 seconds] Using dt = 0.2
20:2010 - (0.105 seconds) Using q = (98. 20, 2. 1. 0, 0. 0. 0. 0. 0. 0. 0. 0, 0. 0. 0)
20:22:47 - (157.030 secondsj Strong Taylor-Stiatonovich 3.0 subs are (inched 20:22:51 - (161.379 seconds] Strong Tayior-Stratonovich 3.0 calculations are finished 20:22:51 - The SQlite connection is closed
✓Ok
Strong Taylor-Stratonovich scheme of order 3.0 (C = 4, dt = 0.2)
Figure 91: Modeling logs
Electronic Journal. http://diffjournal.spbu.ru/ 212
Differential Equations and Control Processes, N. 1, 2021
Figure 92: Strong Taylor-Stratonovich schemes of orders 1.0, 1.5, 2.0, 2.5, and 3.0 (x(2) component, C = 4, dt = 0.2)
5.5 Example of Linear System of Ito SDEs (Solar Activity)
Consider a mathematical model of the solar activity without its average value in a form of the system of linear Ito SDEs (246) [4]. In (246) we choose [4]
n = 2, m = 1, k = 2, x^ = 7, x02) = -0.25,
A
0 1 00
, B =
-0.3205 -0.14 00
0 0 \
u(t) = , F =
0 5.08
(250)
(251)
5.6 Visualization and Numerical Results for Solar Activity Model
This subsection is devoted to the visualization and numerical results for the model of solar activity (246), (250), (251).
Electronic Journal. http://diffjournal.spbu.ru/ 213
Differential Equations and Control Processes, N. 1, 2021
Figure 93: Modeling logs for solar activity model
Figure 94: Solar activity model (x
(1)
t
component)
Electronic Journal. http://diffjournal.spbu.ru/ 214
Differential Equations and Control Processes, N. 1, 2021
Figure 95: Solar activity model (x
(2)
t
component)
Figure 96: Solar activity model (expectations)
Electronic Journal. http://diffjournal.spbu.ru/ 215
Differential Equations and Control Processes, N. 1, 2021
Figure 97: Solar activity model (variances)
5.7 Example of Abstract Linear System of Ito SDEs
Now consider the system of linear ItO SDEs (246) with the following data
n = 4, m = 5, k = 3, x0:) = 1, x02) = 2, x03)
1, x04) = -2, (252)
A
-1 0 0 0 1 1 1 0.2 0.1 0.1 0.1 0.1
0 -2 0 0 1 1 1 0.1 0.2 0.1 0.1 0.1
, B = , F =
0 0 -3 0 1 1 1 0.1 0.1 0.2 0.1 0.1
0 0 0 -4 1 1 1 0.1 0.1 0.1 0.2 0.1
(253)
u(t) = (O 0 ^, H = (q.1 0.1 0.1 0.l) . (254)
Electronic Journal. http://diffjournal.spbu.ru/ 216
Differential Equations and Control Processes, N. 1, 2021
5.8 Visualization and Numerical Results for Abstract Linear System of Ito SDEs Obtained via the SDE-MATH Software Package
This subsection is devoted to the visualization and numerical results for the model (246), (252)-(254).
Figure 98: Modeling logs (linear system of Ito SDEs (246), (252)-(254))
Figure 99: Linear system of Ito SDEs (l246l). (252)-(254) (components of solution)
Electronic Journal. http://diffjournal.spbu.ru/ 217
Differential Equations and Control Processes, N. 1, 2021
Figure 100: Linear system of Ito SDEs (246), (252)-(254) (expectations)
Figure 101: Linear system of Ito SDEs (246), (252)-(254) (variances)
Electronic Journal. http://diffjournal.spbu.ru/ 218
Differential Equations and Control Processes, N. 1, 2021
6 Source Codes of the SDE-MATH Software Package in the Python Programming Language
6.1 Source Codes of Graphical User Interface
6.1.1 Source Codes of Main Menu
Listing 7: Configuration file example
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
Listing 8: Program entry
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21
Electronic Journal. http://diffjournal.spbu.ru/ 219
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Differential Equations and Control Processes, N. 1, 2021
)
app = QApplication(sys.argv)
app . setWindowIcon (QtGui. QIcon(os . path . join (images , ” function .png” ) ) ) app . setStyle (QtWidgets . QStyleFactory . create ( ’ Fusion ’) )
main_window = MainWindow()
main_window . taskbar-button = QWinTaskbarButton()
main .window . taskbar-button . setOverlayIcon ( QtGui. QIcon(” resources / function . svg” ) ) exit(app.exec())
if___name___== ”__main__”:
main ()
Listing 9: Main window
Electronic Journal. http://diffjournal.spbu.ru/ 220
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Differential Equations and Control Processes, N. 1, 2021
self . nonlinear-modeling = NonlinearModelingWidget ( self . stack_widget)
self . stack_widget . addWidget ( self. main_menu)
self . stack_widget . addWidget ( self. nonlinear_modeling)
self . stack_widget . addWidget ( self. linear_modeling)
self . stack_widget . addWidget ( self. greetings)
self . stack_widget . addWidget ( self. simple_progress)
self . stack_widget . addWidget ( self . complex_progress)
self . setCentralWidget ( self . stack_widget)
self. exec _ init()
self . setWindowTitle (”SDE—MATH: software package”) self . setMinimumSize (640, 480) self.resize(800, 600)
self.show ()
self . main_menu . group1 . show_nonlinear_dialog . connect ( self . show_nonlinear) self . mai^menu . group2 . show_nonlinear_dialog . connect ( self . show_nonlinear) self . main_menu . group3 . show_linear_dialog . connect (
lambda: self . stack_widget . setCurrentWidget( self . linear_modeling) )
self . nonlinear_modeling . showmai^menu . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) ) self . nonlinear_modeling . star^progress . connect (
lambda: self . stack_widget . setCurrentWidget( self . complex_progress) )
self . linear_modeling . sho^mai^menu . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) ) self . linear_modeling . start_progress . connect (
lambda: self . stack_widget . setCurrentWidget( self . complex_progress) )
self . greetings . show_main_menu . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) )
self . greetings . show_main_menu . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) )
self . greetings . show_main_menu . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) )
self . complex_progress . back_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . main_menu) )
# plot events
self . main_window_close . connect ( self . plot-window . close)
self. main _menu . charts_check . clicked . connect ( self . plot-window . setVisible) self . plot .window . charts_show . connect (
lambda: self. main_menu . charts_check . setChecked( True) )
self . plot .window . charts_hide . connect (
lambda: self. main_menu . charts_check . setChecked( False) )
Electronic Journal. http://diffjournal.spbu.ru/ 221
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
1
2
Differential Equations and Control Processes, N. 1, 2021
self . nonlinear-modeling . draw_chart . connect ( self . plot-window . charts_list .new_items) self . nonlinear_modeling . draw_chart . connect ( self . plot-window . plot_widget . new_items) self . nonlinear_modeling . draw_chart . connect ( self . plot-window . show)
self . nonlinear_modeling . charts_check . stateChanged . connect ( self . plot-window . setVisible
)
self . plot .window . charts_show . connect (
lambda: self . nonlinear_modeling . charts_check . setChecked (True) )
self . plot .window . charts_hide . connect (
lambda: self . nonlinear_modeling . charts_check . setChecked ( False ) )
self . linear_modeling . draw-chart . connect ( self . plot-window . charts_list .new_items)
self . linear_modeling . draw_chart . connect ( self . plot .window . plot_widget . new. items)
self . linear_modeling . draw .chart . connect ( self . plot .window . show)
self . linear_modeling . charts_check . clicked . connect ( self . plot .window . setVisible) self . plot .window . charts_show . connect (
lambda: self . linear.modeling . charts_check . setChecked ( True) )
self . plot .window . charts_hide . connect (
lambda: self . linear.modeling . charts_check . setChecked( False) )
self . linear_modeling . start-progress . connect ( self . complex-progress . spin ) self . nonlinear.modeling . start-progress . connect ( self . complex_progress . spin) self . linear_modeling . stop_progress . connect ( self . complex .progress . stop ) self . nonlinear.modeling . stop.progress . connect ( self . complex_progress . stop)
def closeEvent(self, event): self . main_window_close . emit ()
def exec.init ( self ) :
self . simple.progress . spin (’’Preparing the database...”) self. stack_widget .setCurrentWidget( self. simple.progress)
worker = Worker( initialization )
worker . signals . finished . connect ( self . init.done )
QThreadPool .globalInstance() .start (worker)
def init.done ( self ) :
if not is_locked (” . welcome . lock”) :
self . stack.widget . setCurrentWidget ( self . greetings ) else :
self . stack.widget . setCurrentWidget ( self . main_menu) self . simple.progress . stop ()
def show.nonlinear ( self , scheme_id) :
self . nonlinear.modeling . set_scheme (scheme_id)
self. stack_widget .setCurrentWidget( self. nonlinear.modeling)
Listing 10: Greetings window
from PyQt5.QtCore import pyqtSignal , Qt
from PyQt5. QtWidgets import QPushButton , QVBoxLayout, QWidget, QSizePolicy , \
Electronic Journal. http://diffjournal.spbu.ru/ 222
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Differential Equations and Control Processes, N. 1, 2021
QSpacerltem , QHBoxLayout, QLabel , QCheckBox, QApplication , QStyle
from tools . fsys import lock , unlock from ui . main . svg import SVG
class GreetingsWidget (QWidget) :
show_main_menu = pyqtSignal ()
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
header = QLabel(”Welcome to SDE—MATH Software Package for ”
”the Numerical Solution of Systems of Ito SDEs”) font = header.font() font . setPointSize(15)
header . setAlignment (Qt. AlignJustify) header . setWordWrap (True) header.setFont(font)
welcome = QLabel (
”Exact solutions of Ito SDEs are known in rare cases. For this ”
” reason , it becomes necessary to construct numerical methods for ”
” Ito SDEs. Moreover , the problem of numerical solution of Ito SDEs ”
”often occurs even in cases when the exact solution of Ito SDE is known. ”
” This means that in some cases , knowing the exact solution to the Ito ”
”SDE does not allow us to simulate it numerically in a simple way.” , self
)
font = welcome . font () welcome . setFont ( font)
welcome . setAlignment (Qt. AlignJustify) welcome . setWordWrap ( True)
welcome . setSizePolicy( QSizePolicy( QSizePolicy . Expanding , QSizePolicy. Minimum) )
check_again = QCheckBox(”Do not show again” , self) next_btn = QPushButton(”Ok” , self)
next _btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_DialogApplyButton) ) check_again.clicked.connect(self.check_lock)
next_btn . clicked . connect (lambda: self. show_main_menu . emit () )
controls = QHBoxLayout ()
controls . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) controls . addWidget( check_again ) controls . addWidget (next_btn)
controls . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq1 = QHBoxLayout ()
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq1 . addWidget (SVG(” equation1.svg” , scale_factor = 1.))
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) )
Electronic Journal. http://diffjournal.spbu.ru/ 223
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
1
2
3
4
5
6
7
8
9
10
11
12
13
1
2
Differential Equations and Control Processes, N. 1, 2021
eq2 = QHBoxLayout ()
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq2 . addWidget (SVG(” equation2.svg” , scale_factor = 1.))
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) column = QVBoxLayout ()
column . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) column . addWidget ( header )
column . addItem(QSpacerItem(0 , 15, QSizePolicy . Expanding , QSizePolicy .Minimum) )
column . addLayout (eq1)
column . addItem(QSpacerItem(0 , 15, QSizePolicy . Expanding , QSizePolicy .Minimum) )
column . addLayout (eq2)
column . addItem(QSpacerItem(0 , 15, QSizePolicy . Expanding , QSizePolicy .Minimum) )
column . addWidget (welcome)
column . addItem(QSpacerItem(0 , 30, QSizePolicy . Expanding , QSizePolicy .Minimum) ) column . addLayout ( controls )
column . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) layout = QHBoxLayout ()
layout . addItem(QSpacerItem(50 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) layout . addLayout (column)
layout . addItem(QSpacerItem(50 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) self . setLayout(layout)
def check_lock ( self ) :
if self.sender() .isChecked() : lock (” . welcome . lock” ) else :
unlock(” . welcome . lock” )
Listing 11: Info icon
from PyQt5.QtCore import QSize
from PyQt5. QtWidgets import QWidget, QApplication , QStyle , QLabel
class InfoIcon (QLabel) :
def _ _ i n i t __ ( self , text: str , parent=None) :
super (QWidget, self) . __init__ (parent)
self . setToolTip(text)
self . setStyleSheet (”QToolTip { background: white; } ”)
self. setPixmap ( QApplication . style () . standardIcon (
QStyle. SP_MessageBoxInformation) . pixmap (QSize(16, 16)))
Listing 12: Error widget
from PyQt5.QtCore import QSize
from PyQt5. QtWidgets import QWidget, QApplication, QStyle, QLabel, QHBoxLayout,
QSpacerItem , QSizePolicy
Electronic Journal. http://diffjournal.spbu.ru/ 224
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1
Differential Equations and Control Processes, N. 1, 2021
class ErrorWidget(QWidget) :
def _ _init__(self , text: str , parent=None) :
super (QWidget, self) . __init__ (parent)
msg_m = QLabel(text)
msg_m. setStyleSheet (”QLabel { color: rgb(230, 0, 0); } ”) ms^i = QLabel ()
ms^i . setStyleSheet (”QToolTip { background: white; } ”)
ms^i .setPixmap(QApplication . style () . standardIcon(
QStyle.SP_MessageBoxCritical) . pixmap (QSize(16, 16)))
layout = QHBoxLayout ()
layout . setContentsMargins(0 , 0, 0, 0)
layout . addWidget ( msg_i)
layout .addWidget( msg_m)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)) self . setLayout(layout)
Listing 13: Svg picture
import os
from PyQt5.QtCore import QSize from PyQt5 . QtSvg import QSvgWidget from PyQt5. QtWidgets import QSizePolicy
from config import images
class SVG(QSvgWidget) :
def __init__(self, name: str , scale_factor = 1.):
super (QSvgWidget , self).__init__()
self . load(os .path . join (images , name) )
self.scale_factor = scale_factor
self . setSizePolicy ( QSizePolicy . Fixed , QSizePolicy . Fixed)
def sizeHint(self):
size = self.renderer().defaultSize() return QSize(size.width() * self.scale_factor, size.height() * self.scale_factor)
Listing 14: Main menu (base part)
from PyQt5. QtWidgets import QWidget, QSizePolicy, QSpacerItem , QHBoxLayout, QVBoxLayout,
Electronic Journal. http://diffjournal.spbu.ru/ 225
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Differential Equations and Control Processes, N. 1, 2021
QCheckBox, QLabel from ui . main . info import InfoIcon
from ui .main.menu. linear import LinearGroupWidget from ui .main.menu. taylor_ito import ItoGroupWidget
from ui .main.menu. taylor_stratonovich import StratonovichGroupWidget
class MainMenuWidget(QWidget) :
def __i n it __ ( self , parent=None) :
super (QWidget, self) . __init__ (parent)
self . charts_check = QCheckBox(”Charts window”, self)
icon = InfoIcon(”This is charts window checkbox , it will \ n”
” follow you on every application dialog , so\n”
”you can easily open or close window with available charts”)
bar_layout = QHBoxLayout ()
bar_layout . addItem(QSpacerItem (0 , 35, QSizePolicy . Expanding , QSizePolicy .Minimum))
bar_layout . addWidget ( icon )
bar_layout . addWidget ( self . charts_check)
header = QLabel(”Strong Numerical Schemes for Ito SDEs” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
icon = InfoIcon(”You are now in main menu, you can choose \ n” ”any scheme to perform modeling” )
header .layout = QHBoxLayout ()
header .layout addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy Expanding)
)
header .layout . addWidget ( icon )
header .layout addWidget ( header)
header .layout add Item ( Q Spacer Item (0 , 0, QSizePolicy . Expanding , QSizePolicy Expanding)
)
self.group3 = LinearGroupWidget( self ) self.group1 = ItoGroupWidget( self) self.group2 = StratonovichGroupWidget( self)
menu_layout = QHBoxLayout () menu-layout . addWidget ( self . group1) menu-layout . addWidget ( self . group2) menu-layout . addWidget ( self . group3)
layout = QVBoxLayout () layout . addLayout ( bar_layout)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) layout . addLayout ( header_layout)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) layout . addLayout (menu-layout)
Electronic Journal. http://diffjournal.spbu.ru/ 226
54
55
56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Differential Equations and Control Processes, N. 1, 2021
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) self . setLayout(layout)
Listing 15: Main menu (linear part)
from PyQt5.QtCore import pyqtSignal
from PyQt5. QtWidgets import QPushButton , QVBoxLayout, QSizePolicy, QSpacerItem , QGroupBox
class LinearGroupWidget(QGroupBox) :
show_linear_dialog = pyqtSignal ()
def __i n it __ ( self , parent=None) :
super (QGroupBox, self) . __init__ (parent)
linear_btn = QPushButton(”Dispersion Spectral Decomposition”)
layout = QVBoxLayout () layout . addWidget ( linear_btn )
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) self . setLayout(layout)
self . setTitle (”Linear Ito SDEs Systems Modeling”)
self . setSizePolicy ( QSizePolicy ( QSizePolicy . Expanding , QSizePolicy . Expanding) ) linear_btn . clicked .connect (lambda: self . show_linear_dialog .emit () )
Listing 16: Main menu (Taylor-ItO part)
from PyQt5.QtCore import pyqtSignal from PyQt5. QtWidgets import QPushButton,
QVBoxLayout, QSizePolicy, QSpacerItem, QGroupBox
class ItoGroupWidget(QGroupBox) :
show_nonlinear_dialog = pyqtSignal (int)
def __i n it __ ( self , parent=None) :
super (QGroupBox, self) . __init__ (parent)
btn1 = QPushButton(”Euler”)
btn2 = QPushButton(”Milstein”)
btn3 = QPushButton(”Convergence Order 1.5”)
btn4 = QPushButton(”Convergence Order 2.0”)
btn5 = QPushButton(”Convergence Order 2.5”)
btn6 = QPushButton(”Convergence Order 3.0”)
layout = QVBoxLayout () layout .addWidget(btn1)
Electronic Journal. http://diffjournal.spbu.ru/ 227
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Differential Equations and Control Processes, N. 1, 2021
Listing 17: Main menu (Taylor—Stratonovich part)
from PyQt5.QtCore import pyqtSignal
from PyQt5. QtWidgets import QPushButton , QVBoxLayout, QSizePolicy, QSpacerItem , QGroupBox
class StratonovichGroupWidget(QGroupBox) :
show_nonlinear_dialog = pyqtSignal (int)
def __init__(self , parent=None) :
super (QGroupBox, self) . __init__ (parent)
btn1 = QPushButton(”Convergence Order 1.0”)
btn2 = QPushButton(”Convergence Order 1.5”)
btn3 = QPushButton(”Convergence Order 2.0”)
btn4 = QPushButton(”Convergence Order 2.5”)
btn5 = QPushButton(”Convergence Order 3.0”)
layout = QVBoxLayout () layout .addWidget(btn1) layout .addWidget(btn2) layout .addWidget(btn3) layout .addWidget(btn4) layout .addWidget(btn5)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) self . setLayout(layout)
self. setTitle (”Taylor—Stratonovich Schemes”)
self . setSizePolicy ( QSizePolicy ( QSizePolicy . Expanding , QSizePolicy . Expanding) )
btn1 . clicked . connect (lambda: self . show_nonlinear_dialog . emit (6) ) btn2. clicked . connect (lambda: self . show_nonlinear_dialog . emit (7) )
Electronic Journal. http://diffjournal.spbu.ru/ 228
33
34
35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Differential Equations and Control Processes, N. 1, 2021
btn3 . clicked . connect (lambda self . show_nonlinear_dialog . emit (8) )
btn4 . clicked . connect (lambda self . show_nonlinear_dialog . emit (9) )
btn5 . clicked . connect (lambda self . show_nonlinear_dialog . emit (10) )
Listing 18: Complex progress view
import logging
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QSpacerltem , QSizePolicy ,
\
QListWidget , QLabel , QPushButton , QApplication , QStyle from pyqtspinner . spinner import WaitingSpinner
from ui . main . progress . log_handler import LogHandler
class ComplexProgressWidget(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self .spinner = WaitingSpinner ( self , radius =5.0, lines =10, line_length = 5.0, centerOnParent=False ) self.list_widget = QListWidget ( self) self. handler = LogHandler ( self . handle_message)
self . label = QLabel ( self) font = self . label . font () font . setPointSize(15) self.label.setFont(font)
self. back _btn = QPushButton ( ”Ok” )
self . back_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_DialogApplyButton) ) self.back_btn.hide()
spinner_layout = QHBoxLayout () spinner_layout . addWidget ( self . spinner) spinner_layout . addWidget ( self . label)
spinner_layout . addSpacerItem ( QSpacerItem (0 , 0 , QSizePolicy . Expanding ,
QSizePolicy .Minimum) )
bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget ( self . back_btn)
layout = QVBoxLayout () layout . addLayout ( spinner_layout) layout . addWidget ( self . list_widget ) layout . addLayout (bottom_bar)
Electronic Journal. http://diffjournal.spbu.ru/ 229
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Differential Equations and Control Processes, N. 1, 2021
Listing 19: Simple progress view
from PyQt5.QtCore import Qt
from PyQt5. QtWidgets import QVBoxLayout, QWidget, QLabel , QSpacerltem , QSizePolicy from pyqtspinner . spinner import WaitingSpinner
class SimpleProgressWidget(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.spinner = WaitingSpinner(self , radius = 15.0, lines = 10, line_length = 15.0) self . label = QLabel ()
self. label . setAlignment(Qt.AlignCenter) font = self . label . font () font . setPointSize(15) self.label.setFont(font)
layout = QVBoxLayout ()
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) ) layout . addWidget ( self . spinner)
layout . addItem(QSpacerItem(0 , 50, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addWidget (self. label)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding) )
self . setLayout(layout)
def spin(self, text): self.spinner.start() self.label.setText(text)
Electronic Journal. http://diffjournal.spbu.ru/ 230
32
33
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Differential Equations and Control Processes, N. 1, 2021
def stop(self):
self . spinner.stop()
Listing 20: Log handler for application
import logging
class LogHandler( logging . Handler) :
def __init__(self, callback): super() . __init__ () self. callback = callback
self. setFormatter( logging. Formatter(”%(asctime)s — %(message)s” , ”%H:%M:%S” ) )
def handle(self , record) :
self . callback( self . format (record))
Listing 21: Matrix widget
Electronic Journal. http://diffjournal.spbu.ru/ 231
Differential Equations and Control Processes, N. 1, 2021
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61 62
63
64
65
66
67
68
69
70
71
if item is not None:
item. setText( self .m[ i ] [j ]) else :
self.setItem(i, j, CustomItem (self.m[i][j]))
self. blockSignals(False)
def resize_h(self, h: int):
self . blockSignals (True)
old_h = self. rowCount () w = self . columnCount() self. setRowCount (h)
self .m = [[self.m[i][j] if i < old _h and j < w else ”0” for j in range (w) ] for i in range(h)]
for i in range(h): for j in range(w):
item = self.item(i, j) if item is not None:
item. setText( self .m[ i ] [j ]) else :
self.setItem(i, j, CustomItem (self.m[i][j]))
self. blockSignals(False)
def item_changed(self, item):
self .m[ item . row ()][item.column()] = item. text ()
class CustomItem(QTableWidgetItem) :
def __init__(self, value: str):
super ( QTableWidgetItem , self) . __init__(value)
self.valid = True
6.1.2 Source Codes of Charts Window
Listing 22: Charts window
1
2
3
4
5
6 7
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QMainWindow, QSplitter
from ui . charts . side . available_charts_widget import AvailableChartsWidget from ui . charts . visuals . charts_widget import ChartsWidget
Electronic Journal. http://diffjournal.spbu.ru/ 232
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Differential Equations and Control Processes, N. 1, 2021
Listing 23: Curves list
Electronic Journal. http://diffjournal.spbu.ru/ 233
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Differential Equations and Control Processes, N. 1, 2021
on_hide_all = pyqtSignal() on_show_all = pyqtSignal() on_remove_all = pyqtSignal()
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self. items = diet ()
self. spacer = QSpacerItem(0 , 0, QSizePolicy .Minimum, QSizePolicy . Expanding) self.plot_widget = self.parent().plot_widget
remove_all = QPushButton() remove_all . setFlat (True) remove_all . setIcon (
QApplication . style () . standardIcon (QStyle . SP_DialogResetButton) )
hide_all = QPushButton() hide _all . setFlat (True)
hide_all . setIcon (QtGui .QIcon(os .path . join (images , ” crossed .png” ) ) )
show_all = QPushButton() show_all . setFlat (True)
show_all . setIcon (QtGui .QIcon(os .path . join (images , ”eye .png” ) ) )
header_layout = QHBoxLayout () header_layout .addWidget(
InfoIcon (” Here You will see all modeling series \ n”
”You can hide them or delete , if you need to”)) header_layout .addItem(
QSpacerItem(5 , 0, QSizePolicy .Minimum, QSizePolicy .Minimum) ) header_layout . addWidget ( QLabel (” Curves” ) ) header_layout .addItem(
QSpacerItem(5 , 0, QSizePolicy .Minimum, QSizePolicy .Minimum) ) header_layout.setContentsMargins(0, 0, 0, 0) header_layout . setSpacing (0) header_layout .addItem(
QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)) header_layout . addWidget (show_all) header_layout . addWidget (hide_all) header_layout . addWidget ( remove_all)
self. layout = QVBoxLayout ()
self. layout.setContentsMargins(3, 3, 3, 3)
self . layout.setSpacing(2)
scro ll_widget = QWidget( self ) scroll_widget . setLayout ( self . layout)
scroll_area = QScrollArea ( self ) scrolLarea . setWidgetResizable(True) scroll_area . setWidget ( scroll_widget )
self . layout . addItem( self . spacer)
Electronic Journal. http://diffjournal.spbu.ru/ 234
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Differential Equations and Control Processes, N. 1, 2021
layout = QVBoxLayout () layout . setContentsMargins(0 , 0, 0, 0) layout . addLayout ( header_layout) layout . addWidget ( scrolLarea )
self . setLayout(layout)
self . setSizePolicy (
QSizePolicy( QSizePolicy . MinimumExpanding ,
QSizePolicy . MinimumExpanding) )
show_all . clicked . connect ( self . show_all) hide_all . clicked . connect ( self . hide_all) remove_all . clicked . connect ( self . delete_all )
def new_items(self, lines: list ):
self . layout . removeItem ( self . spacer)
for i in range (len (lines)) :
item_widget = ItemWidget ( lines [ i ] . name , lines [i ]. color , parent=self) item_widget . uid = lines [ i ] . uid
item_widget . on_show . connect ( self . plot_widget . show_item) item_widget . on_hide . connect ( self . plot_widget . hide_item) item_widget . on_delete . connect ( self . plot_widget . delete_item ) item_widget . on_delete . connect ( self . delete_item ) self.items [lines [i ]. uid] = item_widget
self . plot_widget . hide_label . connect (lambda uid: self. items [uid]. hide () )
self . plot_widget . show_label . connect (lambda uid: self. items [uid]. show () )
self . layout . addWidget (item_widget) self . layout . addItem( self . spacer)
def delete_item ( self ) : s = self.sender () s . setParent (None) self . items . pop (s . uid) self . layout . removeWidget (s)
def delete_all(self):
fo r i t e m i n s e l f . i t e m s . v a l u e s ( ) : item . setParent (None) self . layout . removeWidget (item) self . items . clear () self . on_remove_all . emit ()
def hide_all(self):
fo r i t e m i n s e l f . i t e m s . v a l u e s ( ) : item . checkbox . blockSignals (True) item . checkbox . setChecked ( False) item . checkbox . blockSignals(False) self . on_hide_all . emit ()
def show_all(self):
Electronic Journal. http://diffjournal.spbu.ru/ 235
125
126
127
128
129
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Differential Equations and Control Processes, N. 1, 2021
for item in self. items. values (): item . checkbox . blockSignals (True) item . checkbox . setChecked (True) item . checkbox . blockSignals(False) self . on_show_all . emit ()
Listing 24: Curves list item
Electronic Journal. http://diffjournal.spbu.ru/ 236
46
47
48
49
50
51
52
53
54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Differential Equations and Control Processes, N. 1, 2021
Listing 25: Charts area
Electronic Journal. http://diffjournal.spbu.ru/ 237
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Differential Equations and Control Processes, N. 1, 2021
self . btn_to_fn . setFlat (True)
self . btn_to_mx = QPushButton(”Expectations”) self . btn_to_mx . setFlat (True) self . btn_to_dx = QPushButton(”Variances”) self . btn_to_dx . setFlat (True)
toolbar-layout = QHBoxLayout () toolbar_layout.setContentsMargins(0, 0, 0, 0) toolbar_layout . setSpacing (0)
toolbar-layout . addItem(QSpacerItem(15 , 0, QSizePolicy .Minimum, QSizePolicy .Minimum) ) toolbar-layout . addWidget( InfoIcon (”Click this buttons to switch plot modes \ n”
”between trajectories , expectations and variances”)) toolbar_layout . addItem(QSpacerItem(15 , 0, QSizePolicy .Minimum, QSizePolicy .Minimum) ) toolbar_layout . addWidget ( self . btn_to_fn) toolbar_layout . addWidget ( self .btn_to_mx) toolbar_layout . addWidget ( self . btn_to_dx) toolbar_layout . addWidget ( self . toolbar)
toolbar-layout . addItem(QSpacerItem(15 , 0, QSizePolicy .Minimum, QSizePolicy .Minimum) )
layout = QVBoxLayout ()
layout . setContentsMargins(0 , 0, 0, 0)
layout . setSpacing (0)
layout . addLayout (toolbar-layout)
layout . addWidget ( self . canvas)
self . setLayout(layout)
self . setSizePolicy ( QSizePolicy ( QSizePolicy . Expanding , QSizePolicy . Expanding) )
self . btn_to_fn . pressed . connect ( self . fn_mode) self . btn_to_mx . pressed . connect ( self . mx_mode) self . btn_to_dx . pressed . connect ( self . dx_mode)
def rescale(self):
self .ax. relim ( visible_only=True) self .ax.autoscale() self.canvas.draw ()
def clear(self):
for f in self . plots.values() : self . hide_label . emit( f . uid) if f. l ine_fn is not None:
f. line _f n . set_visible( False) if f.line_mx is not None:
f.line_mx. set_visible( False) if f.line_dx is not None:
f. line _d x . set_visible (False)
def fn_mode( self) :
self. mode = 0
self . clear ()
fo r f i n self . plots.values() :
Electronic Journal. http://diffjournal.spbu.ru/ 238
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
Differential Equations and Control Processes, N. 1, 2021
if f. l ine_fn is not None:
self . show_label . emit ( f. uid) if f .visible:
f. line _f n . set_visible( True) self.rescale() def mx_mode( self ) : self. mode = 1 self . clear ()
for f in self . plots.values() : if f.line_mx is not None:
self . show_label . emit ( f. uid) if f .visible:
f. line_mx. set_visible ( True) self.rescale() def dx_mode(self): self. mode = 2 self . clear ()
fo r f i n self . plots.values() : if f.line_dx is not None:
self . show_label . emit ( f. uid) if f .visible:
f. line_dx . set_visible(True) self.rescale()
def new_items(self, lines: list ):
for line in lines :
self.plots [line.uid] = line
fo r f i n self . plots.values() :
if f. l ine_fn is None and f.fn is not None:
f.line_fn = self .ax. plot ( f .t , f . fn , linewidth = 1, color=f . color ) [0] if f.line_mx is None and f.mx is not None:
f.line_mx = self.ax.plot(f.t, f. mx, linewidth = 1, color=f. color) [0] if f.line_dx is None and f.dx is not None:
f.line_dx = self.ax. plot (f.t, f. dx , linewidth = 1, color=f. color) [0]
if self. mode == 0: self. fn_mode ()
if self. mode == 1: self. mx_mode ()
if self. mode == 2:
Electronic Journal. http://diffjournal.spbu.ru/ 239
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Differential Equations and Control Processes, N. 1, 2021
self. dx_mode ()
def delete_item(self, uid: int):
item = self.plots. pop (uid)
Color . free (item . color) if item . line_fn is not None: item . line_fn . remove () if item . line_mx is not None: item . line_mx . remove () if item.line_dx is not None: item . line_dx . remove ()
self.rescale()
def hide_item(self, uid: int):
item = self. plots [uid]
if item. line_fn is not None and self .mode == 0: item . line_fn . set_visible (False) if item . line_mx is not None and self.mode == 1: item . line_mx . set_visible ( False) if item.line_dx is not None and self.mode == 2: item . line_dx . set_visible ( False) item. visible = False
self.rescale()
def show_item (self, uid: int):
item = self. plots [uid]
if item. line_fn is not None and self.mode == 0: item . line_fn . set_visible (True) if item . line_mx is not None and self.mode == 1: item . line_mx . set_visible (True) if item.line_dx is not None and self.mode == 2: item . line_dx . set_visible (True) item. visible = True
self.rescale()
def show_all(self):
for item in self. plots. values ():
if item. line_fn is not None and self.mode == 0: item. line_fn . set_visible(True) if item . line_mx is not None and self.mode == 1: item . line_mx . set_visible (True) if item.line_dx is not None and self.mode == 2: item . li ne _dx . set_visible (True) item. visible = True
self.rescale()
def hide_all(self):
for item in self. plots. values ():
if item. line_fn is not None and self.mode == 0: item. li ne _fn . set_visible (False) if item . line_mx is not None and self.mode == 1:
Electronic Journal. http://diffjournal.spbu.ru/ 240
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Differential Equations and Control Processes, N. 1, 2021
item.line_mx. set_visible (False) if item.line_dx is not None and self.mode == 2: item. line_dx . set_visible (False) item. visible = False
self.rescale()
def delete_all(self):
for item in reversed (self. plots. values ()):
Color . free (item . color ) if item.line_fn is not None: item. li ne _fn . remove () if item . line_mx is not None: item . line_mx . remove () if item.line_dx is not None: item . li ne _dx . remove ()
self.plots.clear()
self.rescale()
def on_resize(self , event): self . figure . tight_layout () self.canvas.draw ()
Listing 26: Curves color
from random import choice
class Color :
reserved_colors = [
”#ff834a” ,
”#ffe100” ,
”#c700c7” ,
”#24e280” ,
”#1100ff” ,
”#f f 1 e2 2” ,
]
a v a i l a b l e_c o lo r s = [
”#ff834a” ,
”#ffe100” ,
”#c700c7” ,
”#24e280” ,
”#1100ff” ,
”#ff 1 e 2 2” ,
]
def __new__(cls, * args, ** kwargs ) : try :
return cls . available_colors .pop ()
Electronic Journal. http://diffjournal.spbu.ru/ 241
Differential Equations and Control Processes, N. 1, 2021
27
28
29
30
31
32
33
34
35
Listing 27: Curve
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20
6.1.3 Source Codes of Input for Nonlinear Systems of Ito SDEs
from ui . charts . visuals . color import Color
class Line : count = 0
def __init__(self, name, t, fn , mx=None, dx=None) : self.name = name self.t = t self.fn = fn self. mx = mx self.dx = dx self.line_fn = None self.line_mx = None self.line_dx = None self. visible = True self. color = Color ()
self.uid = Line.count Line.count += 1
except IndexError:
return f”# { ’’. join ([ choice (’0123456789ABCDEF’) for j in range(6)]) } @classmethod
def free(cls , code: str) :
if code in cls.reserved_colors:
cls . available_colors .append(code)
Listing 28: Base part of data input for nonlinear systems
1
2
3
4
5
6
7
8 9
10
11
12
13
import logging import numpy as np
from PyQt5.QtCore import QThreadPool , pyqtSignal
from PyQt5. QtWidgets import QCheckBox, QPushButton , QStyle , QApplication ,\
QSizePolicy , QHBoxLayout, QSpacerItem , QVBoxLayout, QStackedWidget , \
QWidget , QLabel from sympy import Matrix
import config
from mathematics . sde . nonlinear . drivers . euler import euler
from mathematics . sde . nonlinear . drivers . milstein import milstein
from mathematics . sde . nonlinear . drivers . strong_taylor_ito_1p5 import strong_taylor_ito_1p5
Electronic Journal. http://diffjournal.spbu.ru/ 242
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . drivers . strong_taylor_ito_2p0 import strong_taylor_ito_2p0
from mathematics . sde . nonlinear . drivers . strong_taylor_ito_2p5 import strong_taylor_ito_2p5
from mathematics . sde . nonlinear . drivers . strong_taylor_ito_3p0 import strong_taylor_ito_3p0
from mathematics . sde . nonlinear . drivers . strong_taylor_stratonovich_1p0 import
strong_taylor_stratonovich_1p0
from mathematics . sde . nonlinear . drivers . strong_taylor_stratonovich_1p5 import strong_taylor_stratonovich_1p5
from mathematics . sde . nonlinear . drivers . strong_taylor_stratonovich_2p0 import strong_taylor_stratonovich_2p0
from mathematics . sde . nonlinear . drivers . strong_taylor_stratonovich_2p5 import strong_taylor_stratonovich_2p5
from mathematics . sde . nonlinear . drivers . strong_taylor_stratonovich_3p0 import strong_taylor_stratonovich_3p0
from mathematics . sde . nonlinear . symbolic . coefficients . c import C from tools import database
from ui . async_calls . worker import Worker
from ui . charts . visuals . line import Line
from ui . main . modeling . nonliear . step1 import Step 1
from ui . main . modeling . nonliear . step2 import Step2
from ui . main . modeling . nonliear . step3 import Step3
from ui . main . modeling . nonliear . step4 import Step4
from ui . main . modeling . nonliear . step5 import Step5
class NonlinearModelingWidget(QWidget) :
show_main_menu = pyqtSignal () start_progress = pyqtSignal(str) stop_progress = pyqtSignal(str) draw_chart = pyqtSignal ( list )
def __i n it __ ( self , parent=None) :
super (QWidget, self) . __init__ (parent)
self. logger = logging.getLogger(__name__)
self.scheme_id = 0 self. schemes = [
(euler , ”Euler” , ”Euler Scheme”) ,
(milstein , ”Milstein” , ”Milstein Scheme”) ,
( strong_taylor_ito_1p5 , ”Taylor — Ito 1.5” ,
”Strong Taylor — Ito Scheme with Convergence Order 1.5”) ,
( strong_taylor_ito_2p0 , ”Taylor — Ito 2.0” ,
”Strong Taylor — Ito Scheme with Convergence Order 2.0”) ,
( strong_taylor_ito_2p5 , ”Taylor — Ito 2.5” ,
”Strong Taylor — Ito Scheme with Convergence Order 2.5”) ,
( strong_taylor_ito_3p0 , ”Taylor — Ito 3.0” ,
”Strong Taylor — Ito Scheme with Convergence Order 3.0”) ,
( strong_taylor_stratonovich_1p0 , ”Taylor — Str. 1.0” ,
”Strong Taylor — Stratonovich Scheme with Convergence Order 1.0”) , ( strong_taylor_stratonovich_1p5 , ”Taylor — Str. 1.5” ,
”Strong Taylor — Stratonovich Scheme with Convergence Order 1.5”) , ( strong_taylor_stratonovich_2p0 , ”Taylor — Str. 2.0” ,
”Strong Taylor — Stratonovich Scheme with Convergence Order 2.0”) , ( strong_taylor_stratonovich_2p5 , ”Taylor — Str. 2.5” ,
”Strong Taylor — Stratonovich Scheme with Convergence Order 2.5”) ,
Electronic Journal. http://diffjournal.spbu.ru/ 243
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Differential Equations and Control Processes, N. 1, 2021
( strong_taylor_stratonovich_3p0 , ”Taylor — Str . 3.0” ,
’’Strong Taylor — Stratonovich Scheme with Convergence Order 3.0”) ,
]
self . stack_widget = QStackedWidget( self )
self.step1 = Step1() self.step2 = Step2() self.step3 = Step3() self.step4 = Step4() self.step5 = Step5()
back_btn = QPushButton(”Back” , self)
back_btn . setIcon (QApplication . style () . standardIcon(QStyle. SP_ArrowBack) ) self . charts_check = QCheckBox(”Charts window”, self) self.scheme_name = QLabel ()
self . scheme_name. setSizePolicy ( QSizePolicy . Expanding , QSizePolicy . Minimum)
bar_layout = QHBoxLayout () bar_layout . addWidget( back_btn )
bar_layout . addItem(QSpacerItem(10 , 35, QSizePolicy .Minimum, QSizePolicy .Minimum)) bar_layout . addWidget ( self. scheme_name)
bar_layout . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bar_layout . addWidget ( self . charts_check)
self . stack_widget . addWidget (self.step1) self . stack_widget . addWidget ( self . step2) self . stack_widget . addWidget ( self . step3) self . stack_widget . addWidget ( self . step4) self . stack_widget . addWidget ( self . step5)
layout = QVBoxLayout ()
layout . addLayout ( bar_layout)
layout . addWidget ( self . stack_widget)
self . setLayout(layout)
back_btn . clicked . connect ( self . show_main_menu . emit) back_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step1 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step2) )
self . step2 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step2 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step3) )
self . step3 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step2) )
self . step3 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step4) )
self . step4 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step3) )
Electronic Journal. http://diffjournal.spbu.ru/ 244
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Differential Equations and Control Processes, N. 1, 2021
self . step4 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step5) )
self . step5 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step4) )
self . step5 . run_btn . clicked . connect ( lambda: self . run_modeling () )
self . step5 . run_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step1 . n_valid . connect ( self . step2 . matrix . resize_h ) self . step1 . n- valid . connect ( self . step3 . matrix . resize_h ) self . step1 . n_valid . connect ( self . step4 . matrix . resize_h )
self . step1 . m_valid . connect ( self . step3 . matrix . resize_w )
def set_scheme(self, scheme_id): self.scheme_id = scheme_id
self . schem^name. setText( self .schemes [scheme_id ] [2] ) if scheme_id == 0:
self . step5 . count_c ( False) else :
self . step5 . counLc (True)
def run_modeling( self ) :
self.start_progress.emit(”The modeling is being performed.. .”)
worker = Worker( self . routine )
worker . signals . result . connect ( self . on_modeling_finish ) worker . signals . error . connect ( self . on_modeling_corrupted) QThreadPool .globalInstance() .start (worker)
def routine(self):
scheme = self. schemes [ self. scheme_id]
a = Matrix( self . step2 . matrix .m) b = Matrix( self . step3 . matrix .m)
x0 = np.ndarray(shape = (self.step4. matrix. rowCount () ,
self . step4 . matrix .columnCount() ) , dtype=float) for i in range( self . step4 . matrix . rowCount () ) :
for j in range ( self . step4 . matrix .columnCount() ) : x0[i][j] = float (self.step4.matrix.m[i][j])
if self.step5.s != 0:
np . random . seed ( self . step5 . s)
database.connect(config .database)
if self.scheme_id == 0: result = scheme [0]( x0 , a, b,
(self.step5.t0 , self.step5.dt ,
Electronic Journal. http://diffjournal.spbu.ru/ 245
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Differential Equations and Control Processes, N. 1, 2021
self.step5.t1)
)
else :
C. preload (56 , 56, 56, 56, 56) result = scheme [0](
x0, a, b, self.step5.c,
(self.step5.t0 , self.step5.dt , self.step5.t1)
)
database.disconnect()
lines = [Line(f” {scheme [1] } , x { i + 1} ”,
np.array( result [1]) .astype( float) , np.array(result [ 0 ][ i , :]) .astype( float))
for i in range(len(result [0]) )]
return lines
def on_modeling_finish ( self , result) :
self.stop_progress.emit(”The modeling has been completed!”) self . draw_chart . emit( result )
def on_modeling_corrupted ( self , result ) :
self.logger.error(result [0]) self.logger.error(result [1]) self.logger.error(result [2])
self . stop_progress . emit(”The modeling failed !” )
Listing 29: Step 1 of data input for nonlinear systems
Electronic Journal. http://diffjournal.spbu.ru/ 246
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Differential Equations and Control Processes, N. 1, 2021
self.input_stack = self.parent()
info _n = InfoIcon (” Dimension of linear system of Ito SDEs” )
info_m = InfoIcon (” Dimension of vector Wiener process” )
label _n = QLabel(”n”) label_m = QLabel(”m”)
self. lineedit_n = QLineEdit() self.lineedit_m = QLineEdit()
self.msg_n = ErrorWidget(”Wrong value!”) self . ms^n . hide ()
self.msg_m = ErrorWidget(”Wrong value!”) self. ms^m . hide ()
grid_layout = QGridLayout () grid_layout . addWidget( self . ms^n , 0, 2) grid_layout . addWidget( self . ms^m , 2, 2)
grid_layout . addWidget( info_n , 1, 0)
grid_layout . addWidget(info_m , 3, 0) grid_layout . addWidget( labeLn , 1, 1)
grid_layout . addWidget(label_m , 3, 1)
grid_layout . addWidget( self . lineedit _n , 1, 2)
grid_layout . addWidget (self.lineedit_m , 3, 2)
header = QLabel(”Dimensions settings”, parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . next_btn . setEnabled( False)
header_layout = QHBoxLayout ()
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) header_layout . addWidget( header )
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self. next _btn)
eq1 = QHBoxLayout ()
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq1 . addWidget (SVG(” equation1.svg” , scale_factor = 1.))
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq2 = QHBoxLayout ()
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq2 . addWidget (SVG(” equation2.svg” , scale_factor = 1.))
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) )
Electronic Journal. http://diffjournal.spbu.ru/ 247
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Differential Equations and Control Processes, N. 1, 2021
equalities_layout = QVBoxLayout () equalities_layout . addLayout (eq1)
equalities.layout . addItem(QSpacerItem(0 , 20, QSizePolicy .Minimum, QSizePolicy .Minimum
))
equalities_layout . addLayout (eq2) equalities_wrap = QHBoxLayout ()
equalities_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)
)
equalities_wrap . addLayout ( equalities_layout )
equalities_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)
)
grid_wrap = QHBoxLayout ()
grid_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) grid_wrap . addLayout ( grid_layout )
grid_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) layout = QVBoxLayout ()
layout . addItem(QSpacerItem(0 , 0, QSizePolicy .Minimum, QSizePolicy . Expanding)) layout . addLayout ( equalities_wrap )
layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout ( header_layout)
layout . addItem(QSpacerItem(0 , 5, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout (grid_wrap)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy .Minimum, QSizePolicy . Expanding)) layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . lineedit_n . textChanged . connect ( self . validate_n ) self. lineedit_m . textChanged . connect ( self . validate_m )
def validate_form ( self ) :
if self. n_is_valid and self. m_is_valid : self . next _btn . setEnabled( True) else :
self . next_btn . setEnabled ( False)
def validate_n(self, value): try :
typed_value = int (value) if typed_value <= 0: raise ValueError()
self . n _is-valid = True
self . n - valid . emit (typed_value)
self. msg_n . hide ()
except ValueError :
self.n_is_valid = False self. msg_n . show ()
Electronic Journal. http://diffjournal.spbu.ru/ 248
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Differential Equations and Control Processes, N. 1, 2021
Listing 30: Step 2 of data input for nonlinear systems
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QLabel , QSpacerltem , QSizePolicy, \ QVBoxLayout, QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
from ui .main. modeling . matrix_widget import MatrixWidget
class Step2(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.errors = 0
header = QLabel(”Setting of column a(x, t)” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
info = InfoIcon(”Elements of column a(x, t) are expected to be functions \ n”
” Size : n x 1 \n”
’’Functions must be set in python and SymPy notation”)
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) )
Electronic Journal. http://diffjournal.spbu.ru/ 249
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Differential Equations and Control Processes, N. 1, 2021
self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
Listing 31: Step 3 of data input for nonlinear systems
Electronic Journal. http://diffjournal.spbu.ru/ 250
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Differential Equations and Control Processes, N. 1, 2021
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next _btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
Listing 32: Step 4 of data input for nonlinear systems
Electronic Journal. http://diffjournal.spbu.ru/ 251
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Differential Equations and Control Processes, N. 1, 2021
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self.prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
Listing 33: Step 5 of data input for nonlinear systems
import sys
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel , QLineEdit , \ QGridLayout , QVBoxLayout, QSizePolicy, QSpacerItem , QPushButton , \ QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
class Step5(QWidget) :
def __i n it __ ( self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.t0 = sys.float_info. min self.dt = 0
self.t1 = sys.float.info.max self.s = 0 self.c = 0
self.t0_is_valid = False self.dt_is_valid = False self.t1_is_valid = False self . s_is_valid = True
Electronic Journal. http://diffjournal.spbu.ru/ 252
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Differential Equations and Control Processes, N. 1, 2021
self.c_is_valid = False self.input_stack = self.parent()
info _t0 = InfoIcon(”Start point of integration interval\n”
” Must be in [0, t1) range”) info _dt = InfoIcon(”Integration step \ n”
” Must be set in (0, 1) interval”)
info_t1 = InfoIcon (”Final point of integration interval\n”
” Must be more then t0” )
info_s = InfoIcon (”This is random generator seed\n”
” If You do not want to use specific \n”
”seed just leave this field empty” )
self.info_c = InfoIcon (”The constant which defines approximation accuracy”)
label_t0 = QLabel(”t0”) label _dt = QLabel (”dt” ) label_t1 = QLabel(”t1”) labeLs = QLabel(”seed”) self. label_c = QLabel(”C”)
self . lineedit _t0 = QLineEdit() self. lineedit_dt = QLineEdit() self . lineedit _t1 = QLineEdit() self. lineedit_s = QLineEdit() self. lineedit_c = QLineEdit()
self.msg_t0 = ErrorWidget(”Wrong value!”) self . msg_t0 . hide ()
self.msg_dt = ErrorWidget(”Wrong value!”) self. msg_dt . hide ()
self.msg_t1 = ErrorWidget(”Wrong value!”) self . msg_t1 . hide ()
self.msg_s = ErrorWidget(”Wrong value!”) self . ms^s. hide ()
self.msg_c = ErrorWidget(”Wrong value!”) self . ms^c . hide ()
header = QLabel(”Accuracy settings”, parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) ) self.run_btn = QPushButton(”Perform modeling”, self)
self . run_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . run_btn . setEnabled ( False)
header_layout = QHBoxLayout ()
Electronic Journal. http://diffjournal.spbu.ru/ 253
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Differential Equations and Control Processes, N. 1, 2021
header_layout . addWidget( header )
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) botto^_bar = QHBoxLayout ()
botto^_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget ( self . run_btn)
grid-layout = QGridLayout ()
grid-layout . addWidget( self . msg_t0 , 0, 2)
grid_layout . addWidget( info_t0 , 1, 0)
grid-layout . addWidget( label_t0 , 1, 1)
grid-layout . addWidget( self . lineedit_t0 , 1, 2)
grid_layout . addWidget( self . msg_dt , 0, 5)
grid-layout . addWidget( info_dt , 1,3)
grid-layout . addWidget( label_dt , 1, 4)
grid-layout . addWidget( self . lineedit_dt , 1, 5)
grid-layout . addWidget( self . msg_t1 , 0, 8)
grid-layout . addWidget( info_t1 , 1, 6)
grid-layout . addWidget( label_t1 , 1, 7)
grid-layout . addWidget( self . lineedit_t1 , 1, 8)
grid-layout . addWidget( self . msg_s , 2, 2)
grid-layout . addWidget( info_s , 3, 0) grid_layout . addWidget( label_s , 3, 1)
grid-layout . addWidget( self . lineedit_s , 3, 2)
grid-layout . addWidget( self . msg_c , 2, 5)
grid-layout . addWidget( self . info_c , 3, 3)
grid-layout . addWidget( self . label_c , 3, 4) grid-layout . addWidget( self . lineedit_c , 3, 5)
column_layout = QVBoxLayout ()
column_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding)
)
column_layout . addLayout ( header_layout)
column_layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) column_layout . addLayout ( grid-layout )
column_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding)
)
control-layout = QHBoxLayout ()
control-layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding
))
control-layout . addLayout (column_layout)
control-layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding
))
Electronic Journal. http://diffjournal.spbu.ru/ 254
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Differential Equations and Control Processes, N. 1, 2021
layout = QVBoxLayout ()
layout . addLayout ( control-layout )
layout . addLayout (bottom_bar)
self . setLayout(layout)
self. lineedit_t0 . textChanged . connect ( self . validate_t0 )
self. lineedit_t0 . textChanged . connect ( self . validate_t1 )
self. lineed it _t0 . textChanged . connect ( self . validate_dt )
self. lineed it _dt . textChanged . connect ( self . validate_dt )
self. lineed it _t1 . textChanged . connect ( self . validate_t0 )
self. lineed it _t1 . textChanged . connect ( self . validate_t1 )
self. lineed it _t1 . textChanged . connect ( self . validate_dt )
self. lineedit _s . textChanged . connect ( self . validate_s )
self.lineedit_c. textChanged . connect ( self . validate_c )
def count_c ( self , flag: bool):
if flag :
self . i nfo _c . show () self . label _c . show () self. lineedit_c . show () self . validate_c () else :
self. i nfo _c .hide() self.label_c. hide () self. lineedit_c .hide() self . c _is _ valid = True
self . msg_c . hide ()
def validate_form ( self ) : if self . t0_is_valid \
and self . dt_is_valid \ and self.t1_is_valid \ and self.s_is_valid \ and self. c _is _valid : self . run_btn . setEnabled ( True) else :
self . run_btn . setEnabled( False)
def validate_t0(self): try :
typed _value = float ( self. lineedit_t0. text ()) if typed_value >= self . t1 : raise ValueError()
self.t0_is_valid = True self.t0 = typed_value self . msg_t0 . hide ()
except ValueError :
self.t0_is_valid = False self . msg_t0 . show ()
Electronic Journal. http://diffjournal.spbu.ru/ 255
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
Differential Equations and Control Processes, N. 1, 2021
def validate_dt(self ) : try :
typed _value = float ( self. lineedit_dt. text ()) if typed_value <= 0 \
or (self.t1 — self.t0) / typed_value < 1 \ or typed_value >= 1: raise ValueError()
self . dt_is_valid = True self.dt = typed_value self . msg_dt . hide () self . validate_form ()
except ValueError :
self.dt_is_valid = False self . msg_dt . show ()
def validate_t1(self): try :
typed-value = float ( self. lineedit_t1.text ()) if typed_value <= self . t0 : raise ValueError ()
self . t1 _is_valid = True self.t1 = typed_value self . ms^t1 . hide ()
except ValueError :
self.t1_is_valid = False self . msg_t1 . show ()
def validate_s ( self ) : try :
if self.lineedit_s.text() == ””: self.s_is_valid = True self.s = 0 else :
typed_value = int (self. lineedit_s.text ()) if typed_value <= 0: raise ValueError () self.s = typed_value
self . s _is _valid = True self . msg_s . hide ()
except ValueError :
self.s_is_valid = False self . msg_s . show ()
finally :
self . validate_form ()
def validate_c(self): try :
typed _value = float ( self. lineedit_c. text ())
Electronic Journal. http://diffjournal.spbu.ru/ 256
Differential Equations and Control Processes, N. 1, 2021
242
243
244
245
246
247
248
249
250
251
252
253
254
if typed_value <= 0: raise ValueError()
self.c_is_valid = True self.c = typed_value self . msg_c . hide ()
exce pt ValueError :
self.c_is_valid = False self . msg_c . show ()
finally :
self . validate_form ()
6.1.4 Source Codes of Input for Linear Systems of Ito SDEs
Listing 34: Base part of data input for linear systems
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
import logging
from time import time
import numpy as np
from PyQt5.QtCore import QThreadPool , pyqtSignal
from PyQt5. QtWidgets import QCheckBox, QPushButton , QStyle , QApplication , \ QSizePolicy , QHBoxLayout, QSpacerItem , QVBoxLayout, QStackedWidget , \ QWidget , QLabel
from mathematics . sde . linear . dindet import dindet
from mathematics . sde . linear . distortions import Symbolic , ComplexDistortion
from mathematics. sde. linear . integration import Integral
from mathematics . sde . linear . stoch import stoch
from ui . async_calls . worker import Worker
from ui . charts . visuals . line import Line
from ui . main . modeling . linear . step1 import Step1
from ui . main . modeling . linear . step2 import Step2
from ui . main . modeling . linear . step3 import Step3
from ui . main . modeling . linear . step4 import Step4
from ui . main . modeling . linear . step5 import Step5
from ui . main . modeling . linear . step6 import Step6
from ui . main . modeling . linear . step7 import Step7
from ui . main . modeling . linear . step8 import Step8
class LinearModelingWidget(QWidget) :
show_main_menu = pyqtSignal () start_progress = pyqtSignal(str) stop_progress = pyqtSignal(str) draw_chart = pyqtSignal ( list )
def __i n it __ ( self , parent=None) :
Electronic Journal. http://diffjournal.spbu.ru/ 257
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Differential Equations and Control Processes, N. 1, 2021
super (QWidget, self) . __init__ (parent)
self. logger = logging.getLogger(__name__)
self . stack_widget = QStackedWidget( self )
self.step1 = Step1() self.step2 = Step2() self.step3 = Step3() self.step4 = Step4() self.step5 = Step5() self.step6 = Step6() self.step7 = Step7() self.step8 = Step8()
back_btn = QPushButton (”Back” , self)
back_btn . setIcon (QApplication . style () . standardIcon(QStyle. SP_ArrowBack) )
self . charts_check = QCheckBox(”Charts window”, self)
self . schem^name = QLabel (”Linear Systems of Ito SDEs” )
bar_layout = QHBoxLayout () bar_layout . addWidget( back_btn )
bar_layout . addItem(QSpacerItem(10 , 35, QSizePolicy .Minimum, QSizePolicy .Minimum)) bar_layout . addWidget ( self. scheme_name)
bar_layout . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bar_layout . addWidget ( self . charts_check)
self . stack_widget . addWidget (self.step1) self . stack_widget . addWidget ( self . step2) self . stack_widget . addWidget ( self . step3) self . stack_widget . addWidget ( self . step4) self . stack_widget . addWidget ( self . step5) self . stack_widget . addWidget ( self . step6) self . stack_widget . addWidget ( self . step7) self . stack_widget . addWidget ( self . step8)
layout = QVBoxLayout ()
layout . addLayout ( bar_layout)
layout . addWidget ( self . stack_widget)
self . setLayout(layout)
back_btn . clicked . connect ( self . show_main_menu . emit) back_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step1 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step2) )
self . step2 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step2 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step3) )
self . step3 . prev_btn . clicked . connect (
Electronic Journal. http://diffjournal.spbu.ru/ 258
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Differential Equations and Control Processes, N. 1, 2021
lambda: self . stack_widget . setCurrentWidget( self . step2) )
self . step3 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step4) )
self . step4 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step3) )
self . step4 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step5) )
self . step5 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step4) )
self . step5 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step6) )
self . step6 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step5) )
self . step6 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step7) )
self . step7 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step6) )
self . step7 . next_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step8) )
self . step8 . prev_btn . clicked . connect (
lambda: self . stack_widget . setCurrentWidget( self . step7) )
self . step8 . run_btn . clicked . connect ( lambda: self . run_modeling () )
self.step8.run_btn . clicked .connect(
lambda: self . stack_widget . setCurrentWidget ( self . step1) )
self . step1 . n_valid . connect ( self . step2 . matrix . resize_h ) self . step1 . n _valid . connect ( self . step2 . matrix . resize_w )
self . step1 . n _valid . connect ( self . step3 . matrix . resize_h )
self . step1 . k_valid . connect ( self . step3 . matrix . resize_w )
self . step1 . n_valid . connect ( self . step4 . matrix . resize_h ) self . step1 . m .valid . connect ( self . step4 . matrix . resize_w )
self . step1 . k .valid . connect ( self . step5 . matrix . resize_h )
self . step1 . n .valid . connect ( self . step6 . matrix . resize_w )
self . step1 . n- valid . connect ( self . step7 . matrix . resize_h )
def run_modeling( self ) :
self.start_progress.emit(”The modeling is being performed.. .”)
worker = Worker( self . routine )
worker . signals . result . connect ( self . on_modeling_finish ) worker . signals . error . connect ( self . on_modeling_corrupted) QThreadPool .globalInstance() .start (worker)
def routine(self):
n = int(self.step1.lineedit_n.text()) m = int ( self . step1 . lineedit_m . text () ) k = int ( self. step1.lineedit_k. text ()) t0 = float ( self. step8.lineedit_t0.text ())
Electronic Journal. http://diffjournal.spbu.ru/ 259
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
Differential Equations and Control Processes, N. 1, 2021
dt = float ( self. step8.lineedit_dt.text ()) t1 = float ( self. step8.lineedit_t1.text ())
self. logger.info(” Reading input data”)
integral = Integral(n)
integral.k, integral.m, integral.dt, integral.t0, integral.tk = \
k, m, dt , t0 , t1
integral . m_a = np.array ( [[ float ( self. step2 . matrix.m[ i ] [j ])
for j in range( self . step2 . matrix . columnCount () ) ]
for i in range ( self . step2 . matrix. rowCount () ) ])
integral . mat_b = np. array ( [[ float ( self. step3 . matrix.m[ i ] [j ])
for j in range ( self . step3 . matrix .columnCount() ) ]
for i in range ( self . step3 . matrix . rowCount () ) ])
integral . mat_f = np. array ( [[ float ( self. step4 . matrix.m[ i ] [j ])
for j in range ( self . step4 . matrix .columnCount() ) ]
for i in range ( self . step4 . matrix . rowCount () ) ])
integral . m_h = np.array ( [[ float ( self. step6 . matrix.m[ i ] [j ])
for j in range( self . step6 . matrix . columnCount () ) ]
for i in range ( self . step6 . matrix. rowCount () ) ])
integral . m_x0 = np.array ( [[ float ( self. step7. matrix.m[ i ] [j ])
for j in range ( self . step7 . matrix .columnCount() ) ] for i in range ( self . step7 . matrix. rowCount () ) ])
integral . m_mx0 = np. array ( [[ float ( self. step7. matrix.m[ i ] [j ])
for j in range ( self . step7 . matrix .columnCount() ) ]
for i in range ( self . step7 . matrix . rowCount () ) ])
integral. m_dx0 = np.zeros((integral .n, integral.n))
self.logger.info(”Input is correct”)
self . logger . info (” Calculation of Ad and Bd (Algorithm 11.2)”)
integral. m_ad, integral . m_bd = dindet(
integral.n, integral .k, integral . m_a, integral.mat_b, integral .dt)
self . logger . info (’’Calculation of Fd (Algorithm 11.6)”)
integral. m_fd = stoch(integral.n, integral. m_a, integral. mat _f, integral.dt)
mat_u = np.array([[ object ]] * self.step5.matrix. rowCount () )
for i in range( self . step5 . matrix . rowCount () ) :
mat_u [ i ] [0] = Symbolic( self .step5 . matrix.m[ i ] [0] )
integral. distortion = ComplexDistortion( self. step5. matrix. rowCount () , mat_u)
self . logger . info (” Starting modeling loop” )
start_time = time ()
Electronic Journal. http://diffjournal.spbu.ru/ 260
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Differential Equations and Control Processes, N. 1, 2021
integral.integrate()
self. logger. info(f”Integration took {(time () — start_time):.3f} seconds”)
lines = [ Line( f”Linear , x{ i + 1}” ,
np.array(integral.v_t) .astype(float) , np. array( integral . m_xt [i , :]) .astype( float) ,
mx=np . array ( integral . m_mx [i , :]) .astype( float) , dx=np . array ( integral . m_dx [i, :]) .astype( float)) for i in range(integral . m_xt.shape [0]) ]
name = f” Linear”
lines .append(Line(f” Linear , y” ,
np.array(integral.v_t) . astype(float) , np.array(integral.v_yt) . astype(float) , mx=np.array(integral.v_my).astype(float), dx=np.array(integral.v_dy).astype(float)))
return lines
def on_modeling_finish ( self , result) :
self.stop_progress.emit(”The modeling has been completed!”) self . draw_chart . emit( result )
def on_modeling_corrupted ( self , result ) : self.logger.error(result [0]) self.logger.error(result [1]) self.logger.error(result [2])
self . stop_progress . emit(”The modeling failed !” )
Listing 35: Step 1 of data input for linear systems
Electronic Journal. http://diffjournal.spbu.ru/ 261
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Differential Equations and Control Processes, N. 1, 2021
self.m_is_valid = False self.k_is_valid = False
self.input_stack = self.parent()
info_n = InfoIcon(”Dimension of linear system of Ito SDEs” )
info_m = InfoIcon (’’Dimension of vector Wiener process”)
info_k = InfoIcon(”Dimension of vector function u(t)”)
labeLn = QLabel(”n”) label_m = QLabel(”m”) label _k = QLabel(”k”)
self. lineedit_n = QLineEdit() self.lineedit_m = QLineEdit() self. lineedit_k = QLineEdit()
self.msg_n = ErrorWidget(”Wrong value!”) self . msg_n . hide ()
self.msg_m = ErrorWidget(”Wrong value!”) self. msg_m . hide ()
self.msg_k = ErrorWidget(”Wrong value!”) self . ms^k. hide ()
grid_layout = QGridLayout () grid_layout . addWidget( self .msg_n , 0, 2) grid_layout . addWidget( self . ms^m , 2, 2) grid_layout . addWidget( self . ms^k , 4, 2) grid_layout . addWidget( info_n , 1, 0)
grid_layout . addWidget(info_m , 3, 0) grid_layout . addWidget (info_k , 5, 0) grid_layout . addWidget( labeLn , 1, 1)
grid_layout . addWidget(label_m , 3, 1)
grid_layout . addWidget ( label_k , 5, 1)
grid_layout . addWidget( self . lineedit_n , 1, 2)
grid_layout . addWidget (self.lineedit_m , 3, 2) grid_layout . addWidget( self . lineedit_k , 5, 2)
header = QLabel(”Dimensions settings”, parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . next_btn . setEnabled( False)
header_layout = QHBoxLayout ()
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) header_layout . addWidget( header )
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
Electronic Journal. http://diffjournal.spbu.ru/ 262
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Differential Equations and Control Processes, N. 1, 2021
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self. next _btn)
eq1 = QHBoxLayout ()
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq1 . addWidget (SVG(” equation3.svg” , scale_factor = 1.))
eq1 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq2 = QHBoxLayout ()
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) eq2 . addWidget (SVG(” equation4.svg” , scale_factor = 1.))
eq2 . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) )
equalities_layout = QVBoxLayout () equalities_layout . addLayout (eq1)
equalities, layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum
))
equalities_layout . addLayout (eq2) equalities_wrap = QHBoxLayout ()
equalities_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)
)
equalities_wrap . addLayout ( equalities_layout )
equalities_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum)
)
grid_wrap = QHBoxLayout ()
grid_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) grid_wrap . addLayout ( grid-layout )
grid_wrap . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) layout = QVBoxLayout ()
layout . addItem(QSpacerItem(0 , 0, QSizePolicy .Minimum, QSizePolicy . Expanding)) layout . addLayout ( equalities_wrap )
layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout ( header_layout)
layout . addItem(QSpacerItem(0 , 5, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout (grid_wrap)
layout . addItem(QSpacerItem(0 , 0, QSizePolicy .Minimum, QSizePolicy . Expanding)) layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . lineedit_n . textChanged . connect ( self . validate_n ) self. lineedit_m . textChanged . connect ( self . validate_m ) self. lineedit_k . textChanged . connect ( self . validate_k )
def validate_form ( self ) :
if self. n_is_valid and self. m_is_valid and self . k_is_valid : self . next _btn . setEnabled( True) else :
self . next_btn . setEnabled ( False) def validate_n(self, value):
Electronic Journal. http://diffjournal.spbu.ru/ 263
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
1
Differential Equations and Control Processes, N. 1, 2021
try :
typed _value = int (value) if typed_value <= 0: raise ValueError()
self . n _is .valid = True
self . n _valid . emit (typed_value)
self. msg_n . hide ()
except ValueError :
self.n_is_valid = False self. msg_n . show ()
finally :
self . validate_form ()
def validate_m(self , value) : try:
typed _value = int (value) if typed_value <= 0: raise ValueError ( )
self . m_is_valid = True
self . m _valid . emit (typed_value)
self. msg_m . hide ()
except ValueError :
self.m_is_valid = False self. msg_m . show ()
fi n a l l y :
self . validate_form ()
def validate_k(self , value) : try:
typed _value = int (value) if typed_value <= 0: raise ValueError ( )
self . k_is_valid = True
self . k- valid . emit(typed_value)
self. msg_k . hide ()
except ValueError :
self.k_is_valid = False self. msg_k . show ()
fi n a l l y :
self . validate_form ()
Listing 36: Step 2 of data input for linear systems
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QLabel , QSpacerItem , QSizePolicy, \
Electronic Journal. http://diffjournal.spbu.ru/ 264
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Differential Equations and Control Processes, N. 1, 2021
QVBoxLayout, QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
from ui .main. modeling . matrix_widget import MatrixWidget
class Step2(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.errors = 0
header = QLabel(”Setting of matrix A” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
info = InfoIcon(”Elements of matrix A are\n”
”expected to be real values\n”
”Size : n x n”)
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . matrix . itemChanged . connect ( self . validate_item ) def validate_item(self, item):
Electronic Journal. http://diffjournal.spbu.ru/ 265
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Differential Equations and Control Processes, N. 1, 2021
Listing 37: Step 3 of data input for linear systems
Electronic Journal. http://diffjournal.spbu.ru/ 266
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Differential Equations and Control Processes, N. 1, 2021
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self.prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next _btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . matrix . itemChanged . connect ( self . validate_item )
def validate_item(self, item):
value = item.text () try :
float ( value) if not item . valid : item. valid = True self.errors —= 1
except ValueError : if item . valid :
item. valid = False self.errors += 1
finally :
self . validate_form ()
def validate_form ( self ) :
if self.errors == 0: self. msg. hide ()
self . next _btn . setEnabled( True) else :
self. msg. show ()
self . next_btn . setEnabled ( False)
Electronic Journal. http://diffjournal.spbu.ru/ 267
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Differential Equations and Control Processes, N. 1, 2021
Listing 38: Step 4 of data input for linear systems
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel , QSpacerltem , \ QSizePolicy , QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
from ui .main. modeling . matrix_widget import MatrixWidget
class Step4(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.errors = 0
header = QLabel(”Setting of matrix F” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
info = InfoIcon(”Elements of matrix F are\n”
”expected to be real values\n”
”Size : n x m”)
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
Electronic Journal. http://diffjournal.spbu.ru/ 268
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Differential Equations and Control Processes, N. 1, 2021
self . matrix . itemChanged . connect ( self . validate_item )
def validate_item(self, item):
value = item.text () try :
float ( value) if not item . valid : item. valid = True self.errors —= 1
except ValueError : if item . valid :
item. valid = False self.errors += 1
finally :
self . validate_form () def validate_form ( self ) :
if self.errors == 0: self. msg. hide ()
self . next _btn . setEnabled( True) else :
self. msg. show ()
self . next_btn . setEnabled ( False)
Listing 39: Step 5 of data input for linear systems
Electronic Journal. http://diffjournal.spbu.ru/ 269
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Differential Equations and Control Processes, N. 1, 2021
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
Listing 40: Step 6 of data input for linear systems
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel , QSpacerItem , \ QSizePolicy , QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
from ui .main. modeling . matrix_widget import MatrixWidget
class Step6(QWidget) :
def __i n it __ ( self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.errors = 0
header = QLabel(”Setting of matrix H” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
info = InfoIcon(”Elements of matrix H are\n”
Electronic Journal. http://diffjournal.spbu.ru/ 270
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Differential Equations and Control Processes, N. 1, 2021
”expected to be int values\n”
"Size: 1 x n”)
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next_btn)
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . matrix . itemChanged . connect ( self . validate_item )
def validate_item(self, item):
value = item.text () try :
float ( value) if not item . valid : item. valid = True self.errors —= 1
except ValueError : if item . valid :
item. valid = False self.errors += 1
finally :
self . validate_form ()
def validate_form ( self ) :
if self.errors == 0: self. msg. hide ()
Electronic Journal. http://diffjournal.spbu.ru/ 271
77
78
79
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Differential Equations and Control Processes, N. 1, 2021
self . next _btn . setEnabled( True) else :
self. msg. show ()
self . next_btn . setEnabled ( False)
Listing 41: Step 7 of data input for linear systems
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel , QSpacerItem , \ QSizePolicy , QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
from ui .main. modeling . matrix_widget import MatrixWidget
class Step7(QWidget) :
def __init__(self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.errors = 0
header = QLabel(”Setting of column x0” , parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
info = InfoIcon(”Elements of column x0 are\n”
”expected to be real values\n”
” Size : n x 1”)
self.msg = ErrorWidget(”Wrong values in matrix!”) self. msg . hide ()
self. matrix = MatrixWidget( self )
self . next_btn = QPushButton(”Next” , self)
self . next_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) )
header_layout = QHBoxLayout () header_layout . addWidget (info) header_layout . addWidget( header ) header_layout . addWidget ( self . msg)
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) bottom_bar = QHBoxLayout ()
bottom_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget (self. next _btn)
Electronic Journal. http://diffjournal.spbu.ru/ 272
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Differential Equations and Control Processes, N. 1, 2021
layout = QVBoxLayout () layout . addLayout ( header_layout) layout . addWidget ( self . matrix) layout . addLayout (bottom_bar)
self . setLayout(layout)
self . matrix . itemChanged . connect ( self . validate_item )
def validate_item(self, item):
value = item.text () try :
fl oat ( value) if not item . valid : item. valid = True self.errors —= 1
exce pt ValueError : if item . valid :
item. valid = False self.errors += 1
finally :
self . validate_form ()
def validate_form ( self ) :
if self.errors == 0: self. msg. hide ()
self . next _btn . setEnabled( True) else :
self. msg. show ()
self . next_btn . setEnabled ( False)
Listing 42: Step 8 of data input for linear systems
import sys
from PyQt5. QtWidgets import QWidget, QHBoxLayout, QLabel , QLineEdit , QGridLayout , \ QVBoxLayout, QSizePolicy , QSpacerItem , QPushButton , QApplication , QStyle
from ui .main. error import ErrorWidget from ui . main . info import InfoIcon
class Step8(QWidget) :
def __i n it __ ( self , parent=None) :
super (QWidget, self) . __init__ (parent)
self.t0 = sys. float_info. min self.dt = 0
Electronic Journal. http://diffjournal.spbu.ru/ 273
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Differential Equations and Control Processes, N. 1, 2021
self.t1 = sys. float-info .max self.s = 0
self.t0_is_valid = False self.dt_is_valid = False self.t1_is_valid = False self . s_is_valid = True
self.input_stack = self.parent()
info_t0 = InfoIcon( ”Start point of integration interval\n”
” Must be in [0, t1) range”)
info _dt = InfoIcon( ”Integration step\n”
” Must be set in (0, 1) interval”)
info_t1 = InfoIcon( ”Final point of integration interval\n”
” Must be more then t0” )
info _s = InfoIcon (” This is random generator see d\n”
”If You do not want to use specific \n”
” seed just leave this field empty” )
label_t0 = QLabel(”t0”) label_dt = QLabel (”dt” ) label_t1 = QLabel(”t1”) labeLs = QLabel(”seed”)
self . lineedit _t0 = QLineEdit() self. lineedit_dt = QLineEdit() self . lineedit_t1 = QLineEdit() self. lineedit_s = QLineEdit()
self.msg_t0 = ErrorWidget(”Wrong value!”) self . msg_t0 . hide ()
self.msg_dt = ErrorWidget(”Wrong value!”) self. msg_dt . hide ()
self.msg_t1 = ErrorWidget(”Wrong value!”) self . msg_t1 . hide ()
self.msg_s = ErrorWidget(”Wrong value!”) self . ms^s. hide ()
header = QLabel(”Accuracy settings”, parent=self) font = header.font() font . setPointSize(15) header.setFont(font)
self . prev_btn = QPushButton(”Back” , self)
self . prev_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowBack) ) self.run_btn = QPushButton(”Perform modeling”, self)
self . run_btn . setIcon ( QApplication . style () . standardIcon ( QStyle . SP_ArrowForward) ) self . run_btn . setEnabled ( False)
header_layout = QHBoxLayout ()
Electronic Journal. http://diffjournal.spbu.ru/ 274
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Differential Equations and Control Processes, N. 1, 2021
header_layout . addWidget( header )
header_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy .Minimum) ) botto^_bar = QHBoxLayout ()
botto^_bar . addItem(QSpacerItem (0 , 0, QSizePolicy .Expanding , QSizePolicy .Minimum)) bottom _bar . addWidget (self.prev_btn) bottom _bar . addWidget ( self . run_btn)
grid-layout = QGridLayout ()
grid-layout . addWidget( self . msg_t0 , 0, 2)
grid_layout . addWidget( info_t0 , 1, 0)
grid-layout . addWidget( label_t0 , 1, 1)
grid-layout . addWidget( self . lineedit_t0 , 1, 2)
grid_layout . addWidget( self . msg_dt , 0, 5)
grid-layout . addWidget( info_dt , 1,3)
grid-layout . addWidget( label_dt , 1, 4)
grid-layout . addWidget( self . lineedit_dt , 1, 5)
grid-layout . addWidget( self . msg_t1 , 0, 8)
grid-layout . addWidget( info_t1 , 1, 6)
grid-layout . addWidget( label_t1 , 1, 7)
grid-layout . addWidget( self . lineedit_t1 , 1, 8)
grid-layout . addWidget( self . msg_s , 2, 2)
grid-layout . addWidget( info_s , 3, 0) grid_layout . addWidget( label_s , 3, 1)
grid-layout . addWidget( self . lineedit_s , 3, 2)
column_layout = QVBoxLayout ()
column_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding)
)
column_layout . addLayout ( header_layout)
column_layout . addItem(QSpacerItem(0 , 25, QSizePolicy .Minimum, QSizePolicy .Minimum)) column_layout . addLayout ( grid-layout )
column_layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding)
)
control-layout = QHBoxLayout ()
control-layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding
))
control-layout . addLayout (column_layout)
control-layout . addItem(QSpacerItem(0 , 0, QSizePolicy . Expanding , QSizePolicy . Expanding
))
layout = QVBoxLayout ()
layout . addLayout ( control-layout )
layout . addLayout (bottom_bar)
self . setLayout(layout)
Electronic Journal. http://diffjournal.spbu.ru/ 275
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Differential Equations and Control Processes, N. 1, 2021
self. lineedit_t0 . textChanged . connect ( self . validate_t0 ) self. lineedit_t0 . textChanged . connect ( self . validate_t1 ) self. lineedit_t0 . textChanged . connect ( self . validate_dt ) self. lineedit_dt . textChanged . connect ( self . validate_dt ) self. lineedit_t1 . textChanged . connect ( self . validate_t0 ) self. lineedit_t1 . textChanged . connect ( self . validate_t1 ) self. lineedit_t1 . textChanged . connect ( self . validate_dt ) self. lineedit_s . textChanged . connect ( self . validate_s )
def count_c ( self , flag: bool):
if flag :
self . i nfo _c . show () self . label _c . show () else :
self. i nfo _c .hide() self . label _c . hide()
self . msg_c . hide ()
def validate-form ( self ) : if self . t0_is_valid \
and self . dt_is_valid \ and self.t1_is_valid \ and self. s_is_valid : self . ru n_btn . setEnabled ( True) else :
self . run_btn . setEnabled( False)
def validate_t0(self): try :
typed_value = float ( self. lineedit_t0. text ()) if typed_value >= self . t1 : raise ValueError()
self . t0_is_valid = True self.t0 = typed_value self . msg_t0 . hide ()
except ValueError :
self.t0_is_valid = False self . msg_t0 . show ()
def validate_dt(self ) : try :
typed_value = float (self. lineedit_dt. text ()) if typed_value <= 0 \
or (self.t1 — self.t0) / typed_value < 1 \ or typed_value >= 1: raise ValueError ()
self . dt_is_valid = True self.dt = typed_value self . msg_dt . hide () self . validate_form ()
Electronic Journal. http://diffjournal.spbu.ru/ 276
Differential Equations and Control Processes, N. 1, 2021
178
179
180 181 182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 201 202
203
204
205
206
207
208
209
210 211 212
213
214
215
216
6.2 Source Codes for Nonlinear Systems of Ito SDEs
6.2.1 Source Codes for Calculation of the Fourier—Legendre Coefficients
Listing 43: Symbolic function of the Legendre polinomial
1
2
from sympy import Rational , factorial , diff
Electronic Journal. http://diffjournal.spbu.ru/ 277
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1
Differential Equations and Control Processes, N. 1, 2021
Listing 44: Symbolic function of the Fourier—Legendre coefficient calculation
from sympy import S, integrate
from mathematics . sde . nonlinear . legendre_polynomial import polynomial
def get_c ( indices : tuple , weights : tuple) :
Calculates the Fourier —Legendre coefficient depending on indices and weights Parameters
indices : tuple
indices of the Fourier —Legendre coefficient weights : tuple
weights of the Fourier —Legendre coefficient Returns
sympy. Rational
from sympy. abc import x , y
# multiplicity of iterated integral which is the Fourier —Legendre coefficient n = len ( indices ) w = list ( reversed (weights))
c = S. One
for i in reversed(range(1, n)):
c = integrate(polynomial(indices[i]) * (x + 1) ** w[i] * c, (x, -1, y)).subs(y, x) c = integrate(polynomial(indices[0]) * (x + 1) ** w[0] * c, (x, -1, 1))
if sum(w) % 2 return c else :
return -c
0:
Listing 45: Symbolic function of the Fourier—Legendre coefficient
import logging
Electronic Journal. http://diffjournal.spbu.ru/ 278
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Differential Equations and Control Processes, N. 1, 2021
from sympy import sympify , Function import tools . database as db
from mathematics . sde . nonlinear . c import get_c
class C(Function):
Gives the Fourier —Legendre coefficient with requested indices and weights _preloaded = diet ()
def __new__( cls , indices : tuple , weights : tuple , to_float=True , **kwargs) :
Creates the Fourier —Legendre coefficient object with needed indices and weights Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C
calculated value or symbolic expression
if not len ( indices ) == len (weights) :
return super (C, cls).__new__(cls, indices, weights, ** kwargs)
index = f” { ’:’.join([str(i) for i in indices]) }_{ ’:’.join([str(i) for i in weights]) }
try :
return cls . .value (index , to_float) except KeyError :
respond = cls.-download_one(index) if len(respond) != 0:
cls. _preloaded [respond [ 0 ] [ 0 ] ] = respond [0][ 1 ] return cls._value(index, to_float) else :
new_c = cls._calculate(index, indices , weights)
cls._upload_one(new_c)
cls . _preloaded [new_c [0] ] = new_c [ 1 ]
return cls._value(index, to_float)
@classmethod
def _calculate(cls, index, indices, weights): new_c = get_c ( indices , weights) return index, ( new_c , sympify(new_c) . evalf () )
@classmethod
def _upload_one ( cls , c):
logging . info ( f”C: ADDING NEW C_ { c[0] } = { c[1][0] } ”)
db. execute( f”INSERT INTO ‘C‘ (‘index ‘, ‘value ‘, ‘value_f‘) VALUES (’ { c[0] } ’, ’ { c
Electronic Journal. http://diffjournal.spbu.ru/ 279
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Differential Equations and Control Processes, N. 1, 2021
[1][0]} ’ , {c[1][1]})”)
@classmethod
def _unpack(cls , rows) :
return [( rows [ i ][0] , ( rows [ i ][1] , rows [ i ] [ 2]) ) for i in range (len ( rows ) ) ]
@classmethod
def _value(cls, index, to_float): c = cls . _preloaded [index] if to_float : return c [1] else :
return sympify(c[0])
@classmethod
def -download _one( cls, index):
logging . info ( f”C: MISSING PRELOADED VERSION OF C_{ index }”) respond = db.execute(
f”SELECT ‘index ‘ , ‘value ‘ , ‘ valu^f ‘ FROM ‘C‘”
f”WHERE REGEXP( ‘index ‘ , { index } $ ’)”
)
return cls._unpack(respond)
@classmethod
def preload(cls , *args) :
Updates dictionary of the preloaded Fourier —Legendre coefficients Note: weights are not accepted , such coefficients are loaded
with all available weights Parameters
args
Indices for the Fourier —Legendre coefficients to download them from database
logging . info ( f”C: PRELOADING COEFFICIENTS { args } ”)
query = []
for q in range(len(args)) :
numbers = [ int (char) for char in str (args[q] + 1)] pattern = []
for i in range (1 , len ( numbers) ) : pattern. append(”[0 — 9]” * i)
for i in range (len ( numbers) ) : p = []
for j in range (len ( numbers) ) :
if j < i:
p.append( str ( numbers [ j ]) ) elif i == j :
p. append( f” [0 — { numbers [ j ] — 1}]”) elif j > i:
p. append(” [0 — 9]”) pattern.append(””.join(p))
Electronic Journal. http://diffjournal.spbu.ru/ 280
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Differential Equations and Control Processes, N. 1, 2021
Listing 46: Calculation of the Fourier—Legendre coefficients CjOjO j
from math import sqrt
from sympy import sympify , Number, Function
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C000 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 4
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C000
calculated value or symbolic expression
j3 , j2 , j1 , dt = sympify ( args )
if not (isinstance (j1 , Number) and isinstance (j2 , Number) and
Electronic Journal. http://diffjournal.spbu.ru/ 281
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Differential Equations and Control Processes, N. 1, 2021
Listing 47: Calculation of the Fourier—Legendre coefficients Cjj
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C10(Function) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C10
calculated value or symbolic expression
j2 , j1 , dt = sympify ( args )
if not (isinstance (j1 , Number) and
Electronic Journal. http://diffjournal.spbu.ru/ 282
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Differential Equations and Control Processes, N. 1, 2021
Listing 48: Calculation of the Fourier—Legendre coefficients C'021?l
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C01 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C01
calculated value or symbolic expression
j2 , j1 , dt = sympify ( args )
if not (isinstance (j1 , Number) and isinstance (j2 , Number) and
Electronic Journal. http://diffjournal.spbu.ru/ 283
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Differential Equations and Control Processes, N. 1, 2021
Listing 49: Calculation of the Fourier—Legendre coefficients C0o°3°2jl
from math import sqrt
from sympy import sympify , Number, Function
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C0000 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C0000
calculated value or symbolic expression
j4 , j3 , j2 , j1 , dt = sympify ( args )
if not (isinstance (j1 , Number) and isinstance (j2 , Number) and isinstance (j3 , Number) and
Electronic Journal. http://diffiournal.spbu.ru/ 284
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Differential Equations and Control Processes, N. 1, 2021
Listing 50: Calculation of the Fourier—Legendre coefficients Cl0,0 •
3 2 1
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C100 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 4
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C100
calculated value or symbolic expression
j3 , j2 , j1 , dt = sympify ( args )
Electronic Journal. http://diffjournal.spbu.ru/ 285
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Differential Equations and Control Processes, N. 1, 2021
Listing 51: Calculation of the Fourier—Legendre coefficients Cjj j
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C010 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 4
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C010
calculated value or symbolic expression
j3 , j2 , j1 , dt = sympify ( args )
Electronic Journal. http://diffjournal.spbu.ru/ 286
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Differential Equations and Control Processes, N. 1, 2021
Listing 52: Calculation of the Fourier—Legendre coefficients C001^
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C001 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 4
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C001
calculated value or symbolic expression
Electronic Journal. http://diffjournal.spbu.ru/ 287
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Differential Equations and Control Processes, N. 1, 2021
Listing 53: Calculation of the Fourier—Legendre coefficients C00000..
from math import sqrt
from sympy import sympify , Number, Function
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C00000 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
symbolic . Rational or C00000
calculated value or symbolic expression
Electronic Journal. http://diffjournal.spbu.ru/ 288
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Differential Equations and Control Processes, N. 1, 2021
Listing 54: Calculation of the Fourier—Legendre coefficients Cjj
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C20(Function) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tup l e
Electronic Journal. http://diffjournal.spbu.ru/ 289
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Differential Equations and Control Processes, N. 1, 2021
Listing 55: Calculation of the Fourier—Legendre coefficients Cjj
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C11 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights
Electronic Journal. http://diffjournal.spbu.ru/ 290
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Differential Equations and Control Processes, N. 1, 2021
Listing 56: Calculation of the Fourier—Legendre coefficients dj
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C02( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
Electronic Journal. http://diffjournal.spbu.ru/ 291
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Differential Equations and Control Processes, N. 1, 2021
Listing 57: Calculation of the Fourier—Legendre coefficients Cj0.OOj
from math import sqrt
from sympy import sympify , Number, Function
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C1000 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tuple
requested weights Returns
Electronic Journal. http://diffjournal.spbu.ru/ 292
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Differential Equations and Control Processes, N. 1, 2021
Listing 58: Calculation of the Fourier—Legendre coefficients С°41°°2^1
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C0100(Function) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
indices: tuple
requested indices weights : tup l e
Electronic Journal. http://diffjournal.spbu.ru/ 293
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Differential Equations and Control Processes, N. 1, 2021
Listing 59: Calculation of the Fourier—Legendre coefficients C'00,110,- •
4 3 2 1
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C0010 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
indices and weights and calculates it
Parameters
Electronic Journal. http://diffjournal.spbu.ru/ 294
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Differential Equations and Control Processes, N. 1, 2021
Listing 60: Calculation of the Fourier—Legendre coefficients C00°172jl
from math import sqrt
from sympy import sympify , Function , Number
from mathematics . sde . nonlinear . symbolic . coefficients . c import C class C0001 ( Function ) :
Gives the Fourier —Legendre coefficient with requested indices and weights nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates the Fourier —Legendre coefficient object with needed
Electronic Journal. http://diffjournal.spbu.ru/ 295
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
Differential Equations and Control Processes, N. 1, 2021
Listing 61: Calculation of the Fourier—Legendre coefficients CejOjOjoim
Electronic Journal. http://diffjournal.spbu.ru/ 296
Differential Equations and Control Processes, N. 1, 2021
14 def __new__(cls, * args, ** kwargs ) :
15 ” ” ”
16 Creates the Fourier —Legendre coefficient object with needed
17 indices and weights and calculates it
18 Parameters
19
20 indices: tuple
21 requested indices
22 weights : tup l e
23 requested weights
24 Returns
25
26 symbolic . Rational or C000000
27 calculated value or symbolic expression
28 ” ” ”
29 j6 , j5 , j4 , j3 , j2 , j1 , dt = sympify ( args)
30
31 if not (isinstance (j1 , Number) and
32 isinstance (j2 , Number) and
33 isinstance (j3 , Number) and
34 isinstance (j4 , Number) and
35 isinstance (j5 , Number) and
36 isinstance (dt , Number)):
37 return super (C000000, cls) .__new__(cls , * args , ** kwargs )
38
39 return sqrt (
40 (j1 * 2+1) *
41 (j2 * 2 + 1) *
42 (j3 * 2 + 1) *
43 (j 4 * 2+1) *
44 (j5 * 2 + 1) *
45 (j6 * 2 + 1)) * \
46 dt ** 3 * \
47 C((j6, j 5 , j4 , j3, j 2 , j1), (0, 0, 0, 0, 0, 0)) / 64
48
49 def doit(self, ** hints):
50 ” ” ”
51 Tries to expand or calculate function
52 Returns
53
54 C000000
55 ” ” ”
56 return C000000( * self .args , ** hints)
Listing 62: Program entry for generation of new Fourier—Legendre coefficients
1
2
3
4
5
6 7
Electronic Journal. http://diffjournal.spbu.ru/ 297
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Differential Equations and Control Processes, N. 1, 2021
from config import csv , new_c_portion_size
from mathematics . sde . nonlinear . new_c import thread_c , split_task
def main () :
logging . basicConfig( level = logging . INFO,
format=” %(asctime)s — %(levelname)s — %(message) s” , datefmt=”%H:%M:%S”
)
logger = logging. getLogger(___name__)
filename = os . path .join(csv, f”c_ { datetime. now () . strftime( ’%d—%n—%Y_%H—%M—%S ’) } . csv” )
logging. info(f”Writing to file { filename } ”)
tasks = [
(((57, 58) , (57 , 58) , (57 , 58) ) , (0, 0 , 0)) ,
# (((0, 56), (0, 56), (0, 56)), (0, 0, 0)),
#
# (((0, 15), (0, 15)), (0, 1)),
# (((0, 15), (0, 15)), (1, 0)),
# (((0, 15), (0, 15), (0, 15)), (0, 0, 0, 0)),
#
# (((0, 6), (0, 6), (0, 6)), (0, 0, 1)),
# (((0, 6), (0, 6), (0, 6)), (0, 1, 0)),
# (((0, 6), (0, 6), (0, 6)), (1, 0, 0)),
# (((0, 6), (0, 6), (0, 6), (0, 6), (0, 6)), (0, 0, 0, 0, 0)),
#
# (((0, 2), (0, 2)), (0, 2)),
# (((0, 2), (0, 2)), (1, 1)),
# (((0, 2), (0, 2)), (2, 0)),
# (((0, 2), (0, 2), (0, 2), (0, 2)), (0, 0, 0, 1)),
# (((0, 2), (0, 2), (0, 2), (0, 2)), (0, 0, 1, 0)),
# (((0, 2), (0, 2), (0, 2), (0, 2)), (0, 1, 0, 0)),
# (((0, 2), (0, 2), (0, 2), (0, 2)), (1, 0, 0, 0)),
# (((0, 2), (0, 2), (0, 2), (0, 2), (0, 2)), (0, 0, 0, 0, 0)),
# (((0, 2), (0, 2), (0, 2), (0, 2), (0, 2), (0, 2)), (0, 0, 0, 0, 0, 0)),
]
with Pool(cpu_count () ) as p:
for t in tasks:
logger. info(f” Running task {t}”)
for chunk in chunks(split_task(t), new_c_portion_size): c = p. map( thread_c , chunk) c.append(””)
with open (filename , ”a”) as f: f.write(” \ n” .join(c)) f.close ()
logger. info(f”The portion of C has been written {chunk[0] } — { chunk[ — 1] } ”)
Electronic Journal. http://diffjournal.spbu.ru/ 298
63
64
65
66
67
68
69
70
71
72
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Differential Equations and Control Processes, N. 1, 2021
logger. info(”Generation has been done”)
def chunks(lst, n):
for i in range (0, len (lst), n): yield lst [ i : i + n]
if____name___== ”__main__”:
main ()
Listing 63: Module for the Fourier—Legendre coefficients generation
from mathematics . sde . nonlinear . c import get_c
def split_task (tasks): c = len (tasks [1])
i f c == 2:
return s plit _2(tasks)
if c == 3:
return s plit _3(tasks)
i f c == 4:
return s plit _4(tasks)
i f c == 5:
return s plit _5(tasks)
i f c == 6:
return s plit _6(tasks)
def split _ 2(ranges):
return [( ( i , j ) , ranges [1 ] )
fo r j i n range (ranges [0] [1] [1])
fo r i i n range ( r a n g e s [ 0 ] [ 0 ] [ 1 ] )
if i >= ranges [0][1][0] or j >= ranges [0][0][1]]
def split _ 3(ranges):
return [( ( i , j , k) , ranges [1 ] )
fo r k i n range (ranges [0] [2] [1])
fo r j i n range (ranges [0] [1] [1])
fo r i i n range ( r a n g e s [ 0 ] [ 0 ] [ 1 ] )
if k >= ranges [0][2][0] or j >= ranges [0] [1] [0] or i >= ranges [0][0][0]]
Electronic Journal. http://diffjournal.spbu.ru/ 299
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Differential Equations and Control Processes, N. 1, 2021
def split _4 (ranges):
return [(( i , j, k, l), ranges[1]) for j in range(* ranges [0][3]) for i in range(* ranges [0][2]) for k in range(* ranges [0][1 ]) for l in range(* ranges [0][0]) if l >= ranges [0][3][0] or k >= ranges [0] [2][0] or j >= ranges [0] [1] [0] or i >= ranges [0][0][0]]
def split _ 5(ranges):
return [( ( i , j , k, l , m) , ranges [1 ] ) for j in range(* ranges [0][4]) for i in range(* ranges [0][3]) for k in range(* ranges [0][2]) for l in range(* ranges [0][1 ]) for m in range(* ranges [0][0]) if m >= ranges [0][4][0] if l >= ranges [0][3][0] or k >= ranges [0] [2][0] or j >= ranges [0] [1] [0] or i >= ranges [0][0][0]]
def split _ 6(ranges):
return [( ( i , j , k, l , m, n) , ranges [1 ] ) for j in range(* ranges [0][5]) for i in range(* ranges [0][4]) for k in range(* ranges [0][3]) for l in range(* ranges [0][2]) for m in range(* ranges [0][1]) for n in range(* ranges [0][0]) if n >= ranges [0] [5][0] if m >= ranges [0][4][0] if l >= ranges [0][3][0] or k >= ranges [0] [2][0] or j >= ranges [0] [1] [0] or i >= ranges [0][0][0]]
def threa^c ( ranges) : c = len(ranges[1])
i f c == 2:
return gen_2(* ranges [0] , ranges [1])
if c == 3:
return gen_3(* ranges [0] , ranges [1])
i f c == 4:
return gen_4(* ranges [0] , ranges [1])
i f c == 5:
Electronic Journal. http://diffjournal.spbu.ru/ 300
Differential Equations and Control Processes, N. 1, 2021
96
97
98
99 100 101 102
103
104
105
106
107
108
109
110 111 112
113
114
115
116
117
118 119
6.2.2 Source Codes for Supplementary Differential Operators and Functions
Listing 64: Implementation of the differential operator L
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
from sympy import Add, sympify , Number, diff
from mathematics . sde . nonlinear . symbolic . operator import Operator
class L(Operator) : nargs = 4
def __new__(cls, * args, ** kwargs ) :
Creates new L object with given args Parameters
args
bunch of necessary arguments Returns
sympy. Expr
Electronic Journal. http://diffjournal.spbu.ru/ 301
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Differential Equations and Control Processes, N. 1, 2021
Listing 65: Implementation of the differential operator G
(i)
0
from sympy import Add, sympify , Number, diff
from mathematics . sde . nonlinear . symbolic . operator import Operator
class G(Operator) : nargs = 3
_dict = diet ()
def __new__(cls, * args, ** kwargs ) :
Creates new G object with given args Parameters
args
bunch of necessary arguments Returns
sympy. Expr
formula to simplify and substitute
Electronic Journal. http://diffjournal.spbu.ru/ 302
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
Differential Equations and Control Processes, N. 1, 2021
Listing 66: Implementation of the function a(x,t)
Listing 67: Implementation of the differential operator L
from sympy import sympify , Number, diff , Add
Electronic Journal. http://diffjournal.spbu.ru/ 303
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1
2
3
4
5
6
7
8
9
10
11
12
Differential Equations and Control Processes, N. 1, 2021
Listing 68: Implementation of the indicator function 1 {i1=i2}
from sympy import sympify , Number, Function
class Ind(Function) :
Indicator function nargs = 2
def __new__(cls, * args, ** kwargs ) :
Creates new Ind object with given args
Electronic Journal. http://diffjournal.spbu.ru/ 304
Differential Equations and Control Processes, N. 1, 2021
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
6.2.3 Source Codes for Iterated Ito Stochastic Integrals Approximations Subprograms
Listing 69: Approximation of Ito stochastic integral I^T + г T
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
from math import sqrt
from sympy import Function , sympify , Number
class I0 ( Function ) :
Ito stochastic integral nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates new I0 object with given args Parameters
Electronic Journal. http://diffjournal.spbu.ru/ 305
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Differential Equations and Control Processes, N. 1, 2021
Listing 70: Approximation of iterated Ito stochastic integral 00)r+1 T
from math import sqrt
from sympy import sympify , Number, Function, Add from mathematics . sde . nonlinear . symbolic . ind import Ind
class I00 ( Function ) :
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new I00 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of
Electronic Journal. http://diffjournal.spbu.ru/ 306
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Differential Equations and Control Processes, N. 1, 2021
Listing 71: Approximation of Ito stochastic integral +i т
from math import sqrt
from sympy import Function , sympify , Number
class 11 ( Function ) :
Ito stochastic integral nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates new I1 object with given args Parameters
Electronic Journal. http://diffjournal.spbu.ru/ 307
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Differential Equations and Control Processes, N. 1, 2021
Listing 72: Approximation of iterated Ito stochastic integral loOOh3+i T
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c000 import C000 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I000 ( Function ) :
Iterated Ito stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new I000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
Electronic Journal. http://diffjournal.spbu.ru/ 308
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
1
2
3
4
5
6
7
8
9
10
11
12
13
Differential Equations and Control Processes, N. 1, 2021
Listing 73: Approximation of iterated Ito stochastic integral 1р0)т+1 T
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c10 import C10 from mathematics . sde . nonlinear . symbolic . ind import Ind
class 110 ( Function ) :
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Electronic Journal. http://diffjournal.spbu.ru/ 309
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1
2
3
4
5
6
7
8
Differential Equations and Control Processes, N. 1, 2021
Listing 74: Approximation of iterated Ito stochastic integral I
(iii2)
(01)rp+i ,Tp
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c01 import C01 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I01 ( Function) :
Electronic Journal. http://diffjournal.spbu.ru/ 310
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1
2
3
Differential Equations and Control Processes, N. 1, 2021
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new I01 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (q, Number)):
return super (I01 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C01(j2, j1, dt) *
(ksi[j1, i 1 ] * ksi [j2 , i 2 ] —
Ind(i1, i2) * Ind(j1, j2)) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
I0 1
return I01(* self.args, ** hints)
Listing 75: Approximation of iterated Ito stochastic integral 1((0000)т4)1 Tp
from sympy import Function , sympify, Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0000 import C0000
Electronic Journal. http://diffiournal.spbu.ru/ 311
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . symbolic . ind import Ind
class I0000(Function) :
Iterated Ito stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new I0000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (I0000 , cls) . __new_(cls , * args , ** kwargs)
return Add ( * [
C0000(j4 , j3 , j 2 , j1 , dt) *
( ksi [ j1 , i 1 ] * ksi [ j2 i 2 ] * ksi [ j3 i3 ] * ksi [ j4 i4 ] -
Ind (i1 , i 2 ) * Ind (j1 j 2 ) * ksi [ j3 i3 ] * ksi [ j4 i4 ] -
Ind (i1 , i3 ) * Ind (j1 j3) * ksi [ j2 i2 ] * ksi [ j4 i4 ] -
Ind (i1 , i4 ) * Ind (j1 j 4 ) * ksi [ j2 i2 ] * ksi [ j3 i3 ] -
Ind (i2 , i3 ) * Ind (j2 j3) * ksi [ j1 i1 ] * ksi [ j4 i4 ] -
Ind (i2 , i4 ) * Ind (j2 j 4 ) * ksi [ j1 i1 ] * ksi [ j3 i3 ] -
Ind (i3 , i4 ) * Ind (j3 j 4 ) * ksi [ j1 i1 ] * ksi [ j2 i 2 ] +
Ind (i1 , i 2 ) * Ind (j1 j 2 ) * Ind ( i3 i4 ) * Ind (j3 , j 4 ) +
Ind (i1 , i3 ) * Ind (j1 j3) * Ind (i2 , i4 ) * Ind (j2 , j 4 ) +
Ind (i1 , i4 ) * Ind (j1 j 4 ) * Ind (i2 , i3 ) * Ind (j2 , j3))
Electronic Journal. http://diffjournal.spbu.ru/ 312
59
60
61
62
63
64
65
66
67
68
69
70
71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Differential Equations and Control Processes, N. 1, 2021
for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
I0000
return I0000(* self.args, ** hints)
Listing 76: Approximation of Ito stochastic integral /(2)T +1 Tp
from math import sqrt
from sympy import sympify , Number, Function
class I2(Function) :
Ito stochastic integral nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates new I2 object with given args Parameters
i1 : int
integral index d t : fl o a t delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , dt , ksi = sympify( args )
if not isinstance (i1 , Number) :
return super (I2 , cls) . __new__(cls , * args , ** kwargs )
return (ksi[0, i1] + ksi [1 , i1] * sqrt(3) / 2 + ksi [2 , i1] / sqrt(5) /2) * dt ** 2.5 / 3
def doit(self, ** hints):
Electronic Journal. http://diffjournal.spbu.ru/ 313
38
39
40
41
42
43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Differential Equations and Control Processes, N. 1, 2021
Tries to expand or calculate function Returns
I2
return I2(* self.args , ** hints)
Listing 77: Approximation of iterated Ito stochastic integral 1р0с)т)+1 T
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c100 import C100 from mathematics . sde . nonlinear . symbolic . ind import Ind
class 1100 ( Function ) :
Iterated Ito stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new I100 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral d t : fl o a t delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, q, dt, ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (q, Number)):
return super (I100 , cls) . __new__(cls , * args , ** kwargs)
return Add ( * [
Electronic Journal. http://diffjournal.spbu.ru/ 314
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Differential Equations and Control Processes, N. 1, 2021
Listing 78: Approximation of iterated Ito stochastic integral I(0k))t'+i Tp
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c010 import C010 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I010 ( Function ) :
Iterated Ito stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new I010 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
Electronic Journal. http://diffjournal.spbu.ru/ 315
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Differential Equations and Control Processes, N. 1, 2021
Listing 79: Approximation of iterated Ito stochastic integral I(0 OpT+i Tp
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c001 import C001 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I00 1 ( Function ) :
Iterated Ito stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new I001 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int
Electronic Journal. http://diffjournal.spbu.ru/ 316
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
1
2
3
4
5
6
7
8
9
10
11
Differential Equations and Control Processes, N. 1, 2021
Listing 80: Approximation of iterated Ito stochastic integral 1(000о0)У+1 T
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c00000 import C00000 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I00000 ( Function ) :
Iterated Ito stochastic integral nargs = 8
Electronic Journal. http://diffjournal.spbu.ru/ 317
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Differential Equations and Control Processes, N. 1, 2021
def __new__(cls, * args, ** kwargs ) :
Creates new I00000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
integral index
15 : int integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute i1 , i2 , i3 , i4 , i5 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and
isinstance (i2 , Number) and
isinstance (i3 , Number) and
isinstance (i4 , Number) and
isinstance (i5 , Number) and
isinstance (q , Number) and
isinstance (dt , Number) ) :
return super (I00000 , cls) new (cls , * args , ** kwargs)
return Add ( * [
C00000 (j5 , j4 , j 3 , j2 , j1 , dt) *
( ksi [ j1 , i 1 ] * ksi [ j2 , i 2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] -
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] -
Ind (i1 , i3) * Ind (j1 , j3) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] -
Ind (i1 , i4) * Ind (j1 , j 4 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j5 , i5 ] -
Ind (i1 , i 5 ) * Ind (j1 , j 5 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i2 , i3 ) * Ind (j2 , j3) * ksi [ j1 , i1 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] -
Ind (i2 , i4 ) * Ind (j2 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] * ksi [ j5 , i5 ] -
Ind (i2 , i 5 ) * Ind (j2 , j 5 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i3 , i4 ) * Ind (j3 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] * ksi [ j5 , i5 ] -
Ind (i3 , i 5 ) * Ind (j3 , j 5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] * ksi [ j4 , i4 ] -
Ind (i4 , i 5 ) * Ind (j4 , j 5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] * ksi [ j3 , i3 ] +
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * Ind ( i3 , i4 ) * Ind (j3 , j 4 ) * ksi [ j5 , i5 ] +
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * Ind ( i3 , i5 ) * Ind (j3 , j 5 ) * ksi [ j4 , i4 ] +
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * Ind (i4 , i5 ) * Ind (j4 , j 5 ) * ksi [ j3 , i3 ] +
Electronic Journal. http://diffjournal.spbu.ru/ 318
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Differential Equations and Control Processes, N. 1, 2021
Ind(i1, i3 ) * Ind (j 1 , j3) * Ind (i2 , i4 ) * Ind (j2 , j 4 ) * ksi [ j5 , i5 ] +
Ind(i1, i3 ) * Ind (j 1 , j3) * Ind (i2 , i5 ) * Ind (j2 , j 5 ) * ksi [ j4 , i4 ] +
Ind(i1, i3 ) * Ind (j 1 , j3) * Ind (i4 , i5 ) * Ind (j4 , j 5 ) * ksi [ j2 , i2 ] +
Ind(i1, i4 ) * Ind (j 1 , j 4 ) * Ind (i2 , i3 ) * Ind (j2 , j3) * ksi [ j5 , i5 ] +
Ind(i1, i4 ) * Ind (j 1 , j 4 ) * Ind (i2 , i5 ) * Ind (j2 , j 5 ) * ksi [ j3 , i3 ] +
Ind(i1, i4 ) * Ind (j 1 , j 4 ) * Ind ( i3 , i5 ) * Ind(j 3 , j 5 ) * ksi [ j2 , i2 ] +
Ind(i1, i 5 ) * Ind (j 1 , j 5 ) * Ind (i2 , i3 ) * Ind(j 2 , j3) * ksi [ j4 , i4 ] +
Ind(i1, i 5 ) * Ind (j 1 , j 5 ) * Ind (i2 , i4 ) * Ind(j 2 , j 4 ) * ksi [ j3 , i3 ] +
Ind(i1, i 5 ) * Ind (j 1 , j 5 ) * Ind ( i3 , i4 ) * Ind(j 3 , j 4 ) * ksi [ j2 , i2 ] +
Ind (i2 , i3 ) * Ind (j2 , j3) * Ind (i4 , i5 ) * Ind (j4 , j 5 ) * ksi [ j 1 , i1 ] +
Ind (i2 , i4 ) * Ind (j2 , j 4 ) * Ind ( i3 , i5 ) * Ind(j 3 , j 5 ) * ksi [j1 , i1 ] +
Ind (i2 , i 5 ) * Ind (j2 , j 5 ) * Ind ( i3 , i4 ) * Ind(j 3 , j 4 ) * ksi [j1 , i 1 ])
for j5 in range(q + 1) for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
I00000
return I00000(* self.args, ** hints)
Listing 81: Approximation of iterated Ito stochastic integral I(20)t+1t
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c20 import C20 from mathematics . sde . nonlinear . symbolic . ind import Ind
class 120 ( Function ) :
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new I20 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral
Electronic Journal. http://diffjournal.spbu.ru/ 319
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Differential Equations and Control Processes, N. 1, 2021
Listing 82: Approximation of iterated Ito stochastic integral I(02)t +1 T
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c02 import C02 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I02 ( Function ) :
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new I02 object with given args Parameters
11 : int
integral index
12 : int
integral index
Electronic Journal. http://diffjournal.spbu.ru/ 320
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Differential Equations and Control Processes, N. 1, 2021
Listing 83: Approximation of iterated Ito stochastic integral IppT*+1 Tp
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c11 import C11 from mathematics . sde . nonlinear . symbolic . ind import Ind
class 111 ( Function ) :
Iterated Ito stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new I11 object with given args Parameters
i1 : int
Electronic Journal. http://diffjournal.spbu.ru/ 321
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Differential Equations and Control Processes, N. 1, 2021
Listing 84: Approximation of iterated Ito stochastic integral IpOO^r ji T
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c1000 import C1000 from mathematics . sde . nonlinear . symbolic . ind import Ind
class 11000 ( Function ) :
Iterated Ito stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new I1000 object with given args
Electronic Journal. http://diffjournal.spbu.ru/ 322
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Differential Equations and Control Processes, N. 1, 2021
Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
if : int
integral index q : int
amount of terms in approximation of iterated Ito stochastic integral d t : fl o a t delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (I1000 , cls) . __new_(cls , * args , ** kwargs)
return Add ( * [
C1000(j4 , j3 , j2 , j1 , dt) *
( ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i1 , i3) * Ind (j1 , j3) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] -
Ind (i1 , i4) * Ind (j1 , j 4 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] -
Ind (i2 , i3 ) * Ind (j2 , j3) * ksi [ j1 , i1 ] * ksi [ j4 , i4 ] -
Ind (i2 , i4 ) * Ind (j2 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] -
Ind (i3 , i4 ) * Ind (j3 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] +
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * Ind ( i3 , i4 ) * Ind (j3 , j 4 ) +
Ind (i1 , i3 ) * Ind (j1 , j3) * Ind (i2 , i4 ) * Ind (j2 , j 4 ) +
Ind (i1 , i4 ) * Ind (j1 , j 4 ) * Ind (i2 , i3 ) * Ind (j2 , j3))
for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
11000
Electronic Journal. http://diffjournal.spbu.ru/ 323
71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Differential Equations and Control Processes, N. 1, 2021
return I1000(* self.args, ** hints)
Listing 85: Approximation of iterated Ito stochastic integral l(0\00)T
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0100 import C0100 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I0100 ( Function ) :
Iterated Ito stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new I0100 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (I0100 , cls) . __new_(cls , * args , ** kwargs)
r e t u r n Add ( *[
C0100(j4, j 3 , j 2 , j1 , dt) *
(ksi [j 1 , i 1 ] * ksi [ j2 , i2] * ksi[j3, i3 ] * ksi[j4, i4 ] —
Electronic Journal. http://diffjournal.spbu.ru/ 324
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Differential Equations and Control Processes, N. 1, 2021
Listing 86: Approximation of iterated Ito stochastic integral IoOioTt4^ t
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0010 import C0010 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I0010 ( Function ) :
Iterated Ito stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new I0010 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
i3 : int
integral index q : int
amount of terms in approximation of iterated Ito stochastic integral
Electronic Journal. http://diffjournal.spbu.ru/ 325
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
1
2
3
4
5
6
7
Differential Equations and Control Processes, N. 1, 2021
dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (I0010 , cls) . __new_(cls , * args , ** kwargs)
return Add ( * [
C0010(j4 , j3 , j 2 , j1 , dt) *
(ksi [jl , il] * ksi [ j2 , i 2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind(il, i 2 ) * Ind (j l , j 2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind(il, i3 ) * Ind (j l , j3) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] -
Ind(il, i4 ) * Ind (j l , j 4 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] -
Ind (i2 , i3 ) * Ind (j2 , j3) * ksi [jl , il] * ksi [ j4 , i4 ] -
Ind (i2 , i4 ) * Ind (j2 , j 4 ) * ksi [jl , il] * ksi [ j3 , i3 ] -
Ind (i3 , i4 ) * Ind (j3 , j 4 ) * ksi [jl , il] * ksi [ j2 , i 2 ] +
Ind(il, i 2 ) * Ind (j l , j 2 ) * Ind ( i3 , i4 ) * Ind (j3 , j 4 ) +
Ind(il, i3 ) * Ind (j l , j3) * Ind (i2 , i4 ) * Ind (j2 , j 4 ) +
Ind(il, i4 ) * Ind (j l , j 4 ) * Ind (i2 , i3 ) * Ind (j2 , j3))
for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
I0010
return I0010(* self.args, ** hints)
Listing 87: Approximation of iterated Ito stochastic integral ^ООо^т4^ t
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0001 import C0001 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I0001 (Function):
Electronic Journal. http://diffjournal.spbu.ru/ 326
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Differential Equations and Control Processes, N. 1, 2021
Iterated Ito stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new I0001 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (I0001 , cls) . __new_(cls , * args , ** kwargs)
return Add ( * [
C0001(j4 , j3 , j2 , j1 , dt) *
( ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (i1 , i3) * Ind (j1 , j3) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] -
Ind (i1 , i4) * Ind (j1 , j 4 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] -
Ind (i2 , i3 ) * Ind (j2 , j3) * ksi [ j1 , i1 ] * ksi [ j4 , i4 ] -
Ind (i2 , i4 ) * Ind (j2 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] -
Ind (i3 , i4 ) * Ind (j3 , j 4 ) * ksi [ j1 , i1 ] * ksi [ j2 , i 2 ] +
Ind (i1 , i 2 ) * Ind (j1 , j 2 ) * Ind ( i3 , i4 ) * Ind (j3 , j 4 ) +
Ind (i1 , i3 ) * Ind (j1 , j3) * Ind (i2 , i4 ) * Ind (j2 , j 4 ) +
Ind (i1 , i4 ) * Ind (j1 , j 4 ) * Ind (i2 , i3 ) * Ind (j2 , j3))
for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
Electronic Journal. http://diffjournal.spbu.ru/ 327
63
64
65
66
67
68
69
70
71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Differential Equations and Control Processes, N. 1, 2021
Listing 88: Approximation of iterated Ito stochastic integral loOOorn)?6^ T
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c000000 import C000000 from mathematics . sde . nonlinear . symbolic . ind import Ind
class I000000 ( Function ) :
Iterated Ito stochastic integral nargs = 9
def __new__(cls, * args, ** kwargs ) :
Creates new I000000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
integral index
15 : int integral index
16 : int
integral index
q : int
amount of terms in approximation of iterated Ito stochastic integral
dt : float delta time
ksi : numpy. ndarray
matrix of Gaussian random variables
Returns
sympy. Expr
fo rmul a to s i m p l i fy and s u b s t i t u t e
Electronic Journal. http://diffjournal.spbu.ru/ 328
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Differential Equations and Control Processes, N. 1, 2021
i1, i2, i3, i4, i5, i6, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and
isinstance (i2 , Number) and
isinstance (i3 , Number) and
isinstance (i4 , Number) and
isinstance (i5 , Number) and
isinstance (i6 , Number) and
isinstance (q , Number) and
isinstance (dt , Number) ) :
return super(I000000, cls).__new__(cls, *args, **kwargs)
return Add ( * [
C000000(j6, j5 , j 4 , j 3 , j2 , j 1 , dt ) *
(ksi [j1 , i 1 * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] *
ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] * ksi [ j6 , i6 ] -
Ind(j1,j6) * Ind (i 1 ,i6) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] -
Ind(j2,j6) * Ind (i2 ,i6) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] -
Ind(j3,j6) * Ind (i3 ,i6) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] -
Ind(j4,j6) * Ind (i4 ,i6) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j5 , i 5 ] -
Ind(j5,j6) * Ind (i5 ,i6) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind(j1,j2) * Ind (i 1 , i2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j1,j3) * Ind (i 1 ,i3) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j1,j4) * Ind (i 1 ,i4) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j1,j5) * Ind (i 1 , i 5 ) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] * ksi [ j3 , i3 ] * ksi [ j6 , i6 ] -
Ind(j2,j3) * Ind (i2 ,i3) * ksi [ j1 , i1 ] * ksi [ j4 , i4 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j2,j4) * Ind (i2 ,i4) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j2,j5) * Ind (i2 , i 5 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] * ksi [ j6 , i6 ] -
Ind(j3 , j4) * Ind (i3 ,i4) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] -
Ind(j3 , j5) * Ind (i3 , i 5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] * ksi [ j6 , i6 ] -
Ind (j4 , j5) * Ind (i4 , i 5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] * ksi [ j6 , i6 ] +
Ind(j1 , j2) * Ind (i 1 , i2 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] +
Ind(j1 , j2) * Ind (i 1 , i2 ) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j4 , i4 ] * ksi [ j6 , i6 ] +
Ind(j1,j2) * Ind (i 1 , i2 ) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j3 , i3 ] * ksi [ j6 , i6 ] +
Ind(j1,j3) * Ind (i 1 ,i3) * Ind (j2 , j4) * Ind ( i2 , i4 ) * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] +
Ind (j1 , j3) * Ind (i 1 ,i3) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * ksi [ j4 , i4 ] * ksi [ j6 , i6 ] +
Ind (j1 , j3) * Ind (i 1 ,i3) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j2 , i2 ] * ksi [ j6 , i6 ] +
Ind(j1 , j4) * Ind (i 1 ,i4) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * ksi [ j5 , i5 ] * ksi [ j6 , i6 ] +
Ind(j1 , j4) * Ind (i 1 ,i4) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * ksi [ j3 , i3 ] * ksi [ j6 , i6 ] +
Ind(j1 , j4) * Ind (i 1 ,i4) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j2 , i2 ] * ksi [ j6 , i6 ] +
Ind(j1,j5) * Ind (i 1 , i 5 ) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * ksi [ j4 , i4 ] * ksi [ j6 , i6 ] +
Ind (j1 , j5) * Ind (i 1 , i 5 ) * Ind(j2 , j4) * Ind ( i2 , i4 ) * ksi [ j3 , i3 ] * ksi [ j6 , i6 ] +
Ind (j1 , j5) * Ind (i 1 , i 5 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j2 , i2 ] * ksi [ j6 , i6 ] +
Ind (j2 , j3) * Ind (i2 ,i3) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j1 , i1 ] * ksi [ j6 , i6 ] +
Ind (j2 , j4) * Ind (i2 ,i4) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j1 , i1 ] * ksi [ j6 , i6 ] +
Ind (j2 , j5) * Ind (i2 , i 5 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j1 , i1 ] * ksi [ j6 , i6 ] +
Ind(j6 , j1) * Ind (i6 , i1 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j2 , i2 ] * ksi [ j5 , i 5 ] +
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] +
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] +
Ind(j6 , j1) * Ind (i6 , i1 ) * Ind (j2 , j4) * Ind ( i2 , i4 ) * ksi [ j3 , i3 ] * ksi [ j5 , i 5 ] +
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] +
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] +
Ind(j6 , j2) * Ind (i6 , i2 ) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j1 , i1 ] * ksi [ j4 , i4 ] +
Ind(j6,j2) * Ind (i6 , i2 ) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] +
Ind(j6,j2) * Ind (i6 , i2 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j1 , i1 ] * ksi [ j5 , i 5 ] +
Electronic Journal. http://diffjournal.spbu.ru/ 329
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Differential Equations and Control Processes, N. 1, 2021
Ind(j6,j2) * Ind (i6 , i2 ) * Ind(j1 , j5) * Ind ( i1 , i5 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] +
Ind(j6,j2) * Ind (i6 , i2 ) * Ind(j1,j4) * Ind ( i1 , i4 ) * ksi [ j3 , i3 ] * ksi [ j5 , i 5 ] +
Ind(j6,j2) * Ind (i6 , i2 ) * Ind(j1 , j3) * Ind ( i1 , i3 ) * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * ksi [j1 , i1 ] * ksi [ j4 , i4 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind (j4 , j5 ) * Ind ( i4 , i5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind(j2 , j4) * Ind ( i2 , i4 ) * ksi [ j1 , i1 ] * ksi [ j5 , i 5 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind (j1 , j5) * Ind ( i1 , i5 ) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind(j1 , j4) * Ind ( i1 , i4 ) * ksi [ j2 , i2 ] * ksi [ j5 , i 5 ] +
Ind(j6,j3) * Ind (i6 , i3 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * ksi [ j4 , i4 ] * ksi [ j5 , i 5 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j3 , j5 ) * Ind ( i3 , i5 ) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * ksi [ j1 , i1 ] * ksi [ j5 , i 5 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j1 , j5) * Ind ( i1 , i5 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind(j1 , j3) * Ind ( i1 , i3 ) * ksi [ j2 , i2 ] * ksi [ j5 , i 5 ] +
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * ksi [ j3 , i3 ] * ksi [ j5 , i 5 ] +
Ind (j6 , j5) * Ind (i6 , i 5 ) * Ind (j3 , j4 ) * Ind ( i3 , i4 ) * ksi [ j1 , i1 ] * ksi [ j2 , i2 ] +
Ind (j6 , j5) * Ind (i6 , i 5 ) * Ind (j2 , j4) * Ind ( i2 , i4 ) * ksi [ j1 , i1 ] * ksi [ j3 , i3 ] +
Ind(j6 , j5) * Ind (i6 , i 5 ) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * ksi [ j1 , i4 ] * ksi [ j1 , i4 ] +
Ind(j6,j5) * Ind (i6 , i 5 ) * Ind(j1 , j4) * Ind ( i1 , i4 ) * ksi [ j2 , i2 ] * ksi [ j3 , i3 ] +
Ind(j6,j5) * Ind (i6 , i 5 ) * Ind(j1 , j3) * Ind ( i1 , i3 ) * ksi [ j2 , i2 ] * ksi [ j4 , i4 ] +
Ind (j6 , j5) * Ind (i6 , i 5 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * ksi [ j3 , i3 ] * ksi [ j4 , i4 ] -
Ind (j6 , j1 ) * Ind (i6 , i1 ) * Ind (j2 , j5 ) * Ind ( i2 , i5 ) * Ind (j3 , j4 ) * Ind (i3 , i4 ) -
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j2 , j4) * Ind ( i2 , i4 ) * Ind (j3 , j5 ) * Ind (i3 , i 5 ) -
Ind (j6 , j1) * Ind (i6 , i1 ) * Ind (j2 , j3 ) * Ind ( i2 , i3 ) * Ind (j4 , j5 ) * Ind (i4 , i 5 ) -
Ind(j6 , j2) * Ind (i6 , i2 ) * Ind (j1 , j5) * Ind ( i1 , i5 ) * Ind (j3 , j4 ) * Ind (i3 , i4 ) -
Ind(j6,j2) * Ind (i6 , i2 ) * Ind(j1 , j4) * Ind ( i1 , i4 ) * Ind (j3 , j5 ) * Ind (i3 , i 5 ) -
Ind (j6 , j2) * Ind (i6 , i2 ) * Ind (j1 , j3) * Ind ( i1 , i3 ) * Ind (j4 , j5 ) * Ind (i4 , i 5 ) -
Ind (j6 , j3) * Ind (i6 , i3 ) * Ind(j1 , j5) * Ind ( i1 , i5 ) * Ind (j 2 , j4) * Ind (i2 , i4 ) -
Ind (j6 , j3) * Ind (i6 , i3 ) * Ind(j1 , j4) * Ind ( i1 , i4 ) * Ind (j2 , j5 ) * Ind (i2 , i 5 ) -
Ind (j3 , j6) * Ind (i3 , i6 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * Ind (j4 , j5 ) * Ind (i4 , i 5 ) -
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j1 , j5) * Ind ( i1 , i5 ) * Ind (j2 , j3 ) * Ind (i2 , i3 ) -
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind (j1 , j3) * Ind ( i1 , i3 ) * Ind (j2 , j5 ) * Ind (i2 , i 5 ) -
Ind(j6 , j4) * Ind (i6 , i4 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * Ind (j3 , j5 ) * Ind (i3 , i 5 ) -
Ind(j6 , j5) * Ind (i6 , i 5 ) * Ind(j1 , j4) * Ind ( i1 , i4 ) * Ind (j2 , j3 ) * Ind (i2 , i3 ) -
Ind (j6 , j5) * Ind (i6 , i 5 ) * Ind(j1 , j2) * Ind ( i1 , i2 ) * Ind (j3 , j4 ) * Ind (i3 , i4 ) -
Ind (j6 , j5) * Ind (i6 , i 5 ) * Ind (j1 , j3) * Ind ( i1 , i3 ) * Ind (j 2 , j4) * Ind (i2 , i4 ) )
for j6 in range(q + 1) for j5 in range(q + 1) for j4 in range(q + 1) for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
I000000
return I000000(* self.args , **hints)
Electronic Journal. http://diffjournal.spbu.ru/ 330
Differential Equations and Control Processes, N. 1, 2021
6.2.4 Source Codes for Iterated Stratonovich Stochastic Integrals Approximations Subprograms
Listing 89: Approximation of Stratonovich stochastic integral I*0()1)+1 T
1 from math import sqrt
2
3 from sympy import Function , sympify , Number
4
5
6 class J0 ( Function ) :
7 ” ” ”
8 Stratonovich stochastic integral
9 ” ” ”
10 nargs = 3
11
12 def __new__(cls, * args, ** kwargs ) :
13 ” ” ”
14 Creates new J0 object with given args
15 Parameters
16
17 i1 : int
18 integral index
19 dt : float
20 delta time
21 ksi : numpy. ndarray
22 matrix of Gaussian random variables
23 Returns
24
25 sympy. Expr
26 formula to simplify and substitute
27 ” ” ”
28 i1 , dt , ksi = sympify ( args )
29
30 if not isinstance (i1 , Number) :
31 return super (J0, cls).__new__(cls, * args, ** kwargs )
32
33 return ksi[0, i1] * sqrt(dt)
34
35 def doit(self, ** hints):
36 ” ” ”
37 Tries to expand or calculate function
38 Returns
39
40 J0
41 ” ” ”
42 return J0(* self.args , **hints)
Listing 90: Approximation of iterated Stratonovich stochastic integral 1*0o)r2)+1 T
1 from math import sqrt
Electronic Journal. http://diffjournal.spbu.ru/ 331
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Differential Equations and Control Processes, N. 1, 2021
from sympy import sympify , Number, Function, Add
class J00(Function) :
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J00 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (q, Number)):
return super (J00 , cls) . __new__(cls , * args , ** kwargs )
return \
( ksi [0 , i 1 ] * ksi [0 , i2 ] +
Add(*[
(ksi[j1 - 1, i1 ] * ksi[j1, i2] —
ksi [j1 , i1 ] * ksi [j1 — 1, i2 ]) /
sqrt(j1 ** 2 * 4 — 1)
for j1 in range(1 , q + 1)]) ) * dt / 2
def doit(self, ** hints):
Tries to expand or calculate function Returns
J00
return J00(* self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 332
Differential Equations and Control Processes, N. 1, 2021
Listing 91: Approximation of Stratonovich stochastic integral I*(ffjt
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Listing 92: Approximation of iterated Stratonovich stochastic integral I(*0(00)r3+)1 T
1
2
3
4
5
6 7
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c000 import C000 class J000 ( Function ) :
from math import sqrt
from sympy import Function , sympify , Number
class J1 ( Function ) :
Stratonovich stochastic integral nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates new J1 object with given args Parameters
i1 : int
integral index dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , dt , ksi = sympify ( args )
if not isinstance (i1 , Number) :
return super (J1 , cls) . __new__(cls , * args , ** kwargs )
return —(ksi [0 , i 1 ] + ksi [1 , i 1 ] / sqrt(3)) * dt ** 1.5 / 2
def doit(self, ** hints):
Tries to expand or calculate function Returns
J1
return J1(* self.args , ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 333
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
]
1
Differential Equations and Control Processes, N. 1, 2021
Iterated Stratonovich stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new J000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (q, Number)):
return super (J000 , cls) . __new__(cls , * args , ** kwargs)
return Add ( * [
C000(j3 , j 2 , j1 , dt) *
ksi[j1, i 1 ] * ksi [j2 , i 2 ] * ksi[j3, i 3 ] for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J000
return J000(* self.args, ** hints)
isting 93: Approximation of iterated Stratonovich stochastic integral I
=(*1*2)
(10)tp+i,tp
from sympy import Function , sympify , Number, Add
Electronic Journal. http://diffiournal.spbu.ru/ 334
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . symbolic . coefficients . c10 import C10
class J10(Function) :
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J10 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (q, Number)):
return super (J10 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C10(j2, j1, dt) * ksi[j1 , i1] * ksi[j2 , i2] for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J10
return J10(* self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 335
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Differential Equations and Control Processes, N. 1, 2021
isting 94: Approximation of iterated Stratonovich stochastic integral I
4*1*2)
(01)тр+ь
т
P
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c01 import C01
class J01(Function) :
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J01 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (q, Number)):
return super (J01 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C01(j2, j1, dt) * ksi[j1 , i1] * ksi[j2 , i2] for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J01
Electronic Journal. http://diffjournal.spbu.ru/ 336
54
L
i
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Differential Equations and Control Processes, N. 1, 2021
return J01(* self.args, ** hints)
iting 95: Approximation of iterated Stratonovich stochastic integral 1*0(0002)t+)1 t
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0000 import C0000
class J0000 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new J0000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
if : int
integral index q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (J0000 , cls) . __new_(cls , * args , ** kwargs)
r e t u r n Add ( *[
C0000(j4 , j3 , j 2 , j1 , dt) *
ksi [ j 1 , i 1 ] * ksi [j2 , i 2 ] * ksi[j3, i 3 ] * ksi[j4, i 4 ]
fo r j 4 i n range(q + 1)
Electronic Journal. http://diffjournal.spbu.ru/ 337
50
51
52
53
54
55
56
57
58
59
60
61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Differential Equations and Control Processes, N. 1, 2021
for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J0000
return J0000(* self.args, ** hints)
Listing 96: Approximation of Stratonovich stochastic integral I
*(ii)
(2)tp+i ,Tp
from math import sqrt
from sympy import sympify , Number, Function
class J2(Function) :
Stratonovich stochastic integral nargs = 3
def __new__(cls, * args, ** kwargs ) :
Creates new J2 object with given args Parameters
i1 : int
integral index d t : fl o a t delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , dt , ksi = sympify( args )
if not isinstance (i1 , Number) :
return super (J2, cls).__new__(cls, * args, ** kwargs )
return (ksi[0, i1] + ksi [1 , i1] * sqrt(3) / 2 + ksi [2 , i1] / sqrt(5) /2) * dt ** 2.5 / 3
def doit(self, ** hints):
Tries to expand or calculate function
Electronic Journal. http://diffjournal.spbu.ru/ 338
Differential Equations and Control Processes, N. 1, 2021
39
40
41
42
43
Listing 97: Approximation of iterated Stratonovich stochastic integral I*1(00)r3+)1 T
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c100 import C100
class J100 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new J100 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, q, dt, ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (q, Number)):
return super (J100 , cls) . __new__(cls , * args , ** kwargs)
return Add ( * [
C100(j3 , j 2 , j1 , dt) *
Returns
J2
return J2(* self.args , **hints)
Electronic Journal. http://diffiournal.spbu.ru/ 339
Differential Equations and Control Processes, N. 1, 2021
46
47
48
49
50
51
52
53
54
55
56
57
58
Listing 98: Approximation of iterated Stratonovich stochastic integral I^wy?3^ Tp
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c010 import C010
class J010 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new J010 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
fo rmula to s i m p l i fy and s u b s t i t u t e i1, i2, i3, q, dt, ksi = sympify (args) if not (isinstance (i1 , Number) and
ksi [ j 1 , i 1 ] * ksi [ j2 , i2 ] * ksi [ j3 , i3 ]
for j3 in range(q + 1) for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J100
return J100(* self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 340
Differential Equations and Control Processes, N. 1, 2021
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Listing 99: Approximation of iterated Stratonovich stochastic integral I*0of)T3+i T
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c001 import C001
class J001 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new J001 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
Electronic Journal. http://diffjournal.spbu.ru/ 341
Differential Equations and Control Processes, N. 1, 2021
31
32 sympy. Expr
33 formula to simplify and substitute
34 """
35 i1, i2, i3, q, dt, ksi = sympify(args)
36
37 if not (isinstance (i1 , Number) and
38 isinstance (i2 , Number) and
39 isinstance (i3 , Number) and
40 isinstance (q, Number)):
41 return super (J001 , cls) . __new__(cls , * args , ** kwargs)
42
43 return Add ( * [
44 C001(j3 , j2 , j1 , dt) *
45 ksi[j1, i 1 ] * ksi[j2, i 2 ] * ksi[j3, i 3 ]
46 for j3 in range(q + 1)
47 for j2 in range(q + 1)
48 for j1 in range(q + 1)])
49
50 def doit(self, ** hints):
51 """
52 Tries to expand or calculate function
53 Returns
54
55 J001
56 """
57 return J001(* self.args, ** hints)
List ing 100: Approximation of iterated Stratonovich stochastic integral IooOoOt4^ T
i from sympy import Function , Number, sympify , Add
2
3 from mathematics . sde . nonlinear . symbolic . coefficients . c00000 import C00000
4 5
6 class J00000 ( Function ) :
7 " " "
8 Iterated Stratonovich stochastic integral
9 """
10 nargs = 8
11
12 def __new__(cls, * args, ** kwargs ) :
13 """
14 Creates new J00000 object with given args
15 Parameters
16
17 i1 : int
18 integral index
19 i2 : int
20 integral index
21 i3 : int
22 integral index
23 if : int
Electronic Journal. http://diffjournal.spbu.ru/ 342
Differential Equations and Control Processes, N. 1, 2021
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61 62
63
64
65
66
Listing 101: Approximation of iterated Stratonovich stochastic integral I*2(0)T2)+1 T
1
2
3
4
5
6 7
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c20 import C20 class J20 ( Function ) :
Electronic Journal. http://diffjournal.spbu.ru/ 343
Differential Equations and Control Processes, N. 1, 2021
8
9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Listing 102: Approximation of iterated Stratonovich stochastic integral I*0(2jT2)+1 T
1
2
3
4
5
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J20 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sy mpify ( args )
if not (isinstance (i1 , Number) and isinstance (i2 , Number) ) :
return super (J20 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C20 (j 2 , j1 , dt) * ksi [ j 1 , i 1 ] * ksi [ j2 , i2 ] for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J20
return J20(* self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 344
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
I
1
2
3
Differential Equations and Control Processes, N. 1, 2021
class J02(Function) :
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J02 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) ) :
return super (J02 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C02(j2, j1, dt) * ksi[j1 , i1] * ksi[j2 , i2] for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J02
return J02(* self.args, ** hints)
sting 103: Approximation of iterated Stratonovich stochastic integral I.
1*1*2)
(11)Tp+bTp
from sympy import Function , sympify, Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c11 import C11
Electronic Journal. http://diffjournal.spbu.ru/ 345
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Li
1
Differential Equations and Control Processes, N. 1, 2021
class J11(Function) :
Iterated Stratonovich stochastic integral nargs = 5
def __new__(cls, * args, ** kwargs ) :
Creates new J11 object with given args Parameters
11 : int
integral index
12 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1 , i2 , q, dt , ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) ) :
return super (J11 , cls) . __new__(cls , * args , ** kwargs )
return Add ( * [
C11(j2, j1, dt) * ksi[j1 , i1] * ksi[j2 , i2] for j2 in range(q + 1) for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function Returns
J11
return J11(* self.args, ** hints)
ting 104: Approximation of iterated Stratonovich stochastic integral I
*(1112*3*4)
(1000)Tp+i,Tp
from sympy import Function , Number, sympify, Add
Electronic Journal. http://diffjournal.spbu.ru/ 346
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . symbolic . coefficients . c1000 import C1000
class J1000(Function) :
Iterated Stratonovich stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new J1000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
if : int
integral index q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (J1000 , cls) . __new_(cls , * args , ** kwargs)
return Add ( * [
C1000(j4 , j3 , j2 , j1 , dt) *
ksi[j1, i 1 ] * ksi [j2 , i 2 ] * ksi[j3, i 3 ] * ksi[j4, i 4 ]
for j4 in range(q + 1)
for j3 in range(q + 1)
for j2 in range(q + 1)
for j1 in range(q + 1)])
def doit(self, ** hints):
Tries to expand or calculate function
Electronic Journal. http://diffjournal.spbu.ru/ 347
Differential Equations and Control Processes, N. 1, 2021
57
58
59
60 61
Listing 105: Approximation of iterated Stratonovich stochastic integral I*0i00)T+! r
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0100 import C0100
class J0100 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new J0100 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
if : int
integral index q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
formula to simplify and substitute
i1, i2, i3, i4, q, dt, ksi = sympify (args)
if not (isinstance (i1 , Number) and isinstance (i2 , Number) and isinstance (i3 , Number) and isinstance (i4 , Number) and isinstance (q, Number)):
return super (J0100 , cls) . __new_(cls , * args , ** kwargs)
Returns
J1000
return J1000(* self.args, ** hints)
Electronic Journal. http://diffiournal.spbu.ru/ 348
Differential Equations and Control Processes, N. 1, 2021
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61
Listing 106: Approximation of iterated Stratonovich stochastic integral I*0oi02)rT
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
from sympy import Function , sympify , Number, Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0010 import C0010
class J0010 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new J0010 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
i3 : int
integral index q : int
amount of terms in approximation of iterated Stratonovich stochastic integral dt : float delta time ksi : numpy. ndarray
matrix of Gaussian random variables Returns
sympy. Expr
Electronic Journal. http://diffjournal.spbu.ru/ 349
Differential Equations and Control Processes, N. 1, 2021
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61
Listing 107: Approximation of iterated Stratonovich stochastic integral I*0o0i2)r+i T
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22 23
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c0001 import C0001
class J0001 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 7
def __new__(cls, * args, ** kwargs ) :
Creates new J0001 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
14 : int
Electronic Journal. http://diffjournal.spbu.ru/ 350
Differential Equations and Control Processes, N. 1, 2021
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 61
Listing 108: Approximation of iterated Stratonovich stochastic integral 1*Oo002q0)T+it
1
2
3
4
5
6
7
8 9
10
11
12
from sympy import Function , Number, sympify , Add
from mathematics . sde . nonlinear . symbolic . coefficients . c000000 import C000000
class J000000 ( Function ) :
Iterated Stratonovich stochastic integral nargs = 9
def __new__(cls, * args, ** kwargs ) :
Electronic Journal. http://diffjournal.spbu.ru/ 351
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Differential Equations and Control Processes, N. 1, 2021
Creates new J000000 object with given args Parameters
11 : int
integral index
12 : int
integral index
13 : int integral index
if : int
integral index
15 : int integral index
16 : int
integral index
q : int
amount of terms in approximation of iterated Stratonovich stochastic integral
dt : float delta time
ksi : numpy. ndarray
matrix of Gaussian random variables
Returns
sympy. Expr
fo rmula t o s i m p l i fy and s u b s t i t u t e
i1, i2, i3, i4, i5, i6, q, dt, ksi = sympify(args)
if not (isinstance (i1 , Number) and
isinstance (i2 , Number) and
isinstance (i3 , Number) and
isinstance (i4 , Number) and
isinstance (i5 , Number) and
isinstance (i6 , Number) and
isinstance (q , Number) and
isinstance (dt , Number) ) :
return super (J000000 , cls) .__new__(cls , * args , ** kwargs )
return Add ( * [
C000000(j6 , j5 , j4 , j3 , j2 , j1 , dt) *
ksi [ j1 i1] * ksi[j2 , i2] * ksi [ j3 , i3 ] *
ksi [ j4 i4 ] * ksi[j5 , i5 ] * ksi [j6 , i6 ]
fo r j 6 in range(q + 1)
fo r j 5 in range(q + 1)
fo r j 4 in range(q + 1)
fo r j 3 in range(q + 1)
fo r j 2 in range(q + 1)
fo r j 1 in range(q + 1) ] )
def doit(self, ** hints):
Tries to expand or calculate function Returns
Electronic Journal. http://diffjournal.spbu.ru/ 352
Differential Equations and Control Processes, N. 1, 2021
68 =======
69 J000000
70 ” ” ”
71 return J000000(*self.args, **hints)
6.2.5 Source Codes for Calculation of the Numbers q, q\,..., ql5
Listing 109: Calculation of the numbers q, q1v .., q15
1
2
3
4
5
6
7
8 9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from mathematics . sde . nonlinear . symbolic . coefficients . c import C def solve_q ( i) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1/4 — 1/2 * sum ( [
1/(4 * j ** 2 — 1) for j in range(1, i + 1)
])
def solve_q1 ( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1/6 — 1/64 * sum ( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(2 * j3 + 1) *
C((j1 , j2 , j3) ,(0,0, 0)) ** 2 for j1 in range(i + 1) for j2 in range(i + 1) for j3 in range(i + 1)
])
Electronic Journal. http://diffjournal.spbu.ru/ 353
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Differential Equations and Control Processes, N. 1, 2021
def solve_q2 ( i ) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1/4 — 1/64 * sum ( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(C((j1, j2), (0, 1)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1)
])
def solve_q2_optional(i):
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1/12 — 1/64 * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(C((j1, j2), (1, 0)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1)
])
def solve_q3 ( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
Electronic Journal. http://diffjournal.spbu.ru/ 354
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Differential Equations and Control Processes, N. 1, 2021
return 1 / 24 — 1 / 256 * sum ( [
(2 j1 + 1) *
(2 j2 + 1) *
(2 j3 + 1) *
(2 j4 + 1) *
(C((j1 , j2 , j 3 , j 4 ) (0, 0, 0, 0)) ** 2)
for j1 in range( i + 1)
for j2 in range( i + 1)
for j3 in range( i + 1)
for j4 in range( i + 1)
])
def solve_q4 ( i ) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 120 — 1 / (32 ** 2) * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(2 * j3 + 1) *
(2 * j4 + 1) *
(2 * j5 + 1) *
(C((j1 , j2 , j3 , j4 , j5) ,(0,0, 0, 0, 0)) ** 2)
for j1 in range(i + 1)
for j2 in range(i + 1)
for j3 in range(i + 1)
for j4 in range(i + 1)
for j5 in range(i + 1)
])
def solve_q5 ( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 60 — 1 / 256 * sum( [
(2 * j1 + 1) *
Electronic Journal. http://diffjournal.spbu.ru/ 355
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Differential Equations and Control Processes, N. 1, 2021
(2 * j 2 + 1) *
(C((j1 , j2 ) , (2, 0) ) ** 2)
for j1 i n range ( i + 1)
for j2 i n range ( i + 1)
])
def solve_q6 ( i ) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 18 — 1 / 256 * sum([
(2 * j1 + 1) *
(2 * j2 + 1) *
(C((j1 , j2), (1, 1)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1)
])
def solve_q7 ( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 6 — 1 / 256 * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(C((j1, j2), (0, 2)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1)
])
def solve_q8 ( i ) :
Calculates value for iteration of loop Parameters
i : int
Electronic Journal. http://diffjournal.spbu.ru/ 356
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Differential Equations and Control Processes, N. 1, 2021
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 10 — 1 / 256 * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(2 * j3 + 1) *
(C((j1 , j2 , j3) ,(0,0,1)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1) for j3 in range(i + 1)
])
def solve_q9 ( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 20 — 1 / 256 * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(2 * j3 + 1) *
(C((j1 , j2, j3), (0, 1, 0)) ** 2) for j1 in range(i + 1) for j2 in range(i + 1) for j3 in range(i + 1)
])
def solve_q10(i):
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 60 — 1 / 256 * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
Electronic Journal. http://diffjournal.spbu.ru/ 357
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
Differential Equations and Control Processes, N. 1, 2021
(2 * j3 + 1) *
(C((j1 , j2 , j3), (1, 0, 0)) ** 2)
for j1 in range(i + 1)
for j2 in range(i + 1)
for j3 in range(i + 1)
])
def solve_q 11(i) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 /36 - 1 / (32 ** 2) * sum ( [
(2 j1 + 1) *
(2 j2 + 1) *
(2 j3 + 1) *
(2 j4 + 1) *
(C((j1 , j2 , j3 , j 4 ) (0, 0, 0, 1)) ** 2)
for j1 in range( i + 1)
for j2 in range( i + 1)
for j3 in range( i + 1)
for j4 in range( i + 1)
])
def solve_q12( i ) :
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 /60 - 1 / (32 ** 2) * sum ( [
(2 j1 + 1) *
(2 j2 + 1) *
(2 j3 + 1) *
(2 j4 + 1) *
(C((j1 , j2 , j 3 , j 4 ) (0, 0, 1, 0)) ** 2)
for j1 in range( i + 1)
for j2 in range( i + 1)
for j3 in range( i + 1)
for j4 in range( i + 1)
Electronic Journal. http://diffjournal.spbu.ru/ 358
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
Differential Equations and Control Processes, N. 1, 2021
])
def solve_q13( i ) :
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 /120 — 1 / (32 ** 2) * sum ( [
(2 j1 + 1) *
(2 j2 + 1) *
(2 j3 + 1) *
(2 j4 + 1) *
(C((j1 , j2 , j3 , j 4 ) , (0, 1, 0, 0)) ** 2)
for j1 in range( i + 1)
for j2 in range( i + 1)
for j3 in range( i + 1)
for j4 in range( i + 1)
])
def solve_q14(i):
Calculates value for iteration of loop Parameters
i : int
amount of members Returns
values : float
value for iteration of loop that calculates amount of q
return 1 / 360 — 1 / (32 ** 2) * sum( [
(2 * j1 + 1) *
(2 * j2 + 1) *
(2 * j3 + 1) *
(2 * j4 + 1) *
(C((j1 to со (1, 0, 0, 0)) ** 2)
for j1 i n range ( i + 1)
for j2 i n range ( i + 1)
for j3 i n range ( i + 1)
for j4 i n range ( i + 1)
])
def solve_q15(i):
Electronic Journal. http://diffjournal.spbu.ru/ 359
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
Differential Equations and Control Processes, N. 1, 2021
Calculates value for iteration of loop Parameters
i : in t
amount of members Returns
values : float
value for iteration of loop that calculates amount of q return 1 / 720 — 1 / (64 ** 2) * sum( [
(2 j1 + 1) *
(2 j2 + 1) *
(2 j3 + 1) *
(2 j4 + 1) *
(2 j5 + 1) *
(2 j6 + 1) *
(C((j1 , j2 , j3 , j4 CM * * о о о о о о со ю
for j1 in range(i + 1)
for j2 in range(i + 1)
for j3 in range(i + 1)
for j4 in range(i + 1)
for j5 in range(i + 1)
for j6 in range(i + 1)
])
solvers = [
solve_q , solve_q1 , solve_q2 , solve_q3 , solve_q8 , solve_q9 , solve_q10 , solve_q4 , solve_q7 , solve_q6 , solve_q5 , solve_q11 , solve_q12 , solve_q13 , solve_q14 , solve_q15 ,
]
dt_degrees = [
[1],
[2, 1],
[3 , 2, 1, 1] ,
[4 , 3, 2, 2, 1 , 1, 1 , 1] ,
[5, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1],
]
q_ranges = [
1, 2, 4, 8, 16
]
def loop(dt: float , k: float , degree: int , solver):
Loop that chooses amount of q that provides necessary accuracy Parameters
dt : float delta time k : f l o a t
Electronic Journal. http://diffjournal.spbu.ru/ 360
Differential Equations and Control Processes, N. 1, 2021
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
user chosen coefficient of accuracy degree : int
degree of dt depending on q solver : function fu n c t i o n t h a t Returns
i : int
amount of q
i = 0
while True:
if solver(i) <= k * dt ** degree: break
i += 1
return i
def get_q(dt: float , k: float , r: float):
Iterates solvers and get q values necessary to
achieve given accuracy
Parameters
d t : fl o a t
integration step k : fl o a t
user chosen coefficient of accuracy r : fl o a t
strong numerical scheme order Returns
qs-result: tuple
q values
qs .result = []
degree = int(r * 2) range_id = degree — 2
for q_id in range(q_ranges[range_id]) :
qs_result.append(loop(dt, k, dt_degrees[range_id][q_id] , solvers [q_id ]) )
return tuple (qs.result)
6.2.6 Source Codes for Strong Taylor—Ito Numerical Schemes with Convergence Orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs
Listing 110: Euler scheme modeling subprogram
1 import logging
Electronic Journal. http://diffjournal.spbu.ru/ 361
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Differential Equations and Control Processes, N. 1, 2021
from time import time import numpy as np
from sympy import lambdify , Matrix , symbols , MatrixSymbol , Symbol from mathematics . sde . nonlinear . symbolic . schemes . euler import Euler
def euler(y0: np.array, a: Matrix, b: Matrix, times: tuple):
Performs modeling of Euler scheme Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b times : tuple
integration limits and step Returns
y : numpy. ndarray vector of s olution t : list
list of time moments start_time = time ()
logger = logging. getLogger(_name__)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Euler start”)
# Ranges
n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt)
# Symbols
sym_i, sym_t = Symbol (”i ”) , Symbol (”t”) sym_ksi = MatrixSymbol(”ksi” , 1 , m)
sym_y=Euler(sym_i, Matrix(args), a, b, dt, sym_ksi)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas
Electronic Journal. http://diffjournal.spbu.ru/ 362
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Differential Equations and Control Processes, N. 1, 2021
Listing 111: Euler scheme
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . ito . i0 import I0
class Euler (Function) :
Euler scheme nargs = 6
def __new__(cls, * args, ** kwargs ) :
Creates new Euler object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables Returns
Electronic Journal. http://diffjournal.spbu.ru/ 363
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Differential Equations and Control Processes, N. 1, 2021
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi = sympify(args) n, m = b.shape[0], b.shape[1]
return Add(
yp[ i , 0] , a[ i , 0] * dt ,
* [b[i, i1 ] * I0(i1, dt , ksi) for i1 in range (m)]
)
def doit(self, ** hints):
Tries to expand or calculate function Returns
sympy. Expr
return Euler(* self.args , ** hints)
Listing 112: Milstein scheme modeling subprogram
import logging
from time import time
import numpy as np
from sympy import symbols , MatrixSymbol , Matrix , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . milstein import Milstein
def milstein(y0: np.array, a: Matrix, b: Matrix, k: float , times: tuple):
Performs modeling of Milstein scheme Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b q : tuple
amount of independent random variables times : tuple
integration limits and step Returns
Electronic Journal. http://diffjournal.spbu.ru/ 364
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Differential Equations and Control Processes, N. 1, 2021
y : numpy. ndarray vector of s olution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger. inf o ( f” [ { (time () — start_time):.3f } seconds] Milstein start”)
# Ranges
n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt) q = get _q(dt, k, 1)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Using C = { k} ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using dt = { dt } ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using q = {q} ”)
# Symbols
sym_i, sym_t = symbols(”i t”)
sym_ksi = MatrixSymbol(”ksi”, q [0] + 2, m)
sym_y = Milstein (sym_i, Matrix(args), a, b, dt, sym_ksi, args, q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y-compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) ) logger. inf o ( f” [ { (time () — start_time):.3f} seconds] Milstein subs are finished
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
logger. inf o ( f” [ { (time () — start_time):.3f} seconds] Milstein calculations are
)
)
fin ished
Electronic Journal. http://diffjournal.spbu.ru/ 365
82
83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Differential Equations and Control Processes, N. 1, 2021
return y, t
Listing 113: Milstein scheme
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . g import G
from mathematics . sde . nonlinear . symbolic . ito . i0 import I0
from mathematics . sde . nonlinear . symbolic . ito . i00 import I00
class Milstein (Function) :
Milstein scheme nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new Milstein object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
return Add(
yp[ i , 0] , a[ i , 0] * dt ,
* [b[i, i1 ] * I0(i1, dt , ksi) for i1 in range (m)] ,
* [G(b[: , i1], b[i, i2 ] , dxs) *
Electronic Journal. http://diffjournal.spbu.ru/ 366
Differential Equations and Control Processes, N. 1, 2021
49
50
51
52
53
54
55
56
57
58
59
60 61 62
Listing 114: Strong Taylor—Ito scheme with convergence order 1.5 modeling subprogram
1 2
3
4
5
6
7
8
9 10 11 12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_ito_1p5 import
StrongTaylorIto1p5
def strong_taylor_ito_1p5(y0: np.array, a: Matrix, b: Matrix, k: float , times: tuple):
Performs modeling of Strong Taylor—Ito scheme with convergence order 1.5 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of solution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
I00(i1, i2, q[0] , dt, ksi) for i2 in range(m) for i1 in range(m) ]
)
def doit(self, ** hints):
Tries to expand or calculate function Returns
sympy. Expr
return Milstein( * self.args , ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 367
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1
Differential Equations and Control Processes, N. 1, 2021
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 1.5 start”)
# Ranges
n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt) q = get_q(dt, k, 1.5)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Using C = { k} ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using dt = { dt } ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using q = {q} ”)
# Symbols
sym_i, sym_t = symbols(”i t”)
sym_ksi = MatrixSymbol(”ksi”, q [0] + 2, m)
sym_y = StrongTaylorIto1p5 (sym_i , Matrix( args) , a, b, dt , sym_ksi , args, q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger . info ( f” [ { (time() — starUtime ) :.3 f} seconds] Strong Taylor — Ito 1.5 subs are finished” )
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 1.5 calculations are finished” )
return y, t
Listing 115: Strong Taylor—Ito scheme with convergence order 1.5
from sympy import Function , sympify , Add
Electronic Journal. http://diffjournal.spbu.ru/ 368
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde from mathematics . sde from mathematics . sde from mathematics . sde from mathematics . sde from mathematics . sde
nonlinear . symbolic nonlinear . symbolic nonlinear . symbolic nonlinear . symbolic nonlinear . symbolic nonlinear . symbolic
. g import G
. ito . i0 import I0 . ito . i00 import I00 ito.i000 import I000 ito. i1 import 11 l import L
class StrongTaylorIto1p5 (Function ) :
Strong Taylor-Ito scheme with convergence order 1.5 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorIto1p5 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
return Add(
yp[ i , 0] , a[ i , 0] * dt ,
* [b[i, i1 ] * I0(i1, dt , ksi) for i1 in range (m)] ,
*[G(b [: . i1 ] , b[ i , i2 ] , dxs) *
I00(i1 , i2 , q[0] , dt , ksi)
fo r i 2 i n range (m)
fo r i 1 i n range (m) ] ,
* [G(b[: , i1], a[i, 0], dxs) *
Electronic Journal. http://diffjournal.spbu.ru/ 369
Differential Equations and Control Processes, N. 1, 2021
57
58
59
60 61 62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Listing 116: Strong Taylor—Ito scheme with convergence order 2.0 modeling subprogram
1 2
3
4
5
6
7
8
9 10 11 12
13
14
15
16
17
18
19
20 21 22
23
24
25
import logging
from time import time
import numpy as np
from sympy import symbols , Matrix , MatrixSymbol , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_ito_2p0 import StrongTaylorIto2p0
def strong_taylor_ito_2p0(y0: np.array, a: Matrix, b: Matrix, k: float , times: tuple):
Performs modeling of Strong Taylor—Ito scheme with convergence order 2.0 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step
Electronic Journal. http://diffjournal.spbu.ru/ 370
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Differential Equations and Control Processes, N. 1, 2021
Returns
y : numpy. ndarray vector of solution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor — Ito 2.0 start”)
# Ranges
n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt) q = get_q(dt, k, 2)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Using C = { k} ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using dt = { dt } ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using q = {q} ”)
# Symbols
sym_i, sym_t = symbols(”i t”)
sym_ksi = MatrixSymbol(”ksi”, q [0] + 2, m)
sym_y = StrongTaylorIto2p0 (sym_i , Matrix( args) , a, b, dt , sym_ksi , args, q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi ])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y-compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 2.0 subs are finished” )
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
Electronic Journal. http://diffjournal.spbu.ru/ 371
80
81
82
83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Differential Equations and Control Processes, N. 1, 2021
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor — Ito 2.0 calculations are finished” )
return y, t
Listing 117: Strong Taylor—Ito scheme with convergence order 2.0
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . g import G from mathematics . sde . nonlinear . symbolic . ito . i0 import I0 from mathematics . sde . nonlinear . symbolic . ito . i00 import I00 from mathematics . sde . nonlinear . symbolic . ito . i000 import I000 from mathematics . sde . nonlinear . symbolic . ito . i0000 import I0000 from mathematics . sde . nonlinear . symbolic . ito . i01 import I01 from mathematics . sde . nonlinear . symbolic . ito . i1 import I1 from mathematics . sde . nonlinear . symbolic . ito . i10 import I10 from mathematics . sde . nonlinear . symbolic . l import L
class StrongTaylorIto2p0 (Function ) :
Strong Taylor-Ito scheme with convergence order 2.0 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorIto2p0 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
Electronic Journal. http://diffjournal.spbu.ru/ 372
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Differential Equations and Control Processes, N. 1, 2021
return Add(
yp [ i , 0] , a[i , 0] * dt ,
* [b[i, i1] * I0(i1, dt , ksi) for i1 in range(m)],
*[G(b[: , i1] , b[i, i 2] , dxs) *
I00(i1, i 2 , q [0] , dt, ksi) for i2 in range (m) for i1 in range(m)],
* [G(b [: , i 1 ] , a [ i , 0], dxs) *
(dt * I0(i1, dt, ksi) + I1(i1, dt, ksi)) —
L(a, b, b[i, i1], dxs) *
I1 (i1 , dt , ksi) for i1 in range(m)],
*[G(b[: , i1] , G(b[: , i2] , b[i, i3], dxs), dxs) *
I000(i1, i2, i3, q [ 1 ] , dt, ksi) for i3 in range (m)
for i2 in range (m)
for i1 in range(m)],
dt ** 2/2 * L(a, b, a[i, 0], dxs),
*[G(b[:, i1], L(a, b, b[i, i2], dxs), dxs) *
(I10(i1, i2, q [ 2 ] , dt, ksi) — 10 1 (i 1 , i2, q [ 2 ] , dt, ksi)) —
L(a, b, G(b[: , i1] , b[i, i2], dxs), dxs) * 110 (i1 , i2, q[2 ] , dt,
G( b [: , i 1 ] , G(b [: , i2 ] , a [ i , 0], dxs), dxs) *
(I01(i1, i2, q [ 2 ] , dt, ksi) + dt * I00(i1, i2, q [0 ] , dt, ksi))
for i2 in range (m)
for i1 in range(m)],
*[G(b[:, i1], G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs)
I0000 (i1 , i2, i3, i4, q [ 3 ] , dt, ksi) for i4 in range (m)
for i3 in range (m)
for i2 in range(m)
for i1 in range(m)]
)
def doit(self, ** hints):
Tries to expand or calculate function Returns
sympy. Expr
return StrongTaylorIt o2p0 (* self.args, ** hints)
ksi) +
*
Electronic Journal. http://diffjournal.spbu.ru/ 373
Js
jr;
i
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Differential Equations and Control Processes, N. 1, 2021
ing 118: Strong Taylor—Ito scheme with convergence order 2.5 modeling subpro-
import logging
from time import time
import numpy as np
from sympy import symbols , Matrix , MatrixSymbol , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_ito_2p5 import StrongTaylorIto2p5
def strong_taylor_ito_2p5(y0: np . array , a : Matrix , b : Matrix , k : float , times: tuple) :
” ” ”
Performs modeling of Strong T aylor-Ito scheme with convergence order 2.5
Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of solution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor — Ito 2.5 start”)
# Ranges
n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt) q = get_q(dt, k, 2.5)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Using C = { k} ”)
Electronic Journal. http://diffjournal.spbu.ru/ 374
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Differential Equations and Control Processes, N. 1, 2021
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using dt = { dt } ”) logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using q = {q} ”)
# Symbols
sym_i, sym_t = symbols(”i t”)
sym_ksi = MatrixSymbol(”ksi”, q [0] + 3, m)
sym_y = StrongTaylorIto2p5 (sym_i , Matrix( args) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi ])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 2.5 subs are finished” )
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 3, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 2.5 calculations are finished” )
return y, t
Listing 119: Strong Taylor—Ito scheme with convergence order 2.5
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear from mathematics . sde . nonlinear
symbolic .g import G symbolic . ito . i0 import I0 symbolic . ito . i00 import I00 symbolic . ito . i000 import I000 symbolic . ito . i0000 import I0000 symbolic . ito . i00000 import I00000 symbolic . ito . i001 import I001 symbolic . ito . i01 import I01 symbolic . ito . i010 import I010 symbolic . ito . i1 import I1 symbolic . ito . i10 import I10 symbolic . ito . i100 import I100 symbolic . ito . i2 import I2
Electronic Journal. http://diffjournal.spbu.ru/ 375
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . symbolic . l import L
class StrongTaylorIto2p5 (Function ) :
Strong Taylor-Ito scheme with convergence order 2.5 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorIto2p5 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
return Add(
yp[ i , 0] , a[ i , 0] * dt ,
* [b[i, i1 ] * I0(i1, dt , ksi) for i1 in range (m)] ,
*[G(b [: . i1 ] , b[ i , i2 ] , dxs) *
I00(i1 , i2 , q[0] , dt , ksi)
fo r i 2 i n range (m)
fo r i 1 i n range (m) ] ,
* [G(b[: , i1], a[i, 0], dxs) *
(dt * I0(i1, dt, ksi) + I1(i1, dt, ksi)) —
L(a, b, b[i, i1], dxs) *
I1(i1 , dt , ksi) for i1 in range (m)] ,
* [G(b[: , i1], G(b[: , i2 ] , b[i, i3 ] , dxs), dxs) *
Electronic Journal. http://diffjournal.spbu.ru/ 376
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Differential Equations and Control Processes, N. 1, 2021
I000(i1 , i2, i3, q[1], dt, ksi) for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
dt ** 2 / 2 * L(a, b, a[ i , 0] , dxs) ,
*[G(b[:, i1], L(a, b, b[ i , i 2] , dxs) , dxs) *
( I10(i1 , i2 , q[2] , dt , ksi) — 10 1 (i 1 , i2, q [ 2 ] , dt, ksi)) —
L(a, b, G(b[:, i1], b[i , i2], dxs), dxs) * 110 (i 1 , i2, q [ 2 ] , dt, ksi) +
G(b [: , i 1 ] , G(b [: , i2 ] , a[i, 0], dxs), dxs) *
( I01 (i1 , i2 , q [2] , dt , ksi) + dt * I00(i1, i2, q [0] , dt, ksi))
for i2 in range(m)
for i1 in range(m) ] ,
* [G(b[: , i1], G(b[: , i2 ] , G(b[: , i3 ] , b[i, i4 ] , dxs) , dxs) , dxs) *
I0000(i1, i2, i3, i4, q[3] , dt, ksi) for i4 in range (m) for i3 in range (m) for i2 in range (m) for i1 in range (m)] ,
*[G(b [: , i1], L(a, b, a[i, 0 ] , dxs ) , dxs ) *
(I2(i1 , dt , ksi) / 2 + dt * I1(i1, dt, ksi) + dt ** 2 / 2 * I0(i1, dt, ksi)) +
L(a, b, L(a , b , b[ i , i1 ] , dxs) , dxs) * I2(i1 , dt , ksi) /2 —
L(a , b, G(b[: , i1 ] , a[ i , 0], dxs), dxs) * (I2(i1, dt, ksi) + dt * I1(i1 , dt , ksi) )
for i1 i n range (m) ] ,
* [G(b[: , i1], L(a, b, G(b[: , i2 ] , b[i, i3 ] , dxs), dxs), dxs) *
(I100(i1, i2, i3, q[6], dt, ksi) — I010(i1, i2, i3, q[5] , dt, ksi)) +
G(b[: , i1], G(b[: , i2] , L(a, b, b[i, i3] , dxs), dxs), dxs) *
(I010(i1, i2, i3, q[5], dt, ksi) — I001(i1, i2, i3, q[4] , dt, ksi)) +
G(b[: , i1], G(b[: , i2 ] , G(b[: , i3 ] , a[i, 0], dxs), dxs), dxs) *
(dt * I000(i1, i2, i3, q[1] , dt, ksi) + I001(i1, i2, i3, q[4] , dt, ksi)) — L(a, b, G(b[:, i1], G(b[:, i2], b[i, i3], dxs), dxs), dxs) *
I100(i1, i2, i3, q[6], dt, ksi) for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
* [G(b [: , i1 ] , G(b[: , i2], G(b[:, i3], G(
b [: , i4], b[i, i5 ] , dxs), dxs), dxs), dxs) *
I00000 (i1 , i2 , i3 , i4 , i5 , q[7], dt, ksi)
for i5 in range(m)
for i4 in range(m)
for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
dt ** 3 / 6 * L(a, b, L(a, b, a[i, 0], dxs), dxs)
)
def doit(self, ** hints):
Tries to expand or calculate function
Electronic Journal. http://diffjournal.spbu.ru/ 377
Differential Equations and Control Processes, N. 1, 2021
126
127
128
129
130
Returns sympy. Expr
return StrongTaylorIt o2p5 (* self.args, ** hints)
Listing 120: Strong Taylor—Ito scheme with convergence order 3.0 modeling subprogram
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logging
from time import time
import numpy as np
from sympy import Matrix , symbols , MatrixSymbol , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_ito_3p0 import StrongTaylorIto3p0
def strong_taylor_ito_3p0(y0: np.array, a: Matrix, b: Matrix, k: float , times: tuple):
Performs modeling of Strong Taylor—Ito scheme with convergence order 3.0 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of s olution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor — Ito 3.0 start”)
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ]
Electronic Journal. http://diffjournal.spbu.ru/ 378
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1
2
3
4
5
6
7
8
Differential Equations and Control Processes, N. 1, 2021
t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: {n + 1} ”) ticks = int ((t2 — t1) / dt) q = get_q(dt, k, 3)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Using C = { k} ”)
logger . info ( f” [ { (time() — starUtime ) :.3 f } seconds] Using dt = { dt } ”)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Using q = {q} ”)
# Symbols
sym_i, sym_t = symbols(”i t”)
sym_ksi = MatrixSymbol(”ksi”, q [0] + 3, m)
sym_y = StrongTaylorIto3p0 (sym_i , Matrix( args) , a, b, dt , sym_ksi , args, q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger . info ( f” [ { (time() — starUtime ) :.3 f} seconds] Strong Taylor — Ito 3.0 subs are finished” )
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 3, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
logger . info ( f” [ { (time() — start_time ) :.3 f} seconds] Strong Taylor — Ito 3.0 calculations are finished” )
return y, t
Listing 121: Strong Taylor—Ito scheme with convergence order 3.0
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . g import G from mathematics . sde . nonlinear . symbolic . ito . i0 import I0
from mathematics . sde . nonlinear . symbolic . ito . i00 import I00
from mathematics . sde . nonlinear . symbolic . ito . i000 import I000
from mathematics . sde . nonlinear . symbolic . ito . i0000 import I0000
from mathematics . sde . nonlinear . symbolic . ito . i00000 import I00000
Electronic Journal. http://diffjournal.spbu.ru/ 379
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear . from mathematics . sde . nonlinear .
symbolic . ito . i000000 import I000000 symbolic . ito . i0001 import I0001 symbolic . ito . i001 import I001 symbolic . ito . i0010 import I0010 symbolic . ito . i01 import I01 symbolic . ito . i010 import I010 symbolic . ito . i0100 import I0100 symbolic . ito . i02 import I02 symbolic . ito . i1 import I1 symbolic . ito . i10 import I10 symbolic . ito . i100 import I100 symbolic . ito . i1000 import I1000 symbolic . ito . i11 import I11 symbolic . ito . i2 import I2 symbolic . ito . i20 import I20 symbolic . l import L
class StrongTaylorIto3p0 (Function ) :
Strong Taylor-Ito scheme with convergence order 3.0 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorIto3p0 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
return Add(
yp[ i , 0] , a[ i , 0] * dt ,
Electronic Journal. http://diffjournal.spbu.ru/ 380
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Differential Equations and Control Processes, N. 1, 2021
* [b[i, i 1 ] * I0(i1, dt , ksi) for i1 in range(m)],
* [G(b [: i1 ] , b[ i , i2 ] dxs) *
I00(i1 i2 , q[0] , dt , ksi)
fo r i 2 i n range (m)
fo r i 1 i n range (m) ] ,
* [G(b [: , i 1 ] , a [ i , 0], dxs) *
(dt * I0(i1, dt, ksi) + I1(i1, dt, ksi)) —
L(a, b, b[i, i1], dxs) *
I1 (i1 , dt , ksi) for i1 in range(m)],
*[G(b[: , i1] , G(b[: , i2] , b[i, i3], dxs), dxs) * I000(i1, i2, i3, q [ 1 ] , dt, ksi) for i3 in range (m)
for i2 in range (m)
for i1 in range(m)],
dt ** 2/2 * L(a, b, a[i, 0], dxs),
*[G(b[:, i1], L(a, b, b[ i , i2 ] , dxs), dxs) *
( 110(i 1 , i2 , q[2] , dt , ksi ) — I0 1 (i 1 , i2, q [ 2 ] , dt, ksi)) —
L(a, b, G(b[:, i1], b[i , i2] , dxs), dxs) * 110 (i 1 , i2, q [ 2 ] , dt, ksi) +
G(b [: , i 1 ] , G(b [: , i2 ] , a[ i , 0 ] , dxs) , dxs) *
( 10 1(i 1 , i2 , q[2] , dt , ksi) + dt * 10 0 (i 1 , i2, q [0] , dt, ksi))
for i2 in range(m)
for i1 in range(m) ] ,
*[G(b[:, i1], G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs) *
I0000 (i1 , i2, i3, i4, q [ 3 ] , dt, ksi) for i4 in range (m) for i3 in range (m) for i2 in range(m) for i1 in range(m)],
*[G(b [: , i 1 ] , L (a , b, a [ i , 0 ] , dxs ) , dxs ) *
( I2(i1 , dt , ksi) / 2 + dt * 11 ( i 1 , dt, ksi) + dt ** 2 / 2 * 10 ( i 1 , dt, ksi)) +
L( a , b , L(a , b , b[ i , i1 ] , dxs) , dxs) * 12 ( i 1 , dt , ksi) /2 —
L( a , b , G(b [: , i1] , a[i , 0], dxs), dxs) * ( I2 (i 1 , dt, ksi) + dt * 11 ( i 1 , dt , ksi) )
fo r i 1 i n range (m) ] ,
*[G(b[: , i 1 ] , L(a, b, G(b[: , i2 ] , b[i, i3], dxs), dxs), dxs) *
( I100 (i 1 , i2, i3, q [6] , dt, ksi) — I010(i1, i2, i3, q [5] , dt, ksi)) +
G(b[:, i1], G(b[:, i2], L(a, b, b[i, i3], dxs), dxs), dxs) *
( I010 (i 1 , i2, i3, q [ 5 ] , dt, ksi) — I001(i1, i2, i3, q [4 ] , dt, ksi)) +
G( b [: , i1] , G(b[: , i2] , G(b[: , i3], a[i , 0], dxs), dxs), dxs) *
(dt * I000(i1, i2, i3, q [ 1 ] , dt, ksi) + I001(i1, i2, i3, q [4 ] , dt, ksi)) — L(a, b, G(b[:, i1], G(b[:, i2], b[i, i3], dxs), dxs), dxs) *
I100(i1, i2, i3, q [ 6 ] , dt, ksi) for i3 in range (m)
for i2 in range (m)
for i1 in range(m)],
Electronic Journal. http://diffjournal.spbu.ru/ 381
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Differential Equations and Control Processes, N. 1, 2021
*[G(b[: , i1] , G(b[: , i2], G(b[:, i3] , G( b[: , i 4] , b[i, i 5] , dxs), dxs), dxs), dxs) *
I00000 (i 1 , i2 , i3 , i4 , i5 , q[7], dt , ksi)
for i5 in range (m)
for i4 in range (m)
for i3 in range(m)
for i2 in range (m)
for i1 in range(m)],
dt ** 3/6 * L(a, b, L(a, b, a[i, 0], dxs), dxs),
*[G(b[: , i1] , G(b[: , i2] , L(a, b, a [ i , 0], dxs), dxs), dxs) *
(I02(i1, i2, q [6] , dt, ksi) / 2 + dt * I01(i1, i2, q [2] , dt, ksi) +
dt ** 2 / 2 * I00(i1, i2, q [2] , dt, ksi)) +
L(a, b, L(a, b, G(b[:, i1], b[i, i2], dxs), dxs), dxs) / 2 *
I20(i1, i2, q[10], dt, ksi) +
G(b[: , i1] , L(a, b, G(b[: , i2] , a[i , 0], dxs), dxs), dxs) *
(I11(i1, i2, q [9] , dt, ksi) — I02(i1, i2, q [8] , dt, ksi) +
dt * ( I10 (i 1 , i2, q [ 2 ] , dt, ksi) — I01(i1, i2, q [ 2 ] , dt, ksi))) +
L(a, b, G(b[:, i1], L(a, b, b[i , i2], dxs), dxs), dxs) *
(I11(i1, i2, q [9] , dt, ksi) — I20(i1, i2, q[10], dt, ksi)) +
G(b[:, i1], L(a, b, L(a, b, b[i , i2], dxs), dxs), dxs) *
(I02(i1, i2, q [8 ] , dt, ksi) / 2 + I20(i1, i2, q[10], dt, ksi) / 2 — I11(i1, i2, q [9] , dt, ksi)) —
L(a, b, G(b[:, i1], G(b[:, i2], a[i, 0], dxs), dxs), dxs) *
(dt * I10(i1, i2, q [ 2 ] , dt, ksi) + I11(i1, i2, q [ 9 ] , dt, ksi)) for i2 in range (m)
for i1 in range(m)],
* [G( b [: , i 1 ] , G( b [: , i2], G(b[:, i3], G(b[:, i4 ] , a[i, 0], dxs), dxs),
(dt * I0000 (i1 , i2, i3, i4, q [3] , dt, ksi) +
I0001 (i1 , i2, i3, i4, q [ 1 1 ] , dt, ksi)) +
G(b[:, i1], G(b[:, i2], L(a, b, G(b[:, i3], b[i, i4], dxs), dxs), dxs)
( I0100 ( i 1 , i2 , i3 , i4 , q[13], dt , ksi) — I0010(i1, i2 , i3 , i4 , q[12],
L(a, b, G(b[:, i1], G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs)
11000 (i 1 , i2 , i3 , i4 , q[14], dt , ksi) +
G(b[:, i1], L(a, b, G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs)
(I1000(i1 , i2 , i3 , i4 , q[14], dt , ksi) — I0100(i1, i2 , i3 , i4 , q[13],
G(b[:, i1], G(b[:, i2], G(b[:, i3], L(a, b, b[i, i4], dxs), dxs), dxs)
( I0010 ( i 1 , i2 , i3 , i4 , q[12], dt , ksi) — I0001 (i1, i2 , i3 , i4 , q[11],
for i4 in range (m) for i3 in range (m) for i2 in range(m) for i1 in range(m)],
* [G( b [: , i 1 ] , G( b [: , i2], G(b[:, i3], G(b[:, i4 ] , G(
b[: , i 5] , b[i, i 6] , dxs), dxs), dxs), dxs), dxs) *
I000000 (i1 , i2 , i3 , i4 , i5 , i6 , q[15], dt , ksi)
for i6 in range (m) for i5 in range (m) for i4 in range(m) for i3 in range (m) for i2 in range (m) for i1 in range(m)]
dxs ) , dxs ) *
, dxs ) *
dt , ksi)) —
, dxs ) *
, dxs ) *
dt , ks i) ) +
, dxs ) *
dt , ksi))
Electronic Journal. http://diffjournal.spbu.ru/ 382
Differential Equations and Control Processes, N. 1, 2021
174
175
176
177
178
179
180 181 182 183
6.2.7 Source Codes for Strong Taylor—Stratonovich Numerical Schemes with Convergence Orders 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs
Listing 122: Strong Taylor—Stratonovich scheme with convergence order 1.0 modeling subprogram
1 2
3
4
5
6
7
8
9 10 11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28 29
)
Electronic Journal. http://diffjournal.spbu.ru/ 383
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Differential Equations and Control Processes, N. 1, 2021
t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Taylor—Stratonovich 1.0 start”)
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols ( f” x1 : { n + 1} ”)
ticks = int ((t2 — t1) / dt )
q = get _q(dt, k, 1)
logger. i nfo ( f” [ { (time () — start_time):.3f} seconds] Using C = {k} ”)
logger. i nfo ( f” [ { (time () logger. i nfo ( f” [ { (time () — start_time):.3f} — start_time):.3f} seconds] seconds] Using Using dt = { dt } ” ) q = {q} ”)
# Symbols
sym_i , sym_t = symbols( ’i t”)
sym_ksi = MatrixSymbol( ’ ksi” , q[0] + 2, m)
sym_y = StrongTaylorStratonovich1p0 (sym_i , Matrix ( args ) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y-compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 1.0 subs are finished”)
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[ tr , p + 1] = y-compiled [ tr ]( * values)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 1.0 calculations are finished”)
Electronic Journal. http://diffjournal.spbu.ru/ 384
85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Differential Equations and Control Processes, N. 1, 2021
return y, t
Listing 123: Strong Taylor—Stratonovich scheme with convergence order 1.0
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . aj import Aj
from mathematics . sde . nonlinear . symbolic . g import G
from mathematics . sde . nonlinear . symbolic . stratonovich . j0 import J0
from mathematics . sde . nonlinear . symbolic . stratonovich . j00 import J00
class StrongTaylorStratonovich1p0 (Function) :
Strong Taylor—Stratonovich scheme with convergence order 1.0 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorStratonovich1p0 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
aj = Aj(i, a, b, dxs)
return Add(
yp[i , 0] , aj [i , 0] * dt ,
* [b[i, i1] * J0(i1, dt , ksi) for i1 in range(m)],
Electronic Journal. http://diffjournal.spbu.ru/ 385
Differential Equations and Control Processes, N. 1, 2021
50
51
52
53
54
55
56
57
58
59
60 61 62
63
64
65
Listing 124: Strong Taylor—Stratonovich scheme with convergence order 1.5 modeling subprogram
1 2
3
4
5
6
7
8
9 10 11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
import logging
from time import time
import numpy as np
from sympy import Matrix , MatrixSymbol , symbols , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_stratonovich_1p5 import StrongTaylorStratonovich1p5
def strong_taylor_stratonovich_1p5(y0: np.array, a: Matrix, b: Matrix, k: float , times: tuple) :
Performs modeling of Strong Taylor—Stratonovich scheme with convergence order 1.5 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of solution t : list
list of time moments
* [G(b[: , i1 ] , b[i, i2 ] , dxs) * J00(i1, i2, q[0], dt, ksi) for i2 in range(m) for i1 in range(m) ]
)
def doit(self, ** hints):
Tries to expand or calculate function Returns
sympy. Expr
return StrongTaylorStratonovich1p0( * self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 386
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Differential Equations and Control Processes, N. 1, 2021
start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor—Stratonovich 1.5 start”)
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols ( f” x1 : { n + 1} ”)
ticks = int ((t2 — t1) / dt )
q = get_q(dt, k, 1.5)
logger. i nfo ( f” [ { (time () — start_time):.3f} seconds] Using C = {k} ”)
logger. i nfo ( f” [ { (time () logger. i nfo ( f” [ { (time () — start_time):.3f} — start_time):.3f} seconds] seconds] Using Using dt = { dt } ” ) q = {q} ”)
# Symbols
sym_i , sym_t = symbols( ’i t”)
sym_ksi = MatrixSymbol( ’ ksi” , q[0] + 2, m)
sym_y = StrongTaylorStratonovich1p5 (sym_i , Matrix ( args ) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger. inf o ( f” [ { (time () — start_time):.3f } seconds] Strong ” f”Taylor — Stratonovich 1.5 subs are finished”)
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[ tr , p + 1] = y .compiled [ tr ]( * values)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 1.5 calculations are finished”)
return y, t
Electronic Journal. http://diffjournal.spbu.ru/ 387
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Differential Equations and Control Processes, N. 1, 2021
Listing 125: Strong Taylor—Stratonovich scheme with convergence order 1.5
from sympy import Function , sympify , Add
from mathematics . sde . from mathematics . sde . from mathematics . sde . from mathematics . sde . from mathematics . sde . from mathematics . sde . from mathematics . sde . from mathematics . sde .
nonlinear . symbolic . aj import Aj
nonlinear . symbolic .g import G
nonlinear . symbolic . l import L
nonlinear . symbolic . lj import Lj
nonlinear . symbolic . stratonovich .j0 import J0
nonlinear . symbolic . stratonovich .j00 import J00
nonlinear . symbolic . stratonovich .j000 import J000
nonlinear . symbolic . stratonovich .j1 import J1
class StrongTaylorStratonovich1p5 (Function) :
Strong Taylor—Stratonovich scheme with convergence order 1.5 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorStratonovich1p5 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
aj = Aj(i, a, b, dxs)
return Add(
yp[i , 0] , aj [i , 0] * dt ,
* [b[i, i1] * J0(i1, dt , ksi) for i1 in range(m)],
Electronic Journal. http://diffjournal.spbu.ru/ 388
Differential Equations and Control Processes, N. 1, 2021
54
55 *[G(b[: , i1] , b[i , i 2] , dxs) *
56 J00(i1, i 2 , q [0] , dt, ksi)
57 for i2 in range(m)
58 for i1 in range(m) ] ,
59
60 * [G(b [: , i 1 ] , aj[i, 0], dxs) *
61 (dt * J0(i1, dt, ksi) + J1(i1, dt, ksi)) —
62 Lj(a, b[i, i1], dxs) *
63 J1 (i1 , dt , ksi)
64 for i1 in range (m)] ,
65
66 *[G(b[:, i1], G(b[:, i2], b[i, i3], dxs), dxs) *
67 J000(i1, i2, i3, q [ 1 ] , dt, ksi)
68 for i3 in range(m)
69 for i2 in range(m)
70 for i1 in range(m) ] ,
71
72 dt ** 2/2 * L(a, b, a[i, 0], dxs)
73
74 )
75
76 def doit(self, ** hints):
77 ” ” ”
78 Tries to expand or calculate function
79 Returns
80
81 sympy. Expr
82 ” ” ”
83 return StrongTaylorStratonovich1p5( * self.args, ** hints)
List sub ng 126: Strong Taylor—Stratonovich scheme with convergence order 2.0 modeling program
i import logging
2 from time import time
3
4 import numpy as np
5 from sympy import symbols , Matrix , MatrixSymbol , lambdify
6
7 from mathematics . sde . nonlinear .q import get_q
8 from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_stratonovich_2p0 import
StrongTaylorStratonovich2p0
9 10
11 def strong_taylor_stratonovich_2p0(y0: np.array, a: Matrix, b: Matrix, k: float , times:
tuple) :
12 ” ” ”
13 Performs modeling of Strong Taylor—Stratonovich scheme with convergence order 2.0
14 Parameters
15
16 y0 : numpy. ndarray
17 initial conditions
Electronic Journal. http://diffjournal.spbu.ru/ 389
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Differential Equations and Control Processes, N. 1, 2021
a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : float
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of solution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger. inf o ( f” [ { (time () - - start_time ) :.3 f} seconds] Strong Taylor—Stratonovich 2.0
start”)
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols(f”x1: { n + 1}” )
ticks = int ((t2 — t1) / dt )
q = get_q ( dt , k , 2)
logger. i nfo ( f” [ { (time () — start_time):.3f} seconds] Using C = {k} ”)
logger. i nfo ( f” [ { (time () logger. i nfo ( f” [ { (time () — start_time):.3f} — start_time):.3f} seconds] seconds] Using Using dt = { dt } ” ) q = {q} ”)
# Symbols
sym_i , sym_t = symbols( ’i t”)
sym_ksi = MatrixSymbol( ’ ksi” , q[0] + 2, m)
sym_y = StrongTaylorStratonovich2p0 (sym_i , Matrix ( args ) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 2.0 subs are finished”)
# Substitution values
Electronic Journal. http://diffjournal.spbu.ru/ 390
72
73
74
75
76
77
78
79
80
81
82
83
84
85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Differential Equations and Control Processes, N. 1, 2021
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y[:, 0] = y0 [:, 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 2, m) ] for tr in range(n):
y[tr, p + 1] = y .compiled [ tr ]( * values)
logger. inf o ( f” [ { (time () — start_time):.3f } seconds] Strong f”Taylor — Stratonovich 2.0 calculations are finished”)
return y, t
Listing 127: Strong Taylor—Stratonovich scheme with convergence order 2.0
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic . aj import Aj
from mathematics . sde . nonlinear . symbolic . g import G
from mathematics . sde . nonlinear . symbolic . lj import Lj
from mathematics . sde . nonlinear . symbolic . stratonovich . j0 import J0
from mathematics . sde . nonlinear . symbolic . stratonovich . j00 import J00
from mathematics . sde . nonlinear . symbolic . stratonovich . j000 import J000
from mathematics . sde . nonlinear . symbolic . stratonovich . j0000 import J0000
from mathematics . sde . nonlinear . symbolic . stratonovich . j01 import J01
from mathematics . sde . nonlinear . symbolic . stratonovich . j 1 import J1
from mathematics . sde . nonlinear . symbolic . stratonovich . j10 import J10
class StrongTaylorStratonovich2p0 (Function) :
Strong Taylor—Stratonovich scheme with convergence order 2.0 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorStratonovich2p0 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
Electronic Journal. http://diffjournal.spbu.ru/ 391
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Differential Equations and Control Processes, N. 1, 2021
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
aj = Aj(i, a, b, dxs)
return Add(
yp[ i , 0] , aj [ i , 0] * dt,
* [b[i, i1 ] * J0(i1, dt , ksi) for i1 in range (m)] ,
* [G(b [: i1 ] , b[ i , i2 ] dxs) *
J00(i1 i2 , q[0] , dt , ksi)
fo r i 2 i n range (m)
fo r i 1 i n range (m) ] ,
* [G(b[: , i1], aj [ i , 0], dxs) *
(dt * J0(i1, dt, ksi) + J1(i1, dt, ksi)) —
Lj(a, b[i, i1], dxs) *
J1(i1 , dt , ksi) for i1 in range (m)] ,
* [G(b[: , i1], G(b[: , i2 ] , b[i, i3 ] , dxs), dxs) *
J000(i1, i2, i3, q[1], dt, ksi)
for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
dt ** 2 / 2 * Lj(a, aj[i, 0], dxs),
* [G(b[: , i1 ] , Lj(a , b [ i i2 ] , dxs ) , dxs ) *
( J10(i1 , i2 , q[2] , dt , ksi) — J01 (i 1 , i2, q [2] , dt, ksi)) —
Lj (a, G(b[: , i1] , b[i, i2 ] , dxs) , dxs) * J10 (i 1 , i2 q [2] , dt , ksi) +
G(b [: , i 1 ] , G(b [: , i2 ] a j [ i , 0 ] , dxs ) , dxs ) *
( J01 (i 1 , i2 , q [ 2 ] , dt , ksi) + dt * J00(i1 , i2 , q[0] dt, ksi))
for i2 in range(m)
for i1 in range(m) ] ,
* [G(b[: , i1], G(b[: , i2 ] , G(b[: , i3 ] , b[i, i4 ] , dxs), dxs), dxs) *
J0000(i1, i2, i3, i4, q[3] , dt, ksi) for i4 in range (m) for i3 in range (m) for i2 in range (m) for i1 in range (m)]
)
Electronic Journal. http://diffjournal.spbu.ru/ 392
Differential Equations and Control Processes, N. 1, 2021
92
93
94
95
96
97
98
99 100
Listing 128: Strong Taylor—Stratonovich scheme with convergence order 2.5 modeling subprogram
1 2
3
4
5
6
7
8
9 10 11
12
13
14
15
16
17
18
19
20 21 22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_stratonovich_2p5 import
StrongTaylorStratonovich2p5
def strong_taylor_stratonovich_2p5(y0: np.array, a: Matrix, b: Matrix, k: float , times:
tuple) :
Performs modeling of Strong Taylor—Stratonovich scheme with convergence order 2.5 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
integration limits and step Returns
y : numpy. ndarray vector of s olution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor—Stratonovich 2.5 start”)
def doit(self, ** hints):
Tries to expand or calculate function Returns
sympy. Expr
return StrongTaylorStratonovich2p0( * self.args, ** hints)
Electronic Journal. http://diffjournal.spbu.ru/ 393
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
1
2
Differential Equations and Control Processes, N. 1, 2021
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols ( f” x1 : { n + 1} ”)
ticks = int ((t2 — t1) / dt )
q = get_q(dt, k, 2.5)
logger. i nfo ( f” [ { (time () — start_time):.3f} seconds] Using C = {k} ”)
logger. i nfo ( f” [ { (time () logger. i nfo ( f” [ { (time () — start_time):.3f} — start_time):.3f} seconds] seconds] Using Using dt = { dt } ” ) q = {q} ”)
# Symbols
sym_i , sym_t = symbols( ’i t”)
sym_ksi = MatrixSymbol( ”ksi” , q [0] + 3, m)
sym_y = StrongTaylorStratonovich2p5 (sym_i , Matrix ( args ) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y .compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 2.5 subs are finished”)
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 3, m) ] for tr in range(n):
y[ tr , p + 1] = y_compiled[tr]( * values)
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 2.5 calculations are finished”)
return y, t
Listing 129: Strong Taylor—Stratonovich scheme with convergence order 2.5
from sympy import Function , sympify , Add
Electronic Journal. http://diffjournal.spbu.ru/ 394
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Differential Equations and Control Processes, N. 1, 2021
from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic
. aj import Aj . g import G . l import L . lj import Lj
. stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich . . stratonovich .
j 0 import J0 j00 import J00 j000 import J000 j0000 import J0000 j00000 import J00000 j001 import J001 j01 import J01 j010 import J010 j1 import J1 j10 import J10 j100 import J100 j2 import J2
class StrongTaylorStratonovich2p5 (Function) :
Strong Taylor—Stratonovich scheme with convergence order 2.5 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorStratonovich2p5 object with given args Parameters
i : in t
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
aj = Aj(i, a, b, dxs)
return Add(
Electronic Journal. http://diffjournal.spbu.ru/ 395
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Differential Equations and Control Processes, N. 1, 2021
yp[i , 0] , aj [i , 0] * dt ,
* [b[i, i1 ] * J0(i1, dt , ksi) for i1 in range (m)] ,
* [G(b [: i1 ] , b[ i , i2 ] dxs) *
J00(i1 i2 , q[0] , dt , ksi)
fo r i 2 i n range (m)
fo r i 1 i n range (m) ] ,
* [G(b[: , i1], aj[i, 0], dxs) *
(dt * J0(i1, dt, ksi) + J1(i1, dt, ksi)) —
Lj(a, b[i, i1], dxs) *
J1(i1 , dt , ksi) for i1 in range (m)] ,
* [G(b[: , i1], G(b[: , i2 ] , b[i, i3 ] , dxs), dxs) *
J000(i1, i2, i3, q[1], dt, ksi)
for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
dt ** 2 / 2 * Lj(a, aj[i, 0], dxs),
* [G(b[: , i1 ] , Lj(a , b [ i i2 ] , dxs ) , dxs ) *
( J10(i1 , i2 , q[2] , dt , ksi) — J01 (i 1 , i2, q [2] , dt, ksi)) —
Lj (a, G(b[: , i1] , b[i, i2 ] , dxs) , dxs) * J10 (i 1 , i2 q [2] , dt , ksi) +
G(b [: , i 1 ] , G(b [: , i2 ] a j [ i , 0 ] , dxs ) , dxs ) *
( J01 (i 1 , i2 , q [ 2 ] , dt , ksi) + dt * J00(i1 , i2 , q[0] dt, ksi))
for i2 in range(m)
for i1 in range(m) ] ,
* [G(b[: , i1], G(b[: , i2 ] , G(b[: , i3 ] , b[i, i4 ] , dxs), dxs), dxs) *
J0000(i1, i2, i3, i4, q[3] , dt, ksi) for i4 in range (m) for i3 in range (m) for i2 in range (m) for i1 in range (m)] ,
* [G(b[: , i1] , Lj (a , aj [ i , 0 ] , dxs) , dxs) *
( J2 ( i1 , dt , ksi ) / 2 + dt * J1 ( i 1 , dt , ksi) + dt ** 2 / 2 * J0 ( i 1 , dt , ksi) ) +
Lj (a , Lj (a , b [ i , i1 ] , dxs ) , dxs ) * J2 ( i 1 , dt , ksi) / 2 —
Lj (a , G(b [: , i1] , aj [ i , 0 ] , dxs ) , dxs) * (J2(i1, dt , ksi) + dt * J1 ( i 1 , dt , ksi) )
fo r i 1 i n r an ge (m )],
* [G(b[: , i1] , Lj (a , G(b[: , i2 ] , b [ i , i3], dxs), dxs), dxs) *
( J100(i1 , i2 , i3 , q[6] , dt , ksi) — J010 (i1 , i2 , i3 , q[5] , dt, ksi)) +
G(b [: , i 1 ] , G(b [: , i2] , Lj(a , b[i , i3], dxs), dxs), dxs) *
( J010(i1 , i2 , i3 , q[5] , dt , ksi) — J001 (i1 , i2 , i3 , q[4] , dt, ksi)) +
G(b [: , i 1 ] , G(b [: , i2 ] , G(b [: , i3 ] , aj [ i , 0 ] , dxs ) , dxs ) , dxs) *
(dt * J000 (i 1 , i2 , i3, q [ 1 ] , dt, ksi) + J001 (i 1 , i2, i3, q [4] , dt, ksi)) —
Lj (a , G(b [: , i1] , G(b [: , i2 ] , b [ i , i3], dxs), dxs), dxs) *
J100 (i 1 , i2 , i3 , q [6] , dt , ksi)
fo r i 3 i n range (m) fo r i 2 i n range (m)
Electronic Journal. http://diffjournal.spbu.ru/ 396
Differential Equations and Control Processes, N. 1, 2021
113 for i1 in range (m)] ,
114
115 *[G(b[:, i1], G(b[:, i2], G(b[:, i3], G(
116 b [: , i4], b[i, i5 ] , dxs), dxs), dxs), dxs) *
117 J00000 ( i1 , i2 , i3 , i4 , i5 , q[7], dt , ksi)
118 for i5 in range(m)
119 for i4 in range(m)
120 for i3 in range(m)
121 for i2 in range(m)
122 for i1 in range(m) ] ,
123
124 dt ** 3 / 6 * L(a, b, L(a, b, a[i, 0], dxs), dxs)
125
126 )
127
128 def doit(self, ** hints):
129 ” ” ”
130 Tries to expand or calculate function
131 Returns
132
133 sympy. Expr
134 ” ” ”
135 return StrongTaylorStratonovich2p5( * self.args, ** hints)
Listing 130: Strong Taylor—Stratonovich scheme with convergence order 3.0 modeling subprogram
1
2
3
4
5
6
7
8
9 10 11
12
13
14
15
16
17
18
19
20 21 22
23
24
import logging
from time import time
import numpy as np
from sympy import Matrix , symbols , MatrixSymbol , lambdify from mathematics . sde . nonlinear .q import get_q
from mathematics . sde . nonlinear . symbolic . schemes . strong_taylor_stratonovich_3p0 import StrongTaylorStratonovich3p0
def strong_taylor_stratonovich_3p0(y0: np.array, a: Matrix, b: Matrix, k: float , times:
tuple) :
Performs modeling of Strong Taylor—Stratonovich scheme with convergence order 3.0 Parameters
y0 : numpy. ndarray initial conditions a : numpy. ndarray vector function a b : numpy. ndarray matrix function b k : fl o a t
precision constant times : tuple
Electronic Journal. http://diffjournal.spbu.ru/ 397
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Differential Equations and Control Processes, N. 1, 2021
integration limits and step Returns
y : numpy. ndarray vector of solution t : list
list of time moments start_time = time ()
logger = logging. getLogger(__name__)
logger . info ( f” [ { (time() — start_time ) :.3 f } seconds] Strong Taylor—Stratonovich 3.0 start”)
# Ranges n = b.shape[0] m = b.shape[1] t1 = times [0 ] dt = times [ 1 ] t2 = times [ 2 ]
# Defining context
args = symbols ( f” x1 : { n + 1} ”)
ticks = int ((t2 — t1) / dt )
q = get_q ( dt , k , 3)
logger. i nfo ( f” [ { (time () — start_time):.3f} seconds] Using C = {k} ”)
logger. i nfo ( f” [ { (time () logger. i nfo ( f” [ { (time () — start_time):.3f} — start_time):.3f} seconds] seconds] Using Using dt = { dt } ” ) q = {q} ”)
# Symbols
sym_i , sym_t = symbols( ’i t”)
sym_ksi = MatrixSymbol( ”ksi” , q [0] + 3, m)
sym_y = StrongTaylorStratonovich3p0 (sym_i , Matrix ( args ) , a, b, dt , sym_ksi , args , q)
args_extended = list () args_extended .extend(args) args_extended .extend ([ sym_t , sym_ksi])
# Compilation of formulas y_compiled = list ()
for tr in range(n):
y-compiled. append(lambdify(args_extended, sym_y.subs(sym_i, tr), ” numpy” ) )
logger. inf o ( f” [ { (time () — start _time):.3f } seconds] Strong ” f”Taylor — Stratonovich 3.0 subs are finished”)
# Substitution values
t = [ 11 + i * dt for i in range(ticks)] y = np.zeros((n, ticks)) y [: , 0] = y0 [: , 0]
# Dynamic substitutions with integration for p in range (ticks — 1) :
values = [ * y [: , p], t[p], np. random .randn(q[0] + 3, m) ]
Electronic Journal. http://diffjournal.spbu.ru/ 398
79
80
81
82
83
84
85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Differential Equations and Control Processes, N. 1, 2021
for tr in range(n):
y[tr, p + 1] = y .compiled [ tr ]( * values)
logger. inf o ( f” [ { (time () — start_time):.3f } seconds] Strong f”Taylor — Stratonovich 3.0 calculations are finished”)
return y, t
Listing 131: Strong Taylor—Stratonovich scheme with convergence order 3.0
from sympy import Function , sympify , Add
from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic from mathematics . sde . nonlinear . symbolic
. aj import Aj . g import G . lj import Lj
. stratonovich .j0 import J0 . stratonovich .j00 import J00 . stratonovich .j000 import J000 . stratonovich . j0000 import J0000 . stratonovich . j00000 import J00000 . stratonovich . j000000 import J000000 . stratonovich .j0001 import J0001 . stratonovich .j001 import J001 stratonovich .j0010 import J0010 stratonovich . j01 import J01 stratonovich . j010 import J010 stratonovich .j0100 import J0100 stratonovich . j02 import J02 stratonovich .j1 import J1 stratonovich . j10 import J10 stratonovich .j100 import J100 stratonovich .j1000 import J1000 stratonovich . j11 import J11 stratonovich .j2 import J2 stratonovich . j20 import J20
class StrongTaylorStratonovich3p0 (Function) :
Strong Taylor—Stratonovich scheme with convergence order 3.0 nargs = 8
def __new__(cls, * args, ** kwargs ) :
Creates new StrongTaylorStratonovich3p0 object with given args Parameters
i : int
component of stochastic process yp : numpy. ndarray initial conditions a : numpy. ndarray
Electronic Journal. http://diffjournal.spbu.ru/ 399
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Differential Equations and Control Processes, N. 1, 2021
algebraic , given in the variables x and t b : numpy. ndarray
algebraic , given in the variables x and t dt : float
integration step ksi : numpy. ndarray
matrix of Gaussian random variables q : tuple
amounts of q for stochastic integrals approximations Returns
sympy. Expr
formula to simplify and substitute
i, yp, a, b, dt, ksi, dxs, q = sympify(args) n, m = b.shape[0], b.shape[1]
aj = Aj(i, a, b, dxs)
return Add(
yp[i , 0] , aj [i , 0] * dt ,
* [b[i, i1] * J0(i1, dt , ksi) for i1 in range(m)],
*[G(b[:, i1], b[i, i2], dxs) *
J00(i1, i2, q [0] , dt, ksi) for i2 in range (m)
for i1 in range(m)],
* [G(b [: , i 1 ] , aj[i, 0], dxs) *
(dt * J0(i1, dt, ksi) + J1(i1, dt, ksi)) —
Lj(a, b[i, i1], dxs) *
J1 (i1 , dt , ksi) for i1 in range(m)],
*[G(b[: , i1] , G(b[: , i2] , b[i, i3], dxs), dxs) *
J000(i1, i2, i3, q [ 1 ] , dt, ksi) for i3 in range (m)
for i2 in range (m)
for i1 in range(m)],
dt ** 2 / 2 * Lj(a, aj[i, 0], dxs),
* [G(b [: , i 1 ] , Lj (a , b[i, i2], dxs), dxs) *
(J10(i1, i2, q [ 2 ] , dt, ksi) — J01(i1, i2, q [ 2 ] , dt, ksi)) —
Lj (a , G(b [: , i 1 ] , b[i, i2], dxs), dxs) * J10(i1, i2, q [ 2 ] , dt,
G( b [: , i 1 ] , G(b [: , i2 ] , aj [ i , 0], dxs), dxs) *
(J01(i1, i2, q [2] , dt, ksi) + dt * J00(i1, i2, q [0] , dt, ksi))
for i2 in range (m)
for i1 in range(m)],
*[G(b[:, i1], G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs)
J0000 (i1 , i2, i3, i4, q [3] , dt, ksi)
ksi) +
*
Electronic Journal. http://diffjournal.spbu.ru/ 400
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Differential Equations and Control Processes, N. 1, 2021
fo r i4 in range (m)
fo r i3 in range (m)
fo r i2 in range (m)
fo r i1 in range (m)] ,
* [G(b [: , i1 ] , Lj(a , aj [ i , 0] dxs ) , dxs ) *
( J 2 (i 1 , dt, ksi) / 2 + dt * J1(i1, dt, ksi) + dt ** 2 / 2 * J0 ( i 1 , dt , ksi) ) +
Lj (a , Lj (a , b [ i , i 1 ] , dxs ) , dxs) * J2(i1 , dt, ksi) / 2 —
Lj (a , G(b [: , i1 ] , aj [ i , 0] , dxs), dxs) * (J 2(i1 , dt, ksi) + dt * J1 ( i 1 , dt , ksi) )
for i1 in range (m)] ,
* [G(b[: , i1] , Lj (a , G(b [ : , i 2 ] , b[i, i3], dxs), dxs), dxs) *
( J100(i1 , i2 , i3 , q[6] , dt, ksi) — J010(i1, i2, i3, q [5] , dt, ksi)) +
G(b [: , i 1 ] , G(b [: , i2] , Lj (a , b[i, i3], dxs), dxs), dxs) *
( J010(i1 , i2 , i3 , q[5] , dt, ksi) — J001(i1, i2, i3, q [4] , dt, ksi)) +
G(b [: , i 1 ] , G(b [: , i2] , G(b [: , i3], aj[i, 0], dxs), dxs), dxs) *
(dt * J000 (i 1 , i2 , i3 , q[1] , dt, ksi) + J001(i1, i2, i3, q [4] , dt, ksi)) —
Lj (a , G(b [: , i1] , G(b [: , i2] , b[i, i3], dxs), dxs), dxs) *
J100 (i 1 , i2 , i3 , q[6] , dt , ksi)
fo r i 3 i n r an ge (m )
fo r i 2 i n r an ge (m )
fo r i 1 i n r an ge (m )] ,
*[G(b[:, i1], G(b[ : , i 2 ] , G(b [ : , i3 ] , G(
b [: , i 4 ] , b[i, i5], dxs), dxs), dxs), dxs) *
J00000 (i1 , i2 , i3 , i4 , i5 , q[7], dt, ksi)
for i5 in range(m)
for i4 in range(m)
for i3 in range(m)
for i2 in range(m)
for i1 in range(m) ] ,
dt ** 3 / 6 * Lj(a, Lj(a, aj[i, 0], dxs), dxs),
*[G(b[: , i1] , G(b [: , i2 ] , Lj (a , aj [ i , 0 ] , dxs ) , dxs ) , dxs ) *
( J02(i1 , i2 , q [ 6 ] , dt , ksi) / 2 + dt * J 01 ( i 1 , i2, q [2] , dt, ksi) +
dt ** 2/2 * J00(i1 , i2 , q [2] , dt , ksi) ) +
Lj (a , Lj (a , G(b [: , i 1 ] , b[i, i2], dxs), dxs), dxs) / 2 *
J20 (i 1 , i2 , q [ 1 0] , dt , ksi) +
G(b [: , i 1 ] , Lj (a , G(b [: , i2] , aj [ i , 0] , dxs) , dxs) , dxs) *
( J11(i1 , i2 , q[9] , dt , ksi) — J02(i1, i2, q [8] , dt, ksi) +
dt * ( J10 (i 1 , i2 , q [ 2] , dt, ksi) — J01 (i 1 , i2, q [2] , dt, ksi))) +
Lj (a , G(b [: , i 1 ] , Lj (a , b[i, i2], dxs), dxs), dxs) *
( J11(i1 , i2 , q[9] , dt , ksi) — J20(i1, i2 , q[10], dt , ksi)) +
G(b [: , i 1 ] , Lj (a , Lj (a , b[i, i2], dxs), dxs), dxs) *
( J02(i1 , i2 , q [ 8 ] , dt , ksi) /2 + J20(i1, i2, q [ 10] , dt, ksi) /2 —
J11 (i 1 , i2, q [ 9 ] , dt, ksi)) —
Lj (a , G(b [: , i1 ] , G(b [: , i2], aj[i, 0], dxs), dxs), dxs) *
( dt * J10 (i 1 , i2 , q[2] , dt, ksi) + J11 (i 1 , i2, q [ 9 ] , dt, ksi))
for i2 in range(m)
for i1 in range(m) ] ,
*[G(b[ , i1 ] , G(b[: , i2] , G(b [: , i3 ] , G(
b [: , >4 ] , aj [ i , 0] , dxs), dxs), dxs), dxs) *
( dt * J0000(i1 , i2 , i3 , i4 , q [3] , dt , ksi) +
Electronic Journal. http://diffjournal.spbu.ru/ 401
Differential Equations and Control Processes, N. 1, 2021
154 J0001(i1 , i2 , i3 , i4 , q[11] , dt, ks i)) +
155 G(b[:, i1], G(b[:, i2], Lj(a, G(b[:, i3], b[i, i4], dxs), dxs), dxs), dxs) *
156 (J0100(i1, i2, i3, i4, q[13], dt, ksi) — J0010 (i1 , i2, i3, i4, q[12], dt, ks i) ) —
157 Lj (a, G(b[: , i1] , G(b[: , i2] , G(b[: , i3], b[i, i4], dxs), dxs), dxs), dxs) *
158 J1000 (i1 , i2, i3, i4, q[14], dt, ksi) +
159 G(b[:, i1], Lj(a, G(b[:, i2], G(b[:, i3], b[i, i4], dxs), dxs), dxs), dxs) *
160 (J1000(i1, i2, i3, i4, q[14], dt, ksi) — J0100 (i1 , i2, i3, i4, q[13], dt, ksi)) +
161 G(b[:, i1], G(b[:, i2], G(b[:, i3], Lj(a, b[i, i4], dxs), dxs), dxs), dxs) *
162 (J0010(i1, i2, i3, i4, q[12], dt, ksi) — J0001 (i1 , i2, i3, i4, q [ 1 1 ] , dt, ksi))
163 for i4 in range (m)
164 for i3 in range (m)
165 for i2 in range (m)
166 for i1 in range (m)] ,
167
168 * [G( b [: , i 1 ] , G( b [: , i2], G(b[:, i3], G(b[:, i4 ] , G(
169 b [: , i 5 ] , b[i, i6 ] , dxs), dxs), dxs), dxs), dxs) *
170 J000000 (i1 , i2 , i3 , i4 , i5 , i6 , q[15], dt , ksi)
171 for i6 in range(m)
172 for i5 in range(m)
173 for i4 in range(m)
174 for i3 in range(m)
175 for i2 in range(m)
176 for i1 in range(m) ]
177
178 )
179
180 def doit(self, ** hints):
181 ” ” ”
182 Tries to expand or calculate function
183 Returns
184
185 sympy. Expr
186 ” ” ”
187 return StrongTaylorStratonovich3p0( * self.args, ** hints)
6.3 Source Codes for Linear Stationary Systems of Ito SDEs
Listing 132: Implementation of supplementary functions
1
2
3
4
5
6
7
8 9
10
11
12
import numpy as np
class NotASquareMatrix(Exception) : pass
def vec_to_eye( vector) :
Converts vector to eye matrix Parameters
Electronic Journal. http://diffjournal.spbu.ru/ 402
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Differential Equations and Control Processes, N. 1, 2021
vector : iterable
Returns
numpy. ndarray
n = len ( vector )
matrix = np. zeros ((n, n))
for i in range (len (matrix)) : matrix [ i ][ i ] = vector [ i ]
return matrix
def diagonal _to_column (matrix):
Converts diagonal matrix to column vector Parameters
matrix : numpy. ndarray Returns
column : numpy. ndarray
height = np. shape(matrix) [0] if height != np. shape(matrix) [1]: raise NotASquareMatrix ()
column = np.zeros((height, 1)) fo r i i n r an ge ( h e i g h t ) :
column [ i ][0] = matrix [ i ] [ i ]
return column
Listing 133: Implementation of Algorithm 11.2 [61]
import numpy as np import scipy.linalg as sci
def dindet(n: int , k: int , m_a: np. ndarray , m_b: np. ndarray , dt : float) :
Algorithm 11.2 [61]
Parameters
n : int
k : int
m_a : numpy. array m-b : numpy. array dt : float Returns
m_ad : numpy. array
Electronic Journal. http://diffjournal.spbu.ru/ 403
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Differential Equations and Control Processes, N. 1, 2021
m-bd : numpy. array
"""
m_okn = - np.zeros((k, n))
m_okk = = np.zeros((k, k))
m_idt = = np.eye(n + k) * dt
maa = np.vstack((np. hstack ((m_a, ^_b)) ,
np . hstack (( m_okn , m_okk) )))
m_ex_aah = sci . expm ( m_aa .dot(m_idt))
m_ad = m_ex_aah [: n, : n]
m_bd = m_ex_aah [: n, n : ( n + k)]
return ^_ad , m_bd
Listing 134: Implementation of Algorithm 11.6 [61]
import numpy as np
from mathematics . sde . linear . dindet import dindet from mathematics . sde . linear . matrix import vec_to_eye
def stoch (n : int , m_a : np . ndarray , m_f : np . ndarray , dt : float) :
Root function for set of algorithms implemented below Parameters
n : int
m_a : numpy. ndarray m-f : numpy. ndarray d t : f l o a t Returns
numpy. ndarray
v_l2 , m_s , m_d1 = algorithm_11_2(n, m_a, m_f, dt) mat_l = vec_to_eye (np. sqrt ( v_l2 ) ) return m_s.dot(mat_l)
def algorithm_11_2(n: int , m_a: np. ndarray , m_f: np. ndarray , dt : float) :
Parameters
n : int
m_a : numpy. ndarray m-f : numpy. ndarray d t : f l o a t Returns
eigenvalues : numpy. ndarray eigenvectors : numpy. ndarray m-d1 : numpy. ndarray
m_ac = algorithm_11_5(n, m_a)
Electronic Journal. http://diffjournal.spbu.ru/ 404
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Differential Equations and Control Processes, N. 1, 2021
m_g = m_f. dot(np. transpose (m_f) ) m_gv = algorithm_11_3 (n, m_g)
m_dd, m_dv = dindet( int (n * (n + 1) / 2), 1, m_ac , m_gv, dt) m_d1 = algorithm_11_4(n, m_dv)
eigenvalues, eigenvectors = np.linalg.eig( m_d1) return eigenvalues , eigenvectors , m_d1
def algorithm_11_3(n: int , m_g: np.ndarray):
Algorithm 11.3 [61]
Parameters
n : int
m_g : numpy. ndarray Returns
m^vec : numpy. ndarray column vector
i2 =0 v _size = 0 for i in range(n): n2 = n — i fo r j i n range ( n 2 ) : if v_size < j + i2 : v_size = j + i2 i2 = i2 + n — i
m_vec = np.ndarray((v_size + 1, 1))
i2 = 0
fo r i i n r an ge ( n ) :
n2 = n — i
fo r j i n range ( n 2 ) :
m_vec [ j + i2 ] [0] = mg [ j ][ j + i ] i2 = i2 + n — i
return m_vec
def algorithm_11_4(n: int , m_dv: np. ndarray):
Algorithm 11.4 [61]
Parameters
n : int
m-dv : numpy. ndarray Returns
m_d1 : numpy. ndarray
i2 = 0 size = 0
fo r i i n r an ge ( n ) :
Electronic Journal. http://diffjournal.spbu.ru/ 405
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Differential Equations and Control Processes, N. 1, 2021
n2 = n— i
fo r j in range(n2):
if size < j + i:
size = j + i
i2 = i 2 + n — i
m_d1 = np.ndarray((size + 1, size + 1)) i2 =0
for i in range(n):
n2 = n — i
for j in range(n2):
m_d1[j ][j + i] = m_dv[j + i2][0] m_d1[j + i ][ j ] = m_dv[j + i2 ] [0 ] i2 = i2 + n — i
return m_d1
def algorithm_11_5(n: int , m_a: np.ndarray):
Algorithm 11.5 [61]
Parameters
n : int
m_a : numpy. ndarray Returns
m_ac : numpy. ndarray r=0
v _size = 0 h _size = 0
fo r i i n range ( n )
n2 = n —i
for j i n range ( n2) :
o= 0
fo r k in range(n):
n3 =n—k
fo r m in range(n3):
if v _size < m + o :
v _size = m + o
if h _size < r :
h _size = r
o = o + n — k
r= r + 1
mones = np. zeros ((n, n))
m_ac = np.ndarray((v_size + 1, h _size + 1)) r = 0
for i in range(n): n2 = n — i for j in range(n2):
Electronic Journal. http://diffjournal.spbu.ru/ 406
150
151
152
153
154
155
156
157
158
159
160
161
162
163
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Differential Equations and Control Processes, N. 1, 2021
i2 = j + i m_ones [ j ] [ i2 ] = 1 m_ones [ i2 ] [ j ] = 1
m_one_a = m_ones.dot(np.transpose( m_a) ) + m_a . dot(m_ones)
o = 0
for k in range(n):
n3 = n — k
for m in range(n3):
m_ac [m + o ] [ r ] = m_one_a [m] [m + k] o = o + n — k m_ones = np.zeros((n, n)) r = r + 1
return m_ac
Listing 135: Implementation of the vector function u(t)
Electronic Journal. http://diffiournal.spbu.ru/ 407
37
38
39
40
41
42
43
44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Differential Equations and Control Processes, N. 1, 2021
Returns
numpy. ndarray column u(t)
for i in range(self._mat_u.shape[0]) :
self._mat_ut[i][0] = self._mat_u[i][0].t(t) return self . _mat_ut
Listing 136: Modeling of linear system of Ito SDEs
Electronic Journal. http://diffjournal.spbu.ru/ 408
Differential Equations and Control Processes, N. 1, 2021
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
self . v_yt .append( self . m_h. dot(xt) [0][0])
# expectation of solution of sde
mx = self. m_ad . dot( self . m_mx0) + self. m_bd . dot(mat_ut)
# expectation of exit process
self. m_mx [: , self . t ] = mx [: , 0]
self. v_my . append( self . m_h . dot (mx) [ 0 ] [ 0 ] )
# dispersion of solution of sde
dx = self. m_ad.dot(self. m_dx0) .dot(np.transpose(self. m_ad)) + self. m_fd.dot(np. transpose ( self . m_fd) )
# dispersion of exit process
self .m_dx [: , self .t] = diagonal_to_column (dx) [: , 0]
self.v_dy.append(self. m_h.dot(dx) .dot(transpose(self. m_h)) [0] [0])
self.v_t.append(t)
self. m_x0 , self. m_mx0 , self. m_dx0 = xt , mx, dx
6.4 Source Codes for Utilities and Initialization
Listing 137: Initialization module
1
2
3
4
5
6
7
8 9
10
11
12
from config import database
from init .database import initdb
from tools . database import connect , disconnect
def initialization ():
Initializes various components of application
connect(database) initdb () disconnect ()
Listing 138: Module for database initialization
1 2
3
4
5 import sympy as sp
6
7
8 9
10 11
12 logger = logging. getLogger(_______name___)
import config as c
from tools import fsys
from tools . database import execute
from tools . fsys import get_files
import csv import logging import os
Electronic Journal. http://diffjournal.spbu.ru/ 409
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Differential Equations and Control Processes, N. 1, 2021
def initdb () :
Initializes database with necessary table drivers
if not fsys. is_locked (” . db.lock”) :
logger . info (” Initializing database . ..”) create_files_table () create_c_table() fsys. lock(” .db.lock”) else :
logger . info (” Updating database . . . ”) update_coefficients ()
def create_files_table():
Initializes the Fourier —Legendre coefficients table
execute(”DROP TABLE IF EXISTS ‘files ‘”) execute(
”CREATE TABLE ‘files ‘ (”
” ‘id ‘ integer PRIMARY KEY AUTOINCREMENT,”
” ‘ name ‘ text unique”
”)”
)
def create_c_table():
Initializes the Fourier —Legendre coefficients table
execute(”DROP TABLE IF EXISTS ‘C‘”) execute(
”CREATE TABLE ‘C‘ (”
” ‘id ‘ integer PRIMARY KEY AUTOINCREMENT,”
” ‘index‘ text unique,”
” ‘value ‘ text , ”
” ‘ value_f ‘ double”
”)”
)
update_coefficients ()
def update .coefficients () :
Updates the Fourier —Legendre coefficients table files = get_files(c.csv, r’c_.*\ . csv ’ )
loaded-files = [record [0] for record in execute( ”SELECT ‘ name ‘ FROM ‘files ‘”) ] difference = [f for f in fil es if f not in loaded-files ]
Electronic Journal. http://diffjournal.spbu.ru/ 410
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Differential Equations and Control Processes, N. 1, 2021
Listing 139: Database module
import logging import re import sqlite3
logger = logging. getLogger(__name___)
connection : sqlite3 . Connection
cursor: sqlite3 .Cursor
def is_connected():
Checks if application is connected to database Returns
True or False
global connection if connection is None: return False else :
return True
def connect(db: str):
Connects application to database Parameters
db : str
path to database file try :
Electronic Journal. http://diffjournal.spbu.ru/ 411
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Differential Equations and Control Processes, N. 1, 2021
global connection global cursor
connection = sqlite3. connect (db)
connection . create_function (”REGEXP” , , 2 , regex)
cursor = connection.cursor()
logger. info(f”SQLite Database is successfully connected”)
query = ”select sqlite_version();” cursor.execute(query) record = cursor.fetchall()
logger. info(f”SQLite Database Version is: {record [0][0] } ”)
query = ”PRAGMA foreign_keys = ON;” cursor . execute (query)
except sqlite3.Error as error:
logger. error (f”Error while connecting to sqlite: { error} ”)
def disconnect () :
Disconnects application from database try :
global connection global cursor
connection . close ()
logger. info (”The SQLite connection is closed”)
except sqlite3.Error as error:
logger. error (f”Error while connecting to sqlite: { error} ”)
def execute(query: str):
Sends query to database and receives data Parameters
query : str
query to database Returns
list of tuples (rows) try :
global connection global cursor
cursor.execute(query) records = cursor.fetchall() connection . commit () return records
Electronic Journal. http://diffjournal.spbu.ru/ 412
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Differential Equations and Control Processes, N. 1, 2021
Listing 140: File system utilities
Electronic Journal. http://diffjournal.spbu.ru/ 413
Differential Equations and Control Processes, N. 1, 2021
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
return True else :
return False
def lock ( filename ) :
Performs locking Parameters
filename : str
name of lock file
f = open (os.path.join (c. resources , filename) , ”w”)
f.close ()
def unlock ( filename ) :
Performs unlocking Parameters
filename : str
name of lock file
os . remove (os . path . join (c . resources , filename) )
7 Future Work
Considering the future work, it is important to say that symbolic algebra gives a wide field for optimizations of modeling process. Symbolic operations is actually operations with strings. Such operations has relatively high complexity and slows down modeling process significantly. One of possible ways to improve modeling performance is to parallelize computations. Since strong numerical schemes for Ito SDEs have massive amount of terms this idea appears justified.
The strong numerical schemes for Ito SDEs seem to be easily optimizable, on the other hand, superpositions of the differential operators (4), (5), and (23) are not. They are called recursively during calculation process which is more difficult to parallelize than strong numerical schemes for Ito SDEs. Differential operators obviously include differentiating which is high cost and optimization of them is a dedicated issue.
In the future, it is possible to improve the SDE-MATH software package in a number of other directions. In particular, high-order strong numerical methods of the Runge-Kutta type [2], [7], [42], [61] (including multistep numerical
Electronic Journal. http://diffjournal.spbu.ru/ 414
Differential Equations and Control Processes, N. 1, 2021
methods [2], [7], [42], [61]) for Ito SDEs can be implemented. In addition, software for solving the filtering problem and the problem of stochastic optimal control can also be developed. These improvements will lead to changes of the graphical user interface due to new features.
Bibliography
[1] Ito, K. On Stochastic Differential Equations. Memoirs of the American Mathematical Society, 4 (1951), 1-51.
[2] Kloeden, P.E., Platen, E. Numerical Solution of Stochastic Differential Equations. Springer, Berlin, 1992, 632 pp.
[3] Kloeden, P.E., Platen, E., Schurz, H. Numerical Solution of SDE Through Computer Experiments. Springer, Berlin, 1994, 292 pp.
[4] Arato, M. Linear Stochastic Systems with Constant Coefficients. A Statistical Approach. Springer-Verlag, Berlin, Heidelberg, N.Y., 1982, 289
pp.
[5] Shiryaev, A.N. Essentials of Stochastic Finance: Facts, Models, Theory. World Scientific Publishing Co United States, 1999, 852 pp.
[6] Karatzas, I., Shreve, S. Methods of Mathematical Finance. Springer-Verlag, New York, 1998, 415 pp.
[7] Platen, E., Bruti-Liberati, N. Numerical Solution of Stochastic Differential Equations with Jumps in Finance. Springer, Berlin, Heidelberg, 2010,
868 pp.
[8] Han, X., Kloeden, P.E., Random Ordinary Differential Equations and Their Numerical Solution. Springer, Singapore, 2017, 250 pp.
[9] Allen, E. Modeling with Ito Stochastic Differential Equations. Springer, Dordrecht, 2007, 230 pp.
[10] Merton, R.C. Continuous-Time Finance. Blackwell, Oxford, 1992, 754 pp.
[11] Heston, S.L. A closed-form solution for options with stochastic volatility with applications to bond and currency options, Rev. Financial Studies, 6, 2 (1993), 327-343.
Electronic Journal. http://diffjournal.spbu.ru/ 415
Differential Equations and Control Processes, N. 1, 2021
[12] Cox, J.C., Ingersoll, J.E., Ross, S.A. A Theory of the term structure of interest rates, Econometrica, 53 (1985), 385-408.
[13] Kimura, M., Ohta, T. Theoretical aspects of Population genetics. Princeton Univ. Press, Boston, 1971, 232 pp.
[14] Iacus, S.M. Simulation and Inference for Stochastic Differential Equations. With R Examples. Springer-Verlag, New York, 2008, 285 pp.
[15] Ricciardi, L.M. Diffusion Processes and Related Topics in Biology, Lecture Notes in Biomathematics. Springer, New York, 1977, 202 pp.
[16] Stratonovich, R.L., Selected Problems of Fluctuations Theory in Radio Engineering. [In Russian]. Sovetskoe Radio, Moscow, 1961, 556 pp.
[17] Liptser, R.Sh., Shirjaev, A.N. Statistics of stochastic processes: nonlinear filtering and related problems. [In Russian]. Nauka, Moscow, 1974, 696
pp.
[18] Nasyrov, F.S. Local times, symmetric integrals and stochastic analysis. [In Russian]. Fizmatlit Publ., Moscow, 2011, 212 pp.
[19] Kagirova, G.R., Nasyrov, F.S. On an optimal filtration problem for onedimensional diffusion processes. Siberian Adv. Math., 28, 3 (2018), 155165.
[20] Chugai, K.N., Kosachev, I.M., Rybakov, K.A. Approximate filtering methods in continuous-time stochastic systems. Smart Innovation, Systems and Technologies, vol. 173, Eds. Jain L.C., Favorskaya M.N., Nikitin
I.S., Reviznikov D.L. Springer, 2020, pp. 351-371. DOI: http://doi.org
10.1007/978-981-15-2600-8_24
[21] Averina, T.A., Rybakov, K.A. Using maximum cross section method for filtering jump-diffusion random processes. Russian Journal of Numerical
Analysis and Mathematical Modelling. 35, 2 (2020), 55-67. DOI: http:
/doi.org/10.1515/rnam-2020-0005
[22] Kloeden, P.E., Platen, E., Schurz, H., Sorensen, M. On effects of discretization on estimators of drift parameters for diffusion processes. J. Appl. Probab., 33 (1996), 1061-1076.
[23] Clark, J.M.C., Cameron, R.J. The maximum rate of convergence of discrete approximations for stochastic differential equations. Stochastic Differential Systems Filtering and Control. Lecture Notes in Control and
Electronic Journal. http://diffjournal.spbu.ru/ 416
Differential Equations and Control Processes, N. 1, 2021
[24]
[25]
[26]
[27]
[28]
[29]
[30]
[31]
[32]
[33]
Information Sciences, vol 25. Ed. Grigelionis B. Springer, Berlin, Heidelberg, 1980, pp. 162-171.
Kulchitskiy, O.Yu., Kuznetsov, D.F. The unified Taylor-Ito expansion. Journal of Mathematical Sciences (New York), 99, 2 (2000), 1130-1140.
DOI: http://doi.org/10.1007/BF02673635
Kuznetsov, D.F. New representations of the Taylor-Stratonovich expansion. Journal of Mathematical Sciences (New York), 118, 6 (2003), 5586-
5596. DOI: http://doi.org/10.1023/A:1026138522239
Kuznetsov, D.F. Strong approximation of iterated Ito and Stratonovich stochastic integrals based on generalized multiple Fourier series. Application to numerical solution of Ito SDEs and semilinear SPDEs. Differen-cialnie Uravnenia i Protsesy Upravlenia, 4 (2020), A.1-A.606. Available
at: http://diffjournal.spbu.ru/EN/numbers/2020.4/article.1.8.html
Milstein, G.N. Numerical Integration of Stochastic Differential Equations. [In Russian]. Ural University Press, Sverdlovsk, 1988, 225 pp.
Kloeden, P.E., Platen, E., Wright, I.W. The approximation of multiple stochastic integrals. Stochastic Analysis and Applications, 10, 4 (1992),
431-441.
Averina, T.A., Prigarin, S.M. Calculation of stochastic integrals of Wiener processes. [In Russian]. Preprint 1048. Novosibirsk, Institute of Computational Mathematics and Mathematical Geophysics of Siberian Branch of the Russian Academy of Sciences, 1995, 15 pp.
Prigarin, S.M., Belov, S.M. One application of series expansions of Wiener process. [In Russian]. Preprint 1107. Novosibirsk, Institute of Computational Mathematics and Mathematical Geophysics of Siberian Branch of the Russian Academy of Sciences, 1998, 16 pp.
Wiktorsson, M. Joint characteristic function and simultaneous simulation of iterated Ito integrals for multiple independent Brownian motions. The Annals of Applied Probability, 11, 2 (2001), 470-487.
Ryden, T., Wiktorsson, M. On the simulation of iterated Ito integrals. Stochastic Processes and their Applications, 91, 1 (2001), 151-168.
Gaines, J.G., Lyons, T.J. Random generation of stochastic area integrals. SIAM J. Appl. Math., 54 (1994), 1132-1146.
Electronic Journal. http://diffjournal.spbu.ru/ 417
Differential Equations and Control Processes, N. 1, 2021
[34] Milstein, G.N., Tretyakov, M.V. Stochastic Numerics for Mathematical Physics. Springer, Berlin, 2004, 616 pp.
[35] Allen, E. Approximation of triple stochastic integrals through region subdivision. Communications in Applied Analysis (Special Tribute Issue to Professor V. Lakshmikantham), 17 (2013), 355-366.
[36] Rybakov, K.A. Applying spectral form of mathematical description for representation of iterated stochastic integrals. [In Russian]. Differencialnie
Uravnenia i Protsesy Upravlenia, 4 (2019), 1-31. Available at: http/
diffjournal.spbu.ru/EN/numbers/2019.4/article.1.1.html
[37] Tang, X., Xiao, A. Asymptotically optimal approximation of some stochastic integrals and its applications to the strong second-order methods. Advances in Computational Mathematics, 45 (2019), 813-846.
[38] Zahri, M. Multidimensional Milstein scheme for solving a stochastic model for prebiotic evolution. Journal of Taibah University for Science, 8, 2 (2014), 186-198.
[39] Li, C.W., Liu, X.Q. Approximation of multiple stochastic integrals and its application to stochastic differential equations. Nonlinear Anal. Theor. Meth. Appl., 30, 2 (1997), 697-708.
[40] Rybakov K. Application of Walsh series to represent iterated Stratonovich stochastic integrals. IOP Conference Series: Materials science and
engineering. 2020, vol. 927, id 012080. DOI: http://doi.org/10.1088
1757-899X/927/1/012080
[41] Rybakov, K.A. Modeling and analysis of output processes of linear continuous stochastic systems based on orthogonal expansions of random functions. J. of Computer and Systems Sci. Int., 59, 3 (2020), 322-337.
DOI: http://doi.org/10.1134/S1064230720030156
[42] Kuznetsov, D.F. Numerical Integration of Stochastic Differential Equations. 2. [In Russian]. Polytechnical University Publishing House, Saint-Petersburg, 2006, 764 pp. DOI: http://doi.org/10.18720/SPBPU/2/
s17-227
[43] Kuznetsov, D.F. A method of expansion and approximation of repeated stochastic Stratonovich integrals based on multiple Fourier series on full orthonormal systems. [In Russian]. Differencialnie Uravnenia i Protsesy
Electronic Journal. http://diffjournal.spbu.ru/ 418
Differential Equations and Control Processes, N. 1, 2021
Upravlenia, 1 (1997), 18-77. Available at: http://diffjournal.spbu.ru/EN
numbers/1997.1/ article.1.2.html
[44] Kuznetsov, D.F. Comparative analysis of the efficiency of application of Legendre polynomials and trigonometric functions to the numerical integration of Ito stochastic differential equations. Computational Mathematics and Mathematical Physics, 59, 8 (2019), 1236-1250. DOI:
http://doi.org/10.1134/S0965542519080116
[45] Kuznetsov, D.F. Application of the method of approximation of iterated stochastic Ito integrals based on generalized multiple Fourier series to the high-order strong numerical methods for non-commutative semilinear stochastic partial differential equations. Differencialnie Uravnenia i Prot-
sesy Upravlenia, 3 (2019), 18-62. Available at: http://diffjournal.spbu.
ru/EN/numbers/2019.3/article.1.2.html
[46] Kuznetsov, D.F. Application of multiple Fourier-Legendre series to strong exponential Milstein and Wagner-Platen methods for non-commutative semilinear stochastic partial differential equations. Differencialnie Urav-nenia i Protsesy Upravlenia, 3 (2020), 129-162. Available at: http:
/diffjournal.spbu.ru/EN/numbers/2020.3/article.1.6.html
[47] Jentzen, A., Rockner, M. A Milstein scheme for SPDEs. Foundations Comp. Math., 15, 2 (2015), 313-362.
[48] Becker, S., Jentzen, A., Kloeden, P.E. An exponential Wagner-Platen type scheme for SPDEs. SIAM J. Numer. Anal., 54, 4 (2016), 2389-2426.
[49] Mishura, Y.S., Shevchenko, G.M. Approximation schemes for stochastic differential equations in a Hilbert space. Theor. Prob. Appl., 51, 3 (2007), 442-458.
[50] Bao, J., Reisinger, C., Renz, P., Stockinger, W. First order convergence of Milstein schemes for McKean equations and interacting particle systems
arXiv:2004.03325v1 [math.PR], 2020, 27 pp.
[51] Son, L.N., Tuan, A.H., Dung, T.N., Yin G. Milstein-type procedures for numerical solutions of stochastic differential equations with Markovian switching. SIAM J. Numer. Anal., 55, 2 (2017), 953-979.
[52] Sun, Y., Yang, J., Zhao W. Ito-Taylor schemes for solving mean-field stochastic differential equations. Numer. Math. Theor. Meth. Appl., 10, 4 (2017), 798-828.
Electronic Journal. http://diffjournal.spbu.ru/ 419
Differential Equations and Control Processes, N. 1, 2021
[53] Higham, D.J. An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations. SIAM Rev., 43, 3 (2001), 525-546.
[54] Cyganowski, S., Grune, L., Kloeden, P.E. Maple for stochastic differential equations. Theory and Numerics of Differential Equations. Eds. Blowey, J.F., Coleman, J.P., Craig, A.W. Universitext. Springer, Berlin, Heidelberg, 2001, pp. 127-177.
[55] Higham, D.J., Kloeden, P.E. MAPLE and MATLAB for stochastic differential equations in finance. Programming Languages and Systems in Computational Economics and Finance. Advances in Computational Economics, vol 18, Ed. Nielsen, S.S. Springer, Boston, MA, 2002, pp. 233-269.
[56] Cyganowski, S., Grune, L., Kloeden P.E. MAPLE for jump-diffusion stochastic differential equations in finance. Programming Languages and Systems in Computational Economics and Finance. Advances in Computational Economics, vol. 18, Ed. Nielsen, S.S. Springer, Boston, MA, 2002, pp. 441-460.
[57] Gilsing, H., Shardlow, T. SDELab: A package for solving stochastic differential equations in MATLAB. Journal of Computational and Applied Mathematics, 2, 205 (2007), 1002-1018.
[58] Kuznetsov, D.F. Stochastic Differential Equations: Theory and Practice of Numerical Solution. With MatLab programs, 3rd Edition. [In Russian]. Polytechnical University Publishing House, Saint-Petersburg, 2009, 768
pp. DOI: http://doi.org/10.18720/SPBPU72/s17-230
[59] Kiesewetter, S., Polkinghorne, R., Opanchuk, B., Drummond, P.D. xSP-DE: Extensible software for stochastic equations. SoftwareX, 5 (2016), 12-15.
[60] Gevorkyan, M.N., Velieva, T.R., Korolkova, A.V., Kulyabov, D.S., Sev-astyanov, L.A. Stochastic Runge-Kutta software package for stochastic differential equations. Dependability Engineering and Complex Systems. DepCoS-RELCOMEX 2016. Advances in Intelligent Systems and Computing, vol. 470, Eds. Zamojski, W., Mazurkiewicz, J., Sugier, J., Walkowiak, T., Kacprzyk, J. Springer, Cham, 2016, pp. 169-179.
[61] Kuznetsov, D.F. Stochastic differential equations: theory and practice of numerical solution. With MATLAB programs, 6th Edition. [In Russian]. Differencialnie Uravnenia i Protsesy Upravlenia, 4 (2018), A.1-A.1073.
Electronic Journal. http://diffjournal.spbu.ru/ 420
Differential Equations and Control Processes, N. 1, 2021
Available at: http://diffjournal.spbu.rU/EN/numbers/2018.4/article.2.1.
html
[62] Kulchitskiy, O.Yu., Kuznetsov, D.F. Numerical Simulation of Stochastic Systems of Linear Stationary Differential Equations. [In Russian]. Differ-encialnie Uravnenia i Protsesy Upravlenia, 1 (1998), 41-65. Available at: http://diffjournal.spbu.ru/pdf/j010.pdf
[63] Gihman, I.I., Skorohod A.V. Stochastic Differential Equations and its Applications. [In Russian]. Naukova Dumka, Kiev, 1982, 612 pp.
[64] Kuznetsov, D.F. On Numerical Modeling of the Multidimensional Dynamic Systems Under Random Perturbations With the 1.5 and 2.0 Orders of Strong Convergence. Automation and Remote Control, 79, 7 (2018),
1240-1254. DOI: http://doi.org/10.1134/S0005117918070056
[65] Kuznetsov, D.F. On Numerical Modeling of the Multidimentional Dynamic Systems Under Random Perturbations With the 2.5 Order of Strong Convergence. Automation and Remote Control, 80, 5 (2019), 867-
881. DOI: http://doi.org/10.1134/S0005117919050060
[66] Kuznetsov, D.F. Explicit one-step mumerical method with the strong convergence order of 2.5 for Ito stochastic differential equations with a multi-dimensional nonadditive noise based on the Taylor-Stratonovich expansion. Computational Mathematics and Mathematical Physics, 60, 3 (2020), 379-389. DOI:
http://doi.org/10.1134/S0965542520030100
[67] Kuznetsov, D.F. Strong approximation of iterated Ito and Stratonovich stochastic integrals based on generalized multiple Fourier series. Application to numerical solution of Ito SDEs and semilinear SPDEs.
arXiv:2003.14184 [math.PR], 2020, 652 pp.
[68] Kuznetsov, D.F. Multiple Ito and Stratonovich stochastic integrals: approximations, properties, formulas. Polytechnical University Publishing House: St.-Petersburg, 2013, 382 pp. DOI: http://doi.org/10.18720
SPBPU/2/s17-234
[69] Kuznetsov, D.F. Expansion of iterated Stratonovich stochastic integrals based on generalized multiple Fourier series. Ufa Mathematical Journal, 11, 4 (2019), 49-77. DOI: http://doi.org/10.13108/2019-11-4-49 Available
at: http://matem.anrb.ru/en/article?art_id=604
Electronic Journal. http://diffjournal.spbu.ru/ 421
Differential Equations and Control Processes, N. 1, 2021
[70] Kuznetsov, D.F. Development and application of the Fourier method for the numerical solution of Ito stochastic differential equations. Computational Mathematics and Mathematical Physics, 58, 7 (2018), 1058-1070.
DOI: http://doi.org/10.1134/S0965542518070096
[71] Kuznetsov, D.F. Mean Square Approximation of Solutions of Stochastic Differential Equations Using Legendres Polynomials. Journal of Automation and Information Sciences (Begell House), 32, Issue 12, (2000), 69-86.
DOI: http://doi.org/10.1615/JAutomatInfScien.v32.i12.80
[72] Kuznetsov, D.F. Multiple Ito and Stratonovich stochastic integrals: Fourier-Legendre and trigonometric expansions, approximations, formulas. Differencialnie Uravnenia i Protsesy Upravlenia, 1 (2017), A.1-A.385. Available at: http://diffjournal.spbu.ru/EN/numbers/2017.1/article.2.1.
html
[73] Kuznetsov, M.D., Kuznetsov, D.F. Optimization of the mean-square approximation procedures for iterated Ito stochastic integrals of multiplicities 1 to 5 from the unified Taylor-Ito expansion based on multiple
Fourier-Legendre series arXiv:2010.13564 [math.PR], 2020, 59 pp.
[74] Kuznetsov, M.D., Kuznetsov, D.F. Implementation of strong numerical methods of orders 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0 for Ito SDEs with non-commutative noise based on the unified Taylor-Ito and Taylor-Stratonovich expansions and multiple Fourier-Legendre series.
arXiv:2009.14011 [math.PR], 2020, 188 pp.
[75] Kuznetsov, D.F., Kuznetsov, M.D. A software package for implementation of strong numerical methods of convergence orders 0.5, 1.0, 1.5, 2.0,
2.5, and 3.0 for Ito SDEs with non-commutative multi-dimensional noise. 19th International Conference ’’Aviation and Cosmonautics” (AviaSpace-2020). Abstracts (Moscow, MAI, 23-27 November, 2020), Publishing house ”Pero”, 2020, 569-570.
[76] Kuznetsov, D.F., Kuznetsov, M.D. Mean-square approximation of iterated stochastic integrals from strong exponential Milstein and Wagner-Platen methods for non-commutative semilinear SPDEs based on multiple Fourier-Legendre series. Springer Proceedings in Mathematics & Statistics. Recent Developments in Stochastic Methods and Applications. Ed. Shiryaev, A.N. Samouylov, K.E, Kozyrev, D.V., 2021 (to appear).
Electronic Journal. http://diffjournal.spbu.ru/ 422