Question: Write a function that can solve a linear system, A x = b , using the Richardson iteration. Add this function to your HW 2

Write a function that can solve a linear system, Ax=b, using the Richardson iteration. Add this function to your
HW2.py file and call it Richardson it().
The function takes in a matrix A, a right-hand side vector b, a scaling parameter , an allowed tolerance, and a maximum iteration number and returns the approximate solution x. Recall from lecture that the Richardson iteration can be defined as follows:
xk+1=xk+(b-Axk)(1)
Where xk+1 is the next approximate solution to the linear system. You will need to start with an initial guess for x, for now assume this is just the O vector. Let the measure of error at the kth iteration be the 12 norm of the vector Axk - b. Continue the Richardson iteration until either the error is below the input error tolerance or the maximum number of iterations are hit. The function should take the following inputs in this order:
numpy array A : the matrix that defines the linear system
numpy array b: the right hand side vector of the linear system
float omega: the scaling parameter of the Richardson iteration (by default this can be 1)
float epsilon: the error tolerance
int max it: the maximum allowed number of iterations
And produce the following outputs in this order: * numpy array x : the approximate solution to the linear system
int n it: the number of iterations taken to reach solution
float error : the calculated error in the last iteration
Hint: The Richardson iteration converges only if III -All1, so if you are
testing out your method on a matrix, be sul darr is property is satisfied. You can
check the norm of a matrix, A using numpy.linalg.norm(A,ord=2).
 Write a function that can solve a linear system, Ax=b, using

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 Databases Questions!