2 (:use [sicp.ch2_3 :exclude (deriv)]
6 (declare exponentiation? exponent base make-exponentiation)
10 (variable? exp) (if (same-variable? exp var) 1 0)
11 (sum? exp) (make-sum (deriv (addend exp) var)
12 (deriv (augend exp) var))
13 (product? exp) (make-sum (make-product (multiplier exp)
14 (deriv (multiplicand exp) var))
15 (make-product (deriv (multiplier exp) var)
17 (exponentiation? exp) (make-product (exponent exp)
18 (make-product (make-exponentiation (base exp)
20 (deriv (base exp) var)))
21 :else (error "unknown expression type -- derive")))
23 (defn exponentiation? [exp]
32 (defn make-exponentiation [b n]
33 (cond (=number? b 1) 1
37 (and (number? b) (number? n)) (Math/pow b n)
38 :else (list '** b n)))