Opened 11 years ago
Closed 11 years ago
#12105 closed defect (fixed)
RuntimeError: Segmentation fault with nth_root
Reported by: | lfousse | Owned by: | jason, jkantor |
---|---|---|---|
Priority: | major | Milestone: | sage-5.0 |
Component: | numerical | Keywords: | |
Cc: | Merged in: | sage-5.0.beta3 | |
Authors: | Johan Bosman | Reviewers: | Karl-Dieter Crisman |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
sage: RealField(53)(0.05).nth_root(7 * 10^8) --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /opt/sage-4.7.2/<ipython console> in <module>() /opt/sage-4.7.2/local/lib/python2.6/site-packages/sage/rings/real_mpfr.so in sage.rings.real_mpfr.RealNumber.nth_root (sage/rings/real_mpfr.c:23889)() RuntimeError: Segmentation fault
Apply 12105.patch to the Sage repository.
Attachments (1)
Change History (7)
comment:1 Changed 11 years ago by
Changed 11 years ago by
Attachment: | 12105.patch added |
---|
comment:2 Changed 11 years ago by
Authors: | → Johan Bosman |
---|---|
Description: | modified (diff) |
Milestone: | → sage-4.8 |
Status: | new → needs_review |
comment:3 Changed 11 years ago by
Reviewers: | → Karl-Dieter Crisman |
---|
On Mac I don't get an error, but it hangs and eventually consumes all resources, so fair enough!
This patch gives
sage: timeit("RealField(53)(0.05).nth_root(7 * 10^8)") 625 loops, best of 3: 69.2 µs per loop
One question I have is whether this is the most appropriate test with this precision.
sage: RealField(53)(0.05).nth_root(7 * 10^8) 0.999999995720382 sage: _^(7*10^8) 0.0499999991341384
Is that good enough?
Otherwise this is fine, passes tests, etc. on 5.0.beta1.
comment:4 follow-up: 5 Changed 11 years ago by
It'll be difficult to get a more accurate answer with that precision. Let's turn the last 2 into a 3:
sage: 0.999999995720383^(7*10^8) 0.0500000185630449
comment:5 Changed 11 years ago by
Status: | needs_review → positive_review |
---|
It'll be difficult to get a more accurate answer with that precision.
Well, that's what I figured, but I'm not a numerical analysis expert. Thanks.
Positive review.
comment:6 Changed 11 years ago by
Merged in: | → sage-5.0.beta3 |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
The bug is in line 4708 of sage/rings/real_mpfr.pyx:
The result of that multiplication as a signed int may become negative and actually does so in your example.