Computing the primitive $\int\frac{1}{1+x^n} dx$

What follows is an essentially unedited translation to LaTex of a 28 October 2006 sci.math post of mine.

The factorization and partial fraction decomposition of $\frac{1}{x^n + 1}$ was essentially done by Roger Cotes (1682-1716), although he expressed his results in a geometric way that makes it difficult for someone not familiar with the notion of his era to interpret.

$$ \text{EVALUATION OF} \;\; \int \frac{dx}{x^4 + 1} $$

There are several elementary calculus texts that include as an exercise the evaluation of $\int \frac{dx}{x^4 + 1},$ but not many texts include this as one of their worked examples. You can find this integral as a worked example in Courant/John [4] (pp. 289-290), Federer/Jonsson [7] (pp. 609-610) [Federer/Jonsson's worked example is actually $\int \frac{x^3 + x^2 + 6}{x^4 + 36}dx,$ but the essential details are the same], Hairer/Wanner [9] (p. 120), and Peters [14] (pp. 99-100). The advanced calculus text Taylor/Mann [18] (Section 22.6, Exercise 9, p. 736) asks the reader to evaluate this integral "by expressing the integrand in terms of partial fractions with quadratic denominators" and the resulting antiderivative is given in the text.

$$ \text{EVALUATION OF} \;\; \int \frac{dx}{x^5 + 1} $$

Edwards [6] (Exercise #14(iv), p. 163) asks for the evaluation of $\int \frac{dx}{x^5 + 1}.$ Edwards mentions that this integral appeared on an 1891 Cambridge College Examination Paper. The answer is given on p. 887. However, the answer is stated in terms of $\cos{\frac{\pi}{5}}$ and $\cos{\frac{3\pi}{5}}.$ Edwards [6] (Exercise #42, p. 167) asks the reader to show that $\int_{0}^{\infty} \frac{x}{x^5 + 1}dx \; = \; \frac{4 \pi}{5 \sqrt{10} \; + \; 2 \sqrt{5}}.$

$$ \text{EVALUATION OF} \;\; \int \frac{dx}{x^6 + 1} $$

Courant/John [4] (Exercise #1, p. 321) and Spivak [17] (Section 19, Exercise #7(x), p. 381) ask for the evaluation of $\int \frac{dx}{x^6 + 1}$ (neither gives the answer). Edwards [6] (Exercise #15, p. 163) asks the reader to show that $\int_{0}^{\infty} \frac{dx}{x^6 + 1} = \frac{\pi}{3}.$ [Edwards mentions that this integral appeared on an 1881 St. John's College Examination Paper.] Federer/Jonsson [7] (Exercise #1(t), p. 616) gives an integral to evaluate whose denominator is $x^6 + 1$ (no answer is given). Vallee Poussin [20] (Exercise 1, 4th integral, p. 189) asks the reader to evaluate $\int \frac{dx}{2 - x^6}$ (the answer is given).

$$ \text{FACTORING} \;\; x^n + 1 $$

The factorizations of $x^n + 1$ for $n$ both even and odd into linear and irreducible quadratic factors making use of the cosine function are given in Archbold [1] (Example 1, p. 154) and Mostowski/Stark [12] (Exercise 1, p. 278). The same factorizations of $x^n + 1$ are derived using De Moivre's formula in Durell/Robson [5] (p. 220, eqs. 3 & 4). Hobson [10] (pp. 117-119, eqs. 26 & 27) gives a derivation without the use of De Moivre's formula (due to Norman MaCleod Ferrers in Messenger of Mathematics, Volume 5) and Hobson [10] (Example 2, pp. 239-240) gives a derivation that makes use of De Moivre's formula. Factorizations of $x^n + a^n$ for $n$ both even and odd are given in Tignol [19] (p. 100, eqs. 3 & 4; see also pp. 108-109, 125). Tignol [19] also gives a detailed discussion of the historical development and importance of these factorizations in Chapter 7 (pp. 97-107). Durell/Robson [5] (p. 226), Hobson [10] (item 3, p. 240), and Jack [11] give factorizations of $x^{2n} - 2x^{n}\cos{\theta} + 1$ into $n$ quadratic polynomials. By replacing $x$ with $\frac{x}{a},$ this last result allows us to factor $x^{2n} - 2a^{n}x^{n}\cos{\theta} + a^{2n}.$ The factorizations in which $\cos{\theta}$ is a parameter can be used to obtain useful finite product expressions for $\sin{n\theta}$ and $\cos{n\theta},$ and other identities.

$$ \text{PARTIAL FRACTION EXPANSIONS OF} \;\; \frac{1}{x^n + 1} $$

The partial fraction expansions of $\frac{1}{x^n + 1}$ for $n$ both even and odd appear in Barnard/Child [2] (Exercise #21, p. 305) (the answers are given, but not a detailed solution). The partial fraction expansion of $\frac{1}{x^n + 1}$ for $n$ even appears in Durell/Robson [5] (Exercise #11, p. 236) (the answer is given, but not a detailed solution). Hobson [10] (pp. 241-242) derives the partial fraction decompositions of $\frac{x^{m-1}}{x^n + 1}$ for $n$ both even and odd, and for $m = 1,$ $2,\,\ldots,$ $n-1$ (use $m=1$ to get the expansion for $\frac{1}{x^n + 1}).$ Edwards [6] (Section 166, pp. 158-159) derives the partial fraction expansion and the antiderivative of $\frac{x^m}{x^{2n} \; - \; 2a^{n}x^{n}\cos{n\theta} \; + \; a^{2n}}$ for integers $m,\,n$ with $0 \leq m < 2n.$ [By choosing $a=1$ and $m=0$ and the angle $\theta$ so that $\cos{n\theta} = 0,$ we get the partial fraction expansion and the antiderivative of $\frac{1}{x^n + 1}$ for $n$ even.]

$$ \text{EVALUATION OF} \;\; \int \frac{dx}{x^n + 1} $$

Gopalan/Ravichandran [8] begin by mentioning $\int \frac{dx}{x^n + 1}$ is explicitly evaluated for $n=1,$ $2,$ $3,$ $4,$ $5,$ $6,$ $8,$ and $10$ in Ramanujan [15] (their paper's only reference). These evaluations of Ramanujan's are also cited in Berndt [3]. In an attempt to evaluate this integral for all positive integers $n$ (apparently they were not aware of the above results), they were able to effect an evaluation for any $n$ that is a power of $2.$ See Ravichandran [16] for some more details regarding this decomposition.

Palagallo/Price [13] begin by mentioning the results in Gopalan/Ravichandran [8] and Ramanujan [15]. Then they show how to evaluate $\int \frac{dx}{x^n + 1}$ where $n$ is any positive rational number. They do this by first evaluating $\int \frac{dx}{x^n + 1}$ for positive integers n (using De Moivre's Theorem and employing the cosine function to express the coefficients that arise) and then making an appropriate change of variables to reduce the $n = \frac{p}{q}$ case to the positive integer case. This more general type, where $n$ is a positive rational number, is a special case of an even more general type of integral -- the binomial integral. Note: The change of variables that Palagallo/Price [13] employ is a standard technique for evaluating certain types of binomial integrals. Binomial integrals are not mentioned in their paper, and their only references are Gopalan/Ravichandran [8] and Ramanujan [15].

Edwards [6] (Exercise #40, p. 167) asks for the evaluation of $\int \frac{x^{p-1}}{x^n + a^n}dx$ for $p - 1 < n$ and the answer is given for both $n$ even and $n$ odd. (I believe $p$ is to be an integer greater than or equal to $1.)$ Taylor/Mann [18] (Exercise 11, p. 740) asks the reader to show that if $a > 1,$ then $\int_{0}^{\infty}\frac{dx}{1 + x^a} \; = \; \frac{\pi}{a}\csc {\frac{\pi}{a}}.$

[1] John W. Archbold, Algebra, Sir Isaac Pitman & Sons, 1958.

[2] Samuel Barnard and James M. Child, Higher Algebra, MacMillian, 1960.

[3] Bruce C. Berndt, Ramanujan's notebooks, Mathematics Magazine 51 (1978), 147-164.

[4] Richard Courant and Fritz John, Introduction to Calculus and Analysis, Volume I, Interscience Publishers, 1965.

[5] Clement V. Durell and Alan Robson, Advanced Trigonometry, Dover Publications, 1930/2003.

[6] Joseph W. Edwards, A Treatise on the Integral Calculus Volume I, Chelsea, 1930/1954.

[7] Herbert Federer and Bjarni Jonsson, Analytic Geometry and Calculus, Ronald Press, 1961.

[8] M. A. Gopalan and V. Ravichandran, Note on the evaluation of $\int \frac{1}{1 + t^{2^n}}dt,$ Mathematics Magazine 67 (1994), 53-54.

[9] Ernst Hairer and Gerhard Wanner, Analysis by Its History, Springer-Verlag, 1996.

[10] Ernest W. Hobson, A Treatise on Plane and Advanced Trigonometry, 7th edition, Dover Publications, 1928/1957.

[11] John Jack, The factorisation of $1 - 2x^{n}\cos {\alpha} + x^{2n},$ Proceedings of the Edinburgh Mathematical Society 15 (1897), 97.

[12] Andrzej W. Mostowski and Marceli Stark, Introduction to Higher Algebra, Pergamon Press, 1964.

[13] Judith A. Palagallo and Thomas E. Price, Some remarks on the evaluation of $\int \frac{dt}{t^m + 1},$ Mathematics Magazine 70 (1997), 59-63.

[14] J. Matthew H. Peters, Some numerical series from $\int \frac{dx}{1 + x^n},$ Mathematical Gazette 67 #440 (June 1983), 95-101.

[15] Srinivasa Ramanujan, Notebooks of Srinivasa Ramanujan, Vol. 2, Tata Institute of Fundamental Research, Bombay, 1957.

[16] V. Ravichandran, On a series considered by Srinivasa Ramanujan, Mathematical Gazette 88 #511 (March 2004), 105-110.

[17] Michael Spivak, Calculus, 3rd edition, Publish or Perish, 1994.

[18] Angus E. Taylor and W. Robert Mann, Advanced Calculus, 2nd edition, Xerox College Publishing, 1972.

[19] Jean-Pierre Tignol, Galois' Theory of Algebraic Equations, World Scientific Publishing Company, 2001.

[20] Charles Jean Vallee Poussin, Cours d'Analyse Infinitesimale, Volume I, 12th edition, Gauthier-Villars and Librairie Universitaire (Louvain), 1959.


Here is an approach. You can get a nice closed form in terms of the hypergeomtric function

$$I = \int\frac{1}{1+x^n} dx = \sum_{k=0}^{\infty}(-1)^k \int x^{kn} dx= \sum_{k=0}^{\infty}\frac{(-1)^kx^{nk+1}}{kn+1} + c $$

$$ \implies I = x\,{\mbox{$_2$F$_1$}(1,{n}^{-1};\,1+{n}^{-1};\,-{x}^{n})}+c.$$


Let $f(x)=\frac{1}{x^n+1}$. Note that we can write

$$f(x)=\prod_{k=1}^n(x-x_k)^{-1} \tag {1}$$

where $x_k=e^{i(2k-1)\pi/n}$, $k=1, \cdots,n$.

We can also express $(1)$ as

$$f(x)=\sum_{k=1}^na_k(x-x_k)^{-1} \tag {2}$$

where $a_k=\frac{-x_k}{n}$.

Now, we can write

$$\begin{align} \int\frac{1}{x^n+1}dx=-\frac1n\sum_{k=1}^nx_k\log(x-x_k)+C \end{align}$$

which can be more explicitly written as

$$\bbox[5px,border:2px solid #C0A000]{\int\frac{1}{x^n+1}dx=-\frac1n\sum_{k=1}^n\left(\frac12 x_{kr}\log(x^2-2x_{kr}x+1)-x_{ki}\arctan\left(\frac{x-x_{kr}}{x_{ki}}\right)\right)+C'} $$

where $x_{kr}$ and $x_{ki}$ are the real and imaginary parts of $x_k$, respectively, and are given by

$$x_{kr}=\text{Re}\left(x_k\right)=\cos \left(\frac{(2k-1)\pi}{n}\right)$$

$$x_{ki}=\text{Im}\left(x_k\right)=\sin \left(\frac{(2k-1)\pi}{n}\right)$$

NOTE :

Here, we derive the form $a_k=-\frac{x_k}{n}$. To that end, we use $(2)$ and observe that

$$\begin{align} \lim_{x\to x_\ell}\left((x-x_{\ell})\sum_{k=1}^{n}a_k(x-x_k)^{-1}\right)&=\lim_{x\to x_\ell}\left((x-x_{\ell})\frac{1}{1+x^n}\right) \tag 3 \end{align}$$

The left-hand side of $(3)$ is simply $a_{\ell}$. For the right-hand side, straightforward application of L'Hospital's Rule yields

$$\begin{align} \lim_{x\to x_\ell}\left(\frac{(x-x_{\ell})}{1+x^n}\right)&=\frac{1}{nx_{\ell}^{n-1}} \end{align}$$

Finally, we note that since $x_{\ell}^n=-1$, then

$$\begin{align} \frac{1}{nx_{\ell}^{n-1}}&=\frac{x_{\ell}}{nx_{\ell}^n}\\\\ &=-\frac{x_{\ell}}{n} \end{align}$$

Thus, we have that

$$\bbox[5px,border:2px solid #C0A000]{a_{k}=-\frac{x_k}{n}}$$