Approximation of PDF with summation to infinity, cos(x) and exp(x)

71 Views Asked by At

I would like to implement this probability density function in C++. However, on this current form, the algorithm takes a lot of time to return a result (especially because it include a summation).

Do you know whether this expression can have a mathematical approximation which may reduce the computation time in the c++ implementation?

I have already tried to replace $cos(x)$ with $\frac{1}{2}[exp(Ix) + exp(Ix)]$, where I is an imaginary unit.

$P(x,t|x_0,t_0)={\frac{1}{L} + \frac{2}{L} }\sum_{n=1}^{\infty}exp[-(\frac{n\pi}{2})^2 \frac{t-t_0}{\tau}] cos(\frac{n\pi x}{L}) cos(\frac{n\pi x_0}{L})$