lizfcm/cl/src/approx/derivative.lisp

9 lines
230 B
Common Lisp
Raw Normal View History

2023-09-07 14:19:32 -04:00
(in-package :lizfcm.approx)
(defun derivative-at (f x &optional (delta 0.01))
(let* ((x2 (+ x delta))
(x1 (- x delta))
(y2 (apply f (list x2)))
(y1 (apply f (list x1))))
(/ (- y2 y1) (- x2 x1))))