New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit(4**(acos(1/(1+x**2))**2)/log(1+x, 4), x, 0) raises NotImplementedError: Don't know how to calculate the mrv of 'O(1/_w, (_w, oo))' #8061

Closed
rubik opened this Issue Sep 18, 2014 · 7 comments

Comments

Projects
None yet
5 participants
@rubik
Copy link

rubik commented Sep 18, 2014

Python 3.4.1
Sympy 0.7.5
How to reproduce:

limit(4**(acos(1/(1+x**2))**2)/log(1+x, 4), x, 0)

Correct result: 0.

The error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-948a2809406b> in <module>()
----> 1 limit(4**(acos(1/(1+x**2))**2)/log(1+x, 4), x, 0)

/home/miki/exp/lib/python3.4/site-packages/sympy/series/limits.py in limit(e, z, z0, dir)
     77 
     78     try:
---> 79         r = gruntz(e, z, z0, dir)
     80         if r is S.NaN:
     81             raise PoleError()

/home/miki/exp/lib/python3.4/site-packages/sympy/series/gruntz.py in gruntz(e, z, z0, dir)
    645         else:
    646             raise NotImplementedError("dir must be + or -")
--> 647         r = limitinf(e0, z)
    648 
    649     # This is a bit of a heuristic for nice results../.. we always rewrite

/home/miki/exp/lib/python3.4/site-packages/sympy/core/cache.py in wrapper(*args, **kw_args)
     91         except (KeyError, TypeError):
     92             pass
---> 93         r = func(*args, **kw_args)
     94         try:
     95             func_cache_it_cache[k] = r

/home/miki/exp/lib/python3.4/site-packages/sympy/series/gruntz.py in limitinf(e, x)
    418         e = e.subs(x, p)
    419         x = p
--> 420     c0, e0 = mrv_leadterm(e, x)
    421     sig = sign(e0, x)
    422     if sig == 1:

/home/miki/exp/lib/python3.4/site-packages/sympy/core/cache.py in wrapper(*args, **kw_args)
     91         except (KeyError, TypeError):
     92             pass
---> 93         r = func(*args, **kw_args)
     94         try:
     95             func_cache_it_cache[k] = r

/home/miki/exp/lib/python3.4/site-packages/sympy/series/gruntz.py in mrv_leadterm(e, x)
    474         return (e, S.Zero)
    475     if Omega == SubsSet():
--> 476         Omega, exps = mrv(e, x)
    477     if not Omega:
    478         # e really does not depend on x after simplification

/home/miki/exp/lib/python3.4/site-packages/sympy/series/gruntz.py in mrv(e, x)
    242     """Returns a SubsSet of most rapidly varying (mrv) subexpressions of e,
    243        and e rewritten in terms of these"""
--> 244     e = powsimp(e, deep=True, combine=exp)
    245     if not isinstance(e, Basic):
    246         raise TypeError("e should be an instance of Basic")

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in powsimp(expr, deep, combine, force, measure)
   2547 
   2548     if deep or expr.is_Add or expr.is_Mul and _y not in expr.args:
-> 2549         expr = expr.func(*[recurse(w) for w in expr.args])
   2550 
   2551     if expr.is_Pow:

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in <listcomp>(.0)
   2547 
   2548     if deep or expr.is_Add or expr.is_Mul and _y not in expr.args:
-> 2549         expr = expr.func(*[recurse(w) for w in expr.args])
   2550 
   2551     if expr.is_Pow:

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in recurse(arg, **kwargs)
   2538         _force = kwargs.get(force, force)
   2539         _measure = kwargs.get(measure, measure)
-> 2540         return powsimp(arg, _deep, _combine, _force, _measure)
   2541 
   2542     expr = sympify(expr)

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in powsimp(expr, deep, combine, force, measure)
   2547 
   2548     if deep or expr.is_Add or expr.is_Mul and _y not in expr.args:
-> 2549         expr = expr.func(*[recurse(w) for w in expr.args])
   2550 
   2551     if expr.is_Pow:

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in <listcomp>(.0)
   2547 
   2548     if deep or expr.is_Add or expr.is_Mul and _y not in expr.args:
-> 2549         expr = expr.func(*[recurse(w) for w in expr.args])
   2550 
   2551     if expr.is_Pow:

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in recurse(arg, **kwargs)
   2538         _force = kwargs.get(force, force)
   2539         _measure = kwargs.get(measure, measure)
-> 2540         return powsimp(arg, _deep, _combine, _force, _measure)
   2541 
   2542     expr = sympify(expr)

/home/miki/exp/lib/python3.4/site-packages/sympy/simplify/simplify.py in powsimp(expr, deep, combine, force, measure)
   2550 
   2551     if expr.is_Pow:
-> 2552         return recurse(expr*_y, deep=False)/_y
   2553 
   2554     if not expr.is_Mul:

/home/miki/exp/lib/python3.4/site-packages/sympy/core/decorators.py in __sympifyit_wrapper(a, b)
     75                 if not hasattr(b, _op_priority):
     76                     b = sympify(b, strict=True)
---> 77                 return func(a, b)
     78             except SympifyError:
     79                 return retval

/home/miki/exp/lib/python3.4/site-packages/sympy/core/decorators.py in binary_op_wrapper(self, other)
    116                     else:
    117                         return f(self)
--> 118             return func(self, other)
    119         return binary_op_wrapper
    120     return priority_decorator

/home/miki/exp/lib/python3.4/site-packages/sympy/core/expr.py in __mul__(self, other)
    123     @call_highest_priority(__rmul__)
    124     def __mul__(self, other):
--> 125         return Mul(self, other)
    126 
    127     @_sympifyit(other, NotImplemented)

/home/miki/exp/lib/python3.4/site-packages/sympy/core/cache.py in wrapper(*args, **kw_args)
     91         except (KeyError, TypeError):
     92             pass
---> 93         r = func(*args, **kw_args)
     94         try:
     95             func_cache_it_cache[k] = r

/home/miki/exp/lib/python3.4/site-packages/sympy/core/operations.py in __new__(cls, *args, **options)
     38             return args[0]
     39 
---> 40         c_part, nc_part, order_symbols = cls.flatten(args)
     41         is_commutative = not nc_part
     42         obj = cls._from_args(c_part + nc_part, is_commutative)

/home/miki/exp/lib/python3.4/site-packages/sympy/core/mul.py in flatten(cls, seq)
    178                 a, b = b, a
    179             assert not a is S.One
--> 180             if not a.is_zero and a.is_Rational:
    181                 r, b = b.as_coeff_Mul()
    182                 if b.is_Add:

/home/miki/exp/lib/python3.4/site-packages/sympy/core/assumptions.py in getit(self)
    142             if self._assumptions is self.default_assumptions:
    143                 self._assumptions = self.default_assumptions.copy()
--> 144             return _ask(fact, self)
    145 
    146     getit.func_name = as_property(fact)

/home/miki/exp/lib/python3.4/site-packages/sympy/core/assumptions.py in _ask(fact, obj)
    195             continue
    196         if pk in handler_map:
--> 197             _ask(pk, obj)
    198 
    199             # we might have found the value of fact

/home/miki/exp/lib/python3.4/site-packages/sympy/core/assumptions.py in _ask(fact, obj)
    195             continue
    196         if pk in handler_map:
--> 197             _ask(pk, obj)
    198 
    199             # we might have found the value of fact

/home/miki/exp/lib/python3.4/site-packages/sympy/core/assumptions.py in _ask(fact, obj)
    185         pass
    186     else:
--> 187         a = evaluate(obj)
    188         if a is not None:
    189             assumptions.deduce_all_facts(((fact, a),))

/home/miki/exp/lib/python3.4/site-packages/sympy/core/power.py in _eval_is_real(self)
    293         if real_e is None:
    294             return
--> 295         if real_b and real_e:
    296             if self.base.is_positive:
    297                 return True

/home/miki/exp/lib/python3.4/site-packages/sympy/core/relational.py in __nonzero__(self)
    109 
    110     def __nonzero__(self):
--> 111         raise TypeError("symbolic boolean expression has no truth value.")
    112 
    113     __bool__ = __nonzero__

TypeError: symbolic boolean expression has no truth value.
@smichr

This comment has been minimized.

Copy link
Member

smichr commented Sep 18, 2014

In my bound branch I get NotImplementedError: Don't know how to calculate the mrv of 'O(1/_w, (_w, oo))'

@rubik

This comment has been minimized.

Copy link

rubik commented Sep 18, 2014

I forgot to point out that Sympy version is 0.7.5.

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Sep 18, 2014

I get the NotImplementedError in master too.

@rubik

This comment has been minimized.

Copy link

rubik commented Sep 19, 2014

If that's the case, I think this can be closed, since the bug appears to be fixed in master.
I have to report another issue, do you prefer that I test the code against master branch too?

@skirpichev

This comment has been minimized.

Copy link
Contributor

skirpichev commented Sep 19, 2014

We can't do this limit, so it's a bug.

@rubik

This comment has been minimized.

Copy link

rubik commented Sep 19, 2014

Well NotImplementedError means that currently there is no way for Sympy to evaluate the limit. As long as the documentation says that there are limits Sympy cannot solve, it's ok.

@skirpichev skirpichev changed the title Limit gives error `TypeError: symbolic boolean expression has no truth value` limit(4**(acos(1/(1+x**2))**2)/log(1+x, 4), x, 0) raises NotImplementedError: Don't know how to calculate the mrv of 'O(1/_w, (_w, oo))' Sep 19, 2014

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Sep 22, 2014

Sure, it's not as bad of a bug. It's more of an enhancement request now. But we would like to be able to compute limits that can't be computed.

What needs to be done to compute the mrv of 'O(1/_w, (_w, oo))'? I tried this at #7529 but it didn't work there either. @avichaldayal

skirpichev added a commit to diofant/diofant that referenced this issue Apr 27, 2015

Add test for SymPy's issue 8061
Note, correct result is oo, not 0!  Here is Mathematica session:

    In[1]:= Limit[4^(ArcCos[(x^2 + 1)^(-1)]^2)*Log[4]/Log[x + 1], x->0]
    Out[1]=
    Infinity

See sympy/sympy#8061

skirpichev added a commit to skirpichev/diofant that referenced this issue Nov 2, 2016

Add regression tests & mention closed issues
    close sympy/sympy#3112 (MrvAsympt was added in diofant#6)
    close sympy/sympy#9173 (test was added in 5a510ac)
    close sympy/sympy#9808 (fixed in 09e539b)
    close sympy/sympy#9341 (fixed in af98a00)
    close sympy/sympy#9908 (fixed in cc3fa8d)
    close sympy/sympy#6171 (test added in d278031)
    close sympy/sympy#9276 (diagnose_imports.py removed in ab8c535)
    close sympy/sympy#10201 (fixed in 0d0fc5f)
    close sympy/sympy#9057 (test was added in 8290a0c)
    close sympy/sympy#11159 (test was added in ffb76cb)
    close sympy/sympy#2839 (new AST transformers are used, see diofant#278 and diofant#167)
    close sympy/sympy#11081 (see ed01e16 and bb92329)
    close sympy/sympy#10974 (see 73fc425)
    close sympy/sympy#10806 (test in 539929a)
    close sympy/sympy#10801 (test in 2fe3da5)
    close sympy/sympy#9549 (test in 88bdefa)
    close sympy/sympy#4231 (test was added in fb411d5)
    close sympy/sympy#8634 (see 2fcbb58)
    close sympy/sympy#8481 (see 1ef20d3)
    close sympy/sympy#9956 (fixed in a34735f)
    close sympy/sympy#9747 (see e117c60)
    close sympy/sympy#7853 (see 3e4fbed)
    close sympy/sympy#9634 (see 2be03f5)
    close sympy/sympy#8500 (fixed in diofant#104 and finally in diofant#316)
    close sympy/sympy#9192 (see 9bf622f)
    close sympy/sympy#7130 (see e068fa3)
    close sympy/sympy#8514 (see b2d543b)
    close sympy/sympy#9334 (see 90de625)
    close sympy/sympy#8229 (see 9755b89)
    close sympy/sympy#8061 (see 7054f06)
    close sympy/sympy#7872 (tested in diofant#6)
    close sympy/sympy#3496 (tested in test_log_symbolic)
    close sympy/sympy#2929 (see da7db7a)
    close sympy/sympy#8203 (oo is not a real, see diofant#36)
    close sympy/sympy#7649 (0 is imaginary since diofant#8)
    close sympy/sympy#7256 (fixed in c0a4549)
    close sympy/sympy#6783 (see cb28d63)
    close sympy/sympy#5662 (is_integer issue fixed in 6bfa9f8, there is no is_bounded anymore)
    close sympy/sympy#5295 (fixed with diofant#354)
    close sympy/sympy#4856 (we now have flake/pep tests)
    close sympy/sympy#4555 (flake8 enabled after diofant#214)
    close sympy/sympy#5773 (cmp_to_key removed after diofant#164 and c9acbf0)
    close sympy/sympy#5484 (see above)

    Added regression tests:
    from https://groups.google.com/forum/#!topic/sympy/LkTMQKC_BOw
    fixes sympy/sympy#8825 (probably via diofant#209)
    fixes sympy/sympy#8635
    fixes sympy/sympy#8157
    fixes sympy/sympy#7872
    fixes sympy/sympy#7599
    fixes sympy/sympy#6179
    fixes sympy/sympy#5415
    fixes sympy/sympy#2865
    fixes sympy/sympy#5907
    fixes sympy/sympy#11722

    Closes diofant#347

skirpichev added a commit to skirpichev/diofant that referenced this issue Nov 2, 2016

Add regression tests & mention closed issues
    close sympy/sympy#3112 (MrvAsympt was added in diofant#6)
    close sympy/sympy#9173 (test was added in 5a510ac)
    close sympy/sympy#9808 (fixed in 09e539b)
    close sympy/sympy#9341 (fixed in af98a00)
    close sympy/sympy#9908 (fixed in cc3fa8d)
    close sympy/sympy#6171 (test added in d278031)
    close sympy/sympy#9276 (diagnose_imports.py removed in ab8c535)
    close sympy/sympy#10201 (fixed in 0d0fc5f)
    close sympy/sympy#9057 (test was added in 8290a0c)
    close sympy/sympy#11159 (test was added in ffb76cb)
    close sympy/sympy#2839 (new AST transformers are used, see diofant#278 and diofant#167)
    close sympy/sympy#11081 (see ed01e16 and bb92329)
    close sympy/sympy#10974 (see 73fc425)
    close sympy/sympy#10806 (test in 539929a)
    close sympy/sympy#10801 (test in 2fe3da5)
    close sympy/sympy#9549 (test in 88bdefa)
    close sympy/sympy#4231 (test was added in fb411d5)
    close sympy/sympy#8634 (see 2fcbb58)
    close sympy/sympy#8481 (see 1ef20d3)
    close sympy/sympy#9956 (fixed in a34735f)
    close sympy/sympy#9747 (see e117c60)
    close sympy/sympy#7853 (see 3e4fbed)
    close sympy/sympy#9634 (see 2be03f5)
    close sympy/sympy#8500 (fixed in diofant#104 and finally in diofant#316)
    close sympy/sympy#9192 (see 9bf622f)
    close sympy/sympy#7130 (see e068fa3)
    close sympy/sympy#8514 (see b2d543b)
    close sympy/sympy#9334 (see 90de625)
    close sympy/sympy#8229 (see 9755b89)
    close sympy/sympy#8061 (see 7054f06)
    close sympy/sympy#7872 (tested in diofant#6)
    close sympy/sympy#3496 (tested in test_log_symbolic)
    close sympy/sympy#2929 (see da7db7a)
    close sympy/sympy#8203 (oo is not a real, see diofant#36)
    close sympy/sympy#7649 (0 is imaginary since diofant#8)
    close sympy/sympy#7256 (fixed in c0a4549)
    close sympy/sympy#6783 (see cb28d63)
    close sympy/sympy#5662 (is_integer issue fixed in 6bfa9f8, there is no is_bounded anymore)
    close sympy/sympy#5295 (fixed with diofant#354)
    close sympy/sympy#4856 (we now have flake/pep tests)
    close sympy/sympy#4555 (flake8 enabled after diofant#214)
    close sympy/sympy#5773 (cmp_to_key removed after diofant#164 and c9acbf0)
    close sympy/sympy#5484 (see above)

    Added regression tests:
    from https://groups.google.com/forum/#!topic/sympy/LkTMQKC_BOw
    fixes sympy/sympy#8825 (probably via diofant#209)
    fixes sympy/sympy#8635
    fixes sympy/sympy#8157
    fixes sympy/sympy#7872
    fixes sympy/sympy#7599
    fixes sympy/sympy#6179
    fixes sympy/sympy#5415
    fixes sympy/sympy#2865
    fixes sympy/sympy#5907
    fixes sympy/sympy#11722

    Closes diofant#347

@Upabjojr Upabjojr closed this Oct 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment