##// END OF EJS Templates
make sdist flags work again (e.g. --manifest-only)...
make sdist flags work again (e.g. --manifest-only) also removed build_sphinx target, since that was joblib specific

File last commit:

r4637:d919e2ec
r4955:a924f50c
Show More
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]:
$$a {\left|000\right\rangle } + b {\left|001\right\rangle }$$
In [8]:
entangle1_2 = CNOT(1,2)*HadamardGate(1); entangle1_2
Out[8]:
$$CNOT_{1,2} H_{1}$$
In [9]:
state = qapply(entangle1_2*state); state
Out[9]:
$$\frac{1}{2} \sqrt{2} a {\left|000\right\rangle } + \frac{1}{2} \sqrt{2} a {\left|110\right\rangle } + \frac{1}{2} \sqrt{2} b {\left|001\right\rangle } + \frac{1}{2} \sqrt{2} b {\left|111\right\rangle }$$
In [10]:
entangle0_1 = HadamardGate(0)*CNOT(0,1); entangle0_1
Out[10]:
$$H_{0} CNOT_{0,1}$$
In [11]:
circuit_plot(entangle0_1*entangle1_2, nqubits=3)
Out[11]:
<sympy.physics.quantum.circuitplot.CircuitPlot object at 0x3b9fb90>
No description has been provided for this image
In [12]:
state = qapply(entangle0_1*state); state
Out[12]:
$$\frac{1}{2} a {\left|000\right\rangle } + \frac{1}{2} a {\left|001\right\rangle } + \frac{1}{2} a {\left|110\right\rangle } + \frac{1}{2} a {\left|111\right\rangle } + \frac{1}{2} b {\left|010\right\rangle } - \frac{1}{2} b {\left|011\right\rangle } + \frac{1}{2} b {\left|100\right\rangle } - \frac{1}{2} b {\left|101\right\rangle }$$
In [13]:
result = measure_partial(state, (0,1))
In [14]:
state = (result[2][0]*2).expand(); state
Out[14]:
$$\frac{a {\left|110\right\rangle }}{\sqrt{a^{2} + b^{2}} \sqrt{\frac{1}{4} \lvert{\frac{a}{\sqrt{a^{2} + b^{2}}}}\rvert^{2} + \frac{1}{4} \lvert{\frac{b}{\sqrt{a^{2} + b^{2}}}}\rvert^{2}}} + \frac{b {\left|010\right\rangle }}{\sqrt{a^{2} + b^{2}} \sqrt{\frac{1}{4} \lvert{\frac{a}{\sqrt{a^{2} + b^{2}}}}\rvert^{2} + \frac{1}{4} \lvert{\frac{b}{\sqrt{a^{2} + b^{2}}}}\rvert^{2}}}$$
In [15]:
state = qapply(XGate(2)*state); state
Out[15]:
$$\frac{a {\left|010\right\rangle }}{\sqrt{a^{2} + b^{2}} \sqrt{\frac{1}{4} \lvert{\frac{a}{\sqrt{a^{2} + b^{2}}}}\rvert^{2} + \frac{1}{4} \lvert{\frac{b}{\sqrt{a^{2} + b^{2}}}}\rvert^{2}}} + \frac{b {\left|110\right\rangle }}{\sqrt{a^{2} + b^{2}} \sqrt{\frac{1}{4} \lvert{\frac{a}{\sqrt{a^{2} + b^{2}}}}\rvert^{2} + \frac{1}{4} \lvert{\frac{b}{\sqrt{a^{2} + b^{2}}}}\rvert^{2}}}$$