All problems
Diagonalization Check
Problem
Check whether A = P*D*inv(P) holds for 2x2 matrices A, P, and D, comparing entries within a tolerance of 1e-9.
Return False if P is singular.
Hint
The columns of P must be eigenvectors matched to the diagonal entries of D.
Test cases
case 1
in: [[[2,0],[0,3]],[[1,0],[0,1]],[[2,0],[0,3]]]
expected: true
case 2
in: [[[4,1],[2,3]],[[1,1],[1,-2]],[[5,0],[0,2]]]
expected: true
case 3
in: [[[4,1],[2,3]],[[1,1],[1,-2]],[[2,0],[0,5]]]
expected: false
case 4
in: [[[1,0],[0,1]],[[1,1],[1,1]],[[1,0],[0,1]]]
expected: false
Starter codePython
def diagonalization_check(A, P, D):
# Your code here
pass4 test cases · run your code against them in the editor