(defconstant *eps* 1e-16)
(defun sine (x)
"Recursive sine function from Fateman 2003 paper on automatic differentation"
(if (< (abs x) *eps*)
x
(let ((g (sine (/ x 3))))
(- (* 3 g) (* 4 g g g)))))
(trace sine)
(sine (/ pi 2))
(untrace sine)
(time (sine (* 2 pi)))
; Compiling LAMBDA NIL:
; Compiling Top-Level Form:
; Evaluation took:
; 0.02 seconds of real time
; 0.0 seconds of user run time
; 0.0 seconds of system run time
; 13,954,220 CPU cycles
; 8 page faults and
; 14,152 bytes consed.
;
1.3322676295501878d-15The thread on comp.lang lisp about the Coyote Gulch challenge. Bill Clementson, as always, provides an excellent overview of the thread.
For a closer look at optimizing numeric code for CMUCL see this thread on the mailing list.