Solution (source code)

= Solution

Under the given <risk-neutral measure>, the option price is $V(t,S)=e^{-r(T-t)}\mathbb E[\phi(S_T)\mid S_t=S]$. Thus $e^{-rt}V(t,S_t)$ is a <martingale>. This valuation also follows from <delta hedging>: cancel the Brownian exposure with $V_S$ units of stock, after which absence of arbitrage makes the locally riskless remainder earn $r$.

Set $f(t,b)=e^{-rt}V(t,S_0e^{\sigma b+(r-\sigma^2/2)t})$. The stated Brownian martingale identity and the chain rule give
$$
f_t+\tfrac12f_{bb}=e^{-rt}\left(V_t+\tfrac12\sigma^2S^2V_{SS}+rSV_S-rV\right).
$$
The drift vanishes because discounted option value is a <martingale>. Consequently the <Black-Scholes equation> is
$$
\boxed{V_t+\tfrac12\sigma^2S^2V_{SS}+rSV_S-rV=0,\qquad V(T,S)=\phi(S).}
$$
For bounded measurable payoffs, the conditional-expectation solution is smooth for $t<T$; terminal values are interpreted in the usual limiting sense at continuity points, or in the bounded measurable pricing sense.