The non-user level function simplimsubst
evaluates a limit by direct substitution.
Near the top of simplimsubst
there is a check if the expression involves any one of $atan2, $floor, %round, ...
. And when that's the case, simplimsubst
declines direct substitution and returns nil.
There are lots of problems with this scheme. For one, the check only looks to see if these functions are in the expression, but it doesn't look to see if the argument of any of these functions depend on the limit variable. This gives rise to inconsistent results:
(%i9) limit(log(-1+%i*x) * ceiling(a),x,0,minus); (%o9) - %i %pi ceiling(a) (%i10) limit(log(-1+%i*x) * a,x,0,minus); (%o10) log(- 1) a
For %o9, since the expression involves ceiling
, the function simplimsubst
declines to use direct substitution and the limit is computed by some other method. But for %o10, simplimsubst
decides that uses direct substitution is OK and it returns a wrong value.
Further, the check declines direct substitution for many cases that are OK; for example the limit of floor(x)
as x
approaches 5/2
for example.
I tried cutting out SIMPLIMSUBST via (defun simplimsubst (&rest a) nil) and then ran run_testsuite(tests = rtest_limit); and I found several results that are different from the expected results. Without looking more carefully, I don't know whether one set of results is better than the other.