

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Deadline: April 8 (Friday), 2005 in class
The linear system
4 x 1 + 3 x 2 = 24
3 x 1 + 4 x 2 − x 3 = 30
− x 2 + 4 x 3 = − 24
should be solved by the following methods (do not use Matlab for this problem)
a) (15 points) Gaussian elimination (tridiagonal system).
b) (15 points) Jacobi’s method.
c) (15 points) Gauss-Seidel’s method.
d) (15 points) The SOR-method, with ω = 1.25.
For the methods in b), c) and d), write out the general iteration scheme, then do 2
iterations for each method, with the start value
x
(0) = [24/ 4 , 30 / 4 , − 24 /4] = [6, 7. 5 , −6].
Which method of b, c, d seems to work better for this example? Put your comments.
a) (25 points) Write a Matlab function which solves a system of linear equations
Ax = b
with successive over relaxation (SOR) iterations. If A is a band matrix, must this fact
be used. The function should take in A, b, a start value, band-width d(defined as aij = 0
for |i − j| > d, and if d = n then A is a full matrix), relaxation parameter ω, an error
tolerance ε and a maximum number of iterations. The iteration stops when the relative
error is less than the tolerance or when the maximum number of iteration is reached.
The function should return the solution vector x and number of iterations.
The first few lines in the function would look like this:
function [x,nit]=sor(A,b,x0,omega,d,tol,nmax)
% SOR : solve linear system with SOR iteration
% Usage: [x,nit]=sor(A,b,x0,omega,d,tol,nmax)
% Inputs:
% A : an n x n-matrix,
% b : the rhs vector, with length n
% x0 : the start vector for the iteration
% tol: error tolerance
% omega: relaxation parameter, (0 < omega < 2),
% d : band width of A.
% Outputs::
% x : the solution vector
% nit: number of iterations
b) (15 points) Use your function sor to solve the following tridiagonal system with
b =
− 3
− 4
− 3
− 3
− 3
− 3
and the start vector x
Solve the system with an error tolerance of 10
− 4 and the maximum number of iterations
of 100. Try different values of ω between 1 and 2 (this is called over-relaxation), for
example ω = 1. 0 , 1. 1 , 1. 2 , · · · , 1 .9. Search for the value of ω that gives the quickest con-
vergence(meaning, smallest number of iterations). Make a plot of number of iterations
as a function of ω.
What to hand in? Your Matlab file sor.m, the script, the running result, the plot,
and whatever comments you have.