
(/VERSIONCHECK 2) 

(DEFUN |FSFUN;bernoulli_gamma_series| (|z| |n| $)
  (PROG (|s| |bk| |kinv| |zk| |k| |z2inv| |zinv|)
    (RETURN
     (SEQ
      (LETT |zinv| (SPADCALL (|spadConstant| $ 7) |z| (QREFELT $ 8))
            . #1=(|FSFUN;bernoulli_gamma_series|))
      (LETT |zk| |zinv| . #1#)
      (LETT |z2inv| (SPADCALL |zinv| |zinv| (QREFELT $ 9)) . #1#)
      (LETT |s|
            (SPADCALL |zk|
                      (SPADCALL
                       (SPADCALL (|spadConstant| $ 11) 12 (QREFELT $ 13))
                       (QREFELT $ 14))
                      (QREFELT $ 9))
            . #1#)
      (SEQ (LETT |k| 1 . #1#) G190 (COND ((QSGREATERP |k| |n|) (GO G191)))
           (SEQ (LETT |zk| (SPADCALL |zk| |z2inv| (QREFELT $ 9)) . #1#)
                (LETT |kinv|
                      (SPADCALL (|spadConstant| $ 11)
                                (SPADCALL
                                 (* (+ (SPADCALL 2 |k| (QREFELT $ 17)) 2)
                                    (+ (SPADCALL 2 |k| (QREFELT $ 17)) 1))
                                 (QREFELT $ 18))
                                (QREFELT $ 19))
                      . #1#)
                (LETT |bk|
                      (SPADCALL
                       (SPADCALL (+ (SPADCALL 2 |k| (QREFELT $ 17)) 2)
                                 (QREFELT $ 22))
                       (QREFELT $ 23))
                      . #1#)
                (EXIT
                 (LETT |s|
                       (SPADCALL |s|
                                 (SPADCALL
                                  (SPADCALL
                                   (SPADCALL |bk| |kinv| (QREFELT $ 24))
                                   (QREFELT $ 14))
                                  |zk| (QREFELT $ 9))
                                 (QREFELT $ 25))
                       . #1#)))
           (LETT |k| (QSADD1 |k|) . #1#) (GO G190) G191 (EXIT NIL))
      (EXIT |s|))))) 

(DEFUN |FSFUN;logGamma_a1| (|z| $)
  (SPADCALL
   (SPADCALL
    (SPADCALL
     (SPADCALL |z|
               (SPADCALL (SPADCALL (|spadConstant| $ 11) 2 (QREFELT $ 13))
                         (QREFELT $ 14))
               (QREFELT $ 26))
     (SPADCALL |z| (QREFELT $ 27)) (QREFELT $ 9))
    |z| (QREFELT $ 26))
   (SPADCALL
    (SPADCALL (SPADCALL (|spadConstant| $ 11) 2 (QREFELT $ 13)) (QREFELT $ 14))
    (SPADCALL
     (SPADCALL (SPADCALL 2 (QREFELT $ 18)) (SPADCALL (QREFELT $ 28))
               (QREFELT $ 29))
     (QREFELT $ 27))
    (QREFELT $ 9))
   (QREFELT $ 25))) 

(DEFUN |FSFUN;logGamma_asymptotic| (|z| |n| $)
  (PROG (|lg1|)
    (RETURN
     (SEQ (LETT |lg1| (|FSFUN;logGamma_a1| |z| $) |FSFUN;logGamma_asymptotic|)
          (EXIT
           (SPADCALL |lg1| (|FSFUN;bernoulli_gamma_series| |z| |n| $)
                     (QREFELT $ 25))))))) 

(DEFUN |FSFUN;gamma_series| (|z| |l| |n| $)
  (PROG (|s| |tk| |k|)
    (RETURN
     (SEQ
      (LETT |tk|
            (SPADCALL
             (SPADCALL
              (SPADCALL |z|
                        (SPADCALL (SPADCALL |l| (QREFELT $ 30)) (QREFELT $ 14))
                        (QREFELT $ 9))
              (QREFELT $ 31))
             |z| (QREFELT $ 8))
            . #1=(|FSFUN;gamma_series|))
      (LETT |s| |tk| . #1#)
      (SEQ (LETT |k| 1 . #1#) G190 (COND ((QSGREATERP |k| |n|) (GO G191)))
           (SEQ
            (LETT |tk|
                  (SPADCALL
                   (SPADCALL |tk| (SPADCALL |l| (QREFELT $ 14)) (QREFELT $ 9))
                   (SPADCALL |z| (SPADCALL |k| (QREFELT $ 32)) (QREFELT $ 25))
                   (QREFELT $ 8))
                  . #1#)
            (EXIT (LETT |s| (SPADCALL |s| |tk| (QREFELT $ 25)) . #1#)))
           (LETT |k| (QSADD1 |k|) . #1#) (GO G190) G191 (EXIT NIL))
      (EXIT
       (SPADCALL |s|
                 (SPADCALL
                  (SPADCALL (SPADCALL |l| (QREFELT $ 33)) (QREFELT $ 34))
                  (QREFELT $ 14))
                 (QREFELT $ 9))))))) 

(DEFUN |FSFUN;Gamma;2C;5| (|z| $)
  (PROG (|result| |l1| #1=#:G1826 |llog| #2=#:G1823 #3=#:G1821 |len| |loss|
         |lz| #4=#:G1820 |oz| #5=#:G1819 |abs_z| |one| |c_pi| |re_z| |l| |l0|)
    (RETURN
     (SEQ
      (COND
       ((EQL (SPADCALL (QREFELT $ 35)) 2)
        (SEQ (LETT |l0| (SPADCALL (QREFELT $ 36)) . #6=(|FSFUN;Gamma;2C;5|))
             (LETT |l| (MAX (+ |l0| 5) 20) . #6#)
             (LETT |re_z| (SPADCALL |z| (QREFELT $ 37)) . #6#)
             (EXIT
              (COND
               ((SPADCALL |re_z|
                          (SPADCALL (|spadConstant| $ 11) 2 (QREFELT $ 13))
                          (QREFELT $ 39))
                (COND
                 ((SPADCALL |re_z| (QREFELT $ 41)) (|error| "Pole of Gamma"))
                 (#7='T
                  (SEQ (SPADCALL (+ |l| 5) (QREFELT $ 42))
                       (LETT |c_pi| (SPADCALL (QREFELT $ 28)) . #6#)
                       (LETT |one| (|spadConstant| $ 7) . #6#)
                       (LETT |result|
                             (SPADCALL |c_pi|
                                       (SPADCALL
                                        (SPADCALL
                                         (SPADCALL |one| |z| (QREFELT $ 26))
                                         (QREFELT $ 43))
                                        (SPADCALL
                                         (SPADCALL |c_pi| |z| (QREFELT $ 9))
                                         (QREFELT $ 44))
                                        (QREFELT $ 9))
                                       (QREFELT $ 8))
                             . #6#)
                       (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))))
               (#7#
                (SEQ
                 (LETT |abs_z|
                       (SPADCALL (SPADCALL |z| (QREFELT $ 45)) (QREFELT $ 37))
                       . #6#)
                 (EXIT
                  (COND
                   ((SPADCALL (SPADCALL 6 |abs_z| (QREFELT $ 46))
                              (SPADCALL |l| (QREFELT $ 18)) (QREFELT $ 39))
                    (SEQ
                     (LETT |oz|
                           (PROG1
                               (LETT #5#
                                     (MAX (SPADCALL |abs_z| (QREFELT $ 48)) 5)
                                     . #6#)
                             (|check-subtype| (> #5# 0) '(|PositiveInteger|)
                                              #5#))
                           . #6#)
                     (LETT |lz|
                           (PROG1 (LETT #4# (INTEGER-LENGTH |oz|) . #6#)
                             (|check-subtype| (> #4# 0) '(|PositiveInteger|)
                                              #4#))
                           . #6#)
                     (SPADCALL (+ (+ |oz| |lz|) 30) (QREFELT $ 42))
                     (LETT |loss|
                           (SPADCALL
                            (SPADCALL
                             (|FSFUN;logGamma_a1|
                              (SPADCALL (SPADCALL |z| (QREFELT $ 37))
                                        (QREFELT $ 14))
                              $)
                             (QREFELT $ 37))
                            (SPADCALL (|FSFUN;logGamma_a1| |z| $)
                                      (QREFELT $ 37))
                            (QREFELT $ 49))
                           . #6#)
                     (LETT |len|
                           (SPADCALL
                            (SPADCALL
                             (SPADCALL 2 (SPADCALL |z| (QREFELT $ 37))
                                       (QREFELT $ 46))
                             (SPADCALL 2
                                       (SPADCALL |loss|
                                                 (SPADCALL
                                                  (SPADCALL (QREFELT $ 50))
                                                  (SPADCALL |l| (QREFELT $ 18))
                                                  (QREFELT $ 24))
                                                 (QREFELT $ 51))
                                       (QREFELT $ 46))
                             (QREFELT $ 51))
                            (SPADCALL 3 (QREFELT $ 18)) (QREFELT $ 51))
                           . #6#)
                     (LETT |l1|
                           (PROG1
                               (LETT #3#
                                     (+
                                      (+
                                       (+ |l| (SPADCALL |len| (QREFELT $ 48)))
                                       (SPADCALL
                                        (SPADCALL |loss|
                                                  (SPADCALL (QREFELT $ 50))
                                                  (QREFELT $ 24))
                                        (QREFELT $ 52)))
                                      12)
                                     . #6#)
                             (|check-subtype| (> #3# 0) '(|PositiveInteger|)
                                              #3#))
                           . #6#)
                     (SPADCALL |l1| (QREFELT $ 42))
                     (LETT |result|
                           (|FSFUN;gamma_series| |z| |len|
                            (+
                             (SPADCALL 4 (SPADCALL |len| (QREFELT $ 52))
                                       (QREFELT $ 53))
                             6)
                            $)
                           . #6#)
                     (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))
                   (#7#
                    (SEQ
                     (LETT |llog|
                           (PROG1
                               (LETT #2#
                                     (MAX
                                      (SPADCALL
                                       (SPADCALL
                                        (SPADCALL (|FSFUN;logGamma_a1| |z| $)
                                                  (QREFELT $ 45))
                                        (QREFELT $ 37))
                                       (QREFELT $ 48))
                                      5)
                                     . #6#)
                             (|check-subtype| (> #2# 0) '(|PositiveInteger|)
                                              #2#))
                           . #6#)
                     (LETT |l1|
                           (+
                            (+ (+ |l| |llog|)
                               (PROG1 (LETT #1# (INTEGER-LENGTH |l|) . #6#)
                                 (|check-subtype| (> #1# 0)
                                                  '(|PositiveInteger|) #1#)))
                            7)
                           . #6#)
                     (SPADCALL |l1| (QREFELT $ 42))
                     (LETT |result|
                           (SPADCALL
                            (|FSFUN;logGamma_asymptotic| |z|
                             (+ (QUOTIENT2 |l| 6) 1) $)
                            (QREFELT $ 31))
                           . #6#)
                     (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))))))))))
       (#7# (|error| "Gamma can only handle base 2 Float-s"))))))) 

(DEFUN |FSFUN;logGamma_lift| (|z| |lg2| $)
  (PROG (|k| |lg2i|)
    (RETURN
     (SEQ
      (LETT |lg2i| (SPADCALL |lg2| (QREFELT $ 54))
            . #1=(|FSFUN;logGamma_lift|))
      (LETT |k|
            (SPADCALL
             (SPADCALL
              (SPADCALL (SPADCALL (|FSFUN;logGamma_a1| |z| $) (QREFELT $ 54))
                        |lg2i| (QREFELT $ 49))
              (SPADCALL 2 (SPADCALL (QREFELT $ 55)) (QREFELT $ 46))
              (QREFELT $ 19))
             (QREFELT $ 56))
            . #1#)
      (EXIT
       (SPADCALL |lg2|
                 (SPADCALL (SPADCALL (QREFELT $ 57))
                           (SPADCALL
                            (SPADCALL |k| (SPADCALL 2 (QREFELT $ 18))
                                      (QREFELT $ 24))
                            (SPADCALL (QREFELT $ 28)) (QREFELT $ 29))
                           (QREFELT $ 9))
                 (QREFELT $ 25))))))) 

(DEFUN |FSFUN;logGamma;2C;7| (|z| $)
  (PROG (|result| |l1| #1=#:G1840 |l| |abs_z| |c_pi| |one| |re_z| |l0|)
    (RETURN
     (SEQ
      (COND
       ((EQL (SPADCALL (QREFELT $ 35)) 2)
        (SEQ (LETT |l0| (SPADCALL (QREFELT $ 36)) . #2=(|FSFUN;logGamma;2C;7|))
             (LETT |l| (MAX (+ |l0| 5) 20) . #2#)
             (LETT |re_z| (SPADCALL |z| (QREFELT $ 37)) . #2#)
             (LETT |one| (|spadConstant| $ 7) . #2#)
             (EXIT
              (COND
               ((SPADCALL |re_z|
                          (SPADCALL (|spadConstant| $ 11) 2 (QREFELT $ 13))
                          (QREFELT $ 39))
                (COND
                 ((SPADCALL |re_z| (QREFELT $ 41)) (|error| "Pole of Gamma"))
                 (#3='T
                  (SEQ (SPADCALL (+ |l| 5) (QREFELT $ 42))
                       (LETT |c_pi| (SPADCALL (QREFELT $ 28)) . #2#)
                       (LETT |result|
                             (SPADCALL
                              (SPADCALL (SPADCALL |c_pi| (QREFELT $ 27))
                                        (SPADCALL
                                         (SPADCALL |one| |z| (QREFELT $ 26))
                                         (QREFELT $ 58))
                                        (QREFELT $ 26))
                              (SPADCALL
                               (SPADCALL (SPADCALL |c_pi| |z| (QREFELT $ 9))
                                         (QREFELT $ 44))
                               (QREFELT $ 27))
                              (QREFELT $ 26))
                             . #2#)
                       (LETT |result| (|FSFUN;logGamma_lift| |z| |result| $)
                             . #2#)
                       (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))))
               (#3#
                (SEQ
                 (LETT |abs_z|
                       (SPADCALL (SPADCALL |z| (QREFELT $ 45)) (QREFELT $ 37))
                       . #2#)
                 (EXIT
                  (COND
                   ((SPADCALL (SPADCALL 6 |abs_z| (QREFELT $ 46))
                              (SPADCALL |l| (QREFELT $ 18)) (QREFELT $ 39))
                    (SEQ (LETT |l| (+ |l| 5) . #2#)
                         (COND
                          ((OR
                            (SPADCALL
                             (SPADCALL
                              (SPADCALL (SPADCALL |z| |one| (QREFELT $ 26))
                                        (QREFELT $ 45))
                              (QREFELT $ 37))
                             (SPADCALL (|spadConstant| $ 11) 4 (QREFELT $ 13))
                             (QREFELT $ 39))
                            (SPADCALL
                             (SPADCALL
                              (SPADCALL
                               (SPADCALL (SPADCALL |z| |one| (QREFELT $ 26))
                                         |one| (QREFELT $ 26))
                               (QREFELT $ 45))
                              (QREFELT $ 37))
                             (SPADCALL (|spadConstant| $ 11) 4 (QREFELT $ 13))
                             (QREFELT $ 39)))
                           (LETT |l| (* 2 |l|) . #2#)))
                         (SPADCALL |l| (QREFELT $ 42))
                         (LETT |result|
                               (|FSFUN;logGamma_lift| |z|
                                (SPADCALL (SPADCALL |z| (QREFELT $ 43))
                                          (QREFELT $ 27))
                                $)
                               . #2#)
                         (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))
                   (#3#
                    (SEQ
                     (LETT |l1|
                           (+
                            (+ |l|
                               (PROG1 (LETT #1# (INTEGER-LENGTH |l|) . #2#)
                                 (|check-subtype| (> #1# 0)
                                                  '(|PositiveInteger|) #1#)))
                            7)
                           . #2#)
                     (SPADCALL |l1| (QREFELT $ 42))
                     (LETT |result|
                           (|FSFUN;logGamma_asymptotic| |z|
                            (+ (QUOTIENT2 |l| 6) 1) $)
                           . #2#)
                     (SPADCALL |l0| (QREFELT $ 42)) (EXIT |result|)))))))))))
       (#3# (|error| "Gamma can only handle base 2 Float-s"))))))) 

(DEFUN |FSFUN;Gamma;2F;8| (|x| $)
  (SPADCALL (SPADCALL (SPADCALL |x| (QREFELT $ 14)) (QREFELT $ 43))
            (QREFELT $ 37))) 

(DEFUN |FSFUN;logGamma;2F;9| (|x| $)
  (COND
   ((SPADCALL (|spadConstant| $ 61) |x| (QREFELT $ 39))
    (SPADCALL (SPADCALL (SPADCALL |x| (QREFELT $ 14)) (QREFELT $ 58))
              (QREFELT $ 37)))
   ('T (|error| "Argument to logGamma <= 0")))) 

(DEFUN |FloatSpecialFunctions| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G1848)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|FloatSpecialFunctions|)
                . #3=(|FloatSpecialFunctions|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|FloatSpecialFunctions|
                         (LIST
                          (CONS NIL (CONS 1 (|FloatSpecialFunctions;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|FloatSpecialFunctions|))))))))))) 

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

(MAKEPROP '|FloatSpecialFunctions| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|Complex| 10) (0 . |One|) (4 . /)
              (10 . *) (|Float|) (16 . |One|) (|Integer|) (20 . /)
              (26 . |coerce|) (|PositiveInteger|) (|NonNegativeInteger|)
              (31 . *) (37 . |coerce|) (42 . /) (|Fraction| 12)
              (|IntegerNumberTheoryFunctions|) (48 . |bernoulli|)
              (53 . |coerce|) (58 . *) (64 . +) (70 . -) (76 . |log|)
              (81 . |pi|) (85 . *) (91 . |log|) (96 . |exp|) (101 . |coerce|)
              (106 . -) (111 . |exp|) (116 . |base|) (120 . |bits|)
              (124 . |real|) (|Boolean|) (129 . <) (|IntegerRetractions| 10)
              (135 . |integer?|) (140 . |bits|) |FSFUN;Gamma;2C;5|
              (145 . |sin|) (150 . |abs|) (155 . *) (161 . |max|)
              (165 . |order|) (170 . -) (176 . |log2|) (180 . +)
              (186 . |wholePart|) (191 . *) (197 . |imag|) (202 . |pi|)
              (206 . |round|) (211 . |imaginary|) |FSFUN;logGamma;2C;7|
              |FSFUN;Gamma;2F;8| (215 . |Zero|) (219 . |Zero|)
              |FSFUN;logGamma;2F;9|)
           '#(|logGamma| 223 |Gamma| 233) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 62
                                                 '(0 6 0 7 2 6 0 0 0 8 2 6 0 0
                                                   0 9 0 10 0 11 2 10 0 0 12 13
                                                   1 6 0 10 14 2 16 0 15 0 17 1
                                                   10 0 12 18 2 10 0 0 0 19 1
                                                   21 20 12 22 1 10 0 20 23 2
                                                   10 0 0 0 24 2 6 0 0 0 25 2 6
                                                   0 0 0 26 1 6 0 0 27 0 6 0 28
                                                   2 6 0 10 0 29 1 10 0 0 30 1
                                                   6 0 0 31 1 6 0 12 32 1 10 0
                                                   0 33 1 10 0 0 34 0 10 15 35
                                                   0 10 15 36 1 6 10 0 37 2 10
                                                   38 0 0 39 1 40 38 10 41 1 10
                                                   15 15 42 1 6 0 0 44 1 6 0 0
                                                   45 2 10 0 15 0 46 0 10 0 47
                                                   1 10 12 0 48 2 10 0 0 0 49 0
                                                   10 0 50 2 10 0 0 0 51 1 10
                                                   12 0 52 2 12 0 15 0 53 1 6
                                                   10 0 54 0 10 0 55 1 10 0 0
                                                   56 0 6 0 57 0 6 0 60 0 10 0
                                                   61 1 0 6 6 58 1 0 10 10 62 1
                                                   0 6 6 43 1 0 10 10 59)))))
           '|lookupComplete|)) 

(MAKEPROP '|FloatSpecialFunctions| 'NILADIC T) 
