Skip to content

Commit b0ba302

Browse files
AnnePicusTaliCohn
authored andcommitted
Swap test English suggestions
1 parent 23baefc commit b0ba302

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

algorithms/swap_test/swap_test.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"id": "e865ba60-b8b6-4dbb-b1d9-fd6883d15d86",
66
"metadata": {},
77
"source": [
8-
"# The Swap Test Algorithm\n",
8+
"# Swap Test Algorithm\n",
99
"\n",
10-
"The Swap test is a quantum function that checks the overlap between two quantum states: the inputs of the function are two quantum registers of the same size, $|\\psi_1\\rangle, \\,|\\psi_2\\rangle$, and it returns as an output a single test qubit whose state encodes the overlap between the two inputs: $|q\\rangle_{\\rm test} = \\alpha|0\\rangle + \\sqrt{1-\\alpha^2}|1\\rangle$, with\n",
10+
"The swap test is a quantum function that checks the overlap between two quantum states. The inputs of the function are two quantum registers of the same size, $|\\psi_1\\rangle, \\,|\\psi_2\\rangle$, and it returns as output a single test qubit whose state encodes the overlap between the two inputs: $|q\\rangle_{\\rm test} = \\alpha|0\\rangle + \\sqrt{1-\\alpha^2}|1\\rangle$, with\n",
1111
"$$\n",
1212
"\\alpha^2 = \\frac{1}{2}\\left(1+|\\langle \\psi_1 |\\psi_2 \\rangle |^2\\right).\n",
1313
"$$\n",
1414
"Thus, the probability of measuring the test qubit at state $|0\\rangle$ is $1$ if the states are identical (up to a global phase) and 0.5 if the states are orthogonal to each other.\n",
1515
"\n",
16-
"The quantum model starts with an $H$ gate on the test qubit, followed by swapping between the two states controlled on the test qubit (a controlled-SWAP gate for each of the qubits in the two states), and a final $H$ gate on the test qubit\n",
16+
"The quantum model starts with an $H$ gate on the test qubit, followed by swapping between the two states controlled on the test qubit (a controlled-SWAP gate for each of the qubits in the two states) and a final $H$ gate on the test qubit.\n",
1717
"\n",
18-
"A general scheme of the Swap test algorithm:\n",
18+
"A general scheme of the swap test algorithm:\n",
1919
"\n",
2020
"<center>\n",
2121
"<div style=\"text-align:center;\">\n",
@@ -99,9 +99,9 @@
9999
"id": "eeaa11bb-4a3a-4172-bc29-1bb8860f232a",
100100
"metadata": {},
101101
"source": [
102-
"## Swap Test - Qmod Implementations\n",
103-
"The Swap test is defined as a library function in the qmod language (definition can be found on our [public github](https://github.com/Classiq/classiq-library/blob/main/functions/open_library_definitions/swap_test.qmod)).\n",
104-
"Users can easily add their own functions."
102+
"## Swap Test Qmod Implementations\n",
103+
"The swap test is defined as a library function in the Qmod language. The definition is in the [public GitHub](https://github.com/Classiq/classiq-library/blob/main/functions/open_library_definitions/swap_test.qmod).\n",
104+
"You can add your own functions."
105105
]
106106
},
107107
{
@@ -127,13 +127,13 @@
127127
"id": "959995ad-aa6b-4b31-a25b-95396f8ffa7f",
128128
"metadata": {},
129129
"source": [
130-
"## Comparing Measured and Exact Overlap\n",
131-
"Using the expected probability of measuring the state $|0\\rangle$ as defined above:\n",
130+
"## Comparing Measured with Exact Overlap\n",
131+
"Using the expected probability of measuring the state $|0\\rangle$ as defined above,\n",
132132
"$$\n",
133-
"\\alpha^2 = \\frac{1}{2}\\left(1+|\\langle \\psi_1 |\\psi_2 \\rangle |^2\\right).\n",
133+
"\\alpha^2 = \\frac{1}{2}\\left(1+|\\langle \\psi_1 |\\psi_2 \\rangle |^2\\right),\n",
134134
"$$\n",
135-
"we extract the overlap $|\\langle \\psi_1 |\\psi_2 \\rangle |=\\sqrt{2 P\\left(q_{\\text{test}}=|0\\rangle\\right)-1}$ \n",
136-
"The exact overlap is computed with the dot product of the two state-vectors.\n",
135+
"we extract the overlap $|\\langle \\psi_1 |\\psi_2 \\rangle |=\\sqrt{2 P\\left(q_{\\text{test}}=|0\\rangle\\right)-1}$. \n",
136+
"The exact overlap is computed with the dot product of the two state vectors.\n",
137137
"Note that for the sake of this demonstration we execute this circuit $100,000$ times to improve the precision of the probability estimate. This is usually not required in actual programs."
138138
]
139139
},
@@ -188,7 +188,7 @@
188188
"assert np.isclose(\n",
189189
" overlap_from_swap_test, exact_overlap, RTOL\n",
190190
"), f\"\"\"\n",
191-
"The quantum result is too far than classical one, by a relative tolerance of {RTOL}. Please verify your parameters\"\"\""
191+
"The quantum result is too far from the classical one by a relative tolerance of {RTOL}. Please verify your parameters\"\"\""
192192
]
193193
},
194194
{

0 commit comments

Comments
 (0)