\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/algebra sf.spad}
\author{Michael Monagan, Stephen M. Watt}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{category REAL RealConstant}
<<category REAL RealConstant>>=
)abbrev category REAL RealConstant
++ Author:
++ Date Created:
++ Date Last Updated:
++ Basic Functions:
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description:
++ The category of real numeric domains, i.e. convertible to floats.
RealConstant(): Category ==
  Join(ConvertibleTo DoubleFloat, ConvertibleTo Float)

@
\section{category RADCAT RadicalCategory}
<<category RADCAT RadicalCategory>>=
)abbrev category RADCAT RadicalCategory
++ Author:
++ Date Created:
++ Change History:
++ Basic Operations: nthRoot, sqrt, **
++ Related Constructors:
++ Keywords: rational numbers
++ Description: The \spad{RadicalCategory} is a model for the rational numbers.
RadicalCategory(): Category == with
  sqrt   : % -> %
      ++ sqrt(x) returns the square root of x.
  nthRoot: (%, Integer) -> %
      ++ nthRoot(x,n) returns the nth root of x.
  _*_*   : (%, Fraction Integer) -> %
      ++ x ** y is the rational exponentiation of x by the power y.
 add
  sqrt x        == x ** inv(2::Fraction(Integer))
  nthRoot(x, n) == x ** inv(n::Fraction(Integer))

@
\section{category RNS RealNumberSystem}
<<category RNS RealNumberSystem>>=
)abbrev category RNS RealNumberSystem
++ Author: Michael Monagan and Stephen M. Watt
++ Date Created:
++   January 1988
++ Change History:
++ Basic Operations: abs, ceiling, wholePart, floor, fractionPart, norm, round, truncate
++ Related Constructors:
++ Keywords: real numbers
++ Description:  
++ The real number system category is intended as a model for the real
++ numbers.  The real numbers form an ordered normed field.  Note that
++ we have purposely not included \spadtype{DifferentialRing} or the elementary
++ functions (see \spadtype{TranscendentalFunctionCategory}) in the definition.
RealNumberSystem(): Category ==
  Join(Field, OrderedRing, RealConstant, RetractableTo Integer,
       RetractableTo Fraction Integer, RadicalCategory,
        ConvertibleTo Pattern Float, PatternMatchable Float,
          CharacteristicZero) with
    norm : % -> %
      ++ norm x returns the same as absolute value.
    ceiling : % -> %
      ++ ceiling x returns the small integer \spad{>= x}.
    floor: % -> %
      ++ floor x returns the largest integer \spad{<= x}.
    wholePart  : % -> Integer
      ++ wholePart x returns the integer part of x.
    fractionPart : % -> %
      ++ fractionPart x returns the fractional part of x.
    truncate: % -> %
      ++ truncate x returns the integer between x and 0 closest to x.
    round: % -> %
      ++ round x computes the integer closest to x.
    abs  : % -> %
      ++ abs x returns the absolute value of x.

 add
   characteristic() == 0
   fractionPart x           == x - truncate x
   truncate x          == (negative? x => -floor(-x); floor x)
   round x          == (negative? x => truncate(x-1/2::%); truncate(x+1/2::%))
   norm x           == abs x
   coerce(x:Fraction Integer):% == numer(x)::% / denom(x)::%
   convert(x:%):Pattern(Float)  == convert(x)@Float :: Pattern(Float)

   floor x ==
      x1 := (wholePart x) :: %
      x = x1 => x
      x < 0 => (x1 - 1)
      x1

   ceiling x ==
      x1 := (wholePart x)::%
      x = x1 => x
      x >= 0 => (x1 + 1)
      x1

   patternMatch(x, p, l) ==
     generic? p => addMatch(p, x, l)
     constant? p =>
       (r := retractIfCan(p)@Union(Float, "failed")) case Float =>
         convert(x)@Float = r::Float => l
         failed()
       failed()
     failed()

@
\section{RNS.lsp BOOTSTRAP} 
{\bf RNS} depends on a chain of
files. We need to break this cycle to build the algebra. So we keep a
cached copy of the translated {\bf RNS} category which we can write
into the {\bf MID} directory. We compile the lisp code and copy the
{\bf RNS.o} file to the {\bf OUT} directory.  This is eventually
forcibly replaced by a recompiled version.

Note that this code is not included in the generated catdef.spad file.

<<RNS.lsp BOOTSTRAP>>=

(|/VERSIONCHECK| 2) 

(SETQ |RealNumberSystem;AL| (QUOTE NIL)) 

(DEFUN |RealNumberSystem| NIL 
  (LET (#:G105478) 
    (COND 
      (|RealNumberSystem;AL|)
      (T (SETQ |RealNumberSystem;AL| (|RealNumberSystem;|)))))) 

(DEFUN |RealNumberSystem;| NIL 
  (PROG (#1=#:G105476) 
    (RETURN 
      (PROG1 
        (LETT #1# 
          (|sublisV| 
            (PAIR 
              (QUOTE (#2=#:G105472 #3=#:G105473 #4=#:G105474 #5=#:G105475))
              (LIST 
                (QUOTE (|Integer|))
                (QUOTE (|Fraction| (|Integer|)))
                (QUOTE (|Pattern| (|Float|)))
                (QUOTE (|Float|))))
            (|Join| 
              (|Field|)
              (|OrderedRing|)
              (|RealConstant|)
              (|RetractableTo| (QUOTE #2#))
              (|RetractableTo| (QUOTE #3#))
              (|RadicalCategory|)
              (|ConvertibleTo| (QUOTE #4#))
              (|PatternMatchable| (QUOTE #5#))
              (|CharacteristicZero|)
              (|mkCategory| 
                (QUOTE |domain|)
                (QUOTE (
                  ((|norm| (|$| |$|)) T)
                  ((|ceiling| (|$| |$|)) T)
                  ((|floor| (|$| |$|)) T)
                  ((|wholePart| ((|Integer|) |$|)) T)
                  ((|fractionPart| (|$| |$|)) T)
                  ((|truncate| (|$| |$|)) T)
                  ((|round| (|$| |$|)) T)
                  ((|abs| (|$| |$|)) T)))
                NIL
                (QUOTE ((|Integer|)))
                NIL)))
          |RealNumberSystem|)
        (SETELT #1# 0 (QUOTE (|RealNumberSystem|))))))) 

(MAKEPROP (QUOTE |RealNumberSystem|) (QUOTE NILADIC) T) 

@
\section{RNS-.lsp BOOTSTRAP} 
{\bf RNS-} depends {\bf RNS}.
We need to break this cycle to build the algebra. So we keep a
cached copy of the translated {\bf RNS-} category which we can write
into the {\bf MID} directory. We compile the lisp code and copy the
{\bf RNS.o} file to the {\bf OUT} directory.  This is eventually
forcibly replaced by a recompiled version.

Note that this code is not included in the generated catdef.spad file.

<<RNS-.lsp BOOTSTRAP>>=

(|/VERSIONCHECK| 2) 

(PUT 
  (QUOTE |RNS-;characteristic;Nni;1|) 
  (QUOTE |SPADreplace|) 
  (QUOTE (XLAM NIL 0))) 

(DEFUN |RNS-;characteristic;Nni;1| (|$|) 0) 

(DEFUN |RNS-;fractionPart;2S;2| (|x| |$|) 
  (SPADCALL |x| (SPADCALL |x| (QREFELT |$| 9)) (QREFELT |$| 10))) 

(DEFUN |RNS-;truncate;2S;3| (|x| |$|) 
  (COND 
    ((SPADCALL |x| (QREFELT |$| 13))
      (SPADCALL 
        (SPADCALL 
          (SPADCALL |x| (QREFELT |$| 14))
          (QREFELT |$| 15)) 
        (QREFELT |$| 14)))
    ((QUOTE T) (SPADCALL |x| (QREFELT |$| 15))))) 

(DEFUN |RNS-;round;2S;4| (|x| |$|) 
  (COND 
    ((SPADCALL |x| (QREFELT |$| 13))
      (SPADCALL 
        (SPADCALL |x| 
          (SPADCALL 
            (|spadConstant| |$| 17)
            (SPADCALL 2 (QREFELT |$| 19))
            (QREFELT |$| 20))
          (QREFELT |$| 10)) 
        (QREFELT |$| 9)))
    ((QUOTE T) 
      (SPADCALL 
        (SPADCALL |x| 
          (SPADCALL 
            (|spadConstant| |$| 17)
            (SPADCALL 2 (QREFELT |$| 19))
            (QREFELT |$| 20)) 
          (QREFELT |$| 21)) 
        (QREFELT |$| 9))))) 

(DEFUN |RNS-;norm;2S;5| (|x| |$|) 
  (SPADCALL |x| (QREFELT |$| 23))) 

(DEFUN |RNS-;coerce;FS;6| (|x| |$|) 
  (SPADCALL 
    (SPADCALL 
      (SPADCALL |x| (QREFELT |$| 26))
      (QREFELT |$| 19)) 
    (SPADCALL 
      (SPADCALL |x| (QREFELT |$| 27))
      (QREFELT |$| 19))
    (QREFELT |$| 20))) 

(DEFUN |RNS-;convert;SP;7| (|x| |$|) 
  (SPADCALL (SPADCALL |x| (QREFELT |$| 30)) (QREFELT |$| 32))) 

(DEFUN |RNS-;floor;2S;8| (|x| |$|) 
  (PROG (|x1|) 
    (RETURN 
      (SEQ 
        (LETT |x1| 
          (SPADCALL (SPADCALL |x| (QREFELT |$| 34)) (QREFELT |$| 19))
          |RNS-;floor;2S;8|)
        (EXIT 
          (COND 
            ((SPADCALL |x| |x1| (QREFELT |$| 35)) |x|)
            ((SPADCALL |x| (|spadConstant| |$| 36) (QREFELT |$| 37))
              (SPADCALL |x1| (|spadConstant| |$| 17) (QREFELT |$| 10)))
            ((QUOTE T) |x1|))))))) 

(DEFUN |RNS-;ceiling;2S;9| (|x| |$|) 
  (PROG (|x1|) 
    (RETURN 
      (SEQ 
        (LETT |x1| 
          (SPADCALL (SPADCALL |x| (QREFELT |$| 34)) (QREFELT |$| 19))
          |RNS-;ceiling;2S;9|)
        (EXIT 
          (COND 
            ((SPADCALL |x| |x1| (QREFELT |$| 35)) |x|)
            ((SPADCALL |x| (|spadConstant| |$| 36) (QREFELT |$| 37)) |x1|)
            ((QUOTE T) 
              (SPADCALL |x1| (|spadConstant| |$| 17) (QREFELT |$| 21))))))))) 

(DEFUN |RNS-;patternMatch;SP2Pmr;10| (|x| |p| |l| |$|) 
  (PROG (|r|) 
    (RETURN 
      (SEQ 
        (COND 
          ((SPADCALL |p| (QREFELT |$| 40))
            (SPADCALL |p| |x| |l| (QREFELT |$| 42)))
          ((SPADCALL |p| (QREFELT |$| 43))
            (SEQ 
              (LETT |r| 
                (SPADCALL |p| (QREFELT |$| 45))
                |RNS-;patternMatch;SP2Pmr;10|)
              (EXIT 
                (COND 
                  ((QEQCAR |r| 0)
                    (COND 
                      ((SPADCALL 
                         (SPADCALL |x| (QREFELT |$| 30))
                         (QCDR |r|)
                         (QREFELT |$| 46))
                        |l|)
                      ((QUOTE T) (SPADCALL (QREFELT |$| 47)))))
                  ((QUOTE T) (SPADCALL (QREFELT |$| 47)))))))
          ((QUOTE T) (SPADCALL (QREFELT |$| 47)))))))) 

(DEFUN |RealNumberSystem&| (|#1|) 
  (PROG (|DV$1| |dv$| |$| |pv$|) 
    (RETURN 
      (PROGN 
        (LETT |DV$1| (|devaluate| |#1|) . #1=(|RealNumberSystem&|))
        (LETT |dv$| (LIST (QUOTE |RealNumberSystem&|) |DV$1|) . #1#)
        (LETT |$| (GETREFV 52) . #1#)
        (QSETREFV |$| 0 |dv$|)
        (QSETREFV |$| 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
        (|stuffDomainSlots| |$|)
        (QSETREFV |$| 6 |#1|)
        |$|)))) 

(MAKEPROP 
  (QUOTE |RealNumberSystem&|)
  (QUOTE |infovec|)
  (LIST 
    (QUOTE 
      #(NIL NIL NIL NIL NIL NIL 
        (|local| |#1|)
        (|NonNegativeInteger|)
        |RNS-;characteristic;Nni;1| 
        (0 . |truncate|)
        (5 . |-|)
        |RNS-;fractionPart;2S;2| 
        (|Boolean|)
        (11 . |negative?|)
        (16 . |-|)
        (21 . |floor|)
        |RNS-;truncate;2S;3| 
        (26 . |One|)
        (|Integer|)
        (30 . |coerce|)
        (35 . |/|)
        (41 . |+|)
        |RNS-;round;2S;4| 
        (47 . |abs|)
        |RNS-;norm;2S;5| 
        (|Fraction| 18)
        (52 . |numer|)
        (57 . |denom|)
        |RNS-;coerce;FS;6| 
        (|Float|)
        (62 . |convert|)
        (|Pattern| 29)
        (67 . |coerce|)
        |RNS-;convert;SP;7| 
        (72 . |wholePart|)
        (77 . |=|)
        (83 . |Zero|)
        (87 . |<|)
        |RNS-;floor;2S;8| 
        |RNS-;ceiling;2S;9| 
        (93 . |generic?|)
        (|PatternMatchResult| 29 6)
        (98 . |addMatch|)
        (105 . |constant?|)
        (|Union| 29 (QUOTE "failed"))
        (110 . |retractIfCan|)
        (115 . |=|)
        (121 . |failed|)
        (|PatternMatchResult| 29 |$|)
        |RNS-;patternMatch;SP2Pmr;10| 
        (|DoubleFloat|)
        (|OutputForm|))) 
    (QUOTE 
      #(|truncate| 125 |round| 130 |patternMatch| 135 |norm| 142 
        |fractionPart| 147 |floor| 152 |convert| 157 |coerce| 162 
        |characteristic| 172 |ceiling| 176)) 
    (QUOTE NIL) 
    (CONS 
      (|makeByteWordVec2| 1 (QUOTE NIL))
      (CONS 
        (QUOTE #())
        (CONS 
          (QUOTE #())
          (|makeByteWordVec2| 49 
            (QUOTE 
              (1 6 0 0 9 2 6 0 0 0 10 1 6 12 0 13 1 6 0 0 14 1 6 0 0 15 0 6 0
               17 1 6 0 18 19 2 6 0 0 0 20 2 6 0 0 0 21 1 6 0 0 23 1 25 18 0
               26 1 25 18 0 27 1 6 29 0 30 1 31 0 29 32 1 6 18 0 34 2 6 12 0
               0 35 0 6 0 36 2 6 12 0 0 37 1 31 12 0 40 3 41 0 31 6 0 42 1 31
               12 0 43 1 31 44 0 45 2 29 12 0 0 46 0 41 0 47 1 0 0 0 16 1 0 0
               0 22 3 0 48 0 31 48 49 1 0 0 0 24 1 0 0 0 11 1 0 0 0 38 1 0 31
               0 33 1 0 0 25 28 1 0 0 25 28 0 0 7 8 1 0 0 0 39)))))) 
    (QUOTE |lookupComplete|))) 

@
\section{category FPS FloatingPointSystem}
<<category FPS FloatingPointSystem>>=
)abbrev category FPS FloatingPointSystem
++ Author:
++ Date Created:
++ Change History:
++ Basic Operations: approximate, base, bits, digits, exponent, float,
++    mantissa, order, precision, round?
++ Related Constructors:
++ Keywords: float, floating point
++ Description:  
++ This category is intended as a model for floating point systems.
++ A floating point system is a model for the real numbers.  In fact,
++ it is an approximation in the sense that not all real numbers are
++ exactly representable by floating point numbers.
++ A floating point system is characterized by the following:
++
++   1: \spadfunFrom{base}{FloatingPointSystem} of the \spadfunFrom{exponent}{FloatingPointSystem}.
++          (actual implemenations are usually binary or decimal)
++   2: \spadfunFrom{precision}{FloatingPointSystem} of the \spadfunFrom{mantissa}{FloatingPointSystem} (arbitrary or fixed)
++   3: rounding error for operations
--++   4:  when, and what happens if exponent overflow/underflow occurs
++
++ Because a Float is an approximation to the real numbers, even though
++ it is defined to be a join of a Field and OrderedRing, some of
++ the attributes do not hold.  In particular associative("+")
++ does not hold.  Algorithms defined over a field need special
++ considerations when the field is a floating point system.
FloatingPointSystem(): Category == RealNumberSystem() with
   approximate
      ++ \spad{approximate} means "is an approximation to the real numbers".
   float: (Integer,Integer) -> %
      ++ float(a,e) returns \spad{a * base() ** e}.
   float: (Integer,Integer,PositiveInteger) -> %
      ++ float(a,e,b) returns \spad{a * b ** e}.
   order: % -> Integer
      ++ order x is the order of magnitude of x.
      ++ Note: \spad{base ** order x <= |x| < base ** (1 + order x)}.
   base: () -> PositiveInteger
      ++ base() returns the base of the \spadfunFrom{exponent}{FloatingPointSystem}.
   exponent: % -> Integer
      ++ exponent(x) returns the \spadfunFrom{exponent}{FloatingPointSystem} part of x.
   mantissa: % -> Integer
      ++ mantissa(x) returns the mantissa part of x.
  -- round?: () -> B
  --    ++ round?() returns the rounding or chopping.

   bits: () -> PositiveInteger
      ++ bits() returns ceiling's precision in bits.
   digits: () -> PositiveInteger
      ++ digits() returns ceiling's precision in decimal digits.
   precision: () -> PositiveInteger
      ++ precision() returns the precision in digits base.

   if % has arbitraryPrecision then
      bits: PositiveInteger -> PositiveInteger
        ++ bits(n) set the \spadfunFrom{precision}{FloatingPointSystem} to n bits.
      digits: PositiveInteger -> PositiveInteger
        ++ digits(d) set the \spadfunFrom{precision}{FloatingPointSystem} to d digits.
      precision: PositiveInteger -> PositiveInteger
        ++ precision(n) set the precision in the base to n decimal digits.
      increasePrecision: Integer -> PositiveInteger
        ++ increasePrecision(n) increases the current
        ++ \spadfunFrom{precision}{FloatingPointSystem} by n decimal digits.
      decreasePrecision: Integer -> PositiveInteger
        ++ decreasePrecision(n) decreases the current
        ++ \spadfunFrom{precision}{FloatingPointSystem} precision by n decimal digits.
   if not (% has arbitraryExponent) then
    --  overflow: (()->Exit) -> Void
    --    ++ overflow() returns the Exponent overflow of float
    --  underflow: (()->Exit) -> Void
    --    ++ underflow() returns the Exponent underflow of float
    --  maxExponent: () -> Integer
    --    ++ maxExponent() returns the max Exponent of float
      if not (% has arbitraryPrecision) then
         min: () -> %
          ++ min() returns the minimum floating point number.
         max: () -> %
          ++ max() returns the maximum floating point number.
 add
   float(ma, ex) == float(ma, ex, base())
   digits() == max(1,4004 * (bits()-1) quo 13301)::PositiveInteger

@
\section{FPS.lsp BOOTSTRAP} 
{\bf FPS} depends on a chain of
files. We need to break this cycle to build the algebra. So we keep a
cached copy of the translated {\bf FPS} category which we can write
into the {\bf MID} directory. We compile the lisp code and copy the
{\bf FPS.o} file to the {\bf OUT} directory.  This is eventually
forcibly replaced by a recompiled version.

Note that this code is not included in the generated catdef.spad file.

<<FPS.lsp BOOTSTRAP>>=

(|/VERSIONCHECK| 2) 

(SETQ |FloatingPointSystem;AL| (QUOTE NIL)) 

(DEFUN |FloatingPointSystem| NIL 
  (LET (#:G105645) 
    (COND 
      (|FloatingPointSystem;AL|) 
      (T (SETQ |FloatingPointSystem;AL| (|FloatingPointSystem;|)))))) 

(DEFUN |FloatingPointSystem;| NIL 
  (PROG (#1=#:G105643) 
    (RETURN 
      (PROG1 
        (LETT #1# 
          (|Join| 
            (|RealNumberSystem|)
            (|mkCategory| 
              (QUOTE |domain|)
              (QUOTE (
                ((|float| (|$| (|Integer|) (|Integer|))) T)
                ((|float| (|$| (|Integer|) (|Integer|) (|PositiveInteger|))) T)
                ((|order| ((|Integer|) |$|)) T)
                ((|base| ((|PositiveInteger|))) T)
                ((|exponent| ((|Integer|) |$|)) T)
                ((|mantissa| ((|Integer|) |$|)) T)
                ((|bits| ((|PositiveInteger|))) T)
                ((|digits| ((|PositiveInteger|))) T)
                ((|precision| ((|PositiveInteger|))) T)
                ((|bits| ((|PositiveInteger|) (|PositiveInteger|))) 
                  (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                ((|digits| ((|PositiveInteger|) (|PositiveInteger|))) 
                  (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                ((|precision| ((|PositiveInteger|) (|PositiveInteger|))) 
                  (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                ((|increasePrecision| ((|PositiveInteger|) (|Integer|))) 
                  (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                ((|decreasePrecision| ((|PositiveInteger|) (|Integer|))) 
                  (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                ((|min| (|$|)) 
                  (AND 
                    (|not| (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                    (|not| (|has| |$| (ATTRIBUTE |arbitraryExponent|)))))
                ((|max| (|$|)) 
                  (AND 
                    (|not| (|has| |$| (ATTRIBUTE |arbitraryPrecision|)))
                    (|not| (|has| |$| (ATTRIBUTE |arbitraryExponent|)))))))
              (QUOTE ((|approximate| T)))
              (QUOTE ((|PositiveInteger|) (|Integer|)))
              NIL))
          |FloatingPointSystem|)
        (SETELT #1# 0 (QUOTE (|FloatingPointSystem|))))))) 

(MAKEPROP (QUOTE |FloatingPointSystem|) (QUOTE NILADIC) T) 

@
\section{FPS-.lsp BOOTSTRAP} 
{\bf FPS-} depends {\bf FPS}.
We need to break this cycle to build the algebra. So we keep a
cached copy of the translated {\bf FPS-} category which we can write
into the {\bf MID} directory. We compile the lisp code and copy the
{\bf FPS-.o} file to the {\bf OUT} directory.  This is eventually
forcibly replaced by a recompiled version.

Note that this code is not included in the generated catdef.spad file.

<<FPS-.lsp BOOTSTRAP>>=

(|/VERSIONCHECK| 2) 

(DEFUN |FPS-;float;2IS;1| (|ma| |ex| |$|) 
  (SPADCALL |ma| |ex| (SPADCALL (QREFELT |$| 8)) (QREFELT |$| 10))) 

(DEFUN |FPS-;digits;Pi;2| (|$|) 
  (PROG (#1=#:G105654) 
    (RETURN 
      (PROG1 
        (LETT #1# 
          (MAX 1 
            (QUOTIENT2 
              (SPADCALL 4004 
                (|-| (SPADCALL (QREFELT |$| 13)) 1)
                (QREFELT |$| 14))
              13301))
          |FPS-;digits;Pi;2|)
        (|check-subtype| (|>| #1# 0) (QUOTE (|PositiveInteger|)) #1#))))) 

(DEFUN |FloatingPointSystem&| (|#1|) 
  (PROG (|DV$1| |dv$| |$| |pv$|) 
    (RETURN 
      (PROGN 
        (LETT |DV$1| (|devaluate| |#1|) . #1=(|FloatingPointSystem&|))
        (LETT |dv$| (LIST (QUOTE |FloatingPointSystem&|) |DV$1|) . #1#)
        (LETT |$| (GETREFV 17) . #1#)
        (QSETREFV |$| 0 |dv$|)
        (QSETREFV |$| 3 
          (LETT |pv$| 
            (|buildPredVector| 0 0 
              (LIST 
                (|HasAttribute| |#1| (QUOTE |arbitraryExponent|))
                (|HasAttribute| |#1| (QUOTE |arbitraryPrecision|)))) . #1#))
        (|stuffDomainSlots| |$|)
        (QSETREFV |$| 6 |#1|)
        |$|)))) 

(MAKEPROP 
  (QUOTE |FloatingPointSystem&|)
  (QUOTE |infovec|)
  (LIST 
    (QUOTE 
      #(NIL NIL NIL NIL NIL NIL 
        (|local| |#1|)
        (|PositiveInteger|)
        (0 . |base|)
        (|Integer|)
        (4 . |float|)
        |FPS-;float;2IS;1| 
        (11 . |One|)
        (15 . |bits|)
        (19 . |*|)
        (25 . |max|)
        |FPS-;digits;Pi;2|)) 
    (QUOTE #(|float| 29 |digits| 35)) 
    (QUOTE NIL) 
    (CONS 
      (|makeByteWordVec2| 1 (QUOTE NIL))
      (CONS 
        (QUOTE #())
        (CONS 
          (QUOTE #())
          (|makeByteWordVec2| 16 
            (QUOTE 
              (0 6 7 8 3 6 0 9 9 7 10 0 6 0 12 0 6 7 13 2 9 0 7 0 14 0 6 0 15
               2 0 0 9 9 11 0 0 7 16)))))) 
     (QUOTE |lookupComplete|))) 

@
\section{domain DFLOAT DoubleFloat}
Greg Vanuxem has added some functionality to allow the user to modify
the printed format of floating point numbers. The format of the numbers
follows the common lisp format specification for floats. First we include
Greg's email to show the use of this feature:
\begin{verbatim}
PS: For those who use the Doublefloat domain
    there is an another (undocumented) patch that adds a
    lisp format to the DoubleFloat output routine. Copy 
    int/algebra/DFLOAT.spad to your working directory,
    patch it, compile it and ")lib" it when necessary.


(1) -> )boot $useBFasDefault:=false

(SPADLET |$useBFasDefault| NIL)
Value = NIL
(1) -> a:= matrix [ [0.5978,0.2356], [0.4512,0.2355] ]

        +      0.5978               0.2356       +
   (1)  |                                        |
        +0.45119999999999999  0.23549999999999999+
                               Type: Matrix DoubleFloat
(2) -> )lib DFLOAT
   DoubleFloat is now explicitly exposed in frame initial
   DoubleFloat will be automatically loaded when needed
from /home/greg/Axiom/DFLOAT.NRLIB/code
(2) -> doubleFloatFormat("~,4,,F")

   (2)  "~G"
                               Type: String
(3) -> a

        +0.5978  0.2356+
   (3)  |              |
        +0.4512  0.2355+
                               Type: Matrix DoubleFloat

\end{verbatim}
So it is clear that he has added a new function called
{\tt doubleFloatFormat} which takes a string argument that
specifies the common lisp format control string (\"{}\~{},4,,F\"{}).
For reference we quote from the common lisp manual \cite{1}.
On page 582 we find:

\begin{quote}
A format directive consists of a tilde (\~{}), optional prefix
parameters separated by commas, optional colon (:) and at-sign (@)
modifiers, and a single character indicating what kind of directive this is.
The alphabetic case of the directive character is ignored. The prefix
parameters are generally integers, notated as optionally signed decimal
numbers.

X3J13 voted in June 1987 (80) to specify that if both colon and at-sign
modifiers are present, they may appear in either order; thus \~{}:@R
and \~{}@:R mean the same thing. However, it is traditional to put the
colon first, and all examples in the book put colon before at-signs.
\end{quote}

\noindent
On page 588 we find:

\begin{quote}
\~{}F

{\sl Fixed-format floating-point}. The next {\sl arg} is printed as a
floating point number.

The full form is {\sl \~{}w,d,k,overfowchar,padchar}F. The parameter
{\sl w} is the width of the filed to be printed; {\sl d} is the number
of digits to print after the decimal point; {\sl k} is a scale factor
that defaults to zero.

Exactly {\sl w} characters will be output. First, leading copies of the
character {\sl padchar} (which defaults to a space) are printed, if 
necessary, to pad the field on the left. If the {\sl arg} is negative,
then a minus sign is printed; if the {\sl arg} is not negative, then
a plus signed is printed if and only if the @ modifier was specified.
Then a sequence of digits, containing a single embedded decimal point,
is printed; this represents the magnitude of the value of {\sl arg}
times $10^k$, rounded to {\sl d} fractional digits. (When rounding up
and rounding down would produce printed values equidistant from the
scaled value of {\sl arg}, then the implementation is free to use
either one. For example, printing the argument 6.375 using the format
\~{}4.2F may correctly produce either 6.37 or 6.38.) Leading zeros are
not permitted, except that a single zero digit is output before the
decimal point if the printed value is less than 1, and this single zero
digit is not output after all if $w = d + 1$.

If it is impossible to print the value in the required format in the
field of width {\sl w}, then one of two actions is taken. If the
parameter {\sl overflowchar} is specified, then {\sl w} copies of that
parameter are printed instead of the scaled value of {\sl arg}. If the
{\sl overflowchar} parameter is omitted, then the scaled value is
printed using more than {\sl w} characters, as many more as may be
needed.

If the {\sl w} parameter is omitted, then the field is of variable width.
In effect, a value is chosen for {\sl w} in such a way that no leading pad
characters need to be printed and exactly {\sl d} characters will follow
the decimal point. For example, the directive \~{},2F will print exactly
two digits after the decimal point and as many as necessary before the
decimal point.

If the parameter {\sl d} is omitted, then there is no constraint on the 
number of digits to appear after the decimal point. A value is chosen
for {\sl d} in such a way that as many digits as possible may be printed
subject to the width constraint imposed by the parameter {\sl w} and the
constraint that no trailing zero digits may appear in the fraction, except
that if the fraction to be printed is zero, then a single zero digit should
appear after the decimal point if permitted by the width constraint.

If both {\sl w} and {\sl d} are omitted, then the effect is to print the
value using ordinary free-format output; {\tt prin1} uses this format
for any number whose magnitude is either zero or between $10^{-3}$
(inclusive) and $10^7$ (exclusive).

If {\sl w} is omitted, then if the magnitude of {\sl arg} is so large
(or, if {\sl d} is also omitted, so small) that more than 100 digits
would have to be printed, then an implementation is free, at its 
discretion, to print the number using exponential notation instead,
as if by the directive \~{}E (with all parameters of \~{}E defaulted,
not taking their valued from the \~{}F directive).

If {\sl arg} is a rational number, then it is coerced to be a 
{\tt single-float} and then printed. (Alternatively, an implementation
is permitted to process a rational number by any other method that has
essentially the same behavior but avoids such hazards as loss of
precision or overflow because of the coercion. However, note that if
{\sl w} and {\sl d} are unspecified and the number has no exact decimal
representation, for example 1/3, some precision cutoff must be chosen
by the implementation; only a finite number of digits may be printed.)

If {\sl arg} is a complex number or some non-numeric object, then it 
is printed using the format directive {\sl \~{}w}D, thereby printing
it in decimal radix and a minimum field width of {\sl w}. (If it is
desired to print each of the real part and imaginary part of a 
complex number using a \~{}F directive, then this must be done explicitly
with two \~{}F directives and code to extract the two parts of the
complex number.)


\end{quote}
<<domain DFLOAT DoubleFloat>>=
)abbrev domain DFLOAT DoubleFloat
++ Author: Michael Monagan
++ Date Created:
++   January 1988
++ Change History:
++ Basic Operations: exp1, hash, log2, log10, rationalApproximation, / , **
++ Related Constructors:
++ Keywords: small float
++ Description:  \spadtype{DoubleFloat} is intended to make accessible
++ hardware floating point arithmetic in \Language{}, either native double
++ precision, or IEEE. On most machines, there will be hardware support for
++ the arithmetic operations:
++ \spadfunFrom{+}{DoubleFloat}, \spadfunFrom{*}{DoubleFloat},
++ \spadfunFrom{/}{DoubleFloat} and possibly also the
++ \spadfunFrom{sqrt}{DoubleFloat} operation.
++ The operations \spadfunFrom{exp}{DoubleFloat},
++ \spadfunFrom{log}{DoubleFloat}, \spadfunFrom{sin}{DoubleFloat},
++ \spadfunFrom{cos}{DoubleFloat},
++ \spadfunFrom{atan}{DoubleFloat} are normally coded in
++ software based on minimax polynomial/rational approximations.
++ Note that under Lisp/VM, \spadfunFrom{atan}{DoubleFloat}
++ is not available at this time.
++ Some general comments about the accuracy of the operations:
++ the operations \spadfunFrom{+}{DoubleFloat},
++ \spadfunFrom{*}{DoubleFloat}, \spadfunFrom{/}{DoubleFloat} and
++ \spadfunFrom{sqrt}{DoubleFloat} are expected to be fully accurate.
++ The operations \spadfunFrom{exp}{DoubleFloat},
++ \spadfunFrom{log}{DoubleFloat}, \spadfunFrom{sin}{DoubleFloat},
++ \spadfunFrom{cos}{DoubleFloat} and
++ \spadfunFrom{atan}{DoubleFloat} are not expected to be
++ fully accurate.  In particular, \spadfunFrom{sin}{DoubleFloat}
++ and \spadfunFrom{cos}{DoubleFloat}
++ will lose all precision for large arguments.
++
++ The \spadtype{Float} domain provides an alternative to the \spad{DoubleFloat} domain.
++ It provides an arbitrary precision model of floating point arithmetic.
++ This means that accuracy problems like those above are eliminated
++ by increasing the working precision where necessary.  \spadtype{Float}
++ provides some special functions such as \spadfunFrom{erf}{DoubleFloat},
++ the error function
++ in addition to the elementary functions.  The disadvantage of
++ \spadtype{Float} is that it is much more expensive than small floats when the latter can be used.
-- I've put some timing comparisons in the notes for the Float
-- domain about the difference in speed between the two domains.
DoubleFloat(): Join(FloatingPointSystem, DifferentialRing, OpenMath,
   TranscendentalFunctionCategory, ConvertibleTo InputForm) with
      _/   : (%, Integer) -> %
        ++ x / i computes the division from x by an integer i.
      _*_* : (%,%) -> %
        ++ x ** y returns the yth power of x (equal to \spad{exp(y log x)}).
      exp1 : () -> %
        ++ exp1() returns the natural log base \spad{2.718281828...}.
      hash : % -> Integer
        ++ hash(x) returns the hash key for x
      log2 :  % -> %
        ++ log2(x) computes the logarithm with base 2 for x.
      log10: % -> %
        ++ log10(x) computes the logarithm with base 10 for x.
      atan : (%,%) -> %
        ++ atan(x,y) computes the arc tangent from x with phase y.
      Gamma: % -> %
        ++ Gamma(x) is the Euler Gamma function.
      Beta : (%,%) -> %
        ++ Beta(x,y) is \spad{Gamma(x) * Gamma(y)/Gamma(x+y)}.
      doubleFloatFormat : String -> String	
        ++ change the output format for doublefloats using lisp format strings
      rationalApproximation: (%, NonNegativeInteger) -> Fraction Integer
        ++ rationalApproximation(f, n) computes a rational approximation
        ++ r to f with relative error \spad{< 10**(-n)}.
      rationalApproximation: (%, NonNegativeInteger, NonNegativeInteger) -> Fraction Integer
         ++ rationalApproximation(f, n, b) computes a rational
         ++ approximation r to f with relative error \spad{< b**(-n)}
         ++ (that is, \spad{|(r-f)/f| < b**(-n)}).

 == add
   format: String := "~G"
   MER ==> Record(MANTISSA:Integer,EXPONENT:Integer)

   manexp: % -> MER

   doubleFloatFormat(s:String): String ==
     ss: String := format
     format := s
     ss

   OMwrite(x: %): String ==
     s: String := ""
     sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
     dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
     OMputObject(dev)
     OMputFloat(dev, convert x)
     OMputEndObject(dev)
     OMclose(dev)
     s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
     s

   OMwrite(x: %, wholeObj: Boolean): String ==
     s: String := ""
     sp := OM_-STRINGTOSTRINGPTR(s)$Lisp
     dev: OpenMathDevice := OMopenString(sp pretend String, OMencodingXML)
     if wholeObj then
       OMputObject(dev)
     OMputFloat(dev, convert x)
     if wholeObj then
       OMputEndObject(dev)
     OMclose(dev)
     s := OM_-STRINGPTRTOSTRING(sp)$Lisp pretend String
     s

   OMwrite(dev: OpenMathDevice, x: %): Void ==
     OMputObject(dev)
     OMputFloat(dev, convert x)
     OMputEndObject(dev)

   OMwrite(dev: OpenMathDevice, x: %, wholeObj: Boolean): Void ==
     if wholeObj then
       OMputObject(dev)
     OMputFloat(dev, convert x)
     if wholeObj then
       OMputEndObject(dev)

   checkComplex(x:%):% == C_-TO_-R(x)$Lisp
   -- In AKCL we used to have to make the arguments to ASIN ACOS ACOSH ATANH
   -- complex to get the correct behaviour.
   --makeComplex(x: %):% == COMPLEX(x, 0$%)$Lisp

   base()           == FLOAT_-RADIX(0$%)$Lisp
   mantissa x       == manexp(x).MANTISSA
   exponent x       == manexp(x).EXPONENT
   precision()      == FLOAT_-DIGITS(0$%)$Lisp
   bits()           ==
     base() = 2 => precision()
     base() = 16 => 4*precision()
     wholePart(precision()*log2(base()::%))::PositiveInteger
   max()            == MOST_-POSITIVE_-LONG_-FLOAT$Lisp
   min()            == MOST_-NEGATIVE_-LONG_-FLOAT$Lisp
   order(a) == precision() + exponent a - 1
   0                == FLOAT(0$Lisp,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp
   1                == FLOAT(1$Lisp,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp
   -- rational approximation to e accurate to 23 digits
   exp1()           == FLOAT(534625820200,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp / FLOAT(196677847971,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp
   pi()             == PI$Lisp
   coerce(x:%):OutputForm == 
     outputForm(FORMAT(NIL$Lisp,format,x)$Lisp pretend DoubleFloat)
   convert(x:%):InputForm == convert(x pretend DoubleFloat)$InputForm
   x < y            == (x<y)$Lisp
   - x              == (-x)$Lisp
   x + y            == (x+y)$Lisp
   x:% - y:%        == (x-y)$Lisp
   x:% * y:%        == (x*y)$Lisp
   i:Integer * x:%  == (i*x)$Lisp
   max(x,y)         == MAX(x,y)$Lisp
   min(x,y)         == MIN(x,y)$Lisp
   x = y            == (x=y)$Lisp
   x:% / i:Integer  == (x/i)$Lisp
   sqrt x           == checkComplex SQRT(x)$Lisp
   log10 x          == checkComplex log(x)$Lisp
   x:% ** i:Integer == EXPT(x,i)$Lisp
   x:% ** y:%       == checkComplex EXPT(x,y)$Lisp
   coerce(i:Integer):% == FLOAT(i,MOST_-POSITIVE_-LONG_-FLOAT$Lisp)$Lisp
   exp x            == EXP(x)$Lisp
   log x            == checkComplex LN(x)$Lisp
   log2 x           == checkComplex LOG2(x)$Lisp
   sin x            == SIN(x)$Lisp
   cos x            == COS(x)$Lisp
   tan x            == TAN(x)$Lisp
   cot x            == COT(x)$Lisp
   sec x            == SEC(x)$Lisp
   csc x            == CSC(x)$Lisp
   asin x           == checkComplex ASIN(x)$Lisp -- can be complex
   acos x           == checkComplex ACOS(x)$Lisp -- can be complex
   atan x           == ATAN(x)$Lisp
   acsc x           == checkComplex ACSC(x)$Lisp
   acot x           == ACOT(x)$Lisp
   asec x           == checkComplex ASEC(x)$Lisp
   sinh x           == SINH(x)$Lisp
   cosh x           == COSH(x)$Lisp
   tanh x           == TANH(x)$Lisp
   csch x           == CSCH(x)$Lisp
   coth x           == COTH(x)$Lisp
   sech x           == SECH(x)$Lisp
   asinh x          == ASINH(x)$Lisp
   acosh x          == checkComplex ACOSH(x)$Lisp -- can be complex
   atanh x          == checkComplex ATANH(x)$Lisp -- can be complex
   acsch x          == ACSCH(x)$Lisp
   acoth x          == checkComplex ACOTH(x)$Lisp
   asech x          == checkComplex ASECH(x)$Lisp
   x:% / y:%        == (x/y)$Lisp
   negative? x      == MINUSP(x)$Lisp
   zero? x          == ZEROP(x)$Lisp
   hash x           == HASHEQ(x)$Lisp
   recip(x)         == (zero? x => "failed"; 1 / x)
   differentiate x  == 0

   SFSFUN           ==> DoubleFloatSpecialFunctions()
   sfx              ==> x pretend DoubleFloat
   sfy              ==> y pretend DoubleFloat
   Gamma x          == Gamma(sfx)$SFSFUN pretend %
   Beta(x,y)        == Beta(sfx,sfy)$SFSFUN pretend %

   wholePart x            == FIX(x)$Lisp
   float(ma,ex,b)   == ma*(b::%)**ex
   convert(x:%):DoubleFloat == x pretend DoubleFloat
   convert(x:%):Float == convert(x pretend DoubleFloat)$Float
   rationalApproximation(x, d) == rationalApproximation(x, d, 10)

   atan(x,y) ==
      x = 0 =>
         y > 0 => pi()/2
         y < 0 => -pi()/2
         0
      -- Only count on first quadrant being on principal branch.
      theta := atan abs(y/x)
      if x < 0 then theta := pi() - theta
      if y < 0 then theta := - theta
      theta

   retract(x:%):Fraction(Integer) ==
     rationalApproximation(x, (precision() - 1)::NonNegativeInteger, base())

   retractIfCan(x:%):Union(Fraction Integer, "failed") ==
     rationalApproximation(x, (precision() - 1)::NonNegativeInteger, base())

   retract(x:%):Integer ==
     x = ((n := wholePart x)::%) => n
     error "Not an integer"

   retractIfCan(x:%):Union(Integer, "failed") ==
     x = ((n := wholePart x)::%) => n
     "failed"

   sign(x) == retract FLOAT_-SIGN(x,1)$Lisp
   abs x   == FLOAT_-SIGN(1,x)$Lisp


   
   manexp(x) ==
      zero? x => [0,0]
      s := sign x; x := abs x
      if x > max()$% then return [s*mantissa(max())+1,exponent max()]
      me:Record(man:%,exp:Integer) := MANEXP(x)$Lisp 
      two53:= base()**precision()
      [s*wholePart(two53 * me.man ),me.exp-precision()]

-- rationalApproximation(y,d,b) ==
--    this is the quotient remainder algorithm (requires wholePart operation)
--    x := y
--    if b < 2 then error "base must be > 1"
--    tol := (b::%)**d
--    p0,p1,q0,q1 : Integer
--    p0 := 0; p1 := 1; q0 := 1; q1 := 0
--    repeat
--       a := wholePart x
--       x := fractionPart x
--       p2 := p0+a*p1
--       q2 := q0+a*q1
--       if x = 0 or tol*abs(q2*y-(p2::%)) < abs(q2*y) then
--          return (p2/q2)
--       (p0,p1) := (p1,p2)
--       (q0,q1) := (q1,q2)
--       x := 1/x

   rationalApproximation(f,d,b) ==
      -- this algorithm expresses f as n / d where d = BASE ** k
      -- then all arithmetic operations are done over the integers
      (nu, ex) := manexp f
      BASE := base()
      ex >= 0 => (nu * BASE ** (ex::NonNegativeInteger))::Fraction(Integer)
      de :Integer := BASE**((-ex)::NonNegativeInteger)
      b < 2 => error "base must be > 1"
      tol := b**d
      s := nu; t := de
      p0:Integer := 0; p1:Integer := 1; q0:Integer := 1; q1:Integer := 0
      repeat
         (q,r) := divide(s, t)
         p2 := q*p1+p0
         q2 := q*q1+q0
         r = 0 or tol*abs(nu*q2-de*p2) < de*abs(p2) => return(p2/q2)
         (p0,p1) := (p1,p2)
         (q0,q1) := (q1,q2)
         (s,t) := (t,r)

   x:% ** r:Fraction Integer ==
      zero? x =>
         zero? r => error "0**0 is undefined"
         negative? r => error "division by 0"
         0
--      zero? r or one? x => 1
      zero? r or (x = 1) => 1
--      one?  r => x
      (r = 1) => x
      n := numer r
      d := denom r
      negative? x =>
         odd? d =>
            odd? n => return -((-x)**r)
            return ((-x)**r)
         error "negative root"
      d = 2 => sqrt(x) ** n
      x ** (n::% / d::%)

@
\section{DFLOAT.lsp BOOTSTRAP} 
{\bf DFLOAT} depends on itself.
We need to break this cycle to build the algebra. So we keep a
cached copy of the translated {\bf DFLOAT} category which we can write
into the {\bf MID} directory. We compile the lisp code and copy the
{\bf DFLOAT.o} file to the {\bf OUT} directory.  This is eventually
forcibly replaced by a recompiled version.

Note that this code is not included in the generated catdef.spad file.

<<DFLOAT.lsp BOOTSTRAP>>=

(|/VERSIONCHECK| 2) 

(DEFUN |DFLOAT;OMwrite;$S;1| (|x| |$|) (PROG (|sp| |dev| |s|) (RETURN (SEQ (LETT |s| "" |DFLOAT;OMwrite;$S;1|) (LETT |sp| (|OM-STRINGTOSTRINGPTR| |s|) |DFLOAT;OMwrite;$S;1|) (LETT |dev| (SPADCALL |sp| (SPADCALL (QREFELT |$| 7)) (QREFELT |$| 10)) |DFLOAT;OMwrite;$S;1|) (SPADCALL |dev| (QREFELT |$| 12)) (SPADCALL |dev| |x| (QREFELT |$| 14)) (SPADCALL |dev| (QREFELT |$| 15)) (SPADCALL |dev| (QREFELT |$| 16)) (LETT |s| (|OM-STRINGPTRTOSTRING| |sp|) |DFLOAT;OMwrite;$S;1|) (EXIT |s|))))) 

(DEFUN |DFLOAT;OMwrite;$BS;2| (|x| |wholeObj| |$|) (PROG (|sp| |dev| |s|) (RETURN (SEQ (LETT |s| "" |DFLOAT;OMwrite;$BS;2|) (LETT |sp| (|OM-STRINGTOSTRINGPTR| |s|) |DFLOAT;OMwrite;$BS;2|) (LETT |dev| (SPADCALL |sp| (SPADCALL (QREFELT |$| 7)) (QREFELT |$| 10)) |DFLOAT;OMwrite;$BS;2|) (COND (|wholeObj| (SPADCALL |dev| (QREFELT |$| 12)))) (SPADCALL |dev| |x| (QREFELT |$| 14)) (COND (|wholeObj| (SPADCALL |dev| (QREFELT |$| 15)))) (SPADCALL |dev| (QREFELT |$| 16)) (LETT |s| (|OM-STRINGPTRTOSTRING| |sp|) |DFLOAT;OMwrite;$BS;2|) (EXIT |s|))))) 

(DEFUN |DFLOAT;OMwrite;Omd$V;3| (|dev| |x| |$|) (SEQ (SPADCALL |dev| (QREFELT |$| 12)) (SPADCALL |dev| |x| (QREFELT |$| 14)) (EXIT (SPADCALL |dev| (QREFELT |$| 15))))) 

(DEFUN |DFLOAT;OMwrite;Omd$BV;4| (|dev| |x| |wholeObj| |$|) (SEQ (COND (|wholeObj| (SPADCALL |dev| (QREFELT |$| 12)))) (SPADCALL |dev| |x| (QREFELT |$| 14)) (EXIT (COND (|wholeObj| (SPADCALL |dev| (QREFELT |$| 15))))))) 

(PUT (QUOTE |DFLOAT;checkComplex|) (QUOTE |SPADreplace|) (QUOTE |C-TO-R|)) 

(DEFUN |DFLOAT;checkComplex| (|x| |$|) (|C-TO-R| |x|)) 

(PUT (QUOTE |DFLOAT;base;Pi;6|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL (|FLOAT-RADIX| 0.0)))) 

(DEFUN |DFLOAT;base;Pi;6| (|$|) (|FLOAT-RADIX| 0.0)) 

(DEFUN |DFLOAT;mantissa;$I;7| (|x| |$|) (QCAR (|DFLOAT;manexp| |x| |$|))) 

(DEFUN |DFLOAT;exponent;$I;8| (|x| |$|) (QCDR (|DFLOAT;manexp| |x| |$|))) 

(PUT (QUOTE |DFLOAT;precision;Pi;9|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL (|FLOAT-DIGITS| 0.0)))) 

(DEFUN |DFLOAT;precision;Pi;9| (|$|) (|FLOAT-DIGITS| 0.0)) 

(DEFUN |DFLOAT;bits;Pi;10| (|$|) (PROG (#1=#:G105705) (RETURN (COND ((EQL (|FLOAT-RADIX| 0.0) 2) (|FLOAT-DIGITS| 0.0)) ((EQL (|FLOAT-RADIX| 0.0) 16) (|*| 4 (|FLOAT-DIGITS| 0.0))) ((QUOTE T) (PROG1 (LETT #1# (FIX (SPADCALL (|FLOAT-DIGITS| 0.0) (SPADCALL (FLOAT (|FLOAT-RADIX| 0.0) |MOST-POSITIVE-LONG-FLOAT|) (QREFELT |$| 28)) (QREFELT |$| 29))) |DFLOAT;bits;Pi;10|) (|check-subtype| (|>| #1# 0) (QUOTE (|PositiveInteger|)) #1#))))))) 

(PUT (QUOTE |DFLOAT;max;$;11|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL |MOST-POSITIVE-LONG-FLOAT|))) 

(DEFUN |DFLOAT;max;$;11| (|$|) |MOST-POSITIVE-LONG-FLOAT|) 

(PUT (QUOTE |DFLOAT;min;$;12|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL |MOST-NEGATIVE-LONG-FLOAT|))) 

(DEFUN |DFLOAT;min;$;12| (|$|) |MOST-NEGATIVE-LONG-FLOAT|) 

(DEFUN |DFLOAT;order;$I;13| (|a| |$|) (|-| (|+| (|FLOAT-DIGITS| 0.0) (SPADCALL |a| (QREFELT |$| 26))) 1)) 

(PUT (QUOTE |DFLOAT;Zero;$;14|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL (FLOAT 0 |MOST-POSITIVE-LONG-FLOAT|)))) 

(DEFUN |DFLOAT;Zero;$;14| (|$|) (FLOAT 0 |MOST-POSITIVE-LONG-FLOAT|)) 

(PUT (QUOTE |DFLOAT;One;$;15|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL (FLOAT 1 |MOST-POSITIVE-LONG-FLOAT|)))) 

(DEFUN |DFLOAT;One;$;15| (|$|) (FLOAT 1 |MOST-POSITIVE-LONG-FLOAT|)) 

(DEFUN |DFLOAT;exp1;$;16| (|$|) (|/| (FLOAT 534625820200 |MOST-POSITIVE-LONG-FLOAT|) (FLOAT 196677847971 |MOST-POSITIVE-LONG-FLOAT|))) 

(PUT (QUOTE |DFLOAT;pi;$;17|) (QUOTE |SPADreplace|) (QUOTE (XLAM NIL PI))) 

(DEFUN |DFLOAT;pi;$;17| (|$|) PI) 

(DEFUN |DFLOAT;coerce;$Of;18| (|x| |$|) (SPADCALL |x| (QREFELT |$| 39))) 

(DEFUN |DFLOAT;convert;$If;19| (|x| |$|) (SPADCALL |x| (QREFELT |$| 42))) 

(PUT (QUOTE |DFLOAT;<;2$B;20|) (QUOTE |SPADreplace|) (QUOTE |<|)) 

(DEFUN |DFLOAT;<;2$B;20| (|x| |y| |$|) (|<| |x| |y|)) 

(PUT (QUOTE |DFLOAT;-;2$;21|) (QUOTE |SPADreplace|) (QUOTE |-|)) 

(DEFUN |DFLOAT;-;2$;21| (|x| |$|) (|-| |x|)) 

(PUT (QUOTE |DFLOAT;+;3$;22|) (QUOTE |SPADreplace|) (QUOTE |+|)) 

(DEFUN |DFLOAT;+;3$;22| (|x| |y| |$|) (|+| |x| |y|)) 

(PUT (QUOTE |DFLOAT;-;3$;23|) (QUOTE |SPADreplace|) (QUOTE |-|)) 

(DEFUN |DFLOAT;-;3$;23| (|x| |y| |$|) (|-| |x| |y|)) 

(PUT (QUOTE |DFLOAT;*;3$;24|) (QUOTE |SPADreplace|) (QUOTE |*|)) 

(DEFUN |DFLOAT;*;3$;24| (|x| |y| |$|) (|*| |x| |y|)) 

(PUT (QUOTE |DFLOAT;*;I2$;25|) (QUOTE |SPADreplace|) (QUOTE |*|)) 

(DEFUN |DFLOAT;*;I2$;25| (|i| |x| |$|) (|*| |i| |x|)) 

(PUT (QUOTE |DFLOAT;max;3$;26|) (QUOTE |SPADreplace|) (QUOTE MAX)) 

(DEFUN |DFLOAT;max;3$;26| (|x| |y| |$|) (MAX |x| |y|)) 

(PUT (QUOTE |DFLOAT;min;3$;27|) (QUOTE |SPADreplace|) (QUOTE MIN)) 

(DEFUN |DFLOAT;min;3$;27| (|x| |y| |$|) (MIN |x| |y|)) 

(PUT (QUOTE |DFLOAT;=;2$B;28|) (QUOTE |SPADreplace|) (QUOTE |=|)) 

(DEFUN |DFLOAT;=;2$B;28| (|x| |y| |$|) (|=| |x| |y|)) 

(PUT (QUOTE |DFLOAT;/;$I$;29|) (QUOTE |SPADreplace|) (QUOTE |/|)) 

(DEFUN |DFLOAT;/;$I$;29| (|x| |i| |$|) (|/| |x| |i|)) 

(DEFUN |DFLOAT;sqrt;2$;30| (|x| |$|) (|DFLOAT;checkComplex| (SQRT |x|) |$|)) 

(DEFUN |DFLOAT;log10;2$;31| (|x| |$|) (|DFLOAT;checkComplex| (|log| |x|) |$|)) 

(PUT (QUOTE |DFLOAT;**;$I$;32|) (QUOTE |SPADreplace|) (QUOTE EXPT)) 

(DEFUN |DFLOAT;**;$I$;32| (|x| |i| |$|) (EXPT |x| |i|)) 

(DEFUN |DFLOAT;**;3$;33| (|x| |y| |$|) (|DFLOAT;checkComplex| (EXPT |x| |y|) |$|)) 

(PUT (QUOTE |DFLOAT;coerce;I$;34|) (QUOTE |SPADreplace|) (QUOTE (XLAM (|i|) (FLOAT |i| |MOST-POSITIVE-LONG-FLOAT|)))) 

(DEFUN |DFLOAT;coerce;I$;34| (|i| |$|) (FLOAT |i| |MOST-POSITIVE-LONG-FLOAT|)) 

(PUT (QUOTE |DFLOAT;exp;2$;35|) (QUOTE |SPADreplace|) (QUOTE EXP)) 

(DEFUN |DFLOAT;exp;2$;35| (|x| |$|) (EXP |x|)) 

(DEFUN |DFLOAT;log;2$;36| (|x| |$|) (|DFLOAT;checkComplex| (LN |x|) |$|)) 

(DEFUN |DFLOAT;log2;2$;37| (|x| |$|) (|DFLOAT;checkComplex| (LOG2 |x|) |$|)) 

(PUT (QUOTE |DFLOAT;sin;2$;38|) (QUOTE |SPADreplace|) (QUOTE SIN)) 

(DEFUN |DFLOAT;sin;2$;38| (|x| |$|) (SIN |x|)) 

(PUT (QUOTE |DFLOAT;cos;2$;39|) (QUOTE |SPADreplace|) (QUOTE COS)) 

(DEFUN |DFLOAT;cos;2$;39| (|x| |$|) (COS |x|)) 

(PUT (QUOTE |DFLOAT;tan;2$;40|) (QUOTE |SPADreplace|) (QUOTE TAN)) 

(DEFUN |DFLOAT;tan;2$;40| (|x| |$|) (TAN |x|)) 

(PUT (QUOTE |DFLOAT;cot;2$;41|) (QUOTE |SPADreplace|) (QUOTE COT)) 

(DEFUN |DFLOAT;cot;2$;41| (|x| |$|) (COT |x|)) 

(PUT (QUOTE |DFLOAT;sec;2$;42|) (QUOTE |SPADreplace|) (QUOTE SEC)) 

(DEFUN |DFLOAT;sec;2$;42| (|x| |$|) (SEC |x|)) 

(PUT (QUOTE |DFLOAT;csc;2$;43|) (QUOTE |SPADreplace|) (QUOTE CSC)) 

(DEFUN |DFLOAT;csc;2$;43| (|x| |$|) (CSC |x|)) 

(DEFUN |DFLOAT;asin;2$;44| (|x| |$|) (|DFLOAT;checkComplex| (ASIN |x|) |$|)) 

(DEFUN |DFLOAT;acos;2$;45| (|x| |$|) (|DFLOAT;checkComplex| (ACOS |x|) |$|)) 

(PUT (QUOTE |DFLOAT;atan;2$;46|) (QUOTE |SPADreplace|) (QUOTE ATAN)) 

(DEFUN |DFLOAT;atan;2$;46| (|x| |$|) (ATAN |x|)) 

(DEFUN |DFLOAT;acsc;2$;47| (|x| |$|) (|DFLOAT;checkComplex| (ACSC |x|) |$|)) 

(PUT (QUOTE |DFLOAT;acot;2$;48|) (QUOTE |SPADreplace|) (QUOTE ACOT)) 

(DEFUN |DFLOAT;acot;2$;48| (|x| |$|) (ACOT |x|)) 

(DEFUN |DFLOAT;asec;2$;49| (|x| |$|) (|DFLOAT;checkComplex| (ASEC |x|) |$|)) 

(PUT (QUOTE |DFLOAT;sinh;2$;50|) (QUOTE |SPADreplace|) (QUOTE SINH)) 

(DEFUN |DFLOAT;sinh;2$;50| (|x| |$|) (SINH |x|)) 

(PUT (QUOTE |DFLOAT;cosh;2$;51|) (QUOTE |SPADreplace|) (QUOTE COSH)) 

(DEFUN |DFLOAT;cosh;2$;51| (|x| |$|) (COSH |x|)) 

(PUT (QUOTE |DFLOAT;tanh;2$;52|) (QUOTE |SPADreplace|) (QUOTE TANH)) 

(DEFUN |DFLOAT;tanh;2$;52| (|x| |$|) (TANH |x|)) 

(PUT (QUOTE |DFLOAT;csch;2$;53|) (QUOTE |SPADreplace|) (QUOTE CSCH)) 

(DEFUN |DFLOAT;csch;2$;53| (|x| |$|) (CSCH |x|)) 

(PUT (QUOTE |DFLOAT;coth;2$;54|) (QUOTE |SPADreplace|) (QUOTE COTH)) 

(DEFUN |DFLOAT;coth;2$;54| (|x| |$|) (COTH |x|)) 

(PUT (QUOTE |DFLOAT;sech;2$;55|) (QUOTE |SPADreplace|) (QUOTE SECH)) 

(DEFUN |DFLOAT;sech;2$;55| (|x| |$|) (SECH |x|)) 

(PUT (QUOTE |DFLOAT;asinh;2$;56|) (QUOTE |SPADreplace|) (QUOTE ASINH)) 

(DEFUN |DFLOAT;asinh;2$;56| (|x| |$|) (ASINH |x|)) 

(DEFUN |DFLOAT;acosh;2$;57| (|x| |$|) (|DFLOAT;checkComplex| (ACOSH |x|) |$|)) 

(DEFUN |DFLOAT;atanh;2$;58| (|x| |$|) (|DFLOAT;checkComplex| (ATANH |x|) |$|)) 

(PUT (QUOTE |DFLOAT;acsch;2$;59|) (QUOTE |SPADreplace|) (QUOTE ACSCH)) 

(DEFUN |DFLOAT;acsch;2$;59| (|x| |$|) (ACSCH |x|)) 

(DEFUN |DFLOAT;acoth;2$;60| (|x| |$|) (|DFLOAT;checkComplex| (ACOTH |x|) |$|)) 

(DEFUN |DFLOAT;asech;2$;61| (|x| |$|) (|DFLOAT;checkComplex| (ASECH |x|) |$|)) 

(PUT (QUOTE |DFLOAT;/;3$;62|) (QUOTE |SPADreplace|) (QUOTE |/|)) 

(DEFUN |DFLOAT;/;3$;62| (|x| |y| |$|) (|/| |x| |y|)) 

(PUT (QUOTE |DFLOAT;negative?;$B;63|) (QUOTE |SPADreplace|) (QUOTE MINUSP)) 

(DEFUN |DFLOAT;negative?;$B;63| (|x| |$|) (MINUSP |x|)) 

(PUT (QUOTE |DFLOAT;zero?;$B;64|) (QUOTE |SPADreplace|) (QUOTE ZEROP)) 

(DEFUN |DFLOAT;zero?;$B;64| (|x| |$|) (ZEROP |x|)) 

(PUT (QUOTE |DFLOAT;hash;$I;65|) (QUOTE |SPADreplace|) (QUOTE HASHEQ)) 

(DEFUN |DFLOAT;hash;$I;65| (|x| |$|) (HASHEQ |x|)) 

(DEFUN |DFLOAT;recip;$U;66| (|x| |$|) (COND ((ZEROP |x|) (CONS 1 "failed")) ((QUOTE T) (CONS 0 (|/| 1.0 |x|))))) 

(PUT (QUOTE |DFLOAT;differentiate;2$;67|) (QUOTE |SPADreplace|) (QUOTE (XLAM (|x|) 0.0))) 

(DEFUN |DFLOAT;differentiate;2$;67| (|x| |$|) 0.0) 

(DEFUN |DFLOAT;Gamma;2$;68| (|x| |$|) (SPADCALL |x| (QREFELT |$| 93))) 

(DEFUN |DFLOAT;Beta;3$;69| (|x| |y| |$|) (SPADCALL |x| |y| (QREFELT |$| 95))) 

(PUT (QUOTE |DFLOAT;wholePart;$I;70|) (QUOTE |SPADreplace|) (QUOTE FIX)) 

(DEFUN |DFLOAT;wholePart;$I;70| (|x| |$|) (FIX |x|)) 

(DEFUN |DFLOAT;float;2IPi$;71| (|ma| |ex| |b| |$|) (|*| |ma| (EXPT (FLOAT |b| |MOST-POSITIVE-LONG-FLOAT|) |ex|))) 

(PUT (QUOTE |DFLOAT;convert;2$;72|) (QUOTE |SPADreplace|) (QUOTE (XLAM (|x|) |x|))) 

(DEFUN |DFLOAT;convert;2$;72| (|x| |$|) |x|) 

(DEFUN |DFLOAT;convert;$F;73| (|x| |$|) (SPADCALL |x| (QREFELT |$| 101))) 

(DEFUN |DFLOAT;rationalApproximation;$NniF;74| (|x| |d| |$|) (SPADCALL |x| |d| 10 (QREFELT |$| 105))) 

(DEFUN |DFLOAT;atan;3$;75| (|x| |y| |$|) (PROG (|theta|) (RETURN (SEQ (COND ((|=| |x| 0.0) (COND ((|<| 0.0 |y|) (|/| PI 2)) ((|<| |y| 0.0) (|-| (|/| PI 2))) ((QUOTE T) 0.0))) ((QUOTE T) (SEQ (LETT |theta| (ATAN (|FLOAT-SIGN| 1.0 (|/| |y| |x|))) |DFLOAT;atan;3$;75|) (COND ((|<| |x| 0.0) (LETT |theta| (|-| PI |theta|) |DFLOAT;atan;3$;75|))) (COND ((|<| |y| 0.0) (LETT |theta| (|-| |theta|) |DFLOAT;atan;3$;75|))) (EXIT |theta|)))))))) 

(DEFUN |DFLOAT;retract;$F;76| (|x| |$|) (PROG (#1=#:G105780) (RETURN (SPADCALL |x| (PROG1 (LETT #1# (|-| (|FLOAT-DIGITS| 0.0) 1) |DFLOAT;retract;$F;76|) (|check-subtype| (|>=| #1# 0) (QUOTE (|NonNegativeInteger|)) #1#)) (|FLOAT-RADIX| 0.0) (QREFELT |$| 105))))) 

(DEFUN |DFLOAT;retractIfCan;$U;77| (|x| |$|) (PROG (#1=#:G105785) (RETURN (CONS 0 (SPADCALL |x| (PROG1 (LETT #1# (|-| (|FLOAT-DIGITS| 0.0) 1) |DFLOAT;retractIfCan;$U;77|) (|check-subtype| (|>=| #1# 0) (QUOTE (|NonNegativeInteger|)) #1#)) (|FLOAT-RADIX| 0.0) (QREFELT |$| 105)))))) 

(DEFUN |DFLOAT;retract;$I;78| (|x| |$|) (PROG (|n|) (RETURN (SEQ (LETT |n| (FIX |x|) |DFLOAT;retract;$I;78|) (EXIT (COND ((|=| |x| (FLOAT |n| |MOST-POSITIVE-LONG-FLOAT|)) |n|) ((QUOTE T) (|error| "Not an integer")))))))) 

(DEFUN |DFLOAT;retractIfCan;$U;79| (|x| |$|) (PROG (|n|) (RETURN (SEQ (LETT |n| (FIX |x|) |DFLOAT;retractIfCan;$U;79|) (EXIT (COND ((|=| |x| (FLOAT |n| |MOST-POSITIVE-LONG-FLOAT|)) (CONS 0 |n|)) ((QUOTE T) (CONS 1 "failed")))))))) 

(DEFUN |DFLOAT;sign;$I;80| (|x| |$|) (SPADCALL (|FLOAT-SIGN| |x| 1.0) (QREFELT |$| 111))) 

(PUT (QUOTE |DFLOAT;abs;2$;81|) (QUOTE |SPADreplace|) (QUOTE (XLAM (|x|) (|FLOAT-SIGN| 1.0 |x|)))) 

(DEFUN |DFLOAT;abs;2$;81| (|x| |$|) (|FLOAT-SIGN| 1.0 |x|)) 

(DEFUN |DFLOAT;manexp| (|x| |$|) (PROG (|s| #1=#:G105806 |me| |two53|) (RETURN (SEQ (EXIT (COND ((ZEROP |x|) (CONS 0 0)) ((QUOTE T) (SEQ (LETT |s| (SPADCALL |x| (QREFELT |$| 114)) |DFLOAT;manexp|) (LETT |x| (|FLOAT-SIGN| 1.0 |x|) |DFLOAT;manexp|) (COND ((|<| |MOST-POSITIVE-LONG-FLOAT| |x|) (PROGN (LETT #1# (CONS (|+| (|*| |s| (SPADCALL |MOST-POSITIVE-LONG-FLOAT| (QREFELT |$| 25))) 1) (SPADCALL |MOST-POSITIVE-LONG-FLOAT| (QREFELT |$| 26))) |DFLOAT;manexp|) (GO #1#)))) (LETT |me| (MANEXP |x|) |DFLOAT;manexp|) (LETT |two53| (EXPT (|FLOAT-RADIX| 0.0) (|FLOAT-DIGITS| 0.0)) |DFLOAT;manexp|) (EXIT (CONS (|*| |s| (FIX (|*| |two53| (QCAR |me|)))) (|-| (QCDR |me|) (|FLOAT-DIGITS| 0.0)))))))) #1# (EXIT #1#))))) 

(DEFUN |DFLOAT;rationalApproximation;$2NniF;83| (|f| |d| |b| |$|) (PROG (|#G102| |nu| |ex| BASE #1=#:G105809 |de| |tol| |#G103| |q| |r| |p2| |q2| #2=#:G105827 |#G104| |#G105| |p0| |p1| |#G106| |#G107| |q0| |q1| |#G108| |#G109| |s| |t| #3=#:G105825) (RETURN (SEQ (EXIT (SEQ (PROGN (LETT |#G102| (|DFLOAT;manexp| |f| |$|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |nu| (QCAR |#G102|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |ex| (QCDR |#G102|) |DFLOAT;rationalApproximation;$2NniF;83|) |#G102|) (LETT BASE (|FLOAT-RADIX| 0.0) |DFLOAT;rationalApproximation;$2NniF;83|) (EXIT (COND ((|<| |ex| 0) (SEQ (LETT |de| (EXPT BASE (PROG1 (LETT #1# (|-| |ex|) |DFLOAT;rationalApproximation;$2NniF;83|) (|check-subtype| (|>=| #1# 0) (QUOTE (|NonNegativeInteger|)) #1#))) |DFLOAT;rationalApproximation;$2NniF;83|) (EXIT (COND ((|<| |b| 2) (|error| "base must be > 1")) ((QUOTE T) (SEQ (LETT |tol| (EXPT |b| |d|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |s| |nu| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |t| |de| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |p0| 0 |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |p1| 1 |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q0| 1 |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q1| 0 |DFLOAT;rationalApproximation;$2NniF;83|) (EXIT (SEQ G190 NIL (SEQ (PROGN (LETT |#G103| (DIVIDE2 |s| |t|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q| (QCAR |#G103|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |r| (QCDR |#G103|) |DFLOAT;rationalApproximation;$2NniF;83|) |#G103|) (LETT |p2| (|+| (|*| |q| |p1|) |p0|) |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q2| (|+| (|*| |q| |q1|) |q0|) |DFLOAT;rationalApproximation;$2NniF;83|) (COND ((OR (EQL |r| 0) (|<| (SPADCALL |tol| (ABS (|-| (|*| |nu| |q2|) (|*| |de| |p2|))) (QREFELT |$| 118)) (|*| |de| (ABS |p2|)))) (EXIT (PROGN (LETT #2# (SPADCALL |p2| |q2| (QREFELT |$| 117)) |DFLOAT;rationalApproximation;$2NniF;83|) (GO #2#))))) (PROGN (LETT |#G104| |p1| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |#G105| |p2| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |p0| |#G104| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |p1| |#G105| |DFLOAT;rationalApproximation;$2NniF;83|)) (PROGN (LETT |#G106| |q1| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |#G107| |q2| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q0| |#G106| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |q1| |#G107| |DFLOAT;rationalApproximation;$2NniF;83|)) (EXIT (PROGN (LETT |#G108| |t| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |#G109| |r| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |s| |#G108| |DFLOAT;rationalApproximation;$2NniF;83|) (LETT |t| |#G109| |DFLOAT;rationalApproximation;$2NniF;83|)))) NIL (GO G190) G191 (EXIT NIL))))))))) ((QUOTE T) (SPADCALL (|*| |nu| (EXPT BASE (PROG1 (LETT #3# |ex| |DFLOAT;rationalApproximation;$2NniF;83|) (|check-subtype| (|>=| #3# 0) (QUOTE (|NonNegativeInteger|)) #3#)))) (QREFELT |$| 119))))))) #2# (EXIT #2#))))) 

(DEFUN |DFLOAT;**;$F$;84| (|x| |r| |$|) (PROG (|n| |d| #1=#:G105837) (RETURN (SEQ (EXIT (COND ((ZEROP |x|) (COND ((SPADCALL |r| (QREFELT |$| 120)) (|error| "0**0 is undefined")) ((SPADCALL |r| (QREFELT |$| 121)) (|error| "division by 0")) ((QUOTE T) 0.0))) ((OR (SPADCALL |r| (QREFELT |$| 120)) (SPADCALL |x| (QREFELT |$| 122))) 1.0) ((QUOTE T) (COND ((SPADCALL |r| (QREFELT |$| 123)) |x|) ((QUOTE T) (SEQ (LETT |n| (SPADCALL |r| (QREFELT |$| 124)) |DFLOAT;**;$F$;84|) (LETT |d| (SPADCALL |r| (QREFELT |$| 125)) |DFLOAT;**;$F$;84|) (EXIT (COND ((MINUSP |x|) (COND ((ODDP |d|) (COND ((ODDP |n|) (PROGN (LETT #1# (|-| (SPADCALL (|-| |x|) |r| (QREFELT |$| 126))) |DFLOAT;**;$F$;84|) (GO #1#))) ((QUOTE T) (PROGN (LETT #1# (SPADCALL (|-| |x|) |r| (QREFELT |$| 126)) |DFLOAT;**;$F$;84|) (GO #1#))))) ((QUOTE T) (|error| "negative root")))) ((EQL |d| 2) (EXPT (SPADCALL |x| (QREFELT |$| 54)) |n|)) ((QUOTE T) (SPADCALL |x| (|/| (FLOAT |n| |MOST-POSITIVE-LONG-FLOAT|) (FLOAT |d| |MOST-POSITIVE-LONG-FLOAT|)) (QREFELT |$| 57))))))))))) #1# (EXIT #1#))))) 

(DEFUN |DoubleFloat| NIL (PROG NIL (RETURN (PROG (#1=#:G105850) (RETURN (COND ((LETT #1# (HGET |$ConstructorCache| (QUOTE |DoubleFloat|)) |DoubleFloat|) (|CDRwithIncrement| (CDAR #1#))) ((QUOTE T) (|UNWIND-PROTECT| (PROG1 (CDDAR (HPUT |$ConstructorCache| (QUOTE |DoubleFloat|) (LIST (CONS NIL (CONS 1 (|DoubleFloat;|)))))) (LETT #1# T |DoubleFloat|)) (COND ((NOT #1#) (HREM |$ConstructorCache| (QUOTE |DoubleFloat|)))))))))))) 

(DEFUN |DoubleFloat;| NIL (PROG (|dv$| |$| |pv$|) (RETURN (PROGN (LETT |dv$| (QUOTE (|DoubleFloat|)) . #1=(|DoubleFloat|)) (LETT |$| (GETREFV 140) . #1#) (QSETREFV |$| 0 |dv$|) (QSETREFV |$| 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#)) (|haddProp| |$ConstructorCache| (QUOTE |DoubleFloat|) NIL (CONS 1 |$|)) (|stuffDomainSlots| |$|) |$|)))) 

(MAKEPROP (QUOTE |DoubleFloat|) (QUOTE |infovec|) (LIST (QUOTE #(NIL NIL NIL NIL NIL NIL (|OpenMathEncoding|) (0 . |OMencodingXML|) (|String|) (|OpenMathDevice|) (4 . |OMopenString|) (|Void|) (10 . |OMputObject|) (|DoubleFloat|) (15 . |OMputFloat|) (21 . |OMputEndObject|) (26 . |OMclose|) |DFLOAT;OMwrite;$S;1| (|Boolean|) |DFLOAT;OMwrite;$BS;2| |DFLOAT;OMwrite;Omd$V;3| |DFLOAT;OMwrite;Omd$BV;4| (|PositiveInteger|) |DFLOAT;base;Pi;6| (|Integer|) |DFLOAT;mantissa;$I;7| |DFLOAT;exponent;$I;8| |DFLOAT;precision;Pi;9| |DFLOAT;log2;2$;37| (31 . |*|) |DFLOAT;bits;Pi;10| |DFLOAT;max;$;11| |DFLOAT;min;$;12| |DFLOAT;order;$I;13| (CONS IDENTITY (FUNCALL (|dispatchFunction| |DFLOAT;Zero;$;14|) |$|)) (CONS IDENTITY (FUNCALL (|dispatchFunction| |DFLOAT;One;$;15|) |$|)) |DFLOAT;exp1;$;16| |DFLOAT;pi;$;17| (|OutputForm|) (37 . |outputForm|) |DFLOAT;coerce;$Of;18| (|InputForm|) (42 . |convert|) |DFLOAT;convert;$If;19| |DFLOAT;<;2$B;20| |DFLOAT;-;2$;21| |DFLOAT;+;3$;22| |DFLOAT;-;3$;23| |DFLOAT;*;3$;24| |DFLOAT;*;I2$;25| |DFLOAT;max;3$;26| |DFLOAT;min;3$;27| |DFLOAT;=;2$B;28| |DFLOAT;/;$I$;29| |DFLOAT;sqrt;2$;30| |DFLOAT;log10;2$;31| |DFLOAT;**;$I$;32| |DFLOAT;**;3$;33| |DFLOAT;coerce;I$;34| |DFLOAT;exp;2$;35| |DFLOAT;log;2$;36| |DFLOAT;sin;2$;38| |DFLOAT;cos;2$;39| |DFLOAT;tan;2$;40| |DFLOAT;cot;2$;41| |DFLOAT;sec;2$;42| |DFLOAT;csc;2$;43| |DFLOAT;asin;2$;44| |DFLOAT;acos;2$;45| |DFLOAT;atan;2$;46| |DFLOAT;acsc;2$;47| |DFLOAT;acot;2$;48| |DFLOAT;asec;2$;49| |DFLOAT;sinh;2$;50| |DFLOAT;cosh;2$;51| |DFLOAT;tanh;2$;52| |DFLOAT;csch;2$;53| |DFLOAT;coth;2$;54| |DFLOAT;sech;2$;55| |DFLOAT;asinh;2$;56| |DFLOAT;acosh;2$;57| |DFLOAT;atanh;2$;58| |DFLOAT;acsch;2$;59| |DFLOAT;acoth;2$;60| |DFLOAT;asech;2$;61| |DFLOAT;/;3$;62| |DFLOAT;negative?;$B;63| |DFLOAT;zero?;$B;64| |DFLOAT;hash;$I;65| (|Union| |$| (QUOTE "failed")) |DFLOAT;recip;$U;66| |DFLOAT;differentiate;2$;67| (|DoubleFloatSpecialFunctions|) (47 . |Gamma|) |DFLOAT;Gamma;2$;68| (52 . |Beta|) |DFLOAT;Beta;3$;69| |DFLOAT;wholePart;$I;70| |DFLOAT;float;2IPi$;71| |DFLOAT;convert;2$;72| (|Float|) (58 . |convert|) |DFLOAT;convert;$F;73| (|Fraction| 24) (|NonNegativeInteger|) |DFLOAT;rationalApproximation;$2NniF;83| |DFLOAT;rationalApproximation;$NniF;74| |DFLOAT;atan;3$;75| |DFLOAT;retract;$F;76| (|Union| 103 (QUOTE "failed")) |DFLOAT;retractIfCan;$U;77| |DFLOAT;retract;$I;78| (|Union| 24 (QUOTE "failed")) |DFLOAT;retractIfCan;$U;79| |DFLOAT;sign;$I;80| |DFLOAT;abs;2$;81| (63 . |Zero|) (67 . |/|) (73 . |*|) (79 . |coerce|) (84 . |zero?|) (89 . |negative?|) (94 . |one?|) (99 . |one?|) (104 . |numer|) (109 . |denom|) |DFLOAT;**;$F$;84| (|Pattern| 100) (|PatternMatchResult| 100 |$|) (|Factored| |$|) (|Union| 131 (QUOTE "failed")) (|List| |$|) (|Record| (|:| |coef1| |$|) (|:| |coef2| |$|) (|:| |generator| |$|)) (|Record| (|:| |coef1| |$|) (|:| |coef2| |$|)) (|Union| 133 (QUOTE "failed")) (|Record| (|:| |quotient| |$|) (|:| |remainder| |$|)) (|Record| (|:| |coef| 131) (|:| |generator| |$|)) (|SparseUnivariatePolynomial| |$|) (|Record| (|:| |unit| |$|) (|:| |canonical| |$|) (|:| |associate| |$|)) (|SingleInteger|))) (QUOTE #(|~=| 114 |zero?| 120 |wholePart| 125 |unitNormal| 130 |unitCanonical| 135 |unit?| 140 |truncate| 145 |tanh| 150 |tan| 155 |subtractIfCan| 160 |squareFreePart| 166 |squareFree| 171 |sqrt| 176 |sizeLess?| 181 |sinh| 187 |sin| 192 |sign| 197 |sech| 202 |sec| 207 |sample| 212 |round| 216 |retractIfCan| 221 |retract| 231 |rem| 241 |recip| 247 |rationalApproximation| 252 |quo| 265 |principalIdeal| 271 |prime?| 276 |precision| 281 |positive?| 285 |pi| 290 |patternMatch| 294 |order| 301 |one?| 306 |nthRoot| 311 |norm| 317 |negative?| 322 |multiEuclidean| 327 |min| 333 |max| 343 |mantissa| 353 |log2| 358 |log10| 363 |log| 368 |lcm| 373 |latex| 384 |inv| 389 |hash| 394 |gcdPolynomial| 404 |gcd| 410 |fractionPart| 421 |floor| 426 |float| 431 |factor| 444 |extendedEuclidean| 449 |exquo| 462 |expressIdealMember| 468 |exponent| 474 |exp1| 479 |exp| 483 |euclideanSize| 488 |divide| 493 |digits| 499 |differentiate| 503 |csch| 514 |csc| 519 |coth| 524 |cot| 529 |cosh| 534 |cos| 539 |convert| 544 |coerce| 564 |characteristic| 594 |ceiling| 598 |bits| 603 |base| 607 |atanh| 611 |atan| 616 |associates?| 627 |asinh| 633 |asin| 638 |asech| 643 |asec| 648 |acsch| 653 |acsc| 658 |acoth| 663 |acot| 668 |acosh| 673 |acos| 678 |abs| 683 |^| 688 |Zero| 706 |One| 710 |OMwrite| 714 |Gamma| 738 D 743 |Beta| 754 |>=| 760 |>| 766 |=| 772 |<=| 778 |<| 784 |/| 790 |-| 802 |+| 813 |**| 819 |*| 849)) (QUOTE ((|approximate| . 0) (|canonicalsClosed| . 0) (|canonicalUnitNormal| . 0) (|noZeroDivisors| . 0) ((|commutative| "*") . 0) (|rightUnitary| . 0) (|leftUnitary| . 0) (|unitsKnown| . 0))) (CONS (|makeByteWordVec2| 1 (QUOTE (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))) (CONS (QUOTE #(|FloatingPointSystem&| |RealNumberSystem&| |Field&| |EuclideanDomain&| NIL |UniqueFactorizationDomain&| |GcdDomain&| |DivisionRing&| |IntegralDomain&| |Algebra&| |Algebra&| |DifferentialRing&| NIL |OrderedRing&| |Module&| NIL NIL |Module&| NIL NIL NIL |Ring&| NIL NIL NIL NIL NIL NIL NIL |AbelianGroup&| NIL NIL |AbelianMonoid&| |Monoid&| NIL |OrderedSet&| |AbelianSemiGroup&| |SemiGroup&| |TranscendentalFunctionCategory&| NIL |SetCategory&| NIL |ElementaryFunctionCategory&| NIL |HyperbolicFunctionCategory&| |ArcTrigonometricFunctionCategory&| |TrigonometricFunctionCategory&| NIL NIL |RadicalCategory&| |RetractableTo&| |RetractableTo&| NIL NIL |BasicType&| NIL)) (CONS (QUOTE #((|FloatingPointSystem|) (|RealNumberSystem|) (|Field|) (|EuclideanDomain|) (|PrincipalIdealDomain|) (|UniqueFactorizationDomain|) (|GcdDomain|) (|DivisionRing|) (|IntegralDomain|) (|Algebra| 103) (|Algebra| |$$|) (|DifferentialRing|) (|CharacteristicZero|) (|OrderedRing|) (|Module| 103) (|EntireRing|) (|CommutativeRing|) (|Module| |$$|) (|OrderedAbelianGroup|) (|BiModule| 103 103) (|BiModule| |$$| |$$|) (|Ring|) (|OrderedCancellationAbelianMonoid|) (|RightModule| 103) (|LeftModule| 103) (|LeftModule| |$$|) (|Rng|) (|RightModule| |$$|) (|OrderedAbelianMonoid|) (|AbelianGroup|) (|OrderedAbelianSemiGroup|) (|CancellationAbelianMonoid|) (|AbelianMonoid|) (|Monoid|) (|PatternMatchable| 100) (|OrderedSet|) (|AbelianSemiGroup|) (|SemiGroup|) (|TranscendentalFunctionCategory|) (|RealConstant|) (|SetCategory|) (|ConvertibleTo| 41) (|ElementaryFunctionCategory|) (|ArcHyperbolicFunctionCategory|) (|HyperbolicFunctionCategory|) (|ArcTrigonometricFunctionCategory|) (|TrigonometricFunctionCategory|) (|OpenMath|) (|ConvertibleTo| 127) (|RadicalCategory|) (|RetractableTo| 103) (|RetractableTo| 24) (|ConvertibleTo| 100) (|ConvertibleTo| 13) (|BasicType|) (|CoercibleTo| 38))) (|makeByteWordVec2| 139 (QUOTE (0 6 0 7 2 9 0 8 6 10 1 9 11 0 12 2 9 11 0 13 14 1 9 11 0 15 1 9 11 0 16 2 0 0 22 0 29 1 38 0 13 39 1 41 0 13 42 1 92 13 13 93 2 92 13 13 13 95 1 100 0 13 101 0 103 0 116 2 103 0 24 24 117 2 24 0 104 0 118 1 103 0 24 119 1 103 18 0 120 1 103 18 0 121 1 0 18 0 122 1 103 18 0 123 1 103 24 0 124 1 103 24 0 125 2 0 18 0 0 1 1 0 18 0 87 1 0 24 0 97 1 0 138 0 1 1 0 0 0 1 1 0 18 0 1 1 0 0 0 1 1 0 0 0 75 1 0 0 0 63 2 0 89 0 0 1 1 0 0 0 1 1 0 129 0 1 1 0 0 0 54 2 0 18 0 0 1 1 0 0 0 73 1 0 0 0 61 1 0 24 0 114 1 0 0 0 78 1 0 0 0 65 0 0 0 1 1 0 0 0 1 1 0 109 0 110 1 0 112 0 113 1 0 103 0 108 1 0 24 0 111 2 0 0 0 0 1 1 0 89 0 90 2 0 103 0 104 106 3 0 103 0 104 104 105 2 0 0 0 0 1 1 0 136 131 1 1 0 18 0 1 0 0 22 27 1 0 18 0 1 0 0 0 37 3 0 128 0 127 128 1 1 0 24 0 33 1 0 18 0 122 2 0 0 0 24 1 1 0 0 0 1 1 0 18 0 86 2 0 130 131 0 1 0 0 0 32 2 0 0 0 0 51 0 0 0 31 2 0 0 0 0 50 1 0 24 0 25 1 0 0 0 28 1 0 0 0 55 1 0 0 0 60 1 0 0 131 1 2 0 0 0 0 1 1 0 8 0 1 1 0 0 0 1 1 0 24 0 88 1 0 139 0 1 2 0 137 137 137 1 1 0 0 131 1 2 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 3 0 0 24 24 22 98 2 0 0 24 24 1 1 0 129 0 1 2 0 132 0 0 1 3 0 134 0 0 0 1 2 0 89 0 0 1 2 0 130 131 0 1 1 0 24 0 26 0 0 0 36 1 0 0 0 59 1 0 104 0 1 2 0 135 0 0 1 0 0 22 1 1 0 0 0 91 2 0 0 0 104 1 1 0 0 0 76 1 0 0 0 66 1 0 0 0 77 1 0 0 0 64 1 0 0 0 74 1 0 0 0 62 1 0 41 0 43 1 0 127 0 1 1 0 13 0 99 1 0 100 0 102 1 0 0 103 1 1 0 0 24 58 1 0 0 103 1 1 0 0 24 58 1 0 0 0 1 1 0 38 0 40 0 0 104 1 1 0 0 0 1 0 0 22 30 0 0 22 23 1 0 0 0 81 2 0 0 0 0 107 1 0 0 0 69 2 0 18 0 0 1 1 0 0 0 79 1 0 0 0 67 1 0 0 0 84 1 0 0 0 72 1 0 0 0 82 1 0 0 0 70 1 0 0 0 83 1 0 0 0 71 1 0 0 0 80 1 0 0 0 68 1 0 0 0 115 2 0 0 0 24 1 2 0 0 0 104 1 2 0 0 0 22 1 0 0 0 34 0 0 0 35 2 0 11 9 0 20 3 0 11 9 0 18 21 1 0 8 0 17 2 0 8 0 18 19 1 0 0 0 94 1 0 0 0 1 2 0 0 0 104 1 2 0 0 0 0 96 2 0 18 0 0 1 2 0 18 0 0 1 2 0 18 0 0 52 2 0 18 0 0 1 2 0 18 0 0 44 2 0 0 0 24 53 2 0 0 0 0 85 2 0 0 0 0 47 1 0 0 0 45 2 0 0 0 0 46 2 0 0 0 0 57 2 0 0 0 103 126 2 0 0 0 24 56 2 0 0 0 104 1 2 0 0 0 22 1 2 0 0 0 103 1 2 0 0 103 0 1 2 0 0 0 0 48 2 0 0 24 0 49 2 0 0 104 0 1 2 0 0 22 0 29)))))) (QUOTE |lookupComplete|))) 

(MAKEPROP (QUOTE |DoubleFloat|) (QUOTE NILADIC) T) 
@
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
--    - Redistributions of source code must retain the above copyright
--      notice, this list of conditions and the following disclaimer.
--
--    - Redistributions in binary form must reproduce the above copyright
--      notice, this list of conditions and the following disclaimer in
--      the documentation and/or other materials provided with the
--      distribution.
--
--    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
--      names of its contributors may be used to endorse or promote products
--      derived from this software without specific prior written permission.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@
<<*>>=
<<license>>

<<category REAL RealConstant>>
<<category RADCAT RadicalCategory>>
<<category RNS RealNumberSystem>>
<<category FPS FloatingPointSystem>>
<<domain DFLOAT DoubleFloat>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} Steele, Guy L. Jr. ``Common Lisp The Language''
Second Edition 1990 ISBN 1-55558-041-6 Digital Press
\end{thebibliography}
\end{document}