Recent from talks
Nothing was collected or created yet.
Polynomial evaluation
View on WikipediaIn mathematics and computer science, polynomial evaluation refers to computation of the value of a polynomial when its indeterminates are substituted for some values. In other words, evaluating the polynomial at consists of computing See also Polynomial ring § Polynomial evaluation
For evaluating the univariate polynomial the most naive method would use multiplications to compute , use multiplications to compute and so on for a total of multiplications and additions. Using better methods, such as Horner's rule, this can be reduced to multiplications and additions. If some preprocessing is allowed, even more savings are possible.
Background
[edit]This problem arises frequently in practice. In computational geometry, polynomials are used to compute function approximations using Taylor polynomials. In cryptography and hash tables, polynomials are used to compute k-independent hashing.
In the former case, polynomials are evaluated using floating-point arithmetic, which is not exact. Thus different schemes for the evaluation will, in general, give slightly different answers. In the latter case, the polynomials are usually evaluated in a finite field, in which case the answers are always exact.
General methods
[edit]Horner's rule
[edit]Horner's method evaluates a polynomial using repeated bracketing: This method reduces the number of multiplications and additions to just
Horner's method is so common that a computer instruction "multiply–accumulate operation" has been added to many computer processors, which allow doing the addition and multiplication operations in one combined step.
Multivariate
[edit]If the polynomial is multivariate, Horner's rule can be applied recursively over some ordering of the variables. E.g.
can be written as
An efficient version of this approach was described by Carnicer and Gasca.[1]
Estrin's scheme
[edit]While it's not possible to do less computation than Horner's rule (without preprocessing), on modern computers the order of evaluation can matter a lot for the computational efficiency. A method known as Estrin's scheme computes a (single variate) polynomial in a tree like pattern:
Combined by Exponentiation by squaring, this allows parallelizing the computation.
Evaluation with preprocessing
[edit]Arbitrary polynomials can be evaluated with fewer operations than Horner's rule requires if we first "preprocess" the coefficients .
An example was first given by Motzkin[2] who noted that
can be written as
where the values are computed in advance, based on . Motzkin's method uses just 3 multiplications compared to Horner's 4.
The values for each can be easily computed by expanding and equating the coefficients:
Example
[edit]To compute the Taylor expansion , we can upscale by a factor 24, apply the above steps, and scale back down. That gives us the three multiplication computation
Improving over the equivalent Horner form (that is ) by 1 multiplication.
Some general methods include the Knuth–Eve algorithm and the Rabin–Winograd algorithm. [3]
Multipoint evaluation
[edit]Evaluation of a degree-n polynomial at multiple points can be done with multiplications by using Horner's method times. Using the above preprocessing approach, this can be reduced by a factor of two; that is, to multiplications.
However, it is possible to do better and reduce the time requirement to just .[4] The idea is to define two polynomials that are zero in respectively the first and second half of the points: and . We then compute and using the Polynomial remainder theorem, which can be done in time using a fast Fourier transform. This means and by construction, where and are polynomials of degree at most . Because of how and were defined, we have
Thus to compute on all of the , it suffices to compute the smaller polynomials and on each half of the points. This gives us a divide-and-conquer algorithm with , which implies by the master theorem.
In the case where the points in which we wish to evaluate the polynomials have some structure, simpler methods exist. For example, Knuth[5] section 4.6.4 gives a method for tabulating polynomial values of the type
Dynamic evaluation
[edit]In the case where are not known in advance, Kedlaya and Umans[6] gave a data structure for evaluating polynomials over a finite field of size in time per evaluation after some initial preprocessing. This was shown by Larsen[7] to be essentially optimal.
The idea is to transform of degree into a multivariate polynomial , such that and the individual degrees of is at most . Since this is over , the largest value can take (over ) is . Using the Chinese remainder theorem, it suffices to evaluate modulo different primes with a product at least . Each prime can be taken to be roughly , and the number of primes needed, , is roughly the same. Doing this process recursively, we can get the primes as small as . That means we can compute and store on all the possible values in time and space. If we take , we get , so the time/space requirement is just
Kedlaya and Umans further show how to combine this preprocessing with fast (FFT) multipoint evaluation. This allows optimal algorithms for many important algebraic problems, such as polynomial modular composition.
Specific polynomials
[edit]While general polynomials require operations to evaluate, some polynomials can be computed much faster. For example, the polynomial can be computed using just one multiplication and one addition since
Evaluation of powers
[edit]A particularly interesting type of polynomial is powers like . Such polynomials can always be computed in operations. Suppose, for example, that we need to compute ; we could simply start with and multiply by to get . We can then multiply that by itself to get and so on to get and in just four multiplications. Other powers like can similarly be computed efficiently by first computing by 2 multiplications and then multiplying by .
The most efficient way to compute a given power is provided by addition-chain exponentiation. However, this requires designing a specific algorithm for each exponent, and the computation needed for designing these algorithms are difficult (NP-complete[8]), so exponentiation by squaring is generally preferred for effective computations.
Polynomial families
[edit]Often polynomials show up in a different form than the well known . For polynomials in Chebyshev form we can use Clenshaw algorithm. For polynomials in Bézier form we can use De Casteljau's algorithm, and for B-splines there is De Boor's algorithm.
Hard polynomials
[edit]The fact that some polynomials can be computed significantly faster than "general polynomials" suggests the question: Can we give an example of a simple polynomial that cannot be computed in time much smaller than its degree? Volker Strassen has shown[9] that the polynomial
cannot be evaluated with less than multiplications and additions. At least this bound holds if only operations of those types are allowed, giving rise to a so-called "polynomial chain of length ".
The polynomial given by Strassen has very large coefficients, but by probabilistic methods, one can show there must exist even polynomials with coefficients just 0's and 1's such that the evaluation requires at least multiplications.[10]
For other simple polynomials, the complexity is unknown. The polynomial is conjectured to not be computable in time for any . This is supported by the fact that, if it can be computed fast, then integer factorization can be computed in polynomial time, breaking the RSA cryptosystem.[11]
Matrix polynomials
[edit]Sometimes the computational cost of scalar multiplications (like ) is less than the computational cost of "non scalar" multiplications (like ). The typical example of this is matrices. If is an matrix, a scalar multiplication takes about arithmetic operations, while computing takes about (or using fast matrix multiplication).
Matrix polynomials are used, for example, for computing matrix exponentials.
Paterson and Stockmeyer[12] showed how to compute a degree polynomial using only non scalar multiplications and scalar multiplications. Thus a matrix polynomial of degree n can be evaluated in time, where is the time needed for multiplying two matices. If this is where or deprending whether usual or fast matrix multiplication is used. This is to be compared to the usual Horner method, which gives or respectively.
This method works as follows: For a polynomial
let k be the least integer not smaller than The powers are computed with matrix multiplications, and are then computed by repeated multiplication by Now,
- ,
where for i ≥ n. This requires just more non-scalar multiplications.
The direct application of this method uses non-scalar multiplications, but combining it with Evaluation with preprocessing, Paterson and Stockmeyer show you can reduce this to .
Methods based on matrix polynomial multiplications and additions have been proposed allowing to save nonscalar matrix multiplications with respect to the Paterson-Stockmeyer method.[13][clarification needed]
See also
[edit]- Estrin's scheme to facilitate parallelization on modern computer architectures
- Arithmetic circuit complexity theory studies the computational complexity of evaluating different polynomials.
References
[edit]- ^ Carnicer, J.; Gasca, M. (1990). "Evaluation of Multivariate Polynomials and Their Derivatives". Mathematics of Computation. 54 (189): 231–243. doi:10.2307/2008692. JSTOR 2008692.
- ^ Motzkin, T. S. (1955). "Evaluation of polynomials and evaluation of rational functions". Bulletin of the American Mathematical Society. 61 (163): 10.
- ^ Rabin, Michael O.; Winograd, Shmuel (July 1972). "Fast evaluation of polynomials by rational preparation". Communications on Pure and Applied Mathematics. 25 (4): 433–458. doi:10.1002/cpa.3160250405.
- ^ Von Zur Gathen, Joachim; Jürgen, Gerhard (2013). Modern computer algebra. Cambridge University Press. Chapter 10. ISBN 9781139856065.
- ^ Knuth, Donald (2005). Art of Computer Programming. Vol. 2: Seminumerical Algorithms. Addison-Wesley. ISBN 9780201853926.
- ^ Kedlaya, Kiran S.; Umans, Christopher (2011). "Fast Polynomial Factorization and Modular Composition". SIAM Journal on Computing. 40 (6): 1767–1802. doi:10.1137/08073408x. hdl:1721.1/71792. S2CID 412751.
- ^ Larsen, K. G. (2012). "Higher Cell Probe Lower Bounds for Evaluating Polynomials". 2012 IEEE 53rd Annual Symposium on Foundations of Computer Science. Vol. 53. IEEE. pp. 293–301. doi:10.1109/FOCS.2012.21. ISBN 978-0-7695-4874-6. S2CID 7906483.
- ^ Downey, Peter; Leong, Benton; Sethi, Ravi (1981). "Computing Sequences with Addition Chains". SIAM Journal on Computing. 10 (3): 638–646. doi:10.1137/0210047. Retrieved 27 January 2024.
- ^ Strassen, Volker (1974). "Polynomials with Rational Coefficients Which are Hard to Compute". SIAM Journal on Computing. 3 (2): 128–149. doi:10.1137/0203010.
- ^ Schnorr, C. P. (1979), "On the additive complexity of polynomials and some new lower bounds", Theoretical Computer Science, Lecture Notes in Computer Science, vol. 67, Springer, pp. 286–297, doi:10.1007/3-540-09118-1_30, ISBN 978-3-540-09118-9
- ^ Chen, Xi, Neeraj Kayal, and Avi Wigderson. Partial derivatives in arithmetic complexity and beyond. Now Publishers Inc, 2011.
- ^ Paterson, Michael S.; Stockmeyer, Larry J. (1973). "On the Number of Nonscalar Multiplications Necessary to Evaluate Polynomials". SIAM Journal on Computing. 2 (1): 60–66. doi:10.1137/0202007.
- ^ Fasi, Massimiliano (1 August 2019). "Optimality of the Paterson–Stockmeyer method for evaluating matrix polynomials and rational matrix functions" (PDF). Linear Algebra and Its Applications. 574: 185. doi:10.1016/j.laa.2019.04.001. ISSN 0024-3795.
Polynomial evaluation
View on GrokipediaFundamentals
Definition and Notation
Polynomial evaluation refers to the process of computing the value of a polynomial function at a specific point or points within its domain. A univariate polynomial of degree over a field or ring (such as the real numbers ) is formally defined as , where the coefficients for , and .[5] The evaluation of this polynomial at a point is given by , obtained by direct substitution of for the variable and applying the arithmetic operations in the standard order.[5] Standard notation for univariate polynomials uses a single indeterminate , with terms ordered by descending powers (standard form) for clarity. For multivariate polynomials in variables , the expression generalizes to , where the sum is over all multi-indices with non-negative integers, , and only finitely many coefficients .[6] Evaluation in the multivariate case proceeds similarly by substituting specific values for each variable and computing the resulting sum. The degree of a polynomial is the highest power (or total degree in the multivariate case, ) among its non-zero terms, with the leading coefficient being the coefficient of that highest-degree term and the constant term the coefficient of the degree-zero monomial. Consider the univariate polynomial . To evaluate at , substitute into each term: , , and the constant term is . Summing these gives .[5] The zero polynomial, defined as the expression with all coefficients zero (i.e., ), evaluates to 0 at every point , and its degree is conventionally taken as or undefined to distinguish it from non-zero constants.[7]Historical Development
The systematic study of polynomials and their evaluation began in 16th-century Europe with François Viète, who introduced symbolic notation for algebraic expressions, enabling the treatment of polynomials as manipulable entities rather than rhetorical problems. Viète's innovations in works like In artem analyticam isagoge (1591) marked a shift toward formal polynomial algebra, laying groundwork for later evaluation techniques by emphasizing coefficients and powers in a structured manner. Precursors to synthetic division, a key tool for root-finding and evaluation, emerged in this period, with early forms of efficient linear division appearing in algebraic texts that built on Viète's framework.[8] A major milestone came in the early 19th century with William George Horner's 1819 publication of a method for solving numerical equations through continuous approximation, which optimized polynomial evaluation via nested multiplication and reduced computational steps compared to direct expansion.[9] Although named after Horner, the method is older and can be traced back to the work of Étienne Bézout in 1752 and even earlier. This approach, now known as Horner's method, minimized arithmetic operations and error propagation, becoming a standard for single-point evaluation. Later in the century, parallel computing considerations led to Gerald Estrin's 1960 scheme, which structured polynomial evaluation in a binary tree fashion to enable concurrent operations across processors.[10] In the mid-20th century, attention turned to minimizing nonscalar multiplications through preprocessing. Theodore S. Motzkin, in his 1955 analysis, established lower bounds on the number of multiplications needed for polynomial evaluation and proposed preprocessing strategies to achieve near-optimal operation counts by restructuring the polynomial form. Building on this, Michael S. Paterson and Larry J. Stockmeyer in 1973 developed an algorithm requiring only O(√n) nonscalar multiplications for degree-n polynomials, using a baby-step giant-step technique that preprocesses subpolynomials for matrix and general evaluations.[11] These advances extended to matrix polynomials, influencing numerical linear algebra. Post-1965, the Cooley-Tukey fast Fourier transform algorithm facilitated efficient multipoint evaluation by leveraging discrete transforms, integrating spectral methods into polynomial computation without altering core evaluation paradigms. Such developments have sustained interest in polynomial evaluation, particularly in cryptography where rapid modular computations underpin secure protocols.Applications in Computing and Mathematics
In numerical analysis, polynomial evaluation plays a central role in root-finding algorithms such as the Newton-Raphson method, which iteratively approximates roots of polynomial equations by leveraging the function's value and its derivative.[12] This method is particularly effective for solving high-degree polynomials where direct factorization is computationally infeasible, enabling precise approximations in scientific computing. Additionally, polynomial evaluation underpins Taylor series approximations, where complex functions are represented by finite-degree polynomials to estimate values near a point, facilitating error analysis and function simplification in optimization problems.[13] In computer science, polynomial evaluation is integral to hash functions, where strings are treated as coefficients of a polynomial over a finite field to compute collision-resistant hashes efficiently, as seen in rolling hash techniques for string matching.[14] It also supports pseudorandom number generation through linear feedback shift registers defined by primitive polynomials, producing sequences with maximal periods for simulations and cryptography.[15] Furthermore, in computer graphics, polynomial interpolation evaluates curves passing through control points to render smooth shapes, such as Bézier surfaces, enhancing visual realism in rendering pipelines.[16] Polynomial evaluation over finite fields is foundational in cryptography and coding theory, particularly for Reed-Solomon codes, where codewords are generated by evaluating message polynomials at distinct field elements to achieve error correction in data transmission.[17] These codes, used in storage systems like CDs and satellite communications, detect and correct up to a specified number of symbol errors through syndrome computations involving polynomial evaluations.[18] In machine learning, polynomial kernels in support vector machines (SVMs) evaluate feature mappings implicitly via dot products to handle nonlinear separability, enabling classification of complex datasets without explicit high-dimensional transformations.[19] Emerging trends as of 2025 include polynomial activations in neural networks, where learnable polynomial functions replace traditional nonlinearities to improve interpretability and approximation accuracy in deep architectures.[20] In big data applications, polynomial regression in distributed systems, such as wireless sensor networks, compresses multivariate data by fitting local polynomials across nodes, reducing transmission overhead while preserving analytical fidelity.[21]Basic Evaluation Techniques
Naive Direct Evaluation
The naive direct evaluation method computes the value of a polynomial by independently calculating each power through successive multiplications of by itself, scaling the result by the coefficient , and then summing all the terms. This approach requires multiplications in total—accounting for the repeated multiplications to form each power from to and the scalings by coefficients for terms from degree 1 to —along with additions to accumulate the sum.[22] For example, consider evaluating at . First, compute the powers: (no multiplication beyond the value itself), (1 multiplication), (2 multiplications). Then scale by coefficients: (1 multiplication), (1 multiplication), (1 multiplication), and (no multiplication). Finally, sum the terms: , , (3 additions). The total is 101, achieved with 6 multiplications and 3 additions, matching multiplications for degree . The primary drawback of this method is its high computational cost, stemming from redundant multiplications in computing the powers—such as repeatedly using the base without reusing intermediate results—which leads to quadratic scaling in the degree . This inefficiency contrasts with more optimized techniques like Horner's method.Horner's Method
Horner's method, also known as Horner's rule or synthetic division, is an efficient algorithm for evaluating a univariate polynomial of degree at a given point .[9] Developed by William George Horner in 1819, it rewrites the polynomial in a nested form to minimize arithmetic operations.[9] This method transforms into the equivalent expression , which allows evaluation through successive multiplications and additions starting from the highest-degree coefficient.[23] The algorithm proceeds iteratively as follows: initialize , then compute for , with the final result .[23] This nested computation ensures that the evaluation requires exactly multiplications and additions, achieving optimal linear time complexity for a single evaluation point, in contrast to the higher cost of direct expansion.[2] Here is pseudocode for Horner's method in a simple iterative form:function horner(coefficients a[0..n], value x)
b = a[n] // Start with highest coefficient
for i = n-1 downto 0 do
b = a[i] + x * b
end for
return b // Returns P(x)
function horner(coefficients a[0..n], value x)
b = a[n] // Start with highest coefficient
for i = n-1 downto 0 do
b = a[i] + x * b
end for
return b // Returns P(x)
Estrin's Scheme
Estrin's scheme, introduced by Gerald Estrin in 1960, is a divide-and-conquer algorithm for evaluating univariate polynomials that facilitates parallel computation by organizing operations into a binary tree structure. The method recursively splits the polynomial into higher- and lower-degree subpolynomials based on powers-of-two blocks of coefficients, enabling independent evaluation of subexpressions that can be performed concurrently. To evaluate a polynomial of degree , the scheme first determines , the largest power of two less than or equal to . It then partitions into a high-degree part and a low-degree part , such that .[24] This splitting is applied recursively to and , forming a balanced binary tree where each non-leaf node represents a multiplication by a power of followed by an addition. Precomputed powers of (via repeated squaring, such as ) are used to connect levels, minimizing redundant multiplications. The tree structure allows for parallelism: at each level, the evaluations of sibling subtrees (corresponding to and ) can proceed independently, making the scheme suitable for hardware with multiple processing units or vectorized execution. The computational depth is , as the recursion halves the problem size at each step, while the total number of arithmetic operations remains , consisting of roughly multiplications and additions overall.[24] This contrasts with Horner's method, which has the same serial operation count but requires sequential steps, limiting its parallelism; Estrin's scheme achieves equivalent serial cost but reduces latency in parallel environments by distributing work across leaves to levels.[25] For a concrete example, consider a degree-4 polynomial . Here, , so and , yielding . Recursing on with : inner low , inner high , so . Thus, , with and precomputed. The innermost pairs and are computed in parallel at level 1 (each one multiplication and one addition). At level 2, the second result is multiplied by and added to the first. At level 3, is added to the result. This tree has three levels, with parallel multiplications and additions at early steps, demonstrating reduced latency compared to Horner's sequential nesting .[26]Advanced General Methods
Preprocessing for Reduced Operations
Preprocessing techniques for polynomial evaluation involve transforming the polynomial's coefficients in advance to enable a rewritten form that shares computational subexpressions during evaluation, thereby reducing the number of multiplications required at runtime. These methods, often referred to as preconditioning or initial conditioning, precompute constants based on the original coefficients, allowing the evaluation phase to exploit symmetries or factorizations that minimize multiplications while potentially increasing the number of additions. A seminal approach is due to Motzkin, who demonstrated that such preprocessing can achieve near-optimal operation counts for general polynomials.[27] In contrast to Horner's method, which requires n multiplications for a degree-n polynomial, preprocessing can reduce this to approximately n/2 multiplications. Motzkin established a general lower bound of at least multiplications/divisions in models where operations solely on coefficients are not counted toward the evaluation complexity. This bound holds for schemes with preprocessing over fields of characteristic zero, and algorithms exist that achieve it or come within one multiplication for most degrees. For instance, for a degree-4 polynomial, 3 multiplications suffice, compared to Horner's 4.[28][27] A representative example is the evaluation of . Through preprocessing, rewrite as , where , with precomputed constants , , , and . To evaluate:- Compute (1 multiplication).
- Compute (2 additions, assuming scalar multiplication is preprocessed or counted separately if needed).
- Compute (1 multiplication).
- Compute (1 multiplication).
- Add (2 additions).
