Ask Your Question

Revision history [back]

You can directly try to simplify the symbolic expresssion, instead of looking for its numerical approximation (which is the of role the n() function):

sage: a = ((-1 + sqrt(-3))/2)*((-1-sqrt(-3))/2)
sage: a
-1/4*(sqrt(-3) + 1)*(sqrt(-3) - 1)
sage: a.parent()
Symbolic Ring
sage: a.full_simplify()
1

Now, if you follow the link provided by @Pierre last comment, you will see that Sage is not very reliable concerning Symbolic expressions (there are also undecidability results behind this). An alternative is to use the Algebraic Field which is much more reliable:

sage: a = QQbar((-1 + sqrt(-3))/2*(-1-sqrt(-3))/2)
sage: a
1.000000000000000? + 0.?e-19*I
sage: a.parent()
Algebraic Field
sage: a.simplify()
sage: a
1