All known bugs in Sage silently producing wrong answers

24 views
Skip to first unread message

William Stein

unread,
Mar 21, 2012, 2:56:43 PM3/21/12
to sage-devel, Martin Albrecht, libsingular-devel
Hi Proud Sage Developers,

At the current Sage workshop some people (me, David Roe, Jen
Balakrishnan, etc.) have made a stopgap function and identified Trac
tickets describing "Bugs silently producing wrong answers". So far
they listed 7 of them: http://trac.sagemath.org/sage_trac/report/79

Do *you* know of such a bug in Sage that has not been classified as
such? Several of the ones listed below have been *known* for over 3
years.

* Trac 12718:

Somebody just pointed out this *doooozie* to me at ICERM [2] a few minutes ago

sage: R.<x,y> = QQ[]
sage: n=1000; f = x^n; f.subs(x = x^n)
x^1000000
sage: n=100000; f = x^n; f.subs(x = x^n)
x^1410065408*y^2

This looks like a serious libsingular bug.

* Trac 4942:

sage: f = x^2*log(x,2) - 1
sage: find_root(f, 0, 2)
0.0
sage: f.limit(x=0) # but 0 is not a root in any sense
-1

* Trac 9505:

sage: var('x,y,z'); f=x*y*z
(x, y, z)
sage: f.coeff(x)
y*z
sage: f.coeff(x*y)
0

This is by definition in GINAC (and Maxima), but is surprising and
confusing, e.g., one expects to get z above, and Mathematica does give
z.

* Trac 11358:

"matrix multiplication over ZZ sometimes gives incorrect results"
Yep.
I just posted a patch.

* Trac 11832:

sage: P3 = SteenrodAlgebra(p=3, profile=(lambda n: Infinity, lambda n: 1))
sage: P3._has_nontrivial_profile()
False

That's crazy? (I guess -- I have no clue whether it is crazy or not.)
There's a patch up.

* Trac 12509:

sage: K.<a> = NumberField(x^2-x-1); E = EllipticCurve([0, a + 1, 1,
28665*a - 46382, 2797026*a - 4525688])
sage: P = E([72*a - 509/5, -682/25*a - 434/25]); P.height()
1.35648516097058
sage: magma(E)(magma([P[0], P[1]])).Height()
1.38877711688727252538242306

The output from Sage is wrong after the 2 digit. Explicitly computing
to higher precision works fine, so some precision estimates in the
code are off.

* Trac 6667:

sage: K = Qp(2, prec=5)
sage: P.<x> = K[]
sage: f = P(x^4 + 2^3*x^3 + 2^13*x^2 + 2^21*x + 2^37)
sage: f.newton_polygon()
[(0, 37), (1, 21), (2, 13), (3, 3), (4, 0)]

This above is not even convex (the point (2,13) should not be there).

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Martin Albrecht

unread,
Mar 24, 2012, 10:11:10 AM3/24/12
to libsingu...@googlegroups.com, William Stein, sage-devel
On Wednesday 21 Mar 2012, William Stein wrote:
> Hi Proud Sage Developers,
>
> At the current Sage workshop some people (me, David Roe, Jen
> Balakrishnan, etc.) have made a stopgap function and identified Trac
> tickets describing "Bugs silently producing wrong answers". So far
> they listed 7 of them: http://trac.sagemath.org/sage_trac/report/79
>
> Do *you* know of such a bug in Sage that has not been classified as
> such? Several of the ones listed below have been *known* for over 3
> years.
>
> * Trac 12718:
>
> Somebody just pointed out this *doooozie* to me at ICERM [2] a few minutes
> ago
>
> sage: R.<x,y> = QQ[]
> sage: n=1000; f = x^n; f.subs(x = x^n)
> x^1000000
> sage: n=100000; f = x^n; f.subs(x = x^n)
> x^1410065408*y^2

This is not a Singular bug but a bug in code wrote, I have a fix almost ready.

However, I ran into this Singular bug when looking at

http://trac.sagemath.org/sage_trac/ticket/7795

> ring r = 3,(T,z),dp;
> poly f = z^3 + T*z;
> f^(3^15);
Segmentation fault

It doesn't seem to be a simple "catch the overflow" bug. Any ideas?

Cheers,
Martin

--
name: Martin Albrecht
mail: martinr...@googlemail.com
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://martinralbrecht.wordpress.com/
_jab: martinr...@jabber.ccc.de

han...@mathematik.uni-kl.de

unread,
Mar 24, 2012, 11:50:07 AM3/24/12
to libsingu...@googlegroups.com
On Sat, Mar 24, 2012 at 02:11:10PM +0000, Martin Albrecht wrote:
> On Wednesday 21 Mar 2012, William Stein wrote:
> > Hi Proud Sage Developers,
> >
> > At the current Sage workshop some people (me, David Roe, Jen
> > Balakrishnan, etc.) have made a stopgap function and identified Trac
> > tickets describing "Bugs silently producing wrong answers". So far
> > they listed 7 of them: http://trac.sagemath.org/sage_trac/report/79
> >
> > Do *you* know of such a bug in Sage that has not been classified as
> > such? Several of the ones listed below have been *known* for over 3
> > years.
> >
> > * Trac 12718:
> >
> > Somebody just pointed out this *doooozie* to me at ICERM [2] a few minutes
> > ago
> >
> > sage: R.<x,y> = QQ[]
> > sage: n=1000; f = x^n; f.subs(x = x^n)
> > x^1000000
> > sage: n=100000; f = x^n; f.subs(x = x^n)
> > x^1410065408*y^2
>
> This is not a Singular bug but a bug in code wrote, I have a fix almost ready.
Yes, this is an overflow in the exponent, one need to check
<ring>->bitmask before (as ithis is the maximum for an exponent)

>
> However, I ran into this Singular bug when looking at
>
> http://trac.sagemath.org/sage_trac/ticket/7795
>
> > ring r = 3,(T,z),dp;
> > poly f = z^3 + T*z;
> > f^(3^15);
> Segmentation fault
>
> It doesn't seem to be a simple "catch the overflow" bug. Any ideas?
This is in principle a recursive call to p_Power, which results in a
stack overflow. I will try to change it to a non-recursive code.

Hans

han...@mathematik.uni-kl.de

unread,
Mar 26, 2012, 7:19:41 AM3/26/12
to libsingu...@googlegroups.com
On Sat, Mar 24, 2012 at 04:50:07PM +0100, han...@mathematik.uni-kl.de wrote:
> > However, I ran into this Singular bug when looking at
> >
> > http://trac.sagemath.org/sage_trac/ticket/7795
> >
> > > ring r = 3,(T,z),dp;
> > > poly f = z^3 + T*z;
> > > f^(3^15);
> > Segmentation fault
> >
> > It doesn't seem to be a simple "catch the overflow" bug. Any ideas?
> This is in principle a recursive call to p_Power, which results in a
> stack overflow. I will try to change it to a non-recursive code.
>
> Hans
>
Here is the patch, which should fix this, if the characteristic is not too large:
--- a/kernel/polys1.cc
+++ b/kernel/polys1.cc
@@ -344,8 +344,8 @@ poly p_Power(poly p, int i, const ring r)
return p_Pow(p,i,r);
if ((char_p==0) || (i<=char_p))
return p_TwoMonPower(p,i,r);
- poly p_p=p_TwoMonPower(p_Copy(p,r),char_p,r);
- return p_Mult_q(p_Power(p,i-char_p,r),p_p,r);
+ poly p_p=p_TwoMonPower(p_Copy(p,r),(i/char_p)*char_p,r);
+ return p_Mult_q(p_Power(p,i % char_p,r),p_p,r);
}
/*end default:*/
}

Hans

han...@mathematik.uni-kl.de

unread,
Mar 27, 2012, 8:41:30 AM3/27/12
to libsingu...@googlegroups.com
On Mon, Mar 26, 2012 at 01:19:41PM +0200, han...@mathematik.uni-kl.de wrote:
> On Sat, Mar 24, 2012 at 04:50:07PM +0100, han...@mathematik.uni-kl.de wrote:
> > > However, I ran into this Singular bug when looking at
> > >
> > > http://trac.sagemath.org/sage_trac/ticket/7795
> > >
> > > > ring r = 3,(T,z),dp;
> > > > poly f = z^3 + T*z;
> > > > f^(3^15);
> > > Segmentation fault
> > >
> > > It doesn't seem to be a simple "catch the overflow" bug. Any ideas?
> > This is in principle a recursive call to p_Power, which results in a
> > stack overflow. I will try to change it to a non-recursive code.
> >
> > Hans
> >
Sorry, the last fix would produce wrong answers (as p_TwoMonPower does
not work as expected).
kernel/polys1.cc
@@ -344,8 +349,7 @@

return p_Pow(p,i,r);
if ((char_p==0) || (i<=char_p))
return p_TwoMonPower(p,i,r);
- poly p_p=p_TwoMonPower(p_Copy(p,r),char_p,r);
- return p_Mult_q(p_Power(p,i-char_p,r),p_p,r);
+ return p_Pow(p,i,r);
}
/*end default:*/
For a better solution see the newest version of polys1.cc

Hans

Reply all
Reply to author
Forward
0 new messages