// --------------------------------------------------------- // Fonction base(j) de Lagrange. (0 =< j =< n) // --------------------------------------------------------- function p=lagrange(pts,j,X); x=poly(0,X); n=length(pts); j=j+1; xnj=pts((1:n)~=j); p=prod((x-xnj)./(pts(j)-xnj)); endfunction // // --------------------------------------------------------- // Fonction interpolation de Lagrange. // --------------------------------------------------------- function p=interp(ft,pts,X); x=poly(0,X); n=length(pts); for i=1:n ploc(i) = ft(pts(i))*lagrange(pts,i-1,'t'); end p = sum(ploc(1:n)); endfunction // // --------------------------------------------------------- // Fonction calcul des differences divisees. // --------------------------------------------------------- function D=diffdiv(pts,val); L = length(pts) // D(1:L,1) = val(1:L)'; // for j=2:L for i = 1:(L-j+1) D(i,j) = (D(i+1,j-1) - D(i,j-1))/(pts(i+j-1)-pts(i)); end end // endfunction // // --------------------------------------------------------- // Fonction test d'application des methodes d'interpolation. // phenomene de Runge // --------------------------------------------------------- function y=ftest(x); y = ( ones(length(x)) ./ (1 + 16*x.^2) ); endfunction //