home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-27 | 21.5 KB | 758 lines | [TEXT/????] |
- ;;; $Header: garith.scm,v 1.1 87/08/25 17:40:01 GMT gjs Exp $
- ;;;; Generic Complex and Rational Arithmetic with Operators
-
- ;;; Requires macro file GENERAL\SYN.SCM
-
- ;;; The definitions follow the order in
- ;;; Revised^3 Report on the Algorithmic Language Scheme.
-
- ;;; Primitives are inherited from underlying Scheme.
-
- (move-definition number? s-number?)
- (move-definition real? s-real?)
-
- (move-definition zero? s-zero?)
-
- (move-definition = s-=)
-
- (move-definition 1+ s-1+)
- (move-definition -1+ s--1+)
-
- (move-definition + s-+)
- (move-definition - s--)
- (move-definition * s-*)
- (move-definition / s-/)
-
- (move-definition sin s-sin)
- (move-definition cos s-cos)
- (move-definition atan s-atan)
- (move-definition acos s-acos)
- (move-definition asin s-asin)
-
- (move-definition sqrt s-sqrt)
- (move-definition exp s-exp)
- (move-definition log s-log)
- (move-definition expt s-expt)
-
- (move-definition abs s-abs)
- (move-definition positive? s-positive?)
- (move-definition negative? s-negative?)
- (move-definition < s-<)
- (move-definition > s->)
- (move-definition <= s-<=)
- (move-definition >= s->=)
-
- ;;; Representation of rational numbers
-
- (define-integrable construct-rational
- (lambda (n d) (list* '*rat* n d)))
-
- (define-integrable &numer cadr)
- (define-integrable &denom cddr)
-
- (define-integrable &rational?
- (lambda (q)
- (and (pair? q)
- (eq? (car q) '*rat*))))
-
- (define-integrable rational?
- (lambda (q)
- (or (integer? q)
- (&rational? q))))
-
- (define (make-rational n d) ;gcd already done
- (cond ((s-= d 0) (error "zero denominator -- rational"))
- ((s-= n 0) 0)
- ((s-= d 1) n)
- ((s-< d 0) (make-rational (s-- n) (s-- d)))
- (else (construct-rational n d))))
-
- ;;; The following procedures try to remove common factors as early as
- ;;; possible to reduce the cost of manipulation of big integers.
-
- (define (+_rat x y)
- (let ((dx (&denom x)) (dy (&denom y)))
- (let ((d1 (gcd dx dy)))
- (let ((dx/d1 (quotient dx d1)) (dy/d1 (quotient dy d1)))
- (if (s-= 1 d1)
- (make-rational (s-+ (s-* (&numer x) dy)
- (s-* dx (&numer y)))
- (s-* dx dy))
- (let ((tem (s-+ (s-* dy/d1 (&numer x))
- (s-* dx/d1 (&numer y)))))
- (if (s-= tem 0)
- 0
- (let ((d2 (gcd tem d1)))
- (make-rational (quotient tem d2)
- (s-* dx/d1
- (quotient dy d2)))))))))))
-
- (define (-_rat x y)
- (+_rat x (construct-rational (s-- (&numer y)) (&denom y))))
-
- (define (*_rat x y)
- (let ((nx (&numer x)) (ny (&numer y))
- (dx (&denom x)) (dy (&denom y)))
- (let ((gnxdy (gcd nx dy)) (gnydx (gcd ny dx)))
- (let ((nx/gcd (quotient nx gnxdy)) (dy/gcd (quotient dy gnxdy))
- (ny/gcd (quotient ny gnydx)) (dx/gcd (quotient dx gnydx)))
- (make-rational (s-* nx/gcd ny/gcd)
- (s-* dx/gcd dy/gcd))))))
-
- (define (/_rat x y)
- (*_rat x (construct-rational (&denom y) (&numer y))))
-
- (define =_rat
- (lambda (x y)
- (and (s-= (&numer x) (&numer y)) (s-= (&denom x) (&denom y)))))
-
- (define (make-rel_rat rel)
- (lambda (x y)
- (rel (s-* (&numer x) (&denom y)) (s-* (&denom x) (&numer y)))))
-
- (define <_rat (make-rel_rat s-<))
- (define >_rat (make-rel_rat s->))
- (define <=_rat (make-rel_rat s-<=))
- (define >=_rat (make-rel_rat s->=))
-
- (define (negate_rat x)
- (make-rational (s-- (&numer x)) (&denom x)))
-
- (define (recip_rat x) (make-rational (&denom x) (&numer x)))
-
- (define negative_rat? (lambda (p) (s-negative? (&numer p))))
-
- (define positive_rat? (lambda (p) (s-positive? (&numer p))))
-
- (define (abs_rat p) (if (negative_rat? p) (negate_rat p) p))
-
- (define-integrable 1_rat (construct-rational 1 1))
- (define-integrable -1_rat (construct-rational -1 1))
-
- (define -1+_rat (lambda (p) (+_rat p -1_rat)))
- (define 1+_rat (lambda (p) (+_rat p 1_rat)))
-
-
- (define (numerator q)
- (cond ((integer? q) q)
- ((eq? '*rat* (car q)) (cadr q))
- (else (error "bad rational"))))
-
- (define (denominator q)
- (cond ((integer? q) 1)
- ((eq? '*rat* (car q)) (caddr q))
- (else (error "bad rational"))))
-
- (define (rational->float q)
- (s-/ (&numer q) (&denom q)))
-
- (define (integer->rational z)
- (construct-rational z 1))
-
- ;;; Real arithmetic with rationals
-
- (define (make-unary-real-operation s-op rat-op)
- (lambda (p)
- (cond ((integer? p) (s-op p))
- ((&rational? p) (rat-op p))
- (else (s-op p)))))
-
- (define (make-binary-real-operation s-op rat-op)
- (lambda (p q)
- (cond ((integer? p)
- (cond ((integer? q) (s-op p q))
- ((&rational? q) (rat-op (integer->rational p) q))
- (else (s-op p q))))
- ((&rational? p)
- (cond ((integer? q) (rat-op p (integer->rational q)))
- ((&rational? q) (rat-op p q))
- (else (s-op (rational->float p) q))))
- (else
- (cond ((integer? q) (s-op p q))
- ((&rational? q) (s-op p (rational->float q)))
- (else (s-op p q)))))))
-
- (define (make-binary-special-operation s-op rat-op)
- (lambda (p q)
- (cond ((integer? p)
- (cond ((integer? q)
- (rat-op (integer->rational p)
- (integer->rational q)))
- ((&rational? q) (rat-op (integer->rational p) q))
- (else (s-op p q))))
- ((&rational? p)
- (cond ((integer? q) (rat-op p (integer->rational q)))
- ((&rational? q) (rat-op p q))
- (else (s-op (rational->float p) q))))
- (else ; p is a float
- (cond ((integer? q) (s-op p q))
- ((&rational? q) (s-op p (rational->float q)))
- (else (s-op p q)))))))
-
- (define (make-irrational-operation s-op)
- (lambda ps
- (apply s-op
- (map (lambda (p)
- (cond ((integer? p) p)
- ((&rational? p) (rational->float p))
- (else p)))
- ps))))
-
- (define-integrable real?
- (lambda (x) (or (s-real? x) (&rational? x))))
-
- (define-integrable r-zero?
- (lambda (z) (and (s-number? z) (s-zero? z))))
-
- (define-integrable r-= (make-binary-real-operation s-= =_rat))
-
- (define-integrable r-1+ (make-unary-real-operation s-1+ 1+_rat))
- (define-integrable r--1+ (make-unary-real-operation s--1+ -1+_rat))
-
- (define-integrable r-+ (make-binary-real-operation s-+ +_rat))
- (define-integrable r-- (make-binary-real-operation s-- -_rat))
- (define-integrable r-* (make-binary-real-operation s-* *_rat))
- (define-integrable r-/ (make-binary-special-operation s-/ /_rat))
-
- (define-integrable r-abs (make-unary-real-operation s-abs abs_rat))
- (define-integrable positive?
- (make-unary-real-operation s-positive? positive_rat?))
- (define-integrable negative?
- (make-unary-real-operation s-negative? negative_rat?))
- (define-integrable < (make-binary-real-operation s-< <_rat))
- (define-integrable > (make-binary-real-operation s-> >_rat))
- (define-integrable <= (make-binary-real-operation s-<= <=_rat))
- (define-integrable >= (make-binary-real-operation s->= >=_rat))
-
- (define-integrable r-sin (make-irrational-operation s-sin))
- (define-integrable r-cos (make-irrational-operation s-cos))
- (define-integrable r-atan (make-irrational-operation s-atan))
- (define-integrable r-acos (make-irrational-operation s-acos))
- (define-integrable r-asin (make-irrational-operation s-asin))
- (define-integrable r-sqrt (make-irrational-operation s-sqrt))
- (define-integrable r-exp (make-irrational-operation s-exp))
- (define-integrable r-log (make-irrational-operation s-log))
- (define-integrable r-expt (make-irrational-operation s-expt))
-
- ;;; Operator stuff
-
- (define-integrable operator-type "*operator*")
-
- (define &procedure->operator
- (lambda (procedure)
- (cons operator-type procedure)))
-
- (define &operator?
- (lambda (object)
- (and (pair? object)
- (eq? operator-type (car object)))))
-
- (define &operator->procedure cdr)
-
- (define identity-operator
- (&procedure->operator (lambda (object) object)))
-
- (define (operation*operator->operator operation operator)
- (&procedure->operator
- (lambda (object)
- (operation ((&operator->procedure operator) object)))))
-
- (define (operation*constant*operator->operator operation constant operator)
- (&procedure->operator
- (lambda (object)
- (operation constant ((&operator->procedure operator) object)))))
-
- (define (operation*operator*constant->operator operation operator constant)
- (&procedure->operator
- (lambda (object)
- (operation ((&operator->procedure operator) object) constant))))
-
- (define (operation*operator*operator->operator operation operator1 operator2)
- (&procedure->operator
- (lambda (object)
- (operation ((&operator->procedure operator1) object)
- ((&operator->procedure operator2) object)))))
-
- (define (procedure->operator procedure)
- (if (procedure? procedure)
- (&procedure->operator procedure)
- (error "Illegal operator definition" procedure)))
-
- (define (operator->procedure operator)
- (if (&operator? operator)
- (&operator->procedure operator)
- (lambda (object) operator)))
-
- (define (operator-compose operator1 operator2)
- (&procedure->operator
- (lambda (object)
- ((operator->procedure operator1)
- ((operator->procedure operator2)
- object)))))
-
-
- (define (operator-value operator object)
- (if (&operator? operator)
- (with-reasonable-object object (&operator->procedure operator))
- operator))
-
- (define (with-reasonable-object object procedure)
- (fluid-let ((operator-value-retry
- (call-with-current-continuation
- (lambda (k)
- (lambda ()
- (set! object (perturb-object object))
- (k k))))))
- (procedure object)))
-
- ;;; Because of the following definitions, these operators are
- ;;; restricted to numbers.
-
- (define operator-perturbation-epsilon 1e-11)
-
- (define (perturb-object object)
- (+ object operator-perturbation-epsilon))
-
-
- (define (operation*operator*object->operator operation operator object)
- (cond ((or (real? object) (&complex? object))
- (operation*operator*constant->operator operation operator object))
- ((&operator? object)
- (operation*operator*operator->operator operation operator object))
- (else
- (error "Bad number" object))))
-
- (define (operation*object*operator->operator operation object operator)
- (cond ((or (real? object) (&complex? object))
- (operation*constant*operator->operator operation object operator))
- ((&operator? object)
- (operation*operator*operator->operator operation object operator))
- (else
- (error "Bad number" object))))
-
- ;;;; Complex number data abstraction
-
- (define-integrable complex-type '*rect*)
-
- (define-integrable &complex?
- (lambda (z)
- (and (pair? z) (eq? (car z) complex-type))))
-
- (define-integrable &complex
- (lambda (re im)
- (list* complex-type re im)))
-
- (define-integrable &real-part cadr)
-
- (define-integrable &imag-part cddr)
-
- (define (&conjugate z)
- (&complex (&real-part z)
- (r-- 0 (&imag-part z))))
-
- (define (&sqr-magnitude z)
- (define r-sqr (lambda (x) (r-* x x)))
- (r-+ (r-sqr (&real-part z))
- (r-sqr (&imag-part z))))
-
- (define (&magnitude z)
- (r-sqrt (&sqr-magnitude z)))
-
- (define (&angle z m)
- (if (zero? m)
- (if (fluid-bound? operator-value-retry)
- ((fluid operator-value-retry))
- (error "angle: magnitude is zero"))
- (r-atan (&imag-part z) (&real-part z))))
-
-
-
- ;;; Complex stuff
-
- (define (&make-rectangular re im)
- (if (r-zero? im)
- re
- (&complex re im)))
-
- (define (&make-polar r theta)
- (if (r-zero? r)
- 0
- (&make-rectangular (r-* r (r-cos theta))
- (r-* r (r-sin theta)))))
-
- (define i (&make-rectangular 0 1))
- (define -i (&make-rectangular 0 -1))
-
- ;;;; Bottom layer
-
- (define (make-binary-componentwise-operation r-opr accum error-string)
- (define (operation z1 z2)
- (cond ((real? z1)
- (cond ((real? z2) (r-opr z1 z2))
- ((&complex? z2)
- (accum (r-opr z1 (&real-part z2))
- (r-opr 0 (&imag-part z2))))
- ((&operator? z2)
- (operation*constant*operator->operator operation z1 z2))
- (else (error error-string z2))))
- ((&complex? z1)
- (cond ((real? z2)
- (accum (r-opr (&real-part z1) z2)
- (r-opr (&imag-part z1) 0)))
- ((&complex? z2)
- (accum (r-opr (&real-part z1) (&real-part z2))
- (r-opr (&imag-part z1) (&imag-part z2))))
- ((&operator? z2)
- (operation*constant*operator->operator operation z1 z2))
- (else (error error-string z2))))
- ((&operator? z1)
- (operation*operator*object->operator operation z1 z2))
- (else
- (error error-string z1))))
- operation)
-
- (define &+
- (make-binary-componentwise-operation r-+
- &make-rectangular
- "+: bad number"))
-
- (define &-
- (make-binary-componentwise-operation r--
- &make-rectangular
- "-: bad number"))
-
- (define &=
- (make-binary-componentwise-operation r-=
- (lambda (p q) (and p q))
- "=: bad number"))
-
- (define (&* z1 z2)
- (cond ((real? z1)
- (cond ((real? z2) (r-* z1 z2))
- ((&complex? z2)
- (&make-rectangular (r-* z1 (&real-part z2))
- (r-* z1 (&imag-part z2))))
- ((&operator? z2)
- (operation*constant*operator->operator &* z1 z2))
- (else (error "*: bad number" z2))))
- ((&complex? z1)
- (cond ((real? z2)
- (&make-rectangular (r-* (&real-part z1) z2)
- (r-* (&imag-part z1) z2)))
- ((&complex? z2)
- (&make-rectangular
- (r-- (r-* (&real-part z1) (&real-part z2))
- (r-* (&imag-part z1) (&imag-part z2)))
- (r-+ (r-* (&real-part z1) (&imag-part z2))
- (r-* (&imag-part z1) (&real-part z2)))))
- ((&operator? z2)
- (operation*constant*operator->operator &* z1 z2))
- (else (error "*: bad number" z2))))
- ((&operator? z1)
- (operation*operator*object->operator &* z1 z2))
- (else
- (error "*: bad number" z1))))
-
- (define (square z) (&* z z))
-
- (define (&/ z1 z2)
- (cond ((real? z2)
- (/real z1 z2))
- ((&complex? z2)
- (/real (&* z1 (&conjugate z2)) (&sqr-magnitude z2)))
- ((&operator? z2)
- (operation*object*operator->operator &/ z1 z2))
- (else
- (error "/: bad number" z2))))
-
- (define (/real z x)
- (cond ((r-zero? x)
- (if (fluid-bound? operator-value-retry)
- ((fluid operator-value-retry))
- (error "/: division by zero" z x)))
- ((real? z)
- (r-/ z x))
- ((&complex? z)
- (&make-rectangular (r-/ (&real-part z) x)
- (r-/ (&imag-part z) x)))
- ((&operator? z)
- (operation*operator*constant->operator /real z x))
- (else
- (error "/: bad number" z))))
-
- ;;;; User selector, constructors, and type predicates
-
- (define-integrable complex?
- (lambda (z)
- (or (real? z) (&complex? z))))
-
- (define (make-rectangular x y)
- (if (and (real? x) (real? y))
- (&make-rectangular x y)
- (error "Make-rectangular: bad arguments" x y)))
-
- (define (make-polar r theta)
- (if (and (real? r) (real? theta))
- (&make-polar r theta)
- (error "Make-polar: bad arguments" r theta)))
-
- (define (real-part z)
- (cond ((real? z) z)
- ((&complex? z) (&real-part z))
- ((&operator? z) (operation*operator->operator real-part z))
- (else (error "Real-part: bad number" z))))
-
- (define (imag-part z)
- (cond ((real? z) 0)
- ((&complex? z) (&imag-part z))
- ((&operator? z) (operation*operator->operator imag-part z))
- (else (error "Imag-part: bad number" z))))
-
- (define (magnitude z)
- (cond ((real? z) (r-abs z))
- ((&complex? z) (&magnitude z))
- ((&operator? z) (operation*operator->operator magnitude z))
- (else (error "Magnitude: bad number" z))))
-
- (define-integrable abs magnitude)
-
- (define (angle z)
- (cond ((real? z) (if (negative? z) pi 0))
- ((&complex? z) (&angle z (&magnitude z)))
- ((&operator? z) (operation*operator->operator angle z))
- (else (error "Angle: bad number" z))))
-
- (define (conjugate z)
- (cond ((real? z) z)
- ((&complex? z) (&conjugate z))
- ((&operator? z) (operation*operator->operator conjugate z))
- (else (error "Conjugate: bad number" z))))
-
- ;;;; Unary arithmetic and predicates
-
- (define zero?
- (lambda (z)
- (cond ((real? z)
- (r-zero? z))
- ((&complex? z)
- (and (r-zero? (&real-part z))
- (r-zero? (&imag-part z))))
- (else
- (error "Zero?: Bad complex number" z)))))
-
- (define (make-unary-componentwise-operation r-op error-string)
- (define (operation z)
- (cond ((real? z)
- (r-op z))
- ((&complex? z)
- (&make-rectangular (r-op (&real-part z))
- (&imag-part z)))
- ((&operator? z)
- (operation*operator->operator operation z))
- (else
- (error error-string z))))
- operation)
-
- (define-integrable 1+
- (make-unary-componentwise-operation r-1+ "1+: bad number"))
-
- (define-integrable -1+
- (make-unary-componentwise-operation r--1+ "-1+: bad number"))
-
-
- ;;;; N-ary predicates
-
- ;;; Predicates are extensions of common Lisp because they can be
- ;;; given no arguments, in which case they return `#t'.
-
- (define (make-pairwise-test &pred)
- (lambda args
- (define (loop x y rem)
- (and (&pred x y)
- (or (null? rem)
- (loop y (car rem) (cdr rem)))))
- (or (null? args)
- (null? (cdr args))
- (loop (car args) (cadr args) (cddr args)))))
-
- (define-integrable = (make-pairwise-test &=))
-
- ;;;; N-ary arithmetic
-
- (define (accumulation operation identity)
- (lambda rest
- (define (loop accum rem)
- (if (null? rem)
- accum
- (loop (operation accum (car rem)) (cdr rem))))
- (cond ((null? rest) identity)
- ((null? (cdr rest)) (car rest))
- (else (operation (car rest) (loop (cadr rest) (cddr rest)))))))
-
- (define-integrable + (accumulation &+ 0))
- (define-integrable * (accumulation &* 1))
-
- (define (inverse-accumulation operation1 operation2 identity)
- (lambda rest
- (define (loop accum rem)
- (if (null? rem)
- accum
- (loop (operation2 accum (car rem)) (cdr rem))))
- (cond ((null? rest) identity)
- ((null? (cdr rest)) (operation1 identity (car rest)))
- ((null? (cddr rest)) (operation1 (car rest) (cadr rest)))
- (else (operation1 (car rest) (loop (cadr rest) (cddr rest)))))))
-
- (define-integrable - (inverse-accumulation &- &+ 0))
- (define-integrable / (inverse-accumulation &/ &* 1))
-
- ;;;; Transcendental functions
-
- (define (exp z)
- (cond ((real? z) (r-exp z))
- ((&complex? z)
- (&make-polar (r-exp (&real-part z)) (&imag-part z)))
- ((&operator? z)
- (operation*operator->operator exp z))
- (else (error "Exp: bad number" z))))
-
- (define (log z)
- (cond ((real? z)
- (if (negative? z)
- (&make-rectangular (error-log (r-- 0 z)) pi)
- (error-log z)))
- ((&complex? z)
- (let ((m (&magnitude z)))
- (&make-rectangular (error-log m) (&angle z m))))
- ((&operator? z)
- (operation*operator->operator log z))
- (else
- (error "log: bad number" z))))
-
- (define (error-log x)
- (if (r-zero? x)
- (if (fluid-bound? operator-value-retry)
- ((fluid operator-value-retry))
- (error "log: Log of zero"))
- (r-log x)))
-
- (define (expt z1 z2)
- (if (and (real? z1) (real? z2))
- (r-expt z1 z2)
- (exp (&* z2 (log z1)))))
-
- (define log10
- (let ((e^base (log 10)))
- (lambda (z)
- (/ (log z) e^base))))
-
- (define (sqrt z)
- (cond ((real? z)
- (if (negative? z)
- (&make-rectangular 0 (r-sqrt (r-- 0 z)))
- (r-sqrt z)))
- ((&complex? z)
- (let ((m (&magnitude z)))
- (&make-polar (r-sqrt m)
- (r-/ (&angle z m) 2))))
- ((&operator? z)
- (operation*operator->operator sqrt z))
- (else
- (error "sqrt: bad number" z))))
-
- (define (sin z)
- (define 2i (&make-rectangular 0 2))
- (cond ((real? z) (r-sin z))
- ((&complex? z)
- (let ((iz (&* i z)))
- (&/ (&- (exp iz) (exp (&- 0 iz)))
- 2i)))
- ((&operator? z)
- (operation*operator->operator sin z))
- (else
- (error "sin: bad number" z))))
-
- (define (cos z)
- (cond ((real? z) (r-cos z))
- ((&complex? z)
- (let ((iz (&* i z)))
- (&/ (&+ (exp iz) (exp (&- 0 iz)))
- 2)))
- ((&operator? z)
- (operation*operator->operator cos z))
- (else
- (error "cos: bad number" z))))
-
- (define (tan z)
- (cond ((real? z)
- (let ((den (r-cos z)))
- (if (r-zero? den)
- (if (fluid-bound? operator-value-retry)
- ((fluid operator-value-retry))
- (error "tan: Overflow" z))
- (r-/ (r-sin z) den))))
- ((&complex? z)
- (let* ((iz (&* i z))
- (den (&+ (exp iz) (exp (&- 0 iz)))))
- (if (zero? den)
- (if (fluid-bound? operator-value-retry)
- ((fluid operator-value-retry))
- (error "tan: Overflow" z))
- (&* -i (&/ (&- (exp iz) (exp (&- 0 iz))) den)))))
- ((&operator? z)
- (operation*operator->operator tan z))
- (else
- (error "tan: bad number" z))))
-
- ;;; There's a problem trying to decide what meaning to attach to (atan y x)
- ;;; when y and x can both be complex. The solution taken below is to
- ;;; handle the one- and two-argument cases separately, as follows. With
- ;;; one argument, the analytic function (atan z) is returned. With two
- ;;; arguments -- (atan z1 z2) -- the returned value is (angle z), which is
- ;;; to say, (r-atan (imaginary-part z) (real-part z)), r-atan = old atan, and
- ;;; z is (+ (* i z1) z2); this has the advantage of doing the right thing
- ;;; when z1 and z2 are real. Notice that this is not an analytic function;
- ;;; e.g., it is purely real-valued. Perhaps the only virtue to not simply
- ;;; flagging an error in the two-argument case when both arguments are
- ;;; not real is that the user may have planned for them to be real and
- ;;; missed by a small amount due to roundoff; in this case the answer will
- ;;; be essentially what's wanted. -- MH.
-
- (define atan
- (let ((2i (&* 2 i)))
- (lambda (y . optionals)
- (let ((x (if (not (null? optionals)) (car optionals) 1)))
- (if (and (real? y) (real? x))
- (r-atan y x)
- (let ((iy (&* i y)))
- (&/ (&- (log (&+ x iy)) (log (&- x iy))) 2i)))))))
-
- (define (acos z)
- (if (and (real? z) (<= z 1) (>= z -1))
- (r-acos z)
- (&* -i (log (&- z (&* -i (sqrt (&- 1 (&* z z)))))))))
-
- (define (asin z)
- (if (and (real? z) (<= z 1) (>= z -1))
- (r-asin z)
- (&* -i (log (&+ (&* i z) (sqrt (&- 1 (&* z z))))))))
-
- (define-integrable number? complex?)
-
- (define-integrable operator?
- (lambda (object)
- (or (number? object) (&operator? object))))
-
-
-
- ;;; 6.003 useful operators
-
- (define s identity-operator)
- (define t identity-operator)
-
-
- ;;; For electrical engineers
-
- (define j i)
- (define -j -i)
-