Evaluation Polynomials PROBLEM
Compute the value of a given polynomial A.N*X**N+...+A.1*X+A.0 of degree N at a given point V.
ALGORITHM A simple algorithm which avoids recomputation of the powers of X is known as Horner's rule. A degree N polynomial can be evaluated using only N-1 multiplications and N additions. This program assumes the array representation for polynomials.
IMPLEMENTATION
Unit: internal function
Global variables: vector A.0,A.1,...,A.N of coefficients from the set of real numbers Parameters: a positive integer N - the degree of the polynomial, real number V - a given point Returns: Evaluating the polynomial A. at the given point V
EXAMPLE The value of a given polynomial 5*X**3+4*X-10 of degree N=3 at a given point V=8 is 2582. See the following fragment of program:
CONNECTIONS
Polynomial addition
Sparse polynomial addition Evaluation of polynomial and its derivatives Division of polynomials
Literature Sedgewick R. Algorithms Addison-Wesley, Reading, Massachusetts, 1984
|
|
|
|
|
|
![]()