Skip to content

Commit bc75272

Browse files
jyotiraj-codeTomerGoldfriend
authored andcommitted
Update arithmetic_expressions.ipynb
1 parent 54e3f4e commit bc75272

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

tutorials/technology_demonstrations/arithmetic_expressions/arithmetic_expressions.ipynb

+25-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 1,
29+
"execution_count": 10,
3030
"id": "674d1423-6ac5-4f6b-8328-7073a72c0a28",
3131
"metadata": {
3232
"execution": {
@@ -74,7 +74,7 @@
7474
},
7575
{
7676
"cell_type": "code",
77-
"execution_count": 2,
77+
"execution_count": 11,
7878
"id": "ba0e933a-9878-4ce2-b5af-2e4c65638f60",
7979
"metadata": {
8080
"execution": {
@@ -89,8 +89,8 @@
8989
"name": "stdout",
9090
"output_type": "stream",
9191
"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"
9494
]
9595
}
9696
],
@@ -113,8 +113,11 @@
113113
"qprog = synthesize(qmod)\n",
114114
"show(qprog)\n",
115115
"\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",
118121
"\n",
119122
"write_qmod(qmod, \"arithmetic_demo_9_qubits\")"
120123
]
@@ -129,7 +132,7 @@
129132
},
130133
{
131134
"cell_type": "code",
132-
"execution_count": 3,
135+
"execution_count": 12,
133136
"id": "77d24a43-5114-46a0-8309-33af8fdc75fb",
134137
"metadata": {
135138
"execution": {
@@ -144,8 +147,8 @@
144147
"name": "stdout",
145148
"output_type": "stream",
146149
"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"
149152
]
150153
}
151154
],
@@ -156,8 +159,10 @@
156159
"qprog = synthesize(qmod)\n",
157160
"show(qprog)\n",
158161
"\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",
161166
"\n",
162167
"\n",
163168
"write_qmod(qmod, \"arithmetic_demo_12_qubits\")"
@@ -171,12 +176,16 @@
171176
" ### Mathematical Background\n",
172177
" \n",
173178
" 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",
178187
" \n",
179-
" The expected result:<br>\n",
188+
" __The expected result__:<br>\n",
180189
" \n",
181190
" Allocated values:\n",
182191
" \n",

0 commit comments

Comments
 (0)