Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-290

Eigenvalue Pair Certificate Check

Problem

Check whether a pair of numbers are the eigenvalues of the 2x2 matrix A.

Two numbers are exactly the eigenvalues when their sum equals tr(A) and their product equals det(A), so test both identities within 1e-9. Return True if both hold.

Hint

The characteristic polynomial is lambda^2 - tr(A)*lambda + det(A), so sum and product certify the roots.

Test cases

case 1
in: [[[2,0],[0,3]],[3,2]]
expected: true
case 2
in: [[[1,2],[2,1]],[3,-1]]
expected: true
case 3
in: [[[1,2],[3,4]],[5,-2]]
expected: false
case 4
in: [[[1,2],[3,4]],[4,-2]]
expected: false
case 5
in: [[[0,-1],[1,0]],[1,-1]]
expected: false
Starter codePython
def eigenvalue_pair_check(A, eigenvalues):
    # Your code here
    pass

5 test cases · run your code against them in the editor