COMPLETE THE EXTRA CREDIT PART IN PYTHON CODE
Extra Credit (10 pts) (Coding): Convert your algorithm from (1) to output the PA = LU factorization of a matrix A. Note that here we are no longer dealing with augments matrices, but instead square matrices. Then, using this algorithm create a function which takes a matrix A and vector b as an input, outputs a solution to Ax b. =
1. (Coding) In this problem we will create code to solve a matrix using Gaussian elimination without partial pivoting. (a) Create a function that takes a matrix A, number c and two integers i and j as inputs, and outputs a matrix where row j is replaced with row i times c subtracted from row j. (b) Using part (a) create a function which takes as input a matrix A and an integer i and eliminates column i. That is, it outputs a matrix using part (a) multiple times where every entry below Ai,i, the diagonal element, are 0. (c) Create a function with an input of a matrix A that applies (b) multiple times so that the resulting matrix is upper triangular. Note that we are doing Gaussian elimination, so our input is really an augmented matrix, meaning that we have one more column than rows. (d) Create a function that takes as input a matrix A in upper triangular form and backsolves for your solution. Again, A is not square as we are dealing with an augmented matrix. Hint: Work this out on paper first. You should be able to write down an explicit formula for what your solution should be.
COMPLETE THE EXTRA CREDIT PART IN PYTHON CODE
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am