Hatena::Groupsicp

SICP in the blanket

2008-10-24

2.3.2 記号微分

00:58 | はてなブックマーク -  2.3.2 記号微分 - SICP in the blanket  2.3.2 記号微分 - SICP in the blanket のブックマークコメント

操作対象が普通のS式なところが美しい.

note:[differentiation:微分, derivative:導関数]

ex2.56

(define (make-exponentiation b e)
  (cond [(=number? e 0) 1]
        [(=number? e 1) b]
        [else (list '** b e)]))

(define (exponentiation? e)
  (and (pair? e) (eq? '** (car e))))

(define base cadr)
(define exponent caddr)
(define ** expt)
  ;; in deriv
  ;; assume (exponent exp) doesn't contain var
  [(exponentiation? exp)
   (make-product
      (make-product (exponent exp)
                    (make-exponentiation (base exp)
                                         (make-sum (exponent exp) -1)))
      (deriv (base exp) var))]

ex2.57

;; ex2.57
(define (augend e)
  (cond [(or (null? e)
             (null? (cdr e))
             (null? (cddr e))) 0]
        [(null? (cdddr e)) (caddr e)]
        [else (cons '+ (cddr e))]))

(define (multiplicand e)
  (cond [(or (null? e)
             (null? (cdr e))
             (null? (cddr e))) 1]
        [(null? (cdddr e)) (caddr e)]
        [else (cons '* (cddr e))]))

ex2.58

a. 常に括弧がついているなら sum?, addend, augend, product? multiplier, multiplicand あたりをいじるだけで deriv はそのままでいけると思う.

b. S式をいじって括弧を補ってやればいいんじゃないかしら.演算子の優先順位とか面倒そうだけど.

HoucineHoucine2012/10/06 22:17Plseiang you should think of something like that

scdmxiscdmxi2012/10/07 17:44UvO1X4 <a href="http://bxtsehkomsbt.com/">bxtsehkomsbt</a>

tdrwemytxctdrwemytxc2012/10/08 04:12U2wCMK , [url=http://jhezyygxtbyo.com/]jhezyygxtbyo[/url], [link=http://xdhegniqrtgf.com/]xdhegniqrtgf[/link], http://sflnpaysxukf.com/

twexqimtwexqim2012/10/08 17:50kdHYHT <a href="http://dpttfgutirib.com/">dpttfgutirib</a>

ngvyqyangvyqya2012/10/10 02:10f2XUxa , [url=http://wlgfrcxnxlgk.com/]wlgfrcxnxlgk[/url], [link=http://lenfvpaehlzv.com/]lenfvpaehlzv[/link], http://ousbumzwrtaq.com/

トラックバック - http://sicp.g.hatena.ne.jp/blanketsky/20081024