Created
October 17, 2019 13:20
-
-
Save gyu-don/8e16465a8c0bbc527ba5bdd3a8f506f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from blueqat import Circuit, pauli, vqe | |
from blueqat.pauli import qubo_bit as q | |
from math import pi | |
import numpy as np | |
def an(index): | |
return 0.5 * pauli.X[index] + 0.5j * pauli.Y[index] | |
def cr(index): | |
return 0.5 * pauli.X[index] - 0.5j * pauli.Y[index] | |
op = (cr(1) * an(0) + cr(0) * an(1)).to_expr().simplify() | |
print(op) | |
x = [] | |
y00 = [] | |
y01 = [] | |
y10 = [] | |
y11 = [] | |
evos = [term.get_time_evolution() for term in op.terms] | |
for i in range(100): | |
c = Circuit().h[0].cx[0, 1].x[1] | |
for evo in evos: | |
evo(c, i / 100 * pi) | |
c.rz(i / 100 * pi)[1] | |
for evo in evos: | |
evo(c, i / 100 * pi) | |
c.rz(i / 100 * pi)[1] | |
state = c.run() | |
_a, _b, _c, _d = list(np.abs(state) ** 2) | |
x.append(i) | |
y00.append(_a) | |
y10.append(_b) | |
y01.append(_c) | |
y11.append(_d) | |
import matplotlib.pyplot as plt | |
plt.plot(x, y00, label='|00>') | |
plt.plot(x, y10, label='|10>') | |
plt.plot(x, y01, label='|01>') | |
plt.plot(x, y11, label='|11>') | |
plt.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment