CS/MA 321-001 Project #1 1. Complete the following MATLAB program for the Naive Gaussian Elimination to solve the linear
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
CS/MA 321-001 Project #1 1. Complete the following MATLAB program for the Naive Gaussian Elimination to solve the linear
CS/MA 321-001 Project #1 1. Complete the following MATLAB program for the Naive Gaussian Elimination to solve the linear system of equations Az = b. function x = Gauss_Naive(A,b) % Function x = Gauss_Naive (A,b) finds the solution x of the linear system % Ax = b by the Naive Gaussian Elimination, where the input A is an % n-by-n matrix and b is a vector of length-n. 2. Select a reasonable value of n and generate a random nxn matrix A (using A = randn(n,n)). Define the vector b such that the solution of the system Ax = b is a vector x with entries x(j) = j for j = 1, 2,..., n. Test the Gauss Naive on this system. 3. Modify Gauss_Naive to include partial pivoting scheme (i.e., select the pivot row to be the one with the maximum pivot entry in absolute value from those in the leading column of the reduced submatrix). function x = Gauss_Pivoted (A,b) % Function x = Gauss_Pivoted (A,b) finds the solution x of the linear system % Ax = b by Gaussian Elimination with partial pivoting, where the input A is % an n-by-n matrix and b is a vector of length-n. 4. Test Gauss Pivoted on the linear system from item 2. Then compare the residual vector r = Ax – b of the solution computed by Gauss Pivoted and Gauss Naive. Which method is more accurate? (You can simply compare the norm of r computed by norm(r).)