Îõ³h*¢0      !"#$%&'()*+,-./0.2.2.0#Multivariate polynomials on a ring.(c) Stéphane Laurent, 2023GPL-3laurent_step@outlook.fr Safe-Inferred 3ÂÃÄÅÆÝ&>0hsprayappend trailing zeros1hspray,append trailing zeros to get the same lengthhsprayAddition of two sprayshspraySubstraction of two sprayshsprayMultiply two sprays hsprayPower of a spray hsprayScale spray by a scalar hsprayScale spray by an integer3 .^ p == p ^+^ p ^+^ p2hspraydrop trailing zeros3hspray,drop trailing zeros in the powers of a spray4hspray%simplify powers and remove zero terms5hsprayaddition of two sprays6hsprayopposite spray7hsprayscale a spray by a scalar8hsprayderivative of a monomial hsprayDerivative of a spray9hspraymultiply two monomials:hspraymultiply two sprays hspray-Spray corresponding to the basic monomial x_nx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intp = 2*^x^**^2 ^-^ 3*^yputStrLn $ prettySpray' p(2) x1^2 + (-3) x2lone 0 == unitSprayhsprayThe unit sprayp ^*^ unitSpray == phsprayThe null sprayp ^+^ zeroSpray == phsprayConstant spray!constantSpray 3 == 3 *^ unitSprayhspray%Get coefficient of a term of a spray x = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int=p = 2 *^ (2 *^ (x^**^3 ^*^ y^**^2)) ^+^ 4*^z ^+^ 5*^unitSpraygetCoefficient [3, 2, 0] p4getCoefficient [0, 4] p0;hspraynumber of variables in a spray<hsprayevaluates a monomialhsprayEvaluates a sprayx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intp = 2*^x^**^2 ^-^ 3*^yevalSpray p [2, 1]5=hsprayspray from monomial>hspray'substitute some variables in a monomialhspray%Substitutes some variables in a sprayx1 :: lone 1 :: Spray Intx2 :: lone 2 :: Spray Intx3 :: lone 3 :: Spray Int'p = x1^**^2 ^-^ x2 ^+^ x3 ^-^ unitSpray0p' = substituteSpray [Just 2, Nothing, Just 3] pputStrLn $ prettySpray' p'(-1) x2 + (6) hsprayèConverts a spray with rational coefficients to a spray with double coefficients (useful for evaluation)hspray+Composes a spray with a change of variablesx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intz :: lone 3 :: Spray Int p = x ^+^ y%q = composeSpray p [z, x ^+^ y ^+^ z]putStrLn $ prettySprayXYZ q(1) X + (1) Y + (2) Zhspray"Creates a spray from list of termshspray!Permutes the variables of a sprayÉf :: Spray Rational -> Spray Rational -> Spray Rational -> Spray RationalÉf p1 p2 p3 = p1^**^4 ^+^ (2*^p2^**^3) ^+^ (3*^p3^**^2) ^-^ (4*^unitSpray)x1 = lone 1 :: Spray Rationalx2 = lone 2 :: Spray Rationalx3 = lone 3 :: Spray Rationalp = f x1 x2 x3*permuteVariables p [3, 1, 2] == f x3 x1 x2hspraySwaps two variables of a spray6swapVariables (1, 3) p == permuteVariables p [3, 2, 1]?hspray(prettyPowers "x" [0, 2, 1] = x^(0, 2, 1)hsprayPretty form of a sprayx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intz :: lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3!putStrLn $ prettySpray show "x" p1(2) * x^(1) + (3) * x^(0, 2) + (-4) * x^(0, 0, 3)@hspray"prettyPowers' [0, 2, 1] = "x2^2x3"hspray9Pretty form of a spray, with monomials showed as "x1x3^2"x :: lone 1 :: Spray Inty :: lone 2 :: Spray Intz :: lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3putStrLn $ prettySpray' p(2) x1 + (3) x2^2 + (-4) x3^3 Ahspray!prettyPowersXYZ [1, 2, 1] = XY^2Zhspray5Pretty form of a spray having at more three variablesx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intz :: lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3putStrLn $ prettySprayXYZ p(2) X + (3) Y^2 + (-4) Z^3hsprayTerms of a sprayhspraySpray as a listhspray>Bombieri spray (for internal usage in the 'scubature' library)Bhsprayindex of the maximum of a listhsprayLeading term of a spray Chspray+whether a monomial divides another monomialDhspray:quotient of monomial Q by monomial p, assuming P divides Q hsprayïRemainder of the division of a spray by a list of divisors, using the lexicographic ordering of the monomialsEhsprayslight modification of   to speed up groebner00Fhspray+groebner basis, not minimal and not reducedGhspray'groebner basis, minimal but not reduced!hsprayReduces a Groebner basis"hspray4Groebner basis (always minimal and possibly reduced):groebner ps True = reduceGroebnerBasis (groebner ps False)Hhspray'combinations of k elements among a listIhspray.generate all permutations of a binary sequence#hsprayElementary symmetric polynomial*putStrLn $ prettySpray' (esPolynomial 3 2)(1) x1x2 + (1) x1x3 + (1) x2x3$hspray)Whether a spray is a symmetric polynomial%hsprayÆWhether a spray can be written as a polynomial of a given list of sprays (the sprays in the list must belong to the same polynomial ring as the spray); this polynomial is returned if this is truex = lone 1 :: Spray Rationaly = lone 2 :: Spray Rational p1 = x ^+^ y p2 = x ^-^ y p = p1 ^*^ p23isPolynomialOf p [p1, p2] == (True, Just $ x ^*^ y)&hspray"Resultant of two univariate sprays'hspray&Subresultants of two univariate sprays(hsprayResultant of two sprays)hspraySubresultants of two sprays hspray8index of the variable of differentiation (starting at 1)hspray the sprayhspray6function mapping a coefficient to a string, typically Jhspray(a string denoting the variable, e.g. "x"hspray the spray"hspraylist of sprays hspray#whether to return the reduced basis#hspraynumber of variableshsprayindex(hspray×indicator of the variable with respect to which the resultant is desired (e.g. 1 for x))hspray×indicator of the variable with respect to which the resultant is desired (e.g. 1 for x)*     "!#$(&)'%*     "!#$(&)'%667 8 7 7Ë      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNÏ%hspray-0.2.2.0-KATCefkA3KeLjgW7IlRdsDMath.Algebra.HsprayhsprayMonomialSprayPowers exponents nvariables^+^^-^^*^^**^*^.^ derivSpraylone unitSpray zeroSpray constantSpraygetCoefficient evalSpraysubstituteSprayfromRationalSpray composeSprayfromListpermuteVariables swapVariables prettySpray prettySpray'prettySprayXYZ sprayTermstoList bombieriSpray leadingTerm sprayDivisionreduceGroebnerBasisgroebner esPolynomialisSymmetricSprayisPolynomialOf resultant1subresultants1 resultant subresultants$fHashablePowers $fEqPowers $fCHashMap $fCaHashMap $fCHashMap0 $fShowPowers growSequence harmonizesimplifyPowers simplifySpray cleanSpray addSprays negateSpray scaleSpray derivMonomial multMonomial multSpraysnumberOfVariables evalMonomial fromMonomialsubstituteMonomial prettyPowers prettyPowers'prettyPowersXYZmaxIndexdividesquotientsprayDivision' groebner00 groebner0combinationsOfpermutationsBinarySequencebaseGHC.Showshow