Skip to content

Commit 9d2b176

Browse files
committed
Create QPE.ipynb
1 parent 06e2a88 commit 9d2b176

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

QPE.ipynb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "79c79c89-dc45-4afa-b538-ff145fd4bb8f",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import cirq\n",
11+
"from cirq.contrib.svg import SVGCircuit\n",
12+
"import matplotlib.pyplot as plt\n",
13+
"\n",
14+
"qc = cirq.Circuit()\n",
15+
"q0,q1,q2,q3,q4 = cirq.LineQubit.range(5)\n",
16+
"\n",
17+
"qc.append(cirq.H(q0))\n",
18+
"qc.append(cirq.H(q1))\n",
19+
"qc.append(cirq.H(q2))\n",
20+
"qc.append(cirq.H(q3))\n",
21+
"\n",
22+
"qc.append(cirq.X(q4))\n",
23+
"\n",
24+
"qc.append(cirq.CZ(q3,q4)**(2/3))\n",
25+
"\n",
26+
"qc.append(cirq.CZ(q2,q4)**(4/3))\n",
27+
"\n",
28+
"qc.append(cirq.CZ(q1,q4)**(8/3))\n",
29+
"\n",
30+
"qc.append(cirq.CZ(q0,q4)**(16/3))\n",
31+
"\n",
32+
"qc.append(cirq.qft(q0,q1,q2,q3,inverse=True))\n",
33+
"\n",
34+
"qc.append(cirq.measure(q0,q1,q2,q3))\n",
35+
"\n",
36+
"print()\n",
37+
"print(qc)\n",
38+
"print()\n",
39+
"\n",
40+
"s = cirq.Simulator()\n",
41+
"samples = s.run(qc, repetitions=1000)\n",
42+
"\n",
43+
"cirq.plot_state_histogram(samples, plt.subplot())\n",
44+
"plt.show()\n",
45+
"\n",
46+
"SVGCircuit(qc)\n"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"id": "3b354ec9-a598-44ec-8c57-356dbc1aa8a6",
53+
"metadata": {},
54+
"outputs": [],
55+
"source": []
56+
}
57+
],
58+
"metadata": {
59+
"kernelspec": {
60+
"display_name": "Python 3 (ipykernel)",
61+
"language": "python",
62+
"name": "python3"
63+
},
64+
"language_info": {
65+
"codemirror_mode": {
66+
"name": "ipython",
67+
"version": 3
68+
},
69+
"file_extension": ".py",
70+
"mimetype": "text/x-python",
71+
"name": "python",
72+
"nbconvert_exporter": "python",
73+
"pygments_lexer": "ipython3",
74+
"version": "3.10.12"
75+
}
76+
},
77+
"nbformat": 4,
78+
"nbformat_minor": 5
79+
}

0 commit comments

Comments
 (0)