Question: modify the nest.m program by adding a counter to the for-loop that keeps track of the number of operations (additions/ subtractions /multiplications) that have been
modify the nest.m program by adding a counter to the for-loop that keeps track of the number of operations (additions/ subtractions /multiplications) that have been executed . have the updated function return this counter as a second output.
%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
Get step-by-step solutions from verified subject matter experts
