Question: Write a function M-file to get 0s beneath the pivot in a given column, say column #k (fixed k). Use input arguments: o a square
Write a function M-file to get 0s beneath the pivot in a given column, say
column #k (fixed k). Use input arguments: o a square matrix of coefficients, say A, with zeros beneath the pivots in
columns 1, 2, ..., k-1, and with the current pivot Akk 0; and o the number k, telling what column we are working on.
For example, if we input: A = the coefficient matrix for a system C(x1+2x2+x3 =1; 2x1x2 x3 =6 ; 3x1+x2+2x3=1), and k = 1
If we input: A = the coefficient matrix for the new system C1, and k = 2.
Note that since you are working on column k, you should getting 0s below the pivot in rows i = k+1, ..., N. (Use a for-loop to go through these rows.)
When your code works correctly for the two test cases above, add in an input for the column vector b, and compute the corresponding output vector b using Gaussian Elimination. (Rename your M-file: gauss_elim_v1.)
Modify your code gauss_elim_v1 from the previous part, so that k is no longer an input argument. You will want to loop through all of the k columns (k = 1:N-1), outside of the for loop for the rows.
Test your code by passing in (as A) the coefficient matrix C; your output should be coefficient of new matrix D
Consider the system with augmented matrix:
A_aug =
3 1 4 2
0 -2 4 0
1 2 1 2
Hence: modify the code (as given on p. 16) so the 3 lines are executed only if A(i, k) 0. Save the new version as gauss_elim_v2. As a check, try your revised code on the system of A_aug, as given above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
