# Evaluate the integral $\int_0^{+\infty} \frac{\sin(x^2)}{x^4+1} dx$ using the residue method

I have a problem in evaluating the integral above. So far I've proceeded in this way. We have an even function, so:

$$\int_0^{+\infty} \frac{\sin(x^2)}{x^4+1} dx = \frac{1}{2} \int_{-\infty}^{+\infty} \frac{\sin(x^2)}{x^4+1} dx$$

Then we choose the complex function:

$$f(z) = \frac{e^{iz^2}}{z^4+1} \qquad \forall z \in \mathbb{C} /\{ e^{i\frac{\pi + 2k\pi}{4}} \} \qquad k= 0,1,2,3$$

Then we choose the integration path $\gamma$ consisting of the real axis from $-R$ to $+R$ and the upper semicircle $\Gamma$ of radius $R$. So we will have:

$$2 \pi i \left(\text{Res}(f, e^{i\pi \over 4}) +\text{Res}(f, e^{i3\pi \over 4}) \right) = \oint_{+\gamma} f(z)dz =\\= \int_{-R}^{+R} f(z)dz + \int_{+\Gamma}f(z)dz$$

Taking the limit $R \to +\infty$ we can prove that the integral over $\Gamma$ is $0$. After some calculation and taking the imaginary part of the integral I obtain:

$$\int_0^{+\infty} \frac{\sin(x^2)}{x^4+1} dx = \frac{\pi}{4\sqrt{2}}\left( e - \frac{1}{e} \right) \simeq 1.31$$

But, if I compute this integral on a computer, it gives me $0.37$. What is wrong with my reasoning ?

• How do you justify that $\int_{+\Gamma}f(z)dz \to 0$ ? – C. Dubussy Jun 14 '16 at 9:30
• By taking the limit $\lim_{z \to \infty} \frac{ze^(iz^2)}{z^4+1}$, which is 0 because: $0 \leqslant | \frac{ze^(iz^2)}{z^4+1} | \leqslant \frac{1}{z^3} \to 0$. So I can conclude by a lemma that the integral is 0 (In my country is called like ''big circle lemma'', but I don't know if is something similar to what you studied) – Nunzio Damino Jun 14 '16 at 9:33
• Ok here is the mistake. In your inequality you used the fact that $|e^{iz^2}| \leq 1$ which is NOT true. (It is true if $z$ is real but not if it is complex, for exemple take $z =\sqrt{-i}$). – C. Dubussy Jun 14 '16 at 9:42
• Thank you, I didn't realize this, but as you can see, the limit is still 0 : link – Nunzio Damino Jun 14 '16 at 9:52
• I guess wolfram computed it by assuming that $z$ is real. Here is a proof that the limit is not $0$. Set $g(z) = \frac{ze^{iz^2}}{z^4+1}$. If $g(z) \to 0$ when $z \to \infty$ then in particular we must have $\lim_{m\to +\infty} |g(m\sqrt{-i})| = 0$. But $|g(m\sqrt{-i})| = \frac{me^{m^2}}{m^4-1} \to +\infty$ when $m\to +\infty.$ – C. Dubussy Jun 14 '16 at 10:05

If $$I(x)=\int_0^{\infty}\frac{\sin(xt^2)}{t^4+1}dt$$ Then $$I^{\prime\prime}-I=-\int_0^{\infty}\sin(xt^2)dt==\frac1{\sqrt x}\int_0^{\infty}\sin(t^2)dt=-\frac{\sqrt\pi}{2\sqrt2}x^{-1/2}$$ By the properties of Fresnel integrals. Then we can use variation of parameters $$I(x)=u(x)e^x+v(x)e^{-x}$$ $$I^{\prime}(x)=u^{\prime}e^x+v^{\prime}e^{-x}+ue^x-ve^{-x}=ue^x-ve^{-x}$$ Where we have use one degree of freedom to set $$u^{\prime}e^x+v^{\prime}e^{-x}=0$$ Then $$I^{\prime\prime}(x)-I(x)=u^{\prime}e^x-v^{\prime}e^{-x}=2u^{\prime}e^x=-2v^{\prime}e^{-x}=-\frac{\sqrt{\pi}}{2\sqrt2}x^{-1/2}$$ Solutions: $$u=-\frac{\sqrt{\pi}}{4\sqrt2}\int x^{-1/2}e^{-x}dx=\frac{\sqrt{\pi}}{4\sqrt2}\left[c_1-\int_0^xt^{-1/2}e^{-t}dt\right]$$ $$v=\frac{\sqrt{\pi}}{4\sqrt2}\int x^{-1/2}e^xdx=\frac{\sqrt{\pi}}{4\sqrt2}\left[c_2+\int_0^xt^{-1/2}e^tdt\right]$$ So that makes $$I(x)=\frac{\sqrt{\pi}}{4\sqrt2}\left[c_1e^x+c_2e^{-x}+\int_0^xt^{-1/2}\left(e^{t-x}-e^{x-t}\right)dt\right]$$ Now, $$I(0)=0=\frac{\sqrt{\pi}}{4\sqrt2}(c_1+c_2)$$ And hopefully we can see that $$\lim_{x\rightarrow\infty}I(x)=\lim_{x\rightarrow\infty}c_2e^{-x}=\lim_{x\rightarrow\infty}\int_0^xt^{-1/2}e^{t-x}dt=0$$ So that requires $$c_1=-c_2=\int_0^{\infty}t^{-1/2}e^{-t}dt=\Gamma\left(\frac12\right)=\sqrt{\pi}$$ So now we want $$I(1)=\frac{\sqrt{\pi}}{4\sqrt2}\left[2\sqrt{\pi}\sinh(1)-2\int_0^1t^{-\frac12}\sinh(1-t)dt\right]$$ Wolfram|Alpha expresses that last integral as $$\int_0^1t^{-\frac12}\sinh(1-t)dt=\frac{\sqrt{\pi}\left(e^2\text{erf}(1)-\text{erfi}(1)\right)}{2e}\approx1.491998962365937$$ And it does in fact add up to about $0.370348638$, so even with the somewhat shaky exposition above, it may be correct.

• You beat me to it :-) – joriki Jun 14 '16 at 19:10
• I really appreciate your answer (even yours @joriki), but I'm looking for a more straightforward approach, because this integral is part of a previous test given by my professor, so it should be done in a time limit. Furthermore I've no understanding of special function like Euler's gamma and whatsoever, so I look for a method that doesn't imply them. – Nunzio Damino Jun 14 '16 at 19:28
• I ask the same question as I asked to @joriki: How do you justify the second differentiating under the integral sign? I'm not asking because I think it is wrong (in fact, after getting a clarification by joriki I'm convinced it is true) but rather because I'm curious if I can learn some nice way of arguing/estimating/majorizing that I've not thought about. – mickep Jun 17 '16 at 17:03
• I'm not a mathematician, so my justification isn't going to be very satisfying, but my understanding was that uniform convergence of $I^{\prime\prime}(x)$ was the biggest chunk of what you need for the differentiation to work. Of course here $I^{\prime\prime}(0)$ doesn't converge at all so that may be a problem. Just looking at the answer you get, it's hard to see you to arrive at it by other means. @joriki has the same situation where he has $c^{\prime\prime}(a)$ undefined at $a=0$ and uses $f(0)$ to determine constants. – user5713492 Jun 17 '16 at 18:27
• It seems that the second differentiation can be justified if one first integrate by parts. – mickep Jun 19 '16 at 17:47

Introduce a parameter $a$ and differentiate under the integral sign:

\begin{align} f(a)&=\int_0^\infty\frac{\mathrm e^{-\mathrm iax^2}}{1+x^4}\mathrm dx\;, \\ f''(a)&=-\int_0^\infty\frac{x^4\mathrm e^{-\mathrm iax^2}}{1+x^4}\mathrm dx\;, \\ f(a)-f''(a)&=\int_0^\infty\mathrm e^{-\mathrm iax^2}\mathrm dx\\ &= \sqrt{\frac\pi{4\mathrm ia}} \;, \end{align}

valid for $\Im a\lt0$. This differential equation can be solved using variation of constants. A solution of the homogoeneous equation is $f(a)=c\mathrm e^a$, so we use the ansatz $f(a)=c(a)\mathrm e^a$ to obtain

$$-2c'(a)-c''(a)=\sqrt{\frac\pi{4\mathrm ia}}\mathrm e^{-a}\;.$$

With $g(a)=c'(a)$, a solution of the homogeneous equation is $g(a)=d\mathrm e^{-2a}$, so we use the ansatz $g(a)=d(a)\mathrm e^{-2a}$ to obtain

$$-d'(a)=\sqrt{\frac\pi{4a}}\mathrm e^a\;.$$

Thus a particular solution is given by

\begin{align} d(a)&=-\int_0^a\sqrt{\frac\pi{4\mathrm ix}}\mathrm e^{x}\mathrm dx \\ &=-\int_0^\sqrt{a}\sqrt{\frac\pi{\mathrm i}}\mathrm e^{u^2}\mathrm du\\ &=-\frac\pi{2\sqrt{\mathrm i}}\operatorname{erfi}\left(\sqrt a\right)\;. \end{align}

Thus

\begin{align} c'(a)&=g(a)\\ &=d(a)\mathrm e^{-2a}\\ &=-\frac\pi{2\sqrt{\mathrm i}}\operatorname{erfi}\left(\sqrt a\right)\mathrm e^{-2a}\;, \end{align}

and a particular solution can be obtained by integration by parts:

\begin{align} c(a)&=-\frac\pi{2\sqrt{\mathrm i}}\int_0^a\operatorname{erfi}\left(\sqrt x\right)\mathrm e^{-2x}\mathrm dx \\ &=-\frac\pi{2\sqrt{\mathrm i}}\left(\left[-\frac12\operatorname{erfi}\left(\sqrt x\right)\mathrm e^{-2x}\right]_0^a+\int_0^a\frac1{2\sqrt{\pi x}}\mathrm e^{-x}\mathrm dx\right) \\ &=\frac\pi{4\sqrt{\mathrm i}}\left(\operatorname{erfi}(\sqrt a)\mathrm e^{-2a}-\operatorname{erf}\left(\sqrt a\right)\right)\;. \end{align}

Thus the general solution for $f$ is

$$f(a)=\frac\pi{4\sqrt{\mathrm i}}\left(\operatorname{erfi}\left(\sqrt a\right)\mathrm e^{-2a}-\operatorname{erf}\left(\sqrt a\right)\right)\mathrm e^a+c_+\mathrm e^a+c_-\mathrm e^{-a}\;.$$

The initial conditions are

$$f(0)=\int_0^\infty\frac1{1+x^4}\mathrm dx=\frac\pi{2\sqrt2}$$

and

$$f'(0)=\int_0^\infty\frac{-\mathrm ix^2}{1+x^4}\mathrm dx=-\mathrm i\frac\pi{2\sqrt2}\;,$$

and since the particular solution and its derivative are $0$ at $a=0$, we have

$$c_++c_-=\frac\pi{2\sqrt2}$$

and

$$c_+-c_-=-\mathrm i\frac\pi{2\sqrt2}\;,$$

so

$$c_\pm=\frac\pi{4\sqrt2}(1\mp\mathrm i)$$

and

$$f(a)=\frac\pi{4\sqrt{\mathrm i}}\left(\operatorname{erfi}\left(\sqrt a\right)\mathrm e^{-a}-\operatorname{erf}\left(\sqrt a\right)\mathrm e^a\right)+\frac\pi{2\sqrt2}(\cosh a-\mathrm i\sinh a)\;.$$

Now we can take the limit $a\to1$ (for which $f(a)$ was originally not defined) to obtain

\begin{align} \int_0^\infty\frac{\sin\left(x^2\right)}{1+x^4}\mathrm dx &=-\Im\lim_{a\to\mathrm 1}\,f(a) \\ &= \frac{\pi}{4\sqrt2}\left(2\sinh1+\operatorname{erfi}(1)\mathrm e^{-1}-\operatorname{erf}(1)\mathrm e\right) \\ &\approx0.370349\;. \end{align}

• How do you motivate the second differentiation under the integral sign, i.e. $f''(a)$. I don't say it is wrong, I just don't see how the motivation goes. – mickep Jun 17 '16 at 14:54
• @mickep: To be honest, I wasn't too concerned with rigour, I was happy to get the calculation to work :-). But I thought that the restriction $\Im a\lt0$ should solve all such convergence issues, since the integrand decays exponentially no matter how many powers the differentiation produces. Is that not the case? (I think in taking the limit $a\to1$ in the end, I'm only relying on the continuity of the original integral, not on convergence in any of the intermediary steps.) – joriki Jun 17 '16 at 16:38
• Thank you! I missed the $\Im a<0$ part. I think your argument is fine. (I'll ask @user5713492 the same question, since in that answer I see no exponentially decreasing factor that saves the situation, and I'm curious if the problem (with finding a majorizing function for example) easily can be taken care of anyways, or if one should use some argument like yours.) – mickep Jun 17 '16 at 16:59

As has been pointed out in comments, your approach doesn't work because the integral over the semicircle doesn't converge.

Here's another approach that also doesn't quite work. Instead of adding the negative real axis, we can add the positive imaginary axis. Let

$$I=\int_0^\infty\frac{\mathrm e^{\mathrm ix^2}}{x^4+1}\mathrm dx\;,$$

so that the desired integral is the imaginary part of $I$. Then

$$\int_{\mathrm i\infty}^0\frac{\mathrm e^{\mathrm iz^2}}{z^4+1}\mathrm dz=-\mathrm i\overline I\;.$$

Now we can complete the contour with a quarter circle in the first quadrant, where the integrand decays sufficiently rapidly. This contour encloses the pole at $z=\mathrm e^{\frac\pi4\mathrm i}$, with residue

\begin{align} \frac{\mathrm e^{-1}}{\prod_{k=1}^3\left(\mathrm e^{\frac\pi4\mathrm i}-\mathrm e^{(2k+1)\frac\pi4\mathrm i}\right)} &= \frac{\mathrm e^{-1}}{(\sqrt2)(\sqrt2\mathrm i)(\sqrt2+\sqrt2\mathrm i)} \\ &= -\frac{1+\mathrm i}{4\sqrt2\mathrm e}\;. \end{align}

Thus

\begin{align} I-\mathrm i\overline I &= -2\pi\mathrm i\frac{1+\mathrm i}{4\sqrt2\mathrm e} \\ &= \frac{\pi}{2\sqrt2\mathrm e}(1-\mathrm i)\;. \end{align}

But unfortunately this merely tells us that

$$\Re I-\Im I=\frac{\pi}{2\sqrt2\mathrm e}$$

and doesn't yield the imaginary part separately.

• So, how I should solve it ? – Nunzio Damino Jun 14 '16 at 12:10