;;; Code:
;; This file is autoloaded from calc-ext.el.
-(require 'calc-ext)
+(require 'calc-ext)
(require 'calc-macs)
-(defun calc-Need-calc-arith () nil)
-
;;; The following lists are not exhaustive.
(defvar math-scalar-functions '(calcFunc-det
calcFunc-cnorm calcFunc-rnorm
calcFunc-max calcFunc-min))
(defvar math-real-if-arg-functions '(calcFunc-sin calcFunc-cos
- calcFunc-tan calcFunc-arctan
+ calcFunc-tan calcFunc-sec
+ calcFunc-csc calcFunc-cot
+ calcFunc-arctan
calcFunc-sinh calcFunc-cosh
- calcFunc-tanh calcFunc-exp
+ calcFunc-tanh calcFunc-sech
+ calcFunc-csch calcFunc-coth
+ calcFunc-exp
calcFunc-gamma calcFunc-fact))
(defvar math-integer-functions '(calcFunc-idiv
((Math-negp a) 1)
((Math-zerop a) 2)
((eq (car a) 'intv)
- (cond ((Math-zerop (nth 2 a)) 6)
- ((Math-zerop (nth 3 a)) 3)
- (t 7)))
+ (cond
+ ((math-known-posp (nth 2 a)) 4)
+ ((math-known-negp (nth 3 a)) 1)
+ ((Math-zerop (nth 2 a)) 6)
+ ((Math-zerop (nth 3 a)) 3)
+ (t 7)))
((eq (car a) 'sdev)
(if (math-known-realp (nth 1 a)) 7 15))
(t 8)))
(math-normalize (list '^ a b)))
(defun math-pow-of-zero (a b)
- (if (Math-zerop b)
- (if calc-infinite-mode
- '(var nan var-nan)
- (math-reject-arg (list '^ a b) "*Indeterminate form"))
- (if (math-floatp b) (setq a (math-float a)))
- (if (math-posp b)
- a
- (if (math-negp b)
- (math-div 1 a)
- (if (math-infinitep b)
- '(var nan var-nan)
- (if (and (eq (car b) 'intv) (math-intv-constp b)
- calc-infinite-mode)
- '(intv 3 (neg (var inf var-inf)) (var inf var-inf))
- (if (math-objectp b)
- (list '^ a b)
- a)))))))
+ "Raise A to the power of B, where A is a form of zero."
+ (if (math-floatp b) (setq a (math-float a)))
+ (cond
+ ;; 0^0 = 1
+ ((eq b 0)
+ 1)
+ ;; 0^0.0, etc., are undetermined
+ ((Math-zerop b)
+ (if calc-infinite-mode
+ '(var nan var-nan)
+ (math-reject-arg (list '^ a b) "*Indeterminate form")))
+ ;; 0^positive = 0
+ ((math-known-posp b)
+ a)
+ ;; 0^negative is undefined (let math-div handle it)
+ ((math-known-negp b)
+ (math-div 1 a))
+ ;; 0^infinity is undefined
+ ((math-infinitep b)
+ '(var nan var-nan))
+ ;; Some intervals
+ ((and (eq (car b) 'intv)
+ calc-infinite-mode
+ (math-negp (nth 2 b))
+ (math-posp (nth 3 b)))
+ '(intv 3 (neg (var inf var-inf)) (var inf var-inf)))
+ ;; If none of the above, leave it alone.
+ (t
+ (list '^ a b))))
(defun math-pow-zero (a b)
(if (eq (car-safe a) 'mod)
(math-commutative-collect (nth 2 b) (not neg)))
(setq math-com-bterms (cons (if neg (math-neg b) b) math-com-bterms)))))
+(provide 'calc-arith)
+
;;; arch-tag: 6c396b5b-14c6-40ed-bb2a-7cc2e8111465
;;; calc-arith.el ends here