阅读量:0
Total points: 20 1. (0 points) Please sign the Academic Integrity Checklist on the last page of this pdf. If you do not sign the Academic Integrity Checklist you will receive a 0 for this assignment. iuww520iuww520iuww520iuww520iuww520iuww520iuww520iuww520 2. (Theoretical, 3 points) When applying Gauss-Seidel iteration to solve a linear system 𝐴 ⃗𝑥 = ⃗𝑏 and when 𝐴 is one of the two matrices below, we expect convergence of the iteration. You’re asked to argue why the convergence. Use two different arguments for convergence of Gauss-Seidel iteration applied to 𝐴1 and 𝐴2. (You’re allowed to use a software/calculator to compute, for example, an inverse of a matrix, if needed.)• Use vector 2-norm to evaluate the residuals;† • Use relative tolerance 𝜏rel = 10−3, i.e., the stopping criterion should be: ‖⃗𝑟 (𝑘) ‖ / ‖⃗𝑟 (0)‖ ≤ 10−3; • Use the zero vector (a vector with all its components being zeros) as the initial guess; • Output the final iteration count when stopping criterion is met. Apply your Jacobi and Gauss-Seidel codes to the two linear systems 𝐴 ⃗𝑥 = ⃗𝑏 and 𝐴bigger ⃗𝑥 = ⃗𝑏bigger, with their data provided on LEARN (A.txt,b.txt,A bigger.txt,b bigger.txt‡ ). Here is how you load matrix/vector data into MATLAB: 1 A = load ('A.txt ') ; 2 b = load ('b.txt ') ; And here is how you load them into Python: 1 import numpy as np 2 A = np . loadtxt ('A.txt ') 3 b = np . loadtxt ('b.txt ', ndmin =2) You are also asked to record the execution time of your code when solving each system. Here is how you do it if, for example, your Jacobi iteration is written as a function jacobi itr(A,b,guess,tol) in MATLAB§ : 1 % The execution of codes between tic and toc is timed by MATLAB 2 % and the elapsed time is printed out ( see the documentation for examples ) 3 tic 4 number_itr = jacobi_itr (A ,b , guess , tol ) ; % the final iteration count is the output 5 toc And here is how you do it in Python¶ : 1 import time 2 3 # ...... 4 # other codes here 5 # ...... 6 7 start = time . time () 8 nunmber_itr = jacobi_itr (A ,b , guess , tol ) 9 T = time . time () - start 10 print ('Elapsed time is ', T , 'seconds .')