\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}}

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

{\em 
Please heed the advice in the HW3 debriefing. Spread out the work and
seek help or collaborate before spending lots of time stuck. A mix of analysis and coding, apt for a computational mathematician.
}

\ben

%\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 {[quick analysis ones]}
\ben
\item
Prove that all of the roots of polynomial which
defines the nodes for an $(n+1)$-node Gaussian quadrature are
simple---we never showed this in lecture.  [Hint:
%What is the definition of a Gaussian quadrature?
Look at the proof in
notes showing you can't integrate exactly all polynomials of degree
$2n+2$.]
\item
Prove that the 2-norm of an integral operator $K$ is bounded by the
2-norm of its kernel function on the square $[a,b]^2$. [Hint:
Cauchy-Schwarz]
\een

\item Solve analytically the second-kind integral equation,
\be
u(t) + \int_0^1 t s^3 u(s) ds\; = \;1, \qquad \mbox{for } t\in[0,1]
\ee
[Hint if stuck: $u$ is the RHS plus something in the range of $K$, the
integral operator].
Compute $\|K\|_\infty$. Is $K$ compact, and why?

\item {[the main one]}
Code up the 1D Nystr\"{o}m method in a way that allows you to switch
easily between different quadrature schemes
(\eg by setting a switch variable at the start of your code).
Apply it to the second-kind Fredholm equation
\be
u(t) + \int_0^1 e^{ts} u(s) ds\; = \;e^t + \frac{1}{t+1}(e^{t+1} - 1)
 \qquad \mbox{for } t\in[0,1]
\ee
which you can check has unique solution $u(t) = e^t$.
\ben
\item Produce plots that show the convergence vs $N$, the number of nodes,
of the maximum error magnitude in $u$ over the nodes, for the two
schemes: i) composite trapezoid, and ii) Gaussian quadrature.
(If you like,
$N = n+1$ since we labeled our nodes $0$ to $n$ for these schemes in
lecture.)
Categorize the convergence in each case and relate it to that of the
quadrature scheme.
What $N$ is required in each case to reach an error smaller than $10^{-5}$?

\item How does the condition number of the linear system you are solving
change with $N$? (You don't need to plot this, just describe).

\item At $N=5$ for Gaussian quadrature, produce a plot of the difference
between the Nystr\"{o}m interpolated solution {\em function} $u_n(t)$
and the exact solution,
on a fine grid on the interval $[0,1]$.
(Don't show the two functions, just subtract them).
Overlay the errors at just the 5 nodes onto your graph as blobs.
Is the true error sup norm of the solution reflected by the
maximum error magnitude in $u$ over the nodes, as you assumed in the
part (a)?
\een

\item Here you explore analytically
Fredholm equations involving a ``periodic convolution operator'',
that is, an operator acting on functions on $[0,2\pi)$ with kernel of the form $k(s,t) = (1/2\pi)\tilde{k}(t-s)$,
where $\tilde{k}:\mathbb{R}\to\mathbb{C}$ is a $2\pi$-periodic function.
They also have applications in signal and image processing.
You will show that they become very simple to solve in the Fourier basis.
\ben
\item Let $K$ be such an operator. Show that $e^{imt}$, for any
$m\in\mathbb{Z}$,
is an eigenfunction of $K$, and find its eigenvalue $\lambda_m$.
\item By substituting a Fourier series
$f(s) = \sum_{m\in\mathbb{Z}} f_m e^{-ims}$ and similar for
$u$ and $\tilde k$,
convert the first-kind
Fredholm equation $Ku = f$ into a set of simple algebraic relations involving
the Fourier coefficients $\{f_m\}$, $\{u_m\}$ and $\{\tilde{k}_m\}$.
[Hint: you'll need orthogonality of $\{e^{imt}\}$ on $[0,2\pi)$]
\item What is $\|K\|_2$ ? [Hint: go into a Fourier basis and use (b)]
\item If $\tilde{k}$ is in $L^2(0,2\pi)$ then its Fourier coefficients decay
as $|m|\to\infty$, by Parseval's equality.
What then is the {\em condition number} of the 1st-kind problem
$Ku=f$? [Hint: what does $K^{-1}$ do?]
What is the condition number of the 2nd-kind problem $u-Ku = f$?
BONUS: What also can you say about compactness of $K$?
%Thus use Parseval's equality to find a formula for $\|K\|_2$, \ie
%the operator norm from $L^2([0,2\pi))$ to itself, and express boundedness
%as a condition on the set $\{k_m\}$.
%\item BONUS: Say $k$ is square-integrable on $[0,2\pi)$.
%Can you prove something about the boundedness of $K$ ?
%Can you do the same for $K^{-1}$ ?
\een

\item
The fundamental solution for Laplace's equation in 2D is
$\Phi(x,y) = (1/2\pi) \ln 1/|x-y|$, where $y$ is a source point in $\mathbb{R}^2$,
and $x$ a target point also in $\mathbb{R}^2$.
Here you examine its directional derivative, a ``dipole source''.
\ben
\item Make a function which returns $\partial\Phi(x,y)/\partial n_y$,
the derivative with respect to source location in the direction $n_y$,
given vectors $x,y \in\mathbb{R}^2$ and
a unit vector $n_y\in\mathbb{R}^2$. %Then, for efficiency,
Generalize your routine so that it handles multiple $x$ vectors (\eg a
2-by-$n$ matrix of coordinates of $n$ such vectors), and returns the
corresponding list of outputs. (Be sure to test it on known inputs!)
\item 
Use the above to produce a
contour plot of $\partial\Phi(x,y)/\partial n_y$ for $y=(0.5,-0.2)$,
$n_y = (1/2,\sqrt{3}/2)$,
for $x$ varying over the square $[-1,1]^2$. This should now be a 3-line
program.
\een

\een

\end{document}
