The most general quantum black box is a unitary operator , defined by the property that applying , and then the adjoint , does nothing:

The adjoint is shorthand for the complex conjugate of each matrix entry, followed by the transpose, .

Write a function which checks if an array of complex numbers is unitary.

Tip. You will find the np.identity, np.allclose, np.conjugate and np.transpose methods useful.

def unitary_check(operator):
"""Checks if a complex-valued matrix is unitary.
Args:
operator (array[complex]): A square complex-valued array.
Returns:
bool: Whether the matrix is unitary or not.
"""
##################
# YOUR CODE HERE #
##################
return True # MODIFY THIS

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Describe how unitarity arises from preservation of marginal probabilities.