I would like to solve numerically the following PDE: $$ \frac{\partial}{\partial t} p(x,t)=-\frac{\partial}{\partial x}p(x,t)+\frac{1}{2}\frac{\partial^2}{\partial x^2}[x^2\,p(x,t)],\;x\ge0,\;t\ge0, $$ where $p(x,t)$ denotes a probability density function. The PDF is subject to the following conditions:
$p(x,0+)=\delta(x-x_0)$, where $x_0\ge0$ is a given constant and $\delta(x)$ denotes the Delta function;
$\int_{0}^\infty p(x,t)\,dx=1$ for all $t\ge0$;
Two limit-type boundary conditions: $$ \lim_{x\to0+}\left\{p(x,t)-\frac{1}{2}\frac{\partial}{\partial x}[x^2\,p(x,t)]\right\}=0, $$ and $$ \lim_{x\to+\infty}\left\{p(x,t)-\frac{1}{2}\frac{\partial}{\partial x}[x^2\,p(x,t)]\right\}=0. $$
I am a novice in Mathematica, but having searched stackexchange.com for similar questions, I was able to come up with the following code:
ClearAll["Global`*"];
$Assumptions = x >= 0 && Subscript[x, 0] >= 0 && t >= 0;
tmax = 15;
xmax = 15;
Subscript[x, 0] = 2;
sol = NDSolve[{D[p[x, t], {t, 1}] == -D[p[x, t], {x, 1}] +
1/2*D[x^2*p[x, t], {x, 2}],
p[x, 0] == D[HeavisideTheta[x - Subscript[x, 0]], {x, 1}],
((p[x, t] - 1/2*D[x^2*p[x, t], {x, 1}]) /. x -> xmax) == 0,
((p[x, t] - 1/2*D[x^2*p[x, t], {x, 1}]) /. x -> 0) == 0},
p, {t, 0, tmax}, {x, 0, xmax}];
pxt = First[p /. sol];
Plot3D[pxt[x, t], {x, 0, xmax}, {t, 0, tmax}, PlotRange -> All]
It basically yields the trivial solution $p(x,t)\equiv 0$, which is because the normalization constraint 2 is not taken into account.
My question is whether it's possible to feed a constraint of this type of NDSolve?
UPDATE This equation can be solved analytically. Its exact solution (evaluated using Mathematica) is illustrated in the following figure:
I would like to compare the exact solution and the numerical solution. What I need help with is getting the latter using Mathematica.
Subscript[x,0]
withx0
, becauseSubscript
is not atomic in Mathematica, so NDSolve will "see" thex
inside it and treat it like the independent variable ofp
. $\endgroup$