Solution (source code)

= Solution

Use the following form of the <Girsanov theorem>. If $W$ is <Brownian motion>, $\vartheta$ is predictable, and
$$
Z_t=\exp\left(\int_0^t\vartheta_s\,dW_s-\frac12\int_0^t\vartheta_s^2\,ds\right)
$$
is a <uniformly integrable martingale> with $Z_0=1$, then the <probability measure> with terminal density $Z_\infty$ makes $W_t-\int_0^t\vartheta_s\,ds$ a <Brownian motion>. The analogous finite-horizon statement uses the terminal density at that horizon.

Here take $W_t=X_t-x$ and $\vartheta_s=\mathbf1_{\{s<\tau\}}/X_s$. Before $\tau$, $X_s\in[\varepsilon,M]$, so the <stochastic integral> is well-defined. The assumed uniform integrability of the stopped <stochastic exponential> gives
$$
\mathbb E_{\mathbb W_x}Z_\tau=1,\qquad
Z_{t\wedge\tau}=\mathbb E_{\mathbb W_x}(Z_\tau\mid\mathcal F_t).
$$
Thus the proposed weighting really defines a <probability measure>, and the <Girsanov theorem> gives the <Brownian motion>
$$
B_t=X_t-x-\int_0^{t\wedge\tau}\frac{ds}{X_s}
$$
under that measure. In particular
$$
\boxed{X_t=x+B_t+\int_0^t\frac{ds}{X_s}\qquad(0\le t\le\tau).}
$$
All calculations are first made on this compact stopped interval. The integral involving $1/X$ is naturally defined on $[0,T_0)$; at $T_0$ its <quadratic variation> may diverge. The density will have a zero limiting extension there, as established below, rather than a finite stochastic logarithm at the hitting time.