It is possible within Magma to assign weights to the variables of a multivariate polynomial ring. This means that monomials of the ring then have a weighted degree with respect to the weights of the variables. Such a multivariate polynomial ring is called graded or weighted. A polynomial of the ring whose monomials all have the same weighted degree is called homogeneous. The polynomial ring can be decomposed as the direct sum of graded homogeneous components.
Suppose a polynomial ring P has n variables x_1, ..., x_n and the weights for the variables are d_1, ..., d_n respectively. Then for a monomial m = x_1^(e_1) ... x_n^(e_n) of P (with e_i >= 0 for 1 <= i <= n), the weighted degree of m is defined to be sum_(i=1)^(n) e_i d_i.
A polynomial ring created without a specific weighting (using the default version of the PolynomialRing function or similar) has weight 1 for each variable so the weighted degree coincides with the total degree.
The following functions allow one to create and operate on elements of polynomial rings with specific weights for the variables.
Given a ring R and a non-empty sequence Q of positive integers, create a multivariate polynomial ring in n=#Q indeterminates over the ring R with the weighted degree of the i-th indeterminate set to be Q[i] for each i. The rank n of the polynomial is determined by the length of the sequence Q. (The angle bracket notation can be used to assign names to the indeterminates, just like in the usual invocation of the PolynomialRing function.)
Given a graded polynomial ring P (or an ideal thereof), return the variable weights of P as a sequence of n integers where n is the rank of P. If P was constructed without specific weights, the sequence containing n copies of the integer 1 is returned.
Given a polynomial f of the graded polynomial ring P, this function returns the weighted degree of f, which is the maximum of the weighted degrees of all monomials that occur in f. The weighted degree of a monomial m depends on the weights assigned to the variables of the polynomial ring P -- see the introduction of this section for details. Note that this is different from the total degree of f which ignores any weights.
Given a polynomial f of the graded polynomial ring P, this function returns the leading weighted degree of f, which is the weighted degree of the leading monomial of f. The weighted degree of a monomial m depends on the weights assigned to the variables of the polynomial ring P -- see the introduction of this section for details.
Given a polynomial f of the graded polynomial ring P, this function returns whether f is homogeneous with respect to the weights on the variables of P (i.e., whether the weighted degrees of the monomials of f are all equal).
Given an ideal I of the graded polynomial ring P, this function returns whether I is homogeneous with respect to the weights on the variables of P (i.e., whether I possesses a basis consisting of homogeneous polynomials alone).
Given a polynomial f of the graded polynomial ring P, this function returns the weighted degree-d homogeneous component of f which is the sum of all the terms of f whose monomials have weighted degree d. d must be greater than or equal to 0. If f has no terms of weighted degree d, then the result is 0.
Given a polynomial f of the graded polynomial ring P, this function returns the weighted degree-d homogeneous component of f which is the sum of all the terms of f whose monomials have weighted degree d. d must be greater than or equal to 0. If f has no terms of weighted degree d, then the result is 0.
Given a polynomial ring P and a non-negative integer d, return an indexed set consisting of all monomials in P with total degree d. If P is graded, the grading is ignored.
Given a graded polynomial ring P and a non-negative integer d, return an indexed set consisting of all monomials in P with weighted degree d. If P has the trivial grading, then this function is equivalent to the function MonomialsOfDegree.
Given a set or sequence S of polynomials from a graded polynomial ring P, return the weighted degree-d Gröbner basis of the ideal generated by S, which is the truncated Gröbner basis obtained by ignoring S-polynomial pairs whose weighted degree (with respect to the grading on P) is greater than d.If the ideal is homogeneous, then it is guaranteed that the result is equal to the set of all polynomials in the full Gröbner basis of the ideal whose weighted degree is less than or equal to d, and a polynomial whose weighted degree is less than or equal to d is in the ideal iff its normal form with respect to this truncated basis is zero. But if the ideal is not homogeneous, these last properties may not hold, but it may be still useful to construct the truncated basis.
The parameters are the same as those for the procedure Groebner. See also [BW93, section 10.2] for further discussion. Note that the base ring may be a field or Euclidean ring.
> P<x, y, z> := PolynomialRing(RationalField(), [1, 2, 4]);
> P;
Graded Polynomial ring of rank 3 over Rational Field
Lexicographical Order
Variables: x, y, z
Variable weights: 1 2 4
> VariableWeights(P);
[ 1, 2, 4 ]
> WeightedDegree(x);
1
> WeightedDegree(y);
2
> WeightedDegree(z);
4
> WeightedDegree(x^2*y*z^3);
16
> TotalDegree(x^2*y*z^3);
6
> IsHomogeneous(x);
true
> IsHomogeneous(x + y);
false
> IsHomogeneous(x^2 + y);
true
> I := ideal<P | y^2 + 2*x^2*y, (x^4 + z)^2, x + y, x^2 + x>;
> IsHomogeneous(I);
true
> MonomialsOfDegree(P, 4);
{@
x^4,
x^3*y,
x^3*z,
x^2*y^2,
x^2*y*z,
x^2*z^2,
x*y^3,
x*y^2*z,
x*y*z^2,
x*z^3,
y^4,
y^3*z,
y^2*z^2,
y*z^3,
z^4
@}
> MonomialsOfWeightedDegree(P, 4);
{@
x^4,
x^2*y,
y^2,
z
@}
> P<a,b,c,d> := PolynomialRing(RationalField(), [4,3,2,1]);
> L := [a*b - c^2*d^3, b*c*d + c^3, c^2*d - d^5, a*d - b*c];
> [IsHomogeneous(f): f in L];
[ true, true, true, true ]
> [WeightedDegree(f): f in L];
[ 7, 6, 5, 5 ]
> G:=GroebnerBasis(L);
> G;
[
a*b - d^7,
a*c^3 + d^10,
a*d - b*c,
b^2*c - d^8,
b*c^3 + d^9,
b*c*d + c^3,
b*d^5 + c^4,
c^5 - d^10,
c^2*d - d^5,
c*d^7 - d^9
]
> #G;
10
> [WeightedDegree(f): f in G];
[ 7, 10, 5, 8, 9, 6, 8, 10, 5, 9 ]
> for D := 1 to 10 do
> T := GroebnerBasis(L, D);
> printf "D = %o, #GB = %o, contains all degree-D polynomials: %o\n",
> D, #T, {f: f in G | WeightedDegree(f) le D} subset T;
> end for;
D = 1, #GB = 4, contains all degree-D polynomials: true
D = 2, #GB = 4, contains all degree-D polynomials: true
D = 3, #GB = 4, contains all degree-D polynomials: true
D = 4, #GB = 4, contains all degree-D polynomials: true
D = 5, #GB = 4, contains all degree-D polynomials: true
D = 6, #GB = 4, contains all degree-D polynomials: true
D = 7, #GB = 4, contains all degree-D polynomials: true
D = 8, #GB = 6, contains all degree-D polynomials: true
D = 9, #GB = 8, contains all degree-D polynomials: true
D = 10, #GB = 10, contains all degree-D polynomials: true
> GroebnerBasis(L, 5);
[
a*b - d^7,
a*d - b*c,
b*c*d + c^3,
c^2*d - d^5
]
> GroebnerBasis(L, 8);
[
a*b - d^7,
a*d - b*c,
b^2*c - d^8,
b*c*d + c^3,
b*d^5 + c^4,
c^2*d - d^5
]