# Contour integration appears to be wrong. Why?

I want to solve the following integral using contour integration:

$$I = \int_0^{\infty} \frac{e^{i x}}{x^2 +1} dx. \tag{1}$$

I built a contour consisting of three paths: $$A$$ (going from 0 to $$\infty$$), $$B$$ (going from $$-\infty$$ to 0 ) and $$C$$ the upper semicircle.

I define

$$f(z) = \frac{e^{i |z|}}{z^2+1}, \tag{2}$$

where $$|\cdot|$$ stands for the modulus of a complex number.

I have that

$$\oint f(z) dz = \left( \int_A + \int_B + \int_C \right) f(z) dz. \tag{3}$$

Now,

$$\int_{A} f(z) dz = \int_0^{\infty} f(x) dx = I, \tag{4}$$ since $$|x| = x$$ if $$x \geq 0$$.

Likewise,

$$\int_{B} f(z) dz = \int_{-\infty}^0 f(x) dx = - \int_{\infty}^0 f(-x) dx = \int_0^{\infty} \frac{e^{i |- x|}}{(-x)^2+1} = \int_0^{\infty} \frac{e^{i x}}{x^2+1} = I. \tag{5}$$

The integral over the contour $$C$$ is 0 when the semicircle is "at" $$\infty$$.

I evaluate the l.h.s of Eq. $$(3)$$ using Cauchy's theorem, and I find

$$\oint f(z) dz = 2 \pi i \frac{e^{i |i|}}{2 i} = \pi e^i. \tag{6}$$

Putting all together I find that

$$I = \frac{\pi}{2} e^i \approx 0.848705 + 1.32178 i, \tag{7}$$

whereas Mathematica says that

$$I \approx 0.577864 + 0.646761 i. \tag{8}$$

What is wrong with my reasoning?

• Your function $f(z)$ is not analytic. You cannot apply Cauchy's Theorem or the Residue Theorem to this function. – Kavi Rama Murthy May 20 at 7:27
• @KaviRamaMurthy Thank you for your answer. Does it exist an extension of the Cauchy's Theorem for non-analytic functions which would allow me to calculate the l.h.s easily? (For more involved reasons I don't want to have $x^2$ in the exponent). – Mat May 20 at 7:37
• There is a solution by contour integration here. – Maxim May 20 at 10:48