Project Nayuki


Polynomial arithmetic shorthand

Introduction

Doing algebra by hand is tedious and error-prone, but is an essential part of every math student’s education. Here, I present a method that made polynomial algebra more manageable for me. It served very well in my math exams and contests throughout high school and university. (I don’t claim to have invented this method, but I honestly can’t remember where I learned it from.)

Let’s start with a short example before I explain in detail. Consider this exercise in manipulating polynomials:

Simplify \((x^2 + 5x - 3) + (-2x^2 + 1)\), the conventional way:
\(= (x^2 - 2x^2) + (5x) + (-3 + 1)\)
\(= -x^2 + 5x - 2\).

Now do it the shorthand way:

  ( 1  5 -3)
+ (-2  0  1)
------------
  (-1  5 -2)

\(= -x^2 + 5x - 2\).

This method works for all four basic arithmetic operations on polynomials: addition, subtraction, multiplication, and division.

Explanation

As a starting point, we know that the conventional algebraic notation does the job correctly. But if we’re manipulating polynomials in just one variable (say, \(x\)), then there is a lot of excess notation that gets in the way. The essence of this shorthand method is to only record the coefficients of the polynomial, and to use the position to indicate the power. For example:

As an analogy, this is exactly like how our place-value number system works. For example, “two thousand one hundred five” is “(two thousands) (one hundreds) (zero tens) (five ones)”, which is 2105.

When we want to add two polynomials in this form, we line them up on the right side and do something like long addition, but without carrying between columns. (See the example in the introduction.) The same goes for subtraction and multiplication. This method is correct because if we explicitly associate each number with the power of x denoted by the number’s position, then the arithmetic is equivalent to the conventional notation with some vertical rearrangement. For example:

  ( 1x^2 + 5x^1 + -3x^0)
+ (-2x^2 + 0x^1 +  1x^0)
------------------------
  (-1x^2 + 5x^1 + -2x^0)

\(= -x^2 + 5x - 2\).

We can even extend this to multiplication:

       ( 1  5 -3)
     × (-2  0  1)
     ------------
       ( 1  5 -3)
   (  0  0  0  0)
(-2 -10  6  0  0)
-----------------
(-2 -10  7  5 -3)

\(= -2x^4 - 10x^3 + 7x^2 + 5x - 3\).

Here is the justification by explicitly including the powers of x:

                ( 1x^2 + 5x^1 + -3x^0)
              × (-2x^2 + 0x^1 +  1x^0)
              ------------------------
                ( 1x^2 + 5x^1 + -3x^0)
          (0x^3 + 0x^2 + 0x^1)
(-2x^4 + -10x^3 + 6x^2)
--------------------------------------
(-2x^4 + -10x^3 + 7x^2 + 5x^1 + -3x^0)

\(= -2x^4 - 10x^3 + 7x^2 + 5x - 3\).

And yes, this shorthand method even works for long division. (Example not included.)


Exercises

The best way to understand this technique is to do some practice exercises!

0. Simplify \((5x^4 + x^3 + 2x^2 + x - 8) + (x^4 - 2x^3 + 7) + (-4x^2 + 6x) - (9x^3 + 2x - 5)\).

Answer:

(5   1   2   1  -8)
(1  -2   0   0   7)
+      (-4   6   0)
-------------------
(6  -1  -2   7  -1)
-   (9   0   2  -5)
-------------------
(6 -10  -2   5  -6)

\(= 6x^4 - 10x^3 - 2x^2 + 5x - 6\).

1. Expand \((x + 1)(5x - 2)(4x^2 - 3x + 1)\).

Answer:

             ( 1  1)
           × ( 5 -2)
           ---------
             (-2 -2)
         + (5  5  0)
         -----------
           (5  3 -2)
         × (4 -3  1)
         -----------
           (5  3 -2)
     (-15  -9  6  0)
+ (20  12  -8  0  0)
--------------------
  (20  -3 -12  9 -2)

\(= 20x^4 - 3x^3 - 12x^2 + 9x - 2\).

2. Construct a polynomial in \(x\) with roots at −1, 2, and 7.

Answer:

\((x + 1)(x - 2)(x - 7)\):

       ( 1  1)
     × ( 1 -2)
     ---------
       (-2 -2)
   + (1  1  0)
   -----------
     (1 -1 -2)
     × ( 1 -7)
     ---------
    (-7  7 14)
+ (1 -1 -2  0)
--------------
  (1 -8  5 14)

\(= x^3 - 8x^2 + 5x + 14\).

(We can evaluate this polynomial at −1, 2, and 7 to verify that the value is 0 at these points. Also, any multiple of this polynomial is a valid answer as well.)

3. Put everything under one denominator: \(-x - 8 + \frac{5x - 1}{x^2 + 3}\).

Answer:

The numerator will be \((-x - 8)(x^2 + 3) + (5x - 1)\):

          (-1  -8)
    × ( 1   0   3)
    --------------
          (-3 -24)
+ (-1  -8   0   0)
------------------
  (-1  -8  -3 -24)
  +       ( 5  -1)
  ----------------
  (-1  -8   2 -25)

\(= -x^3 - 8x^2 + 2x - 25\).

Final answer: \(\frac{-x^3 - 8x^2 + 2x - 25}{x^2 + 3}\).

4. There is a box containing 2 white socks, 2 blue socks, and \(n\) black socks. Two distinct socks from the box are randomly selected. We are given that the probability of both socks being the same color is 1/3. What is \(n\), the number of black socks?

Answer:

In total, there are \(\binom{n+4}{2} = (n+4)(n+3)/2\) ways to select 2 socks (denominator).
There is only 1 way to select 2 white socks, and likewise for blue socks.
There are \(\binom{n}{2} = n(n-1)/2\) ways to select 2 black socks (valid for \(n \ge 0\)).
Thus there are \(n(n-1)/2 + 2\) ways to select two same-color socks (numerator).

We want to solve \(\frac{n(n-1)/2 + 2}{(n+4)(n+3)/2} = \frac{1}{3}\) for \(n\).
So rearrange and multiply by 2 to get \(3[n(n-1) + 4] = (n+4)(n+3)\).
Now perform the polynomial arithmetic using the shorthand method:

(3)((1 0)(1 -1) + (4)) = (1 4)(1 3).
(3)((1 -1 0) + (4)) = (1 7 12).
(3)(1 -1 4) = (1 7 12).
(3 -3 12) = (1 7 12).
(3 -3 12) - (1 7 12) = (0).
(2 -10 0) = (0).
(1 0)(2 -10) = (0).
(2)(1 0)(1 -5) = (0).

Therefore, \(2n(n - 5) = 0\). By inspection, the solutions are \(n = 0, 5\).

5. The sum of the squares of the first \(n\) positive integers (which is \(1^2 + 2^2 + \cdots + n^2\)) is given by \(P_n = \frac{1}{6} n(n + 1)(2n + 1)\). Verify that the difference between successive terms of this sequence, i.e. \(P_n - P_{n-1}\), is indeed \(n^2\).

Answer:

\(P_n - P_{n-1}\)
\(= \frac{1}{6}n(n+1)(2n+1) - \frac{1}{6}(n-1)n(2(n-1)+1)\)
\(= \frac{1}{6} \left[ n(n+1)(2n+1) - (n-1)n(2n-1) \right]\)

First product:

      (1 0)
    × (1 1)
    -------
      (1 0)
  + (1 0 0)
  ---------
    (1 1 0)
    × (2 1)
  ---------
    (1 1 0)
+ (2 2 0 0)
-----------
  (2 3 1 0)

Second product:

       ( 1 -1)
     × ( 1  0)
     ---------
    ( 1 -1  0)
    ×  ( 2 -1)
    ----------
    (-1  1  0)
+ (2 -2  0  0)
--------------
  (2 -3  1  0)

Difference:

  (2  3  1  0)
- (2 -3  1  0)
--------------
  (0  6  0  0)

Therefore, the formula simplifies to \(\frac{1}{6} 6n^2\), which is indeed \(n^2\).