1 ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; The data in this file contains enhancements. ;;;;;
5 ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;
6 ;;; All rights reserved ;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; (c) Copyright 1980 Massachusetts Institute of Technology ;;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 (declare-top (special taylored
))
15 (macsyma-module tlimit
)
17 (load-macsyma-macros rzmac
)
19 ;; TOP LEVEL FUNCTION(S): $TLIMIT $TLDEFINT
21 (defmfun $tlimit
(&rest args
)
22 (let ((limit-using-taylor t
))
23 (declare (special limit-using-taylor
))
24 (apply #'$limit args
)))
26 (defmfun $tldefint
(exp var ll ul
)
27 (let ((limit-using-taylor t
))
28 (declare (special limit-using-taylor
))
29 ($ldefint exp var ll ul
)))
31 ;; Taylor cannot handle conjugate, ceiling, floor, unit_step, or signum
32 ;; expressions, so let's tell tlimit to *not* try. We also disallow
33 ;; expressions containing $ind.
35 (not (amongl '($conjugate $floor $ceiling $ind $unit_step %signum
) e
)))
37 ;; Dispatch Taylor, but recurse on the order until either the recursion
38 ;; depth is 15 or the Taylor polynomial is nonzero. When Taylor
39 ;; fails to find a nonzero Taylor polynomial or the recursion depth is
40 ;; too great, return nil.
42 ;; This recursion on the order attempts to handle limits such as
43 ;; tlimit(2^n/n^5, n, inf) correctly.
45 ;; We set up a reasonable environment for calling taylor. Arguably, setting
46 ;; these option variables is overly removes the users ability to adjust these
47 ;; option variables. When $taylor_logexpand is true, taylor does some
48 ;; principal branch violating transformations, so we set it to nil.
50 ;; I know of no compelling reason for defaulting the taylor order to
51 ;; lhospitallim, but this is documented in the user documentation).
53 (defun tlimit-taylor (e x pt n
&optional
(d 0))
55 (silent-taylor-flag t
)
57 ($taylor_logexpand nil
)
58 ($taylor_simplifier
#'sratsimp
))
59 (setq ee
(ratdisrep (catch 'taylor-catch
($taylor e x pt n
))))
60 (cond ((and ee
(not (alike1 ee
0))) ee
)
61 ;; When taylor returns zero and the depth d is less than 16,
62 ;; declare a do-over; otherwise return nil.
64 (tlimit-taylor e x pt
(* 4 (max 1 n
)) (+ d
1)))
67 ;; Previously when the taylor series failed, there was code for deciding
68 ;; whether to call limit1 or simplimit. The choice depended on the last
69 ;; argument to taylim (previously named *i*) and the main operator of the
70 ;; expression. This code dispenses with this logic and dispatches limit1
71 ;; when Maxima is unable to find the taylor polynomial. This change orphans
72 ;; the last argument of taylim.
73 (defun taylim (e var val flag
)
74 (declare (ignore flag
))
77 (setq e
(stirling0 e
))
78 (setq et
(tlimit-taylor e var
(ridofab val
) $lhospitallim
0)))
79 (if et
(let ((taylored t
)) (limit et var val
'think
)) (limit1 e var val
))))