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.

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.
