Help with Newton divided method
2 views (last 30 days)
Show older comments
Hey guys, I'm trying to use Matlab to estimate a population figure for my Numerical Analysis class. Here's the whole question: Apply the following world population figures to estimate the 1980 population, using: a) the straight line through the 1970 and 1990 estimates; b) the parabola through the 1960, 1970 and 1990 estimates; and c) the cubic curve through all four data points. Compare with the 1980 estimate of 4452584592. Here are the estimates (1960, 3039585530), (1970,3707475887), (1990, 5281653820), and (2000,6079603571). Now the polynomial equation is P(x)= f(x0)+f[x0,x1](x-x0)+f[x0,x1,x2](x-x0)(x-x1)...f[x0...xn](x-x0)(x-x1)...(x-xn) I've done the calculations manually and found the estimates but I can't get the code right to do the same in matlab. Here's the code from the book: %Input: x and y are vectors containing the x and y coordinates % of the n data points %Output: coefficients c of interpolating polynomial in nested form %Use with nest.m to evaluate interpolating polynomial function c=newtdd(x,y,n) for j=1:n v(j,1)=y(j); % Fill in y column of Newton triangle end for i=2:n % For column i, for j=1:n+1-i % fill in column from top to bottom v(j,i)=(v(j+1,i-1)-v(j,i-1))/(x(j+i-1)-x(j)); end end for i=1:n c(i)=v(1,i); % Read along top of triangle end % for output coefficients
x0=[1970,1990]; y0=[37007475887,5281653820]; c=newtdd(x0,y0,2); x=0:.01:5281653820; y=nest(1,c,x,x0);
0 Comments
Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!