Function Repository Resource:

# Cos2PiOverFermatPrime

Closed form of cos(2π/p) where p is a Fermat prime (3, 5, 17, 257, 65537) a la Gauss

Contributed by: Michael Trott
 ResourceFunction["Cos2PiOverFermatPrime"][p,"Rules"] returns a list {cos,rules} where cos represents cos(2π/p) and rules is a list of replacements to be applied to cos. The value p can be one of the five Fermat primes 3, 5, 17, 257, 65537. ResourceFunction["Cos2PiOverFermatPrime"][p,trig] returns trig(2π/p) where trig can be any of the trigonometric function Cos,Sin,Tan,Cot,Sec, or Csc.

## Details and Options

ResourceFunction["Cos2PiOverFermatPrime"] is a faithful implementation of Gauss’ algorithm discovered on March 29, 1796.
The original result realized a ruler and compass construction of a regular 17‐gon.
The resulting expressions contain only square roots, no cube roots or higher roots.
The option GeneratedParameters can be used to specify the variable used to express the rules.

## Examples

### Basic Examples (3)

The classic Gauss result for cos(2π/17):

 In[1]:=
 Out[1]=

Using the "Rules" argument shows the recursive nature of the period values:

 In[2]:=
 Out[2]=

Applying the rules gives the above expression once again:

 In[3]:=
 Out[3]=

The cosine values for the two smallest Fermat primes:

 In[4]:=
 Out[4]=
 In[5]:=
 Out[5]=

### Scope (1)

Cos2PiOverFermatPrime gives results for all the basic trig functions:

 In[6]:=
 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=

### Options (2)

The default parameter is C:

 In[9]:=
 Out[9]=

Use subscripts for the period values:

 In[10]:=
 Out[10]=

### Applications (4)

The case p=257 was manually computed by Richelot in 1832:

 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=

cos(2π/257):

 In[13]:=

The expression contains more than 5,100 square roots:

 In[14]:=
 Out[14]=

Plot the frequency of occurrences of different square roots (mouseover points to see square roots):

 In[15]:=
 In[16]:=
 Out[16]=

The network of the period values of cos(2π/257):

 In[17]:=

Visualize with a graph:

 In[18]:=
 In[19]:=
 Out[19]=
 In[20]:=
 Out[20]=

Find the explicit numerical values of all periods:

 In[21]:=
 Out[21]=
 In[22]:=
 Out[22]=

### Properties and Relations (2)

The function ToRadicals does express cos(2π/257) in radicals, but not in square roots:

 In[23]:=
 Out[23]=

ToRadicals of cos(2π/17) returns an expression quite similar to Cos2PiOverFermatPrime:

 In[24]:=
 Out[24]=
 In[25]:=
 Out[25]=
 In[26]:=
 Out[26]=

### Possible Issues (1)

The computation for the Fermat prime 65,537 will take about 10 to 15 min on a modern laptop:

 In[27]:=
 Out[27]=

### Neat Examples (5)

The value of cos(2π/65537) was first computed by Johann Gustav Hermes and took him 10 years. The computation are still preserved in the famous "suitcase of Göttingen":

 In[28]:=

The length of the rule list is p-2:

 In[29]:=
 Out[29]=

To compute the period values, we change the rules to assignments and let the 65,535 assignments autoevaluate after numericalization of numbers:

 In[30]:=

The last value is just cos(2π/65537):

 In[31]:=
 Out[31]=

Plot the distribution of the 65,535 period values on a linear and on a logarithmic scale:

 In[32]:=
 Out[32]=
 In[33]:=
 Out[33]=

## Version History

• 1.0.0 – 18 October 2019