Some time ago I have proposed an extension to limit to handle special
functions more completely.
In simplimit we have code which supports some functions like erf, tan,
log, ... When simplimit has no special code the function itself is
called to get a value at the limit. This does not work for values which
cause an Maxima error like elliptic_kc(1) or expintegral_ei(0).
We can add code to look up a simplim%function for further special
functions:
((setq op (safe-get (mop exp) 'simplim%function))
;; Lookup a simplim%function from the property list
(funcall op exp var val))
Now we can support a simplim%function. These are some examples for the
gamma_incomplete, expintegral_ei, and elliptic_kc functions:
(defprop %gamma_incomplete simplim%gamma_incomplete simplim%function)
(defun simplim%gamma_incomplete (expr var val)
;; Look for the limit of the arguments.
(let ((a (limit (cadr expr) var val 'think))
(z (limit (caddr expr) var val 'think)))
(cond
;; Handle an argument 0 at this place
((or (zerop1 z)
(eq z '$zeroa)
(eq z '$zerob))
(let ((sgn ($sign ($realpart a))))
(cond ((zerop1 a) '$inf)
((member sgn '($neg $nz)) '$infinity)
((eq sgn '($pos)) ($gamma a))
(t (simplify (list '(%gamma_incomplete) a z))))))
(t
;; All other cases are handled by the simplifier of the function.
(simplify (list '(%gamma_incomplete) a z))))))
(defprop %elliptic_kc simplim%elliptic_kc simplim%function)
(defun simplim%elliptic_kc (expr var val)
;; Look for the limit of the argument
(let ((m (limit (cadr expr) var val 'think)))
(cond ((onep1 m)
;; For an argument 1 return $infinity.
'$infinity)
(t
;; All other cases are handled by the simplifier of the
function.
(simplify (list '(%elliptic_kc) m))))))
(defprop %expintegral_ei simplim%expintegral_ei simplim%function)
(defun simplim%expintegral_ei (expr var val)
;; Look for the limit of the arguments.
(let ((z (limit (cadr expr) var val 'think)))
(cond
;; Handle an argument 0 at this place
((or (zerop1 z)
(eq z '$zeroa)
(eq z '$zerob))
'$minf)
(t
;; All other cases are handled by the simplifier of the function.
(simplify (list '(%expintegral_ei) z))))))
With this extension we get a limit for special values which will give
otherwise a Maxima error:
(%i4) limit(elliptic_kc(x),x,1);
(%o4) infinity
(%i5) limit(expintegral_ei(x),x,0);
(%o5) minf
(%i7) assume(a>0)$
The limit for a positive or negative parameter a:
(%i8) limit(gamma_incomplete(a,x),x,0);
(%o8) gamma(a)
(%i9) limit(gamma_incomplete(-a,x),x,0);
(%o9) infinity
We will get again the following integral:
(%i11) assume(k>0)$
(%i12) integrate((-log(x))^k,x,0,1);
(%o12) gamma(k+1)
Dieter Kaiser