extending limit



Am Montag, den 25.01.2010, 12:54 -0600 schrieb Barton Willis:
> I know little to nothing about the limit code; nevertheless, how about:
> 
> (setf (get '%signum 'simplim%function) 'simplim%signum)
> 
> (defun simplim%signum (e x pt)
>   (let ((sgn))
>     (setq e (limit (cadr e) x pt 'think))
>     (setq sgn ($csign e))
>    (cond ((eq sgn '$zero) '$ind)
>           ((memq sgn '($neg $pn $pos))
>            (take '(%signum) e)) ;; OK, this does sign(e) twice,...
>           (t  (throw 'limit ())))))
> 
> Examples:
> 
> (%i2) limit(signum(x^2-3),x,5);
> (%o2) 1
> 
> (%i3) limit(signum(x),x,a);
> (%o3) 'limit(signum(x+a),x,0)
> 
> (%i4) assume(a > 0);
> (%o4) [a > 0]
> 
> (%i5) limit(signum(x),x,a);
> (%o5) 1
> 
> (%i6) limit(signum(x^3-1),x,inf);
> (%o6) 1
> 
>  
> (%i7) limit(signum(x^3-7),x,minf);
> (%o7) -1
> 
> (%i8) limit(x * signum(x),x,0);
> (%o8) 0

Hello Barton,

I think a simplim%function is the right way to implement the handling of
specific arguments of a function, which are not handled by the
simplifier. If present it is called before the limit routines call the
simplifying function to get an answer for an argument.

Therefore the simplim%function should be as complete as possible. We
have a lot of functions which might benefit from a simplim%function too.

To be consistent I think the default of a simplim%function should be to
call the simplifier. Only known specific arguments are handled. 

This is another short example. Only an argument 1 is handled, all other
arguments are passed to the simplifier:

(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))))))

Dieter Kaiser