# Definite integral of product of exponential function and trigonometry function.

Let $x_0$ and $\sigma$ be constants. How do we evaluate the following?

$$\large \int^{L}_{-L}e^{-\frac{(x-x_0)^2}{2\sigma^2}}\cos x \, \mathrm{d}x$$

I think I can solve that with integration by parts. But I'm confused how to calculate the exponential function if I choose it as $\dfrac{\mathrm{d}v}{\mathrm{d}x}$.

This is not an answer but it is too long for a comment

As Martín-Blas Pérez Pinilla commented, the antiderivative is far away to be simple. One way to approach it is to define $$I=\int e^{-\frac{(x-x_0)^2}{2\sigma^2}}\cos (x) dx$$ $$J=\int e^{-\frac{(x-x_0)^2}{2\sigma^2}}\sin (x) dx$$ $$K=I +i J=\int e^{ix-\frac{(x-x_0)^2}{2\sigma^2}} dx$$ Now, completing the square and integrating, $$K=-i \sqrt{\frac{\pi }{2}}\, \sigma \, e^{i x_0-\frac{\sigma ^2}{2}} \text{erfi}\left(\frac{\sigma ^2+i (x-x_0)}{\sqrt{2} \sigma }\right)$$ Trying to extract the real part of $K$ seems to be a small nightmare.

I have not been able to go beyond $$I=-\frac{1}{2} \sqrt{\frac{\pi }{2}} e^{-\frac{\sigma ^2}{2}} \sigma \left(e^{-i x_0} \text{erf}\left(\frac{x_0-i \sigma ^2-x}{\sqrt{2} \sigma }\right)+e^{i x_0} \text{erf}\left(\frac{x_0+i \sigma ^2-x}{\sqrt{2} \sigma }\right)\right)$$

• @NitaRatnawaty thanks you (I think). – user228113 Jun 24 '15 at 10:35
• You are welcome ! But I am not sure this helps much if you do not access the $\text{erf}$ function with complex arguments. Cheers :-) – Claude Leibovici Jun 24 '15 at 10:49
• @G.Sassatelli. Thanks for the message ! – Claude Leibovici Jun 24 '15 at 10:50

Mathematica 8 says it is

$$\int_{-L}^{L}\exp\!\left(-\frac{\left(x-x_{0}\right)^{2}}{2\sigma^{2}}\right)\cos\!\left(x\right)\mathrm{d}x = \frac{1}{2}\sqrt{\frac{\pi}{2}}s\exp\!\left(-\frac{1}{2}s^{2}-ix_{0}\right) \cdot$$ $$\cdot \left[\exp\!\left(2ix_{0}\right)\mathrm{erf}\!\left(\frac{L+is^{2}+x_{0}}{\sqrt{2}s}\right)-i\left(\exp\left(2ix_0\right)\mathrm{erfi}\!\left(\frac{s^{2}+i(L-x_{0})}{\sqrt{2}s}\right)-\mathrm{erfi}\!\left(\frac{-iL+s^{2}+ix_{0}}{\sqrt{2}s}\right)+\mathrm{erfi}\!\left(\frac{iL+s^{2}+ix_{0}}{\sqrt{2}s}\right)\right)\right]$$