# Is $\sum_{a=0}^m\sum_{b=0}^n\cos(abx)$ always positive?

Fix integers $$m,n\geq0$$.

Do we have the inequality $$\displaystyle\sum_{a=0}^m\sum_{b=0}^n\cos(abx)>0$$ for all $$x\in\mathbb{R}$$?

We can also write this function as \begin{align*} \sum_{a=0}^m\sum_{b=0}^n\cos(abx)&=m+n+1+\sum_{a=1}^m\sum_{b=1}^n\cos(abx)\\ &=m+n+1+\sum_{a=1}^m\frac{1}{2}\left(\frac{\sin((n+1/2)ax)}{\sin(ax/2)}-1\right)\\ &=\frac{m}{2}+n+1+\frac{1}{2}\sum_{a=1}^mD_n(ax), \end{align*} where $$D_n(x)=\frac{\sin((n+1/2)x)}{\sin(x/2)}$$ is the Dirichlet kernel (up to a factor of $$2\pi$$, depending on your convention).

Using this formula, it is easy to check the conjecture for small values of $$m$$ and $$n$$ (desmos link).

• Did you try to obtain a formula for the sum of Dirichlet kernels using $\sin t = \Re e^{it}$ and the formula for geometric sums?
– Gary
Oct 18, 2021 at 3:53
• I don't think that there is a closed form formula for the sum of Dirichlet kernels. The denominators make things tricky. You could phrase this whole question in terms of the real part of $\sum\sum e^{abx}$, which makes it easier to see why the denominators prevent you from applying the geometric series formula twice. Oct 18, 2021 at 4:02
• Yes, sorry I missed the denominator.
– Gary
Oct 18, 2021 at 4:16
• @RiverLi It arose in the context of this mathoverflow question: mathoverflow.net/questions/405593 Oct 18, 2021 at 16:41

No! Consider the case $$m = n$$ and $$x = \frac{8π}{4n + 3}$$. We have
$$\begin{split} \sum_{a=0}^n \sum_{b=0}^n \cos(abx) &= \frac{3n}{2} + 1 + \frac12 \sum_{a=1}^n \frac{\sin\left(\left(n + \frac12\right)ax\right)}{\sin\left(\frac12ax\right)} \\ &= \frac{3n}{2} + 1 + \frac12 \sum_{a=1}^n \frac{\sin\left(2πa - \frac{2πa}{4n + 3}\right)}{\sin\left(\frac{4πa}{4n + 3}\right)} \\ &= \frac{3n}{2} + 1 + \frac12 \sum_{a=1}^n \frac{\sin\left(-\frac{2πa}{4n + 3}\right)}{\sin\left(\frac{4πa}{4n + 3}\right)} \\ &= \frac{3n}{2} + 1 - \frac14 \sum_{a=1}^n \sec\left(\frac{2πa}{4n + 3}\right) \\ &< \frac{3n}{2} + 1 - \frac14 \int_0^n \sec\left(\frac{2πa}{4n + 3}\right)\,da \\ &= \frac{3n}{2} + 1 + \frac{4n + 3}{8π} \ln \tan \frac{3π}{4(4n + 3)} \\ &\sim \frac{3n}{2} + 1 + \frac{4n + 3}{8π} \ln \frac{3π}{4(4n + 3)} \\ &→ -∞ \quad \text{as n → ∞}. \end{split}$$
We can confirm this by plotting the exact sum at $$m = n$$ and $$x = \frac{8π}{4n + 3}$$ (blue); it first becomes negative at $$n = 3286$$. By optimizing $$x$$ near $$\frac{8π}{4n + 3}$$ to minimize the sum (orange), we find a slightly earlier negative value at $$m = n = 3161$$ and $$x = 0.001987239$$.
• From this approach, we can derive an infinite family of counterexamples when $m=n$. In particular, any function $f(n)$ such that $1/f(n)\in(n+1/2,n+1)$ for all positive $n$ yields a counterexample when $x=2\pi f(n)$. Oct 24, 2021 at 11:19
• Wow. ${}{}{}{}{}$ Oct 24, 2021 at 12:31
• @TheSimpliFire Not quite. $x = \frac{4π}{2n + 1}$ and $x = \frac{2π}{n + 1}$ do not lead to counterexamples, so neither does any function sufficiently close to them. You need a stronger condition like $\frac{2π}{x} ∈ (n + \frac12 + ε, n + 1 - ε)$ for some constant $ε > 0$. (But the math is uniquely simple for $x = \frac{8π}{4n + 3}$, which allows the double-angle cancellation on line 4.) Oct 24, 2021 at 18:56