next up previous
Next: About this document ...

Homework Set #7, Math 575A


Part I: This part is the analytical part.

  1. Which of the properties of a natural cubic spline does the following function posess and which properties does it not?

    \begin{displaymath}
f(x) = \left\{ \begin{array}{lr}
(x+1) + (x + 1)^3&   x\...
...]\\
4 + (x-1) + (x - 1)^3&   x\in(0,1]
\end{array}\right.
\end{displaymath}

  2. Let $f(x) = \sqrt{1+\cos{x}}$.
    1. Prove $f$ is a periodic function with periodicity of $2\pi$;
    2. Find the trigonometric polynomial that interpolates $f$ at $x_0 = 0, x_1=\pi$.
  3. Derive the following two formulas for approximating the third derivative. Which one is more accurate?
    1. $f'''(x) \approx \frac{1}{h^3}(f(x+3h)-3 f(x+2h)+3
f(x+h)-f(x))$;
    2. $f'''(x) \approx \frac{1}{2 h^3}(f(x+2h)-2 f(x+h)+2
f(x-h)-f(x-2h)).$
  4. Derive a numerical differentiation formula of order ${\mathcal
O}(h^4)$ by applying Richardson extrapolation to

    \begin{displaymath}
f'(x) = \frac{1}{2 h} [ f(x+h) - f(x-h)] - \frac{h^2}{6} f'''(x) -
\frac{h^4}{120} f^{(5)}(x) - \cdots
\end{displaymath}

Part II: This part is practical

  1. Write a code that uses

    \begin{displaymath}\frac{1}{12h}(-f(x+2h)+8f(x+h)-8f(x-h)+f(x-2h)) \end{displaymath}

    to approximate $f'(x)$, where $f(x) = \tan^{-1}{x}$ and $x=\sqrt{2}$. (Note $f'(\sqrt{2}) = \frac{1}{3}$.). Output $k,h,r,e$. Here $k$ is the iteration index, $h$ is the step size, $r$ is the approximate value of $f'(x)$ and $e$ is the error, i.e. $e=\vert\frac{1}{3}-r\vert$. From a nicely displayed table of the error, estimate the order of the finite difference approximation you just coded, by repeatedly changing the value of $h$.

  2. The following is a MATLAB code for the Richardson extrapolation algorithm on Page 510 of Kincaid&Chenney 1 for approximating the derivative of $f(x) = \ln{x}$ at $x=3$. First copy the code to a M-file and try it in MATLAB. Make a copy of the code and then modify the new version to approximate the derivative of $f(x) = \sin(x^2+\frac{1}{3}x)$ at $x=0$. From a nicely displayed table of the error, estimate the order of the finite difference approximation you just coded, by repeatedly changing the value of $h$.

    % hw7.m
    % Implemention of the Richardson extrapolation algorithm 
    % on Page 510 of Kincaid&Cheney.
    
     x = 3;  h = 1;  M = 6;
     D = zeros(M,M);                % Set D to be an M by M matrix with
                                    % all zero entries
     for n = 1 : M                  % In MATLAB, index has to start from 1
       hn = h/2^(n-1);              % Adapt the index in subsequent places
       D(n,1) = ( log(x+hn) - log(x-hn) ) / (2*hn); 
     end
     for k = 2 : M
       for n = k : M
         D(n,k) = D(n,k-1) + ( D(n,k-1) - D(n-1,k-1) ) / (4^(k-1) - 1 );
       end
     end
    
     format long;
     disp(D);
    




next up previous
Next: About this document ...
Juan Restrepo 2007-07-16