Skip to content
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

Difficulties with limits #14204

Open
ghost opened this issue Feb 14, 2018 · 1 comment
Open

Difficulties with limits #14204

ghost opened this issue Feb 14, 2018 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Feb 14, 2018

>>> print(limit_seq(Sum(1/k, (k, n, 2*n)), n))
None
>>> pprint(limit_seq(Sum(1/k, (k, n, 2*n)), n))
None

Default (Latex?) printing of limit_seq(Sum(1/k, (k, n, 2*n)), n) executes and returns nothing (I think returning nothing is better than returning the original expression)

>>> limit_seq(Sum(1/k, (k, 1, 2*n)) - Sum(1/k, (k, 1, n)), n)
log(2)
>>> a, k = symbols('a, k', positive=True, integer=True)
>>> print(limit_seq(Sum(a**k, (k, 0, n - 1)).doit()/(a**n), n))
None
>>> print(limit_seq(Sum(a**k, (k, 0, n - 1))/(a**n), n))
1/(a - 1)
>>> pprint(limit_seq(Sum(a**k, (k, 0, n - 1)).doit()/(a**n), n))
None
>>> pprint(limit_seq(Sum(a**k, (k, 0, n - 1))/(a**n), n))
  1  
─────
a - 1

Default printing of limit_seq(Sum(a**k, (k, 0, n - 1)).doit()/(a**n), n) executes and returns nothing
Default printing of limit_seq(Sum(a**k, (k, 0, n - 1))/(a**n), n) gives

  1  
─────
a - 1

a can be 1 in the above

>>> a, k = symbols('a, k', positive=True, integer=True)
>>> limit_seq(Sum(1/n, (k, 1, n)).doit()/log(n), n)
0
>>> limit_seq(Sum(1/n, (k, 1, n))/log(n), n)
1
>>> limit_seq(Sum(Rational(1,k), (k, 1, n)).doit()/log(n), n)
Traceback (most recent call last):

  File "<ipython-input-70-8de63e34fe96>", line 1, in <module>
    limit_seq(Sum(Rational(1,k), (k, 1, n)).doit()/log(n), n)

  File ".\sympy\core\numbers.py", line 1490, in __new__
    q = Rational(q)

  File ".\sympy\core\numbers.py", line 1485, in __new__
    raise TypeError('invalid input: %s' % p)

TypeError: invalid input: k
@anutosh491
Copy link
Member

anutosh491 commented Nov 22, 2021

These deserve a simple heuristic which I'll be adding . The reason basically is that something like Sum(1/k, (k, a, b) ), doesn't return harmonic(b) - harmonic(a) when a is positive and returns self .

>>> print(limit_seq(Sum(1/k, (k, n, 2*n)), n))
None

Rest all faulty cases are working as expected on master as of now , (might have been fixed somewhere ) and only tests need to be added for the same

>>> limit_seq(Sum(1/n, (k, 1, n))/log(n), n)
0
>>> limit_seq(Sum(a**k, (k, 0, n - 1)).doit()/(a**n), n)
1/(a - 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants