Solution (source code)

= Solution

Assume $f\in C^{1,2}$ on positive prices before maturity and the usual local trading integrability. If its value is held in <stock> units $\delta_t$ and bank units $\beta_t$, then
$$
f(S_t,t)=\delta_t S_t+\beta_t B_t,\qquad
 df=\delta_t\,dS_t+\beta_t\,dB_t
$$
for a <self-financing portfolio>. The <Itô formula> diffusion coefficient is $\sigma S_tf_x$, so $\sigma S_t>0$ forces $\delta_t=f_x(S_t,t)$ and $\beta_tB_t=f-S_tf_x$. Equating drifts yields
$$
f_t+\alpha xf_x+\frac12\sigma^2x^2f_{xx}
=\alpha xf_x+\rho(f-xf_x).
$$
The physical drift cancels, giving the <Black-Scholes equation>
$$
\boxed{f_t+\frac12\sigma^2x^2f_{xx}+\rho xf_x-\rho f=0.}
$$
Conversely, if the smooth function satisfies this equation, set $\delta=f_x$ and $\beta=(f-xf_x)/B$. Substituting into <Itô formula> gives exactly $df=\delta dS+\beta dB$, so these holdings are <self-financing>. This checks the holdings as well as the value equation; a <partial differential equation> solution does not justify arbitrary prescribed holdings. Appropriate admissibility and growth conditions are imposed when using it as an economic price.

For the <logarithmic stock payoff>, let $\tau=T-t$ and condition on $S_t=x$. Under the <risk-neutral measure>,
$$
S_T=x e^{(\rho-\sigma^2/2)\tau+\sigma\sqrt\tau Z},\qquad Z\sim N(0,1).
$$
The normal exponential moment $\mathbb Ee^{uZ}=e^{u^2/2}$ and its derivative $\mathbb E[Ze^{uZ}]=u e^{u^2/2}$ give
$$
\mathbb E_Q[S_T\log S_T\mid S_t=x]
=xe^{\rho\tau}\bigl[\log x+(\rho+\sigma^2/2)\tau\bigr].
$$
Therefore
$$
\boxed{f(x,t)=x\bigl[\log x+(\rho+\sigma^2/2)(T-t)\bigr],\qquad
\delta_t=\log S_t+1+(\rho+\sigma^2/2)(T-t).}
$$
The <option delta> is the displayed <stock> holding. The <bank account> value is $f-S_tf_x=-S_t$, so $\beta_t=-S_t/B_t$. Directly, $f_{xx}=1/x$ and $f_t=-x(\rho+\sigma^2/2)$ verify the <partial differential equation>, while $f(x,T)=x\log x$ verifies the payoff. Lognormal moments give the required pricing integrability. Since $x\log x\ge-1/e$, the conditional price is bounded below over this finite horizon, so the resulting <claim replication> has the usual admissibility property.