reformat, etc
svn: r9288
This commit is contained in:
parent
e98e5d449c
commit
a4de7ca7c9
|
@ -3,48 +3,32 @@
|
||||||
;; math.ss: some extra math routines
|
;; math.ss: some extra math routines
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(module math scheme/base
|
#lang scheme/base
|
||||||
(provide euler
|
(provide euler
|
||||||
pi
|
pi
|
||||||
sqr
|
sqr
|
||||||
sgn conjugate
|
sgn conjugate
|
||||||
sinh cosh)
|
sinh cosh)
|
||||||
|
|
||||||
(define (sqr z) (* z z))
|
(define (sqr z) (* z z))
|
||||||
|
|
||||||
;; circular constants and aliases
|
;; circular constants and aliases
|
||||||
(define euler (exp 1.0))
|
(define euler (exp 1.0))
|
||||||
(define pi (atan 0 -1))
|
(define pi (atan 0 -1))
|
||||||
|
|
||||||
;; sgn function
|
;; sgn function
|
||||||
(define sgn
|
(define (sgn x)
|
||||||
(lambda (x)
|
(if (exact? x)
|
||||||
(if (exact? x)
|
(cond [(< x 0) -1] [(> x 0) 1] [else 0])
|
||||||
(cond
|
(cond [(< x 0.0) -1.0] [(> x 0.0) 1.0] [else 0.0])))
|
||||||
((< x 0) -1)
|
|
||||||
((> x 0) 1)
|
;; complex conjugate
|
||||||
(else 0))
|
(define (conjugate z)
|
||||||
(cond
|
(make-rectangular (real-part z) (- (imag-part z))))
|
||||||
((< x 0.0) -1.0)
|
|
||||||
((> x 0.0) 1.0)
|
;; real hyperbolic functions
|
||||||
(else 0.0)))))
|
(define (sinh x)
|
||||||
|
(/ (- (exp x) (exp (- x))) 2.0))
|
||||||
;; complex conjugate
|
|
||||||
(define conjugate
|
(define (cosh x)
|
||||||
(lambda (z)
|
(/ (+ (exp x) (exp (- x))) 2.0))
|
||||||
(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))))
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user