In a Quantum Mechanics class the professor pointed out a calculation from Zetilli's textbook on Quantum Mechanics (page 630).
There he says that:
$$\int_0^\infty \sin(qx) dx = \lim_{\lambda \to 0} \int_0^\infty e^{-\lambda x} \sin(qx) dx$$
Then he writes the $\sin$ as complex exponentials and reaches the result that the integral is $1/q$. WHAT? I was taught at my calculus course that this integral does not converge. For me this result is plain wrong, and I do not understand it at all. I even don't see why the limit can be imposed like that. Any thoughts on this "trick"?
Since $$ \newcommand{\Im}{\operatorname{Im}} \int_0^\infty\sin(qx)\,\mathrm{d}x= \Im\left(\int_0^\infty e^{iqx}\,\mathrm{d}x\right)\tag1 $$ in the spirit of analytic continuation, we can look at $$ f(q)=\int_0^\infty e^{iqx}\,\mathrm{d}x\tag2 $$ which is well-defined for $\Im(q)\gt0$, and see how $f$ behaves as $\Im(q)\to0$.
When $\Im(q)\gt0$, we get, via contour integration, $$ \begin{align} f(q) &=\frac iq\int_0^{-iq\infty} e^{-x}\,\mathrm{d}x\tag{3a}\\ &=\frac iq\int_0^\infty e^{-x}\,\mathrm{d}x\tag{3b}\\ &=\frac iq\tag{3c} \end{align} $$ Explanation:
$\text{(3a)}$: substitute $x\mapsto\frac{ix}q$
$\text{(3b)}$: integration over $\gamma=[0,R]\cup[R,-iqR]\cup[-iqR,0]$ is $0$
$\text{(3c)}$: integrate
Then, by analytic continuation, as $\Im(q)\to0$, $\frac iq$ behaves nicely. Therefore, we say for real $q$: $$ \int_0^\infty(\cos(qx)+i\sin(qx))\,\mathrm{d}x=\frac iq\tag4 $$ which says not only that $\int_0^\infty\sin(qx)\,\mathrm{d}x=\frac1q$, but also that $\int_0^\infty\cos(qx)\,\mathrm{d}x=0$ (even though neither of these integrals converges in the classical sense).
Let's verify the integral of $\cos(qx)$: $$ \begin{align} \int_0^\infty\cos(qx)\,\mathrm{d}x &=\int_0^\infty\sin(\pi/2+qx)\,\mathrm{d}x\tag{5a}\\[6pt] &=\int_{\frac\pi{2q}}^\infty\sin(qx)\,\mathrm{d}x\tag{5b}\\ &=\color{#C00}{\int_0^\infty\sin(qx)\,\mathrm{d}x}\color{#090}{-\int_0^{\frac\pi{2q}}\sin(qx)\,\mathrm{d}x}\tag{5c}\\[3pt] &=\color{#C00}{\frac1q}\color{#090}{+\left.\frac1q\cos(qx)\,\right|_0^{\frac\pi{2q}}}\tag{5d}\\[9pt] &=0\tag{5e} \end{align} $$ Explanation:
$\text{(5a)}$: $\cos(x)=\sin(\pi/2+x)$
$\text{(5b)}$: substitute $x\mapsto x-\frac\pi{2q}$
$\text{(5c)}$: difference of integrals
$\text{(5d)}$: integrate
$\text{(5e)}$: evaluate