qerror.ipynb
1 line
| 2.3 KiB
| text/plain
|
TextLexer
Quantum Error Correction
In [2]:
%load_ext sympy_printing
In [3]:
from sympy import sqrt, symbols, Rational
from sympy import expand, Eq, Symbol, simplify, exp, sin
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import *
from sympy.physics.quantum.gate import *
from sympy.physics.quantum.grover import *
from sympy.physics.quantum.qft import QFT, IQFT, Fourier
from sympy.physics.quantum.circuitplot import circuit_plot
5 qubit code
In [4]:
M0 = Z(1)*X(2)*X(3)*Z(4); M0
In [5]:
M1 = Z(2)*X(3)*X(4)*Z(0); M1
In [6]:
M2 = Z(3)*X(4)*X(0)*Z(1); M2
In [7]:
M3 = Z(4)*X(0)*X(1)*Z(2); M3
These operators should mutually commute.
In [7]:
gate_simp(Commutator(M0,M1).doit())
And square to the identity.
In [8]:
for o in [M0,M1,M2,M3]:
display(gate_simp(o*o))
Codewords
In [8]:
zero = Rational(1,4)*(1+M0)*(1+M1)*(1+M2)*(1+M3)*IntQubit(0, 5); zero
In [9]:
qapply(4*zero)
In [10]:
one = Rational(1,4)*(1+M0)*(1+M1)*(1+M2)*(1+M3)*IntQubit(2**5-1, 5); one
In [11]:
qapply(4*one)
The encoding circuit
In [12]:
encoding_circuit = H(3)*H(4)*CNOT(2,0)*CNOT(3,0)*CNOT(4,0)*H(1)*H(4)*\
CNOT(2,1)*CNOT(4,1)*H(2)*CNOT(3,2)*CNOT(4,2)*H(3)*\
H(4)*CNOT(4, 3)*Z(4)*H(4)*Z(4)
In [13]:
circuit_plot(encoding_circuit, nqubits=5, scale=0.5)
In [14]:
represent(4*encoding_circuit, nqubits=5)
In [23]:
%notebook save qerror.ipynb
In [23]:
%notebook load decompose.ipynb