I have a physical problem that yielded the following integral
$$ I(a,b) = \int\limits_0^{\infty}J_0(ax)\exp\left(-i\frac{bx^2}{2}\right)dx $$ where $a,b>0$, $J_0$ is the zeroth order Bessel function of the first kind. I used Mathematica, and found that
$$ I(a,b) = \sqrt{\frac{\pi}{2b}}\exp\left(i\frac{a^2}{4b}-i\frac{\pi}{4}\right)J_0\left(\frac{a^2}{4b}\right) $$
I am interested in the behavior of $I(a,b)$ as $b\to 0$. Naively, plugging $b=0$ gives $$ I(a,0) =\int\limits_0^{\infty}J_0(ax)dx = \frac{1}{a} $$
However, using the asymptotic expansion of $J_0(x)$ as $x\to\infty$, I find $$ J_0\left(x\right)\sim \sqrt{\frac{2}{\pi}}\frac{\cos\left(x-\frac{\pi}{4}\right)}{\sqrt{x}} = \frac{1}{2}\sqrt{\frac{2}{\pi x}}\left(e^{ix-i\pi/4}+e^{-ix+i\pi/4}\right)\Longrightarrow J_0\left(\frac{a^2}{4b}\right)\sim \frac{1}{2}\sqrt{\frac{2}{\pi}}\frac{2\sqrt{b}}{a}\left(e^{i\frac{a^2}{4b}-i\pi/4}+e^{-i\frac{a^2}{4b}+i\pi/4}\right) $$
and therefore
$$ I(a,b)\sim\frac{1}{a}\left(1+e^{i\frac{a^2}{2b}-i\pi/2}\right) $$
which is not asymptotic to $1/a$.
Now I know that changing limits and integral signs is in general not allowed. However I am trying to understand why this residual is there and does not vanish.
Is there a contour integral one might take in order to eliminate this residual? I guess there is a pole somewhere
You may be seeing effects associated with the integrand not being uniformly asymptotic to $J_0(ax)$. No matter how small you make $b$, without taking it to zero, there will be some value of $x$ where $\exp(-ibx^2/2)$ is $-1$ (or any other value of unit modulus) instead of $+1$, so the intended limiting ratio
$\dfrac{J_0(ax)\exp(-ibx^2/2)}{J_0(ax)}\to1$
does not obtain.
This would not alter the leading asymptotic behavior if the integral were absolutely dominated by small values of $x$, as rendered by the absolute convergence criterion
$\int_0^{\infty}|J_0(ax)|dx<\infty.$
But this fails also, so the magnitude of the integrand remains large enough for the asymptotic nonuniformity at large values of $x$ to interfere with the expected $1/a$ leading behavior. The oscillating term is really there.
Yet the $1/a$ behavior is not really lost. Plot the function you found from the integrated expression as a function of $b$; observe that it oscillates wildly as $b\to0$. With that in mind, consider what would happen if $b$ were not rendered as a point value $b=b_0$, but had some variability -- say, $0.9b_0\le b\le 1.1b_0$. Then as $b_0\to0$, the uncertainty range covers more and more of these oscillations and causes them to average out to zero. Similarly the oscillations will grow more numerous and tend towards a zero average if $b$ is considered certain but some variance is allowed in $a$. Then, in a physical setting where some variables are bound to be uncertain, we do indeed get $1/a$ as an averaged asymptotic behavior after all.