;;=============================================================================
;;                    Math functions
;;=============================================================================
;; this packages complements the built-in C routines with functions easily
;; derived from them in Klone, from the Common Lisp specs.
;;NOTE: this only works on reals, not complexes

;;AUTOLOAD: sqrt

(defun sqrt (n) (expt n 0.5))

;;AUTOLOAD: exp
;;(exp x) is (expt e x)

(defun exp (x) (expt *E* x))

;;AUTOLOAD: tan

(defun tan (n) (/ (sin n) (cos n)))

;;AUTOLOAD: acos

(defun acos (x) (- (/ *PI* 2) (asin x)))

;;AUTOLOAD: sinh

(defun sinh (x) (/ (- (exp x) (exp (- x))) 2))

;;AUTOLOAD: cosh

(defun cosh (x) (/ (+ (exp x) (exp (- x))) 2))

;;AUTOLOAD: tanh

(defun tanh (x) (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))

;;AUTOLOAD: asinh

(defun asinh (x) (log (+ x (sqrt (+ (** x 2) 1)))))

;;AUTOLOAD: acosh

(defun acosh (x) (log (+ x (* (+ x 1) (sqrt (/ (- x 1) (+ x 1)))))))

;;AUTOLOAD: atanh

(defun atanh (x) (log (* (+ 1 x) (sqrt (- 1 (/ 1 (** x 2)))))))
