% (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}{tutorial}{10}{indir02\_eng} Write Matlab functions with the function headers \begin{itemize} \item[a)] \texttt{function [u,m] = solveJacobi(A, f, s, tol, max)} \item[b)] \texttt{function [u,m] = solveSOR(A, f, s, w, tol, max)} \end{itemize} that solve the linear equation system $Au=f$ iteratively by using the Jacobi and the SOR method ($A$ must be a symmetric, positive definite $n \times n$ matrix). \texttt{tol} represents a given termination condition (see below), \texttt{max} is the maximum number of iterations to perform, $s$ is the iteration start vector, $w \in (0, 2)$ the so-called relaxation parameter of the SOR method. The output arguments of the function are the number of iterations performed $m$ and the approximate solution vector $u$. $\text{Termination condition:} ~~ \frac{\norm{f-Au}_2}{\norm{f}_2} \leq \texttt{tol}$ \end{exercise}