Skip to content

Commit b194dc2

Browse files
Minor tutorial updates (#24)
1 parent 8bb5acd commit b194dc2

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

docs/tutorials/01_chemistry_hamiltonian.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@
317317
"source": [
318318
"First, we will transform the counts into a bitstring matrix and probability array for post-processing.\n",
319319
"\n",
320-
"Each row in the matrix represents one unique bitstring. Since qubits are normally indexed from the right of a bitstring, column ``0`` represents qubit ``N-1``, and column ``N-1`` represents qubit ``0``, where ``N`` is the number of qubits.\n",
320+
"Each row in the matrix represents one unique bitstring. Since qubits are normally indexed from the right of a bitstring, column ``0`` represents qubit $N-1$, and column $N-1$ represents qubit ``0``, where $N$ is the number of qubits.\n",
321321
"\n",
322-
"The alpha particles are represented in the column range ``[N / 2, N]``, and the beta particles are represented in the column range ``[0, N / 2)``."
322+
"The alpha particles are represented in the column range $[N / 2, N]$, and the beta particles are represented in the column range $[0, N / 2)$."
323323
]
324324
},
325325
{

docs/tutorials/02_qubit_hamiltonian.ipynb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Ground state energy estimation of a spin (qubit) Hamiltonian\n",
7+
"# Minimum eigenvalue estimation of a spin (qubit) Hamiltonian\n",
88
"\n",
9-
"In this tutorial we implement a [Qiskit pattern](https://docs.quantum.ibm.com/guides/intro-to-patterns) showing how to post-process quantum samples to compute an approximation to the ground state of a ``22``-site XX-Z spin-1/2 chain and two-point correlators. We will follow a sample-based quantum diagonalization approach[[1]](https://arxiv.org/abs/2405.05068).\n",
9+
"In this tutorial we implement a [Qiskit pattern](https://docs.quantum.ibm.com/guides/intro-to-patterns) showing how to post-process quantum samples to approximate the minimum eigenvalue and spin-spin correlators for a ``22``-site XX-Z spin-1/2 chain. We will follow a sample-based quantum diagonalization approach [[1]](https://arxiv.org/abs/2405.05068).\n",
1010
"\n",
1111
"While a Qiskit pattern typically involves 4 steps, the aim of this tutorial is to focus on the post-processing of the samples obtained from a quantum circuit whose support coincides with that of the ground state. Consequently, we generate a synthetic set of bitstrings to define the subspace and do not design an ansatz nor sample from a quantum circuit in this tutorial.\n",
1212
"\n",
@@ -20,7 +20,8 @@
2020
" - N/A: Will generate synthetic quantum samples\n",
2121
"4. **Step 4: Post-process results**\n",
2222
" - Project the Hamiltonian onto the subspace spanned by the samples\n",
23-
" - Diagonalize the Hamiltonian in the subspace to approximate the ground state"
23+
" - Diagonalize the Hamiltonian in the subspace to approximate the ground state\n",
24+
" - Calculate spin-spin correlators for each site, $l$"
2425
]
2526
},
2627
{
@@ -39,7 +40,7 @@
3940
"of many-body Hamiltonians can be written as the linear combination of polynomially-many \n",
4041
"Pauli strings, including interacting-electron Hamiltonians, spin Hamiltonians, etc.\n",
4142
"\n",
42-
"In particular, we consider the ground state properties of the antiferromagnetic XX-Z spin-1/2 chain\n",
43+
"In particular, we consider the properties of the antiferromagnetic XX-Z spin-1/2 chain\n",
4344
"with $L = 22$ sites:\n",
4445
"$$\n",
4546
"H = \\sum_{\\langle i, j \\rangle} J_{xy}\\left( \\sigma^x_i\\sigma^x_j + \\sigma^y_i\\sigma^y_j \\right) + \\sigma^z_i\\sigma^z_j.\n",
@@ -231,9 +232,9 @@
231232
"from qiskit_addon_sqd.qubit import solve_qubit\n",
232233
"\n",
233234
"scipy_kwargs = {\"k\": 4, \"which\": \"SA\"}\n",
234-
"energies, eigenstates = solve_qubit(bitstring_matrix, hamiltonian, verbose=True, **scipy_kwargs)\n",
235+
"eigenvals, eigenstates = solve_qubit(bitstring_matrix, hamiltonian, verbose=True, **scipy_kwargs)\n",
235236
"\n",
236-
"ground_state = eigenstates[:, 0]"
237+
"min_eval = eigenstates[:, 0]"
237238
]
238239
},
239240
{
@@ -250,7 +251,7 @@
250251
}
251252
],
252253
"source": [
253-
"print(energies)"
254+
"print(eigenvals)"
254255
]
255256
},
256257
{
@@ -296,21 +297,21 @@
296297
" pstr[i] = \"X\"\n",
297298
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
298299
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
299-
" s_x[i] += np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state)\n",
300+
" s_x[i] += np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval)\n",
300301
"\n",
301302
" # Sigma_y\n",
302303
" pstr = [\"I\" for i in range(num_spins)]\n",
303304
" pstr[i] = \"Y\"\n",
304305
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
305306
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
306-
" s_y[i] += np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state)\n",
307+
" s_y[i] += np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval)\n",
307308
"\n",
308309
" # Sigma_z\n",
309310
" pstr = [\"I\" for i in range(num_spins)]\n",
310311
" pstr[i] = \"Z\"\n",
311312
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
312313
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
313-
" s_z[i] += np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state)"
314+
" s_z[i] += np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval)"
314315
]
315316
},
316317
{
@@ -377,7 +378,7 @@
377378
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
378379
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
379380
" c_x[distance - 1] += (\n",
380-
" np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state) - s_x[i] * s_x[j_wrap]\n",
381+
" np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval) - s_x[i] * s_x[j_wrap]\n",
381382
" )\n",
382383
"\n",
383384
" # Sigma_y Sigma_y\n",
@@ -387,7 +388,7 @@
387388
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
388389
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
389390
" c_y[distance - 1] += (\n",
390-
" np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state) - s_y[i] * s_y[j_wrap]\n",
391+
" np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval) - s_y[i] * s_y[j_wrap]\n",
391392
" )\n",
392393
"\n",
393394
" # Sigma_z Sigma_z\n",
@@ -397,7 +398,7 @@
397398
" pauli_op = SparsePauliOp(\"\".join(pstr))\n",
398399
" sparse_op = project_operator_to_subspace(bitstring_matrix, pauli_op)\n",
399400
" c_z[distance - 1] += (\n",
400-
" np.real(np.conjugate(ground_state).T @ sparse_op @ ground_state) - s_z[i] * s_z[j_wrap]\n",
401+
" np.real(np.conjugate(min_eval).T @ sparse_op @ min_eval) - s_z[i] * s_z[j_wrap]\n",
401402
" )\n",
402403
"\n",
403404
" distance_counts[distance - 1] += 1\n",

0 commit comments

Comments
 (0)