function yint = lagrangeINT( x, y, xint) % % function yint = lagrangeINT(x, y, xint) % % Use Lagrange interpolation to interpolate a set of points % Compare with discussion on pages 104-107 of Burden and Faires % % Input parameters: % x vector of x coordinates of given points. % y vector of y coordinates of given points. % xint the x coordinate at which y is to be interpolated % % % Output parameters: % yint the interpolated value at xint. % % Kartik Sivaramakrishnan % Department of Mathematics % North Carolina State University % September 7, 2007 % n = length(x); for i=1:n, L(i) = 1; for j=1:n, if j~=i, L(i) = L(i)*(xint-x(j))/(x(i)-x(j)); end end end L = L(:); yint = y'*L;