% Typeset with pdflatex
\documentclass[12pt]{amsart}
\usepackage{graphicx}
\usepackage{listings}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[plain]{algorithm}
\textheight=9in
\textwidth=6.5in
\calclayout
\pagestyle{plain}
\thispagestyle{empty}
\parindent=0pt
\parskip=10pt plus3pt minus2pt
\newcommand\norm[1]{\lVert#1\rVert}
\newcommand\C{\mathbb C}
\newcommand\R{\mathbb R}
\newcommand\x{\times}
\renewcommand\P{\mathcal P}
\renewcommand\r{\sqrt{a/b}}
% set up code listings
\newcommand\1{\lstinline} % use \1!<code>! for inline typesetting of <code>
\lstnewenvironment{1!}{}{} % use \begin{1!}<code>\end{1!}  for displayed typesetting of <code>
\lstset{language=Python,basicstyle=\color{MidnightBlue}\ttfamily,showstringspaces=false,
 commentstyle=\color{Gray},columns=fullflexible}
\begin{document}
\hbox to\hsize{\rlap{MATH 8446, Spring '18}\hfil Homework 4 \hfil\llap{Arnold}}
\bigskip
\parskip=10pt plus 2pt minus 2pt
\renewcommand{\theenumi}{\alph{enumi}}

1. Consider the \emph{box scheme} for the advection equation $\partial u/\partial t + \partial u/\partial x = 0$
on the interval $[0,2\pi]$ with periodic conditions (so solutions are $2\pi$-periodic functions on the whole real line),
using mesh size $h=2\pi/N$ and a timestep $k>0$:

$$\frac{(U^{j+1}_n + U^{j+1}_{n+1}) - (U^j_{n}+ U^j_{n+1})}{2k}
  + \frac{(U^{j+1}_{n+1} + U^{j}_{n+1}) - (U^{j+1}_{n}+ U^j_{n})}{2h} = 0.$$
  
a) Draw the stencil diagram for the method (analogous the diagram on the left of Figure~5.2 of the notes for the downwind difference scheme).

b) Is the method implicit or explicit?

c) Show that the truncation error is $O(k^2+h^2)$. (Hint: expand around the center of a box, rather than around a
mesh point.)

d) Compute the amplification matrix $G$ (for which $U^{j+1}=G U^j$, with $U^j$ the vector of mesh values at time $jk$).
State it in terms of the shift matrices $K_+$ and $K_-$.

e) Find the eigenvalues of $G$ and determine whether the method is conditionally stable (in which case give the condition), unconditionally stable, or unconditionally unstable.

f) Can the same method be used to compute a wave travelling to the right?

g) Run the box scheme by adding a function definition {\tt unew = bs(u)} to the program \hbox{advection1d.py.}
Turn in the function definition and the plot of the advected profile at the final time $T=2$.

h) Optional, extra credit.  Precisely state and prove a second-order convergence result for the box scheme in the
discrete $L^2$ norm.

\end{document}

