Solution (source code)

= Solution

Use the usual <Black-Scholes model> with $\sigma>0$ and the <filtration> generated by $W$. Set
$$
\boxed{\lambda=\frac{\mu-r}{\sigma},\qquad Z_t=\exp\left(-\lambda W_t-\frac12\lambda^2t\right).}
$$
For $u>t$, <independence> and the <Gaussian distribution> <exponential moment> formula give $\mathbb E_P[Z_u/Z_t\mid\mathcal F_t]=1$. Thus $Z$ is a strictly positive <martingale> of mean one, defining an equivalent measure $Q$ on every finite horizon by $dQ/dP|_{\mathcal F_t}=Z_t$.

To verify the measure change directly, put $\widehat W_t=W_t+\lambda t$. For any real $a$ and $h=u-t$,
$$
\begin{aligned}\mathbb E_Q[e^{ia(\widehat W_u-\widehat W_t)}\mid\mathcal F_t]&=\mathbb E_P[(Z_u/Z_t)e^{ia(W_u-W_t+\lambda h)}\mid\mathcal F_t]\\&=e^{ia\lambda h-\lambda^2h/2}\exp\left(\tfrac12(-\lambda+ia)^2h\right)\\&=e^{-a^2h/2}.
\end{aligned}
$$
The conditional <characteristic function> is that of $N(0,h)$ and does not depend on past information. Therefore $\widehat W$ has independent increments with <Gaussian distribution> and continuous paths, and is a <Brownian motion> under $Q$. Substituting $dW=d\widehat W-\lambda dt$ gives $dS_t=S_t(rdt+\sigma d\widehat W_t)$. Hence $S_t/B_t$ is a <geometric Brownian motion> that is a <martingale> and $Q$ is an <equivalent martingale measure>.

The form is also forced. By the <Brownian martingale representation theorem>, any <density process> that is a <martingale> has $dZ_t=a_t\,dW_t$. The <change of measure> identity makes $Z_tS_t/B_t$ a <local martingale> under $P$. Its drift, calculated by <Itô formula>, is $(S_t/B_t)[Z_t(\mu-r)+\sigma a_t]dt$, which must vanish. Thus $a_t=-\lambda Z_t$. Solving $dZ_t=-\lambda Z_t\,dW_t$ with $Z_0=1$ gives exactly the displayed <stochastic exponential>. Equivalence here is on each finite horizon, as usual for Black-Scholes pricing.