# Closed expression for an integral involving harmonic numbers

Recently, I stumbled on an interesting class of integrals, and here is one example.

Problem: find the closed form of the integral

$$I = \int_{-\frac{\pi }{2}}^{\frac{\pi }{2}} \frac{\cos (x)}{\gamma ^{H_x-H_{-x}}+1} \, dx$$

Here $$\gamma$$ is Euler's gamma and $$H_x$$ is the harmonic number.

Hint: here is the graph of the integrand

EDIT

Hint #2

Consider also the integrals

$$I_2 = \int_{-\frac{\pi }{2}}^{\frac{\pi }{2}} \frac{\cos (x)}{e^{x}+1} \, dx$$

$$I_3 = \int_{-\frac{\pi }{2}}^{\frac{\pi }{2}} \frac{\cos (x)}{e^{\sin(x)}+1} \, dx$$

$$I_4 = \int_{-\frac{\pi }{2}}^{\frac{\pi }{2}} \frac{\cos (x)}{e^{\frac{1}{\sin ^3(x)}}+1} \, dx$$

• The result is the smallest positive integer number (no proof). Simplify (he integrand using $$H_x-H_{-x}=\frac{1}{x}-\pi \cot (\pi x)$$ Commented Oct 16, 2023 at 10:27
• Looking at my old cookbook, over the second interval, the result should be $\sin(1)$. Commented Oct 16, 2023 at 10:54
• NIntegrate[ Cos[x]/(1 + EulerGamma^(x^(-1) - Pi*Cot[Pi*x])), {x, -1, 1}, WorkingPrecision -> 30] - Sin[1] returns $5.7\times 10^{-29}$ Commented Oct 16, 2023 at 11:23
• With Mathematica 13.3.0 Integrate[ Cos[x]/(1 + EulerGamma^(x^(-1) - Pi*Cot[Pi*x])), {x, -Pi/2, Pi/2}] give me 1. Commented Oct 16, 2023 at 13:11
• @Mariusz Iwaniuk Thank you, confirmed in V11.3. Can you derive the result analytically? Commented Oct 17, 2023 at 8:51

I found this nice surprise in the treasure chest of Maths 505 as this problem

"This OP trick solves IMPOSSIBLE integrals!"

Although a solution has been given here, and I have accepted it, I'd like to write down the derivation in more detail.

The integral to be considered is

$$I=\int_{-a}^{a} \frac{f(x)}{c^{g(x)} + 1}\,dx$$

If $$f(x)$$ is even and $$g(x)$$ is odd the integral over a symmetric integration region admits a suprising general solution in which the function $$g(x)$$ drops out.

Indeed, using the notation of the reference, we have

$$I \overset{x\to -t} = \int_{a}^{-a} \frac{f(-t)}{c^{g(-t)} + 1}\,(-dt) \overset{t\to x} =\int_{-a}^{a} \frac{f(x)}{c^{-g(x)} + 1}\,dx\\ =\int_{-a}^{a} \frac{f(x)}{c^{-g(x)} + 1}\frac{c^{g(x)}}{c^{g(x)}}\,dx = \int_{-a}^{a} \frac{f(x)c^{g(x)} }{1+c^{g(x)}}\,dx$$

hence, adding the two forms of $$I$$, we get

$$2 I = \int_{-a}^{a} \frac{f(x)}{c^{g(x)} + 1}\,dx+\int_{-a}^{a} \frac{f(x)c^{g(x)} }{1+c^{g(x)}}\,dx =\int_{-a}^{a} \frac{f(x)(1+c^{g(x)})}{1+c^{g(x)}}\,dx\\ =\int_{-a}^{a} f(x)\,dx= \int_{-a}^{0} f(x)\,dx+\int_{0}^{a} f(x)\,dx\overset{f(x)\text{ even}}= 2 \int_{0}^{a} f(x)\,dx$$

from which we find that

$$I=\int_{-a}^{a} \frac{f(x)}{c^{g(x)} + 1}\,dx= \int_{0}^{a} f(x)\,dx$$

For the three examples in the OP this gives simply

$$I = \int_{0}^{\frac{\pi}{2}} \cos(x) = \sin (x)\bigg|_0^{\pi/2}=1$$

Remark: there are many more nice problem and derivations in Maths 505.

Consider the following result: let $$f(x)$$ be an even Riemann-integrable function on $$[-a,a]$$ and $$g(x)$$ an odd Riemann-integrable function, then for any $$b\in \Bbb R^+$$ we have $$\int_{-a}^a\frac{f(x)}{b^{g(x)}+1}\mathrm{d}x=\int_0^a f(x)\mathrm{d}x$$ In this case, $$f=\cos x$$ is even and $$g=H_x-H_{-x}$$ is odd, moreover $$\gamma>0$$; hence the integral is: $$\int_{-\pi/2}^{\pi/2}\frac{\cos x}{\gamma^{H_x-H_{-x}}+1}\mathrm{d}x=\int_{0}^{\pi/2}\cos x \mathrm{d}x =\sin x\bigg|_0^{\pi/2}=1$$

• Answer accepted. Some more elaboration why the last equality holds would be nice. Commented Oct 17, 2023 at 16:28