54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
;; Function To Be Tested: LOG
|
|
;;
|
|
;; Source: Guy L Steele's CLTL
|
|
;; Section: 12.5.1 Exponential and Logarithmic Functions
|
|
;; Page: 204
|
|
;;
|
|
;; Created By: Kelly Roach
|
|
;;
|
|
;; Creation Date: July 12,1986
|
|
;;
|
|
;; Last Update: July 12,1986
|
|
;;
|
|
;; Filed As: {ERIS}<LISPCORE>CML>TEST>12-5-1-LOG.TEST
|
|
;;
|
|
;;
|
|
;; Syntax: (LOG NUMBER &OPTIONAL BASE)
|
|
;;
|
|
;; Function Description:
|
|
;; Returns the logarithm of NUMBER in the base BASE,
|
|
;; which defaults to E, the base of the natural logarithms.
|
|
;; For example:
|
|
;;
|
|
;; (LOG 8.0 2) => 3.0
|
|
;; (LOG 100.0 10) => 2.0
|
|
;;
|
|
;; The result of (LOG 8 2) may be either 3 or 3.0, depending on the
|
|
;; implementation.
|
|
;;
|
|
;; Note that LOG may return a complex result when given a non-complex
|
|
;; argument if the argument is negative. For example:
|
|
;;
|
|
;; (LOG -1.0) = (COMPLEX 0.0 (FLOAT PI 0.0))
|
|
;;
|
|
;;
|
|
;; Argument(s): NUMBER - a number
|
|
;; BASE - a number
|
|
;;
|
|
;; Returns: a number
|
|
;;
|
|
|
|
|
|
|
|
(do-test log-test
|
|
(flet ((equalp (x y) (< (abs (- x y)) (* .00001 x))))
|
|
(and (setq e 2.718282)
|
|
(equalp (log e) 1.0)
|
|
(equalp (log (* e e)) 2.0)
|
|
(equalp (log 100) 4.60517)
|
|
(equalp (log 8.0 2) 3.0)
|
|
(equalp (log 1000 10) 3.0)
|
|
(equalp (log 81 3) 4.0))))
|
|
|
|
STOP
|