Question: def jacobi ( A , b , p 0 , tol, maxIter = 1 0 0 ) : n = len ( A ) p

def jacobi(A, b, p0, tol, maxIter=100):
n=len(A)
p = p0
for k in range(maxIter):
p_old = p.copy() # In python assignment is not the same as
copyfor i in range(n):
sumi = b[i];
for j in range(n):
if i==j: # Diagonal elements are not included in
Jacobi
continue;
sumi = sumi - A[i,j]* p_old[j]
p[i]= sumi/A[i,i]
rel_error = np.linalg.norm(p-p_old)/n # Actually 'n' should be
replace by norm of pif rel_error0.00001([10,-1,2,0],[-1,11,-1,3],[2,-1,10,-1],[0,3,-1,8])([x1],[x2],[x3],[x4])=([6],[25],[-11],[15])=1.5f(x1,x2)=x12+x22-2x1+4x2+81,2,-1,1
def jacobi ( A , b , p 0 , tol, maxIter = 1 0 0 )

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!