Macaulay2 » Documentation
Packages » Macaulay2Doc » rings » manipulating polynomials » someTerms
next | previous | forward | backward | up | index | toc

# someTerms -- select some terms of a polynomial

- Usage:
    `someTerms(f,i,n)`
- Inputs:
  - f, a ring element, in a polynomial ring
  - i, an integer, the starting index
  - n, an integer, the number of terms to select
- Outputs:
  - a ring element, the n terms of the polynomial f starting with the i-th one

## 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

- monomials -- matrix of monomials in a ring element or matrix
- coefficients -- get the monomials and coefficients of a polynomial or matrix
- terms -- provide a list of terms of a polynomial
- leadTerm -- get the greatest term

## Ways to use someTerms:

- `someTerms(RingElement,ZZ,ZZ)`

## For the programmer

The object someTerms is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/someTerms-doc.m2:35:0.