Evaluating the integral of $\frac{\cos(x) - e^{-x}}{x}$ using contour integration I am trying to evaluate the value of $$\int_0^\infty\frac{\cos(x) - e^{-x}}{x}dx$$. I am assuming I am supposed to use contour integration, as I was required just before to calculate the value of $$\int_0^\infty\frac{\sin(x)}{x}dx$$ using contour integration over a semicircle in the upper half complex plane.
I may be able to use contour integration directly again in order to calculate this new value, but I prefer using the value I already found for sin to get the new value, if possible.
I have tried differentiating the old term and exchanging the order of intgeration and differentiation (guided by the fact that $(sinx)' = cosx$), but got an expression I cannot simplify to the form above.
 A: Since:
$$ \mathcal{L}\left(\cos x-e^{-x}\right) = \frac{s}{1+s^2}-\frac{1}{s+1} $$
we have:

$$\begin{eqnarray*} \color{red}{I} = \int_{0}^{+\infty}\frac{\cos x-e^{-x}}{x}\,dx &=& \int_{0}^{+\infty}\frac{s-1}{(s+1)(s^2+1)}\,ds\\[0.1cm]&=&\frac{1}{2}\lim_{s\to +\infty}\log\left(\frac{s^2+1}{(s+1)^2}\right)=\color{red}{\large 0}.\end{eqnarray*} $$

Quite impressive, don't you think? That also follows from a symmetry argument:
$$ \int_{0}^{1}\frac{s-1}{(s+1)(1+s^2)}\,ds = -\int_{1}^{+\infty}\frac{s-1}{(s+1)(s^2+1)}\,ds $$
by just applying the substitution $s=\frac{1}{t}$ in the second integral.

You may also use the Cantarini-Frullani's theorem, from which: $$
 \int_{0}^{+\infty}\frac{e^{-ix}-e^{-x}}{x}\,dx = -\frac{\pi i}{2}, $$
   then take the real part of both sides.

A: We know
$$\int_{0}^{\infty }{\frac{f(x)}{x}}dx=\int_{0}^{\infty }{\mathcal{L}(f(x))}ds$$
then
$$\int_{0}^{\infty }{\frac{\cos x-{{e}^{-x}}}{x}}dx=\int_{0}^{+\infty }{\left( \frac{s}{1+{{s}^{2}}}-\frac{1}{s+1} \right)}\,ds=\underset{s\to \infty }{\mathop{\lim }}\,\ln \left(\frac{\sqrt{s^2+1}}{s+1} \right)=0$$
A: APPROACH $1$:
Using contour integration we begin by writing the integral of interest as
$$\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx=\text{Re}\left(\int_0^\infty \frac{e^{ix}-e^{-x}}{x}\,dx\right) \tag 1$$
Next, we note that from Cauchy's Integral Theorem
$$\oint_C \frac{e^{iz}-e^{-z}}{z}\,dz=0 \tag 2$$
where $C$ is the closed contour comprised of (i) the line segment from $\epsilon>0$ to $R$, (ii) the quarter circle of radius $R$ centered at the origin from $R$ to $iR$, (iii) the line segment from $iR$ to $i\epsilon$, and (iv) the quarter circle of radius $\epsilon$ centered at the origin from $i\epsilon$ to $\epsilon$.
We can write $(2)$ as 
$$\begin{align}\oint_C \frac{e^{iz}-e^{-z}}{z}\,dz&=\int_\epsilon^R \frac{e^{ix}-e^{-x}}{x}\,dx+\int_R^\epsilon \frac{e^{-y}-e^{-iy}}{iy}\,i\,dy\\\\
&+\int_0^{\pi/2}\frac{e^{iRe^{i\phi}}-e^{-Re^{i\phi}}}{Re^{i\phi}}\,iRe^{i\phi}\,d\phi\\\\
&+\int_{\pi/2}^0\frac{e^{i\epsilon e^{i\phi}}-e^{-\epsilon e^{i\phi}}}{\epsilon e^{i\phi}}\,i\epsilon e^{i\phi}\,d\phi\tag 3
\end{align}$$
As $R\to \infty$ and $\epsilon \to 0$, the third and fourth integrals on the right-hand side of $(3)$ can be shown to approach zero.  Using $(2)$, we see that
$$\int_0^\infty \frac{e^{ix}-e^{-x}}{x}\,dx=-\int_0^\infty \frac{e^{-iy}-e^{-y}}{y}\,dy \tag 4$$
whence taking the real part of both sides of $(4)$ and comparing with $(1)$ yields
$$\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx=-\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx$$
Therefore, we find that 
$$\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx=0$$
________________________-
APPROACH $2$:
An alternative suggested by Ron Gordon, is to start with the integral
$$\oint_{C}\frac{e^{iz}}{z}\,dz=0$$
Then, we can write
$$\begin{align}
0&=\int_\epsilon^R \frac{e^{ix}}{x}\,dx+\int_R^\epsilon \frac{e^{-x}}{x}\,dx+i\int_0^{\pi/2} e^{iRe^{i\phi}}\,d\phi+i\int_{\pi/2}^0 e^{i\epsilon^{i\phi}}\,d\phi\\\\
&=\int_{\epsilon}^R\frac{e^{ix}-e^{-x}}{x}\,dx+i\int_0^{\pi/2} e^{iRe^{i\phi}}\,d\phi+i\int_{\pi/2}^0 e^{i\epsilon^{i\phi}}\,d\phi\tag 5
\end{align}$$
As $R\to \infty$, the third integral on the right-hand side of $(5)$ approaches $0$.  As $\epsilon \to 0$ the fourth integral on the right-hand side approaches $-i\pi/2$.  Therefore, 
$$\int_0^\infty \frac{e^{ix}-e^{-x}}{x}\,dx=i\pi/2 \tag 6$$
Taking real and imaginary parts of $(6)$ yield respectively
$$\int_0^\infty \frac{\cos(x)-e^{-x}}{x}\,dx=0$$
and
$$\int_0^\infty \frac{\sin(x)}{x}\,dx=\frac{\pi}{2}$$
