Status: Accepted
Owner: Vinzent.Steinberg
Labels: Type-Defect Priority-Medium

New issue 2131 by Vinzent.Steinberg: failing limit
http://code.google.com/p/sympy/issues/detail?id=2131

This should not raise a ZeroDivisionError. (Even if the limit does not exists.)

In [15]: limit(diff(x**3*sin(1/x), x) / x, x, 0)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (63, 0))

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)

/home/one/src/sympy/<ipython console> in <module>()

/home/one/src/sympy/sympy/series/limits.pyc in limit(e, z, z0, dir)
     77         r = gruntz(e, z, z0, dir)
     78     except PoleError:
---> 79         r = heuristics(e, z, z0, dir)
     80     return r
     81

/home/one/src/sympy/sympy/series/limits.pyc in heuristics(e, z, z0, dir)
     87         for a in e.args:
     88             if not a.is_bounded:
---> 89                 r.append(a.limit(z, z0, dir))
     90         if not (r is []):
     91             return Mul(*r)

/home/one/src/sympy/sympy/core/expr.pyc in limit(self, x, xlim, direction)
    744         """
    745         from sympy.series.limits import limit
--> 746         return limit(self, x, xlim, direction)
    747
    748     @cacheit

/home/one/src/sympy/sympy/series/limits.pyc in limit(e, z, z0, dir)
     59         finite = []
     60         for term in e.args:
---> 61             result = term.subs(z, z0)
     62             if result.is_unbounded or result is S.NaN:
     63                 unbounded.append(term)

/home/one/src/sympy/sympy/core/basic.pyc in subs(self, *args)
    703         elif len(args) == 2:
    704             old, new = args
--> 705             return self._subs_old_new(old, new)
    706         else:
    707             raise TypeError("subs accepts either 1 or 2 arguments")

/home/one/src/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     83         except KeyError:
     84             pass
---> 85         func_cache_it_cache[k] = r = func(*args, **kw_args)
     86         return r
     87

/home/one/src/sympy/sympy/core/basic.pyc in _subs_old_new(self, old, new)
    712         old = sympify(old)
    713         new = sympify(new)
--> 714         return self._eval_subs(old, new)
    715
    716     def _eval_subs(self, old, new):

/home/one/src/sympy/sympy/core/mul.pyc in _eval_subs(self, old, new)
    941                 if myFlag == True:
    942                     return Mul(coeff_self/coeff_old, new,
--> 943 Mul(*comms_final)._eval_subs(old,new))#*[c._eval_subs(old,new) for c in comms_final])
    944                 else:
945 return self.__class__(*[s._eval_subs(old, new) for

/home/one/src/sympy/sympy/core/function.pyc in _eval_subs(self, old, new)
165 elif isinstance(new.nargs,tuple) and self.nargs in new.nargs:
    166                     return new(*self.args)
--> 167         return Basic._seq_subs(self, old, new)
    168
    169

/home/one/src/sympy/sympy/core/basic.pyc in _seq_subs(self, old, new)
    797         else:
    798             args = (self.func,)+self
--> 799         return self.func(*[s.subs(old, new) for s in args])
    800
    801     def __contains__(self, what):

/home/one/src/sympy/sympy/core/multidimensional.pyc in wrapper(*args, **kwargs) 134 result = apply_on_element(wrapper, args, kwargs, n)
    135                     return result
--> 136             return f(*args, **kwargs)
    137         wrapper.__doc__ = f.__doc__
    138         wrapper.__name__ = f.__name__

/home/one/src/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     83         except KeyError:
     84             pass
---> 85         func_cache_it_cache[k] = r = func(*args, **kw_args)
     86         return r
     87

/home/one/src/sympy/sympy/core/function.pyc in __new__(cls, *args, **options)
    210         #     UC: Function('f')(x)

    211         #     UC: sin(x)

--> 212         return Application.__new__(cls, *args, **options)
    213
    214

/home/one/src/sympy/sympy/core/multidimensional.pyc in wrapper(*args, **kwargs) 134 result = apply_on_element(wrapper, args, kwargs, n)
    135                     return result
--> 136             return f(*args, **kwargs)
    137         wrapper.__doc__ = f.__doc__
    138         wrapper.__name__ = f.__name__

/home/one/src/sympy/sympy/core/cache.pyc in wrapper(*args, **kw_args)
     83         except KeyError:
     84             pass
---> 85         func_cache_it_cache[k] = r = func(*args, **kw_args)
     86         return r
     87

/home/one/src/sympy/sympy/core/function.pyc in __new__(cls, *args, **options)
    108         if options.get('evaluate') is False:
109 return super(Application, cls).__new__(cls, *args, **options)
--> 110         evaluated = cls.eval(*args)
    111         if evaluated is not None:
    112             return evaluated

/home/one/src/sympy/sympy/functions/elementary/trigonometric.pyc in eval(cls, arg)
    301                 q = pi_coeff.q
    302
--> 303                 Q, P = 2*p // q, p % q
    304
    305                 try:

ZeroDivisionError: integer division or modulo by zero

(Background: The second derivative of 'x**3 * sin(1/x) if x != 0 else 0' in 0.)

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to