All problems
Unitary Check 2x2
Problem
Return True if the complex 2x2 matrix A is unitary: A^H * A must equal the identity within 1e-9.
Entries are [real, imaginary] pairs; A^H is the conjugate transpose.
Hint
Unitary matrices preserve the complex inner product; their columns form an orthonormal basis.
Test cases
case 1
in: [[[[1,0],[0,0]],[[0,0],[1,0]]]]
expected: true
case 2
in: [[[[0,1],[0,0]],[[0,0],[0,1]]]]
expected: true
case 3
in: [[[[1,1],[0,0]],[[0,0],[1,0]]]]
expected: false
case 4
in: [[[[0,1],[0,0]],[[1,0],[0,0]]]]
expected: false
Starter codePython
def is_unitary_2x2(A):
# Your code here
pass4 test cases · run your code against them in the editor