
(/VERSIONCHECK 2) 

(DEFUN |IROOT;perfectSquare?;IB;1| (|a| $)
  (QEQCAR (SPADCALL |a| (QREFELT $ 14)) 0)) 

(DEFUN |IROOT;perfectNthPower?;INniB;2| (|b| |n| $)
  (QEQCAR (SPADCALL |b| |n| (QREFELT $ 18)) 0)) 

(DEFUN |IROOT;perfectNthRoot;IR;3| (|n| $)
  (PROG (|m| |r| #0=#:G1843 |e| #1=#:G1846 |p|)
    (RETURN
      (SEQ (COND
             ((OR (SPADCALL |n| (|spadConstant| $ 8) (QREFELT $ 20))
                  (OR (SPADCALL |n| (QREFELT $ 21))
                      (SPADCALL |n|
                          (SPADCALL (|spadConstant| $ 8)
                              (QREFELT $ 22))
                          (QREFELT $ 20))))
              (CONS |n| 1))
             ('T
              (SEQ (LETT |e| 1 . #2=(|IROOT;perfectNthRoot;IR;3|))
                   (LETT |p| 2 . #2#)
                   (SEQ G190
                        (COND
                          ((NULL (COND
                                   ((SPADCALL
                                     (SPADCALL
                                      (SPADCALL |n| (QREFELT $ 23))
                                      (|spadConstant| $ 8)
                                      (QREFELT $ 24))
                                     (SPADCALL |p| (QREFELT $ 10))
                                     (QREFELT $ 25))
                                    'NIL)
                                   ('T 'T)))
                           #3=(GO G191)))
                        (SEQ (SEQ (LETT |m| 0 . #2#) G190
                                  (COND
                                    ((NULL
                                      (QEQCAR
                                       (LETT |r|
                                        (SPADCALL |n| |p|
                                         (QREFELT $ 18)) . #2#)
                                       0))
                                     #3#))
                                  (SEQ (EXIT
                                        (LETT |n|
                                         (PROG2 (LETT #0# |r| . #2#)
                                          (QCDR #0#)
                                           (|check-union|
                                            (QEQCAR #0# 0)
                                            (QREFELT $ 6) #0#)) . #2#)))
                                  (LETT |m| (QSADD1 |m|) . #2#)
                                  #4=(GO G190) G191 (EXIT NIL))
                             (LETT |e| (* |e| (EXPT |p| |m|)) . #2#)
                             (EXIT (LETT |p|
                                    (PROG1
                                     (LETT #1#
                                      (SPADCALL
                                       (SPADCALL
                                        (SPADCALL |p| (QREFELT $ 10))
                                        (QREFELT $ 27))
                                       (QREFELT $ 28)) . #2#)
                                      (|check-subtype| (>= #1# 0)
                                       '(|NonNegativeInteger|) #1#)) . #2#)))
                        NIL #4# G191 (EXIT NIL))
                   (EXIT (CONS |n| |e|))))))))) 

(DEFUN |IROOT;approxNthRoot;INniI;4| (|a| |n| $)
  (PROG (|l| #0=#:G1854 |n1| |x| |xn| |y| |z|)
    (RETURN
      (SEQ (COND
             ((ZEROP |n|) (|error| "invalid arguments"))
             ((EQL |n| 1) |a|)
             ((EQL |n| 2) (SPADCALL |a| (QREFELT $ 31)))
             ('T
              (COND
                ((SPADCALL |a| (QREFELT $ 32))
                 (COND
                   ((ODDP |n|)
                    (SPADCALL
                        (SPADCALL (SPADCALL |a| (QREFELT $ 22)) |n|
                            (QREFELT $ 33))
                        (QREFELT $ 22)))
                   ('T (|spadConstant| $ 7))))
                ((SPADCALL |a| (QREFELT $ 21)) (|spadConstant| $ 7))
                ((SPADCALL |a| (|spadConstant| $ 8) (QREFELT $ 20))
                 (|spadConstant| $ 8))
                ('T
                 (COND
                   ((NULL (SPADCALL
                              (SPADCALL
                                  (QUOTIENT2
                                      (SPADCALL 3 |n| (QREFELT $ 35))
                                      2)
                                  (QREFELT $ 10))
                              (LETT |l| (SPADCALL |a| (QREFELT $ 23))
                                    . #1=(|IROOT;approxNthRoot;INniI;4|))
                              (QREFELT $ 25)))
                    (QREFELT $ 12))
                   ('T
                    (SEQ (LETT |y|
                               (SPADCALL (QREFELT $ 12)
                                   (SPADCALL (|spadConstant| $ 8)
                                    (SPADCALL
                                     (SPADCALL
                                      (SPADCALL
                                       (SPADCALL |n| (QREFELT $ 10))
                                       |l| (QREFELT $ 24))
                                      (|spadConstant| $ 8)
                                      (QREFELT $ 36))
                                     (SPADCALL |n| (QREFELT $ 10))
                                     (QREFELT $ 37))
                                    (QREFELT $ 38))
                                   (QREFELT $ 39)) . #1#)
                         (LETT |z| (|spadConstant| $ 8) . #1#)
                         (LETT |n1|
                               (PROG1 (LETT #0# (- |n| 1) . #1#)
                                 (|check-subtype| (>= #0# 0)
                                     '(|NonNegativeInteger|) #0#)) . #1#)
                         (SEQ G190
                              (COND
                                ((NULL (SPADCALL (|spadConstant| $ 7)
                                        |z| (QREFELT $ 25)))
                                 (GO G191)))
                              (SEQ (LETT |x| |y| . #1#)
                                   (LETT |xn|
                                    (SPADCALL |x| |n1| (QREFELT $ 40)) . #1#)
                                   (LETT |y|
                                    (SPADCALL
                                     (SPADCALL
                                      (SPADCALL
                                       (SPADCALL |n1| |x|
                                        (QREFELT $ 41))
                                       |xn| (QREFELT $ 42))
                                      |a| (QREFELT $ 24))
                                     (SPADCALL |n| |xn| (QREFELT $ 41))
                                     (QREFELT $ 37)) . #1#)
                                   (EXIT
                                    (LETT |z|
                                     (SPADCALL |x| |y| (QREFELT $ 36)) . #1#)))
                              NIL (GO G190) G191 (EXIT NIL))
                         (EXIT |x|)))))))))))) 

(DEFUN |IROOT;perfectNthRoot;INniU;5| (|b| |n| $)
  (PROG (|r|)
    (RETURN
      (COND
        ((SPADCALL
             (SPADCALL
                 (LETT |r| (SPADCALL |b| |n| (QREFELT $ 33))
                       |IROOT;perfectNthRoot;INniU;5|)
                 |n| (QREFELT $ 40))
             |b| (QREFELT $ 20))
         (CONS 0 |r|))
        ('T (CONS 1 "failed")))))) 

(DEFUN |IROOT;perfectSqrt;IU;6| (|a| $)
  (PROG (|s|)
    (RETURN
      (COND
        ((OR (SPADCALL |a| (|spadConstant| $ 7) (QREFELT $ 25))
             (NULL (SPADCALL
                       (SPADCALL |a| (SPADCALL 144 (QREFELT $ 10))
                           (QREFELT $ 43))
                       (QREFELT $ 11) (QREFELT $ 45))))
         (CONS 1 "failed"))
        ('T
         (COND
           ((SPADCALL
                (SPADCALL
                    (LETT |s| (SPADCALL |a| (QREFELT $ 31))
                          |IROOT;perfectSqrt;IU;6|)
                    |s| (QREFELT $ 42))
                |a| (QREFELT $ 20))
            (CONS 0 |s|))
           ('T (CONS 1 "failed")))))))) 

(DEFUN |IROOT;approxSqrt;2I;7| (|a| $)
  (PROG (|n| |s| #0=#:G1877 |#G15| |#G16| |#G17| |#G18| |new| |old|)
    (RETURN
      (SEQ (EXIT (COND
                   ((SPADCALL |a| (|spadConstant| $ 8) (QREFELT $ 25))
                    (|spadConstant| $ 7))
                   ('T
                    (SEQ (SEQ (LETT |n| (SPADCALL |a| (QREFELT $ 23))
                                    . #1=(|IROOT;approxSqrt;2I;7|))
                              (EXIT (COND
                                      ((SPADCALL
                                        (SPADCALL 100 (QREFELT $ 10))
                                        |n| (QREFELT $ 25))
                                       (SEQ
                                        (LETT |n|
                                         (SPADCALL |n|
                                          (SPADCALL 4 (QREFELT $ 10))
                                          (QREFELT $ 37)) . #1#)
                                        (LETT |s|
                                         (SPADCALL
                                          (SPADCALL |a|
                                           (SPADCALL
                                            (SPADCALL 2 |n|
                                             (QREFELT $ 46))
                                            (QREFELT $ 22))
                                           (QREFELT $ 38))
                                          (QREFELT $ 31)) . #1#)
                                        (LETT |s|
                                         (SPADCALL |s| |n|
                                          (QREFELT $ 38)) . #1#)
                                        (EXIT
                                         (PROGN
                                           (LETT #0#
                                            (SPADCALL
                                             (SPADCALL
                                              (SPADCALL
                                               (|spadConstant| $ 8) |s|
                                               (QREFELT $ 24))
                                              (SPADCALL |a| |s|
                                               (QREFELT $ 37))
                                              (QREFELT $ 24))
                                             (QREFELT $ 12)
                                             (QREFELT $ 37)) . #1#)
                                           (GO #0#))))))))
                         (PROGN
                           (LETT |#G15|
                                 (SPADCALL (|spadConstant| $ 8)
                                     (SPADCALL |n| (QREFELT $ 12)
                                      (QREFELT $ 37))
                                     (QREFELT $ 38)) . #1#)
                           (LETT |#G16| (|spadConstant| $ 8) . #1#)
                           (LETT |new| |#G15| . #1#)
                           (LETT |old| |#G16| . #1#))
                         (SEQ G190
                              (COND
                                ((NULL (COND
                                         ((SPADCALL |new| |old|
                                           (QREFELT $ 20))
                                          'NIL)
                                         ('T 'T)))
                                 (GO G191)))
                              (SEQ (EXIT
                                    (PROGN
                                      (LETT |#G17|
                                       (SPADCALL
                                        (SPADCALL
                                         (SPADCALL (|spadConstant| $ 8)
                                          |new| (QREFELT $ 24))
                                         (SPADCALL |a| |new|
                                          (QREFELT $ 37))
                                         (QREFELT $ 24))
                                        (QREFELT $ 12) (QREFELT $ 37)) . #1#)
                                      (LETT |#G18| |new| . #1#)
                                      (LETT |new| |#G17| . #1#)
                                      (LETT |old| |#G18| . #1#))))
                              NIL (GO G190) G191 (EXIT NIL))
                         (EXIT |new|)))))
           #0# (EXIT #0#))))) 

(DEFUN |IntegerRoots| (#0=#:G1878)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1879)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (LIST (|devaluate| #0#))
                       (HGET |$ConstructorCache| '|IntegerRoots|)
                       '|domainEqualList|)
                   . #2=(|IntegerRoots|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (|IntegerRoots;| #0#) (LETT #1# T . #2#))
               (COND
                 ((NOT #1#) (HREM |$ConstructorCache| '|IntegerRoots|))))))))))) 

(DEFUN |IntegerRoots;| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|IntegerRoots|))
        (LETT |dv$| (LIST '|IntegerRoots| DV$1) . #0#)
        (LETT $ (GETREFV 47) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|IntegerRoots| (LIST DV$1)
            (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 11
            (LIST (|spadConstant| $ 7) (|spadConstant| $ 8)
                  (SPADCALL 4 (QREFELT $ 10))
                  (SPADCALL 9 (QREFELT $ 10))
                  (SPADCALL 16 (QREFELT $ 10))
                  (SPADCALL 25 (QREFELT $ 10))
                  (SPADCALL 36 (QREFELT $ 10))
                  (SPADCALL 49 (QREFELT $ 10))
                  (SPADCALL 52 (QREFELT $ 10))
                  (SPADCALL 64 (QREFELT $ 10))
                  (SPADCALL 73 (QREFELT $ 10))
                  (SPADCALL 81 (QREFELT $ 10))
                  (SPADCALL 97 (QREFELT $ 10))
                  (SPADCALL 100 (QREFELT $ 10))
                  (SPADCALL 112 (QREFELT $ 10))
                  (SPADCALL 121 (QREFELT $ 10))))
        (QSETREFV $ 12 (SPADCALL 2 (QREFELT $ 10)))
        $)))) 

(MAKEPROP '|IntegerRoots| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (0 . |Zero|)
             (4 . |One|) (|Integer|) (8 . |coerce|) '|resMod144| '|two|
             (|Union| 6 '"failed") |IROOT;perfectSqrt;IU;6| (|Boolean|)
             |IROOT;perfectSquare?;IB;1| (|NonNegativeInteger|)
             |IROOT;perfectNthRoot;INniU;5|
             |IROOT;perfectNthPower?;INniB;2| (13 . =) (19 . |zero?|)
             (24 . -) (29 . |length|) (34 . +) (40 . <)
             (|IntegerPrimesPackage| 6) (46 . |nextPrime|)
             (51 . |convert|)
             (|Record| (|:| |base| 6) (|:| |exponent| 17))
             |IROOT;perfectNthRoot;IR;3| |IROOT;approxSqrt;2I;7|
             (56 . |negative?|) |IROOT;approxNthRoot;INniI;4|
             (|PositiveInteger|) (61 . *) (67 . -) (73 . |quo|)
             (79 . |shift|) (85 . |max|) (91 . **) (97 . *) (103 . *)
             (109 . |rem|) (|List| 6) (115 . |member?|) (121 . *))
          '#(|perfectSquare?| 127 |perfectSqrt| 132 |perfectNthRoot|
             137 |perfectNthPower?| 148 |approxSqrt| 154
             |approxNthRoot| 159)
          'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 46
                                '(0 6 0 7 0 6 0 8 1 6 0 9 10 2 6 15 0 0
                                  20 1 6 15 0 21 1 6 0 0 22 1 6 0 0 23
                                  2 6 0 0 0 24 2 6 15 0 0 25 1 26 6 6
                                  27 1 6 9 0 28 1 6 15 0 32 2 17 0 34 0
                                  35 2 6 0 0 0 36 2 6 0 0 0 37 2 6 0 0
                                  0 38 2 6 0 0 0 39 2 6 0 0 17 40 2 6 0
                                  17 0 41 2 6 0 0 0 42 2 6 0 0 0 43 2
                                  44 15 6 0 45 2 6 0 34 0 46 1 0 15 6
                                  16 1 0 13 6 14 1 0 29 6 30 2 0 13 6
                                  17 18 2 0 15 6 17 19 1 0 6 6 31 2 0 6
                                  6 17 33)))))
          '|lookupComplete|)) 
