Skip to content

Commit

Permalink
56
Browse files Browse the repository at this point in the history
  • Loading branch information
Jane Huang committed Apr 9, 2010
1 parent 43e8e57 commit 0f1cac8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 78 deletions.
74 changes: 0 additions & 74 deletions 2/56_jane.scm

This file was deleted.

18 changes: 14 additions & 4 deletions 2/56_janedotx.scm
Expand Up @@ -12,15 +12,19 @@
(make-product (deriv (multiplier ex) var)
(multiplicand ex))))
((exponentiation? ex)
(make-exponentiation (deriv ())

(make-product (exponent ex) (make-exponentiation (base ex) (- (exponent ex) 1))))
(else
(error "unknown exression type -- DERIV" ex))))

(define (exponentiation? x)
(and (pair? x) (eq? (car x) 'ext)))
(and (pair? x) (eq? (car x) 'expt)))

(define (make-exponentiation ex)
(define (make-exponentiation a1 a2)
(cond ((=number? a1 0) 0)
((=number? a2 0) 1)
((=number? a2 1) a1)
((and (number? a1) (number? a2)) (expt a1 a2))
(else (list 'expt a1 a2))))

(define (base x)
(cadr x))
Expand Down Expand Up @@ -61,4 +65,10 @@
((=number? m2 1) m1)
((and (number? m1) (number? m2)) (* m1 m2))
(else (list '* m1 m2))))
;; does the right thing
(deriv '(expt x 2) 'x)

;;doesn't quite simplify it, but w/ever
(deriv '(expt (* 2 x) 5) 'x)


0 comments on commit 0f1cac8

Please sign in to comment.