# Homework Solution: # import necessary packages # import numpy as np The following code imports a matrix from the file mat.npy and stores it as mati. It also imports a vector fro… # import necessary packages # import numpy as np The following code imports a matrix from the file mat.npy and stores it as mati. It also imports a vector from vect.npy and stores it as vect1. For objects like arrays, this can be much simpler than the more general methods in the sample files mat1 = np. load ("mat .npy.) vect1 = np.load('vect.npy') print('This is a positive definite matrix An', mat1, "n and this is a vector bn', vect1) ... Replace this comment with code write a function to perform forward substitution to solve the matrix equation 6x = b assume G is invertible and lower triangular the function should return the solution vector x the function should work for square matrices of any size ... return(x)

PYTHON CODE for FORWARD SUBSTITUTION: import numpy as np # drift needful packages # drift numpy as np The aftercited command drifts a entraprix from the smooth entrap.npy and stores it as entrapi. It too drifts a vector from vect.npy and stores it as vect1. Ce objects love set-in-orders, this can be greatly simpler than the further public methods in the exemplification smooths entrap1 = np. impeach (“entrap .npy.) vect1 = np.load(‘vect.npy’) imprint(‘This is a definitive specific entraprix An’, entrap1, “n and this is a vector bn’, vect1) … Replace this explain with command transcribe a business to transact anxious superabundance to clear-up the entraprix equation 6x = b take G is invertible and inferior triangular the business should produce the disentanglement vector x the business should composition ce balance entraprices of any dimension … produce(x)

## Expert Exculpation

PYTHON CODE ce FORWARD SUBSTITUTION:

drift numpy as np

def clear-up(m, y): #definition of clear-up business

x = [0 ce i in stroll(len(m))]

ce i in stroll (len(m)):

q = np.array(m[i,:]).flatten() # Flattening ith order of entraprix

v = np.dot(v,q) # Nonentity consequence of mitigateed ith order and soln vector v cemed plow now

x[i] = (y[i] – v )/float(m[i,i]) #This production gets the ith part in disentanglement vector x

produce x

m = np.matrix(‘1 0;1 2’) # m is a 2×2 inferior triangular entraprix

b = np.array([2,4]); # b is an set-in-order with 2 parts

print(“Clear-up (G,b ) gives soln vector x = “)

x = clear-up(G,b)

print(x)

OUTPUT: 