>>>>> "Stavros" == Stavros Macrakis <macrakis@gmail.com> writes:
>> FWIW, if we replace both of these by writing them in exponential form,
>> the limits are computed correctly:
>>
>> limit(%e^(n*log(7))/%e^(n*log(8)),n,inf) => 0 ...
>> That might be a useful general heuristic to try.
Stavros> %e^(n*log(7))/%e^(n*log(8)) simplifies to %E^(LOG(7)*n-LOG(8)*n),
Stavros> which is why it works. If the original problem were (2^n+1)/(7^n+1),
Stavros> it wouldn't work. And tlimit works correctly on 2^n/7^n precisely
Stavros> because taylor converts to exponential form.
Stavros> Sadly, tlimit( (2^n+1)/(7^n+1) , n, inf,5) exposes a *different* bug:
Stavros> error: "two equal vars generated" -- I reported this as 1037916
Bummer.
After poking around a bit more, I think I know the problem. In
src/limit.lisp, there's the function ISGREATERP that is meant to
compare the "order" of the type of infinity. However, it doesn't
handle the case where both args are of exponential order of infinity.
If I rewrite it like so:
(DEFUN ISGREATERP (A B)
(let ((TA (car a))
(TB (car b)))
(COND ((or (eq ta 'gen)
(eq tb 'gen)) ())
((AND (EQ TA TB) (EQ TA 'VAR))
(RATGREATERP (CADDR A) (CADDR B)))
((and (eq ta tb) (eq ta 'exp))
;; Both are exponential order of infinity. Check the
;; exponents to determine which exponent is bigger.
(ratgreaterp (third (second a)) (third (second b))))
((MEMQ TA (CDR (MEMQ TB *LIMORDER)))))))
we get limit(7^n/8^n, n, inf) => 0. Also
limit((2^n+1)/(7^n+1),n,inf) => 0
limit(7^(n^2)/8^n,n,inf) => inf
This seems reasonable. I'm not 100% sure that (third (second a)) is
always the right form to get the exponent, but it seems that when
isgreaterp is called, we always have something like
(EXP ((MEXPT SIMP) $%E ((MTIMES SIMP) ((%LOG) 8) |$n|)))
so the exponent is ((MTIMES SIMP) ((%LOG) 8) |$n|).
Ray