Skip to content

Commit

Permalink
Rename final_expval to reconstructed_expval
Browse files Browse the repository at this point in the history
  • Loading branch information
garrison committed Sep 16, 2024
1 parent 58e8588 commit c23d951
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions docs/how-tos/how_to_specify_cut_wires.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@
"metadata": {},
"outputs": [],
"source": [
"reconstructed_expvals = reconstruct_expectation_values(\n",
"reconstructed_expval_terms = reconstruct_expectation_values(\n",
" results,\n",
" coefficients,\n",
" subobservables,\n",
")\n",
"final_expval = np.dot(reconstructed_expvals, observable.coeffs)"
"reconstructed_expval = np.dot(reconstructed_expval_terms, observable.coeffs)"
]
},
{
Expand All @@ -380,11 +380,11 @@
"exact_expval = (\n",
" estimator.run([(qc_0.decompose(\"cut_wire\"), observable)]).result()[0].data.evs\n",
")\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(final_expval, 8))}\")\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(reconstructed_expval, 8))}\")\n",
"print(f\"Exact expectation value: {np.round(exact_expval, 8)}\")\n",
"print(f\"Error in estimation: {np.real(np.round(final_expval-exact_expval, 8))}\")\n",
"print(f\"Error in estimation: {np.real(np.round(reconstructed_expval-exact_expval, 8))}\")\n",
"print(\n",
" f\"Relative error in estimation: {np.real(np.round((final_expval-exact_expval) / exact_expval, 8))}\"\n",
" f\"Relative error in estimation: {np.real(np.round((reconstructed_expval-exact_expval) / exact_expval, 8))}\"\n",
")"
]
}
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@
"from qiskit_addon_cutting import reconstruct_expectation_values\n",
"\n",
"# Get expectation values for each observable term\n",
"reconstructed_expvals = reconstruct_expectation_values(\n",
"reconstructed_expval_terms = reconstruct_expectation_values(\n",
" results,\n",
" coefficients,\n",
" subobservables,\n",
")\n",
"\n",
"# Reconstruct final expectation value\n",
"final_expval = np.dot(reconstructed_expvals, observable.coeffs)"
"reconstructed_expval = np.dot(reconstructed_expval_terms, observable.coeffs)"
]
},
{
Expand Down Expand Up @@ -409,11 +409,11 @@
"\n",
"estimator = EstimatorV2()\n",
"exact_expval = estimator.run([(qc, observable)]).result()[0].data.evs\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(final_expval, 8))}\")\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(reconstructed_expval, 8))}\")\n",
"print(f\"Exact expectation value: {np.round(exact_expval, 8)}\")\n",
"print(f\"Error in estimation: {np.real(np.round(final_expval-exact_expval, 8))}\")\n",
"print(f\"Error in estimation: {np.real(np.round(reconstructed_expval-exact_expval, 8))}\")\n",
"print(\n",
" f\"Relative error in estimation: {np.real(np.round((final_expval-exact_expval) / exact_expval, 8))}\"\n",
" f\"Relative error in estimation: {np.real(np.round((reconstructed_expval-exact_expval) / exact_expval, 8))}\"\n",
")"
]
}
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/02_gate_cutting_to_reduce_circuit_depth.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@
"source": [
"from qiskit_addon_cutting import reconstruct_expectation_values\n",
"\n",
"reconstructed_expvals = reconstruct_expectation_values(\n",
"reconstructed_expval_terms = reconstruct_expectation_values(\n",
" results,\n",
" coefficients,\n",
" observable.paulis,\n",
")\n",
"# Reconstruct final expectation value\n",
"final_expval = np.dot(reconstructed_expvals, observable.coeffs)"
"reconstructed_expval = np.dot(reconstructed_expval_terms, observable.coeffs)"
]
},
{
Expand Down Expand Up @@ -428,11 +428,11 @@
"\n",
"estimator = EstimatorV2()\n",
"exact_expval = estimator.run([(circuit, observable)]).result()[0].data.evs\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(final_expval, 8))}\")\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(reconstructed_expval, 8))}\")\n",
"print(f\"Exact expectation value: {np.round(exact_expval, 8)}\")\n",
"print(f\"Error in estimation: {np.real(np.round(final_expval-exact_expval, 8))}\")\n",
"print(f\"Error in estimation: {np.real(np.round(reconstructed_expval-exact_expval, 8))}\")\n",
"print(\n",
" f\"Relative error in estimation: {np.real(np.round((final_expval-exact_expval) / exact_expval, 8))}\"\n",
" f\"Relative error in estimation: {np.real(np.round((reconstructed_expval-exact_expval) / exact_expval, 8))}\"\n",
")"
]
}
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/03_wire_cutting_via_move_instruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@
"source": [
"from qiskit_addon_cutting import reconstruct_expectation_values\n",
"\n",
"reconstructed_expvals = reconstruct_expectation_values(\n",
"reconstructed_expval_terms = reconstruct_expectation_values(\n",
" results,\n",
" coefficients,\n",
" subobservables,\n",
")\n",
"final_expval = np.dot(reconstructed_expvals, observable.coeffs)"
"reconstructed_expval = np.dot(reconstructed_expval_terms, observable.coeffs)"
]
},
{
Expand Down Expand Up @@ -500,11 +500,11 @@
"\n",
"estimator = EstimatorV2()\n",
"exact_expval = estimator.run([(qc_0, observable)]).result()[0].data.evs\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(final_expval, 8))}\")\n",
"print(f\"Reconstructed expectation value: {np.real(np.round(reconstructed_expval, 8))}\")\n",
"print(f\"Exact expectation value: {np.round(exact_expval, 8)}\")\n",
"print(f\"Error in estimation: {np.real(np.round(final_expval-exact_expval, 8))}\")\n",
"print(f\"Error in estimation: {np.real(np.round(reconstructed_expval-exact_expval, 8))}\")\n",
"print(\n",
" f\"Relative error in estimation: {np.real(np.round((final_expval-exact_expval) / exact_expval, 8))}\"\n",
" f\"Relative error in estimation: {np.real(np.round((reconstructed_expval-exact_expval) / exact_expval, 8))}\"\n",
")"
]
}
Expand Down

0 comments on commit c23d951

Please sign in to comment.