TITLE: How to evaluate $\int_{-\infty}^\infty \frac{\cos x}{\cosh x}\,\mathrm dx$ by hand
QUESTION [17 upvotes]: How can I evaluate$$\int_{-\infty}^\infty \frac{\cos x}{\cosh x}\,\mathrm dx\text{ and }\int_0^\infty\frac{\sin x}{e^x-1}\,\mathrm dx.$$
Thanks in advance.

REPLY [2 votes]: Let us start from the Weierstrass product for the sine function:
$$ \sin(x) = x \prod_{n\geq 1}\left(1-\frac{x^2}{\pi^2 n^2}\right)\tag{1} $$
This identity over the real line can be proved by exploiting Chebyshev polynomials, but it holds over $\mathbb{C}$ and it is equivalent to
$$ \sinh(x) = x \prod_{n\geq 1}\left(1+\frac{x^2}{n^2\pi^2}\right).\tag{1'} $$
If we apply $\frac{d}{dx}\log(\cdot)$ (the logarithmic derivative) to both sides of $(1)$ we end up with
$$ \cot(x)-\frac{1}{x} = \sum_{n\geq 1}\frac{2x}{x^2-n^2 \pi^2} \tag{2}$$
$$ \coth(x)-\frac{1}{x} = \sum_{n\geq 1}\frac{2x}{x^2 + n^2 \pi^2} \tag{2'}$$
and by expanding the main term of the RHS of $(2)$ as a geometric series we have
$$ \frac{1-x\cot x}{2} = \sum_{n\geq 1}\frac{\frac{x^2}{n^2 \pi^2}}{1-\frac{x^2}{n^2\pi^2}} =\sum_{n\geq 1}\sum_{m\geq 1}\left(\frac{x^2}{n^2 \pi^2}\right)^m = \sum_{m\geq 1}x^{2m}\frac{\zeta(2m)}{\pi^{2m}} \tag{3}$$
$$ \frac{1-x\coth x}{2} = \sum_{m\geq 1}(-1)^m x^{2m}\frac{\zeta(2m)}{\pi^{2m}}\tag{3'} $$
$(3')$ alone is enough to prove that $\zeta(2m)$ is always a rational multiple of $\pi^{2m}$, related to a coefficient of the Maclaurin series of $\frac{z}{e^z-1}=-\frac{z}{2}+\frac{z}{2}\coth\frac{z}{2}$, i.e. to a Bernoulli number, but that is not the point here.
Let us deal with the second integral:
$$ \int_{0}^{+\infty}\frac{\sin z}{e^z-1}\,dz = \sum_{m\geq 1}\int_{0}^{+\infty}\sin(z) e^{-mz}\,dz = \sum_{m\geq 1}\frac{1}{m^2+1} $$
can be evaluated through $(2')$ by picking $x=\pi$. In a similar fashion
$$ \int_{0}^{+\infty}\frac{\cos z}{e^z+e^{-z}}\,dz = \sum_{m\geq 0}(-1)^m\int_{0}^{+\infty}\cos(z)e^{-(2m+1)z}\,dz = \sum_{m\geq 0}(-1)^m \frac{(2m+1)}{(2m+1)^2+1} $$
can be computed from the Weierstrass product of the cosine function,
$$ \cos(x) = \prod_{m\geq 0}\left(1-\frac{4x^2}{(2m+1)^2\pi^2}\right)\tag{4} $$
$$ \cosh(x) = \prod_{m\geq 0}\left(1+\frac{4x^2}{(2m+1)^2\pi^2}\right)\tag{4'} $$
leading by logarithmic differentiation to
$$ \sum_{m\geq 0}\frac{x}{x^2+(2m+1)^2} = \frac{\pi}{4}\tanh\left(\frac{\pi x}{2}\right)\tag{5} $$
and also to
$$ \sum_{m\geq 0}\frac{(-1)^m(2m+1)}{x^2+(2m+1)^2} = \frac{\pi}{4}\operatorname{sech}\left(\frac{\pi x}{2}\right).\tag{6}$$