diff --git a/diofant/core/numbers.py b/diofant/core/numbers.py index dbc13da2e19..bdc3e6312d2 100644 --- a/diofant/core/numbers.py +++ b/diofant/core/numbers.py @@ -1854,6 +1854,9 @@ def __new__(cls, expr, coeffs=(1, 0), alias=None, **kwargs): return obj + def _eval_is_real(self): + return self.root.is_real + @property def free_symbols(self): return set() diff --git a/diofant/domains/algebraicfield.py b/diofant/domains/algebraicfield.py index b3606848d97..3225d0b823f 100644 --- a/diofant/domains/algebraicfield.py +++ b/diofant/domains/algebraicfield.py @@ -127,6 +127,10 @@ def is_nonnegative(self, a): """Returns True if ``a`` is non-negative. """ return self.domain.is_nonnegative(a.LC()) + @property + def is_real(self): + return self.ext.is_real + class AlgebraicElement(DomainElement, CantSympify): """Dense Algebraic Number Polynomials over a field. """ diff --git a/diofant/domains/tests/test_domains.py b/diofant/domains/tests/test_domains.py index 4ff1d84b6de..372aed3a1f2 100644 --- a/diofant/domains/tests/test_domains.py +++ b/diofant/domains/tests/test_domains.py @@ -676,6 +676,11 @@ def test_Domain__algebraic_field(): assert alg.characteristic() == 0 + assert alg.is_real is True + + alg = QQ.algebraic_field(I) + assert alg.is_real is False + def test_PolynomialRing_from_FractionField(): F, x, y = field("x,y", ZZ)