Skip to main content
added 293 characters in body
Source Link
GH from MO
  • 105.2k
  • 8
  • 292
  • 398

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv -1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

Added by GH from MO. The result of the above calculation can be expressed in the more symmetric form $$\frac{1}{pq}\sum_{m=1}^{p} \sum_{n=1}^{q} \frac{2}{\cos(\frac{2m\pi}{p})+\cos(\frac{2n\pi}{q})}=1-2\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\pb\equiv 2a+1 \pmod q}}(-1)^b.$$

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv -1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv -1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

Added by GH from MO. The result of the above calculation can be expressed in the more symmetric form $$\frac{1}{pq}\sum_{m=1}^{p} \sum_{n=1}^{q} \frac{2}{\cos(\frac{2m\pi}{p})+\cos(\frac{2n\pi}{q})}=1-2\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\pb\equiv 2a+1 \pmod q}}(-1)^b.$$

added 1 character in body
Source Link
GH from MO
  • 105.2k
  • 8
  • 292
  • 398

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{-n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$$$ T=-\sum_{n=1}^{q-1}\zeta_q^{n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv 1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$$$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv -1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{-n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv 1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv -1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

added 1 character in body
Source Link
GH from MO
  • 105.2k
  • 8
  • 292
  • 398

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n\leq q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$$$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$$$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand thesethe two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}&=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na}, \\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}&=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*}\begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} Therefore,It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{-n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv 1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n\leq q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand these into geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}&=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na}, \\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}&=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} Therefore, $$ T=-\sum_{n=1}^{q-1}\zeta_q^{-n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv 1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

I will continue from the point where Christophe Leuridan's answer stopped. Denote our sum $S$, then $$ S=2p\sum_{n=1}^q \frac{\sin(2\pi np/q)}{(1+\cos(2πnp/q))\sin(2\pi n/q)}. $$ For $n=q$ this is undefined, but the limit of our summand is $p/2$. Hence $S=p^2+2pT$ with $$ T=\sum_{n=1}^{q-1} \frac{\sin(2\pi np/q)}{(1+\cos(2\pi np/q))\sin(2\pi n/q)}. $$ Next, assume that $p<q$ and $q-p=2h$. We want to prove $S\leq pq(2h+1)$. This is the same as $p^2+2pT\leq pq(2h+1)$, i.e. $T\leq h(q+1)$. Since $\sin(2u)=2\sin(u)\cos(u)$, $1+\cos(2u)=2\cos^2(u)$, we see that $$ T=\sum_{n=1}^{q-1} \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}. $$ Next, $\tan(\pi np/q)=-\tan(2\pi hn/q)$. Let $\zeta_q=\exp(2\pi i/q)$. Then we get $$ \frac{\tan(\pi np/q)}{\sin(2\pi n/q)}=-\frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}}\cdot\frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}}. $$ Expand the two fractions on the right-hand side into finite geometric series: \begin{align*} \frac{\zeta_q^{nh}-\zeta_q^{-nh}}{\zeta_q^n-\zeta_q^{-n}} &=\zeta_q^{-n(h-1)}\sum_{a=0}^{h-1}\zeta_q^{2na},\\ \frac{2}{\zeta_q^{nh}+\zeta_q^{-nh}} &=\zeta_q^{nh}\sum_{b=0}^{q-1}(-1)^b\zeta_q^{2bnh}. \end{align*} It follows that $$ T=-\sum_{n=1}^{q-1}\zeta_q^{-n}\sum_{\substack{0\leq a\leq h-1\\ 0\leq b\leq q-1}}(-1)^b\zeta_q^{2na+2bnh}. $$ Switching the order of summation and using the fact that sum of $\zeta_q^{nk}$ over $1\leq n\leq q-1$ is $-1$ for $q\nmid k$ and $q-1$ for $q\mid k$, we see that $$ T=-q\sum_{\substack{0\leq a\leq h-1\\0\leq b\leq q-1\\2a+2bh\equiv 1 \pmod q}}(-1)^b+h\sum_{0\leq b\leq q-1}(-1)^b. $$ The second sum is equal to $1$ and the first one is at least $-h$, since $h$ and $q$ are coprime (hence for fixed $a$ there is a unique $b$). Therefore, $T\leq (-q)(-h)+h=q(h+1)$, as needed.

added 1 character in body
Source Link
GH from MO
  • 105.2k
  • 8
  • 292
  • 398
Loading
added 1 character in body
Source Link
GH from MO
  • 105.2k
  • 8
  • 292
  • 398
Loading
Link to answer
Source Link
LSpice
  • 12.9k
  • 4
  • 45
  • 69
Loading
added 6 characters in body
Source Link
Loading
Source Link
Loading