h*Z"V      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx0.2.6.0#Multivariate polynomials on a ring.(c) Stphane Laurent, 2023GPL-3laurent_step@outlook.fr Safe-Inferred 3UhsprayIdentify a rational to a  A Rational' elementhspray>Division of univariate polynomials; this is an application of y followed by a simplification of the obtained fraction of the two polynomialshspray3Scale 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)-constQPoly (2 % 3) == qpolyFromCoeffs [2 % 3]hspray0Rational univariate polynomial from coefficientsimport Number.Ratio ( (%) )!qpolyFromCoeffs [2 % 3, 5, 7 % 4]hsprayThe variable of a univariate rational polynomial; it is called "outer" because it is the variable occuring in the coefficients of a . (but I do not like this name - see README) (outerQVariable == qpolyFromCoeffs [0, 1]zhsprayidentify a `Polynomial a` to a `Spray a`, in order to apply the show spray functions to the univariate polynomials{hsprayhelper function for prettyRatioOfPolynomials (and prettySymbolicSpray)hsprayPretty form of a ratio of univariate polynomials with rational coefficients|hsprayhelper function for prettyRatioOfPolynomials (and prettySymbolicSpray)}hsprayhelper function for prettyRatioOfPolynomials (and prettySymbolicSpray)hspray0Pretty form of a ratio of univariate polynomialshspray+Evaluates a ratio of univariate polynomials~hspraysimplifies a ratio of polynomials (simply by multiplying it by one)hspraySimplifies the coefficients (the fractions of univariate polynomials) of a symbolic sprayhsprayPretty form of a symbolic spray, using a string (typically a letter) followed by an index to denote the variables hsprayPretty form of a symbolic spray, using some given strings (typically some letters) to denote the variables if possible, i.e. if enough letters are provided; otherwise this function behaves exactly like prettySymbolicQSprayX1X2X3 a where a is the first provided letter!hsprayPretty form of a symbolic spray; see the definition below and see  prettySymbolicSpray a spray == prettySymbolicSprayXYZ a ["x","y","z"] spray"hsprayPretty form of a symbolic spray; see the definition below and see  prettySymbolicSpray' a spray == prettySymbolicSprayXYZ a ["X","Y","Z"] spray#hsprayPretty form of a symbolic rational spray, using a string (typically a letter) followed by an index to denote the variables$hsprayPretty form of a symbolic rational spray, using some given strings (typically some letters) to denote the variables if possible, i.e. if enough letters are provided; otherwise this function behaves exactly like prettySymbolicQSprayX1X2X3 a where a is the first provided letter%hspray0Pretty form of a symbolic rational spray, using "x", "y" and "z" for the variables if possible; i.e. if the spray does not have more than three variables, otherwise "x1", "x2"&, ... are used to denote the variablesprettySymbolicQSpray a == prettySymbolicQSprayXYZ a ["x","y","z"]&hspray0Pretty form of a symbolic rational spray, using X, Y and Z for the variables if possible; i.e. if the spray does not have more than three variables, otherwise X1, X2, ... are used prettySymbolicQSpray' a = prettySymbolicQSprayXYZ a ["X","Y","Z"]'hspraySubstitutes a value to the outer variable of a symbolic spray (the variable occuring in the coefficients)(hspraySubstitutes a value to the outer variable of a symbolic spray as well as some values to the inner variables of this sprayhspray'helper function for evalSymbolicSpray'')hspraySubstitutes some values to the inner variables of a symbolic sprayhsprayappend trailing zeroshspray,append trailing zeros to get the same lengthhspraydrop trailing zeroshsprayaddition of two sprayshsprayopposite sprayhsprayscale a spray by a scalarhspraymultiply two monomialshspraymultiply two sprays*hsprayAddition of two sprays+hspraySubstraction of two sprays,hsprayMultiply two sprays-hsprayPower of a spray.hspray-Scale a spray by a scalar; if you import the Algebra.Module+ module then it is the same operation as (*>) from this module/hsprayScale a spray by an integer3 .^ p == p ^+^ p ^+^ phspray,drop trailing zeros in the powers of a sprayhspray%simplify powers and remove zero termshsprayderivative of a monomial0hsprayDerivative of a sprayx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intspray = 2*^x ^-^ 3*^y^**^8spray' = derivSpray 1 spray putStrLn $ prettyNumSpray spray'21hsprayThe n-th polynomial variable x_n as a spray; one usually builds a spray by introducing these variables and combining them with the arithmetic operationsx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intspray = 2*^x^**^2 ^-^ 3*^yputStrLn $ prettyNumSpray spray 2*x^2 - 3*ylone 0 == unitSpray2hsprayThe unit sprayp ^*^ unitSpray == p3hsprayThe null sprayp ^+^ zeroSpray == phspraywhether the spray is zero4hsprayConstant spray!constantSpray 3 == 3 *^ unitSpray5hspray%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] p06hspray Get the constant term of a spray(getConstantTerm p == getCoefficient [] p7hspraynumber of variables in a sprayhsprayevaluates a monomial8hsprayEvaluates a sprayx :: lone 1 :: Spray Inty :: lone 2 :: Spray Intp = 2*^x^**^2 ^-^ 3*^yevalSpray p [2, 1]5hsprayspray from monomialhspray'substitute some variables in a monomial9hspray4Substitutes 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 $ prettyNumSpray p'-x2 + 6 :hsprayConverts a spray with rational coefficients to a spray with double coefficients (useful for evaluation);hspraySustitutes 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 $ prettyNumSpray' q X + Y + 2*Z<hspray$Creates a spray from a list of terms=hspray!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 x2>hspray#Swaps two variables whithin a spray>swapVariables (1, 3) spray == permuteVariables [3, 2, 1] spray?hsprayPrints a spray; this function is exported for possible usage in other packages@hsprayPrints a spray, with monomials shown as "x.z^2", and with a user-defined showing function for the coefficientsAhspray(Prints a spray, with monomials shown as "x.z^2", and with a user-defined showing function for the coefficients; this is the same as the function @ with the pair of braces  ("(", ")")BhsprayPretty form of a spray with monomials displayed in the style of "x.z^2"; you should rather use K or P# if your coefficients are numericx = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3+putStrLn $ prettySprayXYZ ["X", "Y", "Z"] p(2)*X + (3)*Y^2 + (-4)*Z^3&putStrLn $ prettySprayXYZ ["X", "Y"] p(2)*X1 + (3)*X2^2 + (-4)*X3^3ChsprayPretty form of a spray, with monomials shown as "x1.x3^2", and with a user-defined showing function for the coefficientsDhsprayPretty form of a spray, with monomials shown as "x1.x3^2", and with a user-defined showing function for the coefficients; this is the same as the function C with the pair of braces  ("(", ")")# used to enclose the coefficientsEhsprayPretty form of a spray with monomials displayed in the style of  "x1.x3^2"; you should rather use J or N# if your coefficients are numericx = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int(spray = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3&putStrLn $ prettySprayX1X2X3 "X" spray(2)*X1 + (3)*X2^2 + (-4)*X3^3FhsprayPretty form of a spray with monomials displayed in the style of "x.z^2"; you should rather use V or R4 if you deal with sprays with numeric coefficientsx = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3putStrLn $ prettySpray p(2)*x + (3)*y^2 + (-4)*z^3%putStrLn $ prettySpray (p ^+^ lone 4)"(2)*x1 + (3)*x2^2 + (-4)*x3^3 + x49prettySpray spray == prettySprayXYZ ["x", "y", "z"] sprayGhspray0Pretty form of a spray, with monomials shown as  "x1.x3^2"; use E to change the letter (or J or N! if the coefficients are numeric)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 hspray+showMonomialOld "x" [0, 2, 1] = x^(0, 2, 1)Hhspray1Pretty form of a spray; you will probably prefer F or Gx = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3putStrLn $ prettySpray'' "x" p+(2)*x^(1) + (3)*x^(0, 2) + (-4)*x^(0, 0, 3)IhsprayShow a spray with numeric coefficients; this function is exported for possible usage in other packageshsprayshowMonomialX1X2X3 X [0, 2, 1] = "X2^2.X3"hsprayshowMonomialsX1X2X3 X# [[0, 2, 1], [1, 2]] = ["X2^2.X3", X1.X2]hsprayshowMonomialXYZ [X, Y, Z,] 3 [1, 2, 1] = X.Y^2.Z showMonomialXYZ [X, Y, Z"] 3 [1, 2, 1, 2] = X1.X2^2.X3.X4^2hsprayshowMonomialsXYZ [X, Y, Z*] [[0, 2, 1], [1, 2]] = ["Y^2.Z", "X.Y^2"]JhsprayPretty form of a spray with numeric coefficients, printing monomials as  "x1.x3^2"x = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3%putStrLn $ prettyNumSprayX1X2X3 "x" p2*x1 + 3*x2^2 - 4*x3^3 KhsprayPretty form of a spray with numeric coefficients, printing monomials as "x.z^2" if possible, i.e. if enough letters are provided, otherwise as  "x1.x3^2"x = lone 1 :: Spray Inty = lone 2 :: Spray Intz = lone 3 :: Spray Intw = lone 4 :: Spray Int$p = 2*^x ^+^ 3*^y^**^2 ^-^ 4*^z^**^3,putStrLn $ prettyNumSprayXYZ ["x","y","z"] p2*x + 3*y^2 - 4*z^3 4putStrLn $ prettyNumSprayXYZ ["x","y","z"] (p ^+^ w)2*x1 + 3*x2^2 - 4*x3^3 + x44putStrLn $ prettyNumSprayXYZ ["a","b","c"] (p ^+^ w)2*a1 + 3*a2^2 - 4*a3^3 + a4hsprayhelper function for showQSprayhspray helper function for showQSpray' Lhspray Prints a =; for internal usage but exported for usage in other packagesMhspray Prints a =; for internal usage but exported for usage in other packagesNhsprayPretty form of a spray with rational coefficients, printing monomials in the style of  "x1.x3^2"x = lone 1 :: QSprayy = lone 2 :: QSprayz = lone 3 :: QSpray(p = 2*^x ^+^ 3*^y^**^2 ^-^ (4%3)*^z^**^3#putStrLn $ prettyQSprayX1X2X3 "x" p2*x1 + 3*x2^2 - (4/3)*x3^3 OhspraySame as N but for a  sprayPhsprayPretty form of a spray with rational coefficients, printing monomials in the style of "x.z^2" with the provided letters if possible, i.e. if enough letters are provided, otherwise in the style  "x1.x3^2", taking the first provided letter to denote the non-indexed variablesx = lone 1 :: QSprayy = lone 2 :: QSprayz = lone 3 :: QSpray(p = 2*^x ^+^ 3*^y^**^2 ^-^ (4%3)*^z^**^3*putStrLn $ prettyQSprayXYZ ["x","y","z"] p2*x + 3*y^2 - (4/3)*z^3 &putStrLn $ prettyQSprayXYZ ["x","y"] p2*x1 + 3*x2^2 - (4%3)*x3^3&putStrLn $ prettyQSprayXYZ ["a","b"] p2*a1 + 3*a2^2 - (4/3)*a3^3QhspraySame as P but for a  sprayRhsprayPretty printing of a spray with rational coefficients prop> prettyQSpray == prettyQSprayXYZ ["x", "y", "z"]ShsprayPretty printing of a spray with rational coefficients prop> prettyQSpray'' == prettyQSprayXYZ [X, Y, Z]ThsprayPretty printing of a spray with rational coefficients prop> prettyQSpray' == prettyQSprayXYZ' ["x", "y", "z"]UhsprayPretty printing of a spray with rational coefficients prop> prettyQSpray''' == prettyQSprayXYZ' [X, Y, Z]VhsprayPretty printing of a spray with numeric coefficients prop> prettyNumSpray == prettyNumSprayXYZ ["x", "y", "z"]WhsprayPretty printing of a spray with numeric coefficients prop> prettyNumSpray' == prettyNumSprayXYZ [X, Y, Z]XhsprayTerms of a sprayYhspraySpray as a listZhspray>Bombieri spray (for internal usage in the 'scubature' library)[hspray2Whether two sprays are equal up to a scalar factorhsprayindex of the maximum of a list\hsprayLeading term of a spray hspray+whether a monomial divides another monomialhspray: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 sprayhsprayslight modification of ] to speed up groebner00hspray+groebner basis, not minimal and not reducedhspray'groebner basis, minimal but not reduced_hsprayReduces a Groebner basis`hspray2Grbner basis, always minimal and possibly reducedgroebner sprays True == reduceGroebnerBasis (groebner sprays False)hspray'combinations of k elements among a listhspray/generates all permutations of a binary sequenceahsprayElementary symmetric polynomial*putStrLn $ prettySpray' (esPolynomial 3 2)(1)*x1x2 + (1)*x1x3 + (1)*x2x3bhsprayPower sum polynomialchsprayWhether a spray is a symmetric polynomial, an inefficient algorithm (use the function with the same name in the jackpolynomials" package if you need efficiency)dhsprayWhether 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)hspraysylvester matrixhspray"truncated" Sylvester matrixhspraydeterminant of a matrixhspraythe coefficients of a spray as a univariate spray in x_1 with spray coefficientsehsprayResultant of two  univariate spraysfhspraySubresultants of two  univariate spraysghsprayResultant of two sprayshhspraySubresultants of two spraysihsprayResultant of two sprays with coefficients in a field; this function is more efficient than the function ghspraythe coefficients of a spray as a univariate spray in x_n with spray coefficientshspraythe degree of a spray as a univariate spray in x_n with spray coefficientshspraythe degree and the leading coefficient of a spray as a univariate spray in x_n with spray coefficientshspray9Pseudo-division of two sprays, assuming degA >= degB >= 0hsprayrecursive GCD functionjhsprayGreatest common divisor of two sprays with coefficients in a field&hspray&a string to denote the variable, e.g. "a" hspray>string (usually a single letter) to denote the variable, e.g. "a"hspray,the value at which the evaluation is desiredhspray7string to denote the outer variable of the spray, e.g. "a"hspray7typically a letter, to denote the non-indexed variableshspray>a symbolic spray; note that this function does not simplify it hspray7string to denote the outer variable of the spray, e.g. "a"hspray4typically some letters, to denote the main variableshspray>a symbolic spray; note that this function does not simplify it!hspray7string to denote the outer variable of the spray, e.g. "a"hspray>a symbolic spray; note that this function does not simplify it"hspray7string to denote the outer variable of the spray, e.g. "a"hspray>a symbolic spray; note that this function does not simplify it#hspray7string to denote the outer variable of the spray, e.g. "a"hspray7string to denote the non-indexed variables of the sprayhspray?a symbolic qspray; note that this function does not simplify it$hspray7string to denote the outer variable of the spray, e.g. "a"hspray:usually some letters, to denote the variables of the sprayhspray?a symbolic qspray; note that this function does not simplify it%hspray7string to denote the outer variable of the spray, e.g. "a"hspraythe symbolic qspray to be printed; note that this function does not simplify it&hspray7string to denote the outer variable of the spray, e.g. "a"hspraythe symbolic qsprayto be printed; note that this function does not simplify it(hspraysymbolic spray to be evaluatedhspraya value for the outer variablehspray$some values for the inner variables 0hspray8index of the variable of differentiation (starting at 1)hspraythe spray to be derivatedhspraythe derivated spray?hspray6function mapping a coefficient to a string, typically hspray*pair of braces to enclose the coefficientshsprayfunction mapping a list of exponents to a list of strings representing the monomials corresponding to these exponentshspraythe spray to be printed@hspray6function mapping a coefficient to a string, typically hspray:used to enclose the coefficients, usually a pair of braceshspray7strings, typically some letters, to print the variableshspraythe spray to be printedAhspray6function mapping a coefficient to a string, typically hspray7strings, typically some letters, to print the variableshspraythe spray to be printedBhspray.typically some letters, to print the variableshspraythe spray to be printedChspray6function mapping a coefficient to a string, typically hspray used to enclose the coefficientshspray6typically a letter, to print the non-indexed variableshspraythe spray to be printedDhspray1function mapping a coefficient to a string, e.g. hspray6typically a letter, to print the non-indexed variableshspraythe spray to be printedEhspray6typically a letter, to print the non-indexed variableshspraythe spray to be printedHhspray)a string denoting the variables, e.g. "x"hspray the sprayIhsprayfunction mapping a list of monomial exponents to a list of strings representing the monomialshspray3function mapping a positive coefficient to a stringJhsprayusually a letter such as "x"$ to denote the non-indexed variablesKhspray,usually some letters, denoting the variablesLhsprayfunction printing monomialsMhsprayfunction mapping a list of monomials exponents to a list of stringsNhsprayusually a letter such as "x"%, to denote the non-indexed variablesOhsprayusually a letter such as "x"%, to denote the non-indexed variablesPhspray-usually some letters, to denote the variablesQhspray-usually some letters, to denote the variables^hspray dividend hspraydivisorhspray(quotient, remainder)`hspraylist of sprays hspray#whether to return the reduced basisahspraynumber of variableshsprayindexbhspraynumber of variableshspraypowerghsprayindicator of the variable with respect to which the resultant is desired (e.g. 1 for x)hhsprayindicator of the variable with respect to which the subresultants are desired (e.g. 1 for x)ihsprayindicator 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 ^+^ R1234./*+,-FGHBE?@ACDILMJNOKPQVWRSTU   !"#$%&'()567X89;0=>^]`_abcgiehfj^]`_abcgiehfj?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~%hspray-0.2.6.0-ID4NMSgoBxCHeHfnum8B1kMath.Algebra.HsprayhsprayQSpray'QSpraySprayMonomialPowers exponents nvariablesSymbolicQSpray SymbolicSprayRatioOfQPolynomials QPolynomialRatioOfPolynomials PolynomialQ Rational'AscalarQ^/^*. constPolypolyFromCoeffs outerVariable constQPolyqpolyFromCoeffsouterQVariableprettyRatioOfQPolynomialsprettyRatioOfPolynomialsevalRatioOfPolynomialssimplifySymbolicSprayprettySymbolicSprayX1X2X3prettySymbolicSprayXYZprettySymbolicSprayprettySymbolicSpray'prettySymbolicQSprayX1X2X3prettySymbolicQSprayXYZprettySymbolicQSprayprettySymbolicQSpray'evalSymbolicSprayevalSymbolicSpray'evalSymbolicSpray''^+^^-^^*^^**^*^.^ derivSpraylone unitSpray zeroSpray constantSpraygetCoefficientgetConstantTermnumberOfVariables evalSpraysubstituteSprayfromRationalSpray composeSprayfromListpermuteVariables swapVariables showSpray showSprayXYZ showSprayXYZ'prettySprayXYZshowSprayX1X2X3showSprayX1X2X3'prettySprayX1X2X3 prettySpray prettySpray' prettySpray'' showNumSprayprettyNumSprayX1X2X3prettyNumSprayXYZ showQSpray showQSpray'prettyQSprayX1X2X3prettyQSprayX1X2X3'prettyQSprayXYZprettyQSprayXYZ' prettyQSprayprettyQSpray'' prettyQSpray'prettyQSpray'''prettyNumSprayprettyNumSpray' sprayTermstoList bombieriSpraycollinearSprays leadingTermsprayDivisionRemainder sprayDivisionreduceGroebnerBasisgroebner esPolynomial psPolynomialisSymmetricSprayisPolynomialOf resultant1subresultants1 resultant subresultants resultant'gcdSpray$fCA$fCTT$fCAT$fHashablePowers $fEqPowers $fCHashMap $fCaHashMap $fCHashMap0 $fCTHashMap $fShowPowers$fEqA$fCA0$fCA1$fCA2,numeric-prelude-0.4.4-CRo4YZ5tJQfEddjYHGmG9q Number.Ratio:%polynomialToSprayshowRatioOfPolynomialsshowQpolshowQpolysRatiosimplifyRatioOfPolynomialsevalSymbolicMonomial growSequence harmonizesimplifyPowers addSprays negateSpray scaleSpray multMonomial multSprays simplifySpray cleanSpray derivMonomial isZeroSpray evalMonomial fromMonomialsubstituteMonomialshowMonomialsOldshowMonomialX1X2X3showMonomialsX1X2X3showMonomialXYZshowMonomialsXYZ showRatio showRatio'maxIndexdividesquotientsprayDivisionRemainder' groebner00 groebner0combinationsOfpermutationsBinarySequencesylvesterMatrixsylvesterMatrix' detLaplacesprayCoefficientssprayCoefficients'degreedegreeAndLeadingCoefficientpseudoDivision gcdKX1dotsXnbaseGHC.Showshow