<s>[INST] How to calculate this improper integral? Calculate the improper integral
$$\displaystyle\int_0^{\infty}{\frac{1}{\theta}e^{\cos\theta}\sin(\sin\theta){d\theta}}$$
My try:
We know that for any $a\in\mathbb{C}$ the integral
$$\displaystyle\int_0^{\infty}e^{-ax^2}=\frac{1}{2}\sqrt{\frac{\pi}{a}}$$
Let $a=\cos\theta+i\sin\theta$ we know $$\displaystyle\int_0^{\infty}{e^{x^2\cos\theta}\sin(x^2\sin\theta){dx}}=\frac{\sqrt{\pi}}{2}\sin\frac{\theta}{2}$$
then $$\displaystyle\int_0^{\infty}{\frac{1}{\theta}e^{x^2\cos\theta}\sin(x^2\sin\theta){dx}}=\frac{\sqrt{\pi}}{2}\frac{\sin\frac{\theta}{2}}{\theta}$$
$$\displaystyle\int_0^{\infty}d\theta\displaystyle\int_0^{\infty}{\frac{1}{\theta}e^{x^2\cos\theta}\sin(x^2\sin\theta){dx}}=\displaystyle\int_0^{\infty}\frac{\sqrt{\pi}}{2}\frac{\sin\frac{\theta}{2}}{\theta}d\theta$$
Let $F(x)=\displaystyle\int_0^{\infty}{\frac{1}{\theta}e^{x^2\cos\theta}\sin(x^2\sin\theta){d\theta}}$, then the result equals to $F(1)$,But I don't know what to do next.
 [/INST] 1st Solution. Define the sine integral by
$$ \operatorname{Si}(x) = \int_{0}^{x} \frac{\sin t}{t} \, \mathrm{d}t. $$
Using integartion by parts, it can be proved that
$$ \operatorname{Si}(x) = \frac{\pi}{2} + \mathcal{O}\left(\frac{1}{x}\right) \qquad\text{as } x \to \infty. $$
Now note that $e^{\cos\theta}\sin\sin\theta = \operatorname{Im}(e^{e^{i\theta}}-1) = \sum_{n=1}^{\infty} \frac{1}{n!}\sin(n\theta)$. Then by the Fubini's theorem, for $R > 0$,
\begin{align*}
\int_{0}^{R} \frac{e^{\cos\theta}\sin\sin\theta}{\theta} \, \mathrm{d}\theta
&= \int_{0}^{R} \frac{1}{\theta} \sum_{n=1}^{\infty} \frac{\sin(n\theta)}{n!} \, \mathrm{d}\theta \\
&= \sum_{n=1}^{\infty} \frac{1}{n!} \int_{0}^{R} \frac{\sin(n\theta)}{\theta} \, \mathrm{d}\theta \\
&= \sum_{n=1}^{\infty} \frac{1}{n!} \operatorname{Si}(nR) \\
&= \sum_{n=1}^{\infty} \frac{1}{n!} \left( \frac{\pi}{2} + \mathcal{O}\left( \frac{1}{nR} \right) \right) \\
&= \frac{\pi}{2}(e - 1) + \mathcal{O}\left(\frac{1}{R}\right).
\end{align*}
So by letting $R \to \infty$, the integral converges to
$$ \int_{0}^{\infty} \frac{e^{\cos\theta}\sin\sin\theta}{\theta} \, \mathrm{d}\theta = \frac{\pi}{2}(e-1). $$

2nd Solution. It is well-known that
$$ \lim_{N\to\infty} \sum_{k=-N}^{N} \frac{1}{z + 2\pi k} = \frac{1}{2}\cot\left(\frac{z}{2}\right). $$
Moreover, this convergence is locally uniform (in the sense that the difference between the limit and the $N$-th partial sum, when understood as a meromorphic function on $\mathbb{C}$, converges to $0$ uniformly on any compact subsets of $\mathbb{C}$).
Using this and noting that $e^{\cos\theta}\sin\sin\theta = \operatorname{Im}(e^{e^{i\theta}} - e)$, we find
\begin{align*}
\int_{-(2N+1)\pi}^{(2N+1)\pi} \frac{e^{\cos\theta}\sin\sin\theta}{\theta} \, \mathrm{d}\theta
&= \operatorname{Im}\biggl( \int_{-(2N+1)\pi}^{(2N+1)\pi} \frac{e^{e^{i\theta}} - e}{\theta}  \, \mathrm{d}\theta \biggr) \\
&= \operatorname{Im}\biggl( \int_{-\pi}^{\pi} (e^{e^{i\theta}} - e) \sum_{k=-N}^{N} \frac{1}{\theta + 2\pi k}  \, \mathrm{d}\theta \biggr) \\
&\to \operatorname{Im}\biggl( \int_{-\pi}^{\pi} (e^{e^{i\theta}} - e) \frac{1}{2}\cot\left(\frac{\theta}{2}\right)  \, \mathrm{d}\theta \biggr)
\qquad\text{as } N \to \infty.
\end{align*}
Now we substitute $z = e^{i\theta}$. Then using the identity $\cot(\theta/2) = i \frac{e^{i\theta} + 1}{e^{i\theta} - 1}$ and the residue theorem,
\begin{align*}
\int_{-\infty}^{\infty} \frac{e^{\cos\theta}\sin\sin\theta}{\theta} \, \mathrm{d}\theta
&= \operatorname{Im}\biggl( \frac{1}{2} \int_{|z|=1} \frac{(e^{z} - e)(z+1)}{z(z-1)} \, \mathrm{d}z \biggr) \\
&= \operatorname{Im}\biggl( \pi i \, \underset{z=0}{\operatorname{Res}} \frac{(e^{z} - e)(z+1)}{z(z-1)}  \biggr) \\
&= \pi(e - 1).
\end{align*}
Dividing both sides by $2$, we conclude that
$$ \int_{0}^{\infty} \frac{e^{\cos\theta}\sin\sin\theta}{\theta} \, \mathrm{d}\theta = \frac{\pi}{2}(e - 1). $$
</s>