diff --git a/qiskit/aqua/general/linear_systems_of_equations.ipynb b/qiskit/aqua/general/linear_systems_of_equations.ipynb index 58e2a5e06..3d857aa4d 100644 --- a/qiskit/aqua/general/linear_systems_of_equations.ipynb +++ b/qiskit/aqua/general/linear_systems_of_equations.ipynb @@ -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" ] }, @@ -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", @@ -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", @@ -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" ] }, { @@ -264,10 +270,10 @@ "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" ] } ], @@ -275,7 +281,7 @@ "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", @@ -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" ] }, { @@ -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" ] } ], @@ -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", @@ -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" ] }, { @@ -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", "}" ] }, @@ -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",