divide
-- divide polynomialsdivide(
p, q)
divides the univariate
polynomials p
and q
. It returns the quotient
s and the remainder r satisfying p = s*q +
r, degree
(r) <
degree
(q).
divide(p1, q1 <, mode>)
divide(f1, g1 <, mode>)
divide(f, g <, [x]> <, mode>)
divide(p, q, Exact)
divide(f, g, <[x1, x2, ...],> Exact)
p1, q1 |
- | univariate polynomials of
type DOM_POLY . |
f1, g1 |
- | univariate polynomial expressions |
p, q |
- | univariate or multivariate polynomials of type
DOM_POLY . |
f, g |
- | univariate or multivariate polynomial expressions |
x |
- | an identifier or an indexed identifier. Expressions are regarded as
univariate polynomials in the indeterminate x . |
x1, x2, ... |
- | identifiers or indexed identifiers. Multivariate expressions are regarded as multivariate polynomials in these indeterminates. |
mode |
- | either Quo or Rem. With Quo, only the quotient
s is returned; with Rem, only the
remainder r is returned. |
Exact |
- | exact division of multivariate polynomials. Only the
quotient s is returned. If no exact division without
remainder is possible, FAIL is returned. |
a polynomial, a polynomial expression, a sequence of two polynomials
or polynomial expressions, or the value FAIL
.
p
, q
, p1
, q1
,
f
, g
, f1
, g1
/
, content
, degree
, div
, factor
, gcd
, gcdex
, groebner::normalf
, ground
, mod
, multcoeffs
, pdivide
, poly
, powermod
divide(
p, q)
divides the univariate
polynomials p
and q
. The quotient
s
and the remainder r
are calculated such
that p = s*q + r
and degree(r)
< degree(q)
. If no option is
given, the sequence s, r
is returned.Polynomials must be of the same type, i.e. their variables and coefficient rings must be identical.
Expressions are internally converted to polynomials (see the
function poly
). If no
list of indeterminates is specified, all symbolic variables in the
expressions are chosen as indeterminates. FAIL
is returned
if the expressions cannot be converted to polynomials.
The resulting polynomials are of the same type as the first two
arguments, i.e., either polynomials of type DOM_POLY
or polynomial expressions
are returned.
"_divide"
which is used internally
to divide coefficients. This method must return FAIL
if
coefficients cannot be divided.divide
is a function of the system kernel.Without further options, divide
returns the
quotient and the remainder of the division of univariate
polynomials:
>> divide(poly(x^3 + x + 1, [x]), poly(x^2 + x + 1, [x]))
poly(x - 1, [x]), poly(x + 2, [x])
>> divide(x^3 + x + 1, x^2 + x + 1)
x - 1, x + 2
If expressions contain more than one variable,
indeterminates must be specified. Other symbolic objects are regarded
as parameters. The option Quo instructs
divide
to return the quotient only:
>> divide(a*x^3 + x + 1, x^2 + x + 1, [x], Quo)
a x - a
The option Rem instructs
divide
to return the remainder only:
>> divide(a*x^3 + x + 1, x^2 + x + 1, [x], Rem)
a + x + 1
For multivariate expressions, regarded as a univariate polynomial in a specified indeterminate, the result of the division depends on the indeterminate:
>> divide(x^2 - 2*x - y, y*x - 1, [x]);
1 1 - - 2 - - 2 x y y - + -----, ----- - y y y y
>> divide(x^2 - 2*x - y, y*x - 1, [y])
1 2 1 - -, x - - - 2 x x x
Multivariate polynomials and polynomial expressions can
only be divided with the option Exact. If a
division without remainder is possible, the quotient is returned. This
operation is equivalent to the division of polynomials using the
/
operator:
>> p := poly(x^2 - x*y - x + y, [x, y]): q := poly(x - 1, [x, y]): p/q = divide(p, q, Exact)
poly(x - y, [x, y]) = poly(x - y, [x, y])
If exact division of multivariate polynomials without
remainder is not possible, FAIL
is returned:
>> p := poly(x^2 + y, [x, y]): q := poly(x - 1, [x, y]): divide(p, q, Exact) = p/q
FAIL = FAIL
>> delete p, q: