All problems
Richardson Iteration Step
Problem
Perform one Richardson iteration step for the system A*x = b:
x_new = x + omega * (b - A*x)
The scalar omega controls the step size and convergence.
Hint
The update is a step of size omega along the residual direction.
Test cases
case 1
in: [[[4,1],[1,3]],[1,2],[0,0],0.25]
expected: [0.25,0.5]
case 2
in: [[[1,0],[0,1]],[2,4],[1,1],0.5]
expected: [1.5,2.5]
case 3
in: [[[2,0],[0,2]],[0,0],[1,2],1]
expected: [-1,-2]
case 4
in: [[[1,0],[0,1]],[1,1],[3,4],0]
expected: [3,4]
Starter codePython
def richardson_step(A, b, x, omega):
# Your code here
pass4 test cases · run your code against them in the editor