\documentclass[10pt,letterpaper]{article}
\usepackage{graphicx,verbatim,amsmath,amssymb}
\usepackage[colorlinks=true]{hyperref}

\topmargin -0.5in
\textheight 9in
\oddsidemargin=-0.05in
\evensidemargin=-0.05in
\textwidth 6.5in
\pagestyle{empty}

\def\bea{\begin{eqnarray}}
\def\eea{\end{eqnarray}}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}
\newcommand\ben{\begin{enumerate}}
\newcommand\een{\end{enumerate}}
\newcommand\vg{\vspace{2ex}}
\newcommand{\bc}{\begin{center}}
\newcommand{\ec}{\end{center}}
\newcommand{\ie}{{\it i.e.\ }}
\newcommand{\eg}{{\it e.g.\ }}
\newenvironment{tight}{\vspace{-1ex}\begin{list}%
{$\bullet$}{\setlength{\parsep}{0in} \setlength{\itemsep}{-2ex}}}%
{\end{list}\vspace{-1ex}}
\newcommand{\bt}{\begin{tight}}
\newcommand{\et}{\end{tight}}
\newcommand{\eps}{\varepsilon}
\newcommand{\mbf}[1]{{\mathbf #1}}
\newcommand{\xx}{\mbf{x}}
\newcommand{\uu}{\mbf{u}}
\newcommand{\vv}{\mbf{v}}
\newcommand{\nn}{\mbf{n}}
\newcommand{\bb}{\mbf{b}}
\newcommand{\pO}{{\partial\Omega}}

\begin{document}
\title{Math 116 Numerical PDEs: Homework 5}
\date{due Mon 9am, Feb 13}
\maketitle

{\em 
Notice that I refer to ``the user'' below. When you code, always imagine you
are writing a code for an imaginary ``user'' (which could be your future
self), who needs this code to be a simple to use as possible. Oh, and with
a documented interface for each function, like I gave in HW2 \#4.
}

\ben

\item
Set-up for closed curves in the plane. You'll assume the user supplies a
polar curve given by a $2\pi$-periodic function $R:\mathbb{R}\to\mathbb{R}^+$,
and also supplies its derivative function $R'$.
\ben
\item
In terms of the functions $R$ and $R'$, make functions
of $s$ (inline ones may do) returning the vector $z(s)$, the speed $|z'(s)|$,
and the unit-length normal vector $n(s)$.
\item
Given $M$, the number of equispaced periodic trapezoid nodes,
use the above to fill a $2\times M$ array of boundary nodes $y_j = z(s_j)$,
a similar array of normals $n_j$, and a $1\times M$ array of speeds $p_j$.
\item
For the choice $R(s) = 1 + 0.3\cos(3s)$ and $M=30$,
use the
above arrays to produce a plot of the boundary nodes as blobs, with each
surface normal plotted as a little line with its tail at its own
boundary node.
[Hint: It should look like a hairy amoeba.
Use {\tt axis equal;} so that right angles look like they should.
Debug if not.]
\een

%\item Show that the Lagrange polynomial for trigonometric interpolation
%$l_k(x) = \frac{1}{2n}\sum_m' e^{im(x-x_k)}$ can be written
%\frac{1}{2n} \cot \left(\frac{x-x_k}{2}\right) \sin n(x-x_k)$.


%\item Basic fitting of convergence rates (easy).
%Say an exponentially-convergent numerical procedure gives error $E_n=
%10^{-5}$ at $n=10$ and $E_n=10^{-12}$ at $n=20$. Assuming it is in
%its asymptotic regime, find $K$ such that $E_n = c K^{-n}$.
%Find $\alpha$ such that $E_n = c e^{-\alpha n}$. [Please use either number
%to discuss rates from now on; both have their merits].


%Cut this since b) non-obvious??:
%\ben
%\item Consider the differential operator $A=-d^2/dx^2$ acting on $L^2[0,\pi]$.
%\ben
%\item Prove that $A$ is unbounded. [Hint: consider $A$'s
%action on the o.n.b. $\{\sqrt{2/\pi}\sin nx\}_{n=1,2,\ldots}$]
%\item Prove that $A^{-1}$ is compact. [Hint: see b) in previous question]
%\een

\item
Here you check that ``Gauss' Law'' really works, and test numerical
convergence.
\ben
\item
Use periodic trapezoidal quadrature with $N=30$ nodes in
the parameter $s\in[0,2\pi)$, your arrays from question \#1, your
plotting code from HW4 \#5,
to write a code which approximates the boundary integral
\be
u(x) = \int_\pO \frac{\partial \Phi(x,y)}{\partial n_{y}} ds_y
\ee
for a set of points $x$.
(Note this is the double-layer operator, $u={\cal D}\tau$,
acting on the density $\tau\equiv 1$.)
Use this to make a 3D surface plot of $u(x)$,
for $x$ in the square $[2,2]^2$.
Check that interior values are roughly -1, and exterior zero.
[To debug, try the circle $R\equiv 1$ first].
%{\tt R = @(s) 1+0*s; Rp = @(s) 0*s;} first].
%\een

%\item
%Here you move to a parametrized curve, in preparation for boundary
%integral equations.
%Laplace
%solutions from boundary data; this is {\em nearly} solving a PDE.
%Now you adjust your code to compute interior values from boundary
%values using Green's Representation Formula.
%\ben

\item The above plot should approximate $-1$ in $\Omega$; make a
labeled {\tt contourf}
plot of $\log_{10}$ of the absolute deviation from this value over the
interior of $\Omega$.
How does the error seem to vary in the domain?
\item For the single fixed location $x = (0.2,0.1)$, show convergence vs $N$
of error at this point
on an appropriate plot, and state the convergence order or rate.
What $N$ is needed to reach the minimum error?
BONUS: How does the above depend on the choice of point $x$?
\een

\item
Proof of bound on the ``far'' part in the double-layer jump relation.
Fix $y,z\in\pO$, and let $x = x(h) = z + hn_z$ be a point off the surface for
$h\neq 0$. We make a geometric assumption $2h\le |z-y|$.
\ben
\item By using the assumption, and using crude but rigorous
bounds on things, show that $$\frac{d}{dh} \left(
\frac{\partial \Phi(x,y)}{\partial n_y} -
\frac{\partial \Phi(z,y)}{\partial n_y}
\right)~.$$
is less than $C/|z-y|^2$ in size, for some fixed number $C$.
\item
Use this and the mean value theorem in $h$ to show the following.
Let $z\in\pO$, and $r>0$, then for all $|h|<r/2$,
$$ \int_{y\in\pO, |y-z|\ge r} \left|\frac{\partial \Phi(x,y)}{\partial n_y} -
\frac{\partial \Phi(z,y)}{\partial n_y}\right|\, ds_y
\; \le \; C \frac{h}{r^2}
$$
for some $C$ which may depend on the domain, but not on $z$, $r$ or $h$.
\een

\item
At last you solve a BVP, the interior Dirichlet one for Laplace's equation!
\ben
\item Expand your code from \#1 to allow the input of the 2nd-derivative
function $R''$, and to produce the curvature function $\kappa(s)$
at the parameter $s$. [Debug by checking
your curvature does what you expect for
the curve $R(s) = 1 + 0.3\cos(3s)$.]
\item Make a routine to fill the $N\times N$
Nystr\"{o}m kernel matrix: diagonal elements via
$\kappa(s_j)$, off-diagonal elements via the formula
$\frac{\partial \Phi(x,y)}{\partial n_y}$. Don't forget to
include the speed function and (constant) weights $2\pi/N$.
Oh, and then add the identity.
[Hint: debug using {\tt imagesc} on the matrix to see its diagonal
entries smoothly match the off-diagonal; the kernel function should be
is smooth].
\item 
Let's use a BVP with known solution
$u(x_1,x_2) = \cos(x_1)e^{x_2}$ which you can check is harmonic.
Then its Dirichlet boundary data is $f = u|_{\pO}$, which you should use
to fill a column vector of values $f(s_j)$.
Let's fix $N=30$ nodes.
Solve the Nystr\"{o}m
linear system corresponding to the integral equation
$(I-2D) \tau = -2f$ to get
the $\tau$ vector at the nodes.
Tweak your code from \#2 to compute the
solution potential $u^{(N)}(x)$ generated by this $\tau$,
at the location $x = (0.2,0.1)$.
[Hint: it should be small!]

BONUS: start investigating convergence vs $M$, and location $x$, if you want\ldots
\een

\een

\end{document}

