Why does the hard-looking integral $\int_{0}^{\infty}\frac{x\sin^2(x)}{\cosh(x)+\cos(x)}dx=1$? I have to ask this question; most looking complicated definite integral yield not so nice closed form or irrational numbers or mixed of what ever ect.
Why is this particular hard looking integral gives a $1$ as an answer?
$$\int_{0}^{\infty}\frac{x\sin^2(x)}{\cosh(x)+\cos(x)}dx=1$$
 A: We have the identity $$\frac{\sin\left(x\right)}{\cosh\left(ax\right)+\cos\left(x\right)}=2\sum_{n\geq1}\left(-1\right)^{n-1}\sin\left(nx\right)e^{-anx},\, a>0,\, x\geq0$$ so $$J=\int_{0}^{\infty}\frac{x\sin^{2}\left(x\right)}{\cosh\left(x\right)+\cos\left(x\right)}dx=2\sum_{n\geq1}\left(-1\right)^{n-1}\int_{0}^{\infty}x\sin\left(nx\right)\sin\left(x\right)e^{-nx}dx.$$ Now let us consider the integral. We note that $$I=\int_{0}^{\infty}x\sin\left(nx\right)\sin\left(x\right)e^{-nx}dx=-\frac{1}{4}\int_{0}^{\infty}xe^{-nx-inx-ix}dx+\frac{1}{4}\int_{0}^{\infty}xe^{-nx-inx+ix}dx
 $$ $$+\frac{1}{4}\int_{0}^{\infty}xe^{-nx+inx-ix}dx-\frac{1}{4}\int_{0}^{\infty}xe^{-nx+inx+ix}dx
 $$ and now we observe that $$-\frac{1}{4}\int_{0}^{\infty}xe^{-nx-inx-ix}dx=-\frac{1}{4}\int_{0}^{\infty}xe^{-x\left(n+in+i\right)}dx=-\frac{1}{4\left(n+in+i\right)^{2}}
 $$ and in a similar way we can compute the other integrals, hence $$I=\frac{1}{4}\left(-\frac{1}{\left(n+in+i\right)^{2}}+\frac{1}{\left(n+in-i\right)^{2}}+\frac{1}{\left(n-in+i\right)^{2}}-\frac{1}{\left(n-in-i\right)^{2}}\right)$$ $$=\frac{2n\left(4n^{4}+4n^{2}-1\right)}{\left(4n^{4}+1\right)^{2}}$$ then $$J=\sum_{n\geq1}\left(-1\right)^{n-1}\frac{4n\left(4n^{4}+4n^{2}-1\right)}{\left(4n^{4}+1\right)^{2}}
 $$ $$=\sum_{n\geq1}\left(-1\right)^{n-1}\left(\frac{2n-1}{\left(2n^{2}-2n+1\right)^{2}}+\frac{2n+1}{\left(2n^{2}+2n+1\right)^{2}}\right)$$ and note that we have a telescoping series since $$\frac{2n+1}{\left(2n^{2}+2n+1\right)^{2}}-\frac{2\left(n+1\right)-1}{\left(2\left(n+1\right)^{2}-2\left(n+1\right)+1\right)^{2}}=0$$ so $$\int_{0}^{\infty}\frac{x\sin^{2}\left(x\right)}{\cosh\left(x\right)+\cos\left(x\right)}dx=1.$$
A: One may employ the generating function
$$
\frac{\sin x}{\cosh x+\cos x}=2\sum_{k=1}^\infty(-1)^{k-1}e^{-kx}\sin kx
$$
and the classic result of
$$
\int_0^\infty x^{m-1}e^{-ax} \cos bx  \ dx = \frac{\Gamma(m)}{(a^{2} + b^{2})^{m/2}}\cos\left(m\tan^{-1}\left(\frac{b}{a}\right)\right)
$$
We then have
\begin{align}
\int_{0}^{\infty}\frac{x\sin^2 x}{\cosh x+\cos x}\ dx&=2\sum_{k=1}^\infty(-1)^{k-1}\int_{0}^{\infty}x\ e^{-kx}\sin x\sin kx\ dx\\[10pt]
&=\sum_{k=1}^\infty(-1)^{k-1}\left[\int_{0}^{\infty}x\ e^{-kx}\cos(k-1)x\ dx-\int_{0}^{\infty}x\ e^{-kx}\cos(k+1)x\ dx\right]\\[10pt]
&=\sum_{k=1}^\infty(-1)^{k-1}\left[ \frac{\cos\left(2\tan^{-1}\left(\frac{k-1}{k}\right)\right)}{k^{2}+(k-1)^2}-\frac{\cos\left(2\tan^{-1}\left(\frac{k+1}{k}\right)\right)}{k^{2}+(k+1)^2}\right]\\[10pt]
&=1
\end{align}
and the claim follows.

The latter expression is indeed a telescoping series as one may observe its partial sum equals
$$
\sum_{k=1}^n(-1)^{k-1}\left[ \frac{\cos\left(2\tan^{-1}\left(\frac{k-1}{k}\right)\right)}{k^{2}+(k-1)^2}-\frac{\cos\left(2\tan^{-1}\left(\frac{k+1}{k}\right)\right)}{k^{2}+(k+1)^2}\right]=1+\frac{\cos\left(2\tan^{-1}\left(\frac{n+1}{n}\right)\right)}{n^{2}+(n+1)^2}
$$
Notice that
$$
\cos2a+\cos2b=2\cos(a-b)\cos(a+b)
$$
and
$$
\tan^{-1}(x)+\tan^{-1}\left(\frac{1}{x}\right)=\frac{\pi}{2}\qquad,\qquad x>0
$$
