;;; -*-  Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     The data in this file contains enhancments.                    ;;;;;
;;;                                                                    ;;;;;
;;;  Copyright (c) 1984,1987 by William Schelter,University of Texas   ;;;;;
;;;     All rights reserved                                            ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     (c) Copyright 1980 Massachusetts Institute of Technology         ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-package :maxima)

(macsyma-module tlimit)

(load-macsyma-macros rzmac)

;; TOP LEVEL FUNCTION(S): $TLIMIT $TLDEFINT

(declare-top (special exp var val ll ul))

(defmfun $tlimit (&rest args)
  (let (($tlimswitch t))
    (declare (special $tlimswitch))
    (apply #'$limit args)))

(defmfun $tldefint (exp var ll ul)
  (let (($tlimswitch t))
    (declare (special $tlimswitch))
    ($ldefint exp var ll ul)))

(defun tlimp (exp)		; TO BE EXPANDED TO BE SMARTER (MAYBE)
  t)

(defun taylim (e *i*)
  (prog (ex)
     (setq ex (catch 'taylor-catch
		(let ((silent-taylor-flag t))
		  (declare (special silent-taylor-flag))
		  ($taylor e var (ridofab val) 1))))
     (or ex (return (cond ((eq *i* t)
			   (limit1 e var val))
			  ((eq *i* 'think)
			   (if (member (caar exp) '(mtimes mexpt) :test #'eq)
			       (limit1 e var val)
			       (simplimit e var val)))
			  (t
			   (simplimit e var val)))))
     (return
       (let ((taylored t))
	 (declare (special taylored))
	 (limit (simplify ($logcontract ($ratdisrep ex))) var val 'think)))))

(declare-top (unspecial exp var val ll ul))
