8.5. HORNER: Evaluating a Polynomial

The evaluation of polynomials is essential to implementations of trigonometric functions and other transcendental functions. In practice, simple power series expressions for any F(x) are replaced by Chebyshev polynomial expansions in order to attain the smoothest possible distribution of discrepancies between the approximation and the exact function across the whole range of x (see Markstein).

Consider the operations required to evaluate a third-order polynomial involving real numbers:

P(x) = 1.0 + 0.5 x + 0.25 x2 + 0.125 x3

that we might directly transcribe from algebra into pseudocode:

 sum = 1.0 power = x tmp = 0.5 * power sum = sum + tmp power = power * x tmp = 0.25 * power sum = sum + tmp power = power ...

Get Itanium® Architecture for Programmers: Understanding 64-Bit Processors and EPIC Principles now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.