Hands-on-Chebyshev Polynomials; Approximation of Functions with MATLAB I

  1. The Chebyshev series and Maclaurin series for $ e^x$ are given as the following;

    \begin{displaymath}
\begin{array}{l}
e^x=0.9946+0.9973x+0.5430x^2+0.1772x^3 \\
e^x=1+x+0.5x^2+0.1667x^3\\
\end{array}\end{displaymath}

    Solution:
    function week9litem1(ll,ul,s)
    format short;
    %format long;
    disp('     x        e^x    Chebyshev   Error   Maclaurin   Error')
    x =(ll:s:ul)';
    taylor=exp(x);
    max=(ul-ll)/s+1;
    for i=1:max
    chebyshev=(0.9946 + 0.9973*x(i) + 0.5430*x(i)^2 + 0.1772*x(i)^3);
    errorchebyshev(i)=taylor(i)-chebyshev;
    maclaurin=(1+x(i)+0.5*x(i)^2+0.1667*x(i)^3);
    errormaclaurin(i)=taylor(i)- maclaurin;
    D=[x(i),taylor(i),chebyshev,errorchebyshev(i),maclaurin,
                                                  errormaclaurin(i)];  
    disp(D); 
    end 
    plot(x,errorchebyshev,'o',x,errormaclaurin,'-')
    
    save with the name week9litem1.m. Then;
    >> week9litem1(-1,1,0.1)
    
    Figure 6.3: plot(x,errorchebyshev,'o',x,errormaclaurin,'-').
    \includegraphics[scale=0.43]{figures/week9litem1}
  2. Write a MATLAB program using Chebyshev polynomials to economize a Maclaurin series for $ e^x$ in the interval [0,1] with a precision of $ 0.0001$.

    \includegraphics[scale=1.3]{figures/4-7}

  3. Exercise: Modify the program so that it uses Chebyshev polynomials to economize a Maclaurin series for $ e^{2x}$ in the interval [0,1] with a precision of $ 0.008$.
Cem Ozdogan 2011-12-27