teleportation.ipynb
167 lines
| 31.8 KiB
| text/plain
|
TextLexer
Teleportation
In [5]:
%load_ext sympyprinting
In [6]:
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
In [7]:
a,b = symbols('a b', real=True)
state = Qubit('000')*a + Qubit('001')*b; state
Out[7]:
In [8]:
entangle1_2 = CNOT(1,2)*HadamardGate(1); entangle1_2
Out[8]:
In [9]:
state = qapply(entangle1_2*state); state
Out[9]:
In [10]:
entangle0_1 = HadamardGate(0)*CNOT(0,1); entangle0_1
Out[10]:
In [11]:
circuit_plot(entangle0_1*entangle1_2, nqubits=3)
Out[11]:
In [12]:
state = qapply(entangle0_1*state); state
Out[12]:
In [13]:
result = measure_partial(state, (0,1))
In [14]:
state = (result[2][0]*2).expand(); state
Out[14]:
In [15]:
state = qapply(XGate(2)*state); state
Out[15]: