% This is a function which calculates and returns the % Newton polynomial of degree <= n which passes through % the points (x(i),y(i)), for i = 1, 2, .... n + 1, where % n+1 is the number of components in the input vectors % x and y. % % Usage: [out] = nestmult(a,nodes,x); % % Input: a = vector containing a list of the coefficients % for the interpolating polynomial in Newton form. % nodes = vector containing a list of abscissas % x = vector containing the set of points where the % polynomial is to be evaluated. % % NOTE: The input vectors are REQUIRED TO BE COLUMN VECTORS!!! % % Output: out = vector containing the values of the Newton % interpolating polynomial function [out] = nestmult(a,nodes,x) % Local Variables % j = loop index %----- Here we check to see that a, nodes and x are column vectors ----% [rx,cx] = size(x); [ra,ca] = size(a); [r,c] = size(nodes); if (cx~=1) | (ca~=1) | (c~=1) fprintf(1,'Your input vectors are WRONG!!!--nestmult.m\n'); end; % end-if %---------------------------------------------------------------% % Initializations out = ones(rx,1)*a(r); % Initializes the output vector. % This is our S_j from class. % Loop to evaluate the polynomial for j=(r-1):-1:1 out = out.*(x-nodes(j)) + a(j); end; % end-j-loop