Question: import numpy as np from copy import copy copy your vector norm function here def VNorm ( v , p ) : nrm = 0

import numpy as np
from copy import copy
copy your vector norm function here
def VNorm(v,p):
nrm =0
if p == np.inf:
nrm = np.max(np.abs(v)) # Infinity norm (max absolute value in v)
else:
nrm = np.sum(np.abs(v)**p)**(1/p) # p-norm calculation
return(nrm)
1) define a function
name : Jacobi
inputs : A (2d numpy array) size nxn, positive definite
x0(1d numpy array) starting value
b(1d numpy array) right-hand-side vector
output : x (1d numpy array) approximate solution to Ax=b
k (integer) number of iterations performed
note : do not use the matrix formulation of the algorithm
note : The function should work for any size rectangular array
note : use a tolerance of 1e-15 as a stopping criterion
def Jacobi(A,x0,b):
# add code here
return(x,k)
2) define a function
name : Jacobi_matrix
inputs : A (2d numpy array) size nxn, positive definite
x0(1d numpy array) starting value
b(1d numpy array) right-hand-side vector
output : x (1d numpy array) approximate solution to Ax=b
k (integer) number of iterations performed
note : use the matrix formulation of the algorithm
note : The function should work for any size rectangular array
note : use a tolerance of 1e-15 as a stopping criterion
def Jacobi_matrix(A,x0,b):
# add code here
return(x,k)
3) define a function
name : Gauss_Seidel
inputs : A (2d numpy array) size nxn, positive definite
x0(1d numpy array) starting value
b(1d numpy array) right-hand-side vector
output : x (1d numpy array) approximate solution to Ax=b
k (integer) number of iterations performed
note : do not use the matrix formulation of the algorithm
note : The function should work for any size rectangular array
note : use a tolerance of 1e-15 as a stopping criterion
def Gauss_Seidel(A,x0,b):
# add code here
return(x,k)
4) define a function
name : Gauss_Seidel_matrix
inputs : A (2d numpy array) size nxn, positive definite
x0(1d numpy array) starting value
b(1d numpy array) right-hand-side vector
output : x (1d numpy array) approximate solution to Ax=b
k (integer) number of iterations performed
note : use the matrix formulation of the algorithm
note : The function should work for any size rectangular array
note : use a tolerance of 1e-15 as a stopping criterion
def Gauss_Seidel_matrix(A,x0,b):
# add code here
return(x,k)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!