# Trigonometric diophantine equation $8\sin^2\left(\frac{(k+1)\pi}{n}\right)=n\sin\left(\frac{2\pi}{n}\right)$

Background. I thought up the problem of finding a regular $n$-sided polygon that has a diagonal with length $d_k$ such that the area of the polygon equals ${d_k}^2$. (Let $d_k$ denote the length of a diagonal that skips $k$ vertices, so that $d_0$ is the length of a side.) By doing some trigonometry I got the equation

$$8\sin^2\left(\frac{(k+1)\pi}{n}\right)=n\sin\left(\frac{2\pi}{n}\right).$$

I have checked some values of $n$ and it seems that $(4,0)$ and $(12,3)$ are the only (primitive and non-trivial) possible values for $(n,k)$.

Question. Are there other solutions?

One approach could be rewriting the equation using $\sin(x)=\frac i2(e^{-ix}-e^{ix})$. This gives $$4(\zeta_n^{k+1}+\zeta_n^{-k-1})-in(\zeta_n+\zeta_n^{-1})=8,$$ where $\zeta_n=e^{2\pi i/n}$.

Update. Except for $n=4$, we have $n=4p$ with $p\equiv3\pmod4$ prime. Furthermore, $\gcd(n,k+1)=4$.

See my answer below. Thanks to user dinoboy for the suggested technique.

• maple found for $n \le 100$ only solutions for which $n=4,12$. For $n=4$ we have $k=0,2,4,6,...$ while for $n=12$ we have $k=3,7,15,19,...$ the pattern repeating mod 12. – coffeemath Jan 25 '13 at 13:49
• Perhaps squaring both sides and then using an automorphism approach similar to math.stackexchange.com/questions/235658/… works. If this method works out I'll post a follow-up answer but unfortunately I don't have time right now to try it. – dinoboy Jan 25 '13 at 17:12
• I think the solutions $(12,3)$ and $(12,7)$ are the same, just going opposite ways around. Similarly, $(4,0)$ is one side and $(4,2)$ is the other side. Based on your original problem, you demand $k \le n-2$ and solutions $k$ and $n-2-k$ are equivalent. – Ross Millikan Mar 28 '13 at 16:48

## 3 Answers

(4,0) and (12,3) are the only "primitive and non-trivial" solutions $(n,k)$ with $n\leq 10^5$.

Considering the symmetries that are present both in your geometry question and in the resulting equation, let a "primitive and non-trivial" solution be a pair $(n,k)$ with $n,k\in \mathbb{Z}$, $n\geq 3$, and $0\leq k \leq n/2 - 1$, satisfying$$8\sin^2\left(\frac{(k+1)\pi}{n}\right)=n\sin\left(\frac{2\pi}{n}\right).$$ The fact that $k$ can be restricted to a finite interval for each $n$ opens the problem up for a direct numerical search. Here's my implementation in PARI/GP:

N_MIN=3;
N_MAX=100000;
N_BLOCKSIZE=100;
TOLERANCE=1e-20;

\\ We express the problem in terms of m,n, where m=k+1.
\\ We only call the (slow) sin function once for each computation of the LHS.
lhs(m,n)={sqrt_lhs=sin(m*Pi/n); sqrt_lhs*sqrt_lhs;}
rhs(n)=sin(2*Pi/n)*n/8;

\\ Check m,n for |LHS-RHS| < TOLERANCE
for(n=N_MIN,N_MAX,cur_rhs=rhs(n); if(n%N_BLOCKSIZE==0,printf("# Done checking all n<%u\n", n)); for(m=1,n/2,{
cur_lhs=lhs(m,n);
if(abs(cur_lhs-cur_rhs)<TOLERANCE, printf("%u\t%u\t%e\n", n, m-1, cur_lhs-cur_rhs))
}));
quit


Note: If I'm not mistaken, this is guaranteed to find all solutions $(m,n)$ with $n<n_\max = 10^5$, even though floating point math is used (assuming there are no bugs in PARI/GP or my computer). The point is that PARI/GP claims a default precision of 38 decimal digits, while the tolerance for root-finding in the above code is equivalence to 20 decimal digits. If you calculate the error propagation assuming 38-digit precision for the sin functions, the maximum absolute error after the few arithmetic operations per $n,m$ pair is still on the order of $10^{-38}$. The code can in principle give false positives if the RHS and LHS aren't equal but happen to be within the tolerance of one another, but it can't give false negatives. (In fact for these parameters there were no false positives, either.)

Update: Here is an implementation in C using 128-bit floating point arithmetic:

#include <stdio.h>
#include <quadmath.h>

// To compile: gcc -O3 -std=c99 -lquadmath trig.c -o trig

#define M_2PIq 6.2831853071795864769252867665590058q

#define N_MIN 3
#define N_MAX 2000
#define N_BLOCKSIZE 100
#define TOLERANCE 1e-20q
#define DIGITS 35

int main(){

// We express the problem in terms of m,n, where m=k+1.
for(unsigned n=N_MIN; n<=N_MAX; n++){

// Print out a status update each N_BLOCKSIZE iterations.
if(n%N_BLOCKSIZE==0) printf("# Done checking all n<%u\n", n);

// Compute the RHS only once per n
__float128 cur_rhs = sinq(M_2PIq/n)*n/8.0q;
for(unsigned m=1; 2*m<=n; m++){

// We only call the (slow) sin function once for each computation of the LHS.
__float128 cur_lhs=sinq(m*M_PIq/n);
cur_lhs*=cur_lhs;

// Print out (n,k) if a solution is found
if( fabsq(cur_lhs-cur_rhs) < TOLERANCE ){
char str_difference[DIGITS];
quadmath_snprintf(str_difference, DIGITS, "%Qe", fabsq(cur_lhs-cur_rhs));
printf("%u\t%u\t%s\n", n, m-1, str_difference);
}
}
}

}

• Instead of iterating over possible values of $m$ for every $n$, one can rewrite the equation as $m=\frac{n}{2\pi}\arccos (1-\frac{n}{4}\sin\frac{2\pi}{n})$ and just check if the resulting value is close enough to an integer. This allows one to extend the check all the way to $n_\mathrm{max}=10^7$ in a few minutes. – Peter Košinár Dec 21 '13 at 0:34

Small remark: It is clear that if pair $(n,k)$ with $0\le k<\left\lfloor\frac{n}{2}\right\rfloor$ satisfies the equality then pairs $(n, k+nt)$ and $(n, n-2-k+nt)$ also satisfy it (where $t\in\mathbb{Z^+}$).

As @Peter Košinár noted this equality is equivalent to $$4\cos\left(\frac{2\pi(k+1)}{n}\right)+n\sin\left(\frac{2\pi}{n}\right)=4$$ so for known $n$ the value of $k$ can be found as $$k=\frac{n}{2\pi}\arccos\left(1−\frac{n}{4}\sin \frac{2\pi}{n}\right)-1$$ If $\frac{n}{2\pi}\arccos\left(1−\frac{n}{4}\sin \frac{2\pi}{n}\right)$ is an integer then an appropriate pair is found.

The simple program written in C++ (which uses the type long double for calculations) gives the following pairs $(n,k)$ for $n\le 10^9$:

         n         k
4         0
12         3
104758793  36318061
211160884  73205826
211708650  73395727
317015209 109903690
423417300 146791455
423965066 146981356
634030418 219807381
742623573 257454750
846286834 293393010
846834600 293582911
847382366 293772812
847930132 293962713
848477898 294152614
952688925 330280775
953236691 330470676
953784457 330660577
954332223 330850478
954879989 331040379


Is it a result of the errors of numerical calculations or not? I don't know.

Dinoboy's suggestion to proceed as in For which $(n,m,l)$ does $L_n^2+L_m^2=L_l^2$ hold? already gives an excellent result. At the end I sketch how it might be exploited further.

Partial progress: $(n,k)=(4,0),(4,2)$ or $n=4p$ with $p\equiv3\pmod4$ prime, and $\gcd(n,k+1)=4$.

We start from the equivalent (via a double-angle formula)

$$4\cos\left(\frac{2\pi(k+1)}{n}\right)+n\sin\left(\frac{2\pi}{n}\right)=4.$$

Claim: $4\mid n$. We have that $2\cos({2\pi(k+1)}/{n})$ is integral, so $n\sin(2\pi/n)/2$ is. It is known that $\sin(2\pi/n)$ is not integral for $n>2$, so $4\mid n$.

The automorphism trick. We write everything in terms of $\zeta_n=e^{2\pi i/n}$: $$4(\zeta_n^{k+1}+\zeta_n^{-k-1})-\zeta_n^{n/4}n(\zeta_n-\zeta_n^{-1})=8.$$ We take the sum over all automorphisms of $\mathbb Q[\zeta_n]$ determined by $\zeta_n\mapsto\zeta_n^l$ with $\gcd(l,n)=1$ (note that we don't need to know that $\mathbb Q[\zeta_n]/\mathbb Q$ is Galois). It will be useful to know that:

Lemma. $\sum_{(l,n)=1}\zeta_n^{ml}=\mu\left(\frac n{(n,m)}\right)\frac{\varphi(n)}{\varphi(n/(n,m))}$

Proof. Switching order of summation in $\sum_{l=1}^n\zeta_n^{kl}\sum_{d\mid n,l}\mu(d)$, which is a bit messy if $(k,n)\neq1$. Alternatively, do the case $\gcd(k,n)=1$ first, giving $\mu(n)$, then note that $\zeta_n^m=\zeta_{n/(n,m)}^{m/(n,m)}$ and that every automorphism of $\mathbb Q[\zeta_{n/(n,m)}]$ extends to an automorphism of $\mathbb Q[\zeta_n]$ in exactly $[\mathbb Q[\zeta_n]:\mathbb Q[\zeta_{n/(n,m)}]]=\frac{\varphi(n)}{\varphi(n/(n,m))}$ ways, which is necessarily of the form $\zeta_n\mapsto\zeta_n^l$. $\square$

Let $d=(n,k+1)$. We get $$8\frac{\mu(n/d)}{\varphi(n/d)}-n\frac{\mu(n/(n,\frac n4+1))}{\varphi((n/(n,\frac n4+1))}+n\frac{\mu(n/(n,\frac n4-1))}{\varphi((n/(n,\frac n4-1))}=8.$$

Casework...

• If $8\mid n$, the last two terms in the LHS are $0$ due to $\mu$. So $\mu(n/d)=\varphi(n/d)=1$, so $d=n$ and $n\mid k+1$. The original equation becomes $n\sin(2\pi/n)=0$, $\perp$.
• If $n\equiv4\pmod{16}$, $(n,\frac n4+1)=2$ and $(n,\frac n4-1)=4$, and vice versa if $n\equiv12\pmod{16}$. Either way, $\varphi((n/(n,\frac n4+1))=\varphi((n/(n,\frac n4-1))$, the $\mu$'s have opposite sign and we get $$\frac{\mu(n/d)}{\varphi(n/d)}\pm\,\frac n4\cdot\frac{\mu(n/4)}{\varphi(n/4)}=1.$$ with $\pm\,=+$ for $n\equiv4\pmod{16}$.
• If $\mu(n/d)=0$ then $n/4=\varphi(n/4)$, so $n=4$. Either by the geometric interpretation or from the starting equation we get $k=0$ or $k=3$. From now on we may suppose $n\geq12$.
• If $\mu(n/4)=0$ we have $\mu(n/d)=\varphi(n/d)=1$. So $n\mid k+1$, $\perp$ (as above)
• If $\mu(n/d)\neq0\neq\mu(n/4)$ then $2\mid d$, so $\varphi(n/d)\mid\varphi(n/2)=\varphi(n/4)$. For the $2$-adic valuation of the LHS to be $0$, we must have $\varphi(n/d)=\varphi(n/4)$, i.e. $d=2$ or $d=4$.
We have $\frac n4\varphi(n/4)=\pm\,\varphi(n/4)^2\pm\varphi(n/4)$. If $n/4$ has more than one prime divisor, $\frac n4\geq\varphi(n/4)+2$ and there are no solutions. Let $n=4p$, $p$ prime. We have $$\mu(n/d)\mp\,p=p-1,$$ so $\mp=+$, $n\equiv12\pmod{16}$, $p\equiv3\pmod4$, $d=4$.

Remark. Because $\zeta_n+\zeta_n^{-1}$ is known to have degree $\varphi(n)/2$, we could have said in the beginning that $$\varphi(n)/2\mid[\mathbb Q[\zeta_n^{k+1},i]:\mathbb Q]\mid2\varphi(n/d)$$ from which it follows that $d\mid4$.

Idea. We might use the automorphism trick with a weighted sum, perhaps with $\left(\frac lp\right)$ as weights. This leads to studying Gauss-like sums, and we get $$4\sum_{(l,4p)=1}\left[\left(\frac lp\right)\zeta_{4p}^{(k+1)l}+\left(\frac lp\right)\zeta_{4p}^{-(k+1)l}\right]-\sum_{(l,4p)=1}\left[\left(\frac lp\right)\zeta_{4p}^{(p+1)l}-\zeta_{4p}^{(p-1)l}\right]=8\sum_{(l,4p)=1}\left(\frac lp\right).$$ It turns out that this particular choice does not tell us anything new: Changing the summation variables, it becomes $$8\sum_{(l,p)=1}\left(\frac lp\right)\zeta_p^l+8\left(\frac{-1}p\right)\sum_{(l,p)=1}\left(\frac lp\right)\zeta_p^l\\-2\left(\frac{(p+1)/4}p\right)\sum_{(l,p)=1}\left(\frac lp\right)\zeta_p^l+2\left(\frac{(p-1)/2}p\right)\sum_{(l,2p)=1}\left(\frac lp\right)\zeta_{2p}^l=0.$$

For $\sum_{(l,2p)=1}\left(\frac lp\right)\zeta_{2p}^l$ we multiply by $\zeta_{2p}^p=-1$, change the summation variable to $(l+p)/2$ to get $-\left(\frac2p\right)\sum_{(l,p)=1}\left(\frac lp\right)\zeta_p^l$. So everything cancels.