Multiplication of Polynomials in Point Form

Polynomial multiplication is widely used in zero-knowledge proofs and mathematical cryptography. But the brute force or traditional approach for multiplying polynomials runs in O(n2)\mathcal{O}(n^2), which is fine for small inputs but becomes quite expensive as the degree of the polynomial increases. This article takes a detailed look at polynomial multiplication in order to explore ways of making it faster.

  • We begin with a review of the schoolbook/traditional polynomial arithmetic
  • Followed by a study of different forms of representation of polynomials
  • We examine and compare polynomial arithmetic in these different forms
  • Finally, we look at how these forms can potentially speed up polynomial multiplication - and how they form the grounds for an algorithm called Number Theoretic Transform (NTT)

Polynomial Multiplication - Traditional approach

Consider two polynomials p1(x)p_1(x) and p2(x)p_2(x) of degree nn each:

p1(x)=a0+a1x+a2x2++anxnp2(x)=b0+b1x+b2x2++bnxnp_1(x) = a_0 + a_1x + a_2x^2 + \dots + a_nx^n \\p_2(x) = b_0 + b_1x + b_2x^2 + \dots + b_nx^n

Multiplying these two polynomials using the simple way of distribution of multiplication over addition takes O(n2)\mathcal{O}(n^2). Here, each term of p1(x)p_1(x) is multiplied with each term of p2(x)p_2(x):

p1(x)p2(x)=p1(x)(b0+b1x++bnxn)=(a0+a1x++anxn)(b0+b1x++bnxn)=a0(b0+b1x++bnxn)+a1x(b0+b1x++bnxn)+anxn(b0+b1x++bnxn)\begin{aligned} p_1(x) \cdot p_2(x) &= p_1(x)\cdot (b_0 + b_1x + \dots + b_nx^n) \\ &= (a_0 + a_1x + \dots + a_nx^n)\cdot (b_0 + b_1x + \dots + b_nx^n) \\ &= a_0\cdot (b_0 + b_1x + \dots + b_nx^n) \\ &+ a_1x\cdot (b_0 + b_1x + \dots + b_nx^n) \\ & \vdots\\ &+ a_nx^n\cdot (b_0 + b_1x + \dots + b_nx^n) \end{aligned}

For example,
let p1(x)=1+2xp_1(x) = 1 + 2x,
and p2(x)=3+4xp_2(x) = 3 + 4x.

Then,

Step-wise multiplication of p1(x) and p2(x) by distribution of multiplication over addition.

When programmed, this is implemented in the form of nested loops.

# Let A be array representing the coefficients of p1(x)
A = [a0, a1, ..., an]
# Let B be array representing the coefficients of p2(x)
B = [b0, b1, ..., bn]
# Let C be the array storing coefficients of p1(x).p2(x)

function multiply_polynomials(A, B):
    n = len(A)
    m = len(B)
    C = array of zeros of length (n + m - 1)

    for i from 0 to n - 1:
        for j from 0 to m - 1:
            C[i + j] += A[i] * B[j]
    return C

You would get the result as:

×34x134x2x6x8x2\begin{array}{c|cc} \times & 3 & 4x \\ \hline 1 & 3 & 4x \\ 2x & 6x & 8x^2 \end{array}

For each nn iterations of the outer loop, the inner loop executes n times (assuming equal degree m=nm=n), thus giving n times n, i.e. runtime of O(n2)\mathcal{O}(n^2).

We now want to see if we can optimize this and do better. Or simply, is there a way to make polynomial multiplication faster?

Ways to represent a Polynomial

There are two ways in which we can represent a polynomial: coefficient form and point form.

Coefficient Form

Polynomials are usually expressed in what is called the monomial basis, or the coefficient form, meaning it’s written as a linear combination of powers of the variable.

For instance, a polynomial of degree nn, when expressed as

p(x)=a0+a1x+a2x2++anxnp(x) = a_0 + a_1 x + a_2 x^2 + \dots + a_n x^n

is expressed in the monomial basis, since it is using [1,x,x2,,xn][1, x, x^2, …, x^n] as the basis for its coefficients, which are a0,a1,a2,..,ax.a_0, a_1, a_2, .., a_x.

In this representation, the coefficients of p(x)p(x) can be written as a vector or an array, like [a0,a1,,an][a_0, a_1, …, a_n], where the first element corresponds to the constant term or coefficient of x0x^0, while the last element corresponds to the coefficient of xnx^n.

You should note that the earlier method of distributive multiplication we looked at (runtime O(n2)\mathcal{O}(n^2)) was applied over the coefficient form of polynomials.

Point (or Value) Form

The point (or value) form representation is based on the fact that every polynomial of degree nn can be represented by a set of n+1n+1 distinct points that lie on it.

For example, consider a quadratic polynomial (degree 22):

2x23x+12x^2-3x+1

Now take any 33 (because n=2n=2) lying on this curve, say (0,1)(0,1), (1,0)(1,0) and (2,3)(2,3). We can say that these 33 points represent the given polynomial. Alternatively, if we are just given these points, it is possible to recover the polynomial 2x23x+12x^2 -3x+1 from that information. Why does this work? Or how are we able to equivalently represent a degree nn polynomial with n+1n+1 points?

This is because:

For every set of n+1n+1 distinct points, there exists a unique lowest degree polynomial of degree at most nn that passes through all of them.

This lowest degree polynomial is called the Lagrange Polynomial.

For example,
given two points (1,2)(1, 2) and (3,4)(3, 4), there exists a unique polynomial of degree 11 (a line) passing through these points:

p(x)=1+xp(x) = 1 + x

Similarly,
given three points (0,1)(0, 1), (1,4)(1, 4), and (2,9)(2, 9), the Lagrange polynomial of degree 22 passing through these points is:

p(x)=1+2x+x21+2(0)+(0)2=11+2(1)+(1)2=41+2(2)+(2)2=9p(x) = 1 +2x+ x^2 \\ 1 + 2(0) + (0)^2 = 1 \\ 1 + 2(1) + (1)^2 = 4 \\ 1 + 2(2) + (2)^2 = 9

How this special polynomial is calculated given a set of points is something that is discussed in this article on Lagrange interpolation.

Uniqueness of the Lagrange Polynomial

You must note that for a set of points, there are multiple polynomials of a given degree that pass through all of them. But only the lowest degree polynomial is unique.

For instance, in the above example of points (1,2)(1, 2) and (3,4)(3, 4), there exist many polynomials passing through these two points:
x23x+4x^2 -3x +4 and 2x27x+72x^2 -7x +7 are two of many polynomials of degree 22 (quadratic) that pass through these two points.

 and , two of the many quadratic polynomials that pass through  and .

Similarly, if you consider degree 33, two example polynomials passing through points (1,2)(1,2) and (3,4)(3,4) are x35x2+8x2x^3 -5x^2 +8x-2 and x3+4x22x+1-x^{3}+4x^{2}-2x+1.

 and , two of the many cubic polynomials that pass through  and .

But for the lowest degree, here 11, there exists only one polynomial of the lowest degree, and that is p(x)=1+xp(x) = 1 + x. It is unique, and there is no other polynomial of degree 11 that can pass through these two given points.

The unique linear polynomial  passing through  and .

How is this lowest degree determined?

For every set of n+1n+1 distinct points, there is a unique polynomial of degree at most nn that passes through them. The degree of the unique polynomial is less than nn if some of the points are collinear or lie on a lower degree polynomial. Therefore, we use the term “at most nn” to cover the case where the degree is exactly nn, as well as cases where the degree is lower.

For example,
given the points (1,2),(2,4),(1,2),(2,4), and (3,6)(3,6), the polynomial of lowest degree passing through them is y=2xy=2x. This is because the points are collinear, i.e. they lie on a line. One can check that the slope between any pair of them is the same:

4221=6432=2\frac{4-2}{2-1} = \frac{6-4}{3-2} = 2

Therefore, the lowest degree is 11, and y=2xy=2x is the unique Lagrange polynomial.

Similarly,
Given five points, (2,1),(1,0),(0,1),(1,4),(2,9)(-2,1), (-1,0), (0,1), (1,4), (2,9), we find that all of them lie on a parabola with the equation

y=x2+2x+1y = x^2 + 2x + 1

This is a case where all the given points lie on a lower degree polynomial, here degree 22, and thus the Lagrange polynomial has degree 22, which is less than nn (Here, n=4n=4).

Refer to the Appendix at the end for proof of uniqueness of the lowest degree polynomial.

Conversion Between Coefficient Form and Point Form

Since coefficient form and point form are equivalent, we can readily convert between them as we show now.

Interpolation (Point Form → Coefficient Form)

The conversion from point form to coefficient form, called interpolation, is calculating the polynomial of lowest degree which passes through all the given points. One of the most well-known methods it is done is using Lagrange Interpolation, that we mentioned previously. If you are unfamiliar with it, you may go through this article.

In short, given a set of (n+1)(n+1) distinct points

{(x0,y0),(x1,y1),,(xn,yn)}\{(x_0, y_0), (x_1, y_1), \dots, (x_n, y_n)\}

we can find the unique lowest degree polynomial p(x)p(x) of degree at most nn using the formula for Lagrange interpolation, such that:

p(xi)=yifor all i=0,1,,np(x_i) = y_i \quad \text{for all } i = 0, 1, \dots, n

You should keep in mind that the runtime of Lagrange interpolation is O(n2)\mathcal{O}(n^2).

Evaluation (Coefficient Form → Point Form)

The conversion from coefficient form to point form, called evaluation, is evaluating the polynomial at values of xx to obtain the corresponding values of yy, and thus a set of (xi,yi)(x_i, y_i) points, which represent the polynomial. One common way this can be done is by using Horner’s rule (to be discussed in detail in a future article).

In short, given coefficients [a0,a1,,an][a_0, a_1, \dots, a_n] of a polynomial p(x)p(x) and a value xix_i, Horner’s Method evaluates p(xi)p(x_i) as follows:

p(xi)=a0+xi(a1+xi(a2++xian))p(x_i) = a_0 + x_i(a_1 + x_i(a_2 + \dots + x_i a_n) \dots)

This method factors out common powers of xx, one at a time until all the terms are processed. Let us look at an example to understand it better.

Given the polynomial p(x)=2+3x+5x2+x3p(x) = 2 + 3x + 5x^2 + x^3 and a value x=2x = 2, we will review how Horner’s rule evaluates p(2)p(2).

We can rewrite p(x)p(x) as follows (as shown in the generalized expression above):

p(x)=2+x(3+x(5+x(1)))p(x) = 2 + x(3 + x(5 + x(1)))

Substituting x=2x = 2:

Step-wise multiplication using Horner’s method with alternative multiplication and addition operations.

Observe how the steps involve alternating multiplications and additions. Steps 1, 3 and 5 of the above calculation are multiplications, while steps 2, 4 and 6 are additions. In total, there are nn multiplications and nn additions (here n=3n=3), giving a total runtime of O(n)\mathcal{O}(n). This is how Horner’s rule evaluates a polynomial of degree nn at a given value of xx in O(n).\mathcal{O}(n).

Therefore, evaluating the polynomial at n+1n+1 distinct xx-values - converting from coefficient to point form using this rule - takes nn times n+1n+1, i.e. O(n2)\mathcal{O}(n^2).

Coefficient form VS Point form

We said that coefficient form and point form of a polynomial are equivalent, and one can be converted to the other. That is, there is no difference in the final results of addition and multiplication when done in either form. Let us examine this, with an example of addition first.

Addition in coefficient form

Consider two polynomials given in coefficient form,

p1(x)=1+2x+3x2p2(x)=4+0x+1x2p_1(x) = 1 + 2x + 3x^2 \\p_2(x) = 4 + 0x + 1x^2

Or their respective arrays of coefficients:

p1:[1, 2, 3]p2:[4, 0, 1]p_1: [1,\ 2,\ 3] \\p_2: [4,\ 0,\ 1]

Now, adding the two polynomials is simply adding the two arrays element-wise, and the resultant coefficient array represents the final polynomial. Let’s verify this:

psum(x)=(1+4)+(2+0)x+(3+1)x2=5+2x+4x2p_{\text{sum}}(x) = (1+4) + (2+0)x + (3+1)x^2 = 5 + 2x + 4x^2

Or simply, [(1+4),(2+0),(3+1)]=[5, 2, 4][(1+4), (2+0),(3+1)] = [5,\ 2,\ 4]

For two polynomials of degree nn, we perform n+1n+1 additions to get the sum’s representation. Therefore, the runtime of addition in coefficient form is O(n)\mathcal{O}(n).

Addition in point form

Consider the same two polynomials,

p1(x)=1+2x+3x2p2(x)=4+0x+1x2p_1(x) = 1 + 2x + 3x^2 \\p_2(x) = 4 + 0x + 1x^2

First, we need to convert them from coefficient form to point form. Since the degree of both polynomials is 22, the degree of their sum will be at most 22 as well. Therefore, we need three points to represent the sum (degree plus one: n+1n + 1), which requires 33 evaluations each of p1(x)p_1(x) and p2(x)p_2(x).

Let us evaluate p1(x)p_1(x) and p2(x)p_2(x) at x=0,1,2x = 0, 1, 2 to get our points.

Note: We are just choosing x=0,1,2x=0,1,2 for simplicity. You could pick any other 33 points for evaluation.

  • p1(0)=1,p1(1)=6,p1(2)=17p_1(0) = 1, \quad p_1(1)= 6, \quad p_1(2)=17
  • p2(0)=4,p2(1)=5,p2(2)=8p_2(0) = 4, \quad p_2(1)= 5, \quad p_2(2)=8

Now, adding the two polynomials requires adding the corresponding evaluations element-wise, that is:

  • psum(0)=(1+4)=5p_{\text{sum}}(0) = (1+4) =5
  • psum(1)=(6+5)=11p_{\text{sum}}(1) = (6+5) =11
  • psum(2)=(17+8)=25p_{\text{sum}}(2) = (17+8) =25

These three points (0,5),(1,11)(0, 5), (1, 11) and (2,25)(2, 25) give us the point representation of the sum. Let us verify whether they satisfy the polynomial we calculated earlier:

psum(x)=5+2x+4x2p_{\text{sum}}(x) = 5 + 2x + 4x^2
  • psum(0)=5p_{\text{sum}}(0) = 5
  • psum(1)=5+2+4=11p_{\text{sum}}(1) = 5 + 2 + 4 = 11
  • psum(2)=5+4+16=25p_{\text{sum}}(2) = 5 + 4 + 16 = 25

Therefore, you see that addition in both forms gives the same result, or the same polynomial, just represented in different ways.

In point form addition, for two polynomials of degree nn, there are n+1n+1 points representing each of them, and thus n+1n+1 element-wise additions that we perform to get the sum’s representative points. Therefore, the runtime of addition in point form is O(n)\mathcal{O}(n).

Now, let us also look at multiplication closely.

Multiplication in coefficient form

Consider two polynomials given in coefficient form:

p1(x)=1+2xp2(x)=3+4xp_1(x) = 1 + 2x\\p_2(x) = 3 + 4x

Or their respective coefficient arrays:
p1=[1, 2]p_1 = [1,\ 2] and p2=[3, 4]p_2 = [3,\ 4]

Multiplying them using the distributive way discussed earlier gives:

pprod(x)=(1)(3+4x)+(2x)(3+4x)=3+4x+6x+8x2=3+10x+8x2\begin{aligned} p_{\text{prod}}(x) &= (1)(3+4x) + (2x)(3 + 4x) \\ &= 3 + 4x + 6x + 8x^2 \\&= 3 + 10x + 8x^2 \end{aligned}

The resulting polynomial is pprod(x)=3+10x+8x2p_{\text{prod}}(x) = 3 + 10x + 8x^2, represented by the coefficient array [3, 10, 8][3,\ 10,\ 8]. The distributive method of coefficient form multiplication takes O(n2)\mathcal{O}(n^2), as we saw at the start of this article.

Multiplication in point form

We now consider the same polynomials and convert them to their point forms.

p1(x)=1+2xp2(x)=3+4xp_1(x) = 1 + 2x\\p_2(x) = 3 + 4x

Since both polynomials have degree 11, their product will have a degree of at most 22, meaning we need 33 points to represent it, which requires 3 evaluations of each of p1(x)p_1(x) and p2(x)p_2(x).

So, let’s evaluate p1(x)p_1(x) and p2(x)p_2(x) at x=0,1,2x = 0, 1, 2.

  • p1(0)=1,p1(1)=3,p1(2)=5p_1(0) = 1,\quad p_1(1) = 3,\quad p_1(2) = 5
  • p2(0)=3,p2(1)=7,p2(2)=11p_2(0) = 3,\quad p_2(1) = 7,\quad p_2(2) = 11

Now, to get the points that represent their product, we multiply the evaluations element-wise:

  • pprod(0)=13=3p_{\text{prod}}(0) = 1 \cdot 3 = 3
  • pprod(1)=37=21p_{\text{prod}}(1) = 3 \cdot 7 = 21
  • pprod(2)=511=55p_{\text{prod}}(2) = 5 \cdot 11 = 55

So the three points (0,3),(1,21)(0, 3), (1, 21) and (2,55)(2, 55) give us the point representation of the resultant product.

Let’s verify if they satisfy the polynomial product we got earlier:

pprod(x)=3+10x+8x2p_{\text{prod}}(x) = 3 + 10x + 8x^2
  • pprod(0)=3p_{\text{prod}}(0) = 3
  • pprod(1)=3+10+8=21p_{\text{prod}}(1) = 3 + 10 + 8 = 21
  • pprod(2)=3+20+32=55p_{\text{prod}}(2) = 3 + 20 + 32 = 55

Therefore, you can see that multiplication in both forms gives the same polynomial, just represented in different ways.

In summary, for two polynomials p1(x)p_1(x) and p2(x)p_2(x) of degree nn, their product will have a degree of at most 2n2n, meaning we need 2n+12n+1 points to represent it. Thus, we perform 2n+12n+1 evaluations for each polynomial at common values of xx to convert them into point form:

p1(x0),p1(x1),p1(x2),p1(x2n)p2(x0),p2(x1),p2(x2),p2(x2n)p_1(x_0), p_1(x_1), p_1(x_2), \dots p_1(x_{2n})\\p_2(x_0), p_2(x_1), p_2(x_2), \dots p_2(x_{2n})

We then perform point form multiplication by multiplying these two sets element-wise, which takes 2n+12n+1 multiplications, i.e., runtime of O(n)\mathcal{O}(n).

p1(x0)p2(x0),  p1(x1)p2(x1),,  p1(x2n)p2(x2n)p_1(x_0) \cdot p_2(x_0), \; p_1(x_1) \cdot p_2(x_1), \dots, \; p_1(x_{2n}) \cdot p_2(x_{2n})

This gives us the 2n+12n+1 points which represent the product p1(x).p2(x)p_1(x).p_2(x):

{(x0,p1(x0)p2(x0)),  (x1,p1(x1)p2(x1)),,  (x2n,p1(x2n)p2(x2n))}\{(x_0,p_1(x_0) \cdot p_2(x_0)), \; (x_1, p_1(x_1) \cdot p_2(x_1)), \dots, \; (x_{2n}, p_1(x_{2n}) \cdot p_2(x_{2n}))\}

The amazing thing to note here is that, while addition in both coefficient and point form takes the same time O(n)\mathcal{O}(n), multiplication in point form is significantly faster than in coefficient form. In point form, we perform 2n+12n+1 element-wise multiplications, giving a runtime of O(n)\mathcal{O}(n), which is way better than the O(n2)\mathcal{O}(n^2) required for coefficient form multiplication!

However, there is still an issue- we haven’t considered the overhead of converting to the point form and vice versa.

So, lets look at the complete process of multiplication in point form, which involves three steps:

  1. Conversion of coefficient to point form
    We evaluate the two polynomials of degree nn, to be multiplied, at (2n+1)(2n+1) values of xx, to get a set of (2n+1)(2n+1) evaluations each. This takes O(n2)\mathcal{O}(n^2) using Horner’s Method.
  2. Element-wise multiplication in point form representation
    We multiply these two sets element-wise to get (2n+1)(2n+1) evaluations that gives the point form representation of their product. This takes O(n)\mathcal{O}(n).
  3. Conversion of point to coefficient form
    We calculate the unique lowest degree polynomial (coefficient form) that passes through all the resultant (2n+1)(2n+1) points. This takes O(n2)\mathcal{O}(n^2) using Lagrange interpolation.

Therefore, the overall runtime for the steps above is:

O(n2)+O(n)+O(n2)O(n2)\mathcal{O}(n^2) + \mathcal{O}(n) + \mathcal{O}(n^2) \approx \mathcal{O}(n^2)

which is no better than where we started from. Thus, we need to explore whether any optimizations can make this process faster.

Optimizing conversion

The key point to keep in mind is that multiplication in coefficient form takes O(n2)\mathcal{O}(n^2), whereas multiplication in point form (element-wise) takes O(n)\mathcal{O}(n). Therefore, if we can find a way to convert coefficient form to point form and vice versa (steps 1 and 3 mentioned above) faster than O(n2)\mathcal{O}(n^2), we can optimize multiplication to run in sub-quadratic time.

It is important to note that we cannot optimize polynomial addition, because addition in both coefficient form and point form runs in O(n)\mathcal{O}(n) each.

So now let us brainstorm a few ways we might make the conversion from coefficient to point form faster.

What if we knew a point whose evaluation could give us the values of several related points, saving us from repeated calculations?

For example, if we had a polynomial with a symmetric graph, evaluating one point would tell us the evaluation for its corresponding symmetric point as well.

Consider the polynomial p(x)=x2p(x)= x^2.
Observe how,

p(2)=4   and   p(2)=4p(-2) = 4\space\space\space \text{and} \space\space\space p(2) =4

A graph of  showing symmetric values of  and .

Or, more simply, observe how for all xix_i,

p(xi)=p(xi)p(-x_i)=p(x_i)

This is not just true for p(x)=x2p(x)=x^2, but generalizes to all polynomials that contain only even powered coefficients, which are also called as even polynomials.

For example, consider the even polynomial (containing only terms with even powers of xx:

q(x)=x10+3x82x6+3x42x2x0q(x) =x^{10}+3x^{8}-2x^{6}+3x^{4}-2x^{2}-x^{0}

A graph of  showing symmetric curve about y-axis.

In the graph above, it is easy to observe that

q(x)=q(x)q(x) =q(-x)

Visually speaking, the graphs of even polynomials are mirrored about the yy-axis, and they evaluate to the same yy for both positive and negative values of any given xx.

What about odd polynomials that contain only odd powered coefficients?
Consider p(x)=x3p(x) = x^3.
Observe how

p(2)=8=p(2)p(-2) = -8 =-p(2)

A graph of  showing symmetricity about origin.

In the graph above, observe how, for all xix_i,

p(xi)=p(xi)p(-x_i) = -p(x_i)

Again, this is not just true for p(x)=x3p(x)=x^3, but generalizes to all odd polynomials, i.e. polynomials containing only terms with odd powers of xx. For example, consider the polynomial

q(x)=x7+3x5+x3xq(x)=-x^{7}+3x^{5}+x^{3}-x

A graph of  showing symmetricity about origin.

In the graph above, observe that

q(x)=q(x)q(x) = -q(-x)

Visually, the graphs of all odd polynomials are symmetric about the origin, which makes the above equality true for all of them.

Now you can see that after evaluating certain points, we can get the evaluation at other points without any extra calculation. For instance, in the examples above, for even and odd polynomials, knowing the evaluation for p(x)p(x) also gives us the evaluation for p(x)p(-x).

We can exploit this fact to make polynomial multiplication faster, which is exactly what a beautiful algorithm called the Number Theoretic Transform (NTT) allows us to do. NTT enables evaluation and interpolation in O(nlogn)\mathcal{O}(n \log n) by recursively using properties of symmetries of certain points, thereby making the conversion sub-quadratic.

But since NTT operates over a finite field, there are no negative values of xx we can work with. This is where the concepts of multiplicative subgroups, cyclicity and roots of unity come into the picture. These concepts will allow us to exploit the symmetries present in finite fields to perform polynomial multiplication more efficiently. We’ll explore how NTT works in detail in upcoming articles.

Appendix

Uniqueness of lowest degree polynomial proof

We show that if there are two polynomials p(x)p(x) and q(x)q(x) of equal degree which interpolate a set of points, then a polynomial r(x)r(x) must exist such that r(x)=p(x)q(x)r(x) = p(x)-q(x).

We will then show that the only possible solution for r(x)r(x) is r(x)=0r(x) = 0, otherwise we end up with a polynomial that has more roots than its degree, which we show is impossible. Let us look at these steps in detail now.

Let us assume that the lowest degree Lagrange polynomial is not unique. Then there are at least two distinct polynomials of lowest degree that pass through all given n+1n+1 points. Let these two polynomials be p(x)p(x) and q(x)q(x). Now, define the polynomial r(x)r(x) as the difference between p(x)p(x) and q(x)q(x).

r(x)=p(x)q(x)r(x) = p(x) - q(x)

Now, if we show that r(x)r(x) is 00 for all values of xx, then we will have shown that p(x)p(x) equals q(x)q(x), and therefore the Lagrange polynomial is unique.

Since the degree of both p(x)p(x) and q(x)q(x) is at most nn, it follows from simple algebraic subtraction that r(x)r(x) must also have degree at most nn.
Also, since both p(x)p(x) and q(x)q(x) pass through the same n+1n+1 points, they will evaluate to the same yy-value for each of the xx-values.

Note: Graphically, when two different polynomials evaluate to the same yy-value for a given xx, it means that they intersect at that point. For example:

p(x)=x2andq(x)=2x.p(x) = x^2 \quad \text{and} \quad q(x) = 2x.

A graph showing how  and  intersect at  and .

At x=2x=2, both give y=4y=4, so they intersect at the point (2,4)(2,4). In this case, we’re dealing with different polynomials. Another possibility for having the same yy for a given xx is that they are actually the same polynomial! In that case, they will have the same yy for all values of xx, not just for some particular values of xx.

In the case of p(x)p(x) and q(x)q(x), they are equal for at least n + 1 different values of xx. This can be mathematically expressed as:

p(xi)=q(xi)  i{0,1,,n}p(x_i)=q(x_i) \space\space\forall i \in \{0,1,\dots, n\}

So, the difference between p(x)p(x) and q(x)q(x) at all n+1n+1 points will be zero. That is,

r(xi)=p(xi)q(xi)=0  i{0,1,,n}r(x_i) =p(x_i)- q(x_i) = 0 \space\space\forall i \in \{0,1,\dots, n\}

Therefore, r(x)r(x) evaluates to zero at n+1n+1 points, which implies that it is a zero polynomial. Let us see more clearly why.

A zero polynomial is one that evaluates to zero for all values of xx. The simplest example of a zero polynomial is:

p(x)=0p(x) = 0

Another way of looking at this is, if our domain of polynomial evaluation - the set of points at which the polynomial can be evaluated - is, say, S={x0,x1,xn1}S=\{x_0, x_1 \cdots, x_{n-1}\}, then a zero polynomial for this domain can be:

p(x)=(xx0)(xx1)(xxn1)p(x)=(x-x_0)(x-x_1)\cdots (x-x_{n-1})

Because,

p(x)=0x{x0,x1,xn1}p(x) = 0 \quad \forall \quad x\in \{x_0,x_1,\cdots x_{n-1}\}

We could have many more zero polynomials for the domain SS such as:

f1(x)=p(x)f2(x)=p(x)2f3(x)=0p(x)f_1(x)=p(x)\\f_2(x)=p(x)^2\\f_3(x)=0\cdot p(x)

Notice that each of f1(x),f2(x)f_1(x), f_2(x) and f3(x)f_3(x) evaluates to zero for the domain SS, and thus is a zero polynomial. We can have many more. The most primitive one being f3(x)=0f_3(x)=0, i.e. the constant zero itself.

Note: If the domain SS is taken as the set of all real numbers, then the only zero polynomial we can have is f(x)=0f(x)=0, since no other polynomial will evaluate to zero for all real numbers.

Now observe the number of roots and degree for each of the example zero polynomials we looked at.

Roots of a polynomial are the values in the domain for which the polynomial evaluates to zero, whereas the degree of a polynomial is the highest power of the variable as you well know.

  • f1(x):f_1(x): Roots- nn, Degree- nn
  • f2(x):f_2(x): Roots- nn, Degree- 2n2n
  • f3(x):f_3(x): Roots- nn, Degree- 00

All of them evaluate to zero on SS; therefore, the number of roots is nn, whereas the degree can be varied by modifying p(x)p(x), whose degree is nn.

Also note that f3(x)=0f_3(x)=0 has the number of roots greater than its degree. This is only possible in the case of a zero polynomial, specifically the primitive one f3(x)=0f_3(x)=0. Otherwise, the number of roots is always less than or equal to the degree.

Consider a non-zero polynomial of degree nn; it can have at most nn roots (or intersections with the xx-axis). The primitive zero polynomial is the only exception, as it has more roots than its degree.

For example,
a quadratic equation of degree 22, such as q(x)=x23x+2q(x)=x^2-3x+2, has two roots, i.e. x=1x=1 and x=2x=2.

A graph of a upward-opening parabola, , intersecting the x-axis at points  and .

For a quadratic equation to have more than two roots, it must be equal to zero, i.e. q(x)=0q(x)=0.

Now, coming back to our argument: since r(x)r(x) evaluates to zero at n+1n+1 points, it must have at least n+1n+1 roots, which is greater than its degree nn. Therefore r(x)r(x) must be equal to zero.

p(x)q(x)=r(x)=0p(x)-q(x)=r(x)=0

This implies that p(x)=q(x)p(x)=q(x), meaning they are the same polynomial. Therefore, the polynomial of lowest degree that interpolates a set of n+1n+1 distinct points is unique.

Ready to Get Started?Join Thousands of Users Today

Start your free trial now and experience the difference. No credit card required.

© 2025 Better-Start. All rights reserved.