# Linear exponential sum with gcd

The sum $$\sum _{d,d'\leq D}\sum _{h,h'=1}^q(h,q)e\left (\frac {dh+d'h'}{q}\right )$$ is easily seen to be $$\ll q^{2+\epsilon }+D^2.$$ Indeed with a standard estimate for a linear exponential sum it is $$\sum _{h,h'=1}^q(h,q)\min \left (D,\frac {1}{||h/q||}\right )\min \left (D,\frac {1}{||h'/q||}\right )\\ \ll D^2+D\sum _{h=1}^{q-1}\frac {(q,h)}{||h/q||}+\sum _{h,h'=1}^{q-1}\frac {(q,h)}{||h/q||\cdot ||h'/q||}$$ and then the claim follows from $$\sum _{h=1}^{q-1}\frac {(q,h)}{||h/q||}\ll \sum _{l|q}l\sum _{h=1\atop {(q,h)=l}}^{q-1}\frac {1}{||h/q||}\leq 2q\sum _{l|q}l\sum _{h=1\atop {(q,h)=l}}^{q-1}\frac {1}{h}\ll q(\log q)d(q)\ll q^{1+\epsilon }$$.

If I have instead the sum $$\sum _{d,d'\leq D}\sum _{h,h'=1}^q(h+h',q)e\left (\frac {dh+d'h'}{q}\right )$$ then I'm not sure if the same bound holds (the $$h\equiv h'$$ contribution is already too large, but perhaps there are other large contributions). Does it?

• What happens if you change variables $k=h+h'$, $k'=h'$ before estimating? That changes $d,d'$ to $d,d'-d$, which messes with the outer ranges of summation a bit but perhaps not significantly. – Greg Martin Mar 23 '19 at 0:19
• Then the $d,d'$ sums don't factor, so I can only get cancellation in one of them I think.. – caws Mar 23 '19 at 15:15