# Evaluation of exp(-I*2*pi/5)^5 fails to reduce to 1

In sagemath (version 8.1), I fail to have exp(-I*2*pi/5) ^ 5 nicely reduced to 1. I get 1/1024*(sqrt(5) - I*sqrt(2*sqrt(5) + 10) - 1)^5 instead of 1.

exp(-I*2*pi/3)^3 does not produce 1 at first, but after expand I get 1 - which I fail to obtain with exp(-I*2*pi/5)^5.

exp(-I*2*pi/15) ^ 15 does not produce 1, even after expand.

But, other expression like : exp(-I2pi/35)^35 , exp(-I2pi/18)^18 just behave as expected.

I there a way to block the evaluation of exp(-I2pi/N) when N is small ? so to keep working only with exponent ?

edit retag close merge delete

Sort by » oldest newest most voted

This is indeed a weird behaviour: for some exponents k, Sage fails to turn exp(-I*2*pi/k)^k into 1 (48 seems to be the largest such exponent):

sage: for k in range(1, 10000):
....:     if str(exp(-I*2*pi/k)^k) != "1":
....:         print(k, exp(-I*2*pi/k)^k)
....:
3 (-1/2*I*sqrt(3) - 1/2)^3
5 1/1024*(sqrt(5) - I*sqrt(2*sqrt(5) + 10) - 1)^5
6 (-1/2*I*sqrt(3) + 1/2)^6
10 1/1048576*(sqrt(5) - I*sqrt(-2*sqrt(5) + 10) + 1)^10
12 1/4096*(sqrt(3) - I)^12
15 1/35184372088832*(sqrt(5) + 2*sqrt(-3/2*sqrt(5) + 15/2) - 8*I*sin(2/15*pi) + 1)^15
16 1/65536*(sqrt(sqrt(2) + 2) - I*sqrt(-sqrt(2) + 2))^16
20 (-1/4*I*sqrt(5) + 1/4*sqrt(2*sqrt(5) + 10) + 1/4*I)^20
24 (-(1/4*I - 1/4)*sqrt(6) + (1/4*I + 1/4)*sqrt(2))^24
30 1/1237940039285380274899124224*(sqrt(5) + 2*sqrt(3/2*sqrt(5) + 15/2) - 8*I*sin(1/15*pi) - 1)^30
48 1/79228162514264337593543950336*(sqrt(2*sqrt(6) + 2*sqrt(2) + 8) - I*sqrt(-2*sqrt(6) - 2*sqrt(2) + 8))^48


Even if we simplify the result afterwards, there are two remaining exponents:

sage: for k in range(1, 50):
....:     if str((exp(-I*2*pi/k)^k).full_simplify()) != "1":
....:         print(k)
15
30


This might be considered as a bug (should it ?).

Note however, that Sage correctly decides that those expressions are actually equal to 1:

sage: all(bool(exp(-I*2*pi/k)^k == 1) for k in range(1,50))
True


Now, you can indeed ask Sage to block the evaluation of the exponenential thanks to the hold option as follows:

sage: exp(-I*2*pi/15, hold=True)
e^(-2/15*I*pi)
sage: exp(-I*2*pi/15, hold=True)^15
1


And this seems to work for every exponent, except 1:

sage: for k in range(1, 10000):
....:     if str(exp(-I*2*pi/k, hold=True)^k) != "1":
....:         print(k, exp(-I*2*pi/k, hold=True)^k)
1 e^(-2*I*pi)

more

FWIW :

sage: %time exp(-I*2*pi/5)^5
CPU times: user 4.71 ms, sys: 100 µs, total: 4.81 ms
Wall time: 4.83 ms
1/1024*(sqrt(5) - I*sqrt(2*sqrt(5) + 10) - 1)^5
sage: %time (exp(-I*2*pi/5)^5).simplify()
CPU times: user 4.42 ms, sys: 7.53 ms, total: 12 ms
Wall time: 122 ms
1/1024*(sqrt(5) - I*sqrt(2*sqrt(5) + 10) - 1)^5
sage: %time (exp(-I*2*pi/5)^5).simplify_full()
CPU times: user 43.4 ms, sys: 7.33 ms, total: 50.7 ms
Wall time: 176 ms
1
sage: %time (exp(-I*2*pi/5)^5)._sympy_().simplify()._sage_()
CPU times: user 28.4 ms, sys: 21 µs, total: 28.4 ms
Wall time: 28.3 ms
1

( 2023-01-15 23:31:47 +0200 )edit