;;;;; ;;;;; ;;;;; Mathematical Functions ;;;;; ;;;;; (define $exp (lambda [$x] (if (float? x) (b.exp x) (if (term? x) (match x term-expr {[,0 1] [,1 e] [>>> (** -1 a)] [_ (to-math-expr )]}) (to-math-expr ))))) (define $log (lambda [$x] (if (float? x) (b.log x) (match x math-expr {[,1 0] [,e 1] [_ (to-math-expr )]})))) (define $cos (lambda [$x] (if (float? x) (b.cos x) (match x math-expr {[,0 1] [,(* 2 pi) 1] [_ (to-math-expr )]})))) (define $sin (lambda [$x] (if (float? x) (b.sin x) (match x math-expr {[,0 0] [_ (to-math-expr )]})))) (define $tan (lambda [$x] (if (float? x) (b.tan x) (match x math-expr {[,0 0] [_ (to-math-expr )]})))) (define $cosh (lambda [$x] (if (float? x) (b.cosh x) (match x math-expr {[,0 1] [_ (to-math-expr )]})))) (define $sinh (lambda [$x] (if (float? x) (b.sinh x) (match x math-expr {[,0 0] [_ (to-math-expr )]})))) (define $tanh (lambda [$x] (if (float? x) (b.tanh x) (match x math-expr {[,0 0] [_ (to-math-expr )]})))) (define $sinc (lambda [$x] (if (float? x) (if (eq? x 0.0) 1.0 (/ (b.sin x) x)) (match x math-expr {[,0 1] [_ (/ (sin x) x)]})))) (define $sigmoid (lambda [$z] (/ 1 (+ 1 (exp (* -1 z)))))) (define $kronecker-delta (cambda $js (if (all (eq? $ (car js)) (cdr js)) 1 0)))