# Compute $I_{n}=\int_{-\infty}^\infty \frac{1-\cos x \cos 2x \cdots \cos nx}{x^2}\,dx$

I'm very curious about the ways I may compute the following integral. I'd be very glad to know your approaching ways for this integral:

$$I_{n} \equiv \int_{-\infty}^\infty {1-\cos\left(x\right)\cos\left(2x\right)\ldots\cos\left(nx\right) \over x^{2}} \,{\rm d}x$$

According to W|A, $I_1=\pi$, $I_2=2\pi$, $I_3=3\pi$, and one may be tempted to think that it's about an arithmetical progression here, but things change (unfortunately) from $I_4$ that is $\frac{9 \pi}{2}$. This problem
came to my mind when I was working on a different problem.

• Weird, right now it says that Chris' sister has asked this question. But it was Shaktal, as the edit history reveals. Commented Jul 27, 2012 at 13:18
• @Chris'sister +1 Nice question. I saw what Rasmus saw as well. Momentarily the question was displayed as that of Shaktal, but he just edited your question. Commented Jul 27, 2012 at 13:22
• Actually, I might just have missed the bottommost entry of the edit history. Commented Jul 27, 2012 at 13:26

First note that $$\int_{-\infty}^{\infty} \frac{1-\cos ax}{x^2} \; dx = \left[ -\frac{1-\cos ax}{x}\right]_{-\infty}^{\infty} + a \int_{-\infty}^{\infty} \frac{\sin ax}{x} \; dx = \pi \, |a|,$$ by the Dirichlet integral. Also, by mathematical induction we can easily prove that $$\prod_{k=1}^{n} \cos \theta_k = \frac{1}{2^n} \sum_{\mathrm{e}\in S} \cos\left( e_1 \theta_1 + \cdots + e_n \theta_n \right),$$ where the summation runs over the set $S = \{ -1, 1\}^n$. Thus we have \begin{align*} I_n = \int_{-\infty}^{\infty} \frac{1-\cos x \cdots \cos nx}{x^2} \; dx &= \frac{1}{2^n} \sum_{\mathrm{e}\in S} \int_{-\infty}^{\infty} \frac{1-\cos(e_1 x + \cdots + e_n nx)}{x^2} \; dx \\ &= \frac{\pi}{2^n} \sum_{\mathrm{e}\in S} \left|e_1 + \cdots + e_n n\right|. \end{align*} For example, if $n = 3$, we have $\left|\pm 1 \pm 2 \pm 3\right| = 0, 0, 2, 2, 4, 4, 6, 6$ and hence $$I_3 = \frac{\pi}{8}(0 + 0 + 2 + 2 + 4 + 4 + 6 + 6) = 3\pi.$$ Let the summation part as $$A_n = \sum_{\mathrm{e}\in S} |e_1 + \cdots + e_n n|.$$ The first 10 terms of $(A_n)$ are given by $$\left(A_n\right) = (2, 8, 24, 72, 196, 500, 1232, 2968, 7016, 16280, \cdots ),$$ and thus the corresponding $(I_n)$ are given by $$\left(I_n\right) = \left( \pi ,2 \pi ,3 \pi ,\frac{9 \pi }{2},\frac{49 \pi }{8},\frac{125 \pi }{16},\frac{77 \pi }{8},\frac{371 \pi }{32},\frac{877 \pi }{64},\frac{2035 \pi }{128} \right).$$ So far, I was unable to find a simple formula for $(A_n)$, and I guess that it is not easy to find such one.

p.s. The probability distribution of $S_n = e_1 + \cdots + e_n n$ is bell-shaped, and fits quite well with the corresponding normal distribution $X_n \sim N(0, \mathbb{V}(S_n))$. Thus it is not bad to conjecture that $$\frac{A_n}{2^n} = \mathbb{E}|S_n| \approx \mathbb{E}|X_n| = \sqrt{\frac{n(n+1)(2n+1)}{3\pi}},$$ and hence $$I_n \approx \sqrt{\frac{\pi \, n(n+1)(2n+1)}{3}}.$$ Indeed, numerical experiment shows that

I was able to prove a much weaker statement: $$\lim_{n\to\infty} \frac{I_n}{n^{3/2}} = \sqrt{\frac{2\pi}{3}}.$$ First, we observe that for $|x| \leq 1$ we have $$\log \cos x = -\frac{x^2}{2} + O\left(x^4\right).$$ Thus in particular, $$\sum_{k=1}^{n} \log\cos\left(\frac{kx}{n}\right) = \sum_{k=1}^{n}\left[-\frac{k^2 x^2}{2n^2} + O\left(\frac{k^4x^4}{n^4}\right)\right] = -\frac{nx^2}{6} + O\left(x^2 \vee nx^4\right).$$ Now let \begin{align*}\frac{1}{n^{3/2}} \int_{-\infty}^{\infty} \frac{1 - \prod_{k=1}^{n}\cos (kx)}{x^2} \; dx &= \frac{1}{\sqrt{n}} \int_{-\infty}^{\infty} \frac{1 - \prod_{k=1}^{n}\cos \left(\frac{kx}{n}\right)}{x^2} \; dx \qquad (nx \mapsto x) \\ &= \frac{1}{\sqrt{n}} \int_{|x|\leq 1} + \frac{1}{\sqrt{n}} \int_{|x| > 1} =: J_n + K_n. \end{align*} For $K_n$, we have $$\left|K_n\right| \leq \frac{1}{\sqrt{n}} \int_{1}^{\infty} \frac{2}{x^2}\;dx = O\left(\frac{1}{\sqrt{n}}\right).$$ For $J_n$, the substitution $\sqrt{n} x \mapsto y$ gives \begin{align*} J_n &= \frac{1}{\sqrt{n}} \int_{|x|\leq 1} \left( 1 - \exp\left( -\frac{nx^2}{6} + O\left(x^2 \vee nx^4\right) \right) \right) \; \frac{dx}{x^2} \\ &= \int_{|y|\leq\sqrt{n}} \left( 1 - \exp\left( -\frac{y^2}{6} + O\left(\frac{y^2}{n}\right) \right) \right) \; \frac{dy}{y^2} \\ &\xrightarrow[]{n\to\infty} \int_{-\infty}^{\infty} \frac{1 - e^{-y^2/6}}{y^2} \; dy \\ &= \left[-\frac{1-e^{-y^2/6}}{y}\right]_{-\infty}^{\infty} + \frac{1}{3} \int_{-\infty}^{\infty} e^{-y^2/6} \; dy = \sqrt{\frac{2\pi}{3}}. \end{align*} This completes the proof.

• $\displaystyle\prod_{k=1}^n \cos \theta_k = \frac{1}{2^n} \sum_{e\in S} \cos\left( e_1 \theta_1 + \cdots + e_n \theta_n \right)$ where $S= \{1,-1\}^n$. That identity was not (or could I have missed it?) in Wikipedia's list of trigonometric identities, so I've just added it to the article, in the section on product-to-sum identities. Commented Jul 27, 2012 at 16:44
• @MichaelHardy: Thanks! Actually, it easily follows by a repeated application of the most basic case $n = 2$. I suspect that this is why this identity is not listed so far. Commented Jul 27, 2012 at 17:03
• A very interesting question with a very beautiful answer. Commented Jul 27, 2012 at 18:28
• @sos440 : The fact that it easily follows doesn't mean everyone's noticed that it easily follows, so I think its inclusion is justified. Commented Jul 29, 2012 at 1:05
• Another way to get an upper bound on the sum $\sum_{e\in S}|\sum_{k=1}^n ke_k |$, is to note that $\sum_{e\in S}|\sum_{k=1}^n ke_k| \le 2^{n/2}\sqrt{\sum_{e\in S}(\sum_{k=1}^n ke_k)^2}$. The latter summation can be found to be equal to $2^{n+1}\sum_{k=1}^n k^2$, which produces the bound, $\sum_{e\in S}|\sum_{k=1}^n ke_k |\le 2^{n+1} \sqrt{\sum_{k=1}^n k^2}\implies, \frac{1}{2^n} \sum_{e\in S}|\sum_{k=1}^n ke_k |\le \sqrt{n(n+1)(2n+1)/3}$. Commented Jan 18, 2017 at 6:51

I thought it would be worth mentioning that $$\int_{-\infty}^{\infty} \frac{1-\prod_{k=1}^{n}\cos (a_{k}x)}{x^{2}} = \pi a_{n} \tag{1}$$ if the $a_{k}$'s are positive parameters and $a_{n} \ge \sum_{k=1}^{n-1} a_{k}.$

This integral is somewhat similar to the Borwein integral.

We can show $(1)$ by integrating the function $$f(z) = \frac{1-e^{ia_{n}z}\prod_{k=1}^{n-1}\cos(a_{k}z)}{z^{2}}$$ around an indented contour that consists of the real axis and the semicircle above it.

If $a_{n} \ge \sum_{k=1}^{n-1} a_{k}$, then $$1-e^{ia_{n}z}\prod_{k=1}^{n-1}\cos(a_{k}z) = 1- e^{ia_{n}x}\prod_{k=1}^{n-1}\frac{e^{ia_{k}z}-e^{-ia_{k}z}}{2}$$ is bounded in the upper half-plane. (If you expand, all of the exponentials are of the form $e^{ibz}$, where $b\ge 0$.)

So integrating around the contour, we get $$\operatorname{PV} \int_{-\infty}^{\infty} f(x) \, dx - i \pi \operatorname{Res} [f(z), 0] = 0,$$ where \begin{align}\operatorname{Res}[f(z),0] &= \lim_{z \to 0} \frac{1-e^{ia_{n}z}\prod_{k=1}^{n-1}\cos(a_{k}z)}{z} \\ &= \lim_{z \to 0} \left(-ia_{n}e^{ia_{n}z}\prod_{k=1}^{n-1}\cos(a_{k}z)+e^{ia_{n}z} \sum_{k=1}^{n-1} a_{k} \sin(a_{k}z) \prod_{\underset{j \ne k}{j =1}}^{n-1} \cos(a_{j}z)\right) \\ &= -i a_{n}. \end{align}

The result follows by equating the real parts on both sides of the equation.

• Good to know the complex approach (+1) Commented Apr 10, 2017 at 23:46