Question: . Write a MATLAB function x=GEPP(A, b), with input the matrix A, right hand side vector b and output the solution vector x. (a) Add
. Write a MATLAB function x=GEPP(A, b), with input the matrix A, right hand side vector b and output the solution vector x.
(a) Add the partial pivoting procedure to the Gaussian elimination code, .
(b) Include the backward substitution function x=BS(A, b) as a private function to GEPP(A, b) and call it in GEPP after the Gaussian elimination to solve the reduced problem.
Use your code to do the following problems.
(a) The matrix A and b are defined as below A = ? ? 1 1 1 1 1 + 10?14 2 1 2 2 ? ? , b = ? ? 3 4 + 10?14 5 ? ? . The exact solution is x = (1, 1, 1)T . Output the numerical solution by your linear solver GEPP.
(b) The matrix A is the n n Hilbert matrix, which is defined by Aij = 1/(i + j). In MATLAB, this can be generated by the function hilb(n), where n is the size of the matrix. Generate random right hand side vector b=rand(n,1) and solve the linear system Ax = b for n = 10, 20, 40. For each n do the following things 1
i. solve the linear system Ax = b with GEPP function and output the residual kAx ? bk.
ii. solve the same linear system with the MATLAB backslash solver and output the residual.
iii. output the condition number of the matrix A, by using cond(A). What do you observe? Can you explain?
(c) The nn matrix A is defined as in Example 5.9 on page 109 of the book by Ascher and Greif. The right hand vector is random b=rand(n, 1).
i. For given n, generate the matrix A with diag in MATLAB.
ii. Solve the linear system Ax = b for n = 400 and output the residual kAx ? bk.
iii. Solve the same linear system with the MATLAB backslash function and output the residual as well. What do you observe? 
5. Write a MATLAB function x-GEPP(A, b), with input the matrix A, right hand side vector b and output the solution vector x (a) Add the partial pivoting procedure to the Gaussian elimination code, which you wrote in the last home- (b) Include the backward substitution function x-BS(A, b) as a private function to GEPP (A, b) and call it Use your code to do the following problems. (a) The matrix A and b are defined as below work in GEPP after the Gaussian elimination to solve the reduced problem A=|1 1+10-14 21, b=11+10-14 The exact solution is x = (1, 1, 1)T. Output the numerical solution by your linear solver GEPP. (b) The matrix A is the n x n Hilbert matrix, which is defined by Aij -1/(i+j). In MATLAB, this can be generated by the function hilb(n), where n is the size of the matrix. Generate random right hand side vector b-rand (n, 1) and solve the linear system Ax-b for n = 10, 20.40. For each n do the following things i. solve the linear system Ax -b with GEPP function and output the residual ||Ax-b ii. solve the same linear system with the MATLAB backslash solver and output the residual iii. output the condition number of the matrix A, by using cond (A). What do you observe? Can you explain? (c) The n n matrix A is defined as in Example 5.9 on page 109 of the book by Ascher and Greif. The right hand vector is random b-rand(n, 1). i. For given n, generate the matrix A with diag in MATLAB. ii. Solve the linear system Ax -b for n -400 and output the residual Ax-b iii. Solve the same linear system with the MATLAB backslash function and output the residual as well What do you observe? Read the Example 5.9 and the paragraph below it on page 109 for the explanation 5. Write a MATLAB function x-GEPP(A, b), with input the matrix A, right hand side vector b and output the solution vector x (a) Add the partial pivoting procedure to the Gaussian elimination code, which you wrote in the last home- (b) Include the backward substitution function x-BS(A, b) as a private function to GEPP (A, b) and call it Use your code to do the following problems. (a) The matrix A and b are defined as below work in GEPP after the Gaussian elimination to solve the reduced problem A=|1 1+10-14 21, b=11+10-14 The exact solution is x = (1, 1, 1)T. Output the numerical solution by your linear solver GEPP. (b) The matrix A is the n x n Hilbert matrix, which is defined by Aij -1/(i+j). In MATLAB, this can be generated by the function hilb(n), where n is the size of the matrix. Generate random right hand side vector b-rand (n, 1) and solve the linear system Ax-b for n = 10, 20.40. For each n do the following things i. solve the linear system Ax -b with GEPP function and output the residual ||Ax-b ii. solve the same linear system with the MATLAB backslash solver and output the residual iii. output the condition number of the matrix A, by using cond (A). What do you observe? Can you explain? (c) The n n matrix A is defined as in Example 5.9 on page 109 of the book by Ascher and Greif. The right hand vector is random b-rand(n, 1). i. For given n, generate the matrix A with diag in MATLAB. ii. Solve the linear system Ax -b for n -400 and output the residual Ax-b iii. Solve the same linear system with the MATLAB backslash function and output the residual as well What do you observe? Read the Example 5.9 and the paragraph below it on page 109 for the explanation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
