Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
2

Comparing even powers of i with 1

asked 11 years ago

Ed Scheinerman gravatar image

Computing i4 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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
7

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

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
Preview: (hide)
link

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: 11 years ago

Seen: 480 times

Last updated: Oct 15 '13