Skip to content

Commit 41e2a2b

Browse files
committed
start working on the code
1 parent 4ff511a commit 41e2a2b

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

Hamiltonian_simulation.ipynb

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,50 @@
196196
"The code\n",
197197
"</h3>\n",
198198
"\n",
199-
"Before going into details"
199+
"Before going into Qiskit code, note that:\n",
200+
"\n",
201+
"\\begin{equation*}\n",
202+
"H_y = u2(\\frac{\\pi}{2}, \\frac{\\pi}{2})\n",
203+
"\\qquad \\qquad\n",
204+
"H = u2(0, \\pi)\n",
205+
"\\\\\n",
206+
"u2(\\varphi, \\lambda) = \\frac{1}{\\sqrt{2}}\n",
207+
"\\begin{pmatrix}\n",
208+
"1 & -e^{i\\lambda} \\\\\n",
209+
"e^{i\\varphi} & e^{i(\\varphi + \\lambda)}\n",
210+
"\\end{pmatrix}\n",
211+
"\\end{equation*}\n",
212+
"\n",
213+
"So, in the code we will use $u2(\\frac{\\pi}{2}, \\frac{\\pi}{2})$ gate for implementing $H_y$. For $H$ gate we can use either `.h()` or `.u2()` and for better readability we will use `.h()` in the code.\n",
214+
"\n",
215+
"Firstly we should define what Hamiltonian we want to simulate. Let's do simulation for this Hamiltonian:\n",
216+
"\n",
217+
"$$H = 2 \\cdot \\sigma_x \\otimes \\sigma_z \\otimes \\sigma_x + 5 \\cdot \\sigma_z \\otimes \\sigma_y \\otimes I + 7 \\cdot I \\otimes \\sigma_y \\otimes \\sigma_z$$\n",
218+
"\n",
219+
"It can be shown that all three terms commute to each other, thus we can write $e^{iHt}$ in this form:\n",
220+
"\n",
221+
"$$e^{iHt} = e^{i2 \\cdot \\sigma_x \\otimes \\sigma_z \\otimes \\sigma_x t} \\; \\cdot \\; e^{i5 \\cdot \\sigma_z \\otimes \\sigma_y \\otimes I t} \\; \\cdot \\; e^{i7 \\cdot I \\otimes \\sigma_y \\otimes \\sigma_z t}$$\n",
222+
"\n",
223+
"This will help us to not worry about the Trotterization procidure and will let us to draw simpler circuit at the end. Here we start coding:"
224+
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": null,
229+
"metadata": {},
230+
"outputs": [],
231+
"source": [
232+
"from qiskit import *\n",
233+
"from numpy import pi as PI\n",
234+
"\n",
235+
"# put the Hamiltonian in the dictionary\n",
236+
"\n",
237+
"hamiltonian = {\"XZX\": 2, \"ZYI\": 5, \"IYZ\": 7}\n",
238+
"\n",
239+
"# define function for ZZ..Z exponantiation\n",
240+
"def exp_all_z(quantum_register, qubit_list, t=1):\n",
241+
" \n",
242+
" "
200243
]
201244
},
202245
{

0 commit comments

Comments
 (0)