% (c) 2004/2005 Universitaet Stuttgart
% Chair 'Numerische Mathematik fuer Hoechstleistungsrechner'
% http://www.ians.uni-stuttgart.de/nmh
%
% ----------------------------------------------------------
% Permission to use this exercise for non-profit educational
% purposes is hereby granted provided that this copyright
% notice is included in all copies or substantial portions
% of the LaTeX files.
% ----------------------------------------------------------
\begin{exercise}{Jacobi and SOR method - example}{tutorial}{10}{indir03\_eng}
The discretization of the Poisson equation $-\Delta u = f$ over the unit square with simple finite elements (or finite differences) and a uniform grid gives a sparse $n^2 \times n^2$ matrix $A$ that can be generated in Matlab using the command \texttt{gallery('poisson',n)}.
\begin{itemize}
\item[a)] Examine the number of required iterations for the Jacobi method and the Gauss-Seidel method when solving $Au=f$ for the right-hand side
\[
f = \frac{1}{(n+1)^2} \begin{pmatrix}1 \\ 1 \\ \vdots \\ 1 \end{pmatrix}.
\]
Use the methods of exercise \texttt{indir02\_eng} to do this. As the termination condition, use a tolerance \texttt{tol} of $10^{-5}$ for the relative residuum (in the Euclidean norm). Use the zero vector as start vector of the iteration.
Generate a plot showing the number of iterations vs. the dimension $n$, for $4 \leq n \leq 18$ (set the maximum number of iterations to perform to 1000).
\item[b)] Solve the system $Bu=f$ with $B=A+2I$ ($I$: identity matrix) under the same conditions as in a). How does the number of required iterations change? Explain the observed behavior.
\end{itemize}
\end{exercise}