# For which $n$ is $\int \limits_0^{2\pi} \prod \limits_{k=1}^n \cos(k x)\,dx$ non-zero?

I can verify easily that for $n=1$ and $2$ it's $0$, $3$ and $4$ nonzero, $4$ and $5$ $0$, etc. but it seems like there must be something deeper here (or at least a trick).

-
I deleted my answer because the hint I gave was incorrect. – Américo Tavares Jul 4 '11 at 20:28

Apparently, this isn't an easy question. See here for $n \leq 10$.

EDIT: As Jason pointed out below, the last paragraph on the linked page sketches the proof that the integral is non-zero iff $n$ $=$ $0$ or $3$ mod $4$ (that is, iff $n \in \lbrace 3,4,7,8,11,12,\ldots\rbrace$).

-
 well, great searching :) – user9413 Jul 4 '11 at 19:31 @Chandru, actually this was quite easy to find. – Shai Covo Jul 4 '11 at 19:37 The last paragraph on the linked page sketches the solution for all $n$. – Jason Swanson Jul 4 '11 at 19:42 @user11867: Thanks for pointing this out. – Shai Covo Jul 4 '11 at 19:47

Write $2 \cos ( k x) = e^{ k i x} + e^{- k i x}$. Hence we get (ignoring the multiplicative factor of $2^n$): $$\int_0^{2\pi} \prod_{k=1}^n \left( e^{k i x} + e^{- k i x} \right) dx = \int_0^{2\pi} e^{-n(n+1)/ 2 \cdot i x} \prod_{k=1}^n \left( 1 + e^{2 k i x} \right) dx$$ The product will be a sum of terms, each term is either 1 (the first term) or of the form $e^{2 \Sigma i x}$, where $\Sigma$ runs over all linear combinations of elements of {$1, 2, \dots, n$} (which doesn't use any term more than once). When multiplied by $e^{-n(n+1)/2 \cdot i x}$, the resulting integrand term will contribute either 0 or +1 to the final result depending on whether $n(n+1) = 4 \Sigma$. So long as either $n \equiv 0$ or $3$ modulo 4, we can find terms from $1,2,\dots,n$ such that their sum is any natural number less than $n(n+1)/2$ and hence so that $n(n+1) = 4 \Sigma$.

-
Ah! You know I didn't understand this comment a year ago, but recently I revisited the problem and I like this solution much better than the other one. – Alexander Gruber Oct 4 '12 at 1:56
To clarify for other future readers who may be confused as I first was: This version of the proof hinges on the fact that $\int_0^{2\pi}e^{ikx}dx=0$ if and only if $k=0$. We can write every term in the integrand as $e^{i\left(-\frac{n(n+1)}{2}+2\delta\right)x}$ for some $\delta \in \mathbb{Z}$, so for a non-zero term we need $n(n+1)=4\delta$, or in other words $n(n+1)\equiv 0 \mod{4}$. All other terms vanish, so for the integral to be nonzero, we need either $n$ or $n+1$ to be congruent to $0\mod{4}$, whence $n\equiv 0 \text{ or } -1 \mod{4}$. Voila! Thanks again @anon. – Alexander Gruber Oct 4 '12 at 2:04

Hint: Start as anon did with $$\int_0^{2\pi}\prod_{k=1}^n\cos(kx)\,\mathrm{d}x =\int_0^{2\pi}e^{-i\frac{n(n+1)}{2}x}\prod_{k=1}^n(1+e^{i2kx})\,\mathrm{d}x\tag{1}$$ which would be $2\pi$ times the coefficient of $x^{n(n+1)/2}$ in $$\prod_{k=1}^n(1+x^{2k})\tag{2}$$ $(2)$ is the number of ways to write $n(n+1)/2$ as the sum of distinct even integers $\le2n$.

So $(1)$ is non-zero precisely when you can write $n(n+1)/2$ as the sum of distinct even integers $\le2n$ (a much simpler problem).

-