Question: ****MUST BE DINE USING PYTHON***** please solve sp5 im so confused as to what i need to be doing. please and thank you. will rate




SP5 Writ code to perform back substitution. Note use examples from the handout/lecture notes in Ch. 4. SP6 Write code to perform addition and subtraction for two matrices. x= *3= jun be 04 b3--034X4 3 433 b- , =lt1 X = i=n-1, n-2, ..., 1 ai 4. This is called backsubstitution 6. Lower Triangular Form 011 0 0 0 x b. 021 b 1. a31 432 433 b3 01 02 03 04|X b. 2. Which can be solved by: b, 9,20 0 | X2 0 | X3 X,= 011 b-02, 3. x= 0,2 j=1 b-- , , x = i=2, 3, ..., n a 4. This is forward substitution. 7. Diagonal Form ai 0 0 0 X b. 0 0,2 0 0 0 0 0 0 0 a 2. Which can be solved by: b2 03 bu Developing an algorithm for back substitution (this assumes a in upper triangular form). b- , , x= Jul 1 i=n-1, n-2, ..., 1 HOW DO I CODE THISI? Starting index of 1: Xn-br/ann (Do this part outside the loop) For Loop - Range = i = n-1 to 1 (stepping backward) sum = get_sum(a,x,l) This is a function call to get_sum x = (b - sum)/a. function get_sum(a.x.i): sum = 0 Initialize the sum For Loop - Range j =i+1 to j = n sum = sum + ax return sum Starting index of 0 (python): Xo =br/a.1. (Do this part outside the loop) For Loop - Range = = n-2 to 0 (stepping backward) sum = get_sum(a,x,i) This is a function call to get_sum x = (b. - sum)/a function get_sum(a,x,i): sum = 0 Initialize the sum For Loop - Range j = 1+1 to j = 0-1 sum = sum + a, X return sum ch4 Now with specific values here is what it would happen in code (not coded this way, but just to explain); This assumes a starting index of 0, n = 4... X- byasa (Do this part outside the loop) For Loop - Range = 1 = 2 to Q_(stepping backward) 1-2: sum = get_sum(a,x,2) X2 = (bz-sum)/an This is a function call to get_sum function get_sum(a,x 2): sum = 0 Initialize the sum For Loop - Range j = 3 to j = 3 = 3 sum = 0 + a2 X return sum sum = get_sum(a,x,1) X; = (b, - sum)/a, This is a function call to get_sum function get_sum(a,x,1); sum = 0 Initialize the sum For Loop-Range j = 2 toj = 3 i = 2: I sum = 0 + a12 X2 i = 3 sum = sum + a, X return sum 1=0 sum = get_sum(a,x,0) Xo = (bo- sum)/a. This is a function call to get_sum function get_sum(a,x,0): sum = 0 Initialize the sum Forl non-Ranne i = 1 to i = 3 sum = get_sum(a,x,2) This is a function call to get_sum X2 = ( bz-sum)/az function get_sum(a,x,2): sum = 0 Initialize the sum For Loop - Range j = 3 toj = 3 - 3: sum -0+ az Xs return sum sum = get_sum(a,x,1) This is a function call to get_sum X; - (by-sum)/a, function get_sum(a,x,1): sum = 0 Initialize the sum For Loop - Range j = 2 toj - 3 2: sum = 0 + a2 X2 1 = 3 sum = sum + ass return sum =0 sum = get_sum(a,x,0) Xo = (bo - sum)/a This is a function call to get_sum function get_sum(a,x,0): sum = 0 Initialize the sum For Loop - Range j = 1 toj = 3 1 = 1 sum = 0 + ao Xi 1 2 sum - sum + ao X2 | = 3 sum = sum + ao X3 return sum
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
