The function
a0 + a1 x x + a2 x x2 + a3 x x3 + ... + an x xn
is a polynomial in x whose coefficients are the real numbers a0, a1, ..., an, where an is not zero. The number n is called the polynomial’s degree.You can evaluate a polynomial at a given real value of x—call it x0—by computing the following sequence of numbers:
bn = an
bn-1 = an-1 + bn x x0
bn-2 = an-2 + bn-1 x x0
. . .
b0 = a0 + b1 x x0
The value of the polynomial is then b0. This way of evaluating a polynomial is called Horner’s method and requires n additions and n multiplications. Any other way of evaluating a polynomial will require at least this many additions and multiplications.
Write a program that reads a polynomial’s coefficients into an array and then evaluates it for various values of x, as entered by the user.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here