reformat, etc

svn: r9288
This commit is contained in:
Eli Barzilay 2008-04-14 05:17:09 +00:00
parent e98e5d449c
commit a4de7ca7c9

View File

@ -3,7 +3,7 @@
;; math.ss: some extra math routines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module math scheme/base
#lang scheme/base
(provide euler
pi
sqr
@ -17,34 +17,18 @@
(define pi (atan 0 -1))
;; sgn function
(define sgn
(lambda (x)
(define (sgn x)
(if (exact? x)
(cond
((< x 0) -1)
((> x 0) 1)
(else 0))
(cond
((< x 0.0) -1.0)
((> x 0.0) 1.0)
(else 0.0)))))
(cond [(< x 0) -1] [(> x 0) 1] [else 0])
(cond [(< x 0.0) -1.0] [(> x 0.0) 1.0] [else 0.0])))
;; complex conjugate
(define conjugate
(lambda (z)
(make-rectangular
(real-part z)
(- (imag-part z)))))
(define (conjugate z)
(make-rectangular (real-part z) (- (imag-part z))))
;; real hyperbolic functions
(define sinh
(lambda (x)
(/
(- (exp x) (exp (- x)))
2.0)))
(define (sinh x)
(/ (- (exp x) (exp (- x))) 2.0))
(define cosh
(lambda (x)
(/
(+ (exp x) (exp (- x)))
2.0))))
(define (cosh x)
(/ (+ (exp x) (exp (- x))) 2.0))