# Expand cos(2*pi/n) for n=5, 17, 257, 65537 to Radicals (Fermat prime numbers)

I want to expand $\cos\left( \dfrac{2\pi}{n} \right)$ for $n=5,~17,~ 257, 65537$ to radicals, for example: $\cos\left( \dfrac{2\pi}{5} \right) =\frac14 \sqrt{5} -\frac14$

BTW: These $n$ are *Fermat prime numbers*, see Exact trigonometric values.

Is this a possible task?

```
x = var('x')
test = (x+1)^2 # test
test.expand() # works :)
term = cos(2*pi/5)
term.expand() # works :)
term = cos(2*pi/17)
term.expand() # works not :(
```

PS: I tried

```
cos(2*pi/17).trig_simplify()
cos(2*pi/17).trig_expand()
```

as well.

GAP's package radiroot can do that - see https://www.gap-system.org/Packages/r...

@Max Alekseyev I'm asking in the here about a solution with SageMath / Python. The fact that there are basically programs that can do this is another topic. Thank you anyway.

GAP is naturally accessible from within Sage - see https://doc.sagemath.org/html/en/refe...

@Max Alekseyev Oh, I am sorry. 1) Can I use this when using online https://sagecell.sagemath.org/? 2) Could you give me a simple syntax example (including this library)?