diff --git a/collects/scheme/math.ss b/collects/scheme/math.ss index 5c765b49d1..1a6c242f03 100644 --- a/collects/scheme/math.ss +++ b/collects/scheme/math.ss @@ -3,48 +3,32 @@ ;; math.ss: some extra math routines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(module math scheme/base - (provide euler - pi - sqr - sgn conjugate - sinh cosh) +#lang scheme/base +(provide euler + pi + sqr + sgn conjugate + sinh cosh) - (define (sqr z) (* z z)) - - ;; circular constants and aliases - (define euler (exp 1.0)) - (define pi (atan 0 -1)) - - ;; sgn function - (define sgn - (lambda (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))))) - - ;; complex conjugate - (define conjugate - (lambda (z) - (make-rectangular - (real-part z) - (- (imag-part z))))) - - ;; real hyperbolic functions - (define sinh - (lambda (x) - (/ - (- (exp x) (exp (- x))) - 2.0))) - - (define cosh - (lambda (x) - (/ - (+ (exp x) (exp (- x))) - 2.0)))) +(define (sqr z) (* z z)) + +;; circular constants and aliases +(define euler (exp 1.0)) +(define pi (atan 0 -1)) + +;; sgn function +(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]))) + +;; complex conjugate +(define (conjugate z) + (make-rectangular (real-part z) (- (imag-part z)))) + +;; real hyperbolic functions +(define (sinh x) + (/ (- (exp x) (exp (- x))) 2.0)) + +(define (cosh x) + (/ (+ (exp x) (exp (- x))) 2.0))