diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-09 21:08:25 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-09 21:08:25 -0600 |
commit | adda6869cb2a07984b48c39fcd70ee76449c353d (patch) | |
tree | 3aff88b65292e2ab0e108781206d954a015b2e33 /src/approx/derivative.lisp | |
parent | b35e3998333e8190bf07ade51dba30773b3a3d0b (diff) | |
download | cmath-adda6869cb2a07984b48c39fcd70ee76449c353d.tar.gz cmath-adda6869cb2a07984b48c39fcd70ee76449c353d.zip |
updates 10/9
Diffstat (limited to 'src/approx/derivative.lisp')
-rw-r--r-- | src/approx/derivative.lisp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/approx/derivative.lisp b/src/approx/derivative.lisp index 02fcb4c..8aa171a 100644 --- a/src/approx/derivative.lisp +++ b/src/approx/derivative.lisp @@ -1,9 +1,17 @@ (in-package :lizfcm.approx) -(defun derivative-at (f x &optional (delta 0.01)) +(defun central-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)))) + +(defun fwd-derivative-at (f x &optional (delta 0.01)) + (let* ((x2 (+ x delta)) + (x1 x) + (y2 (apply f (list x2))) + (y1 (apply f (list x1)))) + (/ (- y2 y1) + (- x2 x1)))) |