Question: import numpy as np #from copy import copy 1 ) Use the following forward substitution and back substitution functions def forward _ subs ( G
import numpy as np
#from copy import copy
Use the following forward substitution and back substitution functions
def forwardsubsGb:
rows,cols Gshape
x npzerosrowsdtype float
for i in rangerows:
Gx
for j in rangei:
Gx Gi j xj
xibi Gx Gi i
return x
def backsubsGb:
rows,cols Gshape
x npzerosrowsdtype float
for i in rangerows :
Gx
for j in rangei cols:
Gx Gi j xj
xibi Gx Gi i
returnx
define a function
name : PLUdecomp
inputs : A D numpy array
output : P d numpy array L d numpy array U d numpy array
note : the function should work for square matrices of any size
note : use LU decomposition with pivoting
note : PA LU
def PLUdecompA:
# add code here
returnPLU
define a function
name : solvesystemPLU
inputs : P d numpy array L D numpy array U D numpy array b d numpy array
output : x d numpy array
note : the function should work for square matrices of any size
note : the function should solve the equation Axb where
PALU is the LU decomposition with pivoting of A
note : call the forward subs and back subs functions to solve
def solvesystemPLUPLUb:
x npzerosbshape
# add code here
returnx
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
