\documentclass[12pt,letterpaper]{article}   
\usepackage{amsmath,amssymb,verbatim}
\newcommand{\dspace}{\vskip 24pt}
\newcommand{\sspace}{\vskip 12pt}
\newcommand{\hfspace}{\vskip 6pt}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0.0in}
\setlength{\textheight}{9in}
\setlength{\topmargin}{-0.5in}

\begin{document}
  
\pagestyle{empty}
\raggedright

\vspace*{-36pt}
\begin{center}
  {\Huge MTH 452/552 -- Homework 1}
  \dspace
\end{center}


\begin{enumerate}
  
\item (40 points) [Method of Undetermined Coefficients]
  \begin{enumerate}
  \item \label{D3} 
    Use the method of undetermined coefficients to set up and solve
    the $3\times 3$ Vandermonde system that would determine a centered
    finite difference approximation to $u'(\bar{x})$ of the highest
    order possible based on 3 equally spaced points, i.e., 
    \begin{equation*}
      D_{-1:1} u(\bar{x}) := c_{-1} u(\bar{x}-h) + c_0u(\bar{x}) + 
      c_1u(\bar{x}+h) \approx u'(\bar{x}) . 
    \end{equation*}
    (MATLAB notation for the set of numbers from $a$ to $b$ by 1 is
    $a:b$.)   Find the coefficients $c_{-1}$, $c_0$, and $c_1$. 
    
    Note: the resulting formula is called the {\em centered 3-point
    approximation for the first derivative} (eventhough the center
    point does not appear explicitly...hint).  

  \item Check your answer using the MATLAB code {\tt fdstencil.m}
    available from the author's website. 

  \item \label{D5} Repeat (b) for 5 points, i.e., find
    \begin{equation*}
      D_{-2:2} u(\bar{x}) := c_{-2} u(\bar{x}-2h) + c_{-1}
      u(\bar{x}-h) + c_0u(\bar{x}) + c_1u(\bar{x}+h) +
      c_2u(\bar{x}+2h) \approx u'(\bar{x}). 
    \end{equation*}
    (Note: although the algebra is tedious, one can find an explicit
    formula for these coefficients for any arbitrary number of points
    in a centered stencil.)

  \item Download and run the m-file {\tt fderror.m}.  Describe what it
    is doing. 

    On your own, try changing $h$ to $10^{-1}$, $10^{-2}$, $10^{-3}$,
    \ldots, $10^{-10}$.  You should observe the predicted accuracy for
    larger values of $h$.  For smaller values, numerical cancellation
    in computing the linear combination of $u$ values impacts the
    accuracy observed. In fact, the higher order methods are more
    sensitive to the size of $h$.   

  \item Test the finite difference formulas from \ref{D3} and \ref{D5}
    to approximate $u'(1)$ for $u(x) = \sin(x)$ with values of $h$
    from $2^{-1}$, $2^{-2}$, $2^{-3}$, \ldots, $2^{-8}$.  Make a table
    of the approximate error vs.~$h$ for several values of $h$, as
    well as ratios of errors.  Compare the observed order of accuracy
    against the predicted error from the leading term of the
    expression printed by {\tt fdstencil}.  Also produce a log-log
    plot of the absolute value of the error vs.~$h$ and verify (by
    eye) that the curves have the expected slopes. 
    
    You may either modify the m-file {\tt fderror.m} or make your own
    script.  
    
  \end{enumerate}
  
\item (10 points) ({\bf 552:}) [Higher Order Centered Differences]
  Note that the 5-point formula in \ref{D5} can be written as a linear
  combination of 3-point formulas with different step sizes, i.e., 
  \begin{equation*}
    D_{-2:2} = c_1 D_{-1:1} + c_2 D_{-2:2:2}
  \end{equation*}
  where $D_{-2:2:2}$ is the 3-point formula from \ref{D3} with
  stepsize $2h$.  (MATLAB notation for the set of numbers from $a$ to
  $b$ by $k$ is $a:k:b$.)   Find the coefficients $c_1$ and
  $c_2$. (Note: although the algebra here is even more tedious, one
  can find an explicit formula for these coefficients for any
  arbitrary (even) order of accuracy.) 
  
\end{enumerate}

\end{document}
