b. 加算と乗算を微分する関数書け。その関数をテーブルにインストールするコードも書け.
(define (install-sum-and-product) (define (deriv-sum exp var) (make-sum (deriv (addend exp) var) (deriv (augend exp) var))) (define (deriv-product exp var) (make-sum (make-product (multiplier exp) (deriv (multiplicand exp) var)) (make-product (deriv (multiplier exp) var) (multiplicand exp)))) (put 'deriv '+ deriv-sum) (put 'deriv '* deriv-product) 'done)
実行結果。http://oss.timedia.co.jp/show/SICPのテーブルを使わせていただきました。。
(deriv '(* (+ (* 10 x) y) x) 'x); ((+ (* 10 x) y) + (10 * x))