integral of a diffusion equation

169 Views Asked by At

I am trying to find the cdf of a diffusion process with drift at a given time. Specifically I want to find:

$$ p(x<X|t)=\int_{0}^{X}p(x,t)\,dx = \int_{0}^{X}\frac{1}{\sqrt{2\pi \sigma^{2}t}} exp^{-\frac{(x-z-\mu t)^2}{2\sigma^2 t}}\left( 1-exp^{\frac{-2xz}{\sigma^2 t}}\right) dx $$

Where $x,X,z,t>0$. I haven't done calculus in a long time but I found:

$$ p(x,t) = \frac{1}{\sqrt{2\pi \sigma^{2}t}} \left( exp^{\frac{(x-z-\mu t)^2}{2\sigma^2 t}} - exp^{-\frac{(x-z-\mu t)^2+4xz}{2\sigma^2 t}} \right) = \frac{1}{\sqrt{2\pi \sigma^{2}t}} \left( exp^{-\frac{(x-z-\mu t)^2}{2\sigma^2 t}} - exp^{-\frac{-2z\mu}{\sigma^2}}exp^{-\frac{(x+z-\mu t)^2}{2\sigma^2 t}} \right) $$

This is the part where I am less sure of what I have done. Substituting $u^2= \frac{(x-z-\mu t)^2}{2\sigma^2 t}$ and $v^2= \frac{(x+z-\mu t)^2}{2\sigma^2 t}$:

$$p(x<X|t)=\frac{1}{\sqrt{2\pi\sigma^2 t}}\left[ \int_{\frac{-z-\mu t}{2\sigma^2 t}}^{\frac{X-z-\mu t}{2\sigma^2 t}} exp^{-u^2}du - exp^{-\frac{-2z\mu}{\sigma^2}}\int_{\frac{+z-\mu t}{2\sigma^2 t}}^{\frac{X+z-\mu t}{2\sigma^2 t}} exp^{-v^2}dv \right]\\=\frac{1}{2\sqrt{2\sigma^2 t}}\frac{2}{\sqrt{\pi}}\left[ \int_{0}^{\frac{X-z-\mu t}{2\sigma^2 t}} exp^{-u^2}du - \int_{0}^{\frac{-z-\mu t}{2\sigma^2 t}} exp^{-u^2}du -exp^{-\frac{-2z\mu}{\sigma^2}} \left(\int_{0}^{\frac{X+z-\mu t}{2\sigma^2 t}} exp^{-v^2}dv - \int_{0}^{\frac{+z-\mu t}{2\sigma^2 t}} exp^{-v^2}dv \right)\right]\\ =\frac{1}{2\sqrt{2\sigma^2 t}}\left[erf\left(\frac{X-z-\mu t}{2\sigma^2 t}\right) - erf\left(\frac{-z-\mu t}{2\sigma^2 t}\right) - exp^{\frac{-2z\mu t}{\sigma^2}}\left(erf\left(\frac{X+z-\mu t}{2\sigma^2 t}\right)-erf\left(\frac{+z-\mu t}{2\sigma^2 t}\right)\right)\right]$$

I checked numerically integrating $p(x,t)$ and comparing it to the analytical solution I found and it seems very close but there are some systematic differences between the 2. I don't know if it comes from errors in the numerical integration or a mistake in my equation. I would greatly appreciate if someone could check the equation and tell me if I made a mistake. Also, I was able to find the integral of $p(x,t)$ across x (instead of t) in books and it is:

$$S(t) = \Phi\left(+\frac{z}{\sqrt{\sigma^2 t}}\left(\frac{\mu t}{z}-1\right)\right) + exp^{\frac{2\mu z}{\sigma^2}}\Phi\left(-\frac{z}{\sqrt{\sigma^2 t}}\left(\frac{\mu t}{z}+1\right)\right) $$

Which seems somewhat similar. Is there a way to simplify the 4 erf functions in my equation in only 2 like in the equation above? I haven't been able to figure that out. Thanks.