content
-- the content of a
polynomialcontent(
p)
computes the content of the
polynomial p
, i.e., the gcd of its coefficients.
content(p)
content(f <, vars>)
p |
- | a polynomial of type
DOM_POLY |
f |
- | a polynomial expression |
vars |
- | a list of indeterminates of the polynomial: typically, identifiers or indexed identifiers |
an arithmetical expression, or the value
FAIL
.
p
coeff
, factor
, gcd
, icontent
, ifactor
, igcd
, ilcm
, lcm
, poly
, polylib::primpart
p
is the zero polynomial, then content
returns 0.p
is a nonzero polynomial with coefficient ring IntMod(n)
and n
is a
prime number, then content
returns 1. If
n
is not a prime number, an error message is issued.p
is a polynomial with a
library domain R
as coefficient
ring, the gcd
of its
coefficients is computed using the slot gcd
of R
. If no such slot
exists, then content
returns FAIL
.p
is a polynomial with
coefficient ring Expr
,
then content
does the following.
If all coefficients of p
are either integers or rational
numbers, content(
p)
is equivalent to
gcd(coeff(p))
, and the
return value is a positive integer or rational number. See
example 1.
If at least one coefficient is a floating
point number or a complex number and
all other coefficients are numbers, then
content
returns 1. See example 2.
If at least one coefficient is not a number and all coefficients of p
can be
converted into polynomials via poly
, then
content(
p)
is equivalent to gcd(coeff(p))
. See example 3.
Otherwise, content
returns 1.
f
is converted into a polynomial with
coefficient ring Expr
via
p :=
poly(f <,
vars>)
, and then content
is applied to
p
. See example 1.icontent
for
polynomials that are known to have integer or rational coefficients,
since it is much faster than content
.p
by its content gives
its primitive part. This one can also be obtained directly using
polylib::primpart
.If p
is a polynomial with integer or
rational coefficients, the result is the same as for icontent
:
>> content(poly(6*x^3*y + 3*x*y + 9*y, [x, y]))
3
The following call, where the first argument is a polynomial expression and not a polynomial, is equivalent to the one above:
>> content(6*x^3*y + 3*x*y + 9*y, [x, y])
3
If no list of indeterminates is specified, then poly
converts the expression into
a polynomial with respect to all occurring indeterminates, and we
obtain yet another equivalent call:
>> content(6*x^3*y + 3*x*y + 9*y)
3
Above, we considered the polynomial as a bivariate
polynomial with integer coefficients. We can also consider the same
polynomial as a univariate polynomial in x
, whose
coefficients contain a parameter y
. Then the coefficients
and their gcd--the content--are polynomial expressions in
y
:
>> content(poly(6*x^3*y + 3*x*y + 9*y, [x]))
3 y
Here is another example where the coefficients and the content are again polynomial expressions:
>> content(poly(4*x*y + 6*x^3 + 6*x*y^2 + 9*x^3*y, [x]))
3 y + 2
The following call is equivalent to the previous one:
>> content(4*x*y + 6*x^3 + 6*x*y^2 + 9*x^3*y, [x])
3 y + 2
If a polynomial or polynomial expression has numeric coefficients and at least one floating point number is among them, its content is 1:
>> content(2.0*x+2.0)
1
If not all of the coefficients are numbers, the gcd of the coefficients is returned:
>> content(poly(x^2*y+x, [y]))
x