Docsity

Numerical Computations: Solving Linear Systems with Gaussian Elimination and Iterative Met, Assignments of Mathematics

Toggle sidebar
bg1
CSE/MATH 451.002: Numerical Computations, spring 2005
Home work 7
Deadline: April 8 (Friday), 2005 in class
1 Various methods(60 points)
The linear system
4x1+ 3 x2= 24
3x1+ 4 x2−x3= 30
−x2+ 4 x3=−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.
2 SOR in Matlab (40 points)
a) (25 points) Write a Matlab function which solves a system of linear equations
Ax =b
with successive over relaxation (SOR) iterations. If Ais 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=nthen Ais 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 xand number of iterations.
The first few lines in the function would look like this:
1
pf3

Partial preview of the text

Download Numerical Computations: Solving Linear Systems with Gaussian Elimination and Iterative Met and more Assignments Mathematics in PDF only on Docsity!

CSE/MATH 451.002: Numerical Computations, spring 2005

Home work 7

Deadline: April 8 (Friday), 2005 in class

1 Various methods(60 points)

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.

2 SOR in Matlab (40 points)

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

A =

b =

− 3

− 4

− 3

− 3

− 5. 11719 · 10 −^3

− 3

− 3

and the start vector x

(0)

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.