∫ Polynomial arithmetic as convolution


Kernel:

  • A perspective to represent polynomials using simplexes.
  • A trick to perform polynomial multiplicative operations based on graph convolution.

Polynomials are facinating. They serve as fundamental components in the realm of mathematical education for usPolynomials. Brilliant.org. Retrieved 15:25, April 9, 2023, from https://brilliant.org/wiki/polynomials/. Their orthogonal basis properties also enable the independent factorization of their linear combinations, making them an ideal starting point for machine learning practictionersSchölkopf, B., Smola, A. J., & Bach, F. (2002). Learning with kernels: support vector machines, regularization, optimization, and beyond. MIT press..

Nonetheless, manual calculations involving polynomials can be challenging due to the numerous terms we need to jot down and cancel out during arithmetic operations. In this article, I aim to showcase a technique that simplifies polynomial arithmetic from the perspective of convolutionhttps://en.wikipedia.org/wiki/Convolution, making it less burdensome for individuals.

∂ Yet another way to represent polynomials

Before delving into the method, let's initially examine the approach to representing polynomials that I find both practical and efficient to work with.

From this polynomial \( x^2 + 2xy + y^2 \), I recommend that we simplify it into
{x^2 + 2xy + y^2}
Also for
\[ x^5 + 5x^4 + 10x^3 + 10x^2 + 5x + 1 \]
{x^5 + 5x^4 + 10x^3 + 10x^2 + 5x + 1}

This representation offers a more compact and convenient way to perform convolution. Note that I've omitted the degree component from the individual term, as during polynomial operations, we must define and share the axes among the operands anyway.

We can also generalize the representation up to 3 axes in 2D space using simplex. This polynomial \( 1 + 3x - y - 2xy + 2x^2 \) can be written as
{1 + 3x - y - 2xy + 2x^2 + 0y^2}
Now we are ready to proceed.

∂ Operations using graph convolution

Performing polynomial muliplication is simply convolutionThis is infact cross-correlation. But in machine learning community, they are both interchangeable., for example:
\[ (1 + x - y)(1 + 2x) = 1 + 3x - y - 2xy + 2x^2 \]
{1 + x - y}.{1 + 2x} = {1 + 3x - y - 2xy + 2x^2}

We simply multiply the coefficients of each term in the first polynomial with the coefficients of each term in the second polynomial, and find the terms with the same degree and add them up. This is the same as performing convolution on the graph representation of the polynomials.

This is not a new technique. Polynomial multiplication is one of the common examples to show the speed up benefit of discrete fourier transformhttps://brilliant.org/wiki/discrete-fourier-transform/#convolution-and-polynomial-multiplication. But our goal is the opposite. Rather than presenting a method that provides speed improvements but is difficult to execute manually, we aim to carry out polynomial operations using pen and paper.

Here is my first trick.
When working with two one-dimensional polynomials, do write the artifact terms diagonally.

Typically, we convolve with the smaller operand to minimize the working memory used. By organizing the terms diagonally, you can save space, as it only necessitates a number of rows equivalent to the terms in the moving operand.

\[ (1 - x + x^2 - x^3 + x^4 - x^5).(1 + x + x^2 + x^3) = (1 + x^2 - x^6 - x^8) \]
{1 - x + x^2 - x^3 + x^4 - x^5}.{1 + x + x^2 + x^3} = {1 + 0x + x^2 + 0x^3 + 0x^4 + 0x^5 - x^6 + 0x^7 - x^8}
Polynomial division is merely a game of matching patterns. Finding products that can eliminate all the starting terms.
\[ \frac{- 2x^2 + 3x + 2}{2x + 1} = - x + 2 \]
{2 + 3x - 2x^2}/{1 + 2x} = {2 - x}
\[ \frac{- x^8 - x^6 + x^2 + 1}{x^3 + x^2 + x + 1} = {-x^5 + x^4 - x^3 + x^2 - x + 1} \]
{1 + 0x + x^2 + 0x^3 + 0x^4 + 0x^5 - x^6 + 0x^7 - x^8}/{1 + x + x^2 + x^3} = {-x^5 + x^4 - x^3 + x^2 - x + 1}

You may notice that in both examples, I carried out the convolution using varying order sequences. In fact, it's not essential to follow a specific sequence, provided that each bin has been convolved. Unlike the long division method, which requires a left-to-right sequence, you only need to ensure that every bin is accounted for in the convolution process when the quotient is divisible by the denominator.

However, when dealing with remainders, adhering to a sequence from the highest to the lowest degree ensures that you obtain the lowest degree remainder.
Here is a multi-variable division using simplexes:
\[ \frac{1 + 3x - y - 2xy + 2x^2}{1 + x - y} = 1 + 2x \]
{1 + 3x - y + 2x^2 - 2xy}/{1 + x - y} = {1 + 2x}
When working with simplexes, the best practice is to solve the corners first.
\[ \frac{1 + 4x - 2y + 5x^2 - 6xy + y^2 - 4x^2y + 2xy^2 + 2x^3}{1 + x - y} = 1 + 3x - y - 2xy + 2x^2 \]
{1 + 4x - 2y + 5x^2 - 6xy + y^2 - 4x^2y + 2xy^2 + 2x^3}/{1 + x - y} = {1 + 2x^2 - 2xy - y + 3x}

By leveraging the human visual cortex for solving polynomial arithmetic, we can take advantage of the consistency in the structure. The benefits include:

Looking at these starting simplexes, can you guess the shape of the result before performing the division?
{z^3 - zx^2 + yx^2 - yz^2 + 2xz^2 - 2xzy}/{z^2 + 2xz - x^2} = {z - y}
Here is the last division in the conventional form:
\[ \frac{z^3 + 2xz^2 - yz^2 - zx^2 - 2xzy + yx^2}{z^2 + 2xz - x^2} = z - y \]
For more complicated examples:
\[ (x^3 + x^2z - xz^2 + z^3 + z^2y + zy^2 + y^3 - y^2x + x^2y - xyz).(x + y + z) = (z^4 + 2yz^3 + 2y^2z^2 -xyz^2 + 2y^3z -xy^2z + x^2yz + 2x^3z + y^4 + 2x^3y + x^4) \]
{x^3 + x^2z - xz^2 + z^3 + z^2y + zy^2 + y^3 - y^2x + x^2y - xyz}.{x + y + z} = {z^4 + 2yz^3 + 2y^2z^2 -xyz^2 + 2y^3z -xy^2z + x^2yz + 2x^3z + y^4 + 2x^3y + x^4}
\[ \frac{- z^5 + 2z^4x - 3z^3x^2 + z^2x^3 - x^5 + 3x^3y^2 - x^2y^3 + y^5 + 2y^4z + y^3z^2 + y^2z^3 + 2xz^3y + xz^2y^2 - 3x^2z^2y - x^2zy^2 + 4x^3yz}{-x^2 + xy + y^2 + yz - z^2 + zx} = x^3 + x^2z - xz^2 + z^3 + z^2y + zy^2 + y^3 - y^2x + x^2y - xyz \]
{- z^5 + 2z^4x - 3z^3x^2 + z^2x^3 - x^5 + 3x^3y^2 - x^2y^3 + y^5 + 2y^4z + y^3z^2 + y^2z^3 + 2xz^3y + xz^2y^2 - 3x^2z^2y - x^2zy^2 + 4x^3yz}/{-x^2 + xy + y^2 + yz - z^2 + zx} = {x^3 + y^3 + z^3 + x^2z + z^2y - y^2x - xz^2 + zy^2 + x^2y - xyz}

Though I only present the trick with atmost three variables using simplexes in Euclidean space, I believe that more if possible for individuals capable of reasoning in higher dimensions.

∂ Final words

In essence, I have transformed polynomial arithmetic into a straightforward graphical game. My hope is that this technique will assist those who find math challenging, making their learning experience more enjoyable and accessible.

For those who still find math hard, I have a bad news and a good news for you. The bad news is it's not just math, the truth is hard. Math is unfortunately the simplification of truth that allows us to work with it more easily.

But luckily, it's not just you. Math is hard for everyone. Even one of the greatest physicists said it in his style.

Do not worry about your difficulties in mathematics. I can assure you mine are still greater.

Albert Einstein

The point is, there is nothing in the world that's of value and easy to get. Only hard stuff worth pursuing. And only those who have the gut to press on will get it.

∂ Exercise

One final trick
\[(0\;a\;b\;\ldots\;z\;0) = (a\;b\;\ldots\;z)\]
Now can you solve this problem using what you've just learned?
if \( x^2 + y^2 + (-x-y)^2 = 35 \), then \[ \frac{\left( x^3 + y^3 + (-x-y)^3 \right) \left( x^4 + y^4 + (-x-y)^4 \right)}{ \left( x^5 + y^5 + (-x-y)^5 \right)} = \; ? \]
If you've mastered the technique, you should be able to solve this problem with minimal ink spending.