sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.2k stars 413 forks source link

(do not?) compute Groebner basis over dodgy fields #22387

Open dimpase opened 7 years ago

dimpase commented 7 years ago

Groebner basis algorithms don't quite work with polynomials with floating point coefficients (e.g. in RR), as this is prone to rounding errors.

Prior to Sage 7.5, it was possible to do these computations for some inputs (using the capability of Singular to compute with polynomial rings over their real and complex types(?)).

Another way to handle this would be to convert input coefficients to rationals, and then convert back. I am not sure whether this should be done automatically. See error for more info.

Component: commutative algebra

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

dimpase commented 7 years ago

Description changed:

--- 
+++ 
@@ -1,8 +1,7 @@
-Groebner basis algorithms don't work with polynomials with floating point coefficients (e.g. in RR), as this is prone to rounding errors.
+Groebner basis algorithms don't quite work with polynomials with floating point coefficients (e.g. in RR), as this is prone to rounding errors.

-Prior to Sage 7.5, it was possible to do these computations for some inputs (I guess for coefficients that was possible to convert to rationals). This is error-prone and should not be done naively, i.e. it can happen that the rational output cannot be converted back without loss of precision.
+Prior to Sage 7.5, it was possible to do these computations for some inputs (using the capability of Singular to compute with polynomial rings over their `real` and `complex` types(?)).

-The only way to handle this would be to convert input coefficients to rationals, and then convert back.
+Another way to handle this would be to convert input coefficients to rationals, and then convert back.
 I am not sure whether this should be done automatically.
-The [error](https://groups.google.com/d/msg/sage-devel/fpjl4opcGfQ/sjfknPdRBQAJ) thrown by Sage 7.5+ should be more graceful though.
-
+See [error](https://groups.google.com/d/msg/sage-devel/fpjl4opcGfQ/sjfknPdRBQAJ) for more info. 
dimpase commented 7 years ago
comment:2

On Sage 7.4, one also gets a similar error if the precision is too low:

sage: RRR=RealField(prec=10)
sage: P.<x,y> = PolynomialRing(RRR, order='lex'); P
Multivariate Polynomial Ring in x, y over Real Field with 15 bits of precision
sage: f=11*x^6*y-y^5*x^2+3*y+2
sage: g=x^3+y*x^2+3*y+13*x^5+2017*x^2*y^3
sage: ii=ideal(f,g)
sage: ii.groebner_basis()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
...
KeyError: '1.000e+00'

Running this example in Singular 4.1.0 directly produces the ideal (1) - which is of course nonsense (the exact answer consists of 2 polynomials, one of form x-t(y) and the other s(y), with degrees of s and t around 30, and huge rational coefficients).

> ring r = (real,10),(x,y),lp;
> poly f=11*x^6*y-y^5*x^2+3*y+2;
> poly g=x^3+y*x^2+3*y+13*x^5+2017*x^2*y^3;
> std(ideal(f,g));
_[1]=1

Certainly, there is in general no way to check that the result computed by Singular is correct (they could have detected a rounding error that led to this, but they don't).

johnperry-math commented 7 years ago
comment:3

Maybe just include a warning that the result is untrustworthy?