Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-223

Schur Form 2x2 Check

Problem

Check whether Q puts the 2x2 matrix A into Schur form: Q must be orthogonal and T = Q^T*A*Q must be upper triangular (all within 1e-9).

If both conditions hold, return T; otherwise return None.

Hint

The Schur decomposition always exists for real matrices with real eigenvalues; Q's first column is an eigenvector.

Test cases

case 1
in: [[[2,0],[0,3]],[[1,0],[0,1]]]
expected: [[2,0],[0,3]]
case 2
in: [[[4,1],[2,3]],[[0.7071067811865475,-0.7071067811865475],[0.7071067811865475,0.7071067811865475]]]
expected: [[5,-1],[0,2]]
case 3
in: [[[2,1],[1,2]],[[1,0],[0,1]]]
expected: null
case 4
in: [[[2,0],[0,3]],[[1,1],[0,1]]]
expected: null
Starter codePython
def schur_check_2x2(A, Q):
    # Your code here
    pass

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