:py:mod:`channel_metrics.diamond_norm` ====================================== .. py:module:: channel_metrics.diamond_norm .. autoapi-nested-parse:: Compute the diamond norm between two quantum channels. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: channel_metrics.diamond_norm.diamond_norm .. py:function:: diamond_norm(choi_1, choi_2) Return the diamond norm distance between two quantum channels. The calculation uses the simplified semidefinite program of Watrous in :cite:`Watrous_2009_Semidefinite`. This function has been adapted from :cite:`Rigetti_2022_Forest`. .. note:: This calculation becomes very slow for 4 or more qubits. .. rubric:: Examples Consider the depolarizing and identity channels in a 2-dimensional space. The depolarizing channel parameter is set to 0.2: >>> import numpy as np >>> from toqito.channels import depolarizing >>> from toqito.channel_metrics import diamond_norm >>> choi_depolarizing = depolarizing(dim=2, param_p=0.2) >>> choi_identity = np.identity(2**2) >>> dn = diamond_norm(choi_depolarizing, choi_identity) >>> print("Diamond norm between depolarizing and identity channels: ", '%.2f' % dn) Diamond norm between depolarizing and identity channels: -0.00 .. note:: You do not need to use `'%.2f' %` when you use this function. We use this to format our output such that `doctest` compares the calculated output to the expected output upto two decimal points only. The accuracy of the solvers can calculate the `float` output to a certain amount of precision such that the value deviates after a few digits of accuracy. Similarly, we can compute the diamond norm between the dephasing channel (with parameter 0.3) and the identity channel: >>> import numpy as np >>> from toqito.channels import dephasing >>> from toqito.channel_metrics import diamond_norm >>> choi_dephasing = dephasing(dim=2) >>> choi_identity = np.identity(2**2) >>> dn = diamond_norm(choi_dephasing, choi_identity) >>> print("Diamond norm between dephasing and identity channels: ", '%.2f' % dn) Diamond norm between dephasing and identity channels: -0.00 .. note:: You do not need to use `'%.2f' %` when you use this function. We use this to format our output such that `doctest` compares the calculated output to the expected output upto two decimal points only. The accuracy of the solvers can calculate the `float` output to a certain amount of precision such that the value deviates after a few digits of accuracy. .. rubric:: References .. bibliography:: :filter: docname in docnames :raises ValueError: If matrices are not of equal dimension. :raises ValueError: If matrices are not square. :param choi_1: A 4**N by 4**N matrix (where N is the number of qubits). :param choi_2: A 4**N by 4**N matrix (where N is the number of qubits).