Ask Your Question
2

Comparing even powers of $i$ with 1

asked 2013-10-15 16:41:10 +0100

Ed Scheinerman gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
7

answered 2013-10-15 16:49:17 +0100

tmonteil gravatar image

updated 2013-10-15 16:56:48 +0100

Since I^4 is a symblic expression, I^4 == 1 is also a symbolic expression:

sage: expr = (I^4 == 1)       
sage: expr.parent()
Symbolic Ring

You can evaluate it by typing:

sage: bool(I^4 == 1)
True

But warning: if the expression is complicated and maxima is not able to decide wether it is True or False, then bool(expr) will return False.

A good advice is to avoid the symbolic ring as much as possible. For example, you can work in the algebraic field:

sage: QQbar(I)^4 == 1
True
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-10-15 16:41:10 +0100

Seen: 439 times

Last updated: Oct 15 '13