
(/VERSIONCHECK 2) 

(DEFUN |PADE;constInner| (|up| $) (CONS 0 (CONS (LIST |up|) NIL))) 

(DEFUN |PADE;truncPoly| (|p| |n| $)
  (SEQ (SEQ G190
            (COND
              ((NULL (< |n| (SPADCALL |p| (QREFELT $ 10)))) (GO G191)))
            (SEQ (EXIT (LETT |p| (SPADCALL |p| (QREFELT $ 11))
                             |PADE;truncPoly|)))
            NIL (GO G190) G191 (EXIT NIL))
       (EXIT |p|))) 

(DEFUN |PADE;truncSeries| (|s| |n| $)
  (PROG (|i| |p|)
    (RETURN
      (SEQ (LETT |p| (|spadConstant| $ 12) . #0=(|PADE;truncSeries|))
           (SEQ (LETT |i| 0 . #0#) G190
                (COND ((QSGREATERP |i| |n|) (GO G191)))
                (SEQ (EXIT (LETT |p|
                                 (SPADCALL |p|
                                     (SPADCALL
                                      (SPADCALL |s| |i| (QREFELT $ 13))
                                      |i| (QREFELT $ 14))
                                     (QREFELT $ 15)) . #0#)))
                (LETT |i| (QSADD1 |i|) . #0#) (GO G190) G191
                (EXIT NIL))
           (EXIT |p|))))) 

(DEFUN |PADE;divOutDegree| (|s| |n| $)
  (PROG (|i|)
    (RETURN
      (SEQ (SEQ (LETT |i| 1 . #0=(|PADE;divOutDegree|)) G190
                (COND ((QSGREATERP |i| |n|) (GO G191)))
                (SEQ (EXIT (LETT |s|
                                 (SPADCALL |s| (QREFELT $ 16)) . #0#)))
                (LETT |i| (QSADD1 |i|) . #0#) (GO G190) G191
                (EXIT NIL))
           (EXIT |s|))))) 

(DEFUN |PADE;pade;2Nni2PSU;5| (|l| |m| |gps| |dps| $)
  (PROG (|ad| |plist| |dlist| |p| #0=#:G1848 |d| #1=#:G1847 |approx|)
    (RETURN
      (SEQ (LETT |ad| (|PADE;padeNormalize| |l| |m| |gps| |dps| $)
                 . #2=(|PADE;pade;2Nni2PSU;5|))
           (EXIT (COND
                   ((QEQCAR |ad| 1) (CONS 1 "failed"))
                   ('T
                    (SEQ (LETT |plist| (QCAR (QCDR |ad|)) . #2#)
                         (LETT |dlist| (QCDR (QCDR |ad|)) . #2#)
                         (LETT |approx|
                               (SPADCALL (|SPADfirst| |plist|)
                                   (QREFELT $ 18)) . #2#)
                         (SEQ (LETT |p| NIL . #2#)
                              (LETT #0# (CDR |plist|) . #2#)
                              (LETT |d| NIL . #2#)
                              (LETT #1# |dlist| . #2#) G190
                              (COND
                                ((OR (ATOM #1#)
                                     (PROGN
                                       (LETT |d| (CAR #1#) . #2#)
                                       NIL)
                                     (ATOM #0#)
                                     (PROGN
                                       (LETT |p| (CAR #0#) . #2#)
                                       NIL))
                                 (GO G191)))
                              (SEQ (EXIT
                                    (LETT |approx|
                                     (SPADCALL
                                      (SPADCALL |p| (QREFELT $ 18))
                                      (SPADCALL
                                       (SPADCALL
                                        (SPADCALL (|spadConstant| $ 19)
                                         |d| (QREFELT $ 14))
                                        (QREFELT $ 18))
                                       |approx| (QREFELT $ 21))
                                      (QREFELT $ 22)) . #2#)))
                              (LETT #1#
                                    (PROG1 (CDR #1#)
                                      (LETT #0# (CDR #0#) . #2#)) . #2#)
                              (GO G190) G191 (EXIT NIL))
                         (EXIT (CONS 0 |approx|)))))))))) 

(DEFUN |PADE;padecf;2Nni2PSU;6| (|l| |m| |gps| |dps| $)
  (PROG (|ad| |alist| #0=#:G1859 |d| #1=#:G1860 |blist|)
    (RETURN
      (SEQ (LETT |ad| (|PADE;padeNormalize| |l| |m| |gps| |dps| $)
                 . #2=(|PADE;padecf;2Nni2PSU;6|))
           (EXIT (COND
                   ((QEQCAR |ad| 1) (CONS 1 "failed"))
                   ('T
                    (SEQ (LETT |alist|
                               (REVERSE (QCAR (QCDR |ad|))) . #2#)
                         (LETT |blist|
                               (PROGN
                                 (LETT #0# NIL . #2#)
                                 (SEQ (LETT |d| NIL . #2#)
                                      (LETT #1#
                                       (REVERSE (QCDR (QCDR |ad|))) . #2#)
                                      G190
                                      (COND
                                        ((OR (ATOM #1#)
                                          (PROGN
                                            (LETT |d| (CAR #1#) . #2#)
                                            NIL))
                                         (GO G191)))
                                      (SEQ
                                       (EXIT
                                        (LETT #0#
                                         (CONS
                                          (SPADCALL
                                           (|spadConstant| $ 19) |d|
                                           (QREFELT $ 14))
                                          #0#) . #2#)))
                                      (LETT #1# (CDR #1#) . #2#)
                                      (GO G190) G191
                                      (EXIT (NREVERSE0 #0#)))) . #2#)
                         (EXIT (CONS 0
                                     (SPADCALL (|SPADfirst| |alist|)
                                      (SPADCALL |blist| (QREFELT $ 27))
                                      (SPADCALL (CDR |alist|)
                                       (QREFELT $ 27))
                                      (QREFELT $ 29)))))))))))) 

(DEFUN |PADE;padeNormalize| (|l| |m| |gps| |dps| $)
  (PROG (|ldeg|)
    (RETURN
      (SEQ (COND
             ((SPADCALL |dps| (QREFELT $ 33)) (CONS 1 "failed"))
             ((SPADCALL |gps| (QREFELT $ 33))
              (|PADE;constInner| (|spadConstant| $ 12) $))
             ('T
              (SEQ (LETT |ldeg|
                         (MIN (SPADCALL |dps| (QREFELT $ 34))
                              (SPADCALL |gps| (QREFELT $ 34)))
                         . #0=(|PADE;padeNormalize|))
                   (COND
                     ((< 0 |ldeg|)
                      (SEQ (LETT |dps|
                                 (|PADE;divOutDegree| |dps| |ldeg| $) . #0#)
                           (EXIT (LETT |gps|
                                       (|PADE;divOutDegree| |gps|
                                        |ldeg| $) . #0#)))))
                   (EXIT (|PADE;padeInner| |l| |m| |gps| |dps| $))))))))) 

(DEFUN |PADE;padeInner| (|l| |m| |gps| |dps| $)
  (PROG (|#G33| |#G34| |#G35| |#G36| |#G37| #0=#:G1870 |#G38| |#G39|
                |#G40| |j| |d0| #1=#:G1873 |k| |pk| #2=#:G1874 |p| |s|
                |plist| |alpha| #3=#:G1890 |alist| #4=#:G1879 |h|
                #5=#:G1883 |degbd| |g| |d| |#G43| #6=#:G1884 |#G44|)
    (RETURN
      (SEQ (EXIT (SEQ (COND
                        ((SPADCALL (SPADCALL |gps| 0 (QREFELT $ 13))
                             (QREFELT $ 37))
                         (COND
                           ((SPADCALL (SPADCALL |dps| 0 (QREFELT $ 13))
                                (QREFELT $ 37))
                            (EXIT (|error| "Pade' problem not normalized."))))))
                      (LETT |plist| NIL . #7=(|PADE;padeInner|))
                      (LETT |alist| NIL . #7#)
                      (COND
                        ((SPADCALL (SPADCALL |dps| 0 (QREFELT $ 13))
                             (QREFELT $ 37))
                         (SEQ (PROGN
                                (LETT |#G33| |dps| . #7#)
                                (LETT |#G34| |gps| . #7#)
                                (LETT |gps| |#G33| . #7#)
                                (LETT |dps| |#G34| . #7#))
                              (PROGN
                                (LETT |#G35| |m| . #7#)
                                (LETT |#G36| |l| . #7#)
                                (LETT |l| |#G35| . #7#)
                                (LETT |m| |#G36| . #7#))
                              (LETT |plist|
                                    (CONS (|spadConstant| $ 12)
                                     |plist|) . #7#)
                              (EXIT (LETT |alist|
                                     (CONS 0 |alist|) . #7#)))))
                      (COND
                        ((< |l| |m|)
                         (SEQ (LETT |alpha|
                                    (SPADCALL |gps| (QREFELT $ 34)) . #7#)
                              (COND
                                ((< |l| |alpha|)
                                 (PROGN
                                   (LETT #3# (CONS 1 "failed") . #7#)
                                   (GO #3#))))
                              (LETT |gps|
                                    (|PADE;divOutDegree| |gps| |alpha|
                                     $) . #7#)
                              (PROGN
                                (LETT |#G37| |m| . #7#)
                                (LETT |#G38|
                                      (PROG1
                                       (LETT #0# (- |l| |alpha|) . #7#)
                                        (|check-subtype| (>= #0# 0)
                                         '(|NonNegativeInteger|) #0#)) . #7#)
                                (LETT |l| |#G37| . #7#)
                                (LETT |m| |#G38| . #7#))
                              (PROGN
                                (LETT |#G39| |dps| . #7#)
                                (LETT |#G40| |gps| . #7#)
                                (LETT |gps| |#G39| . #7#)
                                (LETT |dps| |#G40| . #7#))
                              (LETT |plist|
                                    (CONS (|spadConstant| $ 12)
                                     |plist|) . #7#)
                              (EXIT (LETT |alist|
                                     (CONS |alpha| |alist|) . #7#)))))
                      (LETT |degbd| (+ (+ |l| |m|) 1) . #7#)
                      (LETT |g|
                            (|PADE;truncSeries| |gps| |degbd| $) . #7#)
                      (LETT |d|
                            (|PADE;truncSeries| |dps| |degbd| $) . #7#)
                      (EXIT (SEQ (LETT |j| 0 . #7#) G190 NIL
                                 (SEQ (LETT |d0|
                                       (SPADCALL |d| 0 (QREFELT $ 38)) . #7#)
                                      (LETT |d|
                                       (SPADCALL
                                        (SPADCALL (|spadConstant| $ 39)
                                         |d0| (QREFELT $ 40))
                                        |d| (QREFELT $ 41)) . #7#)
                                      (LETT |g|
                                       (SPADCALL
                                        (SPADCALL (|spadConstant| $ 39)
                                         |d0| (QREFELT $ 40))
                                        |g| (QREFELT $ 41)) . #7#)
                                      (LETT |p|
                                       (|spadConstant| $ 12) . #7#)
                                      (LETT |s| |g| . #7#)
                                      (COND
                                        ((< (+ (- |l| |m|) 1) 0)
                                         (|error|
                                          "Internal pade error")))
                                      (LETT |degbd|
                                       (PROG1
                                        (LETT #1#
                                         (+ (- |l| |m|) 1) . #7#)
                                         (|check-subtype| (>= #1# 0)
                                          '(|NonNegativeInteger|) #1#)) . #7#)
                                      (SEQ (LETT |k| 1 . #7#) G190
                                       (COND
                                         ((QSGREATERP |k| |degbd|)
                                          (GO G191)))
                                       (SEQ
                                        (LETT |pk|
                                         (SPADCALL |s| 0
                                          (QREFELT $ 38)) . #7#)
                                        (LETT |p|
                                         (SPADCALL |p|
                                          (SPADCALL |pk|
                                           (PROG1
                                            (LETT #2# (- |k| 1) . #7#)
                                             (|check-subtype|
                                              (>= #2# 0)
                                              '(|NonNegativeInteger|)
                                              #2#))
                                           (QREFELT $ 14))
                                          (QREFELT $ 15)) . #7#)
                                        (LETT |s|
                                         (SPADCALL |s|
                                          (SPADCALL |pk| |d|
                                           (QREFELT $ 42))
                                          (QREFELT $ 43)) . #7#)
                                        (EXIT
                                         (LETT |s|
                                          (PROG2
                                           (LETT #4#
                                            (SPADCALL |s|
                                             (SPADCALL
                                              (|spadConstant| $ 19) 1
                                              (QREFELT $ 14))
                                             (QREFELT $ 46)) . #7#)
                                           (QCDR #4#)
                                            (|check-union|
                                             (QEQCAR #4# 0)
                                             (QREFELT $ 8) #4#)) . #7#)))
                                       (LETT |k| (QSADD1 |k|) . #7#)
                                       #8=(GO G190) G191 (EXIT NIL))
                                      (LETT |plist|
                                       (CONS |p| |plist|) . #7#)
                                      (EXIT
                                       (COND
                                         ((SPADCALL |s|
                                           (|spadConstant| $ 12)
                                           (QREFELT $ 47))
                                          (PROGN
                                            (LETT #3#
                                             (CONS 0
                                              (CONS |plist| |alist|)) . #7#)
                                            (GO #3#)))
                                         ('T
                                          (SEQ
                                           (LETT |alpha|
                                            (+
                                             (SPADCALL |s|
                                              (QREFELT $ 48))
                                             |degbd|) . #7#)
                                           (EXIT
                                            (COND
                                              ((< (+ |l| |m|) |alpha|)
                                               (PROGN
                                                 (LETT #3#
                                                  (CONS 0
                                                   (CONS |plist|
                                                    |alist|)) . #7#)
                                                 (GO #3#)))
                                              ((< |l| |alpha|)
                                               (PROGN
                                                 (LETT #3#
                                                  (CONS 1 "failed") . #7#)
                                                 (GO #3#)))
                                              ('T
                                               (SEQ
                                                (LETT |alist|
                                                 (CONS |alpha| |alist|) . #7#)
                                                (LETT |h|
                                                 (PROG2
                                                  (LETT #4#
                                                   (SPADCALL |s|
                                                    (SPADCALL
                                                     (|spadConstant| $
                                                      19)
                                                     (SPADCALL |s|
                                                      (QREFELT $ 48))
                                                     (QREFELT $ 14))
                                                    (QREFELT $ 46)) . #7#)
                                                  (QCDR #4#)
                                                   (|check-union|
                                                    (QEQCAR #4# 0)
                                                    (QREFELT $ 8) #4#)) . #7#)
                                                (LETT |degbd|
                                                 (PROG1
                                                  (LETT #5#
                                                   (- (+ |l| |m|)
                                                    |alpha|) . #7#)
                                                   (|check-subtype|
                                                    (>= #5# 0)
                                                    '(|NonNegativeInteger|)
                                                    #5#)) . #7#)
                                                (LETT |g|
                                                 (|PADE;truncPoly| |d|
                                                  |degbd| $) . #7#)
                                                (LETT |d|
                                                 (|PADE;truncPoly| |h|
                                                  |degbd| $) . #7#)
                                                (EXIT
                                                 (PROGN
                                                   (LETT |#G43|
                                                    |m| . #7#)
                                                   (LETT |#G44|
                                                    (PROG1
                                                     (LETT #6#
                                                      (- |l| |alpha|) . #7#)
                                                      (|check-subtype|
                                                       (>= #6# 0)
                                                       '(|NonNegativeInteger|)
                                                       #6#)) . #7#)
                                                   (LETT |l|
                                                    |#G43| . #7#)
                                                   (LETT |m|
                                                    |#G44| . #7#))))))))))))
                                 (LETT |j| (QSADD1 |j|) . #7#) #8# G191
                                 (EXIT NIL)))))
           #3# (EXIT #3#))))) 

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

(DEFUN |PadeApproximants;| (|#1| |#2| |#3|)
  (PROG (DV$1 DV$2 DV$3 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|PadeApproximants|))
        (LETT DV$2 (|devaluate| |#2|) . #0#)
        (LETT DV$3 (|devaluate| |#3|) . #0#)
        (LETT |dv$| (LIST '|PadeApproximants| DV$1 DV$2 DV$3) . #0#)
        (LETT $ (GETREFV 49) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|PadeApproximants|
            (LIST DV$1 DV$2 DV$3) (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 7 |#2|)
        (QSETREFV $ 8 |#3|)
        $)))) 

(MAKEPROP '|PadeApproximants| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
             (|local| |#3|) (|NonNegativeInteger|) (0 . |degree|)
             (5 . |reductum|) (10 . |Zero|) (14 . |coefficient|)
             (20 . |monomial|) (26 . +) (32 . |quoByVar|)
             (|Fraction| 8) (37 . |coerce|) (42 . |One|) (46 . |One|)
             (50 . /) (56 . +) (|Union| 17 '"failed")
             |PADE;pade;2Nni2PSU;5| (|List| 8) (|Stream| 8)
             (62 . |coerce|) (|ContinuedFraction| 8)
             (67 . |continuedFraction|) (|Union| 28 '"failed")
             |PADE;padecf;2Nni2PSU;6| (|Boolean|) (74 . |zero?|)
             (79 . |order|) (84 . |Zero|) (88 . |Zero|) (92 . |zero?|)
             (97 . |coefficient|) (103 . |One|) (107 . /) (113 . *)
             (119 . *) (125 . -) (131 . |monomial|)
             (|Union| $ '"failed") (137 . |exquo|) (143 . =)
             (149 . |minimumDegree|))
          '#(|padecf| 154 |pade| 162) 'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 48
                                '(1 8 9 0 10 1 8 0 0 11 0 8 0 12 2 7 6
                                  0 9 13 2 8 0 6 9 14 2 8 0 0 0 15 1 7
                                  0 0 16 1 17 0 8 18 0 6 0 19 0 7 0 20
                                  2 17 0 0 0 21 2 17 0 0 0 22 1 26 0 25
                                  27 3 28 0 8 26 26 29 1 7 32 0 33 1 7
                                  9 0 34 0 6 0 35 0 7 0 36 1 6 32 0 37
                                  2 8 6 0 9 38 0 8 0 39 2 8 0 0 6 40 2
                                  8 0 0 0 41 2 8 0 6 0 42 2 8 0 0 0 43
                                  2 7 0 6 9 44 2 8 45 0 0 46 2 8 32 0 0
                                  47 1 8 9 0 48 4 0 30 9 9 7 7 31 4 0
                                  23 9 9 7 7 24)))))
          '|lookupComplete|)) 
