how to use Euler method for numerical integration of differential equation?

646 views Asked by At

I want to numerically solve a stochastic differential equation (SDE) in MATLAB, The code I have written just simply does not recognize sde function!

The question is as below:

 dz=v*dt +sqrt(2*Ds)*dw_t
 where v = 1/(N*delta) * sigma f_i (i=1- N)
 N= 100,
 delta = e6,

and f_i is calculated form this equation:

 for z>=z0 , f_i = -kappa*(z0_i -z)  and kappa = .17
 for z<z0 ,  f_i = -kappaT*(z0_i -z) and kappaT = 60

note that the initial values for z0_i is randomly distributed over 60nm range.

 Ds = 4e4

and dw_t is an increment in Wiener process.

Firstly I don't know how to set the conditions for z while I don't have the value for it! Secondly, the Euler algorithm is exactly matching the equation but I don't know why the code with sde function is not working!

1

There are 1 answers

0
Son Le On

In order to numerically solve a SDE, you would need a Initial Condition (IC) for the function you want to code. In your case, I guess it's z. If you want to do so without explicitly declaring the IC, you can write it as a function that takes an IC. Then to test, you would input random ICs in.

Also, it is not clear to me whether your z0 is also stochastic and changes with time, is randomly generated every time step, or a constant that was only randomly generated once. Even simpler, if z0 is just the IC of z, then your f_i just inspects whether z has increased or decreased through the time step to decide how z would change the next time step. Please clarify this and your problem will seem much clearer.

It is not too hard to simulate your SDE without the use of the solver. You can try it out and achieve better result since sometimes you will really need to learn the behavior of the solver in order for it to work. I would suggest Monte Carlo method if you choose to write your own solver to ensure accuracy.

I hope my answer helps. If you still have any questions, feel free to ask.