next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: part

part -- select terms of a polynomial by degree(s) or weight(s)

Synopsis

Description

To select terms of a single degree, use part(deg, f). An alternate syntax uses an underscore.

i1 : R = QQ[x,y];
i2 : f = (x+y+1)^4

      4     3      2 2       3    4     3      2         2     3     2  
o2 = x  + 4x y + 6x y  + 4x*y  + y  + 4x  + 12x y + 12x*y  + 4y  + 6x  +
     ------------------------------------------------------------------------
               2
     12x*y + 6y  + 4x + 4y + 1

o2 : R
i3 : part(2, f)

       2             2
o3 = 6x  + 12x*y + 6y

o3 : R
i4 : part_2 f

       2             2
o4 = 6x  + 12x*y + 6y

o4 : R

To select terms within a range of degrees, use part(lo, hi, f).

i5 : part(1, 2, f)

       2             2
o5 = 6x  + 12x*y + 6y  + 4x + 4y

o5 : R

In the next example, we apply the weights {2,3} before selecting terms. In other words, the term xayb is considered to have degree 2a+3b.

i6 : part(6, {2,3}, f)

       3     2
o6 = 4x  + 6y

o6 : R
i7 : part(6, 8, {2,3}, f)

      4     3      2         2     2
o7 = x  + 4x  + 12x y + 12x*y  + 6y

o7 : R

If the generators of the ring were defined to have non-unit degrees, the weights override those degrees.

i8 : R = QQ[x,y, Degrees=>{2,3}];
i9 : f = (x+y+1)^4

      4       3     2 2     3      3    4        2      2      3     2  
o9 = y  + 4x*y  + 6x y  + 4x y + 4y  + x  + 12x*y  + 12x y + 4x  + 6y  +
     ------------------------------------------------------------------------
               2
     12x*y + 6x  + 4y + 4x + 1

o9 : R
i10 : part(2, f)

o10 = 4x

o10 : R
i11 : part(2, {1,1}, f)

        2             2
o11 = 6y  + 12x*y + 6x

o11 : R

By omitting lo or hi, but providing a comma indicating the omission, the range of degrees will be unbounded in the appropriate direction.

i12 : S = QQ[a,b,c]

o12 = S

o12 : PolynomialRing
i13 : g = (a - b*c + 2)^3

         3 3       2 2     2        2 2    3               2
o13 = - b c  + 3a*b c  - 3a b*c + 6b c  + a  - 12a*b*c + 6a  - 12b*c + 12a +
      -----------------------------------------------------------------------
      8

o13 : S
i14 : part(4, , g)

         3 3       2 2     2        2 2
o14 = - b c  + 3a*b c  - 3a b*c + 6b c

o14 : S
i15 : part(, 3, g)

       3               2
o15 = a  - 12a*b*c + 6a  - 12b*c + 12a + 8

o15 : S
i16 : part(, 3, 1..3, g)

       3     2
o16 = a  + 6a  + 12a + 8

o16 : S

Infinite numbers may also be given for the bounds.

i17 : part(4, infinity, g)

         3 3       2 2     2        2 2
o17 = - b c  + 3a*b c  - 3a b*c + 6b c

o17 : S
i18 : part(-infinity, 3, g)

       3               2
o18 = a  - 12a*b*c + 6a  - 12b*c + 12a + 8

o18 : S
i19 : part(-infinity, infinity, 1..3, g)

         3 3       2 2     2        2 2    3               2
o19 = - b c  + 3a*b c  - 3a b*c + 6b c  + a  - 12a*b*c + 6a  - 12b*c + 12a +
      -----------------------------------------------------------------------
      8

o19 : S

For multigraded rings, use a list to specify a single multidegree in the first argument. The underscore syntax works here too.

i20 : R = QQ[x,y,z, Degrees => {{1,0,0},{0,1,0},{0,0,1}}];
i21 : f = (x+y+z)^3

       3     2        2    3     2               2        2       2    3
o21 = x  + 3x y + 3x*y  + y  + 3x z + 6x*y*z + 3y z + 3x*z  + 3y*z  + z

o21 : R
i22 : part({2,0,1}, f)

        2
o22 = 3x z

o22 : R
i23 : part_{2,0,1} f

        2
o23 = 3x z

o23 : R

A range of degrees cannot be asked for in the multigraded case. Polynomial rings over polynomial rings are multigraded, so either use a multidegree or specify weights to avoid errors.

i24 : R = QQ[a][x];
i25 : h = (1+a+x)^3

       3            2      2               3     2
o25 = x  + (3a + 3)x  + (3a  + 6a + 3)x + a  + 3a  + 3a + 1

o25 : R
i26 : part(2, {1,0}, h)

               2
o26 = (3a + 3)x

o26 : R
i27 : part(2, {0,1}, h)

        2      2
o27 = 3a x + 3a

o27 : R
i28 : part({2,1}, h)

               2
o28 = (3a + 3)x

o28 : R

See also

Ways to use part :