Question: Write a function with the header [U, new_b] = myForward(A,b) which performs systematic linear transformation on the system Ax=b (the forward sweep). Prior to every
Write a function with the header [U, new_b] = myForward(A,b) which performs systematic linear transformation on the system Ax=b (the forward sweep). Prior to every step of the forward sweep, the rows of the augmented matrix (from row "step" to the last row) should be sorted by the column of the current step. At the start of step 1, you should sort rows 1 to n on column 1. At the start of step 3, you should sort rows 3 to end on column 3. At the start of step 17, you should sort rows 17 to end on column 17. Recall the equation for m (assuming i is the outer, step loop and j is the inner transformation loop): m(j, i) = -A(j, i) / A(i, i)
Test Cases:
>> format short
>> A = [ 10 6 2 1 8 5 3 3 3 5 2 7 4 9 6 3 8 5 1 3 5 3 6 10 5]
>> b = [5; 4; 3; 2; 1];
>> [U, b2] = mySweep(A,b)
U = 10.0000 6.0000 2.0000 1.0000 8.0000 0 6.2000 4.4000 0.7000 0.6000 0 0 5.0000 9.5000 1.0000 0 0 0 9.1258 3.9419 0 0 0 0 1.1615
b2 = 5.0000 0.5000 -1.5000 1.3774 2.2962
>> U\b2
= -0.8478 -0.4857 0.6403 -0.7030 1.9769
>> A\b ans = -0.8478 -0.4857 0.6403 -0.7030 1.9769 2.
) An upper triangular matrix is a square matrix with all zeros BELOW the diagonal elements. Write a function with header [x] = myBackwardSub(U, b) which solves Ax = b for x given an nxn upper triangular matrix A and an nx1 vector b. Use nested for loops, do not use built in Matlab functions inv, pinv, \.
Test Case:
>> myBackwardSub(U,b2)
ans
=
-0.8478 -0.4857 0.6403 -0.7030 1.9769
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
