Skip to content

Commit

Permalink
Use correct accuracy for the RR domain
Browse files Browse the repository at this point in the history
We use two extra guard digits from the maximum precision of all coefficients.

Previously:

In [1]: simplify(1e-14*I)
Out[1]: 0

Now:

In [1]: simplify(1e-14*I)
Out[1]: 1.0e-14⋅ⅈ

Fixes sympy#9398
  • Loading branch information
certik committed May 16, 2015
1 parent d9b59fd commit 2c14682
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sympy/polys/constructor.py
Expand Up @@ -6,6 +6,7 @@
from sympy.polys.polyoptions import build_options
from sympy.polys.polyerrors import GeneratorsNeeded
from sympy.polys.domains import ZZ, QQ, RR, EX
from sympy.polys.domains.realfield import RealField
from sympy.utilities import public
from sympy.core import sympify

Expand Down Expand Up @@ -44,7 +45,8 @@ def _construct_simple(coeffs, opt):
domain, result = _construct_algebraic(coeffs, opt)
else:
if reals:
domain = RR
max_prec = max([c._prec for c in coeffs])
domain = RealField(prec=max_prec+2)
else:
if opt.field or rationals:
domain = QQ
Expand Down

0 comments on commit 2c14682

Please sign in to comment.