TITLE: Iwaniec-Kowalski Exponential Sum for Quadratic Function
QUESTION [12 upvotes]: I am reading about 'Exponential Sums' in the book 'Analytic Number Theory' by  Iwaniec and Kowalski. On page 199 they mention the bound:
$$|S_f(N)|^2 \le N +2N^2q^{-1}+4(N+q)\log q \tag{1}$$
where, $\displaystyle S_f(n) = \sum\limits_{n=1}^{N} e^{2\pi i(\alpha n^2 +\beta n)}$ and $1 \le q \le 2N$ satisfies $\displaystyle 2\alpha = \frac{a}{q} + \frac{\theta}{2Nq}$,with $|\theta| < 1$ and $(a,q) = 1$.
I am having trouble following why $(1)$ along with the trivial bound $|S_f(N)| \le N$ implies,
$$|S_f(N)| \le 2Nq^{-1/2}+q^{1/2}\log q\tag{2}$$
How do we see the claim that $(2)$ is best possible?

"Is it possible to deduce (2) more directly, without much numerical work at small values?"

Applying Vander Corput's Inequlity, we may derive:
$$|S_f(N)|^2 \le \frac{N^2}{H}+\frac{N(2N-H)}{q}+4N\left(1+\frac{q}{H}\right)\log q$$
where, $1\le q < 2H$, and $H$ is an integer less than $N$ we are free to choose. Is there a way to proceed to $(2)$ from here?

REPLY [9 votes]: If $\log(q)\ge4$, then the fact that $N\le2N^2q^{-1}$ and $4q\log(q)\le q\log(q)^2$ show that
$$
N+2N^2q^{-1}+4(N+q)\log(q)\le\overbrace{4N^2q^{-1}+q\log(q)^2+4N\log(q)}^{\left(2Nq^{-1/2}+q^{1/2}\log(q)\right)^2}
$$
This shows that $(1)\implies(2)$.

If $q\le4$, then
$$
N^2\le4N^2q^{-1}+q\log(q)^2+4N\log(q)
$$
This and $|S_f(N)|\le N$ also verifies $(2)$.

Therefore, we need to consider
$$
4\lt q\lt e^4
$$
Consider
$$
N^2\gt4N^2q^{-1}+q\log(q)^2+4N\log(q)
$$
which is only true for
$$
N\gt\frac{q\log(q)}{\sqrt{q}-2}
$$
and
$$
N+2N^2q^{-1}+4(N+q)\log(q)
\gt4N^2q^{-1}+q\log(q)^2+4N\log(q)
$$
which is only true for
$$
N\lt\frac q4\left(1+\sqrt{1+32\log(q)-8\log(q)^2}\right)
$$
Unfortunately, between $q\doteq12.592$ and $q\doteq48.802$ the bounds on $N$ above permit some common values of $N$.

The convex blue curve is $\frac{q\log(q)}{\sqrt{q}-2}$ and the concave red curve is $\frac q4\left(1+\sqrt{1+32\log(q)-8\log(q)^2}\right)$. The area above the blue curve and below the red curve is where the problem lies.
For example, at $q=30$ and $N=32$, we have
$$
\begin{align}
N^2&=1024\\
N+2N^2q^{-1}+4(N+q)\log(q)&=943.764\\
4N^2q^{-1}+q\log(q)^2+4N\log(q)&=918.931
\end{align}
$$
Thus, it doesn't seem that the third bound, $(2)$, can be derived from the first bound, (1), and the trivial bound. This doesn't mean that $(2)$ is not valid, just that is does not seem to follow from the other bounds.