# 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.

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.

edit retag close merge delete

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

( 2023-11-26 14:22:34 +0100 )edit

@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.

( 2023-11-26 14:35:16 +0100 )edit

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

( 2023-11-26 14:49:53 +0100 )edit

@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)?

( 2023-11-26 14:57:47 +0100 )edit

Sort by » oldest newest most voted

Using the method radical_expression for algebraic real field element, you can sometimes obtain a result. Its doc says Attempt to obtain a symbolic expression using radicals. If no exact symbolic expression can be found, the algebraic number will be returned without modification:

sage: AA
Algebraic Real Field
1/4*sqrt(5) - 1/4
(7/144*I*sqrt(3) + 7/432)^(1/3) + 7/36/(7/144*I*sqrt(3) + 7/432)^(1/3) - 1/6


But it does not work for n=17 and n=257:

sage: AA(cos(2*pi/17)).radical_expression()
0.9324722294043558?
0.9997011578430937?

more

Here in a sample code using GAP's RadiRoot package that works for $n=5$ and $n=17$. It produces the result in the form of a LaTeX file. For $n=257$, it gives an error Transitive groups of degree 128 are not available, while for $n=65537$ it goes into lengthy calculations (I was not patient enough to wait for an answer).

n = 5
f = cos(2*pi/n).minpoly()
x = f.variables()[0]
gap.eval(f'{x} := Indeterminate( Rationals, "{x}" );')
assert gap.eval(f'IsSolvablePolynomial({f});')     # necessary condition
fname = gap.eval(f'RootsOfPolynomialAsRadicals( {f}, "latex" );').strip('"')
with open(fname) as file:
for line in file:
print(fr'{line.rstrip()}')

more

Thx. Works fine for n=17; but not for n=5 or n=257... (at my cocalc).

( 2023-11-26 19:02:36 +0100 )edit

@Max Alekseyev Did you test this with your code?

( 2023-11-26 21:52:35 +0100 )edit

( 2023-11-27 01:51:52 +0100 )edit

I think, if it can't calc for the Fermat prime $n=257$, it wont be able to calc for the Fermat prime $n=65537$.

( 2023-11-27 09:58:52 +0100 )edit