
(/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=#:G1861 |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| (MAKEARR1 (LETT |n| (QVSIZE |v|) . #2#) (|spadConstant| $ 28))
            . #2#)
      (LETT |vf| (MAKEARR1 |n| (|spadConstant| $ 31)) . #2#)
      (SEQ (LETT |i| (SPADCALL |v| (QREFELT $ 34)) . #2#)
           (LETT #1# (QVSIZE |v|) . #2#) G190 (COND ((> |i| #1#) (GO G191)))
           (SEQ
            (LETT |r|
                  (SPADCALL (SPADCALL (QAREF1O |v| |i| 1) |d| (QREFELT $ 35))
                            (QREFELT $ 37))
                  . #2#)
            (QSETAREF1O |vf| |i| (QCDR |r|) 1)
            (EXIT (QSETAREF1O |vp| |i| (QCAR |r|) 1)))
           (LETT |i| (+ |i| 1) . #2#) (GO G190) G191 (EXIT NIL))
      (LETT |ff|
            (SPADCALL |vf| (LETT |w| (SPADCALL (QREFELT $ 39)) . #2#)
                      (QREFELT $ 41))
            . #2#)
      (LETT |h| (SPADCALL |ff| |derivation| (QREFELT $ 45)) . #2#)
      (LETT |p|
            (SPADCALL (SPADCALL (ELT $ 46) |vp| (QREFELT $ 50)) |w|
                      (QREFELT $ 41))
            . #2#)
      (COND
       ((SPADCALL (QCDR |h|) (QREFELT $ 52))
        (COND
         ((SPADCALL |p| (QREFELT $ 52))
          (EXIT (SPADCALL (QCAR |h|) (QREFELT $ 54)))))))
      (LETT |u| (|INTALG;alglogint| (QCDR |h|) |derivation| $) . #2#)
      (EXIT
       (COND
        ((QEQCAR |u| 1)
         (SPADCALL (QCAR |h|) NIL
                   (LIST
                    (CONS (SPADCALL |p| (QCDR |h|) (QREFELT $ 55))
                          (QREFELT $ 12)))
                   (QREFELT $ 60)))
        ((SPADCALL |p| (QREFELT $ 52))
         (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 60)))
        ('T
         (|error|
          "integrate: implementation incomplete (has polynomial part)")))))))) 

(DEFUN |INTALG;algintprim| (|f| |derivation| $)
  (PROG (|u| |h|)
    (RETURN
     (SEQ
      (LETT |h| (SPADCALL |f| |derivation| (QREFELT $ 45))
            . #1=(|INTALG;algintprim|))
      (EXIT
       (COND
        ((SPADCALL (QCDR |h|) (QREFELT $ 52))
         (SPADCALL (QCAR |h|) (QREFELT $ 54)))
        (#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 $ 60)))
                (#2#
                 (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 60))))))))))))) 

(DEFUN |INTALG;palglogint| (|f| |derivation| $)
  (PROG (|dv0| #1=#:G1949 #2=#:G1948 #3=#:G1950 #4=#:G1961 |a| #5=#:G1962 |dv|
         |g| |cd| |bb| #6=#:G1945 |pp| |ld| #7=#:G1960 |b| #8=#:G1959 |la|
         #9=#:G1958 |q| #10=#:G1957 |fc| |lf| |u| |r| |rec|)
    (RETURN
     (SEQ
      (LETT |rec| (SPADCALL |f| |derivation| (QREFELT $ 62))
            . #11=(|INTALG;palglogint|))
      (EXIT
       (COND
        ((SPADCALL (LETT |r| (SPADCALL |f| |derivation| (QREFELT $ 64)) . #11#)
                   (QREFELT $ 65))
         (CONS 1 "failed"))
        (#12='T
         (SEQ (LETT |u| (SPADCALL |r| (QREFELT $ 68)) . #11#)
              (EXIT
               (COND ((QEQCAR |u| 1) (|INTALG;nonQ| |rec| |r| $))
                     (#12#
                      (SEQ
                       (LETT |fc|
                             (|INTALG;nonLinear|
                              (LETT |lf| (SPADCALL (QCDR |u|) (QREFELT $ 72))
                                    . #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 $ 73))
                                             . #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 $ 77))
                                                 (QREFELT $ 78))
                                                #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 $
                                                                             79))
                                                          (QREFELT $ 81))
                                                #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 $ 82))
                                                          1)
                                                         . #11#)
                                                 (|check-subtype| (>= #6# 0)
                                                                  '(|NonNegativeInteger|)
                                                                  #6#))
                                               (QREFELT $ 77))
                                     . #11#)
                               (QREFELT $ 84))
                              (SEQ
                               (LETT |cd| (SPADCALL |la| (QREFELT $ 88))
                                     . #11#)
                               (LETT |g| (SPADCALL (QCAR |cd|) (QREFELT $ 90))
                                     . #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 $ 91))
                                                    . #11#)
                                              (COND
                                               (#1#
                                                (LETT #2#
                                                      (SPADCALL #2# #3#
                                                                (QREFELT $ 92))
                                                      . #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| $ 93))))
                                     . #11#)
                               (EXIT
                                (|INTALG;trace0| |rec| |pp|
                                 (SPADCALL |g| (QCDR |cd|) (QREFELT $ 94))
                                 |dv0| $))))
                             (#12#
                              (|INTALG;trace1| |rec| |pp| |la| |ld| |bb|
                               $)))))))))))))))))))) 

(DEFUN |INTALG;UPQ2F| (|p| $) (SPADCALL (ELT $ 79) |p| (QREFELT $ 97))) 

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

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

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

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

(DEFUN |INTALG;varRoot?| (|p| |derivation| $)
  (PROG (#1=#:G1971 #2=#:G1973 #3=#:G1974 |c|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (SEQ
         (EXIT
          (SEQ (LETT |c| NIL . #4=(|INTALG;varRoot?|))
               (LETT #3#
                     (SPADCALL (SPADCALL |p| (QREFELT $ 104)) (QREFELT $ 106))
                     . #4#)
               G190
               (COND
                ((OR (ATOM #3#) (PROGN (LETT |c| (CAR #3#) . #4#) NIL))
                 (GO G191)))
               (SEQ
                (EXIT
                 (COND
                  ((NULL
                    (SPADCALL (SPADCALL |c| |derivation|) (|spadConstant| $ 30)
                              (QREFELT $ 107)))
                   (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=#:G2020 |i| |diflog| |numlog| |c| |n|)
    (RETURN
     (SEQ
      (COND
       ((NULL
         (SPADCALL (SPADCALL |derivation| (QVELT |log| 1) (QREFELT $ 109))
                   (|spadConstant| $ 110) (QREFELT $ 111)))
        (|error| "can only handle logs with constant coefficients"))
       ('T
        (SEQ
         (LETT |n| (SPADCALL (QVELT |log| 1) (QREFELT $ 112))
               . #2=(|INTALG;pLogDeriv|))
         (EXIT
          (COND
           ((EQL |n| 1)
            (SEQ
             (LETT |c|
                   (SPADCALL
                    (SPADCALL
                     (SPADCALL (SPADCALL (QVELT |log| 1) (QREFELT $ 114))
                               (QREFELT $ 115))
                     (SPADCALL (QVELT |log| 1) (QREFELT $ 115))
                     (QREFELT $ 116))
                    (QREFELT $ 117))
                   . #2#)
             (LETT |ans| (SPADCALL (QVELT |log| 2) |c| (QREFELT $ 118)) . #2#)
             (EXIT
              (SPADCALL
               (SPADCALL
                (SPADCALL (SPADCALL (QVELT |log| 0) (QREFELT $ 119)) |c|
                          (QREFELT $ 120))
                (SPADCALL |ans| |derivation|) (QREFELT $ 120))
               |ans| (QREFELT $ 116)))))
           (#3='T
            (SEQ
             (LETT |numlog|
                   (SPADCALL |derivation| (QVELT |log| 2) (QREFELT $ 109))
                   . #2#)
             (LETT |diflog|
                   (SPADCALL (QVELT |log| 2) (QVELT |log| 1) |numlog|
                             (QREFELT $ 123))
                   . #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| $ 124) 1
                                                  (QREFELT $ 125))
                                                 (QREFELT $ 126))
                                       (QVELT |log| 1) (QREFELT $ 127))
                                      . #2#)
                                (EXIT
                                 (LETT |ans|
                                       (SPADCALL |ans|
                                                 (SPADCALL |algans| |i|
                                                           (QREFELT $ 128))
                                                 (QREFELT $ 55))
                                       . #2#)))
                               (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191
                               (EXIT NIL))
                          (EXIT
                           (SPADCALL (SPADCALL (QVELT |log| 0) (QREFELT $ 119))
                                     |ans| (QREFELT $ 120)))))))))))))))))) 

(DEFUN |INTALG;R2UP| (|f| |k| $)
  (PROG (|g| |y| |x|)
    (RETURN
     (SEQ
      (LETT |x| (SPADCALL (QREFELT $ 17) (QREFELT $ 130)) . #1=(|INTALG;R2UP|))
      (LETT |g|
            (SPADCALL
             (SPADCALL (CONS #'|INTALG;R2UP!0| (VECTOR $ |x|))
                       (SPADCALL |f| (QREFELT $ 133)) (QREFELT $ 136))
             (LETT |y| (SPADCALL (QREFELT $ 18) (QREFELT $ 130)) . #1#)
             (QREFELT $ 137))
            . #1#)
      (EXIT
       (SPADCALL
        (CONS #'|INTALG;R2UP!1| (VECTOR $ (QREFELT $ 18) (QREFELT $ 17)))
        (SPADCALL |g| |k| (SPADCALL |k| (QREFELT $ 139)) (QREFELT $ 141))
        (QREFELT $ 144))))))) 

(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 $ 132)))))) 

(DEFUN |INTALG;univ| (|f| |k| $)
  (PROG (|g|)
    (RETURN
     (SEQ (LETT |g| (SPADCALL |f| |k| (QREFELT $ 146)) |INTALG;univ|)
          (EXIT
           (SPADCALL (|INTALG;SUP2UP| (SPADCALL |g| (QREFELT $ 148)) $)
                     (|INTALG;SUP2UP| (SPADCALL |g| (QREFELT $ 149)) $)
                     (QREFELT $ 35))))))) 

(DEFUN |INTALG;rlift| (|f| |kx| |ky| $)
  (PROG ()
    (RETURN
     (SPADCALL
      (SPADCALL (CONS #'|INTALG;rlift!0| (VECTOR $ |kx|))
                (SPADCALL (SPADCALL |f| |ky| (QREFELT $ 146)) (QREFELT $ 150))
                (QREFELT $ 153))
      (QREFELT $ 154))))) 

(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 $ 104)) (QREFELT $ 156))
                (QREFELT $ 159))
               |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 $ 160)) NIL)
                  (#1='T
                   (SEQ
                    (LETT |rc0| (SPADCALL |dv0| (QREFELT $ 164))
                          . #2=(|INTALG;trace0|))
                    (EXIT
                     (COND
                      ((QEQCAR |rc0| 1)
                       (|error|
                        "Not integrable (provided residues have no relations)"))
                      (#1#
                       (|INTALG;mkLog| (|spadConstant| $ 165)
                        (SPADCALL |r|
                                  (SPADCALL (QCAR (QCDR |rc0|))
                                            (QREFELT $ 166))
                                  (QREFELT $ 167))
                        (QCDR (QCDR |rc0|)) (|spadConstant| $ 113) $)))))))
            . #2#)
      (EXIT (|INTALG;trace00| |rec| |q| |lg| $)))))) 

(DEFUN |INTALG;trace00| (|rec| |pp| |lg| $)
  (PROG (|rc| |dvr| |alpha| |q| #1=#:G2071 |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 $ 168))
                            . #2=(|INTALG;trace00|))
                      (QREFELT $ 81))
            . #2#)
      (LETT |q|
            (PROG2
                (LETT #1#
                      (SPADCALL |pp|
                                (SPADCALL
                                 (SPADCALL (|spadConstant| $ 113) 1
                                           (QREFELT $ 169))
                                 (SPADCALL |alpha0| (QREFELT $ 21))
                                 (QREFELT $ 170))
                                (QREFELT $ 172))
                      . #2#)
                (QCDR #1#)
              (|check-union| (QEQCAR #1# 0) (QREFELT $ 8) #1#))
            . #2#)
      (LETT |alpha| (SPADCALL (|INTALG;UP2SUP| |q| $) (QREFELT $ 173)) . #2#)
      (LETT |dvr|
            (SPADCALL
             (SPADCALL (QVELT |rec| 0) (QVELT |rec| 1) (QVELT |rec| 2)
                       (QVELT |rec| 3) |alpha| (QREFELT $ 81))
             |p0| (QREFELT $ 174))
            . #2#)
      (LETT |rc| (SPADCALL |dvr| (QREFELT $ 164)) . #2#)
      (EXIT
       (COND
        ((QEQCAR |rc| 1)
         (COND ((NULL (< 2 (SPADCALL |pp| (QREFELT $ 175)))) (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 $ 166))
                           (QREFELT $ 176))
                          (QCDR (QCDR |rc|)) |alpha| $)
                         (QREFELT $ 177)))))))))) 

(DEFUN |INTALG;trace1| (|rec| |q| |la| |ld| |b| $)
  (PROG (|rc| |v| |alpha| |v0| #1=#:G2097 #2=#:G2096 #3=#:G2098 #4=#:G2109 |a|
         #5=#:G2110 |dv| |cd| #6=#:G2108 #7=#:G2107)
    (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 $ 167)) #7#)
                           . #8#)))
                   (LETT #6# (CDR #6#) . #8#) #10=(GO G190) G191
                   (EXIT (NREVERSE0 #7#))))
             (QREFELT $ 88))
            . #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 $ 91)) . #8#)
                     (COND
                      (#1# (LETT #2# (SPADCALL #2# #3# (QREFELT $ 92)) . #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| $ 93))))
            . #8#)
      (LETT |alpha| (SPADCALL (|INTALG;UP2SUP| |q| $) (QREFELT $ 173)) . #8#)
      (LETT |v|
            (SPADCALL |v0|
                      (SPADCALL (QCDR |cd|)
                                (SPADCALL (QVELT |rec| 0) (QVELT |rec| 1)
                                          (QVELT |rec| 2) (QVELT |rec| 3)
                                          |alpha| (QREFELT $ 81))
                                (QREFELT $ 91))
                      (QREFELT $ 174))
            . #8#)
      (LETT |rc| (SPADCALL |v| (QREFELT $ 164)) . #8#)
      (EXIT
       (COND
        ((QEQCAR |rc| 1)
         (COND ((NULL (< 2 (SPADCALL |q| (QREFELT $ 175)))) (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 $ 166))
                 (QREFELT $ 176))
                (QCDR (QCDR |rc|)) |alpha| $))))))))) 

(DEFUN |INTALG;mkLog| (|q| |scalr| |lgd| |alpha| $)
  (COND
   ((NULL (< 1 (SPADCALL |q| (QREFELT $ 175))))
    (LIST
     (VECTOR |scalr|
             (SPADCALL (SPADCALL (|spadConstant| $ 124) 1 (QREFELT $ 125))
                       (|INTALG;F2UPR| |alpha| $) (QREFELT $ 180))
             (SPADCALL |lgd| (QREFELT $ 20)))))
   ('T
    (LIST
     (VECTOR |scalr|
             (SPADCALL (CONS (|function| |INTALG;F2R|) $) |q| (QREFELT $ 182))
             (|INTALG;R2UP| |lgd| (SPADCALL |alpha| (QREFELT $ 183)) $)))))) 

(DEFUN |INTALG;nonLinear| (|l| $)
  (PROG (|ans| |found| #1=#:G2124 #2=#:G2125 |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 $ 82)))
                     (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 $ 45))
            |INTALG;palginfieldint;RMU;20|)
      (EXIT
       (COND ((SPADCALL (QCDR |h|) (QREFELT $ 52)) (CONS 0 (QCAR |h|)))
             ('T (CONS 1 "failed")))))))) 

(DEFUN |INTALG;palgintegrate;RMIr;21| (|f| |derivation| $)
  (PROG (|difFirstKind| #1=#:G2272 #2=#:G2271 #3=#:G2273 #4=#:G2279 |lg|
         #5=#:G2276 |u| |h|)
    (RETURN
     (SEQ
      (LETT |h| (SPADCALL |f| |derivation| (QREFELT $ 45))
            . #6=(|INTALG;palgintegrate;RMIr;21|))
      (EXIT
       (COND
        ((SPADCALL (QCDR |h|) (QREFELT $ 52))
         (SPADCALL (QCAR |h|) (QREFELT $ 54)))
        (#7='T
         (SEQ
          (EXIT
           (SEQ
            (COND
             ((SPADCALL (QCDR |h|) (QREFELT $ 187))
              (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 $ 60))
                         . #6#)
                   (GO #5#)))))))
             (#7#
              (EXIT
               (SPADCALL (QCAR |h|) NIL (LIST (CONS (QCDR |h|) (QREFELT $ 12)))
                         (QREFELT $ 60)))))
            (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 $ 55))
                                                 . #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 $ 189))
                      . #6#)
                (QREFELT $ 52))
               (SPADCALL (QCAR |h|) (QCDR |u|) NIL (QREFELT $ 60)))
              (#7#
               (SPADCALL (QCAR |h|) (QCDR |u|)
                         (LIST (CONS |difFirstKind| (QREFELT $ 12)))
                         (QREFELT $ 60)))))))
          #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 $ 188)))))) 

(DEFUN |INTALG;algintegrate;RMIr;22| (|f| |derivation| $)
  (PROG (#1=#:G2293 |xx| |x'| |x|)
    (RETURN
     (SEQ
      (COND
       ((ZEROP
         (SPADCALL
          (LETT |x'|
                (SPADCALL
                 (LETT |x| (SPADCALL (|spadConstant| $ 113) 1 (QREFELT $ 169))
                       . #2=(|INTALG;algintegrate;RMIr;22|))
                 |derivation|)
                . #2#)
          (QREFELT $ 175)))
        (|INTALG;algintprim| |f| |derivation| $))
       ('T
        (SEQ
         (EXIT
          (SEQ
           (SEQ (LETT |xx| (SPADCALL |x'| |x| (QREFELT $ 172)) . #2#)
                (EXIT
                 (COND
                  ((QEQCAR |xx| 0)
                   (COND
                    ((QEQCAR (SPADCALL (QCDR |xx|) (QREFELT $ 192)) 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 $ 64))
        (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 $ 194)))))) 

(DEFUN |AlgebraicIntegrate| (&REST #1=#:G2304)
  (PROG ()
    (RETURN
     (PROG (#2=#:G2305)
       (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 195) . #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| 33) (|:| |den| 8))
              (33 . |integralCoordinates|) (|LaurentPolynomial| 7 8)
              (38 . |Zero|) (42 . |Zero|) (46 . |Zero|) (50 . |Zero|)
              (|Integer|) (|Vector| 8) (54 . |minIndex|) (59 . /)
              (|Record| (|:| |polyPart| $) (|:| |fracPart| 22))
              (65 . |separate|) (|Vector| $) (70 . |integralBasis|)
              (|Vector| 22) (74 . |represents|)
              (|Record| (|:| |answer| 10) (|:| |logpart| 10)) (|Mapping| 8 8)
              (|AlgebraicHermiteIntegration| 7 8 9 10)
              (80 . |HermiteIntegrate|) (86 . |convert|) (|Mapping| 22 27)
              (|Vector| 27) (|VectorFunctions2| 27 22) (91 . |map|) (|Boolean|)
              (97 . |zero?|) (|IntegrationResult| 10) (102 . |coerce|)
              (107 . +)
              (|Record| (|:| |scalar| 74) (|:| |coeff| 19) (|:| |logand| 19))
              (|List| 56) (|Record| (|:| |integrand| 10) (|:| |intvar| 10))
              (|List| 58) (113 . |mkAnswer|)
              (|Record| (|:| |num| $) (|:| |den| 8) (|:| |derivden| 8)
                        (|:| |gd| 8))
              (120 . |algSplitSimple|) (|DoubleResultantPackage| 7 8 9 10)
              (126 . |doubleResultant|) (132 . |ground?|)
              (|Union| 71 '"failed")
              (|FunctionSpaceUnivariatePolynomialFactor| 6 7 8)
              (137 . |qfactor|)
              (|Record| (|:| |factor| 76) (|:| |exponent| 32)) (|List| 69)
              (|Factored| 76) (142 . |factors|) (147 . |remove!|)
              (|Fraction| 32) (|NonNegativeInteger|)
              (|SparseUnivariatePolynomial| 74) (153 . |coefficient|) (159 . -)
              (164 . |coerce|) (|FiniteDivisor| 7 8 9 10) (169 . |divisor|)
              (178 . |degree|) (183 . |One|) (187 . |zero?|)
              (|Record| (|:| |num| (|List| 32)) (|:| |den| 32)) (|List| 74)
              (|InnerCommonDenominator| 32 74 (|List| 32) 86)
              (192 . |splitDenominator|) (|List| $) (197 . |gcd|) (202 . *)
              (208 . +) (214 . |Zero|) (218 . /) (|Mapping| 7 74)
              (|UnivariatePolynomialCategoryFunctions2| 74 76 7 8)
              (224 . |map|) (|SparseUnivariatePolynomial| 7) (|Mapping| 7 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 8 7 98) (230 . |map|)
              (|UnivariatePolynomialCategoryFunctions2| 7 98 7 8) (236 . |map|)
              (242 . |primitivePart|) (|List| 7) (247 . |coefficients|)
              (252 . =) (|Mapping| 10 10) (258 . |map|) (264 . |Zero|)
              (268 . =) (274 . |degree|) (279 . |One|) (283 . |reductum|)
              (288 . |leadingCoefficient|) (293 . /) (299 . -) (304 . |elt|)
              (310 . |coerce|) (315 . *)
              (|Record| (|:| |coef1| $) (|:| |coef2| $))
              (|Union| 121 '"failed") (321 . |extendedEuclidean|) (328 . |One|)
              (332 . |monomial|) (338 . *) (344 . |rem|) (350 . |coefficient|)
              (|Kernel| $) (356 . |coerce|) (|Fraction| $) (361 . |elt|)
              (367 . |lift|) (|Mapping| 7 22)
              (|UnivariatePolynomialCategoryFunctions2| 22 9 7 8) (372 . |map|)
              (378 . |elt|) (|SparseUnivariatePolynomial| $) (384 . |minPoly|)
              (|PolynomialCategoryQuotientFunctions| (|IndexedExponents| 15) 15
                                                     6
                                                     (|SparseMultivariatePolynomial|
                                                      6 15)
                                                     7)
              (389 . |univariate|) (|Mapping| 10 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 98 10 19)
              (396 . |map|) (|Fraction| 138) (402 . |univariate|)
              (|Fraction| 98) (408 . |numer|) (413 . |denom|) (418 . |retract|)
              (|Mapping| 22 7)
              (|UnivariatePolynomialCategoryFunctions2| 7 98 22 9)
              (423 . |map|) (429 . |reduce|) (|Factored| 8) (434 . |ffactor|)
              (|Record| (|:| |factor| 8) (|:| |exponent| 32)) (|List| 157)
              (439 . |factors|) (444 . |zero?|)
              (|Record| (|:| |order| 75) (|:| |function| 10))
              (|Union| 161 '"failed") (|PointsOfFiniteOrder| 6 7 8 9 10)
              (449 . |torsionIfCan|) (454 . |One|) (458 . |coerce|) (463 . /)
              (469 . |zeroOf|) (474 . |monomial|) (480 . -)
              (|Union| $ '"failed") (486 . |exquo|) (492 . |rootOf|) (497 . -)
              (503 . |degree|) (508 . |inv|) (513 . |concat|) (519 . |One|)
              (523 . |One|) (527 . -)
              (|UnivariatePolynomialCategoryFunctions2| 7 8 10 19)
              (533 . |map|) (539 . |retract|) (544 . |One|)
              (|Union| 10 '"failed") |INTALG;palginfieldint;RMU;20|
              (548 . |integralAtInfinity?|) (553 . |differentiate|) (559 . -)
              |INTALG;palgintegrate;RMIr;21| (|Union| 7 '"failed")
              (565 . |retractIfCan|) |INTALG;algintegrate;RMIr;22|
              (570 . |retract|))
           '#(|palgintegrate| 575 |palginfieldint| 581 |algintegrate| 587) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 194
                                                 '(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 0 6 0
                                                   29 0 7 0 30 0 22 0 31 1 33
                                                   32 0 34 2 22 0 8 8 35 1 27
                                                   36 22 37 0 10 38 39 2 10 0
                                                   40 38 41 2 44 42 10 43 45 1
                                                   27 22 0 46 2 49 40 47 48 50
                                                   1 10 51 0 52 1 53 0 10 54 2
                                                   10 0 0 0 55 3 53 0 10 57 59
                                                   60 2 10 61 0 43 62 2 63 8 10
                                                   43 64 1 8 51 0 65 1 67 66 8
                                                   68 1 71 70 0 72 2 70 0 69 0
                                                   73 2 76 74 0 75 77 1 74 0 0
                                                   78 1 7 0 74 79 5 80 0 10 8 8
                                                   8 7 81 1 76 75 0 82 0 6 0 83
                                                   1 74 51 0 84 1 87 85 86 88 1
                                                   32 0 89 90 2 80 0 32 0 91 2
                                                   80 0 0 0 92 0 80 0 93 2 74 0
                                                   32 32 94 2 96 8 95 76 97 2
                                                   100 98 99 8 101 2 102 8 99
                                                   98 103 1 8 0 0 104 1 8 105 0
                                                   106 2 7 51 0 0 107 2 19 0
                                                   108 0 109 0 19 0 110 2 19 51
                                                   0 0 111 1 19 75 0 112 0 7 0
                                                   113 1 19 0 0 114 1 19 10 0
                                                   115 2 10 0 0 0 116 1 10 0 0
                                                   117 2 19 10 0 10 118 1 10 0
                                                   74 119 2 10 0 0 0 120 3 19
                                                   122 0 0 0 123 0 10 0 124 2
                                                   19 0 10 75 125 2 19 0 0 0
                                                   126 2 19 0 0 0 127 2 19 10 0
                                                   75 128 1 7 0 129 130 2 8 7
                                                   131 7 132 1 10 9 0 133 2 135
                                                   8 134 9 136 2 8 7 0 7 137 1
                                                   7 138 129 139 3 140 98 7 15
                                                   98 141 2 143 19 142 98 144 2
                                                   7 145 0 129 146 1 147 98 0
                                                   148 1 147 98 0 149 1 147 98
                                                   0 150 2 152 9 151 98 153 1
                                                   10 0 9 154 1 67 155 8 156 1
                                                   155 158 0 159 1 80 51 0 160
                                                   1 163 162 80 164 0 8 0 165 1
                                                   74 0 32 166 2 74 0 0 0 167 1
                                                   7 0 138 168 2 8 0 7 75 169 2
                                                   8 0 0 0 170 2 8 171 0 0 172
                                                   1 7 0 138 173 2 80 0 0 0 174
                                                   1 8 75 0 175 1 74 0 0 176 2
                                                   57 0 0 0 177 0 9 0 178 0 74
                                                   0 179 2 19 0 0 0 180 2 181
                                                   19 142 8 182 1 7 129 0 183 0
                                                   76 0 184 1 10 51 0 187 2 10
                                                   0 0 43 188 2 10 0 0 0 189 1
                                                   8 191 0 192 1 8 7 0 194 2 0
                                                   53 10 43 190 2 0 185 10 43
                                                   186 2 0 53 10 43 193)))))
           '|lookupComplete|)) 
