Evaluate $\int_0^{\infty} {\sin(\tan(x)) \over x}dx$

Notice $\tan x$ is a periodic function with period $\pi$ and recall following expansion:

$$\frac{1}{\tan x} = \lim_{N\to\infty}\sum_{n=-N}^N \frac{1}{x + n\pi}$$

The integral we seek $$\mathcal{I} \stackrel{def}{=} \int_0^\infty \frac{\sin\tan x}{x} dx = \frac12 \int_{-\infty}^\infty \frac{\sin\tan x}{x} dx = \frac12 \left(\sum_{n=-\infty}^\infty \int_{(n-\frac12)\pi}^{(n+\frac12)\pi}\right)\frac{\sin\tan x}{x}dx $$ can be rewritten as $$ \mathcal{I} = \frac12 \int_{-\frac12\pi}^{\frac12\pi}\sin\tan x\left(\sum_{n=-\infty}^\infty\frac{1}{x+n\pi}\right) dx = \frac12\int_{-\frac12\pi}^{\frac12\pi}\frac{\sin\tan x}{\tan x} dx $$ Change variable to $t = \tan x$, we get

$$\mathcal{I} = \frac12\int_{-\infty}^{\infty} \frac{\sin t}{t(1+t^2)} dt = \frac12\Im\left[\int_{-\infty}^{\infty}\frac{e^{it}-1}{t(1+t^2)} dt\right]$$

We can evaluate the integral on RHS as a contour integral. By completing the contour in upper half-plane and using the fact the integrand has only two poles at $t = \pm i$, we get:

$$\begin{align} \mathcal{I} &= \frac12\Im\left[ 2\pi i \, \mathop{\text{Res}}_{z = i}\left(\frac{e^{it}-1}{t(1+t^2)}\right)\right] = \pi\Re\left[ \frac{e^{i(i)} - 1}{i(i+i)}\right] = \frac{\pi}{2}\left(1 - \frac1e \right)\\ &\approx 0.9929326518994357602762750999834... \end{align} $$

Update

If one don't want to use contour integral, we can replace the last step by a Feymann trick. Consider the function

$$J(a) = \int_0^\infty \frac{\sin(at)}{t(1+t^2)}dt $$

It is easy to see $\mathcal{I} = J(1)$ and $J(a)$ satisfies following ODE for $a > 0$.

$$\left( -\frac{d^2}{da^2} + 1 \right)J(a) = \int_0^\infty \frac{\sin(at)}{t} dt = \int_0^\infty \frac{\sin t}{t} dt = \frac{\pi}{2}$$

This implies $\displaystyle\;J(a) = \frac{\pi}{2} + A e^a + B e^{-a}\;$ for suitably chosen constants $A, B$. Notice $$\begin{align} J(+\infty) &= \lim_{a\to+\infty} \int_0^\infty \frac{\sin t}{t\left(1 + \left(\frac{t}{a}\right)^2\right)} dt = \int_0^\infty \frac{\sin t}{t} dt = \frac{\pi}{2}\\ J'(0^{+}) &= \lim_{a\to 0^{+}} \int_0^\infty \frac{\cos(at)}{1+t^2} dt = \int_0^\infty \frac{dt}{1+t^2} = \frac{\pi}{2} \end{align}$$

This fixes $\;A = 0$, $\displaystyle\;B = -\frac{\pi}{2}\;$ and hence

$$J(a) = \frac{\pi}{2}\left(1 - e^{-a}\right) \quad\implies\quad \mathcal{I} = J(1) = \frac{\pi}{2}\left( 1 - \frac{1}{e}\right)$$


Real Manipulations $$ \begin{align} \int_0^\infty\frac{\sin(\tan(x))}x\,\mathrm{d}x &=\frac12\int_{-\infty}^\infty\frac{\sin(\tan(\pi x))}x\,\mathrm{d}x\tag{1}\\ &=\frac12\sum_{k\in\mathbb{Z}}\int_0^1\frac{\sin(\tan(\pi x))}{x+k}\,\mathrm{d}x\tag{2}\\ &=\frac\pi2\int_0^1\sin(\tan(\pi x))\cot(\pi x)\,\mathrm{d}x\tag{3}\\ &=\frac\pi2\int_{-1/2}^{1/2}\sin(\tan(\pi x))\cot(\pi x)\,\mathrm{d}x\tag{4}\\ &=\frac12\int_{-\infty}^\infty\frac{\sin(u)}{u(1+u^2)}\,\mathrm{d}u\tag{5}\\ \end{align} $$ Explanation:
$(1)$: $\frac{\sin(\tan(x))}x$ is even, double domain and divide by $2$; substitute $x\mapsto\pi x$
$(2)$: break the domain into unit intervals
$(3)$: $\sum\limits_{k\in\mathbb{Z}}\frac1{x+k}=\pi\cot(\pi x)$ (see this answer)
$(4)$: $\sin(\tan(\pi x))\cot(\pi x)$ has period $\pi$
$(5)$: substitute $u=\tan(\pi x)$

Contour Integration

We will use the counter-clockwise contour $$ \gamma^+=[-R-i/2,R-i/2]\cup Re^{i[0,\pi]}-i/2 $$ and the clockwise contour $$ \gamma^-=[-R-i/2,R-i/2]\cup Re^{-i[0,\pi]}-i/2 $$ Then $$ \begin{align} \frac12\int_{-\infty}^\infty\frac{\sin(u)}{u(1+u^2)}\,\mathrm{d}u &=\frac12\int_{-\infty-\frac i2}^{\infty-\frac i2}\frac{\sin(u)}{u(1+u^2)}\,\mathrm{d}u\tag{6}\\ &=\frac1{4i}\int_{\gamma^+}\frac{e^{iz}}{z(1+z^2)}\,\mathrm{d}z -\frac1{4i}\int_{\gamma^-}\frac{e^{-iz}}{z(1+z^2)}\,\mathrm{d}u\tag{7}\\ &=\frac1{4i}\int_{\gamma^+}e^{iz}\left(\frac1z-\frac{1/2}{z-i}\color{#A0A0A0}{-\frac{1/2}{z+i}}\right)\,\mathrm{d}u\\ &-\frac1{4i}\int_{\gamma^-}e^{-iz}\left(\color{#A0A0A0}{\frac1z-\frac{1/2}{z-i}}-\frac{1/2}{z+i}\right)\,\mathrm{d}u\tag{8}\\ &=\frac{2\pi i}{4i}\left(1-\frac1{2e}\right)-\frac{2\pi i}{4i}\left(\frac1{2e}\right)\tag{9}\\ &=\frac\pi2\left(1-\frac1e\right)\tag{10} \end{align} $$ Explanation:
$(6)$: no singularities in $\small[-R,R]\cup[R,R-i/2]\cup[R-i/2,-R-i/2]\cup[-R-i/2,-R]$
$\hphantom{(6)\text{:}}$ integrand vanishes on vertical segments
$(7)$: $\sin(z)=\frac{e^{iz}-e^{-iz}}{2i}$, integrals vanish on semi-circular arcs
$(8)$: $\frac1{z(z^2+1)}=\frac1z-\frac{1/2}{z-i}-\frac{1/2}{z+i}$
$(9)$: singularities at $0$ and $i$ are in $\gamma^+$, singularity at $-i$ is in $\gamma^-$
$(10)$: simplify


EDIT: I modified the contour slightly.


Similar to the answer HERE, we can integrate the complex function $$f(z) = \frac{e^{i \tan z}}{z} $$ around a rectangular contour with vertices at $z= N$, $z=N+i\sqrt{N}$, $z= -N + i \sqrt{N}$, and $z=-N$, where $N$ is some positive integer.

Due to the presence of a simple pole at the origin and essential singularities at the half-integers, the contour needs to be indented along the real axis.

But since $$|e^{i \tan z}| = |e^{i \tan (x+iy)}| =\exp \left(-\frac{\sinh 2y}{\cos 2x + \cosh 2y} \right) \le 1$$ in the upper half-plane, the total contribution from the indentations around the essential singularities is vanishingly small.

Also, since the height of the contour is $\sqrt{N}$ and the magnitude of $e^{i \tan z}$ is bounded in the upper half-plane, the estimation lemma tells us that integrals along the sides of the rectangle vanish as $N \to \infty$.

So letting the radius of the indentation around the origin go to zero and then letting $N \to \infty$, we get

$$ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i \tan x}}{x} \, dx - i \pi \,\text{Res}[f(z),0] -\lim_{N \to \infty} \int_{-N}^{N} \frac{e^{i \tan (t+i\sqrt{N})}}{t+i\sqrt{N}} \, dt =0. $$

But since the magnitude of $e^{i \tan z}- \frac{1}{e}$ tends to zero exponentially fast as $\Im(z) \to +\infty$, we can replace $e^{i \tan(t+ i \sqrt{N})}$ with $\frac{1}{e}$. (Specifically, it's going to zero like $\frac{2}{e} e^{-2 \, \Im(z)}$.)

So we have

$$\text{PV} \int_{-\infty}^{\infty} \frac{e^{i \tan x}}{x} \, dx - i \pi - \frac{1}{e} \lim_{N \to \infty} \int_{-N}^{N} \frac{1}{t+i\sqrt{N}} \, dt =0. $$

But if we integrate $g(z) = \frac{1}{z}$ around a similar contour, we get

$$ \underbrace{\text{PV} \int_{-\infty}^{\infty} \frac{dx}{x}}_{0} - i \pi \underbrace{\text{Res}[g(z),0]}_{1} - \lim_{N \to \infty} \int_{-N}^{N} \frac{1}{t+i\sqrt{N}} \, dt = 0.$$

Therefore,

$$ \text{PV} \int_{-\infty}^{\infty} \frac{e^{i \tan x}}{x} \, dx - i \pi - \frac{1}{e} (-i \pi) =0.$$

The result then follows if we equate the imaginary parts on both sides of the equation.