<h1>Quantum Error Correction</h1>

## Imports


```python
%matplotlib inline
```


```python
from IPython.display import display
```


```python
from sympy import init_printing
init_printing(use_latex=True)
```


```python
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
```

<h2>5 qubit code</h2>


```python
M0 = Z(1)*X(2)*X(3)*Z(4)
M0
```


```python
M1 = Z(2)*X(3)*X(4)*Z(0)
M1
```


```python
M2 = Z(3)*X(4)*X(0)*Z(1)
M2
```


```python
M3 = Z(4)*X(0)*X(1)*Z(2)
M3
```

These operators should mutually commute.


```python
gate_simp(Commutator(M0,M1).doit())
```

And square to the identity.


```python
for o in [M0,M1,M2,M3]:
    display(gate_simp(o*o))
```

<h2>Codewords</h2>


```python
zero = Rational(1,4)*(1+M0)*(1+M1)*(1+M2)*(1+M3)*IntQubit(0, 5)
zero
```


```python
qapply(4*zero)
```


```python
one = Rational(1,4)*(1+M0)*(1+M1)*(1+M2)*(1+M3)*IntQubit(2**5-1, 5)
one
```


```python
qapply(4*one)
```

<h2>The encoding circuit</h2>


```python
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)
```


```python
circuit_plot(encoding_circuit, nqubits=5, scale=0.5);
```


```python
represent(4*encoding_circuit, nqubits=5)
```

52502336e531e2c8e3c324097fa06657256dc1a2
ipynb
Jupyter Notebook
notebooks/error_correction.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-17T22:44:27.000Z
2022-03-28T06:26:46.000Z
notebooks/error_correction.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T05:16:41.000Z
2018-09-22T03:08:29.000Z
notebooks/error_correction.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T04:22:19.000Z
2022-03-28T06:25:21.000Z
Qwen/Qwen-72B
1. YES
2. YES