Asymptotic error of Fourier series partial sum of sawtooth function In Iwaniec's book, Topics in Classical Automorphic Forms, pg. 4, he gives the statement:
$$\{x\}=\frac{1}{2}-\sum_{n=1}^N\frac{\sin 2\pi nx}{\pi n}+O((1+||x||N)^{-1})$$
where $\{x\}$ denotes the fractional part of $x\in\mathbb R$, and $||x||$ denotes the distance from $x$ to the nearest integer, and the implied constant is "absolute" (which I take to mean that it is independent of $x$ and $N$).
I haven't been able to prove this bound for the error.  Does anyone have any ideas how to proceed?
 A: It suffices to prove this for $0 \leq x \leq 1/2$. Let $$g_N(x)=\sum_{n=1}^N\frac{\sin 2\pi nx}{\pi n}+x-\frac{1}{2}$$
To show $g_N(x)=O(\frac{1}{1+xN})$, it suffices to show $g_N(x)$ is $O(\frac{1}{xN})$ and also $O(1)$.  But it's hard to show $O(1)$ directly so I'll actually show it is $1/2+O(\log(1+xN))$, which together with $O(\frac{1}{xN})$ implies $O(1)$.
Let $$D_N(t)=1+2\sum_{n=1}^N\cos2 \pi nt=\frac{\sin2\pi(N+1/2)t}{\sin\pi t}$$ be the Dirichlet kernel.  Observe that $g_N'(x)=D_N(x)$.  Thus: $$g_N(x)=\int_0^xD_N(t)dt - \frac{1}{2}$$
The Dirichlet kernel satisfies the inequalities $|D_N(t)| \leq 2N+1$ and $|D_N(t)|\leq \frac{1}{2|t|}$ for $0<|t|<1/2$.  We combine these to get $|D_N(t)| \leq \frac{7}{2}\frac{N}{1+N|t|}$.  Then we have: $$\int_0^x|D_n(t)|dt \leq \frac{7}{2}\int_0^x\frac{N}{1+Nt}dt=\frac{7}{2}\log(1+xN)$$
Thus we get $g_N(x)=1/2+O(\log(1+xN))$.
It remains to show that $g_N(x)=O(\frac{1}{xN})$.  To get that kind of bound, we need to use the trick of integrating by parts, but we can't do that on $\int_0^xD_N(t)dt$ because the boundary terms will blow up.  So we use the fact that $D_N(1-t)=D_N(t)$ and $\int_0^1D_N(t)dt=1$ to rewrite $g_N(x)$ as: $$g_N(x)=-\frac{1}{2}\int_x^{1-x}D_N(t)dt$$ for $0 \leq x \leq 1/2$.  Now we can integrate by parts to get:$$\int_x^{1-x}D_n(t)dt=\frac{1}{\pi(N+\frac{1}{2})}\frac{\cos 2\pi(N+\frac{1}{2})x}{\sin\pi x}-\frac{1}{2(N+\frac{1}{2})}\int_x^{1-x}\frac{\cos 2\pi(N+\frac{1}{2})tdt}{\sin^2\pi t}$$
Using the fact that $\sin\pi t \geq 2t$ for $0 \leq t \leq 1/2$, the first term above is bounded by $\frac{1}{2\pi}\frac{1}{(N+1/2)x}$.  A similar calculation for the second term gives a bound of $\frac{1}{8}\frac{1}{(N+1/2)x}$.  Putting this together, we get: $$|g_N(x)|\leq\left(\frac{1}{4\pi}+\frac{1}{16}\right)\frac{1}{(N+\frac{1}{2})x}$$
Thus, $g_N(x)=O(\frac{1}{xN})$ and so also $O(1)$, thus $g_N(x)=O(\frac{1}{1+xN})$, and we are done.
ADDED LATER:
In response to the question about the bound $|D_N(t)| \leq \frac{7}{2}\frac{N}{1+N|t|}$, we consider two cases:
Case 1:  When $\frac{1}{2|t|} \leq 2N+1$, we have $\frac{1}{N|t|} \leq 4 + 2/N \leq 6$, since $N$ is a positive integer.  Therefore,
$$|D_N(t)| \leq \frac{1}{2|t|} \leq \frac{1}{2|t|} \cdot \frac{7}{1+\frac{1}{N|t|}} =\frac{1}{2|t|} \cdot \frac{7N|t|}{1+ N|t|} = \frac{7}{2}\frac{N}{1+N|t|}.$$
Case 2:  When $\frac{1}{2|t|} \geq 2N+1$, since $N \geq 1$ we have
$$|D_N(t)| \leq 2N+1 \leq \frac{7N}{5N+2}(2N+1) = \frac{7}{2} \frac{N}{1+N/(4N+2)} \leq \frac{7}{2}\frac{N}{1+N|t|}.$$
