# Integral $\int_0^{\infty} \frac{\log x}{\cosh^2x} \ \mathrm{d}x = \log\frac {\pi}4- \gamma$

Inspired by the user @Integrals, I thought I'd find some nice integrals! Especially interesting are those involving $\log \pi$. From Borwein and Devlin's "The Computer as Crucible", pg. 58 - show that

$$\displaystyle \int_0^{\infty} \frac{\log x}{\cosh^2x} \ \mathrm{d}x = \log\frac {\pi}4 - \gamma,$$

where $\gamma$ is the Euler-Mascheroni constant.

• This integral appears in the calculation of the transition temperature in a superconductor. For instance, it's evaluated in Fetter and Walecka Book appendix. Commented Jun 29, 2014 at 22:13

Let the considered integral be denoted by $I$. We have \eqalign{I&=\int_0^{1}\frac{\ln x}{\cosh^2x}dx+\int_{1}^\infty\frac{\ln x}{\cosh^2x}dx\cr &=\Big[(\ln x)\tanh x \Big]_0^1-\int_0^1\frac{\tanh x}{x}dx+ \Big[(\ln x)(\tanh x-1) \Big]_1^\infty-\int_1^\infty\frac{\tanh x-1}{x}dx\cr &=2\int_1^\infty\frac{dx}{x(1+e^{2x})}-\int_0^1\frac{1-e^{-2x}}{x(1+e^{-2x})}dx\cr &=2\int_1^\infty\frac{dx}{x(1+e^{2x})}-\int_0^1\frac{1-e^{-2x}}{x}\left(\frac{1}{1+e^{-2x}}-1\right)dx- \int_0^1\frac{1-e^{-2x}}{x}dx\cr &=2\int_1^\infty\frac{dx}{x(1+e^{2x})}+\int_0^1\frac{e^{-2x}-e^{-4x}}{x(1+e^{-2x})}dx- \int_0^1\frac{1-e^{-2x}}{x}dx\cr &=2\int_1^\infty\frac{dx}{x(1+e^{2x})}-\int_1^\infty\frac{e^{-2x}-e^{-4x}}{x(1+e^{-2x})}dx+\int_0^\infty\frac{e^{-2x}-e^{-4x}}{x(1+e^{-2x})}dx- \int_0^1\frac{1-e^{-2x}}{x}dx\cr &=\int_1^\infty\frac{1+e^{-2x}}{x(1+e^{2x})}dx+\int_0^\infty\frac{e^{-2x}-e^{-4x}}{x(1+e^{-2x})}dx- \int_0^1\frac{1-e^{-2x}}{x}dx\cr &=\int_1^\infty\frac{e^{-2x}}{x}dx- \int_0^1\frac{1-e^{-2x}}{x}dx+\int_0^\infty\frac{e^{-2x}-e^{-4x}}{x(1+e^{-2x})}dx\cr &=\underbrace{\int_2^\infty\frac{e^{-t}}{t}dt- \int_0^2\frac{1-e^{-t}}{t}dt}_A+\underbrace{\int_0^\infty\frac{e^{-t}-e^{-2t}}{t(1+e^{-t})}dt}_B} Now, note that \eqalign{ A&=\int_2^\infty\frac{e^{-t}}{t}dt-\int_0^1\frac{1-e^{-t}}{t}dt- \int_1^2\frac{1-e^{-t}}{t}dt\cr &=\int_2^\infty\frac{e^{-t}}{t}dt-\int_0^1\frac{1-e^{-t}}{t}dt-\ln2 +\int_1^2\frac{e^{-t}}{t}dt\cr &=\int_1^\infty\frac{e^{-t}}{t}dt-\int_0^1\frac{1-e^{-t}}{t}dt-\ln2\cr &=-\gamma-\ln2 } To calculate $B$ we can do the following \eqalign{ B&=\int_0^\infty\frac{e^{-t}-e^{-2t}}{t}\left(\sum_{n=0}^\infty(-1)^ne^{-nt}\right)dt\cr &=\sum_{n=0}^\infty(-1)^n\int_0^\infty\frac{e^{-(n+1)t}-e^{-(n+2)t}}{t}dt\cr &=\sum_{n=0}^\infty(-1)^n\ln\left(\frac{n+2}{n+1}\right)\cr &=\lim_{m\to\infty}\sum_{n=0}^{2m-2}(-1)^n\ln\left(\frac{n+2}{n+1}\right)\cr &=\lim_{m\to\infty}\ln\left(\prod_{k=1}^m\frac{2k}{2k-1}\prod_{k=1}^{m-1}\frac{2k}{2k+1}\right)\cr &=\lim_{m\to\infty}\ln\left(\frac{(2m)!!(2m-2)!!}{((2m-1)!!)^2}\right)=\ln\left(\frac{\pi}{2}\right)\cr } By Stirling's formula. This yields $I=\ln \pi-2\ln 2-\gamma$. $\qquad\square$

• By Wallis' product we have that $$\prod_{n=1}^{\infty} \frac{4n^2}{4n^2-1}=\frac{\pi}{2}$$ that simplifies things. (+1) for your answer Commented May 16, 2014 at 12:45

Let $\displaystyle I(a) = \int_{0}^{\infty} \frac{x^{a}}{\cosh^{2} x} \ dx$.

Then if $\text{Re} (a) >0$,

\begin{align} I(a) &= 4 \int_{0}^{\infty} \frac{x^{a}}{(e^{x}+e^{-x})^{2}} \ dx \\ &= 4 \int_{0}^{\infty}x^{a} \frac{e^{-2x}}{(1+e^{-2x})^{2}} \ dx \\ &=4\int_{0}^{\infty} x^{a} \sum_{n=1}^{\infty} (-1)^{n-1} n e^{-2nx} \ dx \\ &=4 \sum_{n=1}^{\infty} (-1)^{n-1}n \int_{0}^{\infty} x^{a} e^{-2nx} \ dx \\ &= 4 \sum_{n=1}^{\infty} (-1)^{n-1} n \frac{\Gamma(a+1)}{(2n)^{a+1}} \\ &= \frac{2 \Gamma(a+1)}{2^{a}}\sum_{n=1}^{\infty} \frac{(-1)^{n-1}}{n^{a}} \\ &= \frac{2 \Gamma(a+1) \eta(a)}{2^{a}} \end{align}

where $\eta(a)$ is the Dirichlet eta function.

But by analytic continuation, the above formula is valid if $\text{Re}(a) >- 1$.

Then differentiating under the integral sign we get

\begin{align} I'(a) &= \int_{0}^{\infty} \frac{x^{a} \log(x)}{\cosh^{2} x} \ dx \\ &= 2 \ \frac{[\Gamma'(a+1) \eta(a) + \Gamma(a+1) \eta'(a)]2^{a}- \Gamma(a+1) \eta(a) \log (2) 2^{a}}{2^{{2a}}} \ , \end{align}

which means

$$\int_{0}^{\infty}\frac{\log x}{\cosh^{2}x} \ dx = I'(0) = 2 \Big( \Gamma'(1) \eta(0)+\eta'(0) - \eta(0) \log(2) \Big) .$$

The eta values can be determined using the relation

$$\eta(s) = (1-2^{1-s})\zeta(s)$$

and the known Riemann zeta values $$\zeta(0) = -\frac{1}{2}$$ and $$\zeta'(0) = - \frac{1}{2} \log (2 \pi) .$$

Therefore,

\begin{align} \int_{0}^{\infty}\frac{\log x}{\cosh^{2}x} \ dx &= 2 \left[-\gamma \left(\frac{1}{2}\right)+ \frac{1}{2} \log \left(\frac{\pi}{2}\right) -\frac{1}{2}\log(2) \right] \\ &= \log \left( \frac{\pi}{4}\right) - \gamma . \end{align}

• Excellent method! Commented May 8, 2014 at 22:17
• +1. That is the traditional proof. Pretty fine. This integral appears in the evaluation of the transition temperature of a superconductor. We arrive to that expression from the integration by parts of $\displaystyle\int_{0}^{\Lambda}{\tanh\left(\, x\,\right) \over x}\,{\rm d}x$. In that way we skip the divergence when $\displaystyle\Lambda \to \infty$. Commented Jan 16, 2015 at 22:54

Largely speaking, we have

\begin{align} \int_0^{\infty} \frac{\log x}{\cosh^2x}\ \mathrm{d}x &=\lim_{a\to0} \lim_{b\to2}\frac{\partial}{ \partial a \partial b}\left(-4\int_0^{ \infty}\frac{x^{a-1}}{1+e^{b x}} \ dx\right)\\&= \lim_{a\to0} \lim_{b\to2}\frac{\partial}{\partial a \partial b}\left(b^{-a} (2^{3-a}-4) \Gamma(a) \zeta(a)\right)\\&=\log\left(\frac{\pi}{4}\right)-\gamma\end{align}

Done.

• Obviously you find this solution in less 10 secondes right ? Commented Jul 13, 2015 at 12:04
• @Shadock I don't remember how fast I was, but now I only edited the answer because of the latex rendering issue. Commented Jul 13, 2015 at 12:07
• So use \mathrm{d}x in you integral it looks better :) Commented Jul 13, 2015 at 12:08