<s>[INST] How to evaluate $\int_{0}^{+\infty} \cos(x^2)\cos(x)dx$ How do I evaluate $\int_{0}^{+\infty} \cos(x^2)\cos(x)dx$?
I don't know what to do. Should I use a contour integration?
 [/INST] Let $I$ be the desired integral. Then, by the product-to-sum trigonometric identity,
\begin{align*}
2I&=\int_{0}^{+\infty} \cos (x-x^2)\,dx+\int_{0}^{+\infty} \cos (x^2+x)\,dx\\
&=\int_{0}^{+\infty} \cos ((x-1/2)^2-1/4)\,dx+\int_{0}^{+\infty} \cos ((x+1/2)^2-1/4)\,dx\\
&=\cos(1/4)\int_{0}^{+\infty} \cos ((x-1/2)^2)\,dx+\sin(1/4)\int_{0}^{+\infty} \sin((x-1/2)^2)\,dx\\
&\quad+\cos(1/4)\int_{0}^{+\infty} \cos ((x+1/2)^2)\,dx+\sin(1/4)\int_{0}^{+\infty} \sin ((x+1/2)^2)\,dx\\
&=\cos(1/4)\int_{-1/2}^{+\infty} \cos (x^2)\,dx+\sin(1/4)\int_{-1/2}^{+\infty} \sin(x^2)\,dx\\
&\quad+\cos(1/4)\int_{1/2}^{+\infty} \cos (x^2)\,dx+\sin(1/4)\int_{1/2}^{+\infty} \sin (x^2)\,dx.
\end{align*}
By the Fresnel integrals,
$$\int_{0}^{+\infty} \cos (x^2)\,dx=\int_{0}^{+\infty} \sin (x^2)\,dx=\sqrt{\pi/8},$$
we obtain
\begin{align*}
\int_{-1/2}^{+\infty} \cos (x^2)\,dx+\int_{1/2}^{+\infty} \cos (x^2)\,dx&=\int_{-1/2}^{0} \cos (x^2)\,dx +\sqrt{\pi/8}\\
&\quad+\sqrt{\pi/8}-\int_{0}^{1/2} \cos (x^2)\,dx=2\sqrt{\pi/8}
\end{align*}
and
\begin{align*}
\int_{-1/2}^{+\infty} \sin (x^2)\,dx+\int_{1/2}^{+\infty} \sin (x^2)\,dx&=\int_{-1/2}^{0} \sin(x^2)\,dx +\sqrt{\pi/8}\\
&\quad+\sqrt{\pi/8}-\int_{0}^{1/2} \sin(x^2)\,dx=2\sqrt{\pi/8}
\end{align*}
Hence
$$I=\sqrt{\pi/8}\left(\cos(1/4)+\sin(1/4)\right)=
\frac{\sqrt{\pi}}{2}\cos\left(\frac{\pi-1}{4}\right).$$
</s>