lizfcm/deprecated-cl/tests,approx.lisp

49 lines
1.3 KiB
Common Lisp
Raw Normal View History

2023-09-07 14:19:32 -04:00
(defpackage lizfcm/tests.approx
(:use :cl
:fiveam
:lizfcm.approx
:lizfcm.utils
:lizfcm/tests)
(:export :approx-suite))
(in-package :lizfcm/tests.approx)
(def-suite approx-suite
:in lizfcm-test-suite)
(in-suite approx-suite)
2023-10-09 23:08:25 -04:00
(test central-derivative-at
2023-09-07 14:19:32 -04:00
:description "derivative at is within bounds"
(let ((f (lambda (x) (* x x)))
(x 2)
2023-09-13 11:54:12 -04:00
(accepted-delta 0.02)
2023-09-07 14:19:32 -04:00
(f-prime-at-x 4)
(delta 0.01))
(is (within-range-p
2023-10-09 23:08:25 -04:00
(central-derivative-at f x delta)
f-prime-at-x
accepted-delta))))
(test fwd-derivative-at
:description "forward derivative at is within bounds"
(let ((f (lambda (x) (* x x)))
(x 2)
(accepted-delta 0.02)
(f-prime-at-x 4)
(delta 0.01))
(is (within-range-p
(forward-derivative-at f x delta)
2023-09-07 14:19:32 -04:00
f-prime-at-x
2023-09-13 11:54:12 -04:00
accepted-delta))))
(test bwd-derivative-at
:description "backward derivative at is within bounds"
(let ((f (lambda (x) (* x x)))
(x 2)
(accepted-delta 0.02)
(f-prime-at-x 4)
(delta 0.01))
(is (within-range-p
(backward-derivative-at f x delta)
f-prime-at-x
accepted-delta))))