Changes http://wiki.axiom-developer.org/MantepseSpad2/diff
--

??changed:
 
--- brauche hier EXPRI, weil das Ergebnis ja die allgemeine Form enthält
-
+    --<<implementation: Guess - Hermite-Pade - Types for Operators>>
     Exports == with

??changed:
 
-      guess: List F -> GUESSRESULT
-        ++ \spad{guess l} applies recursively \spadfun{guessRec} and
-        ++ \spadfun{guessADE} to the successive differences and quotients of
-        ++ the list. Default options as described in
-        ++ \spadtype{GuessOptionFunctions0} are used.
-
-      guess: (List F, LGOPT) -> GUESSRESULT
-        ++ \spad{guess(l, options)} applies recursively \spadfun{guessRec} and
-        ++ \spadfun{guessADE} to the successive differences and quotients of
-        ++ the list. The given options are used.
-
-      guess: (List F, List GUESSER, List Symbol) -> GUESSRESULT
-        ++ \spad{guess(l, guessers, ops)} applies recursively the given
-        ++ guessers to the successive differences if ops contains the symbol
-        ++ guessSum and quotients if ops contains the symbol guessProduct to
-        ++ the list. Default options as described in
-        ++ \spadtype{GuessOptionFunctions0} are used.
-
-      guess: (List F, List GUESSER, List Symbol, LGOPT) -> GUESSRESULT
-[137 more lines...]
+        guess: List F -> GUESSRESULT
+          ++ \spad{guess l} applies recursively \spadfun{guessRec} and
+          ++ \spadfun{guessADE} to the successive differences and quotients of
+          ++ the list. Default options as described in
+          ++ \spadtype{GuessOptionFunctions0} are used.
+  
+        guess: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guess(l, options)} applies recursively \spadfun{guessRec}
+          ++ and \spadfun{guessADE} to the successive differences and quotients
+          ++ of the list. The given options are used.
+  
+        guess: (List F, List GUESSER, List Symbol) -> GUESSRESULT
+          ++ \spad{guess(l, guessers, ops)} applies recursively the given
+          ++ guessers to the successive differences if ops contains the symbol
+          ++ guessSum and quotients if ops contains the symbol guessProduct to
+          ++ the list. Default options as described in
+          ++ \spadtype{GuessOptionFunctions0} are used.
+  
+        guess: (List F, List GUESSER, List Symbol, LGOPT) -> GUESSRESULT
+          ++ \spad{guess(l, guessers, ops)} applies recursively the given
+          ++ guessers to the successive differences if ops contains the symbol
+          ++ \spad{guessSum} and quotients if ops contains the symbol
+          ++ \spad{guessProduct} to the list. The given options are used.
+  
+        guessExpRat: List F -> GUESSRESULT
+          ++ \spad{guessExpRat l} tries to find a function of the form 
+          ++ n+->(a+b n)^n r(n), where r(n) is a rational function, that fits
+          ++ l. 
+  
+        guessExpRat: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessExpRat(l, options)} tries to find a function of the
+          ++ form n+->(a+b n)^n r(n), where r(n) is a rational function, that
+          ++ fits l. 
+  
+        if F has RetractableTo Symbol and S has RetractableTo Symbol then
+
+            guessExpRat: Symbol -> GUESSER
+              ++ \spad{guessExpRat q} returns a guesser that tries to find a
+              ++ function of the form n+->(a+b q^n)^n r(q^n), where r(n) is a
+              ++ rational function, that fits l.
+
+        guessHP: (LGOPT -> HPSPEC) -> GUESSER
+          ++ \spad{guessHP f} constructs an operation that applies Hermite-Pade
+          ++ approximation to the series generated by the given function f.
+  
+        guessADE: List F -> GUESSRESULT
+          ++ \spad{guessADE l} tries to find an algebraic differential equation
+          ++ for a generating function whose first Taylor coefficients are
+          ++ given by l, using the default options described in
+          ++ \spadtype{GuessOptionFunctions0}.
+  
+        guessADE: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessADE(l, options)} tries to find an algebraic
+          ++ differential equation for a generating function whose first Taylor
+          ++ coefficients are given by l, using the given options.
+  
+        guessAlg: List F -> GUESSRESULT
+          ++ \spad{guessAlg l} tries to find an algebraic equation for a
+          ++ generating function whose first Taylor coefficients are given by
+          ++ l, using the default options described in
+          ++ \spadtype{GuessOptionFunctions0}. It is equivalent to
+          ++ \spadfun{guessADE}(l, maxDerivative == 0).
+  
+        guessAlg: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessAlg(l, options)} tries to find an algebraic equation
+          ++ for a generating function whose first Taylor coefficients are
+          ++ given by l, using the given options. It is equivalent to
+          ++ \spadfun{guessADE}(l, options) with \spad{maxDerivative == 0}.
+  
+        guessHolo: List F -> GUESSRESULT
+          ++ \spad{guessHolo l} tries to find an ordinary linear differential
+          ++ equation for a generating function whose first Taylor coefficients
+          ++ are given by l, using the default options described in
+          ++ \spadtype{GuessOptionFunctions0}. It is equivalent to
+          ++ \spadfun{guessADE}\spad{(l, maxPower == 1)}.
+  
+        guessHolo: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessHolo(l, options)} tries to find an ordinary linear
+          ++ differential equation for a generating function whose first Taylor
+          ++ coefficients are given by l, using the given options. It is
+          ++ equivalent to \spadfun{guessADE}\spad{(l, options)} with
+          ++ \spad{maxPower == 1}.
+  
+        guessPade: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessPade(l, options)} tries to find a rational function
+          ++ whose first Taylor coefficients are given by l, using the given
+          ++ options. It is equivalent to \spadfun{guessADE}\spad{(l,
+          ++ maxDerivative == 0, maxPower == 1, allDegrees == true)}.
+  
+        guessPade: List F -> GUESSRESULT
+          ++ \spad{guessPade(l, options)} tries to find a rational function
+          ++ whose first Taylor coefficients are given by l, using the default
+          ++ options described in \spadtype{GuessOptionFunctions0}. It is
+          ++ equivalent to \spadfun{guessADE}\spad{(l, options)} with
+          ++ \spad{maxDerivative == 0, maxPower == 1, allDegrees == true}.
+  
+        guessRec: List F -> GUESSRESULT
+          ++ \spad{guessRec l} tries to find an ordinary difference equation
+          ++ whose first values are given by l, using the default options
+          ++ described in \spadtype{GuessOptionFunctions0}.
+  
+        guessRec: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessRec(l, options)} tries to find an ordinary difference
+          ++ equation whose first values are given by l, using the given
+          ++ options. 
+  
+        guessPRec: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessPRec(l, options)} tries to find a linear recurrence
+          ++ with polynomial coefficients whose first values are given by l,
+          ++ using the given options. It is equivalent to
+          ++ \spadfun{guessRec}\spad{(l, options)} with \spad{maxPower == 1}.
+  
+        guessPRec: List F -> GUESSRESULT
+          ++ \spad{guessPRec l} tries to find a linear recurrence with
+          ++ polynomial coefficients whose first values are given by l, using
+          ++ the default options described in
+          ++ \spadtype{GuessOptionFunctions0}. It is equivalent to
+          ++ \spadfun{guessRec}\spad{(l, maxPower == 1)}. 
+  
+        guessRat: (List F, LGOPT) -> GUESSRESULT
+          ++ \spad{guessRat(l, options)} tries to find a rational function
+          ++ whose first values are given by l, using the given options. It is
+          ++ equivalent to \spadfun{guessRec}\spad{(l, maxShift == 0, maxPower
+          ++ == 1, allDegrees == true)}.
+  
+        guessRat: List F -> GUESSRESULT
+          ++ \spad{guessRat l} tries to find a rational function whose first
+          ++ values are given by l, using the default options described in
+          ++ \spadtype{GuessOptionFunctions0}. It is equivalent to
+          ++ \spadfun{guessRec}\spad{(l, maxShift == 0, maxPower == 1,
+          ++ allDegrees == true)}.
+  
+        diffHP: LGOPT -> HPSPEC
+          ++ \spad{diffHP options} returns a specification for Hermite-Pade
+          ++ approximation with the differential operator
+  
+        shiftHP: LGOPT -> HPSPEC
+          ++ \spad{shiftHP options} returns a specification for Hermite-Pade
+          ++ approximation with the shift operator
+  
+        if F has RetractableTo Symbol and S has RetractableTo Symbol then
+            shiftHP: Symbol -> (LGOPT -> HPSPEC)
+              ++ \spad{shiftHP options} returns a specification for
+              ++ Hermite-Pade approximation with the $q$-shift operator
+    
+            diffHP: Symbol -> (LGOPT -> HPSPEC)
+              ++ \spad{diffHP options} returns a specification for Hermite-Pade
+              ++ approximation with the  $q$-dilation operator
+    
+            guessRec: Symbol -> GUESSER
+              ++ \spad{guessRec q} returns a guesser that finds an ordinary
+              ++ q-difference equation whose first values are given by l, using
+              ++ the given options.
+      
+            guessPRec: Symbol -> GUESSER
+              ++ \spad{guessPRec q} returns a guesser that tries to find
+              ++ a linear q-recurrence with polynomial coefficients whose first
+              ++ values are given by l, using the given options. It is
+              ++ equivalent to \spadfun{guessRec}\spad{(q)} with 
+              ++ \spad{maxPower == 1}.
+      
+            guessRat: Symbol -> GUESSER
+              ++ \spad{guessRat q} returns a guesser that tries to find a
+              ++ q-rational function whose first values are given by l, using
+              ++ the given options. It is equivalent to \spadfun{guessRec} with
+              ++ \spad{(l, maxShift == 0, maxPower == 1, allDegrees == true)}.
+    
+            guessADE: Symbol -> GUESSER
+              ++ \spad{guessADE q} returns a guesser that tries to find an
+              ++ algebraic differential equation for a generating function 
whose
+              ++ first Taylor coefficients are given by l, using the given
+              ++ options.
+
+        --<<debug exports: Guess>>
     Implementation == add

??changed:
     Implementation == add
-
--------------------------------------------------------------------------------
--- order and degree for the resultants in guessExpRat
--------------------------------------------------------------------------------
-
--- Note that this expression are only conjectured - in fact, using guessRat.
-
--- We have to put them at the beginning, because otherwise they will
--- take very long to compile.
-
-      ord1(n: Integer): Integer == (3*n**4-4*n**3+3*n*n-2*n) quo 12
-
-      ord2(n: Integer, i: Integer): Integer == 
-        if i=0 
-        then ord1 n + ((n*n-n) quo 2)
-        else ord1 n
-         
-
-      deg1(n: Integer, i: Integer): Integer == 
-[1158 more lines...]
+        
+       -- We have to put this chunk at the beginning, because otherwise it 
will take
+       -- very long to compile.
+
+       ord1(x: List Integer, i: Integer): Integer == 
+           n := #x - 3 - i
+           x.(n+1)*reduce(_+, [x.j for j in 1..n], 0) + _
+               2*reduce(_+, [reduce(_+, [x.k*x.j for k in 1..j-1], 0) _
+                             for j in 1..n], 0)
+
+       ord2(x: List Integer, i: Integer): Integer == 
+           if zero? i then
+               n := #x - 3 - i
+               ord1(x, i) + reduce(_+, [x.j for j in 1..n], 
0)*(x.(n+2)-x.(n+1))
+           else
+               ord1(x, i)
+
+       deg1(x: List Integer, i: Integer): Integer == 
+           m := #x - 3 
+           (x.(m+3)+x.(m+1)+x.(1+i))*reduce(_+, [x.j for j in 2+i..m], 0) + _
+               x.(m+3)*x.(m+1) + _
+               2*reduce(_+, [reduce(_+, [x.k*x.j for k in 2+i..j-1], 0) _
+                             for j in 2+i..m], 0)
+
+       deg2(x: List Integer, i: Integer): Integer == 
+           m := #x - 3
+           deg1(x, i) + _
+               (x.(m+3) + reduce(_+, [x.j for j in 2+i..m], 0)) * _
+               (x.(m+2)-x.(m+1))
+
+
+       checkResult(res: EXPRR, n: Symbol, l: Integer, list: List F, 
+                   options: LGOPT): NNI ==
+           for i in l..1 by -1 repeat
+               den := eval(denominator res, n::EXPRR, (i-1)::EXPRR)
+               if den = 0 then return i::NNI
+               num := eval(numerator res, n::EXPRR, (i-1)::EXPRR)
+               if list.i ~= retract(retract(num/den)@R)
+               then return i::NNI
+           0$NNI
+
+       SUPS2SUPF(p: SUP S): SUP F ==
+         if F is S then 
+           p pretend SUP(F)
+         else if F is Fraction S then
+           map(coerce(#1)$Fraction(S), p)
+             $SparseUnivariatePolynomialFunctions2(S, F)
+         else error "Type parameter F should be either equal to S or equal _
+                     to Fraction S"
+
+       F2FPOLYS(p: F): FPOLYS ==
+         if F is S then 
+           p::POLYF::FPOLYF pretend FPOLYS
+         else if F is Fraction S then
+           numer(p)$Fraction(S)::POLYS/denom(p)$Fraction(S)::POLYS
+         else error "Type parameter F should be either equal to S or equal _
+                      to Fraction S"
+
+       MPCSF ==> MPolyCatFunctions2(V, IndexedExponents V, 
+                                       IndexedExponents V, S, F,
+                                       POLYS, POLYF)
+
+       SUPF2EXPRR(xx: Symbol, p: SUP F): EXPRR ==
+         zero? p => 0
+         (coerce(leadingCoefficient p))::EXPRR * (xx::EXPRR)**degree p
+            + SUPF2EXPRR(xx, reductum p)
+
+       FSUPF2EXPRR(xx: Symbol, p: FSUPF): EXPRR ==
+         (SUPF2EXPRR(xx, numer p)) / (SUPF2EXPRR(xx, denom p))
+
+
+       POLYS2POLYF(p: POLYS): POLYF ==
+         if F is S then 
+           p pretend POLYF
+         else if F is Fraction S then
+           map(coerce(#1)$Fraction(S), p)$MPCSF
+         else error "Type parameter F should be either equal to S or equal _
+                     to Fraction S"
+
+       SUPPOLYS2SUPF(p: SUP POLYS, a1v: F, Av: F): SUP F ==
+         zero? p => 0
+         lc: POLYF := POLYS2POLYF leadingCoefficient(p)
+         monomial(retract(eval(lc, [index(1)$V, index(2)$V]::List V, 
+                                   [a1v, Av])),
+                  degree p) 
+           + SUPPOLYS2SUPF(reductum p, a1v, Av)
+
+
+       SUPFPOLYS2FSUPPOLYS(p: SUP FPOLYS): Fraction SUP POLYS  ==
+         cden := splitDenominator(p)
+                $UnivariatePolynomialCommonDenominator(POLYS, FPOLYS,SUP 
FPOLYS)
+         
+         pnum: SUP POLYS 
+              := map(retract(#1 * cden.den)$FPOLYS, p)
+                    $SparseUnivariatePolynomialFunctions2(FPOLYS, POLYS)
+         pden: SUP POLYS := (cden.den)::SUP POLYS
+
+         pnum/pden
+
+
+       POLYF2EXPRR(p: POLYF): EXPRR ==
+         map(convert(#1)@Symbol::EXPRR, coerce(#1)@EXPRR, p)
+            $PolynomialCategoryLifting(IndexedExponents V, V, 
+                                       F, POLYF, EXPRR)
+
+       defaultD: DIFFSPECN
+       defaultD(expr: EXPRR): EXPRR == expr
+
+       -- applies n+->q^n or whatever DN is to i
+       DN2DL: (DIFFSPECN, Integer) -> F
+       DN2DL(DN, i) == retract(retract(DN(i::EXPRR))@R)
+
+       evalResultant(p1: POLYS, p2: POLYS, o: Integer, d: Integer, va1: V, vA: 
V)_
+       : List S == 
+           res: List S := []
+           d1 := degree(p1, va1)
+           d2 := degree(p2, va1)
+           lead: S
+           for k in 1..d-o+1 repeat
+               p1atk := univariate eval(p1, vA, k::S)
+               p2atk := univariate eval(p2, vA, k::S)
+
+               d1atk := degree p1atk
+               d2atk := degree p2atk
+
+       --      output("k: " string(k))$OutputPackage
+       --      output("d1: " string(d1) " d1atk: " string(d1atk))$OutputPackage
+       --      output("d2: " string(d2) " d2atk: " string(d2atk))$OutputPackage
+
+
+               if d2atk < d2 then
+                   if  d1atk < d1
+                   then lead := 0$S
+                   else lead := (leadingCoefficient p1atk)**((d2-d2atk)::NNI)
+               else
+                   if  d1atk < d1
+                   then lead := (-1$S)**d2 * (leadingCoefficient 
p2atk)**((d1-d1atk)::NNI)
+                   else lead := 1$S
+
+               if zero? lead 
+               then res := cons(0, res)
+               else res := cons(lead * (resultant(p1atk, p2atk)$SUP(S) exquo _
+                                       (k::S)**(o::NNI))::S, 
+                                res)
+
+           reverse res
+
+       p(xm: Integer, i: Integer, va1: V, vA: V, basis: DIFFSPECN): FPOLYS == 
+           vA::POLYS::FPOLYS + va1::POLYS::FPOLYS _ 
+                              * F2FPOLYS(DN2DL(basis, i) - DN2DL(basis, xm))
+
+       p2(xm: Integer, i: Symbol, a1v: F, Av: F, basis: DIFFSPECN): EXPRR == 
+           coerce(Av) + coerce(a1v)*(basis(i::EXPRR) - basis(xm::EXPRR))
+
+       GF ==> GeneralizedMultivariateFactorize(SingletonAsOrderedSet,
+                                               IndexedExponents V, F, F,
+                                               SUP F)
+
+       guessExpRatAux(xx: Symbol, list: List F, basis: DIFFSPECN, 
+                      xValues: List Integer, options: LGOPT): List EXPRR ==
+
+           a1: V := index(1)$V
+           A: V := index(2)$V
+
+           len: NNI := #list
+           if len < 4 then return []
+                      else len := (len-3)::NNI
+         
+           xlist := [F2FPOLYS DN2DL(basis, xValues.i) for i in 1..len]
+           x1 := F2FPOLYS DN2DL(basis, xValues.(len+1))
+           x2 := F2FPOLYS DN2DL(basis, xValues.(len+2))
+           x3 := F2FPOLYS DN2DL(basis, xValues.(len+3))
+
+           y: NNI -> FPOLYS := 
+               F2FPOLYS(list.#1) * _
+               p(last xValues, (xValues.#1)::Integer, a1, A, basis)**_
+                   (-(xValues.#1)::Integer)
+
+           ylist: List FPOLYS := [y i for i in 1..len]
+
+           y1 := y(len+1)
+           y2 := y(len+2)
+           y3 := y(len+3)
+
+           res := []::List EXPRR
+           if maxDegree(options)$GOPT0 = -1
+           then maxDeg := len-1
+           else maxDeg := min(maxDegree(options)$GOPT0, len-1)
+
+           for i in 0..maxDeg repeat
+               if debug(options)$GOPT0 then
+                   output(hconcat("degree ExpRat "::OutputForm, i::OutputForm))
+                       $OutputPackage
+
+               if debug(options)$GOPT0 then 
+                   systemCommand("sys date +%s")$MoreSystemCommands
+                   output("interpolating..."::OutputForm)$OutputPackage
+
+               ri: FSUPFPOLYS
+[902 more lines...]
 

                            coerce$Expression(Integer))
++added:
+
 \end{spad}

--
forwarded from http://wiki.axiom-developer.org/[EMAIL PROTECTED]

Reply via email to