Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions qiskit/aqua/general/linear_systems_of_equations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"from qiskit.aqua import run_algorithm\n",
"from qiskit.aqua.input import LinearSystemInput\n",
"from qiskit.quantum_info import state_fidelity\n",
"from qiskit.aqua.algorithms.classical import ExactLPsolver\n",
"from qiskit.aqua.algorithms.classical import ExactLSsolver\n",
"import numpy as np"
]
},
Expand Down Expand Up @@ -147,7 +147,7 @@
"result = run_algorithm(params)\n",
"print(\"solution \", np.round(result['solution'], 5))\n",
"\n",
"result_ref = ExactLPsolver(matrix, vector).run()\n",
"result_ref = ExactLSsolver(matrix, vector).run()\n",
"print(\"classical solution \", np.round(result_ref['solution'], 5))\n",
"\n",
"print(\"probability %f\" % result['probability_result'])\n",
Expand Down Expand Up @@ -186,7 +186,7 @@
"result = run_algorithm(params2)\n",
"print(\"solution \", np.round(result['solution'], 5))\n",
"\n",
"result_ref = ExactLPsolver(matrix, vector).run()\n",
"result_ref = ExactLSsolver(matrix, vector).run()\n",
"print(\"classical solution \", np.round(result_ref['solution'], 5))\n",
"\n",
"print(\"probability %f\" % result['probability_result'])\n",
Expand Down Expand Up @@ -252,7 +252,13 @@
" 'name': 'LinearSystemInput',\n",
" 'matrix': matrix,\n",
" 'vector': vector\n",
"}"
"}\n",
"params3['reciprocal'] = {\n",
" 'negative_evals': True\n",
"}\n",
"params3['eigs'] = {\n",
" 'negative_evals': True\n",
"}\n"
]
},
{
Expand All @@ -264,18 +270,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"solution [0.22147+0.j 0.22034-0.j]\n",
"solution [0.14223-5.e-05j 0.28622+7.e-05j]\n",
"classical solution [0.14286 0.28571]\n",
"probability 0.424639\n",
"fidelity 0.898454\n"
"probability 0.000316\n",
"fidelity 0.999994\n"
]
}
],
"source": [
"result = run_algorithm(params3)\n",
"print(\"solution \", np.round(result['solution'], 5))\n",
"\n",
"result_ref = ExactLPsolver(matrix, vector).run()\n",
"result_ref = ExactLSsolver(matrix, vector).run()\n",
"print(\"classical solution \", np.round(result_ref['solution'], 5))\n",
"\n",
"print(\"probability %f\" % result['probability_result'])\n",
Expand All @@ -286,7 +292,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Compared to the the first example, the circuit depth is increased approximately by a factor 2,5"
"Compared to the the first example, the circuit depth is increased approximately by a factor of 6"
]
},
{
Expand All @@ -298,8 +304,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"circuit_width 7\n",
"circuit_depth 30254\n"
"circuit_width 11\n",
"circuit_depth 73313\n"
]
}
],
Expand Down Expand Up @@ -378,7 +384,7 @@
"result = run_algorithm(params4)\n",
"print(\"solution \", np.round(result['solution'], 5))\n",
"\n",
"result_ref = ExactLPsolver(matrix, vector).run()\n",
"result_ref = ExactLSsolver(matrix, vector).run()\n",
"print(\"classical solution \", np.round(result_ref['solution'], 5))\n",
"\n",
"print(\"probability %f\" % result['probability_result'])\n",
Expand All @@ -389,7 +395,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Considering the circuit depth, it is increased approximately by a factor 10 compared to the two dimensional matrices. The circuit width is increased by two additional qubits"
"Considering the circuit depth and circuit width"
]
},
{
Expand Down Expand Up @@ -451,26 +457,30 @@
"outputs": [],
"source": [
"params5 = params\n",
"params5[\"reciprocal\"] = {\n",
" \"name\": \"Lookup\",\n",
" \"negative_evals\": True\n",
"params5['algorithm'] = {\n",
" 'truncate_powerdim': False,\n",
" 'truncate_hermitian': False\n",
"}\n",
"params5['reciprocal'] = {\n",
" 'name': 'Lookup',\n",
" 'negative_evals': True\n",
"}\n",
"params5[\"eigs\"] = {\n",
" \"expansion_mode\": \"suzuki\",\n",
" \"expansion_order\": 2,\n",
" \"name\": \"EigsQPE\",\n",
" \"negative_evals\": True,\n",
" \"num_ancillae\": 6,\n",
" \"num_time_slices\": 70\n",
"params5['eigs'] = {\n",
" 'expansion_mode': 'suzuki',\n",
" 'expansion_order': 2,\n",
" 'name': 'EigsQPE',\n",
" 'negative_evals': True,\n",
" 'num_ancillae': 6,\n",
" 'num_time_slices': 70\n",
"}\n",
"params5[\"initial_state\"] = {\n",
" \"name\": \"CUSTOM\"\n",
"params5['initial_state'] = {\n",
" 'name': 'CUSTOM'\n",
"}\n",
"params5[\"iqft\"] = {\n",
" \"name\": \"STANDARD\"\n",
"params5['iqft'] = {\n",
" 'name': 'STANDARD'\n",
"}\n",
"params5[\"qft\"] = {\n",
" \"name\": \"STANDARD\"\n",
"params5['qft'] = {\n",
" 'name': 'STANDARD'\n",
"}"
]
},
Expand Down Expand Up @@ -521,7 +531,7 @@
"result = hhl.run(quantum_instance)\n",
"print(\"solution \", np.round(result['solution'], 5))\n",
"\n",
"result_ref = ExactLPsolver(matrix, vector).run()\n",
"result_ref = ExactLSsolver(matrix, vector).run()\n",
"print(\"classical solution \", np.round(result_ref['solution'], 5))\n",
"\n",
"print(\"probability %f\" % result['probability_result'])\n",
Expand Down