channels.bitflip

Implements the bitflip quantum gate channel.

Functions

bitflip([input_mat, prob])

Apply the bitflip quantum channel to a state or return the Kraus operators.

Module Contents

channels.bitflip.bitflip(input_mat=None, prob=0)

Apply the bitflip quantum channel to a state or return the Kraus operators.

The bitflip channel is a quantum channel that flips a qubit from \(|0\rangle\) to \(|1\rangle\) and from \(|1\rangle\) to \(|0\rangle\) with probability \(p\). It is defined by the following operation:

\[\mathcal{E}(\rho) = (1-p) \rho + p X \rho X\]

where \(X\) is the Pauli-X (NOT) gate given by:

\[\begin{split}X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\end{split}\]

The Kraus operators for this channel are:

\[\begin{split}K_0 = \sqrt{1-p} \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, \quad K_1 = \sqrt{p} \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\end{split}\]

Examples

We can generate the Kraus operators for the bitflip channel with probability 0.3:

from toqito.channels import bitflip

bitflip(prob=0.3)
[array([[0.83666003, 0.        ],
        [0.        , 0.83666003]]),
 array([[0.        , 0.54772256],
        [0.54772256, 0.        ]])]

We can also apply the bitflip channel to a quantum state. For the state \(|0\rangle\), the bitflip channel with probability 0.3 produces:

import numpy as np
from toqito.channels import bitflip

rho = np.array([[1, 0], [0, 0]])  # |0><0|
bitflip(rho, prob=0.3)
array([[0.7+0.j, 0. +0.j],
       [0. +0.j, 0.3+0.j]])

References

Parameters:
  • input_mat (numpy.ndarray | None) – A matrix or state to apply the channel to. If None, returns the Kraus operators.

  • prob (float) – The probability of a bitflip occurring.

Returns:

Either the Kraus operators of the bitflip channel if input_mat is None, or the result of applying the channel to input_mat.

Return type:

numpy.ndarray