h* 1      !"#$%&'()*+,-./00.2.3.0#Multivariate polynomials on a ring.(c) Stphane Laurent, 2023GPL-3laurent_step@outlook.fr Safe-Inferred 3>1hsprayappend trailing zeros2hspray,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 ^+^ p3hspraydrop trailing zeros4hspray,drop trailing zeros in the powers of a spray5hspray%simplify powers and remove zero terms6hsprayaddition of two sprays7hsprayopposite spray8hsprayscale a spray by a scalar9hsprayderivative of a monomial hsprayDerivative of a spray:hspraymultiply 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) hsprayConverts 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 sprayf :: Spray Rational -> Spray Rational -> Spray Rational -> Spray Rationalf 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 p (1, 3) == 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)Ahspray"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 Bhspray!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)Chsprayindex of the maximum of a listhsprayLeading term of a spray Dhspray+whether a monomial divides another monomialEhspray:quotient of monomial Q by monomial p, assuming P divides Q hsprayRemainder of the division of a spray by a list of divisors, using the lexicographic ordering of the monomialsFhsprayslight modification of   to speed up groebner00Ghspray+groebner basis, not minimal and not reducedHhspray'groebner basis, minimal but not reduced!hsprayReduces a Groebner basis"hspray4Groebner basis (always minimal and possibly reduced):groebner ps True = reduceGroebnerBasis (groebner ps False)Ihspray'combinations of k elements among a listJhspray.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%hsprayWhether 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)&hsprayResultant of two  univariate sprays'hspraySubresultants 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 Khspray(a string denoting the variable, e.g. "x"hspray the spray"hspraylist of sprays hspray#whether to return the reduced basis#hspraynumber of variableshsprayindex(hsprayindicator of the variable with respect to which the resultant is desired (e.g. 1 for x))hsprayindicator of the variable with respect to which the resultant is desired (e.g. 1 for x)LhsprayAhsprayBhspray)(c, (Q, R)) such that c^*^A = B^*^Q ^+^ R+     "!#$(&)'*%+     "!#$(&)'*%667 8 7 7      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP%hspray-0.2.3.0-9iFQcWB4EMQJd1cMhvp8LLMath.Algebra.HsprayhsprayMonomialSprayPowers exponents nvariables^+^^-^^*^^**^*^.^ derivSpraylone unitSpray zeroSpray constantSpraygetCoefficient evalSpraysubstituteSprayfromRationalSpray composeSprayfromListpermuteVariables swapVariables prettySpray prettySpray'prettySprayXYZ sprayTermstoList bombieriSpray leadingTerm sprayDivisionreduceGroebnerBasisgroebner esPolynomialisSymmetricSprayisPolynomialOf resultant1subresultants1 resultant subresultantsgcdQX$fHashablePowers $fEqPowers $fCHashMap $fCaHashMap $fCHashMap0 $fShowPowers growSequence harmonizesimplifyPowers simplifySpray cleanSpray addSprays negateSpray scaleSpray derivMonomial multMonomial multSpraysnumberOfVariables evalMonomial fromMonomialsubstituteMonomial prettyPowers prettyPowers'prettyPowersXYZmaxIndexdividesquotientsprayDivision' groebner00 groebner0combinationsOfpermutationsBinarySequencebaseGHC.ShowshowpseudoDivision