# Approximating $\pi$ and $\ln 2$ with $I_k=\int_0^\infty \left(\text{sech}x\tanh\tfrac12x\right)^k\,dx$ for integer $k$

Consider the following integral:

$$I_k=\int_0^\infty \left(\text{sech}x\tanh\tfrac12x\right)^k\,dx$$

where $$k\in\Bbb N$$.

If we evaluate $$I_1$$, $$I_2$$, $$I_3$$, etc. we get the following pattern:

• $$I_1=\log(2)$$
• $$I_2=-3+\pi$$
• $$I_3=\frac 72-5\log(2)$$
• $$I_4=22-7\pi$$
• $$I_5=-\frac{341}{12}+41\log(2)$$
• $$I_6=-\frac{968}{5}+\frac{493}{8}\pi$$
• ...

From this data we can see that:

\begin{align} \pi&=3+I_2=\frac{22}{7}-\frac17 I_4=\frac{7744}{2465}+\frac{8}{493}I_6 \\[4pt] \log(2)&=0+I_1=\frac{7}{10}-\frac15I_3=\frac{341}{492}+I_5 \end{align}

And because $$I_k$$ decreases very rapidly($$I_{10}$$ is in the order of $$1e6$$) we can set $$I_k\approx 0$$ for high $$k$$ and we get rational approximations of both, $$\pi$$ and $$\log(2)$$, for $$I_{2k}$$ and $$I_{2k+1}$$, respectively, that apparently go on forever.

I see some equations that somehow "encode" the information of a given number, but how is it that this integral has the information of both $$\pi$$ and $$\log(2)$$, apparently unrelated numbers?

Thanks.

• Please write an informative title that will allow others to find the problem and solution later. Cutesy uninformative titles are annoying and unhelpful. Commented Aug 29, 2019 at 2:04
• Interesting exercise, for sure and $\to +1$ for the question. Commented Aug 29, 2019 at 4:21
• $\pi$ and $\ln 2$ are not actually very unrelated. The $\ln 2$ constant shows up naturally, for instance, in the study of integrals like $$\int_0^{\pi/2}\ln(\sin t)dt=-\frac{\pi}{2}\ln 2.$$ See also the relations between $\pi$, $\ln2$, $e$, and Catalan's constant $\mathrm{G}$ in this post. Commented Nov 19, 2019 at 5:25

I'm not sure exactly what kind of an answer you're looking for---but the following might be a helpful heuristic:

1. A standard substitution transforms the integrals $$I_k=\int_0^\infty \left(\operatorname{sech} x \tanh\frac{x}{2}\right)^k\,dx ,$$ (for $$k$$ a nonnegative integer, which we henceforth assume) into integrals of rational functions of a new variable.

2. After applying the method of partial fractions, we can integrate term-by-term, and the only non-rational functions that occur in the antiderivatives have the form $$\log q(u)$$ and $$\arctan r(u)$$ for some affine functions $$q, r$$ with rational coefficients.

3. At typical limits of integration the functions $$q(u)$$ usually take on values of rational number with small numerator and denominator, and so the contribution of these terms is a sum of logarithms of small numbers---of course, the smallest positive integer with nonzero logarithm is $$2$$, so it's no surprise that $$\log 2$$ occurs in the values of such integrals often.

4. Likewise, if we can write $$\arctan v$$ without $$\arctan$$, typically the result is some rational multiple of $$\pi$$. In particular, we have $$\arctan 1 = \frac{\pi}{4}$$ and $$\lim_{v \to \infty} \arctan v = \frac{\pi}{2}$$, no it's no surprise that $$\pi$$ occurs often either.

More explicitly: Applying the hyperbolic analogue $$x = 2 \operatorname{artanh} t$$ of the Weierstrass substitution transforms $$I_k$$ into an integral with a rational integrand, $$I_k = 2 \int_0^1 \frac{(1 - t^2)^{k - 1} t^k \,dt}{(1 + t^2)^k}.$$ The next step for evaluating this integral in terms of elementary functions depends on the parity of $$k$$.

For $$k$$ odd, substituting $$u = t^2, \qquad du = 2 t \,dt$$ gives $$I_k = \int_0^1 \frac{(1 - u)^{k - 1} u^{(k - 1) / 2}}{(u + 1)^k} .$$ Expanding the integrand using partial fractions gives $$I_k = \int_0^1 \left(P(u) + \frac{A_t}{(u + 1)^k} + \cdots + \frac{A_2}{(u + 1)^2} + \frac{A_1}{u + 1} \right) du$$ for some rational polynomial $$P(u)$$ and rational coefficients $$A_1, \ldots, A_k$$. But the antiderivative of every term but $$\frac{A_1}{u + 1}$$ is a rational function, so each contributes some rational number, altogether contributing a rational total, call it $$\alpha$$. The value of the last term is $$A_1 \int_0^1 \frac{du}{u + 1} = A_1 \log u\vert_0^1 = A_1 \log 2$$, so $$\boxed{I_k = \alpha_k + \beta_k \log 2}$$ for some rational numbers $$\alpha_k$$ and $$\beta_k := A_1$$. A tedious but straightforward induction shows that $$\beta_k \neq 0$$.

For $$k$$ even, that substitution is not available (or more precisely, it makes the integrand worse), but applying the method of partial fractions again gives $$I_k = \int_0^1 \left(P(t) + \frac{A_k t + B_k}{(t^2 + 1)^k} + \cdots + \frac{A_2 t + B_2}{(t^2 + 1)^2} + \frac{A_1 t + B_1}{(t^2 + 1)} \right) dt$$ for some polynomial $$P(t)$$ and rational coefficients $$A_1, \ldots, A_k, B_1, \ldots, B_k$$. But our integrand in $$u$$ is even, and so $$A_1 = \cdots = A_k = 0$$. On the other hand, for $$m > 1$$, the integral of $$\frac{1}{(t^2 + 1)^m}$$ satisfies the reduction formula of the form $$\int \frac{dt}{(t^2 + 1)^m} = f_m(t) + \gamma_m \int \frac{dt}{(t^2 + 1)^{m - 1}}$$ for some rational function $$f_m$$ and rational constant $$\gamma_m$$ (both depending on $$m$$). In particular, induction gives $$\int \frac{dt}{(t^2 + 1)^m} = g_m(x) + \delta_m \int \frac{dx}{t^2 + 1} = g_m(t) + \delta_m \arctan t + C$$ for some rational function $$g_m$$ and rational constant $$\delta_m$$ (again both depending on $$m$$). Substituting back into our previous formula for $$I_k$$, we have that $$I_k = [h(t) + \zeta \arctan t]\vert_0^1 = h(1) - h(0) + \beta_k \pi$$ for some rational function $$h$$ and rational constant $$\beta_k$$, and so $$\boxed{I_k = \alpha_k + \beta_k \pi}$$ for rational numbers $$\alpha_k := h(1) - h(0)$$ and $$\beta_k$$. Again, an induction shows that $$\beta_k \neq 0$$ for $$k > 0$$.

Remark 1 Essentially the same phenomenon occurs for the similar family $$J_j := \int_0^1 \frac{x^{2 j} (1 - x)^{2 j}dx}{1 + x^2} ,$$ which generalizes the so-called Dalzell integral (the case $$j = 2$$, which gives $$\frac{22}{7} - \pi$$). If $$j$$ is odd, we get an expression of the form $$\alpha + \beta \log 2$$, and if $$j$$ is even we get $$\alpha + \beta \pi$$, with $$\alpha, \beta \neq 0$$ in both cases.

Remark 2 We can use the resulting integral expressions to derive rational approximations of $$\pi$$ and $$\log 2$$. On the interval $$[0, 1]$$, $$\frac{1}{2^k} \leq \frac{1}{(1 + t^2)^k} \leq 1$$, giving the bounds $$\frac{1}{2^k} E_k < I_k < E_k, \\ \textrm{where} \quad E_k = 2 \int_0^1 u^k (1 - u^2)^k du = \frac{\Gamma(k) \Gamma\left(\frac{1}{2} k + \frac{1}{2}\right)}{\Gamma\left(\frac{3}{2} k + \frac{1}{2}\right)} \sim \frac{\sqrt{2 \pi}}{\sqrt{k}} \left(\frac{2}{3 \sqrt{3}}\right)^k ,$$ so for any particular $$k$$, rearranging gives rational bounds for $$\pi$$ or $$\log 2$$. (For odd $$k = 2 l + 1$$, by the way, we have $$E_{2 l + 1} = \frac{(2 l)! l!}{(3 l + 1)!}$$.)

For example, taking $$k = 2$$ gives $$I_2 = \pi - 3$$ and $$L_2 = \frac{16}{105}$$, and rearranging gives $$\frac{319}{105} < \pi < \frac{331}{105} .$$

• Very nice work with the bounds. Commented Aug 29, 2019 at 7:46
• $K_j=\frac{\Gamma (2 j+1)^2}{\Gamma (4 j+2)}\sim \frac{\sqrt{\pi } 2^{-4 j-\frac{3}{2}}}{\sqrt{j}}$ seems to be interesting Commented Aug 29, 2019 at 8:16

Probably not an answer but too long for the comment section.

You are considering $$I_k=\int_0^\infty \Big( \text{sech}(x) \tanh \left(\frac{x}{2}\right) \Big)^k \,dx$$ Let $$x=2 \tanh ^{-1}(t)$$ which makes $$J_k=\int \Big( \text{sech}(x) \tanh \left(\frac{x}{2}\right) \Big)^k \,dx=2 \int\left(1-t^2\right)^{k-1} \left(\frac{t}{1+t^2}\right)^k\,dt$$ that is to say $$J_k=2\frac{ t^{k+1}}{k+1}\, F_1\left(\frac{k+1}{2};1-k,k;\frac{k+3}{2};t^2,-t^2\right)$$ where appears the Appell hypergeometric function of two variables.

Integrating between $$0$$ and $$1$$, after simplification, this leads to $$I_k=\, _2\tilde{F}_1\left(k,\frac{k+1}{2};\frac{3 k+1}{2} ;-1\right)\, \Gamma (k)\, \Gamma \left(\frac{k+1}{2}\right)$$ where appears the regularized hypergeometric function.

As you noticed $$I_{2k}=a_k-b_k \pi$$ and $$I_{2k+1}=c_k-d_k \log(2)$$. So, for sure, if you make $$I_k\sim \epsilon$$, you have rational approximations of $$\pi$$ and $$\log(2)$$. The small problem I see is that they are not extremely accurate.

For example $$I_{20}=\frac{2357262305394688}{1119195}-\frac{21968591457761 \pi }{32768}\approx 1.7 \times 10^{-11}$$ would give as a rational approximation $$\pi \approx \frac{77242771223173136384}{24587137716568822395}=\color{red}{3.1415926535897932384}88023$$ while $$\pi \approx \frac{21053343141}{6701487259}=\color{red}{3.141592653589793238462}382$$ is better.

Similarly $$I_{21}= 4354393801 \log (2)-\frac{100374690765091043}{33256080}\approx 5.0 \times 10^{-12}$$ would give as a rational approximation $$\log(2)\approx \frac{100374690765091043}{144810068597560080}=\color{red}{0.69314718055994530941}60873$$ while $$\log(2)\approx \frac{34733068453}{50109225612}=\color{red}{0.693147180559945309417}8461$$ is better.

Too long for a comment.

We have the convenient relation $$\text{sech}(x)\tanh(x/2)=\frac{2}{e^x+1}-\frac{2}{e^{2x}+1},$$ so let $$L_n=I_{2n+1}=2^{2n+1}\sum_{k=0}^{2n+1}(-1)^k{2n+1\choose k}\int_0^{\infty}\frac{dx}{(e^x+1)^{2n-k+1}(e^{2x}+1)^k}$$ and $$P_n=I_{2n}=2^{2n}\sum_{k=0}^{2n}(-1)^k{2n\choose k}\int_0^{\infty}\frac{dx}{(e^x+1)^{2n-k}(e^{2x}+1)^k}.$$ These integrals may be easier to evaluate explicitly.