Previous Page Next Page Contents

divide -- divide polynomials

Introduction

divide(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).

Call(s)

divide(p1, q1 <, mode>)
divide(f1, g1 <, mode>)
divide(f, g <, [x]> <, mode>)
divide(p, q, Exact)
divide(f, g, <[x1, x2, ...],> Exact)

Parameters

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.

Options

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.

Returns

a polynomial, a polynomial expression, a sequence of two polynomials or polynomial expressions, or the value FAIL.

Overloadable:

p, q, p1, q1, f, g, f1, g1

Related Functions

/, content, degree, div, factor, gcd, gcdex, groebner::normalf, ground, mod, multcoeffs, pdivide, poly, powermod

Details

Example 1

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

Example 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

Example 3

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

Example 4

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:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000