2.6.2 Boundary value problem for the Black Scholes equation

problem number 98

From Mathematica DSolve help pages.

Solve for \(V(t,s)\) \[ \frac {\partial v}{\partial t} + \frac {1}{2} \sigma ^2 s^2 \frac {\partial ^2 v}{\partial s^2} +(r-q) s \frac {\partial v}{\partial s} - r v(t,s)=0 \] With boundary condition \( v(T,s) = \psi (s)\)

Reference https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_equation

Mathematica

ClearAll["Global`*"]; 
pde =  D[v[t, s], t] + (1*sigma^2*s^2*D[v[t, s], {s, 2}])/2 + (r - q)*s*D[v[t, s], s] - r*v[t, s] == 0; 
bc  = v[T, s] == psi[s]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc}, v[t, s], {t, s}], 60*10]];
 

\[\left \{\left \{v(t,s)\to \frac {e^{r (t-T)} \int _{-\infty }^{\infty } \psi \left (e^{K[1]}\right ) \exp \left (-\frac {\left (-K[1]+\frac {1}{2} (t-T) \left (2 q-2 r+\sigma ^2\right )+\log (s)\right )^2}{2 \sigma ^2 (T-t)}\right ) \, dK[1]}{\sqrt {2 \pi } \sqrt {\sigma ^2 (T-t)}}\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
pde := diff(v(t, s), t) +s^2*(diff(v(t, s), s, s))/(2*sigma^2)+(r-q)*s*(diff(v(t, s), s))-r*v(t, s) = 0; 
ic:=v(T, s) = psi(s); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic],v(t,s))),output='realtime'));
 

\[v \left ( t,s \right ) ={\it invmellin} \left ( {\it mellin} \left ( \psi \left ( s \right ) ,s,s \right ) {{\rm e}^{{\frac { \left ( -t+T \right ) \left ( \left ( s \left ( -r+q \right ) -r \right ) {\sigma }^{2}+1/2\,{s}^{2}+s/2 \right ) }{{\sigma }^{2}}}}},s,s \right ) \]