Synthetic division

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

In algebra, synthetic division is a method of performing polynomial long division, with less writing and fewer calculations. It is mostly taught for division by binomials of the form

x - a,\

but the method generalizes to division by any monic polynomial, and to any polynomial.

The advantages of synthetic division are that it allows one to calculate without writing variables, it uses few calculations, and it takes significantly less space on paper than long division. Also, the subtractions in long division are converted to additions by switching the signs at the very beginning, preventing sign errors.

Synthetic division for linear denominators is also called division through Ruffini's rule.

Regular synthetic division

The first example is synthetic division with only a monic linear denominator x-a .

\frac{x^3 - 12x^2 - 42}{x - 3}

Write the coefficients of the polynomial that is to be divided at the top (the zero is for the unseen 0x).

\begin{array}{cc}
    \begin{array}{r} \\  \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     &   &     \\
        \hline 
    \end{array}
\end{array}

Negate the coefficients of the divisor.

	\begin{array}{rr} 
     -1x & + 3
\end{array}

Write in every coefficient of the divisor but the first one on the left.

\begin{array}{cc}
    \begin{array}{r} \\ 3 \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     &   &     \\
        \hline 
    \end{array}
\end{array}

Note the change of sign from −3 to 3. "Drop" the first coefficient after the bar to the last row.

\begin{array}{cc}
    \begin{array}{r} \\ 3 \\ \\ \end{array}
    &
    \begin{array}{|rrrr}  
        1 & -12 & 0 & -42 \\
          &     &   &     \\
        \hline 
        1 &     &   &     \\
    \end{array}
\end{array}

Multiply the dropped number by the number before the bar, and place it in the next column.

\begin{array}{cc}
    \begin{array}{r} \\ 3 \\ \\ \end{array}
    &
    \begin{array}{|rrrr}  
        1 & -12 & 0 & -42 \\
          &   3 &   &     \\
        \hline 
        1 &     &   &     \\
    \end{array}
\end{array}

Perform an addition in the next column.

\begin{array}{cc}
    \begin{array}{c} \\ 3 \\ \\ \end{array}
    &
    \begin{array}{|rrrr}  
        1 & -12 & 0 & -42 \\
          &   3 &   &     \\
        \hline 
        1 &  -9 &   &     \\
    \end{array}
\end{array}

Repeat the previous two steps and the following is obtained:

\begin{array}{cc}
    \begin{array}{c} \\ 3 \\ \\ \end{array}
    &
    \begin{array}{|rrrr}  
        1 & -12 &   0 & -42 \\
          &   3 & -27 & -81 \\
        \hline 
        1 & -9 & -27 & -123 
    \end{array}
\end{array}

Count the terms to the left of the bar. Since there is only one, the remainder has degree zero. Mark the separation with a vertical bar.

	\begin{array}{rrr|r} 
    1 &  -9 & -27 & -123 
\end{array}

The terms are written with increasing degree from right to left beginning with degree zero for both the remainder and the result.

	\begin{array}{rrr|r} 
    1x^2 &  -9x & -27 & -123 
\end{array}

The result of our division is:

\frac{x^3 - 12x^2 - 42}{x - 3} = x^2 - 9x - 27 - \frac{123}{x - 3}

Evaluating Polynomials by the Remainder Theorem

The above form of synthetic division is useful in the context of the Polynomial remainder theorem for evaluating univariate polynomials. To summarize, the value of p(x) at a is equal to the remainder of \frac{p(x)}{(x-a)}. The advantage of calculating the value this way is that it requires just over half as many multiplication steps as naive evaluation. An alternative evaluation strategy is Horner's method.

Expanded synthetic division

This method generalizes to division by any monic polynomial with only a slight modification with changes in bold. Using the same steps as before, let's try to perform the following division:

\frac{x^3 - 12x^2 - 42}{x^2 + x - 3}

We concern ourselves only with the coefficients. Write the coefficients of the polynomial to be divided at the top.

	\begin{array}{|rrrr} 
     1 & -12 & 0 & -42 
\end{array}

Negate the coefficients of the divisor.

	\begin{array}{rrr} 
     -1x^2 &-1x &+3
\end{array}

Write in every coefficient but the first one on the left in an upward right diagonal (see next diagram).

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     &   &     \\
          &     &   &     \\
        \hline 
    \end{array}
\end{array}

Note the change of sign from 1 to −1 and from −3 to 3 . "Drop" the first coefficient after the bar to the last row.

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     &   &     \\
          &     &   &     \\
        \hline 
        1 &     &   &     \\    
    \end{array}
\end{array}

Multiply the dropped number by the diagonal before the bar, and place the resulting entries diagonally to the right from the dropped entry.

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     & 3 &     \\
          &  -1 &   &     \\
        \hline 
        1 &     &   &     \\    
    \end{array}
\end{array}

Perform an addition in the next column.

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 & 0 & -42 \\
          &     & 3 &     \\
          &  -1 &   &     \\
        \hline 
        1 & -13 &   &     \\    
    \end{array}
\end{array}

Repeat the previous two steps until you would go past the entries at the top with the next diagonal.

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 &  0 & -42 \\
          &     &  3 & -39 \\
          &  -1 & 13 &     \\
        \hline 
        1 & -13 & 16 &     \\    
    \end{array}
\end{array}

Then simply add up any remaining columns.

\begin{array}{cc}
    \begin{array}{rr} \\ &3 \\ -1& \\ \\ \end{array}
    &
    \begin{array}{|rrrr} 
        1 & -12 &  0 & -42 \\
          &     &  3 & -39 \\
          &  -1 & 13 &     \\
        \hline 
        1 & -13 & 16 & -81 \\    
    \end{array}
\end{array}

Count the terms to the left of the bar. Since there are two, the remainder has degree one. Mark the separation with a vertical bar.

	\begin{array}{rr|rr} 
    1 &  -13 & 16 & -81 
\end{array}

The terms are written with increasing degree from right to left beginning with degree zero for both the remainder and the result.

	\begin{array}{rr|rr} 
    1x &  -13 & 16x & -81 
\end{array}

The result of our division is:

\frac{x^3 - 12x^2 - 42}{x^2 + x - 3} = x - 13 + \frac{16x - 81}{x^2 + x - 3}

For non-monic divisors

With a little prodding, the expanded technique may be generalised even further to work for any polynomial, not just monics. The usual way of doing this would be to divide the divisor g(x) with its leading coefficient (call it a):

h(x) = \frac{g(x)}{a}

then using synthetic division with h(x) as the divisor, and then dividing the quotient by a to get the quotient of the original division (the remainder stays the same). But this often produces unsightly fractions which get removed later, and is thus more prone to error. It is possible to do it without first dividing the coefficients of g(x) by a.

As can be observed by first performing long division with such a non-monic divisor, the coefficients of f(x) are divided by the leading coefficient of g(x) after "dropping", and before multiplying.

Let's illustrate by performing the following division:

\frac{6x^3+5x^2-7}{3x^2-2x-1}

A slightly modified table is used:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &     &  &     \\
          &    &   &     \\
        \hline
          &     &   &     \\ 
          &     &   &     \\   
    \end{array}
\end{array}

Note the extra row at the bottom. This is used to write values found by dividing the "dropped" values by the leading coefficient of g(x) (in this case, indicated by the /3; note that, unlike the rest of the coefficients of g(x), the sign of this number is not changed).

Next, the first coefficient of f(x) is dropped as usual:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &     &  &     \\
          &    &   &     \\
        \hline
        6 &     &   &     \\ 
          &     &   &     \\   
    \end{array}
\end{array}

and then the dropped value is divided by 3 and placed in the row below:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &     &  &     \\
          &    &   &     \\
        \hline
        6 &     &   &     \\ 
        2 &     &   &     \\   
    \end{array}
\end{array}

Next, the new (divided) value is used to fill the top rows with multiples of 2 and 1, as in the expanded technique:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &   & 2 &     \\
          & 4 &   &     \\
        \hline
        6 &     &   &     \\ 
        2 &     &   &     \\   
    \end{array}
\end{array}

The 5 is dropped next, with the obligatory adding of the 4 below it, and the answer is divided again:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &   & 2 &     \\
          & 4 &   &     \\
        \hline
        6 & 9   &   &     \\ 
        2 & 3   &   &     \\   
    \end{array}
\end{array}

Then the 3 is used to fill the top rows:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &   & 2 &  3  \\
          & 4 & 6 &     \\
        \hline
        6 & 9 &   &     \\ 
        2 & 3 &   &     \\   
    \end{array}
\end{array}

At this point, if, after getting the third sum, we were to try and use it to fill the top rows, we would "fall off" the right side, thus the third sum is the first coefficient of the remainder, as in regular synthetic division. But the values of the remainder are not divided by the leading coefficient of the divisor:

\begin{array}{cc}
    \begin{array}{rrr} \\ &1& \\ 2&& \\ \\&&/3 \\ \end{array}
    \begin{array}{|rrrr} 
        6 & 5 & 0 & -7 \\
          &   & 2 &  3  \\
          & 4 & 6 &     \\
        \hline
        6 & 9 & 8 & -4  \\ 
        2 & 3 &   &     \\   
    \end{array}
\end{array}

Now we can read off the coefficients of the answer. As in expanded synthetic division, the last two values (2 is the degree of the divisor) are the coefficients of the remainder, and the remaining values are the coefficients of the quotient:

	\begin{array}{rr|rr} 
    2x &  +3 & 8x & -4 
\end{array}

and the result is

\frac{6x^3+5x^2-7}{3x^2-2x-1} = 2x + 3 + \frac{8x - 4}{3x^2-2x-1}

Compact Expanded Synthetic Division

However, the diagonal format above becomes less space-efficient when the degree of the divisor exceeds half of the degree of the dividend. It is easy to see that we have complete freedom to write each product in any row, as long as it is in the correct column. So the algorithm can be compactified by a greedy strategy, as illustrated in the division below.

\dfrac{ax^7+bx^6+cx^5+dx^4+ex^3+fx^2+gx+h}{ix^4-jx^3-kx^2-lx-m}=nx^3+ox^2+px+q+\dfrac{rx^3+sx^2+tx+u}{ix^4-jx^3-kx^2-lx-m}

\begin{array}{cc} \begin{array}{rrrr} \\ \\ \\ \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & & & & qj & & & \\ & & & pj & pk & qk & & \\ & & oj & ok & ol & pl & ql & \\ & nj & nk & nl & nm & om & pm & qm \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & p_0 & q_0 & r & s & t & u \\ n & o & p & q & & & & \\ \end{array} \end{array}

The following describes how to perform the algorithm; this algorithm includes steps for dividing non-monic divisors:

  1. Write the coefficients of the dividend on a bar \begin{array}{cc} \begin{array}{|rrrrrrrr} a & b & c & d & e & f & g & h \\ \hline \end{array} \end{array}
  2. Ignoring the first (leading) coefficient of the divisor, negate each coefficients and place them on the left-hand side of the bar. \begin{array}{cc} \begin{array}{rrrr} j &k & l & m \\ \end{array} & \begin{array}{|rrrrrrrr} a & b & c & d & e & f & g & h \\ \hline \end{array} \end{array}
  3. From the number of coefficients placed on the left side of the bar, count the number of dividend coefficients above the bar, starting from the rightmost column. Then place a vertical bar to the left, and as well as the row below, of that column. This vertical bar marks the separation between the quotient and the remainder. \begin{array}{cc} \begin{array}{rrrr} j &k & l & m \\ \\ \end{array} & \begin{array}{|rrrr|rrrr} a & b & c & d & e & f & g & h \\ \hline & & & & & & & \\ \end{array} \end{array}
  4. Drop the first coefficient of the dividend below the bar.
    \begin{array}{cc} \begin{array}{rrrr} j &k & l & m \\ \\ \end{array} & \begin{array}{|rrrr|rrrr} a & b & c & d & e & f & g & h \\ \hline a &  & & & & & & \\ \end{array} \end{array}
    • Divide the previously dropped/summed number by the leading coefficient of the divisor and place it on the row below (this doesn't need to be done if the leading coefficient is 1). In this case n = \dfrac{a}{i}.
    • Multiply the previously dropped/summed number (or the divided dropped/summed number) to each negated divisor coefficients on the left (starting with the left most); skip if the dropped/summed number is zero. Place each product on top of the subsequent columns.
    \begin{array}{cc} \begin{array}{rrrr} \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & nj & nk & nl & nm & & & \\ a & b & c & d & e & f & g & h \\ \hline a & & & & & & & \\ n & & & & & & & \\ \end{array} \end{array}
  5. Perform an column-wise addition on the next column.
    \begin{array}{cc} \begin{array}{rrrr} \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & nj & nk & nl & nm & & & \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & & & & & & \\ n & & & & & & & \\ \end{array} \end{array}
  6. Repeat the previous two steps. Stop when you performed the previous two steps on the number just before the vertical bar.

    Let o = \dfrac{o_0}{i}.

    \begin{array}{cc} \begin{array}{rrrr} \\ \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & & oj & ok & ol & & & \\ & nj & nk & nl & nm & om & & \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & p_0 & & & & & \\ n & o & & & & & & \\ \end{array} \end{array}

    Let p = \dfrac{p_0}{i}.

    \begin{array}{cc} \begin{array}{rrrr} \\ \\ \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & & & pj & pk & & & \\ & & oj & ok & ol & pl & & \\ & nj & nk & nl & nm & om & pm & \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & p_0 & q_0 & & & & \\ n & o & p & & & & & \\ \end{array} \end{array}

    Let q = \dfrac{q_0}{i}.

    \begin{array}{cc} \begin{array}{rrrr} \\ \\ \\ \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & & & & qj & & & \\ & & & pj & pk & qk & & \\ & & oj & ok & ol & pl & ql & \\ & nj & nk & nl & nm & om & pm & qm \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & p_0 & q_0 & r & & & \\ n & o & p & q & & & & \\ \end{array} \end{array}
  7. Perform the remaining column-wise additions on the subsequent columns (calculating the remainder).
    \begin{array}{cc} \begin{array}{rrrr} \\ \\ \\ \\ j &k & l & m \\ \end{array} & \begin{array}{|rrrr|rrrr} & & & & qj & & & \\ & & & pj & pk & qk & & \\ & & oj & ok & ol & pl & ql & \\ & nj & nk & nl & nm & om & pm & qm \\ a & b & c & d & e & f & g & h \\ \hline a & o_0 & p_0 & q_0 & r & s & t & u \\ n & o & p & q & & & & \\ \end{array} \end{array}
  8. The bottommost results below the horizontal bar are coefficients of the polynomials, the remainder and the quotient. Where the coefficients of the quotient is to the left of the vertical bar separation, and the coefficients of the remainder to the right. These coefficients would be interpreted with increasing degree from right to left beginning with degree zero for both the remainder and the quotient. We interpret the results to get: \dfrac{ax^7+bx^6+cx^5+dx^4+ex^3+fx^2+gx+h}{ix^4-jx^3-kx^2-lx-m}=nx^3+ox^2+px+q+\dfrac{rx^3+sx^2+tx+u}{ix^4-jx^3-kx^2-lx-m}

Python implementation

The following snippet implements the Extended Synthetic Division for non-monic polynomials (which also supports monic polynomials of course since it is a generalization):

def extended_synthetic_division(dividend, divisor):
    '''Fast polynomial division by using Extended Synthetic Division. Also works with non-monic polynomials.'''
    # dividend and divisor are both polynomials, which are here simply lists of coefficients. Eg: x^2 + 3x + 5 will be represented as [1, 3, 5]

    out = list(dividend) # Copy the dividend
    normalizer = divisor[0]
    for i in xrange(len(dividend)-(len(divisor)-1)):
        out[i] /= normalizer # for general polynomial division (when polynomials are non-monic),
                                 # we need to normalize by dividing the coefficient with the divisor's first coefficient
        coef = out[i]
        if coef != 0: # useless to multiply if coef is 0
            for j in xrange(1, len(divisor)): # in synthetic division, we always skip the first coefficient of the divisor,
                                              # because it is only used to normalize the dividend coefficients
                out[i + j] += -divisor[j] * coef

    # The resulting out contains both the quotient and the remainder, the remainder being the size of the divisor (the remainder
    # has necessarily the same degree as the divisor since it is what we couldn't divide from the dividend), so we compute the index
    # where this separation is, and return the quotient and remainder.
    separator = -(len(divisor)-1)
    return out[:separator], out[separator:] # return quotient, remainder.

See also

References

  • Lua error in package.lua at line 80: module 'strict' not found.
  • Lua error in package.lua at line 80: module 'strict' not found.

External links