Interpolation and Curve Fitting

  1. For the given data points;

    \begin{displaymath}
\begin{array}{rr}
x & y \\ \hline
1 & 1.06 \\
2 & 1.12 \\
3 & 1.34 \\
5 & 1.78 \\
\end{array}\end{displaymath}

  2. We have given the following MATLAB code to evaluate the Lagrange polynomial $P(x)=\sum_{k=0}^N y_k \frac{\prod_{j\neq k}(x-x_j)}{\prod_{j\neq k}(x_k-x_j)}$ based on $N+1$ points $(x_k,y_k)$ for $k=0,1,\ldots,N$.
    function [C,L]=lagran(X,Y)
    %Input  - X is a vector that contains a list of abscissas
    %       - Y is a vector that contains a list of ordinates
    %Output - C is a matrix that contains the coefficents of 
    %         the Lagrange interpolatory polynomial
    %       - L is a matrix that contains the Lagrange coefficient polynomials
    
    w=length(X);
    n=w-1;
    L=zeros(w,w);
    %Form the Lagrange coefficient polynomials
    for k=1:n+1
       V=1;
       for j=1:n+1
          if k~=j
             V=conv(V,poly(X(j)))/(X(k)-X(j));
          end
       end
       L(k,:)=V;
    end
    %Determine the coefficients of the Lagrange interpolator polynomial
    C=Y*L;
    
    where Study this MATLAB code and then use the data set in the previous item to
  3. We have given the following MATLAB code to construct and evaluate divided-difference table for the (Newton) polynomial of $degree\leq N$ that passes through $(x_k,y_k)$ for $k=0,1,\ldots,N$:

    \begin{displaymath}
P(x)=d_{0,0}+d_{1,1}(x-x_0)+d_{2,2}(x-x_0)(x-x_1)+\ldots+d_{N,N}(x-x_0)(x-x_1)\ldots(x-x_{N-1})
\end{displaymath}

    where

    \begin{displaymath}
d_{k,0}=y_k~and~d_{k,j}=\frac{d_{k,j-1}-d_{k-1,j-1}}{x_k-x_{k-j}}
\end{displaymath}

    function [C,D]=newpoly(X,Y)
    %Input   - X is a vector that contains a list of abscissas
    %        - Y is a vector that contains a list of ordinates
    %Output  - C is a vector that contains the coefficients
    %          of the Newton interpolatory polynomial
    %        - D is the divided difference table
    
    n=length(X);
    D=zeros(n,n);
    D(:,1)=Y';
    
    %Use the formula above to form the divided difference table
    for j=2:n
       for k=j:n
          D(k,j)=(D(k,j-1)-D(k-1,j-1))/(X(k)-X(k-j+1));
       end
    end
    
    %Determine the coefficients of the Newton interpolatory polynomial
    C=D(n,n);
    for k=(n-1):-1:1
       C=conv(C,poly(X(k)));
       m=length(C);
       C(m)=C(m)+D(k,k);
    end
    
    Study this MATLAB code and then use the data set in the first item to
2004-11-26