\documentclass[12pt]{article}
\usepackage{fullpage,amsmath,amsfonts}

\newcommand{\x}{\boldsymbol{x}}
\newcommand{\y}{\boldsymbol{y}}
\newcommand{\z}{\boldsymbol{z}}
\renewcommand{\v}{\boldsymbol{v}}
\newcommand{\w}{\boldsymbol{w}}
\renewcommand{\r}{\boldsymbol{r}}
\renewcommand{\b}{\boldsymbol{b}}
\renewcommand{\c}{\boldsymbol{c}}
\newcommand{\e}{\boldsymbol{e}}
\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}
\newcommand{\Range}{\operatorname{Range}}
\newcommand{\Ker}{\operatorname{Ker}}
\newcommand{\Span}{\operatorname{Span}}
\renewcommand{\dim}{\operatorname{dim}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}


\begin{document}

\title{Numerical Methods I -- Lab 5}
\author{Fall Semester 2005}
\date{October 25, 2005}
\maketitle



\begin{enumerate}


\item It can be shown that the error of approximating a function $f$
via a polynomial $p_n$ of degree less or equal to $n$ can be estimated
by
\[
  | f(x) - p_n(x) | \leq \frac{M_{n+1}}{(n+1)!} \, |\pi_{n+1}(x)| \,,
\]
where
\begin{gather*}
  M_{n+1} = \max_{x\in[x_0,x_n]} |f^{(n+1)}(x)| \,,\\
  \pi_{n+1}(x) = \prod_{j=1}^n (x-x_j) \,,
\end{gather*}
and where $x_0,\dots,x_n$ are $n+1$ distinct interpolation nodes.

In other words, the error is determined by two factors:  One depends
only on the function $f$ and will not be considered here.  The other
factor depends only on the distribution of nodes.
\begin{enumerate}
\item Plot $\pi_{n+1}(x)$ for an equidistantly distributed nodes
$x_0$,\dots,$x_n$ on the interval $[-5,5]$ for $n=10,20$.
\item Plot $\pi_{n+1}(x)$ for the so-called Chebycheff-nodes
\[
  x_i = 5 \, \cos \frac{i \, \pi}{n}
\]
where $i=0,\dots,n$.

\item Plot both graphs into the same plot, and label the graphs.
\end{enumerate}

Hints: \texttt{help plot} for labeling, \texttt{help poly} and
\texttt{help polyval} for the quick construction and evaluation of
polynomials.
\newpage

\item The polynomial interpolation problem, i.e.\ finding
\[
  p_n(x) = c_0 + c_1 \, x + \dots + c_n \, x^n
\]
such that $p_n(x_i)=y_i$ for $i=0,\dots,n$, leads immediately to the
system of linear equations for the coefficients $c_0, \dots, c_n$:
\[
  \begin{pmatrix}
    x_0^n & \cdots & x_0^0 \\
    \vdots & & \vdots \\
    x_n^n & \cdots & x_n^0
  \end{pmatrix}
  \begin{pmatrix}
  c_n \\ \vdots \\ c_0
  \end{pmatrix}
  =
  \begin{pmatrix}
  y_0 \\ \vdots \\ y_n
  \end{pmatrix} \,.
\]
The matrix on the left is called \emph{Vandermonde matrix}.  (The
Vandermonde matrix we have encountered in a previous example is the
special case when the nodes are $1,\dots,n$.)

\begin{enumerate}
\item Construct the Vandermonde matrix for the two distributions of
nodes from part~1.
\item Use this approach to solve an interpolation problem, e.g.\ the
problem from Homework~6 where
\[
  f(x) = \frac1{1+x^2}
\]
on the interval $[-5,5]$, and $y_i=f(x_i)$ for $i=0,\dots,n$.
\end{enumerate}
\end{enumerate}
\noindent
\textbf{Octave Trick:} To generate an Encapsulated Postscript (EPS)
file from a plot for printing or inclusion into other documents, use
the following code.
\begin{verbatim}
  gset term postscript eps monochrome; % omit 'monochome' for color output
  gset output "filename.eps";          % change 'filename' as needed
  replot;
  gset term x11;                       % restore screen output if necessary
\end{verbatim}
\emph{Note for Windows:} The last line may work differently on Windows
(any information is welcome).  Also, you may need to install
\textsl{ghostscript} and \textsl{gsview} in order to print and process
Postscript files.



\end{document}

