TITLE: Integral $\int_0^\infty\frac{\log(1+\cos x)}{1+e^x}\,dx=0$
QUESTION [24 upvotes]: In this question, the result $$\int_0^\infty\frac{\log\cos^2x}{1+e^{2x}}\,dx=-\frac{\log^22}2$$ was shown by writing $\log\cos^2x=2\log\cos x$.
The OP of the linked question attempted the integral as follows $$\int_0^\infty\frac{\log\cos^2x}{1+e^{2x}}\,dx=\frac12\int_0^\infty\frac{\log(1+\cos x)}{1+e^x}\,dx-\frac{\log^22}2$$ by writing $\log\cos^2x=\log(1+\cos2x)-\log2$.
Equating these two expressions yields $$\int_0^\infty\frac{\log(1+\cos x)}{1+e^x}\,dx=0.$$ Is there a direct way to prove this result (without writing $\log\cos^2x$ in two different ways to get there)?

REPLY [4 votes]: A shortcut:
$$\begin{align}
\int_0^\infty\frac{\log(2(1+\cos x))}{1+e^x}dx&=
\int_0^\infty\frac{\log(1+e^{ix})+\log(1+e^{-ix})}{1+e^x}dx\\
&=\int_0^\infty\left[\sum_{k=1}^\infty(-1)^k\frac{e^{ikx}+e^{-ikx}}k\sum_{n=1}^\infty(-1)^n e^{-nx}\right]dx\\
&=\sum_{k=1}^\infty\sum_{n=1}^\infty\frac{(-1)^{k+n}}k\int_0^\infty
\left[e^{-(n-ik)x}+e^{-(n+ik)x}\right]dx\\
&=\sum_{k=1}^\infty\sum_{n=1}^\infty\frac{(-1)^{k+n}}k
\left[\frac1{n-ik}+\frac1{n+ik}\right]\\
&=2\sum_{k=1}^\infty\sum_{n=1}^\infty\frac{(-1)^{k+n}}k\frac n{n^2+k^2}\\
&=\log^22,
\end{align}$$
where the last equality is proved by the same trick as in the linked answer:
$$
2S=2\sum_{k=1}^\infty\sum_{n=1}^\infty\frac{(-1)^{k+n}}{kn}=2\left[\sum_{k=1}^\infty\frac{(-1)^{k}}{k}\right]=2\log^22.
$$
Finally the original integral is obtained by subtracting:
$$\int_0^\infty\frac{\log2}{1+e^x}dx.
$$