Macaulay2 » Documentation
Packages » Macaulay2Doc :: someTerms
next | previous | forward | backward | up | index | toc

someTerms -- select some terms of a polynomial

Synopsis

Description

The index i is 0-based, and a negative number refers to location from the end of the polynomial.
i1 : R = ZZ[a..d];
i2 : f = (a+2*b-3)^2

      2            2
o2 = a  + 4a*b + 4b  - 6a - 12b + 9

o2 : R
i3 : someTerms(f,0,1) -- the lead term

      2
o3 = a

o3 : R
i4 : someTerms(f,-1,1) -- the last term

o4 = 9

o4 : R
i5 : someTerms(f,-2,2) -- the last 2 terms

o5 = - 12b + 9

o5 : R
Here is an example where the coefficient ring is also a polynomial ring.
i6 : S = R[x,y,z];
i7 : f = (x*(a-b)+y^2+a-1)^2

      4               2     2           2  2            2      2            
o7 = y  + (2a - 2b)x*y  + (a  - 2a*b + b )x  + (2a - 2)y  + (2a  - 2a*b - 2a
     ------------------------------------------------------------------------
               2
     + 2b)x + a  - 2a + 1

o7 : S
i8 : someTerms(f,-1,1) -- the last term

      2
o8 = a  - 2a + 1

o8 : S
i9 : someTerms(f,-2,2) -- the last 2 terms

        2                       2
o9 = (2a  - 2a*b - 2a + 2b)x + a  - 2a + 1

o9 : S

See also

Ways to use someTerms :

For the programmer

The object someTerms is a method function.