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)