Consider the integral
\[I=\int_0^\infty\frac{\sin x}{x(1+x^2)}\,\mathrm{d}x.\]The apparent singularity at the origin is removable, since the integrand tends to $1$ as $x\to0$. At infinity, its absolute value is bounded by $x^{-3}$, so the integral converges absolutely.
We will evaluate this integral in three ways, using successively fewer parameter derivatives: twice to obtain a differential equation, once to obtain a cosine integral, and finally not at all, by applying the residue theorem directly. The details justifying differentiation and the Dirichlet integral are collected at the end.
1. Differentiate twice: a differential equation
For the first two methods, define
\[F(a)=\int_0^\infty\frac{\sin(ax)}{x(1+x^2)}\,\mathrm{d}x, \qquad a\geq0.\]Our target is $I=F(1)$. Differentiating once cancels the factor $1/x$:
\[F'(a)=\int_0^\infty\frac{\cos(ax)}{1+x^2}\,\mathrm{d}x.\]The two initial values are therefore
\[\boxed{ F(0)=0, \qquad F'(0^+)=\int_0^\infty\frac{\mathrm{d}x}{1+x^2} =\frac{\pi}{2}. }\]Differentiate once more. For $a>0$,
\[F''(a)=-\int_0^\infty\frac{x\sin(ax)}{1+x^2}\,\mathrm{d}x.\]This second differentiation needs a separate justification: the new integral is only conditionally convergent. We will establish that step below. First, notice the algebraic identity
\[\frac{x}{1+x^2} =\frac1x-\frac{1}{x(1+x^2)}.\]Substituting it into the expression for $F’’$ gives
\[F''(a) =-\int_0^\infty\frac{\sin(ax)}x\,\mathrm{d}x +\int_0^\infty\frac{\sin(ax)}{x(1+x^2)}\,\mathrm{d}x=-\frac{\pi}{2}+F(a).\]Here we used the Dirichlet integral,
\[\int_0^\infty\frac{\sin(ax)}x\,\mathrm{d}x =\int_0^\infty\frac{\sin t}{t}\,\mathrm{d}t =\frac{\pi}{2},\qquad a>0.\]The substitution $t=ax$ explains why its value is independent of positive $a$. A real-variable derivation of that value is included below, so this method does not depend on the residue calculation.
We have obtained the initial-value problem
\[\boxed{ F''(a)-F(a)=-\frac{\pi}{2},\quad a>0; \qquad F(0)=0,\quad F'(0^+)=\frac{\pi}{2}. }\]The homogeneous equation has solutions $e^a$ and $e^{-a}$, while the constant $\pi/2$ is a particular solution. Hence
\[F(a)=\frac{\pi}{2}+C_1e^a+C_2e^{-a}.\]Applying the two initial conditions gives
\[C_1+C_2=-\frac{\pi}{2}, \qquad C_1-C_2=\frac{\pi}{2}.\]Therefore $C_1=0$ and $C_2=-\pi/2$, giving
\[\boxed{ F(a)=\frac{\pi}{2}(1-e^{-a}),\qquad a\geq0. }\]In particular, $I=\frac{\pi}{2}(1-e^{-1})$.
2. Differentiate once: the residue theorem
We can also stop after the first derivative and evaluate $F’(a)$ by residues. Consider the complex function
\[f_a(z)=\frac{e^{iaz}}{1+z^2},\qquad a\geq0.\]For $R>1$, integrate over the positively oriented contour $C_R$ formed by the real segment from $-R$ to $R$ and the upper semicircle
\[\gamma_R(\theta)=Re^{i\theta},\qquad 0\leq\theta\leq\pi.\]The poles are at $z=\pm i$, and only $z=i$ lies inside $C_R$. Its residue is
\[\operatorname{Res}_{z=i} f_a(z) =\lim_{z\to i}\frac{e^{iaz}}{z+i} =\frac{e^{-a}}{2i}.\]The residue theorem therefore gives
\[\int_{-R}^R\frac{e^{iax}}{1+x^2}\,\mathrm{d}x +\int_{\gamma_R}\frac{e^{iaz}}{1+z^2}\,\mathrm{d}z =\pi e^{-a}.\]To remove the arc contribution, observe that on the upper semicircle
\[|e^{iaz}|=e^{-a\operatorname{Im}z}\leq1, \qquad |1+z^2|\geq R^2-1.\]Since the arc has length $\pi R$,
\[\left| \int_{\gamma_R}\frac{e^{iaz}}{1+z^2}\,\mathrm{d}z \right| \leq\frac{\pi R}{R^2-1} \longrightarrow0.\]This estimate works even at $a=0$; no exponential decay is needed there. Letting $R\to\infty$, taking real parts, and using the evenness of the cosine integrand yields
\[2F'(a) =\int_{-\infty}^{\infty}\frac{\cos(ax)}{1+x^2}\,\mathrm{d}x =\pi e^{-a}.\]Finally, integrate with respect to $a$ and use $F(0)=0$:
\[F(a)=\int_0^a\frac{\pi}{2}e^{-t}\,\mathrm{d}t =\frac{\pi}{2}(1-e^{-a}).\]Thus
\[\boxed{ I=F(1)=\frac{\pi}{2}\left(1-\frac1e\right). }\]3. No differentiation: a direct contour integral
We can avoid the parameter altogether by choosing
\[g(z)=\frac{e^{iz}-1}{z(1+z^2)}.\]For real $x$, its imaginary part is exactly the original integrand:
\[\operatorname{Im}g(x)=\frac{\sin x}{x(1+x^2)}.\]Subtracting $1$ from the numerator leaves this imaginary part unchanged and removes the apparent pole at the origin. Indeed,
\[e^{iz}-1=iz+O(z^2), \qquad g(z)=i+O(z).\]Thus $z=0$ is a removable singularity. Define $g(0)=i$ and integrate over the positively oriented upper semicircular contour $C_R$ shown below. The real segment passes directly through the origin; no indentation or principal-value integral is needed.
The blue point marks the regular extension at $z=0$; the black points mark the poles. The only pole inside the contour is $z=i$, with residue
\[\operatorname{Res}_{z=i}g(z) =\left.\frac{e^{iz}-1}{z(z+i)}\right|_{z=i} =\frac{e^{-1}-1}{-2} =\frac{1-e^{-1}}2.\]| On the upper semicircle, $ | e^{iz} | \leq1$, so for $R>1$, |
Consequently,
\[\left|\int_{\gamma_R}g(z)\,\mathrm{d}z\right| \leq\frac{2\pi}{R^2-1}\longrightarrow0.\]The residue theorem now gives
\[\int_{-\infty}^{\infty} \frac{e^{ix}-1}{x(1+x^2)}\,\mathrm{d}x =2\pi i\operatorname{Res}_{z=i}g(z) =\pi i(1-e^{-1}).\]This real-axis integral is absolutely convergent: $g$ is bounded near zero and is $O(|x|^{-3})$ at infinity. Taking imaginary parts and using the evenness of $\sin x/[x(1+x^2)]$ therefore yields
\[2I=\pi(1-e^{-1}), \qquad \boxed{I=\frac{\pi}{2}\left(1-\frac1e\right).}\]Supplementary details
Why the first differentiation is valid, including at zero
The parameter derivative satisfies
\[\left| \frac{\partial}{\partial a} \frac{\sin(ax)}{x(1+x^2)} \right| =\left|\frac{\cos(ax)}{1+x^2}\right| \leq\frac{1}{1+x^2}.\]The bound is integrable and independent of $a$. Dominated convergence therefore justifies the first differentiation, including the right derivative at $a=0$, and shows that $F’$ is continuous from the right there. This validates the initial conditions used in the first method.
Why the second differentiation is valid for positive parameters
Let $g(x)=x/(1+x^2)$. For $x\geq1$, this function decreases to zero. Integration by parts gives, for $B>A\geq1$,
\[\int_A^B g(x)\sin(ax)\,\mathrm{d}x =\left[-\frac{g(x)\cos(ax)}a\right]_A^B +\frac1a\int_A^B g'(x)\cos(ax)\,\mathrm{d}x.\]On any parameter interval $0<\delta\leq a\leq M$, we consequently have
\[\left|\int_A^B g(x)\sin(ax)\,\mathrm{d}x\right| \leq\frac{g(A)+g(B)+\int_A^B|g'(x)|\,\mathrm{d}x}{a} =\frac{2g(A)}a \leq\frac{2g(A)}\delta \longrightarrow0.\]Thus the derivatives of the truncated integrals defining $F’$ converge uniformly on every such interval. This justifies differentiating $F’$ under the integral sign for $a>0$.
The restriction matters. Directly setting $a=0$ inside the expression for $F’’$ would give zero, but the formula we found implies
\[F''(0^+) =\lim_{h\to0^+}\frac{F'(h)-F'(0^+)}h =-\frac{\pi}{2}.\]There is no contradiction: the tail estimate contains $1/\delta$ and does not give uniform convergence down to $a=0$. The differential equation holds for $a>0$, and its initial data come from $F$ and $F’$, whose integral representations do remain valid at zero.
A real-variable derivation of the Dirichlet integral
For $\varepsilon>0$, introduce the absolutely convergent integral
\[D_\varepsilon(b) =\int_0^\infty e^{-\varepsilon x}\frac{\sin(bx)}x\,\mathrm{d}x, \qquad b\geq0.\]Differentiation under the integral sign and an elementary exponential integral give
\[D_\varepsilon'(b) =\int_0^\infty e^{-\varepsilon x}\cos(bx)\,\mathrm{d}x =\frac{\varepsilon}{\varepsilon^2+b^2}.\]Since $D_\varepsilon(0)=0$,
\[D_\varepsilon(b)=\arctan\left(\frac b\varepsilon\right) \longrightarrow\frac{\pi}{2} \quad (\varepsilon\to0^+,\ b>0).\]To connect this limit to the ordinary improper integral, note that $e^{-\varepsilon x}/x$ decreases to zero. The same integration-by-parts estimate as above yields
\[\left|\int_A^\infty e^{-\varepsilon x}\frac{\sin(bx)}x\,\mathrm{d}x\right| \leq\frac{2}{bA},\qquad \varepsilon\geq0,\quad b>0.\]The tails are therefore uniformly small, including when $\varepsilon=0$. On $[0,A]$, dominated convergence lets us remove the exponential factor. Together these facts prove
\[\int_0^\infty\frac{\sin(bx)}x\,\mathrm{d}x=\frac{\pi}{2}, \qquad b>0.\]