Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 (8 points) Implement in Matlab the following functions (2 points each). In the first three functions, you are not allowed to use the
Problem 1 (8 points) Implement in Matlab the following functions (2 points each). In the first three functions, you are not allowed to use the lu function and the backslash operator. function [L, U, P] = lu-pp (A) %[L, U,P] = lu-pp (A) computes a unit lower triangular matriu L, %an upper triangular matris U, and a permutation matris p such that %P+A = L*U. %The LU factorization is computed using partial pivoting. function [L, U, P] = lu_spp (A) %[L, U,P] = lu_spp (A) computes a unit lower triangular matris L, %an upper triangular matris U, and a permutation matris P such that %P+A = L*U. %The LU factorization is computed using scaled partial pivoting function x = lu_solve (L,U,b) %Solves LUx=b by solving Ly=b and then Ux=y. %Lis unit lower triangular, U is upper triangular function (xm, XPP, Xspp] = solve all (A,b) % Solves a linear system A*2 = b using Matlab's lu and %lu-pp and lu_spp. %Returns %2m = Alb %upp solution computed using lu-pp and lu_solve | % spp solution computed using lu_spp and lu_sovle For this problem, we will investigate the errors in the computed solutions by solve_all. As a reference solution, we use a vector of ones. That is, for a given matrix A, if r = (1,1,..., 1)", we compute b= A*r and then solve Ar = b. If t is the computed solution, the error is 1-and the residual is 16 - Afl. Problem 1 (8 points) Implement in Matlab the following functions (2 points each). In the first three functions, you are not allowed to use the lu function and the backslash operator. function [L, U, P] = lu-pp (A) %[L, U,P] = lu-pp (A) computes a unit lower triangular matriu L, %an upper triangular matris U, and a permutation matris p such that %P+A = L*U. %The LU factorization is computed using partial pivoting. function [L, U, P] = lu_spp (A) %[L, U,P] = lu_spp (A) computes a unit lower triangular matris L, %an upper triangular matris U, and a permutation matris P such that %P+A = L*U. %The LU factorization is computed using scaled partial pivoting function x = lu_solve (L,U,b) %Solves LUx=b by solving Ly=b and then Ux=y. %Lis unit lower triangular, U is upper triangular function (xm, XPP, Xspp] = solve all (A,b) % Solves a linear system A*2 = b using Matlab's lu and %lu-pp and lu_spp. %Returns %2m = Alb %upp solution computed using lu-pp and lu_solve | % spp solution computed using lu_spp and lu_sovle For this problem, we will investigate the errors in the computed solutions by solve_all. As a reference solution, we use a vector of ones. That is, for a given matrix A, if r = (1,1,..., 1)", we compute b= A*r and then solve Ar = b. If t is the computed solution, the error is 1-and the residual is 16 - Afl
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started