|
@@ -6,8 +6,7 @@
|
|
|
(:use #:cl)
|
|
|
(:export :derive
|
|
|
:csc
|
|
|
- :sec
|
|
|
- :cot))
|
|
|
+ :sec))
|
|
|
|
|
|
(in-package #:derive)
|
|
|
|
|
@@ -19,7 +18,7 @@ Derives an equation using the normal rules of differentiation."
|
|
|
(declare (cons equation))
|
|
|
(let ((op (first equation)))
|
|
|
(cond
|
|
|
- ((member op '(sin cos tan csc sec cot sqrt))
|
|
|
+ ((member op '(sin cos tan csc sec cot))
|
|
|
(chain equation))
|
|
|
((equal op 'expt)
|
|
|
(power (rest equation)))
|
|
@@ -75,7 +74,21 @@ Derive using quotient rule"
|
|
|
"chain -- (chain equation)
|
|
|
Apply the chain rule to the equation"
|
|
|
(declare (cons equation))
|
|
|
- )
|
|
|
+ (let ((op (first equation))
|
|
|
+ (arg (second equation)))
|
|
|
+ (case op
|
|
|
+ (sin
|
|
|
+ `(* (cos ,arg) ,(derive arg)))
|
|
|
+ (cos
|
|
|
+ `(* (- (sin ,arg)) ,(derive arg)))
|
|
|
+ (tan
|
|
|
+ `(* (expt (sec ,arg) 2) ,(derive arg)))
|
|
|
+ (csc
|
|
|
+ `(* (- (csc ,arg)) (cot ,arg) ,(derive arg)))
|
|
|
+ (sec
|
|
|
+ `(* (sec ,arg) (tan ,arg) ,(derive arg)))
|
|
|
+ (cot
|
|
|
+ `(* (- (expt (csc ,arg) 2)) ,(derive arg))))))
|
|
|
|
|
|
(defun power (eq)
|
|
|
"power -- (power rest)
|
|
@@ -97,9 +110,4 @@ Calculate the cosecant of x"
|
|
|
Calculate the secant of x"
|
|
|
(/ (cos x)))
|
|
|
|
|
|
-(defun cot (x)
|
|
|
- "cot -- (cot x)
|
|
|
-Calculate the cotangent of x"
|
|
|
- (/ (tan x)))
|
|
|
-
|
|
|
;;; End derive
|