Ask Your Question

Revision history [back]

If your symbolic expression is a polynomial and your constants are algebraic numbers, work in a polynomial ring with coefficients in AA or QQbar.

sage: R.<x> = PolynomialRing(AA)
sage: a = AA(2).sqrt()
sage: x - a
x - 1.414213562373095?

Elements of AA or QQbar are exact. Compare:

sage: a = AA(2).sqrt()
sage: b = sqrt(2)
sage: c = n(sqrt(2))
sage: aa = a^2
sage: bb = b^2
sage: cc = c^2
sage: aa == 2
True
sage: bb == 2
2 == 2
sage: cc == 2
False