Issue with $\int_0^{\infty}\frac{\cos(x^2)}{x^2}dx$ I have stumbled into a issue with  gamma function, I will show the approach first: 
$$\Gamma(x)=\int_0^{\infty}t^{x-1}e^{-t}dt$$ subtituting $t=iu^2$ gives:
$$\Gamma(x)=2\int_0^{\infty}(iu^2)^{x-1}e^{-iu^2}iudu\rightarrow\frac{\Gamma(x)}{2i^x}=\int_0^{\infty}u^{2x-1}e^{-iu^2}du$$ Doing the same thing using $t=-iu^2\,$results in$$\frac{\Gamma(x)}{-2i^x}=\int_0^{\infty}u^{2x-1}e^{iu^2}du$$ Now, summing those two  and using that $i^x=e^{\frac{i\pi}{2}x} \,$gives
$$\frac{\Gamma(x)}{2}(e^{\frac{i\pi}{2}x}+e^{\frac{-i\pi}{2}x})=\int_0^{\infty}u^{2x-1}(e^{iu^2}+e^{-iu^2})du$$ which is just $$\frac{\Gamma(x)}{2}\cos(\frac{\pi}{2}x)=\int_0^{\infty}u^{2x-1}\cos(u^2)du$$ plugging $x=-\frac{1}{2}$ we get that$$\int_0^{\infty}\frac{\cos(x^2)}{x^2}dx=-\sqrt{\frac{\pi}{2}}$$ Well, obviously this integral diverges... But if Instead of summing we subtract we get that $$\frac{\Gamma(x)}{2}\sin(\frac{\pi}{2}x)=\int_0^{\infty}u^{2x-1}\sin(u^2)du$$ simmilarly with $$x=-\frac12 \rightarrow \int_0^{\infty}\frac{\sin(x^2)}{x^2}dx=\sqrt{\frac{\pi}{2}}$$ So its not that completely garbage. Now my question is, what goes wrong when I use the first substitution? And how do I prove that I am allowed to use this substitution for the sine integral? 
 A: When you make a change of variables in a definite integral, the integration limits change as well.
The question now is why your formulas are correct. The original integral converges for $\operatorname{Re} x > 0.$ When additionally $\operatorname{Re} x < 1$, the integral of $u^{2x-1} \exp(-i u^2)$ over the arc of a large circle between $\arg u = -\pi/4$ and $\arg u = 0$ is negligible and we don't have to take any singularities into account, therefore the integral over $[0, e^{-i \pi/4} \infty)$ is the same as the integral over $[0, \infty)$.
Similar reasoning for the second integral $-$ this time starting from $[0, e^{i \pi/4} \infty)$ $-$ shows that both the sine and the cosine formulas are correct for $0 < \operatorname{Re} x < 1$.
The integral of $u^{2x-1} \sin(u^2)$ is an analytic function on $-1 < \operatorname{Re} x < 1$, and the reason why the sine formula is correct for $-1 < \operatorname{Re} x < 1$ is the uniqueness of analytic continuation.
The cosine formula will be correct for $x = -1/2$ if you choose the regularization of the divergent integral that coincides with the analytic continuation. For $-2 < \operatorname{Re} x < 0$, that regularization is the integral of $u^{2x-1} (\cos(u^2) - 1)$.
A: $\small\underline{\text{For}\,\,Re\{s\}\gt0}$ :
$$ \Gamma(s)=\int_{0}^{\infty}\frac{x^{s-1}}{e^x}\,dx $$
Substitute $\{\,x=+it^2\quad\text{&}\quad x=-it^2\,\}$, subtract, add, and simplify to get:
$$
\begin{align}
\frac{\Gamma(s)}{2}\,\sin\left(\frac{\pi}{2}s\right) &=\int_{0}^{\infty}\frac{\sin\left(x^2\right)}{x^{1-2s}}\,dx \\[2mm] 
\frac{\Gamma(s)}{2}\,\cos\left(\frac{\pi}{2}s\right) &=\int_{0}^{\infty}\frac{\cos\left(x^2\right)}{x^{1-2s}}\,dx 
\end{align}
$$

$\small\underline{\text{For}\,\,-1\lt Re\{s\}\lt0}$ :
$$ \Gamma(s)=\int_{0}^{\infty}x^{s-1}\left(\frac{1}{e^x}\color{red}{-1}\right)\,dx $$
Substitute $\{\,x=+it^2\quad\text{&}\quad x=-it^2\,\}$, subtract, add, and simplify to get:
$$
\begin{align}
\frac{\Gamma(s)}{2}\,\sin\left(\frac{\pi}{2}s\right) &=\int_{0}^{\infty}\frac{\sin\left(x^2\right)}{x^{1-2s}}\,dx \\[2mm] 
\frac{\Gamma(s)}{2}\,\cos\left(\frac{\pi}{2}s\right) &=\int_{0}^{\infty}\frac{\cos\left(x^2\right)\color{red}{-1}}{x^{1-2s}}\,dx 
\end{align}
$$

$\{\,\color{red}{-1}\,\}$ cancelled each other in sine, and added to each other in cosine.


Nevertheless, do not forget to re-calculate the integration limits whenever you change the integration variable.




$$ \small\Gamma(s-N)=\int_0^\infty x^{s-1-N}\,\left[\,\frac1{e^x}-\sum_{n=0}^N (-1)^n\,\frac{x^n}{n!}\,\right]\,dx \quad\colon -1\lt Re\{s\}\lt0,\,\,N\in\{0,\,1,\,2,\,\dots\,\} $$ 

A: What you get when you substitute, say, $t=iu$ into an integral 
$$ \int_a^b f(t)\; dt$$
where $a, b \in \mathbb R$ is an integral over a path in the complex plane
$$ i \int_C f(iu)\; du$$
where $C$ is a path consisting of points mapped into the interval $[a,b]$ by
the mapping $u \mapsto iu$.
