\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}{9in}
\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 3}
\end{center}
\dspace


\begin{enumerate}
\item Consider the following initial boundary value problem for the heat equation 
\begin{align*}
u_t &= u_{xx}, \ \text{for} \ x \in (0,1), t > 0 \\
u(0,t) & = u(1,t) = 0 \\
u(x,0) & = f(x),
\end{align*}
with the function $f$ defined as 
\begin{equation*}
f = \begin{cases} 
2x & x \leq 1/2, \\
2(1-x) & x \geq 1/2.
\end{cases}
\end{equation*}
A formal solution of this problem can be derived using Fourier's method and
is given as 
\begin{equation*}
u(x,t) = \ds\frac{8}{\pi^2} \sum_{p=1}^{\infty}\left(\ds\frac{\sin{(p\pi/2)}}{p^2}\right )\e^{-(p\pi)^2t}\sin{(p\pi x)}.
\end{equation*}
\begin{enumerate}
\item Plot the Fourier series solution as a function of $x$ for $t = 0.1$,
  by truncating the series after 200 terms.
\item Implement the explicit method (forward Euler in MOL), the implicit
  method (backward Euler in MOL) and the Crank Nicolson method (trapezoidal
  in MOL) in MATLAB. (Download the code {\tt ImplicitHE.m} from my
  webpage. This implements the implicit scheme. Modify this to implement
  the explicit and Crank-Nicolson methods.) 
\item Using $h = 0.02$ and $k = 0.000201$, so that $r = k/h^2 = 0.5025$,
  show that the numerical solution to the explicit method exhibits
  instability, whereas the numerical solutions produced by the implicit and
  Crank Nicolson methods are well behaved. Plot the three numerical
  solutions and the exact solution on the same graph.
\item Choose $h = k = 0.02$ so that $r = 50$ in the implicit and Crank
  Nicolson schemes. What can you say about these numerical solutions? Plot
  the solutions and the exact solution on the same graph. 
\end{enumerate}


\item Consider the following nonlinear heat equation 
\begin{align*}
u_t &= (\alpha(u)u_x)_x, \ \text{for} \ x \in (0,1), t > 0 \\
u(0,t) & = u(1,t) = 0 \\
u(x,0) & = f(x),
\end{align*}
where $\alpha(u)$ is a given strictly positive and smooth function.
\begin{enumerate}
\item Let $v = \alpha(u)u_x$ and justify the following approximations,
  in particular, what are the errors?
\begin{align*}
u_t(x,t) &\approx \ds\frac{u(x,t+k)-u(x,t)}{k} \\
v_x(x,t) &\approx \ds\frac{v(x+h/2,t)-v(x-h/2,t)}{h} \\
\end{align*}
\item {\bf (553:)} Show the following approximation.  What is the order of the error?
\[ v(x+h/2,t) \approx
\frac{1}{2}\left[\alpha(u(x+h,t))+\alpha(u(x,t))\right]\frac{u(x+k,t)-u(x,t)}{h}\]
\item Use these approximations to derive the scheme
\[ \frac{U^{n+1}_j-U^{n}_j}{k}= 
  \frac{\alpha_{j+1/2}^n(U^{n}_{j+1}-U^{n}_j)-\alpha_{j-1/2}^n(U^{n}_{j}-U^{n}_{j-1})}{h^2},\] 
where $\alpha_{j+1/2}^n = (\alpha(U_{j+1}^n) +\alpha(U_j^n))/2$.
\end{enumerate}

\item Consider the nonlinear heat equation
\begin{align*}
u_t &= (uu_x)_x, \ \text{for} \ x \in (0,1), 0<t\leq 1 \\
u(0,t) & = t, \ u(1,t) = 1+t \\
u(x,0) & = x
\end{align*}
\begin{enumerate}
\item Verify that the exact solution to this problem is $u(x,t) = x+t$.
\item {\bf (Bonus):} Show, by induction, that the explicit scheme in Problem 2, part c, gives the exact
  solution at each grid point, i.e., show that $U_j^n = x_j+t_n$ for any
  grid sizes.
\item Compute the numerical solution at $t = 1$ using this explicit
  scheme. Try the following grid parameters:
\begin{enumerate}
\item $m = 4$ and $k = 1/40$
\item  $m = 30$ and $k = 1/3000$
\end{enumerate}
(Note: $h = 1/(m+1)$.) Discuss your observations in light of the result in
part b. (Download the 
code {\tt NonlinearHE.m} from my webpage. This implements the nonlinear
heat equation for the example problem that we saw in class. Modify this
code for the present problem.)
\item From the numerical results obtained in part c, it is clear that some
  kind of stability condition is needed. Try to come up with a stability
  condition for this problem. Run some numerical experiments with mesh
  parameters satisfying this condition. Are the numerical solutions
  well-behaved if the conditions on the mesh parameters are satisfied?
\end{enumerate}
\end{enumerate}

\begin{comment}
\item  Consider the advection-diffusion equation 
\begin{equation}
u_t+cu_x = u_{xx}
\end{equation}
with Dirichlet-type boundary conditions. Here $c \geq 0$ is a given
constant.
\begin{enumerate}

\item Show that this problem has a family of particular solutions of the
  form 
\begin{equation}
u(x,t) = \e^{-(\mr{i}k\pi c+ (k\pi)^2)t}\e^{ik\pi x}
\end{equation}
\item Derive stability conditions for the following numerical methods by
  applying the von Neumann method.
\begin{align*}
\mr{(i)} \ \ & \ds\frac{U^{n+1}_j-U^{n}_j}{k}+c\ds\frac{U^n_{j+1}-U^n_{j-1}}{2h} =
  \ds\frac{U^n_{j-1}-2U^n_j+ U^n_{j+1}}{h^2}\\
\mr{(ii)} \ \ & \ds\frac{U^{n+1}_j-U^{n}_j}{k}+c\ds\frac{U^n_{j}-U^n_{j-1}}{h} =
  \ds\frac{U^n_{j-1}-2U^n_j+ U^n_{j+1}}{h^2}\\
\mr{(iii)} \ \ &\ds\frac{U^{n+1}_j-U^{n}_j}{k}+c\ds\frac{U^n_{j+1}-U^n_{j}}{h} =
  \ds\frac{U^n_{j-1}-2U^n_j+ U^n_{j+1}}{h^2}\\
\mr{(iv)} \ \  & \ds\frac{U^{n+1}_j-U^{n}_j}{k}+c\ds\frac{U^n_{j}-U^n_{j-1}}{h} =
  \ds\frac{U^{n+1}_{j-1}-2U^{n+1}_j+ U^{n+1}_{j+1}}{h^2}\\
\mr{(v)} \ \ & \ds\frac{U^{n+1}_j-U^{n}_j}{k}+c\ds\frac{U^{n+1}_{j}-U^{n+1}_{j-1}}{h} =
  \ds\frac{U^{n+1}_{j-1}-2U^{n+1}_j+ U^{n+1}_{j+1}}{h^2}
\end{align*}
\end{enumerate}
\end{comment}
\end{document}
