Stochastic Differetion Equation and Stopping Time I'm working on a homework problem.
Let $X(t)$ satisfies $\mathrm{d}X(t)=\mu(X(t))\mathrm{d}t+\sigma(X(t))\mathrm{d}W(t)$, with $X(0)=x_0 \in(A,B)$.
Let $T$ be the stopping time when $X(t)$ leaves $(A,B)$, i.e.
$T\triangleq \inf\left\{ t \geq 0:X(t)\notin(A,B) \right\}$.
Find: (1) $\mathbb{P}(X(T)=A)$ (2)$\mathbb{E}(T)$
It seems to be like the gambler's ruin problem, which can be solved by calculating $\mathbb{E}(X(T))$ through optional sampling theorem. But here, is this way possible since the expectation seems not easy to find?
Many thanks.
 A: Notations
For the convention of notations, let us take
$$
{\rm d}X_t=\mu(X_t){\rm d}t+\sigma(X_t){\rm d}W_t
$$
with $X_0=x_0\in\left(a,b\right)$, and
$$
\tau=\inf\left\{t>0:X_t\not\in\left(a,b\right)\right\}.
$$
Figure out $\mathbb{P}\left(X_{\tau}=a\right)$
As @saz has pointed out, focusing on $\mathbb{E}\left(X_{\tau}\right)$ might be less helpful, because $X_{\tau}$ is not likely to be a martingale. Nevertheless, we may try to construct some function $f$, such that $f(X_{\tau})$ is a martingale. With the help of $\mathbb{E}f(X_{\tau})=\mathbb{E}f(X_0)=f(x_0)$, we are still able to figure out $\mathbb{P}\left(X_{\tau}=a\right)$, i.e.,
\begin{align}
f(x_0)&=\mathbb{E}f(X_{\tau})=f(a)\mathbb{P}\left(X_{\tau}=a\right)+f(b)\mathbb{P}\left(X_{\tau}=b\right),\\
1&=\mathbb{P}\left(X_{\tau}=a\right)+\mathbb{P}\left(X_{\tau}=b\right).
\end{align}
$f$ could be constructed as follows. Thanks to Ito's formula,
\begin{align}
{\rm d}f(X_t)&=f'(X_t){\rm d}X_t+\frac{1}{2}f''(X_t){\rm d}\left<X\right>_t\\
&=f'(X_t)\left(\mu(X_t){\rm d}t+\sigma(X_t){\rm d}W_t\right)+\frac{1}{2}f''(X_t)\sigma^2(X_t){\rm d}t\\
&=\left(\mu(x)f'(x)+\frac{1}{2}\sigma^2(x)f''(x)\right)\Bigg|_{x=X_t}{\rm d}t+\sigma(X_t)f'(X_t){\rm d}W_t.
\end{align}
Obviously, if we require
$$
\mu(x)f'(x)+\frac{1}{2}\sigma^2(x)f''(x)=0,
$$
$f(X_t)$ would become an Ito integral. By the optimal stopping time theorem, it yields
$$
\mathbb{E}f(X_{\tau})=\mathbb{E}f(X_0)=f(x_0).
$$
Hence any non-degenerated $f$ that satisfies the above ODE would help.
Figure out $\mathbb{E}\tau$
We still play the $f$-trick as above. In case of confusion, let us use $g$ in this section. We have
$$
{\rm d}g(X_t)=\left(\mu(x)g'(x)+\frac{1}{2}\sigma^2(x)g''(x)\right)\Bigg|_{x=X_t}{\rm d}t+\sigma(X_t)g'(X_t){\rm d}W_t.
$$
As this time, if we require
$$
\mu(x)g'(x)+\frac{1}{2}\sigma^2(x)g''(x)=1,
$$
$g(X_t)-t$ would be come an Ito integral. By the optimal stopping time theorem, it yields
$$
\mathbb{E}\left(g(X_{\tau})-\tau\right)=\mathbb{E}g(X_0)=g(x_0)\iff\mathbb{E}\tau=\mathbb{E}g(X_{\tau})-g(x_0).
$$
The unknown $\mathbb{E}g(X_{\tau})$ could be figured out as per its definition, i.e.,
$$
\mathbb{E}g(X_{\tau})=g(a)\mathbb{P}\left(X_{\tau}=a\right)+g(b)\mathbb{P}\left(X_{\tau}=b\right).
$$
Hence any non-degenerated $g$ that satisfies the above ODE would help.
