The are two parts to the problem the first is to find the probability that a Brownian motion, $W_t$ hits 1 before it hits -2. Using the martingale method. This can be done using optimal sampling theorem which gives:
$$\begin{align*} 0 = E(W_{\tau}) &= P(W_{\tau} = 1) - 2P(W_{\tau}=-2) =P(W_{\tau} = 1) - 2(1 - P(W_{\tau} = 1)) \\ \implies P(W_{\tau} = 1) = \frac{2}{3}. \end{align*}$$
It then asks what is the expected time to hit either of these levels.
The solution starts off by noting that the process $Y_t = W_t^2 - t$ is a martingale and proceeds as follows again using the OST.
$0 = E(Y_{\tau})=E(W_{\tau}^2)-E(\tau)$
they then say using previous result this gives
$E_{\tau} = \frac{2}{3} + \frac{4}{3} = 2$
But I don't see how to get to this answer?
I can apply Ito to the $W_{\tau}^2$ term:
$2 W_{\tau} dW + \frac{1}{2}2dt$
Taking expectations this gives $2 W_{\tau} dW$ which would give you the $\frac{4}{3}$ term? is this part correct?
I can't see how to get the other $\frac{2}{3}$ term?
Thanks
There is no need to apply Itô's formula. We know that $W_{\tau}$ takes only the values $1$ and $-2$, and you have already shown that
$$\mathbb{P}(W_{\tau}=1) = \frac{2}{3} \qquad \mathbb{P}(W_{\tau}=-2) = \frac{1}{3}.$$
Thus,
$$\mathbb{E}(W_{\tau}^2) = \mathbb{E}(W_{\tau}^2 1_{\{W_{\tau}=1\}}) + \mathbb{E}(W_{\tau}^2 1_{\{W_{\tau}=-2\}}) = 1 \cdot \mathbb{P}(W_{\tau}=1) + (-2)^2 \mathbb{P}(W_{\tau}=-2) = \frac{2}{3} + \frac{4}{3}.$$