# Why are these indefinite integrals nonzero?

$$\int_0^\infty \int_0^\infty e^{-x^2}\cos(2xn)\,dx\,dn = \pi$$

or

$$\int_0^\infty \int_0^\infty e^{-x} \cos(2xn)\,dx\,dn = \pi$$

==

the number in the cosine will just scale it. but doesn't it look like it would cancel out over the first quadrant of the plane or for the first one the entire plane. i thought if you fix x and integrate over n first it would cancel out or at least not take on a particular value. so how can you then integrate over x and have it return a single value. if the indefinite integral of cosine or sine on its own has little meaning than why do these?

the reason i came to considering the first one was i tried to do a contour integral with $e^{-z^2}$ and got $$\int_{-\infty}^\infty e^{-x^2+n^2}\cos(2nx)\,dx=\int_{-\infty}^\infty e^{-x^2} \,dx$$ for any $n$

when you multiply both sides by $e^{-n^2}$ you get this identity here https://en.wikipedia.org/wiki/Common_integrals_in_quantum_field_theory#Integrals_with_an_imaginary_linear_term_in_the_argument_of_the_exponent but then integrating over n brings you to

$$\int_0^\infty \int_0^\infty e^{-x^2} \cos(2xn)\,dx\,dn = \big(\int_0^\infty e^{-x^2} \, dx \big)^2=\pi/4$$

i thought maybe there could be a simple way to show the integral on the left is $\pi$ without knowing the value of the gaussian integral but the integral seems too weird.

• Use integration by parts to evaluate the two integrals. Then can you see why they are non-zero. – Varun Iyer Aug 3 '14 at 2:59

You can compute the integral without using the Gaussian integral by using polar coordinates and some complex analysis:

$$\int_{0}^{\infty}\int_{0}^{\infty}e^{-x^{2}}\cos(2xn)dxdn=\frac{1}{4}\mathcal{Re}\bigg(\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-(x^{2}-2ixn)}dxdn\bigg)$$

$$=\frac{1}{4}\mathcal{Re}\bigg(\int_{-\infty}^{\infty} e^{-n^{2}}\int_{-\infty}^{\infty}e^{-(x-in)^{2}}dx\bigg)=\frac{1}{4}\mathcal{Re}\bigg(\int_{-\infty}^{\infty}e^{-n^{2}}\int_{-\infty}^{\infty}e^{-u^{2}}dudn \bigg)$$

$$=\frac{1}{4}\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}e^{-(x^{2}+y^{2})}dxdy=\frac{1}{4}\int_{0}^{\infty}\int_{0}^{2\pi}re^{-r^{2}}drd\theta=\frac{1}{4}(\pi)\int_{0}^{\infty}e^{-w}dw=\frac{\pi}{4}$$

For sure, the most elegant way is the one proposed by user71352 but they are also simple step by step algebraic calculation which can be done.

For the first integral

$$\int e^{-x^2}\cos(2xn)\,dx = \frac{1}{4} i \sqrt{\pi } e^{-n^2} (\text{erfi}(n-i x)-\text{erfi}(n+i x))$$ $$\int_0^{\infty} e^{-x^2}\cos(2xn)\,dx =\frac{1}{2} \sqrt{\pi } e^{-n^2}$$ $$\int \frac{1}{2} \sqrt{\pi } e^{-n^2}\,dn =\frac{\pi}{4} \text{erf}(n)$$ $$\int_0^{\infty} \frac{1}{2} \sqrt{\pi } e^{-n^2}\,dn =\frac{\pi}{4}$$

For the second integral

$$\int e^{-x}\cos(2xn)\,dx = \frac{e^{-x} (2 n \sin (2 n x)-\cos (2 n x))}{4 n^2+1}$$ $$\int_0^{\infty} e^{-x}\cos(2xn)\,dx = \frac{1}{4 n^2+1}$$ $$\int \frac{dn}{4n^2+1}=\frac{1}{2} \tan ^{-1}(2 n)$$ $$\int_0^{\infty} \frac{dn}{4n^2+1}=\frac{\pi }{4}$$