Solution (source code)

= Solution

Choose the <market price of risk> $\lambda_t=(\mu-rS_t)/\sigma$. The <Girsanov theorem>, with the hypotheses allowed in the question, gives an <equivalent martingale measure> $\mathbb Q$ under which
$$
dW_t^{\mathbb Q}=dW_t+\lambda_tdt,\qquad
dS_t=rS_tdt+\sigma dW_t^{\mathbb Q}.
$$
Thus the <stock> under the <risk-neutral measure> is a linear <Gaussian> diffusion. In particular, for $\tau=T-t$ its conditional mean and standard deviation are
$$
m=e^{r\tau}S_t,\qquad
v=\sigma\sqrt{\frac{e^{2r\tau}-1}{2r}}.
$$
Put $\phi(x)=(2\pi)^{-1/2}e^{-x^2/2}$ and let $\Phi$ be the standard <normal distribution> function. For $N\sim N(0,1)$,
$$
\mathbb E(m+vN-K)^+=(m-K)\Phi((m-K)/v)+v\phi((m-K)/v),
$$
since $\int_{-d}^\infty x\phi(x)dx=\phi(d)$. Discounting this <expectation> gives the <call price in an arithmetic stock model with interest>. A particularly convenient expression is
$$
\begin{aligned}
\nu(\tau)&=\sigma\sqrt{\frac{1-e^{-2r\tau}}{2r}},
&d(t,s)&=\frac{s-Ke^{-r\tau}}{\nu(\tau)},\\
\boxed{C(t,s)}&=\boxed{(s-Ke^{-r\tau})\Phi(d(t,s))+\nu(\tau)\phi(d(t,s))}.
\end{aligned}
$$
At maturity define $C(T,s)=(s-K)^+$. This value is nonnegative because it is a discounted <expectation> of a nonnegative payoff.

For $t<T$, hold $\pi_t=C_s(t,S_t)$ shares and hold $\beta_t=[C(t,S_t)-\pi_tS_t]/B_t$ units of the <continuous-time bank account>. The pricing function solves
$$
C_t+rsC_s+\tfrac12\sigma^2C_{ss}-rC=0.
$$
The <Itô formula> under the physical measure therefore gives
$$
dC(t,S_t)=C_s(t,S_t)dS_t+r[C(t,S_t)-S_tC_s(t,S_t)]dt
=\pi_t dS_t+\beta_t dB_t.
$$
This proves <self-financing> and terminal replication, with wealth always $C(t,S_t)\geq0$. The coefficients are locally smooth before maturity, and the strategy extends to maturity through its continuous wealth limit and the square-integrable discounted payoff representation.

To see minimality, any other nonnegative <self-financing portfolio> replicating the payoff has discounted wealth a nonnegative <local martingale> under $\mathbb Q$, hence a <supermartingale>. Its initial capital $x$ must satisfy $x\geq\mathbb E^{\mathbb Q}[e^{-rT}(S_T-K)^+]=C(0,S_0)$. The strategy constructed above attains equality. Thus
$$
\boxed{x_{\min}=C(0,S_0).}
$$
The additive physical diffusion may take negative <stock> values; the formula and nonnegative replicating wealth remain valid. Replacing it by a multiplicative Black–Scholes diffusion would give the wrong price and hedge.