Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Comparing even powers of $i$ with 1

Computing $i^4$ yields $1$, but it's not the same $1$ as when I type $1$. Compare these two evaluations:

sage: I^4 == 1
1 == 1
sage: I^2 == 1
-1 == 1

I would have expected the first to yield True and the second to yield False. Is Sage's answer a desirable default behavior?

I see that the first $1$ is a sage.symbolic.expression.Expression and the other $1$ is a sage.rings.integer.Integer (likewise for the $-1$). How can I make the comparison evaluate as one might reasonably expect mathematically?