## `nterms` -- the number of terms of a polynomial

#### Introduction

`nterms(`p`)` returns the number of terms of the polynomial `p`.

#### Call(s)

`nterms(p)`
`nterms(f <, vars>)`

#### Parameters

`p` | - | a polynomial of type `DOM_POLY`
`f` | - | a polynomial expression
`vars` | - | a list of indeterminates of the polynomial: typically, identifiers or indexed identifiers

#### Returns

a nonnegative number. `FAIL` is returned if the input cannot be converted to a polynomial.

### Overloadable:

`p`

#### Related Functions

`coeff`, `degree`, `degreevec`, `ground`, `lcoeff`, `ldegree`, `lmonomial`, `lterm`, `nthcoeff`, `nthmonomial`, `nthterm`, `poly`, `poly2list`, `tcoeff`

#### Details

- If the first argument `f` is not element of a polynomial domain, then `nterms` converts the expression to a polynomial via `poly``(f)`. If a list of indeterminates is specified, then the polynomial `poly``(f, vars)` is considered.
- A zero polynomial has no terms: the return value is 0.
- `nterms` is a function of the system kernel.

#### Example 1

We give some self explaining examples:

    >> nterms(x^2*y^2 + x^2 + y + 2, [x, y])

                                         4

    >> nterms(poly(x^2*y^2 + x^2 + y + 2))

                                         4

    >> nterms(poly(0, [x]))

                                         0

#### Example 2

The following polynomial expression may be regarded as a polynomial in different ways:

    >> f := x^2*y^2 + x^2 + y + 2:
       nterms(f, [x]), nterms(f, [y]), nterms(f, [x, y]),
       nterms(f, [z])

                                    2, 3, 4, 1

    >> delete f:

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000