In: Advanced Math
(a) Solve the linear system Az = b using the following three methods:
I. The GE+PP algorithm for sparse (banded) linear systems, which is the default algorithm used by Matlab’s “\” operator when the matrix (call it Asparse) is of sparse type. You may find it easiest to set up the matrix using the spdiags command.
II. The GE+PP algorithm for dense linear systems, again using “\”. Here, you need a dense version of A which you can obtain either with the diag command or more simply by typing Adense = full(Asparse)
III. The Gauss-Seidel iterative algorithm, also using the matrix Asparse. You may make use of the gs2 code from lectures, setting the parameters tol = 1e-8 and maxiter = 1e5, and taking initial guess z0 = (1, 1, . . . , 1)T .
For each method, compute the solution with n = 100 and n = 1000 points. How do the three methods compare in terms of cost? (use elapsed time from Matlab’s tic / toc as a proxy for cost). How well do your three answers agree with each other? (use the vector 2-norm to compare the differences). Which result do you think is most accurate?