;;;;; ;;;;; ;;;;; Integration ;;;;; ;;;;; (define $Sd (lambda [$x $f] (match f math-expr {; symbols [,x (* (/ 1 2) x^2)] [ (* f x)] ; function application [(,exp ,x) (exp x)] [(,cos ,x) (sin x)] [(,sin ,x) (* -1 (cos x))] [(,log ,x) (multSd x 1 (log x))] [(,** $a ,x) (/ (** a x) (log a))] [(,** $a $y) (with-symbols {t} (substitute {[t y]} (Sd t (* (** a t) (d/d (inverse t y x) t)))))] [(,Sd $y $g) (`Sd x (`Sd y g))] [($f $y) (with-symbols {t} (substitute {[t y]} (Sd t (* (f t) (d/d (inverse t y x) t)))))] ; term (constant) [,0 0] [> (* c x)] ; term (multiplication) [> (if (contain-symbol? x r) (`Sd x f) (* (/ a (+ n 1)) (** x (+ n 1)) r))] ; polynomial [ (sum (map (Sd x $) ts))] ; quotient [
$p2> (sum (map 1#(Sd x (/ %1 p2)) ts))] [
(if (contain-symbol? x p2) (`Sd x f) (/ (Sd x p1) p2))] }))) (define $multSd (lambda [$x $f $g] (let {[$F (Sd x f)]} (- (* F g) (Sd x (* F (d/d g x))))))) (define $dSd (lambda [$x $a $b $f] (let {[$F (Sd x f)]} (- (substitute {[x b]} F) (substitute {[x a]} F)))))