Question: Write a script m-file that calls the function nest() to evaluate P(2) , where P(x) =n 2x^25 + 7x^15 - x^10 + 4x^5 -1. You

Write a script m-file that calls the function nest() to evaluate P(2) , where P(x) =n 2x^25 + 7x^15 - x^10 + 4x^5 -1. You do not have to pass the 4th argument to the function (the base points) just the first 3 arguments. Run your script and give the output. the nest function is as follows:

%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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!