For two Hermitian operators a in the Hilbert space , we define the trace distance as half of the -distance between and :

Equivalenty, if has eigendecomposition , we can calculate the trace distance as

With this in mind, let us build a function that calculates the trace distance.

Fill in the code to calculate the trace distance between two operators.

Hint

The function np.linalg.eigvals may be helpful.

or to submit your code

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

Learning Objectives:

  • Define and calculate the trace distance between two probability distributions.
  • State important properties of the trace distance.