Question: Please solve Question 1 PART B using the code given above. Dont write a different code please just modify the above code. Thank you Question

Please solve Question 1 PART B using the code given above. Dont write a different code please just modify the above code. Thank you
Question 1: Iterative Methods for Linear Systems Consider the following linear system 1012011113211010318x1x2x3x4=6251115 Jacobi Method Initialize the iterative solution vector x01 randomly, or with the zero vector, for k=0 :maxiteration, update every element until convergece for i=1:n xik+1=aij1(bij=iajjxik) \# You can modify this code to answer the following Jacobi's iteration method for solving the system of equations Ax=b. po is the initialization for the iteration. 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 \# Update every component of iterant p for i in range (n) : sumi =b[i]; for j in range (n) : if i=j: : \# Diagonal elements are not included in Jacobi replace by norm of p \# print ("Relative error in iteration", k+1,";, rel error) if rel errorp; \# Example System A1=np.array([[10,1,2,0], [1,11,1,3], [2,1,10,1], [0,3,1,8]], dtype=float ) b=np.array([6,25,11,15],dtype=float) \# Solved by using Jacobi Method x=jacobi(A1,b,np.array([0,,0,0],dtype=f loat ),0.0000001,100) print("The solution is: ", x) TOLERANCE MET BEFORE MAX-ITERATION (A) Modify the code for Jacobi Method to implement the Gauss-Siedel Iteration in Python. Solve the above system by using this method. Exact answer is (1,2,1,1). Stopping criteria (B) Successive overrelaxation (SOR) is another iterative method for solving linear systems. It picks up the next iteration from a weighted sum of the current iteration and the next iteration by Gauss-seidel. Modify the code for Jacobi Method to implement the SOR method in Python and solve the above system again with =1.5. Display the solution of the above system by this method. Question 1: Iterative Methods for Linear Systems Consider the following linear system 1012011113211010318x1x2x3x4=6251115 Jacobi Method Initialize the iterative solution vector x01 randomly, or with the zero vector, for k=0 :maxiteration, update every element until convergece for i=1:n xik+1=aij1(bij=iajjxik) \# You can modify this code to answer the following Jacobi's iteration method for solving the system of equations Ax=b. po is the initialization for the iteration. 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 \# Update every component of iterant p for i in range (n) : sumi =b[i]; for j in range (n) : if i=j: : \# Diagonal elements are not included in Jacobi replace by norm of p \# print ("Relative error in iteration", k+1,";, rel error) if rel errorp; \# Example System A1=np.array([[10,1,2,0], [1,11,1,3], [2,1,10,1], [0,3,1,8]], dtype=float ) b=np.array([6,25,11,15],dtype=float) \# Solved by using Jacobi Method x=jacobi(A1,b,np.array([0,,0,0],dtype=f loat ),0.0000001,100) print("The solution is: ", x) TOLERANCE MET BEFORE MAX-ITERATION (A) Modify the code for Jacobi Method to implement the Gauss-Siedel Iteration in Python. Solve the above system by using this method. Exact answer is (1,2,1,1). Stopping criteria (B) Successive overrelaxation (SOR) is another iterative method for solving linear systems. It picks up the next iteration from a weighted sum of the current iteration and the next iteration by Gauss-seidel. Modify the code for Jacobi Method to implement the SOR method in Python and solve the above system again with =1.5. Display the solution of the above system by this method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
