80 likes | 221 Views
Introduction to Numerical Analysis I. Evaluating a Polynomial. MATH/CMPSC 455. Evaluating a Polynomial. Question: What is the BEST way to evaluate a polynomial? . What does BEST mean?. To me, BEST means: Give right answer Number of operations is minimized (Addition, Multiplication)
E N D
Introduction to Numerical Analysis I Evaluating a Polynomial MATH/CMPSC 455
Evaluating a Polynomial Question: What is the BEST way to evaluate a polynomial? What does BEST mean? • To me, BEST means: • Give right answer • Number of operations is minimized (Addition, Multiplication) • Easy to implement
Example: Evaluate at Method 1: We need 14 operations: 10 multiplications and 4 additions
Can we do better? Method 2: We need 11 operations, 7 multiplications and 4 additions
Can we do even better (best)? Method 3: We need 8 operations, 4 multiplications and 4 additions!!
Nested Multiplication Nested Multiplication (Horner’s method): We need 2n operations, n multiplications and n additions!!
Example: HW1 Write a Matlab function that uses nested multiplication to evaluate a polynomial. See notes for a hint.