Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overflow error in SR approx #4266

Closed
robertwb opened this issue Oct 11, 2008 · 5 comments
Closed

overflow error in SR approx #4266

robertwb opened this issue Oct 11, 2008 · 5 comments

Comments

@robertwb
Copy link
Contributor

sage: round(sqrt(Integer('1'*500)))
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "/Users/robert/sage/current/local/lib/python2.5/site-packages/sage/misc/functional.py", line 865, in round
    except AttributeError: return RealDoubleElement(__builtin__.round(x, 0))
  File "/Users/robert/sage/current/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 6164, in __float__
    return float(f._approx_(float(g)))
  File "/Users/robert/sage/current/local/lib/python2.5/site-packages/sage/calculus/calculus.py", line 7941, in _approx_
    return math.sqrt(x)
OverflowError: math range error

Approx should fall back to mpfr if float fails.

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/4266

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-3.2 milestone Oct 18, 2008
@robertwb
Copy link
Contributor Author

comment:2

This is related to #188...

@robertwb
Copy link
Contributor Author

comment:3

Attachment: 4266-sr-round.patch.gz

I assume there is good reason that "always return an RDF" is enforced. SR elements should probably implement round() themselves.

@mwhansen
Copy link
Contributor

comment:4

Actually, I don't know of a good reason that "always return as RDF" is enforced. It seems like floor, round, and ceiling should return Integers where possible. There is a trac ticket by Nick Alexander that does this for some objects.

@williamstein
Copy link
Contributor

comment:5

REFEREE REPORT:

The attached patch fixes the reported problem.

I agree that changing round, etc., to not return RDF's makes perfect sense, but I think that should be an entirely new trac ticket.

I doctested only the calculus tree after applying this patch, and all was good.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Nov 28, 2008

comment:6

Merged in Sage 3.2.1.rc0

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Nov 28, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants