Solution Found!
There is a more efficient algorithm (in terms of the
Chapter 3, Problem 14E(choose chapter or problem)
Problem 14E
There is a more efficient algorithm (in terms of the number of multiplications and additions used) for evaluating polynomials than the conventional algorithm described in the previous exercise. It is called Horner's method. This pseudocode shows how to use this method to find the value of anxn + an-1xn-1+ … +a1x + a0 at x = c
procedure Honer(c, a0. a1 ,…, an: real numbers)
y := an
for i := 1 to n
y := y * c + an−1
return y {y = ancn + an−1cn−1 + … + a1c + a0}
a) Evaluate 3x2 + x + 1 at x = 2 by working through each step of the algorithm showing the values assigned at each assignment step.
b) Exactly how many multiplications and additions are used by this algorithm to evaluate a polynomial of degree n at x = c? (Do not count additions used to increment the loop variable.)
Questions & Answers
QUESTION:
Problem 14E
There is a more efficient algorithm (in terms of the number of multiplications and additions used) for evaluating polynomials than the conventional algorithm described in the previous exercise. It is called Horner's method. This pseudocode shows how to use this method to find the value of anxn + an-1xn-1+ … +a1x + a0 at x = c
procedure Honer(c, a0. a1 ,…, an: real numbers)
y := an
for i := 1 to n
y := y * c + an−1
return y {y = ancn + an−1cn−1 + … + a1c + a0}
a) Evaluate 3x2 + x + 1 at x = 2 by working through each step of the algorithm showing the values assigned at each assignment step.
b) Exactly how many multiplications and additions are used by this algorithm to evaluate a polynomial of degree n at x = c? (Do not count additions used to increment the loop variable.)
ANSWER:
Solution:
Step 1
In this problem we need to find the value of polynomial at using the given algorithm.
Given algorithm :
procedure Honer(real numbers)
y :=
for i := 1 to n
y :=
return y {}
where the final value of y is the value of the polynomial at x = c.