Solve the linear system with the four methods below (Do not use Matlab).
4 x1 + 3 x2 = 24
3 x1 + 4 x2 − x3 = 30
− x2 + 4 x3 = −24
(a). Gaussian elimination (tridiagonal system).
(b). Jacobi’s method.
(c). Gauss-Seidel’s method.
(d). 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 initial guess
x0 = [24/4, 30/4, −24/4] = [6, 7.5, −6].
Among the methods (b), (c), (d), which seems to work better for this example? Please comment.
(a). Write a Matlab function which solves a system of linear equations Ax = b, with successive over relaxation (SOR) iterations. Assume here that A is a banded matrix with band width d, (so that aij = 0 for |i−j| > d). The inputs of the function are: A, b, a starting vector x0, the band-width d, the relaxation parameter w, an error tolerance ε and the maximum number of iterations. The iteration stops when the error (you may use the residual r = Ax−b measured in certain norm) is less than the tolerance, or when the maximum number of iterations is reached. The function should return the solution vector x and the number of iterations.
The first few lines in the function should look like this:
function [x,nit]=sor(A,b,x0,w,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
% w: relaxation parameter, (1 < w < 2),
% d : band width of A.
% Outputs::
% x : the solution vector
% nit: number of iterations
(b). Use your function sor to solve the following tridiagonal system, with
−2.011 1
A =
1 −2.012 1
1 −2.013 1
1 −2.014 1
1 −2.015 1 ,
1 −2.016 1
1 −2.017 1
1 −2.018 1
1 −2.019
−0.994974
1.57407 10
−4
−2.71137 • 10
0.95
0.9
0.85
0.8
b = −4.07407 • 10−3
, x0 = 0.75 .
5.11719 10−3
−3
−6.57065 • 10−3
−0.507084
0.7
0.65
0.6
0.55
Here b is the load vector and x0 is the initial guess. Solve the system with an error toler- ance ε = 10−4, setting 100 as the maximum number of iterations. Try different values of w between 1 and 2 (this is called over-relaxation), for example w = 1.0, 1.1, 1.2, • • • , 1.9. Search for the value of w that gives the fastest convergence (requiring the smallest number of iterations). Make a plot of number of iterations as a function of w.
What to hand in? Your Matlab file sor.m, the script, the running result, the plot, and whatever comments you have.
Write a Matlab function, using Jacobi’s method to solve a system of linear equations. Do it similarly as in Problem 2(a), but only for tri-diagonal systems.
Test it on the same system in Problem 2b), with error tolerance ε = 10−4 and setting the maximum number of iterations =100. Compare the result with the result from SOR. Which method converges faster? Put your comments.
What to hand in? Your Matlab file jacobi.m, the script, the running result, and whatever comments you have.
4. More practice on various methods
Do not use Matlab for this problem. Consider the system of linear equations
5x + 4y − 2z = 2
−2x + 8y − 3z = 6
x + y − 7z = 5
• Perform one step Jacobi iteration, using x0 = y0 = z0 = 1 as starting value.
• Perform one step Gauss-Seidel iteration, using x0 = y0 = z0 = 1 as starting value.
• Do Jacobi iterations converge for this system? Do Gauss-Seidel iterations converge for this system? Why?
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme