I have shown that
$$\int^\infty_0 e^{ix^2}dx = \dfrac{\sqrt\pi}{2},$$
using contour integration on $f(z) = e^{iz^2}$. But since
$$\int^\infty_0 e^{ix^2}dx = \int^\infty_0 (\cos x^2+ i \sin x^2) dx = \dfrac{\sqrt\pi}{2}, $$ I would have thought equating the imaginary and real parts would do the trick. But this just gives wrong answers. What's wrong here?