Polynomials and generating functions
Manipulating finite- and infinite-term polynomials is an important topic in OI mathematics, especially in the study of generating functions.
Polynomial algorithms based on the fast Fourier transform give algorithm-competition contestants the ability to manipulate generating functions directly.
Basic concepts
For the sum , if it has finitely many terms, it is called a polynomial and denoted by .
A sum with countably many terms is called a series. In the sum , every term is a constant coefficient times a nonnegative integer power of the variable; a series of this form is called a power series.
When studying polynomial arithmetic, we first consider the simpler polynomial case; the concept of a power series is used only for convenience. Mathematical analysis further studies the convergence and divergence of power series.
For general definitions of rings, fields, and their derived structures, see Basic concepts of abstract algebra.
For a general ring , define the polynomial ring over , denoted .
Each element is called a polynomial over and can be written as
In other words, we define a polynomial directly as a sequence of coefficients. It can also be written as
Here, is regarded merely as a formal symbol, an identifier for the positions of the coefficients.
If we also allow infinitely many terms, namely
we obtain the formal power series ring . Each element is called a formal power series, abbreviated to power series below.
Degree of a polynomial
For a polynomial , the degree of its highest-degree term is called the degree of the polynomial, denoted by .
Polynomial multiplication
The most fundamental operation is multiplying two polynomials. Given polynomials and :
To compute the polynomial :
Multiplication of polynomials or power series is associative and distributes over addition. If is a commutative ring or a ring with identity, multiplication also has commutativity and an identity element, respectively.
If contains a -th root of unity, the fast Fourier transform allows us to compute, in time instead of time, the product of two degree- polynomials.
Composition
In , define the powers of an element by
Based on this, for elements of denoted , define their composition by
We stipulate that exists if and only if has finitely many terms or , so no limits over are involved.
is associative (whenever both and exist), but not commutative. When is a ring with identity, has the identity element .
Polynomial composition (and compositional inversion) can be performed in time. The method was proposed by Yasunori Kinoshita and Li Baitian in 2024; see Formal power series composition | compositional inversion.
Derivative
Although a general ring may not even have limits,
we can still define the formal derivative of a formal power series as
where
The basic differentiation rules—the sum rule, product rule, and chain rule (when composition is allowed)—remain valid.
If division is allowed in , we can similarly define the formal indefinite integral of a formal power series.
Multiplicative inverse
From the example
we see that the reciprocal of a polynomial can be expanded as an infinite series. A reciprocal exists if and only if the constant term is not , and its reciprocal also has a constant term not equal to .
Thus, for a formal power series with , define its multiplicative inverse to be another formal power series satisfying
Expanding this equation using formal power series multiplication gives the recurrence for the coefficients of :
Computing the first terms directly from the recurrence takes time; using the FFT gives an algorithm.
Note
It is easy to see that the reciprocal of is the infinite Maclaurin expansion of (the Taylor expansion at ).
Common power-series expansions
In mathematical analysis, a univariate function that is differentiable to some order at a point or on an interval can be expanded into a polynomial over the corresponding range. This is generally called a Taylor expansion; an expansion at is also called a Maclaurin expansion.
If a function is infinitely differentiable, it can be expanded as a power series. The most common expansion point is still .
In complex analysis, some functions cannot be Taylor-expanded at a singularity but can be expanded in a Laurent series.
The following equalities hold only when the power series converge; they do not hold when the series diverge. We give only the expansions and do not discuss their domains of convergence.
The two basic expansions are those of the exponential and power functions:
More expansions can often be derived by transforming these two. For example, the trigonometric functions are obtained by substituting complex numbers into the exponential function:
The logarithm, arctangent, and arcsine functions are obtained by integration:
Compositional inverse
Compositional inversion is the extension of the concept of an inverse function to the formal power series ring.
For a formal power series with and , denoted , its compositional inverse is the formal power series satisfying , denoted . Lagrange inversion gives, for any integers ,
Here, denotes the coefficient of at .
Polynomial divisibility
For polynomials and , if there exists a polynomial such that
then divides .
It is clear that divides if and only if every root of is a root of , with multiplicity in no greater than the corresponding multiplicity in .
Polynomial remainders and quotients
For polynomials , there are unique polynomials satisfying
When , we have ; otherwise, . We call the quotient, with as the divisor and as the dividend, and call the remainder, with as the divisor and as the dividend.
Polynomial congruences
Polynomial congruence is the subring of a polynomial ring obtained by quotienting the polynomial ring by the equivalence relation of congruence.
In the polynomial division with remainder discussed above, and its remainder are congruent modulo the polynomial .
This congruence also means that, for the polynomial , substituting any root into and gives the same value:
Moreover, if is a root of the polynomial with multiplicity , meaning that divides , then for every integer at least and less than , denoted by ,
Here, the notation denotes the -th derivative.
Polynomial congruence can also be applied to power series. An infinite power series can be congruent to a finite polynomial modulo a specific polynomial. For example:
Clearly, all remaining terms are divisible by . Therefore, operating modulo is equivalent to truncation: truncate the power series to its first terms, directly discarding all higher-order information.
In some specific cases, we can also work modulo other polynomials; the corresponding cases are explained below.
Multi-point evaluation and interpolation of polynomials
Multi-point evaluation of a polynomial means, given a polynomial and points , computing
Polynomial interpolation means, given points
finding an -th degree polynomial such that all points lie on .
The essence of these two operations is converting a polynomial between its coefficient representation and point-value representation. Multi-point evaluation converts the coefficient representation into the point-value representation, while interpolation converts the point-value representation into the coefficient representation.
Note
From the viewpoint of power series, multi-point evaluation compresses the information in infinitely many terms into finitely many point values, and therefore loses some information; interpolation restores the coefficient representation up to the corresponding degree.
In common programming applications of evaluation and interpolation, such as the discrete Fourier transform and its inverse, the selected points all have multiplicity , that is, they are pairwise distinct, avoiding the need for derivatives.
This kind of compression guarantees agreement only at the selected points. According to the explanation of polynomial congruence above, if a power series is evaluated at points through and then interpolated to obtain a polynomial , define
Then
Since the degree of is strictly less than that of , the obtained through evaluation and interpolation is the remainder. Thus, in this situation, if the power series can be evaluated at the roots, it can be reduced modulo a polynomial. A counterexample is
It cannot be evaluated at , so the series cannot be reduced modulo the polynomial .
Since every derivative of a power series has a value at , reduction modulo can always be computed, consistent with the meaning of truncation above. The discrete Fourier transform and its inverse correspond to reduction modulo the polynomial .
Factorization and Euclidean algorithm
Many results from elementary number theory generalize to polynomials.
Over the complex numbers, the fundamental theorem of algebra implies that for an -th degree polynomial , the equation
has exactly solutions, counting repeated roots according to their multiplicity.
Therefore, over the complex numbers, has the unique factorization
Analogous to the greatest common divisor of positive integers, this gives the polynomial greatest common divisor (gcd). It can be computed with the Euclidean algorithm:
This property generalizes to a more general setting:
For any field , the polynomial ring satisfies:
every polynomial has a unique factorization, and the greatest common divisor can be computed with the Euclidean algorithm.
Note that this conclusion need not hold for polynomials over a general ring.
When the Euclidean algorithm applies, the extended Euclidean algorithm gives the following Diophantine equation
A particular solution is , and Bézout's identity can be used to determine whether the Diophantine equation
is solvable.
HALF-GCD allows polynomial Euclidean algorithms to be computed in time.
Multiplicative inverse modulo a polynomial
Modulo a polynomial , a power series sometimes has an inverse. The inverse is the remainder obtained by reducing the reciprocal of modulo .
Equivalently, for a polynomial , if there exists a satisfying
then is called the inverse element of modulo . When the polynomial Euclidean algorithm applies, the inverse exists if and only if .
The inverse modulo a polynomial is always unique. If the degree of is also less than that of , then the resulting and are mutual inverses.
In terms of truncation, the inverse modulo is generally denoted by , and this is also the default meaning of inverse below. Unless otherwise specified, the modulus of an inverse is .
Note
One might ask whether various interpolation transforms can be used to solve for the inverse directly, for example by computing:
The answer is no. According to the explanation above, the inverse obtained directly using the discrete Fourier transform and its inverse here is the inverse modulo the polynomial , not the usual inverse modulo . Moreover, because the original polynomial may be at some point values, this computation may not be possible.
Generating functions
A generating function, also called a mother function, is a formal power series whose coefficients can provide information about a sequence.
Generating functions come in many kinds, but most can be written in the unified form
where is called the kernel function. Different kernel functions lead to different generating functions with different properties. For example:
- Ordinary generating function: .
- Exponential generating function: .
- Dirichlet generating function: .
References and further reading
- Picks's Blog
- Miskcoo's Space
- Polynomial ring - Wikipedia
- Formal power series - Wikipedia
- 《The theoretical framework for generating-function computation in informatics competitions》