|
26 | 26 | },
|
27 | 27 | {
|
28 | 28 | "cell_type": "code",
|
29 |
| - "execution_count": 1, |
| 29 | + "execution_count": 10, |
30 | 30 | "id": "674d1423-6ac5-4f6b-8328-7073a72c0a28",
|
31 | 31 | "metadata": {
|
32 | 32 | "execution": {
|
|
74 | 74 | },
|
75 | 75 | {
|
76 | 76 | "cell_type": "code",
|
77 |
| - "execution_count": 2, |
| 77 | + "execution_count": 11, |
78 | 78 | "id": "ba0e933a-9878-4ce2-b5af-2e4c65638f60",
|
79 | 79 | "metadata": {
|
80 | 80 | "execution": {
|
|
89 | 89 | "name": "stdout",
|
90 | 90 | "output_type": "stream",
|
91 | 91 | "text": [
|
92 |
| - "Opening: https://platform.classiq.io/circuit/46aab825-d4f7-4096-a5d8-158e4dfc80d0?version=0.42.0\n", |
93 |
| - "ExecutionJob(id='83e8fea7-97dd-432f-be39-bf4d06e22c79')\n" |
| 92 | + "Opening: https://platform.classiq.io/circuit/737ef5dd-eba0-49f5-9a61-25814ca2f523?version=0.42.0\n", |
| 93 | + "The result of the arithmetic calculation: [{'z': 1.0}: 2048]\n" |
94 | 94 | ]
|
95 | 95 | }
|
96 | 96 | ],
|
|
113 | 113 | "qprog = synthesize(qmod)\n",
|
114 | 114 | "show(qprog)\n",
|
115 | 115 | "\n",
|
116 |
| - "result = execute(qprog)\n", |
117 |
| - "print(result)\n", |
| 116 | + "job = execute(qprog)\n", |
| 117 | + "result = job.result()\n", |
| 118 | + "parsed_counts = result[0].value.parsed_counts\n", |
| 119 | + "print(\"The result of the arithmetic calculation: \",parsed_counts)\n", |
| 120 | + "\n", |
118 | 121 | "\n",
|
119 | 122 | "write_qmod(qmod, \"arithmetic_demo_9_qubits\")"
|
120 | 123 | ]
|
|
129 | 132 | },
|
130 | 133 | {
|
131 | 134 | "cell_type": "code",
|
132 |
| - "execution_count": 3, |
| 135 | + "execution_count": 12, |
133 | 136 | "id": "77d24a43-5114-46a0-8309-33af8fdc75fb",
|
134 | 137 | "metadata": {
|
135 | 138 | "execution": {
|
|
144 | 147 | "name": "stdout",
|
145 | 148 | "output_type": "stream",
|
146 | 149 | "text": [
|
147 |
| - "Opening: https://platform.classiq.io/circuit/1aac1cb8-437c-4261-a540-679aa62ef242?version=0.42.0\n", |
148 |
| - "ExecutionJob(id='6e1c4bf7-adce-4137-8d57-04f4639f0ced')\n" |
| 150 | + "Opening: https://platform.classiq.io/circuit/00705127-ab37-41d3-b8a6-71939bf39146?version=0.42.0\n", |
| 151 | + "The result of the arithmetic calculation: [{'z': 1.0}: 2048]\n" |
149 | 152 | ]
|
150 | 153 | }
|
151 | 154 | ],
|
|
156 | 159 | "qprog = synthesize(qmod)\n",
|
157 | 160 | "show(qprog)\n",
|
158 | 161 | "\n",
|
159 |
| - "result = execute(qprog)\n", |
160 |
| - "print(result)\n", |
| 162 | + "job = execute(qprog)\n", |
| 163 | + "result = job.result()\n", |
| 164 | + "parsed_counts = result[0].value.parsed_counts\n", |
| 165 | + "print(\"The result of the arithmetic calculation: \",parsed_counts)\n", |
161 | 166 | "\n",
|
162 | 167 | "\n",
|
163 | 168 | "write_qmod(qmod, \"arithmetic_demo_12_qubits\")"
|
|
171 | 176 | " ### Mathematical Background\n",
|
172 | 177 | " \n",
|
173 | 178 | " The given mathematical expression:\n",
|
174 |
| - " $$z \\mathrel{|}= (2 \\cdot x + y + \\max(3 \\cdot y, 2)) > 4$$ \n", |
175 |
| - " is solved with the synthesis engine, optimizing over depth and constraining the maximal width to 9 and 12 qubits, which outputs the value for z:\n", |
176 |
| - " $$z = 1$$\n", |
177 |
| - " This verifies the arithmetic expression to be True.\n", |
| 179 | + " $$z = (2 \\cdot x + y + \\max(3 \\cdot y, 2)) > 4$$ \n", |
| 180 | + " is solved by the automatic arithmetic operation management, optimizing over depth and constraining the maximal width to 9 and 12 qubits, which outputs the value for z.\n", |
| 181 | + " \n", |
| 182 | + " __The `parsed_counts` result:__\n", |
| 183 | + " - Optimizing over depth and constraining the maximal width to 9 qubits: `[{'z': 1.0}: 2048]`\n", |
| 184 | + " - Optimizing over depth and constraining the maximal width to 12 qubits: `[{'z': 1.0}: 2048]`\n", |
| 185 | + "\n", |
| 186 | + "Both the result are same which verifies the arithmetic expression to be True.\n", |
178 | 187 | " \n",
|
179 |
| - " The expected result:<br>\n", |
| 188 | + " __The expected result__:<br>\n", |
180 | 189 | " \n",
|
181 | 190 | " Allocated values:\n",
|
182 | 191 | " \n",
|
|
0 commit comments