An amazing integral with a typo

This question Concerns a certain integral $$f(p)=\int_0^1\frac{x^p(1-x)^p}{1+x^2}\mathrm dx$$ Which, as proven by Calvin Khor, has the property that $$f(4k)-4^{k-1}(-1)^k\pi\in\Bbb Q$$ when $$k\in\mathbb N$$.

When I was investigating this question, I made a typo (switching the places of the "$$)$$" and the "$${}^p$$") when inputting the integral into Mathematica, and instead inputted the integral $$g(p)=\int_0^1\frac{x^p(1-x^p)}{1+x^2}\mathrm dx$$ However, rather unexpectedly, this appears to have the same property as well, with my Mathematica spitting out $$g(4\cdot 1)=\frac{2}{35} \\ g(4\cdot 2)=\frac{196}{6~435} \\ g(4\cdot 3)=\frac{208~786}{10~140~585} \\ g(4\cdot 4)=\frac{489~772~744}{31~556~720~475} \\ \text{etc}.$$

My question is simple - can someone explain why?

• That does not seem to be quite "the same property": $g(4k)$ is a rational number, $f(4k)$ is a rational number plus a multiple of $\pi$. So, are you asking why $g(4k)$ is rational? Jun 15, 2023 at 23:47
• If you tell Mathematica that $p$ is a natural number it should quickly spit out an exact solution for the indefinite integral. So you just compute $g(p)$ exactly for $p$ a natural number. (I currently don't have acces to Mathematica, it might even be able to handle the indefinite integral for arbitrary $p$). Jun 16, 2023 at 9:04
• @David Well, almost the same property. Jun 16, 2023 at 17:15
• @quarague Indeed, giving it the command Assuming[{k \[Element] Integers && k > 0}, Integrate[(x^(4 k) (1 - x^(4 k)))/(1 + x^2), {x, 0, 1}]] it spits out the result $$\frac{1}{4}\bigg(-\psi^{(0)}(k+1/4)+\psi^{(0)}(k+3/4)+\psi^{(0)}(2k+1/4)-\psi^{(0)}(2k+3/4)\bigg)$$ In agreement with Leucippus's answer Jun 16, 2023 at 17:19

Observe that

• $$\frac{ x^{4a} - 1 } { 1+x^2} = \frac{ x^{4a} - 1 } {x^4 - 1 } \times \frac{ x^4 - 1 } { x^2 + 1 }$$ is a polynomial with rational coefficients.
• (In fact, the coefficients are $$0, 1, -1$$.)
• Hence it's integral is a polynomial with rational coefficients.
• Hence $$\int_{0}^1 \frac{ x^{4a} - 1 } { 1+x^2}\, dx = [f(x) ]_0^1$$ is a rational number.
• Hence $$\int_{0}^1 \frac{ x^{4a} - x^{8a} } { 1+x^2}\, dx$$ is a rational number.
• Bonus: Show that $$\frac{ x^{4a} - x^{8a} } { 1+x^2} = x^{4a} - x^{4a+2} + x^{4a+4} -x^{4a+6} \ldots + x^{8a-4} - x^{8a-2}$$. Hence, the integral from 0 to 1 is equal to the rational number $$\frac{1}{4a+1} - \frac{1}{4a+3} + \frac{1}{4a+5} - \frac{1}{4a+7} \ldots + \frac{1}{8a-3} - \frac{1}{ 8a-1} .$$

Furthermore, to understand why this doesn't hold for $$p \neq 4k$$, we can study it in a similar manner.

• For $$p = 4k+1$$, show that $$\frac{x^{p} - x^{2p}} { x^2 + 1 } = f(x) + \frac{ 1 + x } { 1 + x^2 }$$, where $$f(x)$$ is a polynomial with rational(integer) coefficients. Hence, the integral is of the form rational number $$+\frac{ \pi + \log 4 } { 4}$$.
• For $$p = 4k+2$$, show that $$\frac{x^{p} - x^{2p}} { x^2 + 1 } = f(x) + \frac{ -2 } { 1 + x^2 }$$, where $$f(x)$$ is a polynomial with rational(integer) coefficients. Hence, the integral is of the form rational number $$- \frac{ \pi} { 2}$$.
• For $$p = 4k+3$$, show that $$\frac{x^{p} - x^{2p}} { x^2 + 1 } = f(x) + \frac{ 1-x } { 1 + x^2 }$$, where $$f(x)$$ is a polynomial with rational(integer) coefficients. Hence, the integral is of the form rational number $$+\frac{ \pi - \log 4} { 4}$$.
• Bonus: We can similarly hunt down the polynomial $$f(x)$$ and can state what the rational number is.

By considering the integral, then: \begin{align} g(p) &= \int_{0}^{1} \frac{x^p \, (1 - x^p)}{1+x^2} \, dx \\ &= \sum_{n=0}^{\infty} (-1)^n \, \int_{0}^{1} x^{p+2 n} \, (1 - x^p) \, dx \\ &= \sum_{n=0}^{\infty} (-1)^n \, \left(\frac{1}{2n+p+1} - \frac{1}{2n+2p+1} \right) \\ &= \frac{1}{4} \, \left( \psi\left(\frac{p+3}{4}\right) - \psi\left(\frac{p+1}{4}\right) - \psi\left(\frac{2p+3}{4}\right) + \psi\left(\frac{2p+1}{4}\right) \right), \end{align} where $$\psi(x)$$ is the digamma function. Letting $$p \to 4 p$$ gives $$g(4 p) = \frac{1}{4} \, \left( \psi\left(p + \frac{3}{4}\right) - \psi\left(p + \frac{1}{4}\right) - \psi\left(2 p +\frac{3}{4}\right) + \psi\left(2 p + \frac{1}{4}\right) \right).$$ Using $$\psi(x+1) = \psi(x) + \frac{1}{x}$$ then for each $$p$$ the values of $$g(4 p)$$ can be calculated. For $$p=0,1,2$$ then \begin{align} g(4 \cdot 0) &= 0 \\ g(4 \cdot 1) &= \frac{1}{5} - \frac{1}{7} = \frac{2}{35} \\ g(4 \cdot 2) &= \frac{1}{9} - \frac{1}{11} + \frac{1}{13} - \frac{1}{15} = \frac{196}{6435} \end{align}

In another form $$g(4 \, p) = \sum_{j=2p}^{4p-1} \frac{(-1)^j}{2j+1}.$$

For note(s): \begin{align} f(p) &= \int_{0}^{1} \frac{x^p \, (1-x)^p}{1+x^2} \, dx \\ &= \sum_{n=0}^{\infty} (-1)^n \, B(2n + p + 1, p + 1) \\ &= \left( \frac{\Gamma(p+1)}{\Gamma(2p+2)}\right)^2 \, {}_{3}F_{2}\left( \frac{p+1}{2}, \, \frac{p+3}{2}, \, 1; \, p+1, \, p + \frac{3}{2}; \, -1 \right), \end{align} where $$B(x, y)$$ is the Beta function and $${}_{3}F_{2}$$ is a hypergeometric function.

• Great answer and thank you for the thorough computation. I have decided to accept Calvin Lin's answer as it explains rather straightforwardly why the aforementioned property emerges without needing to resort to any special functions, but I greatly appreciate the effort you put into obtaining the closed form. Jun 16, 2023 at 17:13
• Side note: The closed form for $g(4p)$ can easily be obtained from my approach, because the "polynomial with rational coefficients" is $x^{4p}-x^{4p+2} + x^{4p+4} - x^{4p+6} + \ldots$, and the integer from 0 to 1 is clearly your expression. Jun 16, 2023 at 17:24