h*+)       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXY0.2.5.0#Multivariate polynomials on a ring.(c) Stphane Laurent, 2023GPL-3laurent_step@outlook.fr Safe-Inferred 3(AhsprayIdentify a rational to a  A Rational' elementhspray3Scale a ratio of univariate polynomials by a scalarhsprayConstant univariate polynomialhsprayUnivariate polynomial from its coefficients (ordered by increasing degrees)hsprayThe variable of a univariate polynomial; it is called "outer" because this is the variable occuring in the polynomial coefficients of a  hspray'Constant rational univariate polynomialimport Number.Ratio ( (%) )constQPoly (2 % 3)hspray0Rational univariate polynomial from coefficientsimport Number.Ratio ( (%) )!qpolyFromCoeffs [2 % 3, 5, 7 % 4]hsprayThe variable of a univariate qpolynomial; it is called "outer" because this is the variable occuring in the polynomial coefficients of a  (outerQVariable == qpolyFromCoeffs [0, 1]Zhsprayhelper function for prettyRatioOfPolynomials (and prettySymbolicSpray)[hsprayhelper function for prettyRatioOfPolynomials (and prettySymbolicSpray)hspray0Pretty form of a ratio of univariate polynomialshspray1Pretty form of a ratio of univariate qpolynomialshspray+Evaluates a ratio of univariate polynomialshspraySimplifies the coefficients (the ratio of univariate polynomials) of a symbolic sprayhsprayPretty form of a symbolic sprayhspray Pretty form of a symbolic qsprayhspray=Substitutes a value to the outer variable of a symbolic spray hspraySubstitutes a value to the outer variable of a symbolic spray as well as some values to the inner variables of this spray!hspraySubstitutes some values to the inner variables of a symbolic spray\hsprayappend trailing zeros]hspray,append trailing zeros to get the same length^hspraydrop trailing zeros_hsprayaddition of two sprays`hsprayopposite sprayahsprayscale a spray by a scalarbhspraymultiply two monomialschspraymultiply two sprays"hsprayAddition of two sprays#hspraySubstraction of two sprays$hsprayMultiply two sprays%hsprayPower of a spray&hsprayScale a spray by a scalar'hsprayScale a spray by an integer3 .^ p == p ^+^ p ^+^ pdhspray,drop trailing zeros in the powers of a sprayehspray%simplify powers and remove zero termsfhsprayderivative of a monomial(hsprayDerivative of a spray)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 == unitSpray*hsprayThe unit sprayp ^*^ unitSpray == p+hsprayThe null sprayp ^+^ zeroSpray == p,hsprayConstant spray!constantSpray 3 == 3 *^ unitSpray-hspray%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.hspray Get the constant term of a spray(getConstantTerm p == getCoefficient [] pghspraynumber of variables in a sprayhhsprayevaluates a monomial/hsprayEvaluates a sprayx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intp = 2*^x^**^2 ^-^ 3*^yevalSpray p [2, 1]5ihsprayspray from monomialjhspray'substitute some variables in a monomial0hspray4Substitutes some variables in a spray by some valuesx1 :: 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) 1hsprayConverts a spray with rational coefficients to a spray with double coefficients (useful for evaluation)2hspraySustitutes the variables of a spray with some sprays (e.g. change of variables)x :: 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) Z3hspray$Creates a spray from a list of terms4hspray!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 [3, 1, 2] p == f x3 x1 x25hspraySwaps two variables of a spray6swapVariables (1, 3) p == permuteVariables [3, 2, 1] pkhspray(prettyPowers "x" [0, 2, 1] = x^(0, 2, 1)6hsprayPretty 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)lhspray"prettyPowers' [0, 2, 1] = "x2^2x3"7hspray8Pretty form of a spray, with monomials shown 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 8hsprayPretty form of a spray, with monomials shown as "x1x3^2", and with a user-defined showing function for the coefficients&prettySpray' p == prettySpray'' show pmhspray!prettyPowersXYZ [1, 2, 1] = XY^2Z9hspray5Pretty 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^3:hsprayTerms of a spray;hspraySpray as a list<hspray>Bombieri spray (for internal usage in the 'scubature' library)nhsprayindex of the maximum of a list=hsprayLeading term of a spray ohspray+whether a monomial divides another monomialphspray: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 monomials?hsprayDivision of a spray by a sprayqhsprayslight modification of > to speed up groebner00rhspray+groebner basis, not minimal and not reducedshspray'groebner basis, minimal but not reduced@hsprayReduces a Groebner basisAhspray4Groebner basis (always minimal and possibly reduced)groebner sprays True == reduceGroebnerBasis (groebner sprays False)thspray'combinations of k elements among a listuhspray/generates all permutations of a binary sequenceBhsprayElementary symmetric polynomial*putStrLn $ prettySpray' (esPolynomial 3 2)(1) x1x2 + (1) x1x3 + (1) x2x3ChsprayPower sum polynomialDhspray)Whether a spray is a symmetric polynomialEhsprayWhether 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)vhspraysylvester matrixwhspray"truncated" Sylvester matrixxhspraydeterminant of a matrixyhspraythe coefficients of a spray as a univariate spray in x with spray coefficientsFhsprayResultant of two  univariate spraysGhspraySubresultants of two  univariate spraysHhsprayResultant of two spraysIhspraySubresultants of two spraysJhsprayResultant of two sprays with coefficients in a field; this function is more efficient than the function Hzhspraythe coefficients of a spray as a univariate spray in x_n with spray coefficients{hspraythe degree of a spray as a univariate spray in x_n with spray coefficients|hspraythe degree and the leading coefficient of a spray as a univariate spray in x_n with spray coefficients}hspray9pseudo-division of two sprays, assuming degA >= degB >= 0~hsprayrecursive GCD functionKhsprayGreatest common divisor of two sprays with coefficients in a fieldhspray&a string to denote the variable, e.g. "a"hspray&a string to denote the variable, e.g. "a" hspray,the value at which the evaluation is desiredhspray9a string to denote the outer variable of the spray, e.g. "a"hspray>a symbolic spray; note that this function does not simplify ithspray9a string to denote the outer variable of the spray, e.g. "a"hspray?a symbolic qspray; note that this function does not simplify it hspraysymbolic spray to be evaluatedhspraya value for the outer variablehspray$some values for the inner variables (hspray8index of the variable of differentiation (starting at 1)hspraythe spray to be derivatedhspraythe derivated spray6hspray6function mapping a coefficient to a string, typically hspray(a string denoting the variable, e.g. "x"hspray the spray?hspray dividend hspraydivisorhspray(quotient, remainder)Ahspraylist of sprays hspray#whether to return the reduced basisBhspraynumber of variableshsprayindexChspraynumber of variableshspraypowerHhsprayindicator of the variable with respect to which the resultant is desired (e.g. 1 for x)Ihsprayindicator of the variable with respect to which the subresultants are desired (e.g. 1 for x)Jhsprayindicator of the variable with respect to which the resultant is desired (e.g. 1 for x)}hspraynumber of variableshsprayAhsprayBhspray)(c, (Q, R)) such that c^*^A = B^*^Q ^+^ R)*+,&'"#$%6789   !-.:/02(45?>A@BCDHJFIGK3;1=E<)*+,&'"#$%6789   !-.:/02(45?>A@BCDHJFIGK3;1=E<7"6#6$7%8&7'7      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~%hspray-0.2.5.0-A3S1T7Cj7OsLjJCDLvjCUsMath.Algebra.HsprayhsprayQSpraySprayMonomialPowers exponents nvariablesSymbolicQSpray SymbolicSprayRatioOfQPolynomials QPolynomialRatioOfPolynomials PolynomialQ Rational'AscalarQ*. constPolypolyFromCoeffs outerVariable constQPolyqpolyFromCoeffsouterQVariableprettyRatioOfPolynomialsprettyRatioOfQPolynomialsevalRatioOfPolynomialssimplifySymbolicSprayprettySymbolicSprayprettySymbolicQSprayevalSymbolicSprayevalSymbolicSpray'evalSymbolicSpray''^+^^-^^*^^**^*^.^ derivSpraylone unitSpray zeroSpray constantSpraygetCoefficientgetConstantTerm evalSpraysubstituteSprayfromRationalSpray composeSprayfromListpermuteVariables swapVariables prettySpray prettySpray' prettySpray''prettySprayXYZ sprayTermstoList bombieriSpray leadingTermsprayDivisionRemainder sprayDivisionreduceGroebnerBasisgroebner esPolynomial psPolynomialisSymmetricSprayisPolynomialOf resultant1subresultants1 resultant subresultants resultant'gcdSpray$fCA$fCTT$fCAT$fHashablePowers $fEqPowers $fCHashMap $fCaHashMap $fCHashMap0 $fCTHashMap $fShowPowers$fEqA$fCA0$fCA1$fCA2showQpolshowQpolysRatio growSequence harmonizesimplifyPowers addSprays negateSpray scaleSpray multMonomial multSprays simplifySpray cleanSpray derivMonomialnumberOfVariables evalMonomial fromMonomialsubstituteMonomial prettyPowers prettyPowers'prettyPowersXYZmaxIndexdividesquotientsprayDivisionRemainder' groebner00 groebner0combinationsOfpermutationsBinarySequencesylvesterMatrixsylvesterMatrix' detLaplacesprayCoefficientssprayCoefficients'degreedegreeAndLeadingCoefficientpseudoDivision gcdKX1dotsXnbaseGHC.Showshow