\documentclass[minion]{homework}
\newcommand{\Reals}{\mathbb{R}}
\doclabel{Math F615: Homework 7}
\docdate{Due: March 18, 2019}
\usepackage{graphicx}

\newcommand{\bfx}{\mathbf{x}}
\newcommand{\bfv}{\mathbf{v}}

\begin{document}

\begin{problems}

\problem  Determine the values of $\theta$ for which the $\theta$ method 
is $L$-stable.

\problem Consider the function $f(x)=x-x^2$ on the interval $[0,1]$.
\begin{subproblems}
\item  Compute the Fourier sine series coefficients of
$f(x)$.
\item The function $f(x)$ looks pretty darn smooth. In class
we saw that smoothness should be reflected in the rate of decay
of the Fourier coefficients.  But the coefficients of $f(x)$ don't decay
very fast, only $O(N^3)$.  
Why doesn't this contradict the theorems we saw in class?
\item It can be shown that $\sum_{k=N}^\infty \frac{1}{k^3}\le \frac{1}{2N^2}$.
Use this result to show that if $s_N(x)$ is the partial sum of the 
Fourier sin series of $f(x)=x-x^2$ with $N$ terms, then 
\[
\max_{0\le x\le 1} |f(x)-s_N(x)|\le \frac{4}{\pi^3 N^2}
\]

\item Generate a convincing plot that shows that the error
between $f(x)$ and the partial sum $s_N(x)$ of the Fourier sine series 
$N$ terms converges $O(N^{-2)})$.  You must show the code used to generate the plot.
\end{subproblems}

\problem Suppose $u$ is a solution of $u_t=u_{xx}$ for $0\le x \le 1$
and $t\ge 0$ with boundary condition $u|_{x=0,1}=0$.
\begin{subproblems}
\item
Suppose that $u$ has $j$ continuous time derivatives
and $2j$ continuous space derivatives everywhere on its domain
for some $j=1,2,3,\ldots$.  Show that $(\partial_x)^{2j} u=0$ at $x=0,1$.
\item Suppose you solve this problem with initial data $u(x,0)=x-x^2$.
Does the solution have one continuous time derivative and two
continuous space derivatives everywhere on its domain? Justify
you answer briefly.
\end{subproblems}

\problem Recall the partial sums $s_N(x)$ from problem 2. 
Suppose $u_N(x,t)$ is the solution of the heat equation $u_t=u_{xx}$
for $0\le x\le 1$ with $u_N(x,0)=s_N(x)$ with Dirichlet boundary conditions.
Suppose $u(x,t)$ the the solution of the heat equation with the same boundary
conditions but with $u(x,0)=x-x^2$.  Show that $|u_N(x,t)-u(x,t)|<10^{-7}$
for all $x\in[0,1]$ and all $t\ge 0$ if $N=1200$.


\problem Suppose we wish to solve $u_t=u_{xx}$ with homogeneous 
Dirichlet boundary conditions and $u(x,0)=x-x^2$.  The aim
of this exercise (and indeed this entire assignment) is to show
that if the solution of the heat equation isn't smooth, then
the order of accuracy of your numerical solution can be reduced
from the accuracy expected using arguments that use smoothness.

We don't know the exact solution of the heat equation with this
initial condition.  But by the previous problem, we know that we can
compute an approximate solution with a known error by using the series
solution with 1200 terms.  So this will play the role of the ``exact''
solution, which is good enough until we see errors on the order of $10^{-7}$.

We are going to compare solving the heat equation with homogeneous 
Dirichlet boundary conditions with initial condition $f_1(x)=x-x^2$ and 
with initial condition $f_2(x) = \sin(\pi x)/4$.

\begin{subproblems}
\item Generate a graph of $f_1(x)$ and $f_2(x)$ for $0\le x \le 1$.  This
step is just to convince you that these initial conditions look ``close''
to each other.

\item For $N = 50, 100, 500, 1000, 5000$ and $M=2N$, generate
a solution of the heat equation using backwards Euler and initial
condition $f_2(x)=\sin(\pi x)/4$.  
Then compute the error at the first time step (i.e.
at the first time beyond $t=0$).  Generate a log-log plot of the error
versus $N$ and compute the order of convergence.  

\item Repeat the above but measuring error at the final time step.
Why do you see the two orders of convergence you observe
in this part and in the previous part? Why are they different?

\item Repeat parts b) and c), but with Crank Nicolson.

\item Now generate the same log-log plots of error (with computed
orders of convergence) when the initial condition is $f_1(x)=x-x^2$.
There should be four log-log plots (first time step and last time step
for each of backward Euler and Crank Nicolson).

\item Discuss the differences you see between the various convergence
plots for $f_1$ and their corresponding plots for $f_2$.
\end{subproblems}

\end{problems}

\end{document}