Contour integration of $\cos z^2$ I must calculate $\int^\infty_0\cos x^2 dx$, so I need to integrate $\cos z^2$ along a convenient closed path. Since $\cos z^2=\frac{e^{iz^2}+e^{-iz^2}} 2$, it seems to me that the only two useful paths could be 1) the one consisting of the segment $[-r,r]$ and the upper half of the circle of radius $r$ centered in $0$; 2) the one consisting of $[0,r]$, of $R=\{z\in \mathbb C: z = it$ for some $t\in [0,r]\}$ and of the quarter of circle necessary to close the path. However I must have misunderstood something at this point, because I have this problem: the function is entire, so the integral along a closed path (so both 1 and 2) is zero; if I call $I_r$ the integral $\int^r_0\cos x^2 dx$, I have that for 1) $\int_{[-r,0]}\cos z^2dz=I_r$, and for 2) I have $\int_R\cos z^2dz=iI_r$. So in both cases the integral along the arc of circle must be different from zero, or I'd have $I_r=0$, but it seems quite difficult to calculate it. Am I wrong with something? Thank you in advance
 A: You don't even need to use complex analysis.
$$e^{ix} = \cos{x} + i\sin{x}$$
$$e^{-ix^2} = \cos{(-x^2)} + i\sin{(-x^2)}=\cos{x^2} - i\sin{x^2}$$
So now if we integrate:
$$\int_{-\infty}^\infty e^{-ix^2}dx = \int_{-\infty}^\infty \cos{x^2}dx - i\int_{-\infty}^\infty \sin{x^2}dx$$
Gaussian integral is: $$\int_{-\infty}^\infty e^{-ax^2}dx = \sqrt{\frac{\pi}{a}}$$
So if we take $a=i$:
$$\sqrt{\frac{\pi}{i}} =\int_{-\infty}^\infty \cos{x^2}dx - i\int_{-\infty}^\infty \sin{x^2}dx$$
Know to clean up: $$\sqrt{\frac{\pi \cdot i}{i\cdot i}}= \sqrt{-\pi i} =\frac{i\sqrt{2 \pi}}{2}(\pm(1+i))$$ however, both integrals are positive so we take $-(1+i)$ and get:
$$ \int_{-\infty}^\infty \cos{x^2}dx - i\int_{-\infty}^\infty \sin{x^2}dx = -\frac{i\sqrt{2 \pi}}{2}+\frac{\sqrt{2 \pi}}{2}$$
Taking real and imaginary parts together we get:
$$\int_{-\infty}^\infty \cos{x^2}dx = \int_{-\infty}^\infty \sin{x^2}dx = \frac{\sqrt{2\pi}}{2}$$
A: $$\int_{0}^\infty cos(x^2)dx\buildrel{x^2\rightarrow z}\over{\overbrace{=}}\frac{1}{2}\int_{0}^\infty cos(z)z^{-\frac{1}{2}}dz=\frac{1}{2}\mathfrak{R}\left(\int_{0}^\infty e^{iz}z^{-\frac{1}{2}}dz\right)$$
We choose a quarter of the complex plane with a quarter cirlce deformation in the origin as our contour and define $f(z)=e^{iz}z^{-\frac{1}{2}}$
$$\oint{f(z)dz}=\left(\int_{r}^R+\int_\Gamma+\int_{iR}^{ir}+\int_\gamma\right) f(z)dz$$
Since there are no poles inside the contour $\oint{f(z)dz}=0$
Using the Estimation Lemma, it's easy to show that$\int_\Gamma f(z)dz\rightarrow0$ when $R\rightarrow\infty$ and that$\int_\gamma f(z)dz\rightarrow0$ when $r\rightarrow0$.
Hence:
$$\int_{r}^R f(z)dz=-\int_{iR}^{ir} f(z)dz\buildrel{z\rightarrow it}\over{\overbrace{=}}i\int_{r}^{R} f(it)dt$$
$$\int_{0}^\infty e^{iz}z^{-\frac{1}{2}}dz=ie^{-\frac{i\pi}{4}} \int_{0}^\infty e^{-t}t^{-\frac{1}{2}}dt=\frac{i}{\sqrt2}(1-i)\Gamma\left(\frac{1}{2}\right)=\frac{1+i}{\sqrt2}\sqrt{\pi}$$
Therefore, it's possible to conclude that:
$$\int_{0}^\infty cos(x^2)dx=\frac{1}{2}\mathfrak{R}\left(\frac{1+i}{\sqrt2}\sqrt{\pi}\right)=\frac{\sqrt{\pi}}{2\sqrt2}$$
$\textbf{Addendum:}$ 
If you don't need to provide a proof about this result, you could use the Mellin Transform of cosine and the result would be immediate:
$$\int_{0}^\infty cos(x^2)dx\buildrel{x^2\rightarrow z}\over{\overbrace{=}}\frac{1}{2}\int_{0}^\infty cos(z)z^{-\frac{1}{2}}dz=\frac{1}{2}\mathscr{M}\left(\cos(z)\right)_{s=\frac{1}{2}}=$$
$$\frac{1}{2}\left(\cos(\frac{s\pi}{2})\Gamma(s)\right)_{s=\frac{1}{2}}=\frac{\sqrt{\pi}}{2\sqrt2}$$
http://mathworld.wolfram.com/MellinTransform.html
https://en.wikipedia.org/wiki/Mellin_transform
