
(/VERSIONCHECK 2) 

(DEFUN |INTALG;F2UPR| (|f| $) (SPADCALL (|INTALG;F2R| |f| $) (QREFELT $ 20))) 

(DEFUN |INTALG;F2R| (|f| $)
  (SPADCALL (SPADCALL (SPADCALL |f| (QREFELT $ 21)) (QREFELT $ 23))
            (QREFELT $ 24))) 

(DEFUN |INTALG;algintexp| (|f| |derivation| $)
  (PROG (|u| |p| |h| |ff| |w| |r| #1=#:G709 |i| |vf| |vp| |n| |v| |d| |c|)
    (RETURN
     (SEQ
      (LETT |d|
            (QCDR
             (LETT |c| (SPADCALL |f| (QREFELT $ 26))
                   . #2=(|INTALG;algintexp|)))
            . #2#)
      (LETT |v| (QCAR |c|) . #2#)
      (LETT |vp|
            (SPADCALL (LETT |n| (QVSIZE |v|) . #2#) (|spadConstant| $ 28)
                      (QREFELT $ 31))
            . #2#)
      (LETT |vf| (SPADCALL |n| (|spadConstant| $ 34) (QREFELT $ 36)) . #2#)
      (SEQ (LETT |i| (SPADCALL |v| (QREFELT $ 39)) . #2#)
           (LETT #1# (QVSIZE |v|) . #2#) G190 (COND ((> |i| #1#) (GO G191)))
           (SEQ
            (LETT |r|
                  (SPADCALL
                   (SPADCALL (SPADCALL |v| |i| (QREFELT $ 40)) |d|
                             (QREFELT $ 41))
                   (QREFELT $ 43))
                  . #2#)
            (SPADCALL |vf| |i| (QCDR |r|) (QREFELT $ 44))
            (EXIT (SPADCALL |vp| |i| (QCAR |r|) (QREFELT $ 45))))
           (LETT |i| (+ |i| 1) . #2#) (GO G190) G191 (EXIT NIL))
      (LETT |ff|
            (SPADCALL |vf| (LETT |w| (SPADCALL (QREFELT $ 47)) . #2#)
                      (QREFELT $ 48))
            . #2#)
      (LETT |h| (SPADCALL |ff| |derivation| (QREFELT $ 52)) . #2#)
      (LETT |p|
            (SPADCALL (SPADCALL (ELT $ 53) |vp| (QREFELT $ 56)) |w|
                      (QREFELT $ 48))
            . #2#)
      (COND
       ((SPADCALL (QCDR |h|) (QREFELT $ 58))
        (COND
         ((SPADCALL |p| (QREFELT $ 58))
          (EXIT (SPADCALL (QCAR |h|) (QREFELT $ 60)))))))
      (LETT |u| (|INTALG;alglogint| (QCDR |h|) |derivation| $) . #2#)
      (EXIT
       (COND
        ((QEQCAR |u| 1)
         (SPADCALL (QCAR |h|) NIL
                   (LIST
                    (CONS (SPADCALL |p| (QCDR |h|) (QREFELT $ 61))
                          (QREFELT $ 12)))
                   (QREFELT $ 66)))
        ((SPADCALL |p| (QREFELT $ 58))
         (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 66)))
        ('T
         (|error|
          "integrate: implementation incomplete (has polynomial part)")))))))) 

(DEFUN |INTALG;algintprim| (|f| |derivation| $)
  (PROG (|u| |h|)
    (RETURN
     (SEQ
      (LETT |h| (SPADCALL |f| |derivation| (QREFELT $ 52))
            . #1=(|INTALG;algintprim|))
      (EXIT
       (COND
        ((SPADCALL (QCDR |h|) (QREFELT $ 58))
         (SPADCALL (QCAR |h|) (QREFELT $ 60)))
        (#2='T
         (SEQ (LETT |u| (|INTALG;alglogint| (QCDR |h|) |derivation| $) . #1#)
              (EXIT
               (COND
                ((QEQCAR |u| 1)
                 (SPADCALL (QCAR |h|) NIL
                           (LIST (CONS (QCDR |h|) (QREFELT $ 12)))
                           (QREFELT $ 66)))
                (#2#
                 (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 66))))))))))))) 

(DEFUN |INTALG;palglogint| (|f| |derivation| $)
  (PROG (|dv0| #1=#:G785 #2=#:G784 #3=#:G786 #4=#:G797 |a| #5=#:G798 |dv| |g|
         |cd| |bb| #6=#:G781 |pp| |ld| #7=#:G796 |b| #8=#:G795 |la| #9=#:G794
         |q| #10=#:G793 |fc| |lf| |u| |r| |rec|)
    (RETURN
     (SEQ
      (LETT |rec| (SPADCALL |f| |derivation| (QREFELT $ 68))
            . #11=(|INTALG;palglogint|))
      (EXIT
       (COND
        ((SPADCALL (LETT |r| (SPADCALL |f| |derivation| (QREFELT $ 70)) . #11#)
                   (QREFELT $ 71))
         (CONS 1 "failed"))
        (#12='T
         (SEQ (LETT |u| (SPADCALL |r| (QREFELT $ 74)) . #11#)
              (EXIT
               (COND ((QEQCAR |u| 1) (|INTALG;nonQ| |rec| |r| $))
                     (#12#
                      (SEQ
                       (LETT |fc|
                             (|INTALG;nonLinear|
                              (LETT |lf| (SPADCALL (QCDR |u|) (QREFELT $ 78))
                                    . #11#)
                              $)
                             . #11#)
                       (EXIT
                        (COND
                         ((QEQCAR |fc| 1)
                          (|error|
                           "integrate: implementation incomplete (residue poly has multiple non-linear factors)"))
                         (#12#
                          (SEQ
                           (LETT |la|
                                 (PROGN
                                  (LETT #10# NIL . #11#)
                                  (SEQ (LETT |q| NIL . #11#)
                                       (LETT #9#
                                             (SPADCALL (QCDR |fc|) |lf|
                                                       (QREFELT $ 79))
                                             . #11#)
                                       G190
                                       (COND
                                        ((OR (ATOM #9#)
                                             (PROGN
                                              (LETT |q| (CAR #9#) . #11#)
                                              NIL))
                                         #13=(GO G191)))
                                       (SEQ
                                        (EXIT
                                         (LETT #10#
                                               (CONS
                                                (SPADCALL
                                                 (SPADCALL (QCAR |q|) 0
                                                           (QREFELT $ 82))
                                                 (QREFELT $ 83))
                                                #10#)
                                               . #11#)))
                                       (LETT #9# (CDR #9#) . #11#)
                                       #14=(GO G190) G191
                                       (EXIT (NREVERSE0 #10#))))
                                 . #11#)
                           (LETT |ld|
                                 (PROGN
                                  (LETT #8# NIL . #11#)
                                  (SEQ (LETT |b| NIL . #11#)
                                       (LETT #7# |la| . #11#) G190
                                       (COND
                                        ((OR (ATOM #7#)
                                             (PROGN
                                              (LETT |b| (CAR #7#) . #11#)
                                              NIL))
                                         #13#))
                                       (SEQ
                                        (EXIT
                                         (LETT #8#
                                               (CONS
                                                (SPADCALL (QVELT |rec| 0)
                                                          (QVELT |rec| 1)
                                                          (QVELT |rec| 2)
                                                          (QVELT |rec| 3)
                                                          (SPADCALL |b|
                                                                    (QREFELT $
                                                                             84))
                                                          (QREFELT $ 86))
                                                #8#)
                                               . #11#)))
                                       (LETT #7# (CDR #7#) . #11#) #14# G191
                                       (EXIT (NREVERSE0 #8#))))
                                 . #11#)
                           (LETT |pp| (|INTALG;UPQ2F| (QCAR (QCDR |fc|)) $)
                                 . #11#)
                           (EXIT
                            (COND
                             ((SPADCALL
                               (LETT |bb|
                                     (SPADCALL (QCAR (QCDR |fc|))
                                               (PROG1
                                                   (LETT #6#
                                                         (-
                                                          (SPADCALL
                                                           (QCAR (QCDR |fc|))
                                                           (QREFELT $ 87))
                                                          1)
                                                         . #11#)
                                                 (|check-subtype| (>= #6# 0)
                                                                  '(|NonNegativeInteger|)
                                                                  #6#))
                                               (QREFELT $ 82))
                                     . #11#)
                               (QREFELT $ 89))
                              (SEQ
                               (LETT |cd| (SPADCALL |la| (QREFELT $ 93))
                                     . #11#)
                               (LETT |g| (SPADCALL (QCAR |cd|) (QREFELT $ 95))
                                     . #11#)
                               (LETT |dv0|
                                     (PROGN
                                      (LETT #1# NIL . #11#)
                                      (SEQ (LETT |dv| NIL . #11#)
                                           (LETT #5# |ld| . #11#)
                                           (LETT |a| NIL . #11#)
                                           (LETT #4# (QCAR |cd|) . #11#) G190
                                           (COND
                                            ((OR (ATOM #4#)
                                                 (PROGN
                                                  (LETT |a| (CAR #4#) . #11#)
                                                  NIL)
                                                 (ATOM #5#)
                                                 (PROGN
                                                  (LETT |dv| (CAR #5#) . #11#)
                                                  NIL))
                                             #13#))
                                           (SEQ
                                            (EXIT
                                             (PROGN
                                              (LETT #3#
                                                    (SPADCALL
                                                     (QUOTIENT2 |a| |g|) |dv|
                                                     (QREFELT $ 96))
                                                    . #11#)
                                              (COND
                                               (#1#
                                                (LETT #2#
                                                      (SPADCALL #2# #3#
                                                                (QREFELT $ 97))
                                                      . #11#))
                                               ('T
                                                (PROGN
                                                 (LETT #2# #3# . #11#)
                                                 (LETT #1# 'T . #11#)))))))
                                           (LETT #4#
                                                 (PROG1 (CDR #4#)
                                                   (LETT #5# (CDR #5#) . #11#))
                                                 . #11#)
                                           #14# G191 (EXIT NIL))
                                      (COND (#1# #2#)
                                            (#12# (|spadConstant| $ 98))))
                                     . #11#)
                               (EXIT
                                (|INTALG;trace0| |rec| |pp|
                                 (SPADCALL |g| (QCDR |cd|) (QREFELT $ 99))
                                 |dv0| $))))
                             (#12#
                              (|INTALG;trace1| |rec| |pp| |la| |ld| |bb|
                               $)))))))))))))))))))) 

(DEFUN |INTALG;UPQ2F| (|p| $) (SPADCALL (ELT $ 84) |p| (QREFELT $ 102))) 

(DEFUN |INTALG;UP2SUP| (|p| $)
  (SPADCALL (LIST #'|INTALG;UP2SUP!0|) |p| (QREFELT $ 106))) 

(DEFUN |INTALG;UP2SUP!0| (|x| $$) |x|) 

(DEFUN |INTALG;SUP2UP| (|p| $)
  (SPADCALL (LIST #'|INTALG;SUP2UP!0|) |p| (QREFELT $ 108))) 

(DEFUN |INTALG;SUP2UP!0| (|x| $$) |x|) 

(DEFUN |INTALG;varRoot?| (|p| |derivation| $)
  (PROG (#1=#:G805 #2=#:G807 #3=#:G808 |c|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (SEQ
         (EXIT
          (SEQ (LETT |c| NIL . #4=(|INTALG;varRoot?|))
               (LETT #3#
                     (SPADCALL (SPADCALL |p| (QREFELT $ 109)) (QREFELT $ 111))
                     . #4#)
               G190
               (COND
                ((OR (ATOM #3#) (PROGN (LETT |c| (CAR #3#) . #4#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (COND
                  ((NULL
                    (SPADCALL (SPADCALL |c| |derivation|) (|spadConstant| $ 33)
                              (QREFELT $ 112)))
                   (PROGN
                    (LETT #1# (PROGN (LETT #2# 'T . #4#) (GO #2#)) . #4#)
                    (GO #1#))))))
               (LETT #3# (CDR #3#) . #4#) (GO G190) G191 (EXIT NIL)))
         #1# (EXIT #1#))
        (EXIT 'NIL)))
      #2# (EXIT #2#))))) 

(DEFUN |INTALG;pLogDeriv| (|log| |derivation| $)
  (PROG (|ans| |algans| #1=#:G827 |i| |diflog| |numlog| |c| |n|)
    (RETURN
     (SEQ
      (COND
       ((NULL
         (SPADCALL (SPADCALL |derivation| (QVELT |log| 1) (QREFELT $ 114))
                   (|spadConstant| $ 115) (QREFELT $ 116)))
        (|error| "can only handle logs with constant coefficients"))
       ('T
        (SEQ
         (LETT |n| (SPADCALL (QVELT |log| 1) (QREFELT $ 117))
               . #2=(|INTALG;pLogDeriv|))
         (EXIT
          (COND
           ((EQL |n| 1)
            (SEQ
             (LETT |c|
                   (SPADCALL
                    (SPADCALL
                     (SPADCALL (SPADCALL (QVELT |log| 1) (QREFELT $ 119))
                               (QREFELT $ 120))
                     (SPADCALL (QVELT |log| 1) (QREFELT $ 120))
                     (QREFELT $ 121))
                    (QREFELT $ 122))
                   . #2#)
             (LETT |ans| (SPADCALL (QVELT |log| 2) |c| (QREFELT $ 123)) . #2#)
             (EXIT
              (SPADCALL
               (SPADCALL
                (SPADCALL (SPADCALL (QVELT |log| 0) (QREFELT $ 124)) |c|
                          (QREFELT $ 125))
                (SPADCALL |ans| |derivation|) (QREFELT $ 125))
               |ans| (QREFELT $ 121)))))
           (#3='T
            (SEQ
             (LETT |numlog|
                   (SPADCALL |derivation| (QVELT |log| 2) (QREFELT $ 114))
                   . #2#)
             (LETT |diflog|
                   (SPADCALL (QVELT |log| 2) (QVELT |log| 1) |numlog|
                             (QREFELT $ 128))
                   . #2#)
             (EXIT
              (COND ((QEQCAR |diflog| 1) (|error| "this shouldn't happen"))
                    (#3#
                     (SEQ (LETT |algans| (QCAR (QCDR |diflog|)) . #2#)
                          (LETT |ans| (|spadConstant| $ 11) . #2#)
                          (SEQ (LETT |i| 0 . #2#) (LETT #1# (- |n| 1) . #2#)
                               G190 (COND ((QSGREATERP |i| #1#) (GO G191)))
                               (SEQ
                                (LETT |algans|
                                      (SPADCALL
                                       (SPADCALL |algans|
                                                 (SPADCALL
                                                  (|spadConstant| $ 129) 1
                                                  (QREFELT $ 130))
                                                 (QREFELT $ 131))
                                       (QVELT |log| 1) (QREFELT $ 132))
                                      . #2#)
                                (EXIT
                                 (LETT |ans|
                                       (SPADCALL |ans|
                                                 (SPADCALL |algans| |i|
                                                           (QREFELT $ 133))
                                                 (QREFELT $ 61))
                                       . #2#)))
                               (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191
                               (EXIT NIL))
                          (EXIT
                           (SPADCALL (SPADCALL (QVELT |log| 0) (QREFELT $ 124))
                                     |ans| (QREFELT $ 125)))))))))))))))))) 

(DEFUN |INTALG;R2UP| (|f| |k| $)
  (PROG (|g| |y| |x|)
    (RETURN
     (SEQ
      (LETT |x| (SPADCALL (QREFELT $ 17) (QREFELT $ 135)) . #1=(|INTALG;R2UP|))
      (LETT |g|
            (SPADCALL
             (SPADCALL (CONS #'|INTALG;R2UP!0| (VECTOR $ |x|))
                       (SPADCALL |f| (QREFELT $ 138)) (QREFELT $ 141))
             (LETT |y| (SPADCALL (QREFELT $ 18) (QREFELT $ 135)) . #1#)
             (QREFELT $ 142))
            . #1#)
      (EXIT
       (SPADCALL
        (CONS #'|INTALG;R2UP!1| (VECTOR $ (QREFELT $ 18) (QREFELT $ 17)))
        (SPADCALL |g| |k| (SPADCALL |k| (QREFELT $ 144)) (QREFELT $ 146))
        (QREFELT $ 149))))))) 

(DEFUN |INTALG;R2UP!1| (|x1| $$)
  (PROG (|dumx| |dumy| $)
    (LETT |dumx| (QREFELT $$ 2) . #1=(|INTALG;R2UP|))
    (LETT |dumy| (QREFELT $$ 1) . #1#)
    (LETT $ (QREFELT $$ 0) . #1#)
    (RETURN (PROGN (|INTALG;rlift| |x1| |dumx| |dumy| $))))) 

(DEFUN |INTALG;R2UP!0| (|f1| $$)
  (PROG (|x| $)
    (LETT |x| (QREFELT $$ 1) . #1=(|INTALG;R2UP|))
    (LETT $ (QREFELT $$ 0) . #1#)
    (RETURN (PROGN (SPADCALL |f1| |x| (QREFELT $ 137)))))) 

(DEFUN |INTALG;univ| (|f| |k| $)
  (PROG (|g|)
    (RETURN
     (SEQ (LETT |g| (SPADCALL |f| |k| (QREFELT $ 151)) |INTALG;univ|)
          (EXIT
           (SPADCALL (|INTALG;SUP2UP| (SPADCALL |g| (QREFELT $ 153)) $)
                     (|INTALG;SUP2UP| (SPADCALL |g| (QREFELT $ 154)) $)
                     (QREFELT $ 41))))))) 

(DEFUN |INTALG;rlift| (|f| |kx| |ky| $)
  (PROG ()
    (RETURN
     (SPADCALL
      (SPADCALL (CONS #'|INTALG;rlift!0| (VECTOR $ |kx|))
                (SPADCALL (SPADCALL |f| |ky| (QREFELT $ 151)) (QREFELT $ 155))
                (QREFELT $ 158))
      (QREFELT $ 159))))) 

(DEFUN |INTALG;rlift!0| (|x1| $$)
  (PROG (|kx| $)
    (LETT |kx| (QREFELT $$ 1) . #1=(|INTALG;rlift|))
    (LETT $ (QREFELT $$ 0) . #1#)
    (RETURN (PROGN (|INTALG;univ| |x1| |kx| $))))) 

(DEFUN |INTALG;nonQ| (|rec| |p| $)
  (PROG (|lf|)
    (RETURN
     (COND
      ((NULL
        (CDR
         (LETT |lf|
               (SPADCALL
                (SPADCALL (SPADCALL |p| (QREFELT $ 109)) (QREFELT $ 161))
                (QREFELT $ 164))
               |INTALG;nonQ|)))
       (|INTALG;trace00| |rec| (QCAR (|SPADfirst| |lf|)) NIL $))
      ('T
       (|error|
        "integrate: implementation incomplete (non-algebraic residues)")))))) 

(DEFUN |INTALG;trace0| (|rec| |q| |r| |dv0| $)
  (PROG (|lg| |rc0|)
    (RETURN
     (SEQ
      (LETT |lg|
            (COND ((SPADCALL |dv0| (QREFELT $ 165)) NIL)
                  (#1='T
                   (SEQ
                    (LETT |rc0| (SPADCALL |dv0| (QREFELT $ 169))
                          . #2=(|INTALG;trace0|))
                    (EXIT
                     (COND
                      ((QEQCAR |rc0| 1)
                       (|error|
                        "Not integrable (provided residues have no relations)"))
                      (#1#
                       (|INTALG;mkLog| (|spadConstant| $ 170)
                        (SPADCALL |r|
                                  (SPADCALL (QCAR (QCDR |rc0|))
                                            (QREFELT $ 171))
                                  (QREFELT $ 172))
                        (QCDR (QCDR |rc0|)) (|spadConstant| $ 118) $)))))))
            . #2#)
      (EXIT (|INTALG;trace00| |rec| |q| |lg| $)))))) 

(DEFUN |INTALG;trace00| (|rec| |pp| |lg| $)
  (PROG (|rc| |dvr| |alpha| |q| #1=#:G872 |p0| |alpha0|)
    (RETURN
     (SEQ
      (LETT |p0|
            (SPADCALL (QVELT |rec| 0) (QVELT |rec| 1) (QVELT |rec| 2)
                      (QVELT |rec| 3)
                      (LETT |alpha0|
                            (SPADCALL (|INTALG;UP2SUP| |pp| $) (QREFELT $ 173))
                            . #2=(|INTALG;trace00|))
                      (QREFELT $ 86))
            . #2#)
      (LETT |q|
            (PROG2
                (LETT #1#
                      (SPADCALL |pp|
                                (SPADCALL
                                 (SPADCALL (|spadConstant| $ 118) 1
                                           (QREFELT $ 174))
                                 (SPADCALL |alpha0| (QREFELT $ 21))
                                 (QREFELT $ 175))
                                (QREFELT $ 177))
                      . #2#)
                (QCDR #1#)
              (|check-union| (QEQCAR #1# 0) (QREFELT $ 8) #1#))
            . #2#)
      (LETT |alpha| (SPADCALL (|INTALG;UP2SUP| |q| $) (QREFELT $ 178)) . #2#)
      (LETT |dvr|
            (SPADCALL
             (SPADCALL (QVELT |rec| 0) (QVELT |rec| 1) (QVELT |rec| 2)
                       (QVELT |rec| 3) |alpha| (QREFELT $ 86))
             |p0| (QREFELT $ 179))
            . #2#)
      (LETT |rc| (SPADCALL |dvr| (QREFELT $ 169)) . #2#)
      (EXIT
       (COND
        ((QEQCAR |rc| 1)
         (COND ((NULL (< 2 (SPADCALL |pp| (QREFELT $ 180)))) (CONS 1 "failed"))
               ('T
                (|error|
                 "Not integrable (provided residues have no relations)"))))
        ('T
         (CONS 0
               (SPADCALL |lg|
                         (|INTALG;mkLog| |q|
                          (SPADCALL
                           (SPADCALL (QCAR (QCDR |rc|)) (QREFELT $ 171))
                           (QREFELT $ 181))
                          (QCDR (QCDR |rc|)) |alpha| $)
                         (QREFELT $ 182)))))))))) 

(DEFUN |INTALG;trace1| (|rec| |q| |la| |ld| |b| $)
  (PROG (|rc| |v| |alpha| |v0| #1=#:G890 #2=#:G889 #3=#:G891 #4=#:G902 |a|
         #5=#:G903 |dv| |cd| #6=#:G901 #7=#:G900)
    (RETURN
     (SEQ
      (LETT |cd|
            (SPADCALL
             (PROGN
              (LETT #7# NIL . #8=(|INTALG;trace1|))
              (SEQ (LETT |a| NIL . #8#) (LETT #6# |la| . #8#) G190
                   (COND
                    ((OR (ATOM #6#) (PROGN (LETT |a| (CAR #6#) . #8#) NIL))
                     #9=(GO G191)))
                   (SEQ
                    (EXIT
                     (LETT #7# (CONS (SPADCALL |a| |b| (QREFELT $ 172)) #7#)
                           . #8#)))
                   (LETT #6# (CDR #6#) . #8#) #10=(GO G190) G191
                   (EXIT (NREVERSE0 #7#))))
             (QREFELT $ 93))
            . #8#)
      (LETT |v0|
            (PROGN
             (LETT #1# NIL . #8#)
             (SEQ (LETT |dv| NIL . #8#) (LETT #5# |ld| . #8#)
                  (LETT |a| NIL . #8#) (LETT #4# (QCAR |cd|) . #8#) G190
                  (COND
                   ((OR (ATOM #4#) (PROGN (LETT |a| (CAR #4#) . #8#) NIL)
                        (ATOM #5#) (PROGN (LETT |dv| (CAR #5#) . #8#) NIL))
                    #9#))
                  (SEQ
                   (EXIT
                    (PROGN
                     (LETT #3# (SPADCALL |a| |dv| (QREFELT $ 96)) . #8#)
                     (COND
                      (#1# (LETT #2# (SPADCALL #2# #3# (QREFELT $ 97)) . #8#))
                      ('T (PROGN (LETT #2# #3# . #8#) (LETT #1# 'T . #8#)))))))
                  (LETT #4# (PROG1 (CDR #4#) (LETT #5# (CDR #5#) . #8#)) . #8#)
                  #10# G191 (EXIT NIL))
             (COND (#1# #2#) (#11='T (|spadConstant| $ 98))))
            . #8#)
      (LETT |alpha| (SPADCALL (|INTALG;UP2SUP| |q| $) (QREFELT $ 178)) . #8#)
      (LETT |v|
            (SPADCALL |v0|
                      (SPADCALL (QCDR |cd|)
                                (SPADCALL (QVELT |rec| 0) (QVELT |rec| 1)
                                          (QVELT |rec| 2) (QVELT |rec| 3)
                                          |alpha| (QREFELT $ 86))
                                (QREFELT $ 96))
                      (QREFELT $ 179))
            . #8#)
      (LETT |rc| (SPADCALL |v| (QREFELT $ 169)) . #8#)
      (EXIT
       (COND
        ((QEQCAR |rc| 1)
         (COND ((NULL (< 2 (SPADCALL |q| (QREFELT $ 180)))) (CONS 1 "failed"))
               ('T
                (|error|
                 "Not integrable (provided residues have no relations)"))))
        (#11#
         (CONS 0
               (|INTALG;mkLog| |q|
                (SPADCALL
                 (SPADCALL (- (* (QCAR (QCDR |rc|)) (QCDR |cd|)))
                           (QREFELT $ 171))
                 (QREFELT $ 181))
                (QCDR (QCDR |rc|)) |alpha| $))))))))) 

(DEFUN |INTALG;mkLog| (|q| |scalr| |lgd| |alpha| $)
  (COND
   ((NULL (< 1 (SPADCALL |q| (QREFELT $ 180))))
    (LIST
     (VECTOR |scalr|
             (SPADCALL (SPADCALL (|spadConstant| $ 129) 1 (QREFELT $ 130))
                       (|INTALG;F2UPR| |alpha| $) (QREFELT $ 185))
             (SPADCALL |lgd| (QREFELT $ 20)))))
   ('T
    (LIST
     (VECTOR |scalr|
             (SPADCALL (CONS (|function| |INTALG;F2R|) $) |q| (QREFELT $ 187))
             (|INTALG;R2UP| |lgd| (SPADCALL |alpha| (QREFELT $ 188)) $)))))) 

(DEFUN |INTALG;nonLinear| (|l| $)
  (PROG (|ans| |found| #1=#:G916 #2=#:G917 |q|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (LETT |found| 'NIL . #3=(|INTALG;nonLinear|))
            (LETT |ans| (|SPADfirst| |l|) . #3#)
            (SEQ (LETT |q| NIL . #3#) (LETT #2# |l| . #3#) G190
                 (COND
                  ((OR (ATOM #2#) (PROGN (LETT |q| (CAR #2#) . #3#) NIL))
                   (GO G191)))
                 (SEQ
                  (EXIT
                   (COND
                    ((< 1 (SPADCALL (QCAR |q|) (QREFELT $ 87)))
                     (COND
                      (|found|
                       (PROGN (LETT #1# (CONS 1 "failed") . #3#) (GO #1#)))
                      ('T
                       (SEQ (LETT |found| 'T . #3#)
                            (EXIT (LETT |ans| |q| . #3#)))))))))
                 (LETT #2# (CDR #2#) . #3#) (GO G190) G191 (EXIT NIL))
            (EXIT (CONS 0 |ans|))))
      #1# (EXIT #1#))))) 

(DEFUN |INTALG;palginfieldint;RMU;20| (|f| |derivation| $)
  (PROG (|h|)
    (RETURN
     (SEQ
      (LETT |h| (SPADCALL |f| |derivation| (QREFELT $ 52))
            |INTALG;palginfieldint;RMU;20|)
      (EXIT
       (COND ((SPADCALL (QCDR |h|) (QREFELT $ 58)) (CONS 0 (QCAR |h|)))
             ('T (CONS 1 "failed")))))))) 

(DEFUN |INTALG;palgintegrate;RMIr;21| (|f| |derivation| $)
  (PROG (|difFirstKind| #1=#:G1011 #2=#:G1010 #3=#:G1012 #4=#:G1016 |lg|
         #5=#:G1013 |u| |h|)
    (RETURN
     (SEQ
      (LETT |h| (SPADCALL |f| |derivation| (QREFELT $ 52))
            . #6=(|INTALG;palgintegrate;RMIr;21|))
      (EXIT
       (COND
        ((SPADCALL (QCDR |h|) (QREFELT $ 58))
         (SPADCALL (QCAR |h|) (QREFELT $ 60)))
        (#7='T
         (SEQ
          (EXIT
           (SEQ
            (COND
             ((SPADCALL (QCDR |h|) (QREFELT $ 192))
              (SEQ
               (LETT |u| (|INTALG;palglogint| (QCDR |h|) |derivation| $) . #6#)
               (EXIT
                (COND
                 ((QEQCAR |u| 1)
                  (PROGN
                   (LETT #5#
                         (SPADCALL (QCAR |h|) NIL
                                   (LIST (CONS (QCDR |h|) (QREFELT $ 12)))
                                   (QREFELT $ 66))
                         . #6#)
                   (GO #5#)))))))
             (#7#
              (EXIT
               (SPADCALL (QCAR |h|) NIL (LIST (CONS (QCDR |h|) (QREFELT $ 12)))
                         (QREFELT $ 66)))))
            (EXIT
             (COND
              ((SPADCALL
                (LETT |difFirstKind|
                      (SPADCALL (QCDR |h|)
                                (PROGN
                                 (LETT #1# NIL . #6#)
                                 (SEQ (LETT |lg| NIL . #6#)
                                      (LETT #4# (QCDR |u|) . #6#) G190
                                      (COND
                                       ((OR (ATOM #4#)
                                            (PROGN
                                             (LETT |lg| (CAR #4#) . #6#)
                                             NIL))
                                        (GO G191)))
                                      (SEQ
                                       (EXIT
                                        (PROGN
                                         (LETT #3#
                                               (|INTALG;pLogDeriv| |lg|
                                                (CONS
                                                 #'|INTALG;palgintegrate;RMIr;21!0|
                                                 (VECTOR $ |derivation|))
                                                $)
                                               . #6#)
                                         (COND
                                          (#1#
                                           (LETT #2#
                                                 (SPADCALL #2# #3#
                                                           (QREFELT $ 61))
                                                 . #6#))
                                          ('T
                                           (PROGN
                                            (LETT #2# #3# . #6#)
                                            (LETT #1# 'T . #6#)))))))
                                      (LETT #4# (CDR #4#) . #6#) (GO G190) G191
                                      (EXIT NIL))
                                 (COND (#1# #2#) (#7# (|spadConstant| $ 11))))
                                (QREFELT $ 194))
                      . #6#)
                (QREFELT $ 58))
               (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 66)))
              (#7#
               (SPADCALL (QCAR |h|) (QCDR |u|)
                         (LIST (CONS |difFirstKind| (QREFELT $ 12)))
                         (QREFELT $ 66)))))))
          #5# (EXIT #5#))))))))) 

(DEFUN |INTALG;palgintegrate;RMIr;21!0| (|x1| $$)
  (PROG (|derivation| $)
    (LETT |derivation| (QREFELT $$ 1) . #1=(|INTALG;palgintegrate;RMIr;21|))
    (LETT $ (QREFELT $$ 0) . #1#)
    (RETURN (PROGN (SPADCALL |x1| |derivation| (QREFELT $ 193)))))) 

(DEFUN |INTALG;algintegrate;RMIr;22| (|f| |derivation| $)
  (PROG (#1=#:G1028 |xx| |x'| |x|)
    (RETURN
     (SEQ
      (COND
       ((ZEROP
         (SPADCALL
          (LETT |x'|
                (SPADCALL
                 (LETT |x| (SPADCALL (|spadConstant| $ 118) 1 (QREFELT $ 174))
                       . #2=(|INTALG;algintegrate;RMIr;22|))
                 |derivation|)
                . #2#)
          (QREFELT $ 180)))
        (|INTALG;algintprim| |f| |derivation| $))
       ('T
        (SEQ
         (EXIT
          (SEQ
           (SEQ (LETT |xx| (SPADCALL |x'| |x| (QREFELT $ 177)) . #2#)
                (EXIT
                 (COND
                  ((QEQCAR |xx| 0)
                   (COND
                    ((QEQCAR (SPADCALL (QCDR |xx|) (QREFELT $ 197)) 0)
                     (PROGN
                      (LETT #1# (|INTALG;algintexp| |f| |derivation| $) . #2#)
                      (GO #1#))))))))
           (EXIT (|error| "should not happen"))))
         #1# (EXIT #1#)))))))) 

(DEFUN |INTALG;alglogint| (|f| |derivation| $)
  (PROG ()
    (RETURN
     (COND
      ((|INTALG;varRoot?| (SPADCALL |f| |derivation| (QREFELT $ 70))
        (CONS #'|INTALG;alglogint!0| (VECTOR |derivation| $)) $)
       (CONS 1 "failed"))
      ('T
       (|error| "integrate: implementation incomplete (constant residues)")))))) 

(DEFUN |INTALG;alglogint!0| (|x1| $$)
  (PROG ($ |derivation|)
    (LETT $ (QREFELT $$ 1) . #1=(|INTALG;alglogint|))
    (LETT |derivation| (QREFELT $$ 0) . #1#)
    (RETURN
     (PROGN
      (SPADCALL (SPADCALL (SPADCALL |x1| (QREFELT $ 21)) |derivation|)
                (QREFELT $ 199)))))) 

(DEFUN |AlgebraicIntegrate| (&REST #1=#:G1037)
  (PROG ()
    (RETURN
     (PROG (#2=#:G1038)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (|devaluateList| #1#)
                                           (HGET |$ConstructorCache|
                                                 '|AlgebraicIntegrate|)
                                           '|domainEqualList|)
                . #3=(|AlgebraicIntegrate|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT
              (PROG1 (APPLY (|function| |AlgebraicIntegrate;|) #1#)
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|AlgebraicIntegrate|))))))))))) 

(DEFUN |AlgebraicIntegrate;| (|#1| |#2| |#3| |#4| |#5|)
  (PROG (|pv$| $ |dv$| DV$5 DV$4 DV$3 DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|AlgebraicIntegrate|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT DV$3 (|devaluate| |#3|) . #1#)
      (LETT DV$4 (|devaluate| |#4|) . #1#)
      (LETT DV$5 (|devaluate| |#5|) . #1#)
      (LETT |dv$| (LIST '|AlgebraicIntegrate| DV$1 DV$2 DV$3 DV$4 DV$5) . #1#)
      (LETT $ (GETREFV 200) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|AlgebraicIntegrate|
                  (LIST DV$1 DV$2 DV$3 DV$4 DV$5) (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 8 |#3|)
      (QSETREFV $ 9 |#4|)
      (QSETREFV $ 10 |#5|)
      (QSETREFV $ 12 (|spadConstant| $ 11))
      (QSETREFV $ 17 (SPADCALL (SPADCALL (QREFELT $ 14)) (QREFELT $ 16)))
      (QSETREFV $ 18 (SPADCALL (SPADCALL (QREFELT $ 14)) (QREFELT $ 16)))
      $)))) 

(MAKEPROP '|AlgebraicIntegrate| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) (|local| |#4|) (|local| |#5|) (0 . |Zero|)
              '|dummy| (|Symbol|) (4 . |new|) (|Kernel| 7) (8 . |kernel|)
              '|dumx| '|dumy| (|SparseUnivariatePolynomial| 10) (13 . |coerce|)
              (18 . |coerce|) (|Fraction| 8) (23 . |coerce|) (28 . |coerce|)
              (|Record| (|:| |num| 38) (|:| |den| 8))
              (33 . |integralCoordinates|) (|LaurentPolynomial| 7 8)
              (38 . |Zero|) (|NonNegativeInteger|) (|Vector| 27) (42 . |new|)
              (48 . |Zero|) (52 . |Zero|) (56 . |Zero|) (|Vector| 22)
              (60 . |new|) (|Integer|) (|Vector| 8) (66 . |minIndex|)
              (71 . |qelt|) (77 . /)
              (|Record| (|:| |polyPart| $) (|:| |fracPart| 22))
              (83 . |separate|) (88 . |qsetelt!|) (95 . |qsetelt!|)
              (|Vector| $) (102 . |integralBasis|) (106 . |represents|)
              (|Record| (|:| |answer| 10) (|:| |logpart| 10)) (|Mapping| 8 8)
              (|AlgebraicHermiteIntegration| 7 8 9 10)
              (112 . |HermiteIntegrate|) (118 . |convert|) (|Mapping| 22 27)
              (|VectorFunctions2| 27 22) (123 . |map|) (|Boolean|)
              (129 . |zero?|) (|IntegrationResult| 10) (134 . |coerce|)
              (139 . +)
              (|Record| (|:| |scalar| 80) (|:| |coeff| 19) (|:| |logand| 19))
              (|List| 62) (|Record| (|:| |integrand| 10) (|:| |intvar| 10))
              (|List| 64) (145 . |mkAnswer|)
              (|Record| (|:| |num| $) (|:| |den| 8) (|:| |derivden| 8)
                        (|:| |gd| 8))
              (152 . |algSplitSimple|) (|DoubleResultantPackage| 7 8 9 10)
              (158 . |doubleResultant|) (164 . |ground?|)
              (|Union| 77 '"failed")
              (|FunctionSpaceUnivariatePolynomialFactor| 6 7 8)
              (169 . |qfactor|)
              (|Record| (|:| |factor| 81) (|:| |exponent| 37)) (|List| 75)
              (|Factored| 81) (174 . |factors|) (179 . |remove!|)
              (|Fraction| 37) (|SparseUnivariatePolynomial| 80)
              (185 . |coefficient|) (191 . -) (196 . |coerce|)
              (|FiniteDivisor| 7 8 9 10) (201 . |divisor|) (210 . |degree|)
              (215 . |One|) (219 . |zero?|)
              (|Record| (|:| |num| (|List| 37)) (|:| |den| 37)) (|List| 80)
              (|InnerCommonDenominator| 37 80 (|List| 37) 91)
              (224 . |splitDenominator|) (|List| $) (229 . |gcd|) (234 . *)
              (240 . +) (246 . |Zero|) (250 . /) (|Mapping| 7 80)
              (|UnivariatePolynomialCategoryFunctions2| 80 81 7 8)
              (256 . |map|) (|SparseUnivariatePolynomial| 7) (|Mapping| 7 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 8 7 103)
              (262 . |map|)
              (|UnivariatePolynomialCategoryFunctions2| 7 103 7 8)
              (268 . |map|) (274 . |primitivePart|) (|List| 7)
              (279 . |coefficients|) (284 . =) (|Mapping| 10 10) (290 . |map|)
              (296 . |Zero|) (300 . =) (306 . |degree|) (311 . |One|)
              (315 . |reductum|) (320 . |leadingCoefficient|) (325 . /)
              (331 . -) (336 . |elt|) (342 . |coerce|) (347 . *)
              (|Record| (|:| |coef1| $) (|:| |coef2| $))
              (|Union| 126 '"failed") (353 . |extendedEuclidean|) (360 . |One|)
              (364 . |monomial|) (370 . *) (376 . |rem|) (382 . |coefficient|)
              (|Kernel| $) (388 . |coerce|) (|Fraction| $) (393 . |elt|)
              (399 . |lift|) (|Mapping| 7 22)
              (|UnivariatePolynomialCategoryFunctions2| 22 9 7 8) (404 . |map|)
              (410 . |elt|) (|SparseUnivariatePolynomial| $) (416 . |minPoly|)
              (|PolynomialCategoryQuotientFunctions| (|IndexedExponents| 15) 15
                                                     6
                                                     (|SparseMultivariatePolynomial|
                                                      6 15)
                                                     7)
              (421 . |univariate|) (|Mapping| 10 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 103 10 19)
              (428 . |map|) (|Fraction| 143) (434 . |univariate|)
              (|Fraction| 103) (440 . |numer|) (445 . |denom|)
              (450 . |retract|) (|Mapping| 22 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 103 22 9)
              (455 . |map|) (461 . |reduce|) (|Factored| 8) (466 . |ffactor|)
              (|Record| (|:| |factor| 8) (|:| |exponent| 37)) (|List| 162)
              (471 . |factors|) (476 . |zero?|)
              (|Record| (|:| |order| 29) (|:| |function| 10))
              (|Union| 166 '"failed") (|PointsOfFiniteOrder| 6 7 8 9 10)
              (481 . |torsionIfCan|) (486 . |One|) (490 . |coerce|) (495 . /)
              (501 . |zeroOf|) (506 . |monomial|) (512 . -)
              (|Union| $ '"failed") (518 . |exquo|) (524 . |rootOf|) (529 . -)
              (535 . |degree|) (540 . |inv|) (545 . |concat|) (551 . |One|)
              (555 . |One|) (559 . -)
              (|UnivariatePolynomialCategoryFunctions2| 7 8 10 19)
              (565 . |map|) (571 . |retract|) (576 . |One|)
              (|Union| 10 '"failed") |INTALG;palginfieldint;RMU;20|
              (580 . |integralAtInfinity?|) (585 . |differentiate|) (591 . -)
              |INTALG;palgintegrate;RMIr;21| (|Union| 7 '"failed")
              (597 . |retractIfCan|) |INTALG;algintegrate;RMIr;22|
              (602 . |retract|))
           '#(|palgintegrate| 607 |palginfieldint| 613 |algintegrate| 619) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 199
                                                 '(0 10 0 11 0 13 0 14 1 15 0
                                                   13 16 1 19 0 10 20 1 8 0 7
                                                   21 1 22 0 8 23 1 10 0 22 24
                                                   1 10 25 0 26 0 27 0 28 2 30
                                                   0 29 27 31 0 6 0 32 0 7 0 33
                                                   0 22 0 34 2 35 0 29 22 36 1
                                                   38 37 0 39 2 38 8 0 37 40 2
                                                   22 0 8 8 41 1 27 42 22 43 3
                                                   35 22 0 37 22 44 3 30 27 0
                                                   37 27 45 0 10 46 47 2 10 0
                                                   35 46 48 2 51 49 10 50 52 1
                                                   27 22 0 53 2 55 35 54 30 56
                                                   1 10 57 0 58 1 59 0 10 60 2
                                                   10 0 0 0 61 3 59 0 10 63 65
                                                   66 2 10 67 0 50 68 2 69 8 10
                                                   50 70 1 8 57 0 71 1 73 72 8
                                                   74 1 77 76 0 78 2 76 0 75 0
                                                   79 2 81 80 0 29 82 1 80 0 0
                                                   83 1 7 0 80 84 5 85 0 10 8 8
                                                   8 7 86 1 81 29 0 87 0 6 0 88
                                                   1 80 57 0 89 1 92 90 91 93 1
                                                   37 0 94 95 2 85 0 37 0 96 2
                                                   85 0 0 0 97 0 85 0 98 2 80 0
                                                   37 37 99 2 101 8 100 81 102
                                                   2 105 103 104 8 106 2 107 8
                                                   104 103 108 1 8 0 0 109 1 8
                                                   110 0 111 2 7 57 0 0 112 2
                                                   19 0 113 0 114 0 19 0 115 2
                                                   19 57 0 0 116 1 19 29 0 117
                                                   0 7 0 118 1 19 0 0 119 1 19
                                                   10 0 120 2 10 0 0 0 121 1 10
                                                   0 0 122 2 19 10 0 10 123 1
                                                   10 0 80 124 2 10 0 0 0 125 3
                                                   19 127 0 0 0 128 0 10 0 129
                                                   2 19 0 10 29 130 2 19 0 0 0
                                                   131 2 19 0 0 0 132 2 19 10 0
                                                   29 133 1 7 0 134 135 2 8 7
                                                   136 7 137 1 10 9 0 138 2 140
                                                   8 139 9 141 2 8 7 0 7 142 1
                                                   7 143 134 144 3 145 103 7 15
                                                   103 146 2 148 19 147 103 149
                                                   2 7 150 0 134 151 1 152 103
                                                   0 153 1 152 103 0 154 1 152
                                                   103 0 155 2 157 9 156 103
                                                   158 1 10 0 9 159 1 73 160 8
                                                   161 1 160 163 0 164 1 85 57
                                                   0 165 1 168 167 85 169 0 8 0
                                                   170 1 80 0 37 171 2 80 0 0 0
                                                   172 1 7 0 143 173 2 8 0 7 29
                                                   174 2 8 0 0 0 175 2 8 176 0
                                                   0 177 1 7 0 143 178 2 85 0 0
                                                   0 179 1 8 29 0 180 1 80 0 0
                                                   181 2 63 0 0 0 182 0 9 0 183
                                                   0 80 0 184 2 19 0 0 0 185 2
                                                   186 19 147 8 187 1 7 134 0
                                                   188 0 81 0 189 1 10 57 0 192
                                                   2 10 0 0 50 193 2 10 0 0 0
                                                   194 1 8 196 0 197 1 8 7 0
                                                   199 2 0 59 10 50 195 2 0 190
                                                   10 50 191 2 0 59 10 50
                                                   198)))))
           '|lookupComplete|)) 
