# Thread: How to integrate cos(x)e-x^2 ?

1. ## How to integrate cos(x)e-x^2 ?

I'd love to know how to integrate

$
\int cos(x)e^{-x^2} \,dx
$

and evaluate

$
\int_{-\infty}^{+\infty}cos(x)e^{-x^2} \,dx
$
.

I hope the latex comes out OK.

Thanks for any ideas. I tried attacking the integral by doing it by parts, hoping for a bit of algebra in the style of sinx.e^x, but after two by parts, we end up with F = F if you know what I mean.

iota

2. Originally Posted by iota
I'd love to know how to integrate

$
\int \cos(x)e^{-x^2} \,dx
$

and evaluate

$
\int_{-\infty}^{+\infty} \cos(x)e^{-x^2} \,dx
$
.

I hope the latex comes out OK.

Thanks for any ideas. I tried attacking the integral by doing it by parts, hoping for a bit of algebra in the style of sinx.e^x, but after two by parts, we end up with F = F if you know what I mean.

iota
With correct LATEX formula

Wolfram Mathematica Online Integrator

3. Thanks very much for correcting the latex!

I would like to know how to go about solving this integral, not just the 'final' answer.

So if anyone could point me to a different technique than by parts that would be great. I tried u = x^2 substitution but made things worse!!

Regards,

iota.

4. As the Wolfram answer showed, it involves the error function, and so it can not be expressed in terms of elementary functions. You can approximate it using one of the various rules like Midpoint Rule or Simpson's Rule though...

5. Can we get anywhere with the definite integral between -inf and inf?

I'd settle for that! :-)

Is there some substitution involving imaginary numbers that would help?

6. Originally Posted by iota
Can we get anywhere with the definite integral between -inf and inf?

I'd settle for that! :-)

Is there some substitution involving imaginary numbers that would help?
You should write the whole question.
The problem asked you to evaluate the value of the improper integral or just determine its convergence/divergence?

7. The questions are the two integrals (corrected for me) above.

So far we know that the indefinite integral is restated as another integal via the error function.

What about the definite integral?

As we know the integral of e^-x^2 from -inf to inf, I'm hoping to transform my question into something similar via a substitution. It's going to be a complex substitution.

But I'm not good enough to get further ...

Any ideas for a substitution?

PS The actual thing I'm trying to solve is another integral, but this will do for starters as it's more simple, but probably involves same technique.

8. Originally Posted by iota

What about the definite integral?
$\int_{-\infty}^{\infty}\cos(x)e^{-x^2}dx=\text{Re}\,\int_{-\infty}^{\infty}e^{iz}e^{-z^2}dz$

$=\text{Re}\,\int_{-\infty}^{\infty}e^{-[(z-i/2)^2+1/4]}dz=e^{-1/4}\sqrt{\pi}$

9. Originally Posted by shawsend
$\int_{-\infty}^{\infty}\cos(x)e^{-x^2}dx=\text{Re}\,\int_{-\infty}^{\infty}e^{iz}e^{-z^2}dz$

$=\text{Re}\,\int_{-\infty}^{\infty}e^{-[(z-i/2)^2+1/4]}dz=e^{-1/4}\sqrt{\pi}$
Thanks shawsend, that's excellent.

e^-x^2 integrated is sqrt(pi). But how are you able to go from e^{-[(z-i/2)^2]} to that value in one step above? I thought it might be something like e^-(x-a)^2 is just e^-x^2 shifted to the right so has same integral with these limits. But there's an i in there which I'm sort of worrying about because I don't know anything about complex analysis.

If you could just help fill in this last query, that would make my weekend!

Cheers,

iota

10. Well if it was just real numbers that would make sense right like:

$\int_{-\infty}^{\infty} e^{-(x+1000)^2}dx$ and I just let $u=x+1000$ then the limits are still at $\pm \infty$ so I get the same answer. Probably could use that same argument for any constant $x+k$ even if k is complex but also if it's complex like:

$\int_{-\infty}^{\infty} e^{-(z+ai)^2}dz$

then I can consider a "contour integral" over a square contour which goes along the real axis, up $ai$ across then down $ai$ and the integral over the horizontal legs are zero so the integral over $z+ai$ is the same as the integral over $z$ by the Residue Theorem.

11. Originally Posted by shawsend
Well if it was just real numbers that would make sense right like:

$\int_{-\infty}^{\infty} e^{-(x+1000)^2}dx$ and I just let $u=x+1000$ then the limits are still at $\pm \infty$ so I get the same answer. Probably could use that same argument for any constant $x+k$ even if k is complex but also if it's complex like:

$\int_{-\infty}^{\infty} e^{-(z+ai)^2}dz$

then I can consider a "contour integral" over a square contour which goes along the real axis, up $ai$ across then down $ai$ and the integral over the horizontal legs are zero so the integral over $z+ai$ is the same as the integral over $z$ by the Residue Theorem.
Hi

Sorry for delay in reply. Had to sleep :-) I have had a brief look at the contour integration and the residue theorem. Thanks very much for the introduction! And I do understand your explanation. I will come back to this to fill in my knowledge for sure.

Now I've got the true problem to do which is the integral of cos(2x)*normal density from -inf to inf. Should fall out in a similar way hopefully. The whole point of this is I want to verify a Monte Carlo approximation and have had a nice excursion along the way.

Cheers!

iota

,
,
,

,

,

,

,

,

,

,

,

,

,

# integral of cos x exp x 2

Click on a term to search for related topics.