How calculate $\quad \int_0^\infty \frac{\cos(x^2)}{1+x^2} dx$ How calculate
$$\int_0^\infty \frac{\cos(x^2)}{1+x^2}\;dx$$
$\mathbf {My Attempt}$  
I tried introducing a new parameter and differentiating twice like this:
$$I(a)=\int_0^\infty \frac{\cos(ax^2)}{1+x^2}\;dx \quad \Rightarrow$$
$$I^{''}(a)+I(a)=\frac{\sqrt{\pi}}{\sqrt{2}}a^{\frac{-1}{2}}+\frac{\sqrt{\pi}}{2\sqrt{2}}a^{\frac{-3}{2}}$$
I'm unable to come up with a particular solution for this differential equation.  
I tried using a double integral like this:
$$\int_0^\infty e^{-y(1+x^2)}\; dy = \frac1{1+x^2} \quad\Rightarrow$$
$$\int_0^\infty \int_0^\infty \cos(x^2)\; e^{-y(1+x^2)}\; dy\,dx = \int_0^\infty\frac{\cos(x^2)}{1+x^2}\; dx$$
But this wasn't that useful.  
Result by Wolfram (Mathematica): $$-\frac{1}{2} \pi  \left[\sin (1) \left(S\left(\sqrt{\frac{2}{\pi    }}\right)-C\left(\sqrt{\frac{2}{\pi }}\right)\right)+\cos (1)    \left(C\left(\sqrt{\frac{2}{\pi }}\right)+S\left(\sqrt{\frac{2}{\pi    }}\right)-1\right)\right] $$
Any hint? (I'm not familiar with the Residue Theorem)
 A: Using the complex representation makes the problem solvable with a first order ODE.
$$I(a)=\int_0^\infty\frac{e^{iax^2}}{x^2+1}dx,$$
$$I'(a)=i\int_0^\infty x^2\frac{e^{iax^2}}{x^2+1}dx,$$
$$I'(a)+iI(a)=i\int_0^\infty e^{iax^2}dx=wa^{-1/2},$$ where $w$ is a complex constant (namely $(i-1)\sqrt{\pi/8}$).
Then by means of an integrating factor,
$$(I'(a)+iI(a))e^{ia}=(I(a)e^{ia})'=wa^{-1/2}e^{ia}$$
and integrating from $a=0$ to $1$,
$$I(a)e^{ia}-I(0)=w\int_0^1a^{-1/2}e^{ia}da=2w\int_0^1e^{ib^2}db=2w(C(1)+iS(1)).$$
Finally,
$$I(a)=\left(2w(C(1)+iS(1))+I(0)\right)e^{-i}$$ of which you take the real part. (With $I(0)=\pi/2$.)

Note that we have been using the Fresnel integral without the $\pi/2$ factor in its definition, and this answer coincides with those of the CAS softwares.
A: $$J=\int^\infty_0\frac{\cos(x^2)}{1+x^2}dx=\Re\int^\infty_0\frac{e^{ix^2}}{1+x^2}dx=\Re\,\, e^{-i}\underbrace{\int^\infty_0\frac{e^{ia(x^2+1)}}{1+x^2}dx}_{=I(a)}$$ where $a=1$.
Restrict $a$ to be real non-negative.
$$I'(a)=ie^{ia}\int^\infty_0e^{iax^2}dx$$
By the substitution $-u=iax^2$, we get 
$$I'(a)=\frac12ie^{ia}\sqrt{\frac{i}a}\int^{-i\infty}_0u^{-1/2}e^{-u}du=\frac{i^{3/2}}2\frac{e^{ia}}{\sqrt a}\sqrt\pi$$
Let $k=\frac{i^{3/2}}2\sqrt\pi$.
$$I(a)=k\int\frac{e^{ia}}{\sqrt a}da$$
By the substitution $ia=-v$, we get 
$$I(a)=k\sqrt i\int\frac{e^{-v}}{\sqrt v}dv=-\frac{\sqrt\pi}2\gamma(\frac12,v)+C=-\frac{\sqrt\pi}2\gamma(\frac12,-ia)+C$$
Because $I(0)=\frac{\pi}2$, so $C=\frac{\pi}2$.
Since $\gamma(\frac12,x)=\sqrt\pi\text{erf}(\sqrt x)$,
$$I(a)=-\frac{\pi}2\text{erf}(\sqrt {-i}\sqrt a)+\frac\pi2=\frac\pi2\text{erfc}(\overbrace{e^{-\pi i/4}}^{\text{principal value}}\cdot\sqrt a)$$
As a result, $$J=\Re e^{-i}I(1)=\frac\pi2\,\Re\,\, e^{-i}\text{erfc}(e^{-\pi i/4})$$
Note that $I(1)=-\frac{\sqrt\pi}2\gamma(\frac12,-i)+\frac\pi2$ is wrong if you calculate it using Wolfram Alpha. However, an equivalent expression $I(1) = \frac\pi2\text{erfc}(e^{-\pi i/4})$ is correct as calculated by Wolfram Alpha. I don't know why $-\frac{\sqrt\pi}2\gamma(\frac12,-i)+\frac\pi2\ne \frac\pi2\text{erfc}(e^{-\pi i/4})$. I suspect this might be a bug of Wolfy.
