# Maximum Value of $|\sum_{k=1}^n (-1)^{\lfloor ak/b\rfloor}|$

Let $$a,b\in\mathbb{N}$$ such that $$(a,b)=1$$. If $$2\nmid a$$, then one can show that $$\rho_{a/b}(n)=\sum_{k=1}^n (-1)^{\lfloor ak/b\rfloor}$$ is periodic. Is there any explicit way to give the maximum of $$|\rho_{a/b}(n)|$$ in terms of $$a$$ and $$b$$? As a first attempt we can show that $$\rho_{a/b}(n+b)=\sum_{k=1}^{n+b}(-1)^{\lfloor ak/b\rfloor}=\rho_{a/b}(b)+\sum_{k=1}^n(-1)^{\lfloor a(k+b)/b\rfloor}=\rho_{a/b}(b)+(-1)^a\rho_{a/b}(n).$$ Since we assume that $$2\nmid a$$ we have that $$\rho_{a/b}(n+2b)=\rho_{a/b}(n)$$ meaning the period is $$\le 2b$$. Since the function starts at $$0$$ and $$\rho_{a/b}(2b)=0$$, combined with the fact that it moves in discrete steps, gives $$\max|\rho_{a/b}(n)|\le b.$$ However, I've noticed that the maximum doesn't seem to depend too reliably on just $$b$$. If you fix $$b$$ you can achieve a whole spectrum of bounds by adjusting $$a$$. Hence, I've wondering if we can improve this bound, or even better explicitly find the max.

Edit: Since $$2b$$ is a valid period, if $$T_0$$ is a fundamental period we know that $$T_0\mid 2b$$. Moreover, we know that any period must be even due to $$\rho_{a/b}(T_0)=0$$ so that there can be an equal number of negative terms as even terms. Thus $$T_0=2d$$ for some $$d\mid b$$. We know that for whatever $$T_0$$ we find that $$\max |\rho_{a/b}(n)|\le T_0/2$$ however, the function rarely achieves this maximum of $$T_0/2$$.

Edit 2: Let $$M(a,b)=\max |\rho_{a/b}(n)|$$. As noted we have that $$M(a_1,b)=M(a_2,b)$$ if $$a_1\equiv a_2\mod 2b$$. Hence for fixed $$b$$, it suffices to analyze $$a\in [-b,b]$$. Notice that we have $$\left\lfloor\frac{-ak}{b}\right\rfloor=\begin{cases} -\left\lfloor\frac{ak}{b}\right\rfloor - 1 & b\nmid k \\ -\left\lfloor\frac{ak}{b}\right\rfloor & b\mid k \end{cases}.$$ Hence, $$\rho_{a/b}(n)+\rho_{-a/b}(n)=2\sum_{\substack{k=1 \\ b\mid k}}^n(-1)^{\left\lfloor\frac{ak}{b}\right\rfloor}=2\sum_{k=1}^{\lfloor n/b\rfloor}(-1)^k=\begin{cases} -2 & 2\nmid \lfloor n/b\rfloor \\ 0 & 2\mid \lfloor n/b\rfloor \end{cases}.$$ Thus $$|M(a,b)-M(-a,b)|\le 2.$$ Thus to properly analyze bounds on $$M(a,b)$$ it suffices to analyze $$M(a,b)$$ for $$a\in [1,b]$$.

• It’s interesting to note that $\rho_{(a+2b)/b}(x)=\rho_{a/b}(x)$ since $(-1)^{\lfloor (a+2b)k/b \rfloor}=(-1)^{\lfloor ak/b + 2k\rfloor}=(-1)^{\lfloor ak/b \rfloor}$, so we have another period of $2b$. Also, by comparing terms, we have $\rho_{a/b}(x)+\rho_{a/b+1}(x)=\rho_{2a/b}(\lfloor x/2 \rfloor)$, which may be of use as well. – Jacob Nov 19 '18 at 20:58

A pretty solid estimation is as follows. By playing around with the fourier series of $$\rho_{a/b}$$ we find that for all $$x\in \mathbb{N}$$, $$\rho_{a/b}(x)=\frac{1}{2b}\sum_{n=1}^{2b}\rho_{a/b}(n)+\frac{1}{2b}\cdot\frac{1}{\pi}\sum_{n=1}^{2b}\psi^{(0)}\left(\frac{n}{2b}\right)\left[a_n\cos\left(\frac{n\pi x}{b}\right)-b_n\sin\left(\frac{n\pi x}{b}\right)\right]$$ where \begin{aligned} a_n &= \sum_{k=1}^{2b}(-1)^{\lfloor ak/b\rfloor}\sin\left(\frac{n\pi k}{b}\right) \\ b_n &= \sum_{k=1}^{2b} (-1)^{\lfloor ak/b\rfloor}\cos\left(\frac{n\pi k}{b}\right). \end{aligned} and $$\psi^{(0)}$$ is the digamma function. Thus, $$\|\rho_{a/b}\|_{\infty}\le \frac{1}{2b}\left(\left|\sum_{n=1}^{2b}\rho_{a/b}(n)\right|+\frac{1}{\pi}\sum_{n=1}^{2b}\left|\psi^{(0)}\left(\frac{n}{2b}\right)\right|\left[|a_n|+|b_n|\right]\right)$$ simply using the triangle inequality and $$\sin$$ and $$\cos$$'s upper bounds.