A demo for computing expected stopping time with Matlab function ‘pdepe’

Consider a geometric Brownian motion

$\displaystyle d X_r = b X_r dr + \sigma X_r d W_r, X_t = x,$

and a stopping time, for some ${\alpha<\beta}$

$\displaystyle \tau^{x,t} = \inf\{r>t: X_r^{x,t} \notin (\alpha, \beta)\} \wedge T.$

We will use Matlab function ‘pdepe’ to find the numerical solution of

$\displaystyle V(x,t) = \mathbb{E}[\tau^{x,t}] - t.$

We use the following values for the coefficients:

$\displaystyle \alpha = 1.7, \ \beta = 2.3, \ b = 0.05, \ \sigma = 0.2, \ T = 1.$

Proposition 1 ${V(x,t)}$ is the unique classical solution of the following parabolic PDE backward in time:

$\displaystyle \left\{ \begin{array}{ll} (Eq1) & \partial_t V + b x \partial_x V + \frac 1 2 \sigma^2 x^2 \partial_x^2 V + 1 = 0, \ (\alpha,\beta) \times (0,T); \\ (Tc1) & V(x,T) = 0, \ \forall x\in (\alpha,\beta)\\ (Bc1) & V(\alpha,t) = V(\beta,t) = 0, \ \forall t \in (0,1). \end{array} \right. \ \ \ \ \ (1)$

Matlab function ‘pdepe’ can solve the following specific form of PDE forward in time:

$\displaystyle \left\{ \begin{array}{ll} (Eq2) & c(x,t,u,\partial_x u) \partial_t u = x^{-m} \partial_x (x^m f(x,t,u, \partial_x u)) \\ & \hspace{2.2in} + s(x,t,u, \partial_x u), \ (\alpha,\beta) \times (t_0, t_f); \\ (Ic2) & u(x,t_0) = u_0(x), \ \forall x\in (\alpha,\beta)\\ (Bc2) & p(x,t,u) + q(x,t) f(x,t,u,\partial_x u) = 0, \ \forall t \in (t_0,t_f), x = \alpha, \beta. \end{array} \right. \ \ \ \ \ (2)$

Let ${u(x,t) = V(x,T -t)}$, then (1) becomes (2) with

$\displaystyle c = 1, \ m = 0, \ f = \frac 1 2 \sigma^2 x^2 \partial_x u), \ s = bx \partial_x u - \sigma^2 x \partial_x u + 1, \ p = u, \ q = 0.$

Now, we are ready for the code with the above datas. For Matlab code, please download it from here, then save it with file name ‘Etau.m’, then run it in Matlab. For example, we find

$\displaystyle \mathbb{E}[\tau^{2,0}] = V(2,0) = u(2,1) = 0.4962.$

This code also plots 3-D pictures for the numerical solution, EtauFig1