# Problem evaluating limit: assume doesn't work!

Hi everyone,

I'm trying to evaluate the following limit in sage:

$$\lim_{N\to \infty}\frac{6N^k(N-1)^{1-k}}{(2N-1)(k+1)},$$

where $k\neq \pm1$. From Wolfram-Alpha I know this is equal to $3/(1+k)$, but I was trying to get to that answer with sage with no progress. What I did to do it was the following:

sage: N = var('N')
sage: k = var('k')
sage: assume(k!=1)
sage: assume(k!=-1)
sage: limit((6*N^k*(N-1)^(1-k))/((2*N-1)*(k+1)),N=oo)


But I get the following error:

ValueError                                Traceback (most recent call last)
<ipython-input-7-bb63a0377d1b> in <module>()
----> 1 limit((Integer(6)*N**k*(N-Integer(1))**(Integer(1)-k))/((Integer(2)*N-Integer(1))*(k+Integer(1))),N=oo)

/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/calculus/calculus.pyc in limit(ex, dir, taylor, algorithm, **argv)
1198     if algorithm == 'maxima':
1199         if dir is None:
-> 1200             l = maxima.sr_limit(ex, v, a)
1201         elif dir in ['plus', '+', 'right', 'above']:
1202             if dir == 'above':

/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py in sr_limit(self, expr, v, a, dir)
855                 j = s.find('Is ')
856                 s = s[j:]
--> 857                 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see assume? for more details)\n" + s
858             else:
859                 raise error

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see assume? for more details)
Is  k-1.0  positive or negative?


In general it doesn't matter if $k$ is positive or negative, they converge to the same value. However, for the sake of completeness, let's first try to restrict $k$ to values between 0 and 1. So, I opened other sage session and did:

sage: N = var('N')
sage: k = var('k')
sage: assume(k>0,k<1)
sage: limit((6*N^k*(N-1)^(1-k))/((2*N-1)*(k+1)),N=oo)


But I got:

ValueError                                Traceback (most recent call last)
<ipython-input-4-bb63a0377d1b> in <module>()
----> 1 limit((Integer(6)*N**k*(N-Integer(1))**(Integer(1)-k))/((Integer(2)*N-Integer(1))*(k+Integer(1))),N=oo)

/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/calculus/calculus.pyc in limit(ex, dir, taylor, algorithm, **argv)
1198     if algorithm == 'maxima':
1199         if dir is None:
-> 1200             l = maxima.sr_limit(ex, v, a)
1201         elif dir in ['plus', '+', 'right', 'above']:
1202             if dir == 'above':

/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py in sr_limit(self, expr, v, a, dir)
855                 j = s.find('Is ')
856                 s = s[j:]
--> 857                 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see assume? for more details)\n" + s
858             else:
859                 raise error

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before limit evaluation *may* help (see assume? for more details)
Is k an integer?


Trying to do sage: assume(k ...

edit retag close merge delete

Sort by » oldest newest most voted

Assuming that k is real is much weaker than assuming that k is an integer. Also it seems that you need to simplify the expression first to let the computation work:

sage: N = var('N')
sage: k = var('k')
sage: assume(k-1>0)
sage: assume(k, 'integer')
sage: E = (6*N^k*(N-1)^(1-k))/((2*N-1)*(k+1))
sage: limit(E.full_simplify(),N=oo)
3/(k + 1)

more

Hi @tmonteil; thanks for your anwer. I understand that assuming that k is real is much weaker than assuming that k is an integer, but, as I implicitly showed, I'm using this for non-integers inclusive.

Also, I'm using Sage Version 6.1.1 (Release Date: 2014-02-04) and this doesn't work; it gives me the same error I showed, and asks me: "Is k-1 positive, negative, or zero?" (which is strange since I already defined it to be positive).

Yeah, Maxima's assumptions are notoriously weak. We can of course report something upstream if you can confirm with the most recent Sage.

I'm trying to update my Sage version to try this but it won't let me; do you know if there's something going on with the trac server? I try: sage -upgrade, and it gives me:

Upgrading to the latest development version fatal: unable to connect to trac.sagemath.org: trac.sagemath.org[0: 128.208.178.249]: errno=Connection refused

Ok, solution works with new version, but still think that imposing $k$ to be an integer is too much...