All problems
Residual Vector
Problem
Compute the residual vector r = b - A*x for a matrix A and vectors x and b with matching dimensions.
Return the residual as a list.
Hint
The residual is zero exactly when A*x equals b.
Test cases
case 1
in: [[[1,1],[1,2],[1,3]],[0,1],[1,2,3]]
expected: [0,0,0]
case 2
in: [[[1,0],[0,1]],[3,-4],[1,1]]
expected: [-2,5]
case 3
in: [[[2,0],[0,3]],[1,1],[4,4]]
expected: [2,1]
case 4
in: [[[1,1],[1,1]],[2,3],[5,5]]
expected: [0,0]
Starter codePython
def residual_vector(A, x, b):
# Your code here
pass4 test cases · run your code against them in the editor