\documentclass[12pt]{article}    % Specifies the document style.

\usepackage{amsmath}              %   AMS equation environments
\usepackage{amssymb}              %   AMS symbol fonts (e.g., \boldsymbol{}
\usepackage{amsfonts}             %   AMS math fonts
\usepackage{verbatim}             %   define comments

%==========================

\vfuzz2pt 
\tolerance = 1000

% ====================New declarations===========================
\newcommand{\ds}{\displaystyle}
\newcommand{\e}{\mathrm{e}}


%---------------------------------------------------------------------
\setlength{\topmargin}{-0.5in} 
\setlength{\textheight}{9.0in}
\setlength{\oddsidemargin}{-0.25in} 
\setlength{\textwidth}{7in}
% ----------------------------------------------------------------------
\newcommand{\dspace}{\vskip 24pt}
\newcommand{\sspace}{\vskip 12pt}
\newcommand{\hfspace}{\vskip 6pt}


\begin{document}
\baselineskip=18pt

\begin{center}
  {\Huge MTH 453/553 -- Homework 4}
\end{center}
\dspace


\begin{enumerate}
\item  Consider the initial value problem
\begin{align*}
u_t-u_x &= 0, \\
u(x,0) &= \sin(\omega x),
\end{align*}
where $\omega$ is a parameter. The exact solution to this problem is 
\[ u(x,t) = \sin(\omega (t+x)). \]
Let us solve this problem on the interval $[-\pi, \pi]$ 
with periodic boundary conditions, i.e.,
\[ u(t,-\pi) = u(t,\pi), \ t>0. \]

We perform a discretization of the spatial interval $[-\pi, \pi]$ with
spatial step size $h$ and we use a 
temporal step size $k$ on the time interval [0,1]. Let $m+1 =
\frac{2\pi}{h}$. We want to calculate approximate solution values $u_j^n$
for $ j = 1,\ldots, m+1$. The periodic boundary conditions give 
\[ u_{0}^n = u_{m+1}^n, \ \forall n\]
It is helpful to imagine the spatial mesh points sitting on a ring, rather
than on a straight line, with $x_{m+1}$ being identified with $x_0$. Thus,
when $j = m$, then $u_{j+1} = u_0$ and for $j=0, u_{j-1} = u_m$.  (This gets
further complicated in MATLAB as zero index is not allowed, so we add one
to each index.)

\begin{enumerate}
\item Download the code {\texttt{leapfrog.m}} from the course webpage. This code
  implements the Leapfrog (midpoint) method (CC), given in (10.13) in the
  text, to obtain a numerical solution to the given problem.
\item Modify this code to create a new file that implements the forward in
  time-backward in space (FB) finite difference scheme given in (10.23)
  to solve the given problem. 
\item Create a new file that implements the forward in
  time-centered in space (FC) finite difference scheme given in (10.5)
  to solve the given problem. 
\item Calculate the maximum errors at $t = 1$ for all three schemes using
  the values of $\omega$, $m$ and $\nu$ ($=k/h$) given in the table below and fill in the
  missing entries in the table
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
$\omega$& $m+1$& $\nu$ & Error in FB & Error in FC & Error in CC\\
\hline 
2 & 20 & 0.5 & 0.2473& 0.3304& 0.0788 \\
2 & 200& 0.5 & ? & ? & ? \\
2 & 2000 & 0.5 & ? & ? & ? \\ 
\hline
\end{tabular}
\end{center}
What order of accuracy does each method seem to exhibit?

%consider 200: give omega^2 & omega^3 behavior.
\item Fix $m+1=20$.  What is the effect on the error of each method when
  $\omega$ is increased or decreased?

\item Fix $m+1=20$.  What is the effect on the error of each method when
  $\nu$ is increased or decreased?  In particular, try $\nu=1$ and $\nu>1$.

\end{enumerate}


\item Download the code {\texttt{leapfrogpulse.m}} from the course webpage. This code
  implements the Leapfrog method with a Gaussian pulse for the initial
  condition.  Snapshots of the solution at various times are shown, and
  the norm of the solution is displayed to the prompt.
\begin{enumerate}
\item Run the code {\texttt{leapfrogpulse.m}} with $m+1=75$ and try $\nu$
  values of 1, 0.8, and 1.01.  Describe the resulting qualitative behavior
  of solutions and explain why it occurs.
\item Change the boundary condition from periodic to $u(\pi,t)=0$.  Impose
  {\em artificial absorbing boundary conditions} at the outflow boundary
  $x=-\pi$:  
\[ U^{n+1}_1 =U^n_1 + \nu \left(U^n_2 - U^{n}_1\right)\]
Run the code with $m+1=75$ and try $\nu$
  values of 1, 0.8, and 1.01.  (Try also the case $\nu=0.25$, and look closely for a
  ``reflection'' that travels backwards!) Discuss the accuracy of the
  absorbing boundary condition in terms of the remaining ``energy''.  
\end{enumerate}


\item  Consider the advection equation
\[ u_t + au_x = 0,\]
and recall that the forward in time-centered in space (FC)
scheme is consistent but unconditionally unstable.
The {\it Lax-Friedrichs} scheme is a variation of the FC scheme and is given as 
\[ U^{n+1}_j =\ds\frac{1}{2}\left(U^n_{j-1}+ U^n_{j+1}\right) -\ds\frac{\nu}{2}
\left(U^n_{j+1} - U^{n}_{j-1}\right),\]
where $\nu = \frac{ak}{h}$ is the {\it Courant number}.
\begin{enumerate}
\item ({\bf 553:}) Show that the Lax-Friedrichs scheme is consistent and
  find the order of accuracy.


\item Use von Neumann analysis to show that the Lax-Friedrichs scheme is
  stable, provided that the CFL condition, $|\nu| \leq 1$, holds.

\end{enumerate}

\end{enumerate}
\end{document}



