All problems
Eigenvalue Certificate Check
Problem
Check whether lam is an eigenvalue of A by testing whether det(A - lam*I) is zero.
Subtract lam along the diagonal, compute the determinant for matrices of size 1, 2, or 3 by cofactor expansion, and return True if the absolute determinant is below 1e-9.
Hint
lam is an eigenvalue exactly when A - lam*I is singular.
Test cases
case 1
in: [[[2,0],[0,3]],2]
expected: true
case 2
in: [[[2,0],[0,3]],4]
expected: false
case 3
in: [[[1,2,3],[0,4,5],[0,0,6]],4]
expected: true
case 4
in: [[[1,2,3],[0,4,5],[0,0,6]],2]
expected: false
case 5
in: [[[7]],7]
expected: true
Starter codePython
def eigenvalue_certificate(A, lam):
# Your code here
pass5 test cases · run your code against them in the editor