teleportation.ipynb
1 line
| 1.5 KiB
| text/plain
|
TextLexer
Teleportation
In [1]:
%load_ext sympy_printing
In [2]:
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 [3]:
a,b = symbols('ab', real=True)
state = Qubit('000')*a + Qubit('001')*b; state
In [4]:
entangle1_2 = CNOT(1,2)*HadamardGate(1); entangle1_2
In [5]:
state = qapply(entangle1_2*state); state
In [6]:
entangle0_1 = HadamardGate(0)*CNOT(0,1); entangle0_1
In [7]:
circuit_plot(entangle0_1*entangle1_2, nqubits=3)
In [8]:
state = qapply(entangle0_1*state); state
In [10]:
result = measure_partial(state, (0,1))
In [11]:
state = (result[2][0]*2).expand(); state
In [12]:
state = qapply(XGate(2)*state); state
In [13]:
%notebook save teleportation.ipynb
In [18]: