/***************************************************************************\
Efficient Evaluation of Polynomials
Author : Greg Young, Z-World.
The need to compute polynomials occurs commonly in numeric applications.
Rather than performing these long hand, the library function poly uses
Horner's Method to compute the value as efficiently as possible. In the
below example, the polynomial (as written explicitly in C) would be
fX*fX*fX*fX - fX*fX*fX + 2*fX + 1.0
\***************************************************************************/
float arC[] = { 1.0,2.0,0.0,-1.0,1.0 };
void
main ( void
)
{ float fX;
for (fX=-3.0;fX<=3.0;fX+=1.0)
printf ( "%f %f\n",fX,poly(fX,4,arC) );
}