|
@@ -6,7 +6,9 @@
|
|
|
(:use #:cl)
|
|
|
(:export :derive
|
|
|
:csc
|
|
|
- :sec))
|
|
|
+ :sec
|
|
|
+ :define-equation-functions
|
|
|
+ :take-derivative))
|
|
|
|
|
|
(in-package #:derive)
|
|
|
|
|
@@ -110,4 +112,18 @@ Calculate the cosecant of x"
|
|
|
Calculate the secant of x"
|
|
|
(/ (cos x)))
|
|
|
|
|
|
+(defmacro define-equation-functions (name variable equation)
|
|
|
+ (let ((derivative-name
|
|
|
+ (intern (string-upcase (format nil "d/d~a-~a" variable name))))
|
|
|
+ (derivative (derive equation)))
|
|
|
+ `(progn
|
|
|
+ (defun ,name (,variable)
|
|
|
+ ,equation)
|
|
|
+ (defun ,derivative-name (,variable)
|
|
|
+ ,derivative))))
|
|
|
+
|
|
|
+(defmacro take-derivative (equation)
|
|
|
+ (let ((derivative (derive equation)))
|
|
|
+ `',derivative))
|
|
|
+
|
|
|
;;; End derive
|