Question
Show how to evaluate the polynomial P(x) = 7x^25 -x^20 +4x^15 -x^10 +3x^5 using as few arithmetic operations as possible. How many multiplications and how
Show how to evaluate the polynomial P(x) = 7x^25 -x^20 +4x^15 -x^10 +3x^5 using as few arithmetic operations as possible. How many multiplications and how many additions are needed in your method?
Where indicated below, write a script that calls the function nest to help evaluate P(2), using the results to minimize the numbr of computations.
Matlab code:
format long e
%define any necessary variables before calling nest() below
%let d be the appropriate degree used in nest()
%let c be the vector of coefficients used in nest()
%let z be the value at which the polynomial in nest() is evaluated
%let ynest be the output of nest()
%let yfinal be the final value of P(-2) (not necessarily the output of nest())
%check by evaluating the poly. the "old fashioned way," i.e., using y = a_n*x^n + a_(n-1)*x^(n-1) +...+ a_1*x + a_0
%Let y be the value of this polynomial
%Program 0.1 Nested multiplication
%Evaluates polynomial from nested form using Horner's method
%Input: degree d of polynomial,
% array of d+1 coefficients (constant term first),
% x-coordinate x at which to evaluate, and
% array of d base points b, if needed
%Output: value y of polynomial at x
function y=nest(d,c,x,b)
if nargin<4, b=zeros(d,1); end
y=c(d+1);
for i=d:-1:1
y = y.*(x-b(i))+c(i);
end
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started