sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 481 forks source link

asymptotics for multivariate generating functions: zero division error on last coordinate #19989

Open dkrenn opened 8 years ago

dkrenn commented 8 years ago
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_functions import FractionWithFactoredDenominatorRing
sage: R.<x,y,t> = PolynomialRing(QQ)
sage: FFPD = FractionWithFactoredDenominatorRing(R)
sage: H = (1 - y) * (1 + x^2) * (1 - t*(1 + x^2 + x*y^2))
sage: G = (1 + x) * (1 + x^2 - x*y^2)
sage: Hfac = H.factor()
sage: G = G / Hfac.unit()
sage: F = FFPD(G, Hfac)
sage: p = {x: 1, y: 1, t: 1/3}
sage: alpha = [1, 1, 1]
sage: F.asymptotics_multiple(p, alpha, 1, var('r'))
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-4-82ca86d72d26> in <module>()
      9 p = {x: Integer(1), y: Integer(1), t: Integer(1)/Integer(3)}
     10 alpha = [Integer(1), Integer(1), Integer(1)]
---> 11 F.asymptotics_multiple(p, alpha, Integer(1), var('r'))

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.pyc in asymptotics_multiple(self, p, alpha, N, asy_var, coordinate, numerical, verbose)
   2184         n = len(H)
   2185         P = {SR(x): p[x] for x in R.gens()}
-> 2186         Sstar = self._crit_cone_combo(p, alpha, coordinate)
   2187 
   2188         # Put the given convenient variable at end of variable list.

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.pyc in _crit_cone_combo(self, p, alpha, coordinate)
   2428         d = self.dimension()
   2429         n = len(self.denominator_factored())
-> 2430         Gamma = matrix([direction(v, coordinate) for v in self.log_grads(p)])
   2431         beta = direction(alpha, coordinate)
   2432         # solve_left() fails when working in SR :-(.

/usr/local/src/sage-config/local/lib/python2.7/site-packages/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.pyc in direction(v, coordinate)
   4260     if coordinate is None:
   4261         coordinate = len(v) - 1
-> 4262     return tuple([vv / v[coordinate] for vv in v])
   4263 
   4264 

/usr/local/src/sage-config/src/sage/rings/rational.pyx in sage.rings.rational.Rational.__div__ (build/cythonized/sage/rings/rational.c:21767)()
   2355         if type(left) is type(right):
   2356             if mpq_cmp_si((<Rational> right).value, 0, 1) == 0:
-> 2357                 raise ZeroDivisionError('rational division by zero')
   2358             x = <Rational> Rational.__new__(Rational)
   2359             mpq_div(x.value, (<Rational>left).value, (<Rational>right).value)

ZeroDivisionError: rational division by zero

This gives a divison by zero since the direction is normalized by the last coordinate.

This is a follow-up of #10519.

Depends on #10519

Component: asymptotic expansions

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

jdemeyer commented 7 years ago

Description changed:

--- 
+++ 
@@ -17,3 +17,4 @@

 This is a follow-up of #10519.

+Possibly related: #19989
jdemeyer commented 7 years ago

Description changed:

--- 
+++ 
@@ -1,20 +1,53 @@