Polynomial Long Division

Polynomial Long Division is a technique for dividing polynomial by another polynomial. It works in the same way as long division of numbers, but here you are dealing with variables.

You perform division step by step, by "guessing" terms of a quotient. Division is finished, when degree of the result is less than degree of the divisor.

Example 1. Divide $$${{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}$$$ by $$${x}+{3}$$$.

Write division in special form:

$$$\begin{array}{r}\\x+3\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\\end{array}$$$

Let's carefully think what to do next.

The goal is to get rid of the leading term of dividend $$${{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}$$$.

In other words, we need to get rid of $$${{x}}^{{3}}$$$.

To do it, we divide $$${{x}}^{{3}}$$$ by the leading term of divisor $$${x}+{3}$$$, i.e. $$${x}$$$ (divide monomials): $$$\frac{{{x}}^{{3}}}{{x}}={\color{red}{{{{x}}^{{2}}}}}$$$.

Now, we subtract $$${\color{red}{{{{x}}^{{2}}}}}{\left({x}+{3}\right)}$$$ from $$${{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}$$$:

$$${{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}-{{x}}^{{2}}{\left({x}+{1}\right)}={{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}-{\left({{x}}^{{3}}+{3}{{x}}^{{2}}\right)}=$$$ (multiply monomial by polynomial)

$$$={{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}-{{x}}^{{3}}-{3}{{x}}^{{2}}=-{5}{{x}}^{{2}}-{8}{x}+{21}$$$.

Nice, we got rid of $$${{x}}^{{3}}$$$ and ended up with a polynomial of lower degree.

Let's write it in vertical division:

$$$\begin{array}{r}\color{green}{x^2}\phantom{-2x^2-8x+21}\\\color{green}{x+3}\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\-\underline{\color{green}{(x^3+3x^2)}}\phantom{-8x+21}\\\end{array}$$$

You need to be careful with minus sign (we subtract polynomials). The best way is to change signs of terms, and discard parenthesis and minus sign in front of parenthesis, in other words add polynomials.

$$$\begin{array}{r}\color{green}{x^2}\phantom{-2x^2-8x+21}\\\color{green}{x+3}\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\\underline{\color{green}{\color{red}{-}x^3\color{red}{-}3x^2}}\phantom{-8x+21}\\\end{array}$$$

Next, perform addition:

$$$\begin{array}{r}\color{green}{x^2}\phantom{-2x^2-8x+21}\\\color{green}{x+3}\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\\underline{\color{green}{-x^3-3x^2}}\phantom{-8x+21}\\-5x^2-8x+21\end{array}$$$

Now, repeat above steps.

We need to get rid of $$$-{5}{{x}}^{{2}}$$$.

To do it, we divide $$$-{5}{{x}}^{{2}}$$$ by the leading term of divisor $$${x}+{3}$$$, i.e. $$${x}$$$: $$$\frac{{-{5}{{x}}^{{2}}}}{{x}}={\color{red}{{-{5}{x}}}}$$$.

Next, subtract $$${\color{red}{{-{5}{x}}}}{\left({x}+{3}\right)}$$$ from $$$-{5}{{x}}^{{2}}-{8}{x}+{21}$$$:

$$$-{5}{{x}}^{{2}}-{8}{x}+{21}-{\left(-{5}{x}{\left({x}+{3}\right)}\right)}=-{5}{{x}}^{{2}}-{8}{x}+{21}-{\left(-{5}{{x}}^{{2}}-{15}{x}\right)}=$$$ (multiply monomial by polynomial)

$$$=-{5}{{x}}^{{2}}-{8}{x}+{21}+{5}{{x}}^{{2}}+{15}{x}={7}{x}+{21}$$$.

We got rid of $$$-{5}{{x}}^{{2}}$$$ and ended up with a polynomial of lower degree:

$$$\begin{array}{r}x^2\color{purple}{-5x}\phantom{-8x^2+21}\\\color{green}{x+3}\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\\underline{-x^3-3x^2}\phantom{-8x+21}\\-5x^2-8x+21\\\underline{\color{purple}{\color{red}{+}5x^2\color{red}{+}15x}\phantom{+21}}\\7x+21\end{array}$$$

Finally, get rid of $$${7}{x}$$$ by multiplying $$${x}+{3}$$$ by $$${7}$$$:

$$$\begin{array}{r}x^2-5x+\color{brown}{7}\phantom{x+21}\\\color{brown}{x+3}\hspace{1pt})\overline{\hspace{1pt}x^3-2x^2-8x+21}\\\underline{-x^3-3x^2}\phantom{-8x+21}\\-5x^2-8x+21\\\underline{+5x^2+15x}\phantom{+21}\\7x+21\\\underline{\color{brown}{-7x-21}}\\\color{cyan}{0}\end{array}$$$

We are done, because remainder is 0.

Thus, we can write that $$$\frac{{{{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}}}{{{x}+{3}}}={{x}}^{{2}}-{5}{x}+{7}$$$.

From another side it means, that $$${{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}={\left({x}+{3}\right)}{\left({{x}}^{{2}}-{5}{x}+{7}\right)}$$$.

To better understand the process of long division, let's write, that

$$${\color{purple}{{{{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}={{x}}^{{2}}{\left({x}+{3}\right)}+{\left(-{5}{x}\right)}{\left({x}+{3}\right)}+{7}{\left({x}+{3}\right)}}}}$$$ (you can simplify right hand side to make sure, that this is equality).

Each summand in the right hand side corresponds to the step in the division process.

Now, above equality can be divided by $$${\left({x}+{3}\right)}$$$: $$$\frac{{{{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}}}{{{x}+{3}}}=\frac{{{{x}}^{{2}}{\left({x}+{3}\right)}}}{{{x}+{3}}}+\frac{{-{5}{x}{\left({x}+{3}\right)}}}{{{x}+{3}}}+\frac{{{7}{\left({x}+{3}\right)}}}{{{x}+{3}}}={{x}}^{{2}}-{5}{x}+{7}$$$.

Note, how $$${x}+{3}$$$'s in the denominators and numerators were cancelled.

Answer: $$$\frac{{{{x}}^{{3}}-{2}{{x}}^{{2}}-{8}{x}+{21}}}{{{x}+{3}}}={{x}}^{{2}}-{5}{x}+{7}$$$.

Now, when you understood how to perform polynomial long division, it's time to consider harder examples.

First example was a "nice" example.

But in most cases there will be not "nice" cases.

Non-Zero Remainder. First not "nice" case is when remainder is not 0.

Similarly to division with remainder for numbers, in most cases you will end up with non-zero remainder (polynomial). But such cases are handled in the same way.

Example 2. Perform the long division: $$$\frac{{{6}{{x}}^{{3}}-{17}{{x}}^{{2}}-{8}{x}+{2}}}{{{3}{{x}}^{{2}}+{2}{x}-{1}}}$$$.

I will do this example a bit faster.

$$$\begin{array}{r}\color{green}{2x}\phantom{-^3}\color{purple}{-7}\phantom{-8x^2+21}\\3x^2+2x-1\hspace{1pt})\overline{\hspace{1pt}6x^3-17x^2-8x+2}\\\underline{\color{green}{\color{red}{-}6x^3\color{red}{-}4x^2\color{red}{+}2x}}\phantom{+21}\\-21x^2-6x+2\\\underline{\color{purple}{\color{red}{+}21x^2\color{red}{+}14x\color{red}{-}7}}\\\color{cyan}{8x-5}\end{array}$$$

We are done, because degree of the remainder $$${8}{x}-{5}$$$ is less than degree of the divisor $$${3}{{x}}^{{2}}+{2}{x}-{1}$$$, however, remainder is not zero.

We can write now (according to the steps), that

$$${6}{{x}}^{{3}}-{17}{{x}}^{{2}}-{8}{x}+{2}={2}{x}{\left({\underline{{{3}{{x}}^{{2}}+{2}{x}-{1}}}}\right)}-{7}{\left({\underline{{{3}{{x}}^{{2}}+{2}{x}-{1}}}}\right)}+{\left({8}{x}-{5}\right)}$$$.

Or $$${\color{purple}{{{6}{{x}}^{{3}}-{17}{{x}}^{{2}}-{8}{x}+{2}={\left({2}{x}-{7}\right)}{\left({3}{{x}}^{{2}}+{2}{x}-{1}\right)}+{8}{x}-{5}}}}$$$ (distributive property of multiplication: $$${a}{c}-{b}{c}={\left({a}-{b}\right)}{c}$$$).

Finally, $$$\frac{{{6}{{x}}^{{3}}-{17}{{x}}^{{2}}-{8}{x}+{2}}}{{{3}{{x}}^{{2}}+{2}{x}-{1}}}={2}{x}-{7}+\frac{{{8}{x}-{5}}}{{{3}{{x}}^{{2}}+{2}{x}-{1}}}$$$.

Answer: $$$\frac{{{6}{{x}}^{{3}}-{17}{{x}}^{{2}}-{8}{x}+{2}}}{{{3}{{x}}^{{2}}+{2}{x}-{1}}}={2}{x}-{7}+\frac{{{8}{x}-{5}}}{{{3}{{x}}^{{2}}+{2}{x}-{1}}}$$$, quotient is $$${2}{x}-{7}$$$, remainder is $$${8}{x}-{5}$$$.

Missing Terms. Another not "nice" case is when there are missing terms.

In some cases, during division process, there can appear terms that are not present in the dividend.

There are two options to fix this problem:

  • add missing terms with zero coefficient
  • add gaps during long division.

First option, actually, creates gaps at the beginning of the process, so you need not to worry about gaps later. However, second option is better, because often you don't know when and where to fill gaps.

Example 3. Find quotient and remainder of $$$\frac{{{{x}}^{{3}}-{1}}}{{{2}{x}+{8}}}$$$.

When we perform long division, there will appear terms involving $$${x}$$$ and $$${{x}}^{{2}}$$$. However, there are no such terms in $$${{x}}^{{3}}-{1}$$$.

To fix situation, we add mentioned terms with zero coefficient: $$${{x}}^{{3}}-{1}={{x}}^{{3}}+{0}{{x}}^{{2}}+{0}{x}-{1}$$$. We haven't changed anything, because adding zero doesn't change anything.

Now, perform long division:

$$$\begin{array}{r}\color{green}{\frac{1}{2}x^2}\color{purple}{-2x}\color{brown}{+8}\phantom{x-1}\\2x+8\hspace{1pt})\overline{\hspace{1pt}x^3\color{magenta}{+0x^2+0x}-1}\\\underline{\color{green}{\color{red}{-}x^3\color{red}{-}4x^2}}\phantom{+0x-1}\\-4x^2+0x-1\\\underline{\color{purple}{\color{red}{+}4x^2\color{red}{+}16x}}\phantom{-1}\\16x-1\\\underline{\color{brown}{-16x-64}}\\\color{cyan}{-65}\end{array}$$$

Therefore, $$${{x}}^{{3}}-{1}={\left(\frac{{1}}{{2}}{{x}}^{{2}}-{2}{x}+{8}\right)}{\left({2}{x}+{8}\right)}-{65}$$$.

Answer: Quotient is $$$\frac{{1}}{{2}}{{x}}^{{2}}-{2}{x}+{8}$$$, remainder is $$$-{65}$$$.

Finally, you can divide polynomials, that contain many variables, can also be divided.

Example 4. Divide $$${3}{{x}}^{{3}}{{y}}^{{3}}+{{x}}^{{2}}{{y}}^{{3}}+{{x}}^{{2}}{{y}}^{{2}}+{x}{{y}}^{{2}}-{2}{x}{y}$$$ by $$${x}{y}+{1}$$$.

$$$\begin{array}{r}3x^2y^2-2xy+xy^2\phantom{+x^2y^3+x^2y^2}\\xy+1\hspace{1pt})\overline{\hspace{1pt}3x^3y^3+x^2y^2-2xy+x^2y^3+xy^2}\\\underline{-3x^3y^3-3x^2y^2}\phantom{+x^2y^3+xy^2-2xy}\\-2x^2y^2-2xy+x^2y^3+xy^2\\\underline{+2x^2y^2+2xy}\phantom{+x^2y^3+xy^2}\\0+x^2y^3+xy^2\\\underline{-x^2y^3-xy^2}\\\color{cyan}{0}\end{array}$$$

Note, that we swapped some terms to perform division.

Answer: $$$\frac{{{3}{{x}}^{{3}}{{y}}^{{3}}+{{x}}^{{2}}{{y}}^{{3}}+{{x}}^{{2}}{{y}}^{{2}}+{x}{{y}}^{{2}}-{2}{x}{y}}}{{{x}+{1}}}={3}{{x}}^{{2}}{{y}}^{{2}}-{2}{x}{y}+{x}{{y}}^{{2}}$$$.

Now, it is time to exercise.

Exercise 1. Divide $$${{x}}^{{3}}-{3}{{x}}^{{2}}-{3}{x}+{5}$$$ by $$${x}-{1}$$$.

Answer: $$${{x}}^{{2}}-{2}{x}-{5}$$$.

Exercise 2. Find quotient and remainder of $$$\frac{{{{x}}^{{3}}+{7}{{x}}^{{2}}+{10}{x}-{3}}}{{{x}+{4}}}$$$.

Answer: Quotient is $$${{x}}^{{2}}+{3}{x}-{2}$$$, remainder is $$${5}$$$.

Exercise 3. Divide the following: $$$\frac{{{{x}}^{{3}}-{2}{{x}}^{{2}}+{3}}}{{{{x}}^{{2}}+{1}}}$$$.

Answer: $$$\frac{{{{x}}^{{3}}-{2}{{x}}^{{2}}+{3}}}{{{{x}}^{{2}}+{1}}}={x}-{2}+\frac{{{5}-{x}}}{{{{x}}^{{2}}+{1}}}$$$.

Exercise 4. Perform long division: $$$\frac{{{2}{{a}}^{{3}}{{b}}^{{3}}+{{a}}^{{3}}{{b}}^{{2}}+{{a}}^{{2}}{{b}}^{{3}}-{6}{{a}}^{{2}}{b}-{3}{{a}}^{{2}}-{3}{a}{b}}}{{{a}+{b}+{2}{a}{b}}}$$$.

Answer: $$${{a}}^{{2}}{{b}}^{{2}}-{3}{a}$$$.