next up previous
Next: What to submit Up: Description Previous: Evaluating a polynomial


Dividing by a monic polynomial

Division of polynomials $ P_1$ by $ P_2$ should behave like division of integers, that is you would like to find quotient polynomial $ Q$ and remainder polynomial $ R$ such that:

$\displaystyle P_1 = P_2 \times Q + R$    AND $\displaystyle \deg(R) < \deg(P_2).
$

This is NOT always possible when $ P_1$, $ P_2$, $ Q$, and $ R$ must be polynomials over the integers. For example, what quotient and remainder would you suggest for $ P_1$ $ =$ $ x^2$, and $ P_2$ $ =$ $ 3x$?

In the special case where $ P_2$ has leading (highest) coefficient either 1 or -1 (that is, $ P_2$ is monic), and $ P_2$ has degree no greater than $ P_1$, then division is possible. Here's a recipe:

  1. Set the remainder $ R$ initially equal to $ P_1$, and the quotient $ Q$ initially equal to 0.
  2. While the degree of $ R$ is no less than the degree of $ P_2$ do the following steps:
    1. Construct a monomial $ M$ (a polynomial with one term) $ m$ by raising $ x$ (or whatever variable you're using) to the exponent equal to the degree of $ R$ minus the degree of $ P_2$, and then multiplying this power of $ x$ by the leading coefficient of $ R$ times the leading coefficient of $ P_2$ (either 1 or -1).
    2. Recalculate $ Q$ by adding $ M$ to it.
    3. Recalculate $ R$ by subtracting ($ M$ $ \times$ $ P_2$) from it. This new remainder will have lower degree than the old one.

Implement the function monDiv specified in Polynomial.h. For $ P_1$ or order $ n$, your function should have complexity $ O(n^3)$.


next up previous
Next: What to submit Up: Description Previous: Evaluating a polynomial
Danny Heap 2002-09-20