Polynomial Evaluation Using Horner Method
1 Canonical Polynomial
Given a canonical polynomial f(x)=åi=0n aixi, the Horner method
is an efficient way to calculate a polynomial value with respect to the given x. For
simplicity, we take a cubic polynomial as an example. If we write a cubic polynomial as
|
f(x)= |
3 å
i=0
|
aixi=x[x(a3x+a2)+a1]+a0 |
|
the Horner method to compute a polynomial value may be stated as follows:
- Let fx=a3.
- Compute fx ×x+a2 and assign the value to fx.
- Compute fx ×x+a1 and assign the value to fx.
- Compute fx ×x+a0 and output the result fx.
As indicated above, only three multiplications are used. For a polynomial of degree n,
the well-known Horner method is
fx = a(n)
do i=n, 1, -1
fx = fx * x + a(i-1)
enddo
There are, in toltal, n multiplications and n additions.
2 Legendre Polynomial
Given a Legendre polynomial f(x)=åi=0n aili(x), we have
a recursive formula to calculate li(x):
|
li(x)= |
(2i-1)xli-1(x)-(i-1)li-2(x) i
|
=b+a(b-li-2(x)) |
|
where, a = (i-1)/i, b = xli-1(x). Therefore, we have the following
Horner type recursive method to calculate the polynomial value:
fx = a(0) + a(1)*x
lg_2 = 1.0
lg_1 = x
do i=2, n
alpha = (i-1)/i
beta = x*lg_1
lg_i = beta + alpha*(beta-lg_2)
fx += a(i)*lg_i
lg_2 = lg_1
lg_1 = lg_i
enddo
There are in toltal 3×n multiplications, n division and 4×n
additions.
3 Tchebyshev Polynomial
Given a Tchebyshev polynomial f(x)=åi=0n aiti(x), we
have a recursive formula to calculate ti(x):
|
t0(x)=1, t1(x)=x, ti(x)=2xti-1(x)-ti-2(x) |
|
Therefore, we have the following Horner type recursive method to calculate the
polynomial value:
fx = a(0) + a(1)*x
t_2 = 1.0
t_1 = x
do i=2, n
t_i = (2*x*t_1 - t_2)
fx += a(i)*t_i
t_2 = t_1
t_1 = t_i
enddo
There are in toltal 3×n multiplications and 2×n additions.
RETURN