Ticket #12718 (needs_work defect)

Opened 14 months ago

Last modified 13 months ago

polynomial substitution overflow hell (libsingular bug?)

Reported by: was Owned by: malb
Priority: critical Milestone: sage-5.10
Component: commutative algebra Keywords:
Cc: Work issues:
Report Upstream: N/A Reviewers: Volker Braun, William Stein
Authors: Martin Albrecht Merged in:
Dependencies: Stopgaps:

Description

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 

Attachments

trac_12718_singular_overflow.patch Download (17.2 KB) - added by malb 14 months ago.

Change History

comment:1 Changed 14 months ago by was

  • Stopgaps set to todo

comment:2 Changed 14 months ago by malb

Ah, crap, we took care of the actual overflows but missed this one. I'll try to port our fix from __pow__ over this weekend.

comment:3 Changed 14 months ago by was

By the way, this bug was quickly hit by Ben Hutz, who is doing research in arithmetic dynamics, which involves dynamics of *iterating* maps.

comment:4 Changed 14 months ago by malb

  • Status changed from new to needs_review
  • Authors set to Martin Albrecht

comment:5 Changed 14 months ago by malb

I am not sure what I am supposed to do about this stopgap business.

comment:6 Changed 14 months ago by was

  • Status changed from needs_review to needs_work

REFEREE REPORT:

This looks great except for one little thing. Can you give examples to illustrate the max_degree_per_variable parameter in the Python-callable functions that define it.

Changed 14 months ago by malb

comment:7 Changed 13 months ago by malb

  • Status changed from needs_work to needs_review

comment:8 Changed 13 months ago by malb

I removed max_degree_per_variable because it turns out to not work anyway.

comment:9 Changed 13 months ago by vbraun

Looks good!

comment:10 Changed 13 months ago by vbraun

  • Status changed from needs_review to positive_review
  • Reviewers set to Volker Braun, William Stein
  • Stopgaps todo deleted

comment:11 Changed 13 months ago by jdemeyer

In cdef int singular_polynomial_subst(), did you verify that adding the sig_on() conditions doesn't slow things down? If you need a function call to determine whether to call sig_on(), it's probably faster to always call sig_on().

comment:12 Changed 13 months ago by jdemeyer

Never mind, the difference is hardly noticable anyway. Your way (with the conditional sig_on()) seems to be very slightly faster.

comment:13 Changed 13 months ago by malb

Btw. it's the "standard" way we do it in the singular interface. I think Joel Mohler introduced it ages ago.

comment:14 Changed 13 months ago by jdemeyer

  • Status changed from positive_review to needs_work

On 32-bit systems:

**********************************************************************
File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/devel/sage-main/sage/rings/polynomial/multi_polynomial_libsingular.pyx", line 3154:
    sage: n=1000; f = x^n; f.subs(x = x^n)
Exception raised:
    Traceback (most recent call last):
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_61[28]>", line 1, in <module>
        n=Integer(1000); f = x**n; f.subs(x = x**n)###line 3154:
    sage: n=1000; f = x^n; f.subs(x = x^n)
      File "multi_polynomial_libsingular.pyx", line 3240, in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.subs (sage/rings/polynomial/multi_polynomial_libsingular.cpp:21411)
        raise OverflowError("Exponent overflow (%d)."%(degree))
    OverflowError: Exponent overflow (1000000).
**********************************************************************
File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/devel/sage-main/sage/rings/polynomial/multi_polynomial_libsingular.pyx", line 3157:
    sage: n=100000; f = x^n; f.subs(x = x^n)
Expected:
    Traceback (most recent call last):
    ...
    OverflowError: Exponent overflow (10000000000).
Got:
    Traceback (most recent call last):
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/Users/buildbot/build/sage/moufang-1/moufang_full/build/sage-5.0.beta15/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_61[29]>", line 1, in <module>
        n=Integer(100000); f = x**n; f.subs(x = x**n)###line 3157:
    sage: n=100000; f = x^n; f.subs(x = x^n)
      File "multi_polynomial_libsingular.pyx", line 2347, in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.__pow__ (sage/rings/polynomial/multi_polynomial_libsingular.cpp:16619)
        singular_polynomial_pow(&_p, self._poly, exp, _ring)
      File "polynomial.pyx", line 322, in sage.libs.singular.polynomial.singular_polynomial_pow (sage/libs/singular/polynomial.cpp:3976)
      File "singular.pyx", line 667, in sage.libs.singular.singular.overflow_check (sage/libs/singular/singular.cpp:6526)
    OverflowError: Exponent overflow (100000).
**********************************************************************
Last edited 13 months ago by jdemeyer (previous) (diff)
Note: See TracTickets for help on using tickets.