-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Revert cif fast inversion 84ab655 #37941
Revert cif fast inversion 84ab655 #37941
Conversation
OK, though of course it would be better to debug the inversion routine if somebody has time for that. |
Sorry for the multiple label changes. I agree with the revert, but the tests currently fail, tough I don't think this is due to the changes made here. Also, you might want to add a test based on #37927 (comment). |
For a tentative to repair the currently very broken CI , see #37926 |
Isn't that enough? commit 7a00b56dca6a148cc577aab9b3ffd647d4204c15
Author: Vincent Delecroix <[email protected]>
Date: Mon May 6 00:05:36 2024 +0200
add doctests
diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx
index eb8c4f00da..8276d1e31e 100644
--- a/src/sage/rings/complex_interval.pyx
+++ b/src/sage/rings/complex_interval.pyx
@@ -1149,6 +1149,11 @@ cdef class ComplexIntervalFieldElement(FieldElement):
sage: 1 / CIF(RIF(-1,1),0)
[.. NaN ..] + [.. NaN ..]*I
+ Test that the bug reported in :issue:`37927` is fixed::
+
+ sage: (961 * (1 / CIF(0, 31))**2 + 1).contains_zero()
+ True
+
REFERENCES:
- [RL1971]_
diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
index 4e4454988c..773853ec67 100644
--- a/src/sage/rings/qqbar.py
+++ b/src/sage/rings/qqbar.py
@@ -552,6 +552,28 @@ Check that :issue:`28530` is fixed::
(0.999999587? + 0.?e-11*I, 1),
(0.999999999? + 0.?e-11*I, 1)]
+Check that issue:`37927` is fixed::
+
+ sage: y = polygen(QQ, 'y')
+ sage: v1 = QQbar.polynomial_root(y**2 + 1, CIF(0, -1))
+ sage: v2 = -QQbar(2).sqrt()
+ sage: M = matrix(QQbar, [[0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
+ ....: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
+ ....: [-4, 2*v1, 1, 64, -32*v1, -16, 8*v1, 4, -2*v1, -1],
+ ....: [4*v1, 1, 0, -192*v1, -80, 32*v1, 12, -4*v1, -1, 0],
+ ....: [2, 0, 0, -480, 160*v1, 48, -12*v1, -2, 0, 0],
+ ....: [-4, 2*I, 1, 64, -32*I, -16, 8*I, 4, -2*I, -1],
+ ....: [4*I, 1, 0, -192*I, -80, 32*I, 12, -4*I, -1, 0],
+ ....: [2, 0, 0, -480, 160*I, 48, -12*I, -2, 0, 0],
+ ....: [0, 0, 0, 8, 4*v2, 4, 2*v2, 2, v2, 1],
+ ....: [0, 0, 0, 24*v2, 20, 8*v2, 6, 2*v2, 1, 0],
+ ....: [0, 0, 0, 8, 4*v2, 4, 2*v2, 2, -v2, 1],
+ ....: [0, 0, 0, 24*v2, 20, 8*v2, 6, 2*v2, 1, 0],
+ ....: [0, 0, 0, -4096, -1024*I, 256, 64*I, -16, -4*I, 1],
+ ....: [0, 0, 0, -4096, 1024*I, 256, -64*I, -16, 4*I, 1]])
+ sage: M.right_kernel_matrix()
+ [ 1.000000000000000? + 0.?e-16*I 0 0 -0.00925925925925926? + 0.?e-19*I 0.?e-35 + 0.?e-18*I -0.11111111111111111? + 0.?e-18*I 0.?e-34 + 0.?e-17*I 0.5555555555555555? + 0.?e-16*I 0 -0.5925925925925926? + 0.?e-17*I]
+
AUTHOR:
- Carl Witty (2007-01-27): initial version |
As I mentioned in #37927, I think there is another underlying problem with mpfr not being able to find the difference between two different numbers:
My guess is that in that particular case, the difference is in the last bit, but one of the numbers uses a higher exponent (both examples I have seen involve the inverses of powers of 2 or powers of two minus one, which are where you would expect to find this kind corner cases), so the precision of the result is set to the bigger exponent, and that last bit of difference is lost. This problem is exposed in this case because the result of the inversion method is too tight, but I think it would be worth detecting this kind of problems and fixing them, because there are important performance advantages in using tight results. |
Contrarily to the
The two floating points above are the one appearing in our example
|
Documentation preview for this PR (built with commit c687feb; changes) is ready! 🎉 |
04c87b1
to
f6c384e
Compare
f6c384e
to
1f7c574
Compare
1f7c574
to
c687feb
Compare
@mezzarobba some doctest failures were due to the reversion. They are fixed in c687feb. |
Reducing to "critical" because "blocker" still doubles as "CI Fix" until this is merged: |
Thanks for taking care of this. I would really appreciate this PR to be part of the next beta as it does fix a critical bug! |
Sure, I somehow missed the first of the two tests, sorry! |
…_ - thus for complex interval division. The implementation is inspired by Rokne-Lancaster 1971. Some history: - The first implementation of returning tight intervals was commit 84ba655 (see ticket sagemath#19964). - That implementation had bugs (returning too small intervals) and was reverted to fix ticket sagemath#37941. - This change is the second implementation.
…_ - thus for complex interval division. The implementation is inspired by Rokne-Lancaster 1971. Some history: - The first implementation of returning tight intervals was commit 84ba655 (see ticket sagemath#19964). - That implementation had bugs (returning too small intervals) and was reverted to fix ticket sagemath#37941. - This change is the second implementation.
…_ - thus for complex interval division. The implementation is inspired by Rokne-Lancaster 1971. Some history: - The first implementation of returning tight intervals was commit 84ba655 (see ticket sagemath#19964). - That implementation had bugs (returning too small intervals) and was reverted to fix ticket sagemath#37941. - This change is the second implementation.
This provides a (hopefully) correct implementation of computing a tight enclosure for the inverse of a complex interval. It fixes sagemath#37963. There is some history to this: Commit 84ab655 from sagemath#19964 introduced a tight enclosure but had some bugs such as ticket sagemath#37927. Thus, the that commit (and the subsequent partial fixes) were reverted in commit 8d59b12, see pull request sagemath#37941. This is a new implementation of Rokne-Lancaster that I wrote from scratch. ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies sagemath#37941 URL: sagemath#38360 Reported by: Matthias Goerner Reviewer(s): Marc Culler, Nathan Dunfield
The tight reversion of complex intervals introduced in 84ab655 from #19964 made complex intervals wrong... and hence unreliable. This remained unnoticed until an apparently unrelated bug involving QQbar #37927. As an emergency measure we simply revert the tight reversion.
Fixes #37927
📝 Checklist