You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/quantum/explore-entanglement/includes/3-create-entanglement-qsharp.md
+53-56Lines changed: 53 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,84 +6,81 @@ First, let's understand how these operations work and why they create entangled
6
6
7
7
## The Hadamard operation
8
8
9
-
Recall that the Hadamard, or H, operation, puts a qubit that's in a pure $|0\rangle$ state or $|1\rangle$ state into an equal superposition state.
9
+
Recall that the Hadamard, or H, operation, puts a qubit that's in a pure :::no-loc text="$\\ket{0}$"::: state or :::no-loc text="$\\ket{1}$"::: state into an equal superposition state.
10
10
11
-
$$ H |0\rangle = \frac1{\sqrt2} |0\rangle + \frac1{\sqrt2} |1\rangle$$
12
-
$$ H |1\rangle = \frac1{\sqrt2} |0\rangle - \frac1{\sqrt2} |1\rangle$$
11
+
:::no-loc text="$$ H \\ket{0} = \\frac1{\\sqrt2} \\ket{0} + \\frac1{\\sqrt2} \\ket{1}$$":::
12
+
:::no-loc text="$$ H \\ket{1} = \\frac1{\\sqrt2} \\ket{0} - \\frac1{\\sqrt2} \\ket{1}$$":::
13
13
14
14
The first step to create your Bell state is to perform a Hadamard operation on one of the qubits.
15
15
16
16
## The Controlled-NOT (CNOT) operation
17
17
18
-
When two qubits are entangled, the state of one qubit is dependent on the state of the other qubit. Therefore, to entangle two qubits you need an operation that acts on both qubits at the same time. This is called a multi-qubit operation. The Controlled-NOT, or CNOT, operation is a multi-qubit operation that helps create entanglement.
18
+
When two qubits are entangled, the state of one qubit is dependent on the state of the other qubit. Therefore, to entangle two qubits you need to apply a multi-qubit operation, which is an operation that acts on both qubits at the same time. The Controlled-NOT, or CNOT, operation is a multi-qubit operation that helps create entanglement.
19
19
20
-
The CNOT operation takes two qubits as input. One of the qubits is called the control qubit and the other qubit is called the target qubit. If the control qubit is in the $|1\rangle$ state, then the CNOT operation flips the state of the target qubit. Otherwise, CNOT does nothing.
20
+
The CNOT operation takes two qubits as input. One of the qubits is the control qubit and the other qubit is the target qubit. If the control qubit is in the :::no-loc text="$\\ket{1}$"::: state, then the CNOT operation flips the state of the target qubit. Otherwise, CNOT does nothing.
21
21
22
22
For example, in the following two-qubit states, the control qubit is the leftmost qubit and the target qubit is the rightmost qubit.
In Q#, the `CNOT` operation acts on an array of two qubits, and it flips the second qubit only if the first qubit is `One`.
32
32
33
33
## Entanglement with Hadamard and CNOT operations
34
34
35
-
Suppose that you have a two-qubit system in the state $|00\rangle$. In this state, the qubits aren't entangled. To put these qubits into the entangled Bell state $\ket{\phi^+}=\frac1{\sqrt2}(|00\rangle+|11\rangle)$, apply the Hadamard and CNOT operations.
35
+
Suppose that you have a two-qubit system in the state :::no-loc text="$\\ket{00}$":::. In this state, the qubits aren't entangled. To put these qubits into the entangled Bell state :::no-loc text="$\\ket{\\phi^+}=\\frac1{\\sqrt2}(\\ket{00}+\\ket{11})$":::, apply the Hadamard and CNOT operations.
36
36
37
37
Here's how it works:
38
38
39
-
1. Choose one qubit in the $|00\rangle$ state to be the control qubit and the other qubit to be the target qubit. Here, we choose the leftmost qubit to be the control and the rightmost qubit to be the target.
39
+
1. Choose one qubit in the c state to be the control qubit and the other qubit to be the target qubit. Here, we choose the leftmost qubit to be the control and the rightmost qubit to be the target.
40
40
1. Put only the control qubit into an equal superposition state. To do so, apply an H operation to only the control qubit:
> The subscripts ${}_c$ and ${}_t$ specify the control and target qubits, respectively.
45
+
> The subscripts :::no-loc text="${}_c$"::: and :::no-loc text="${}_t$"::: specify the control and target qubits, respectively.
46
46
47
-
1. Apply a CNOT operation to the qubit pair. Recall that the control qubit is in a superposition state and the target qubit is in the $|0_t\rangle$ state.
47
+
1. Apply a CNOT operation to the qubit pair. Recall that the control qubit is in a superposition state and the target qubit is in the :::no-loc text="$\\ket{0_t}$"::: state.
The state $\frac{1}{\sqrt2}(\ket{0_c 0_t}+\ket{1_c 1_t})$ is entangled. This particular entangled state is one of the four Bell states, $\ket{\phi^{+}}$.
57
+
The state :::no-loc text="$\\frac{1}{\\sqrt2}(\\ket{0_c 0_t}+\\ket{1_c 1_t})$"::: is entangled. This particular entangled state is one of the four Bell states, :::no-loc text="$\\ket{\\phi^{+}}$":::.
58
58
59
59
> [!NOTE]
60
60
> In quantum computing, operations are often called gates. For example, the H gate and the CNOT gate.
61
61
62
-
## Create quantum entanglement in Q#
62
+
## Create quantum entanglement in Q\#
63
63
64
64
To create a Bell state with Q# code, follow these steps in Visual Studio Code (VS Code):
65
65
66
66
1. Open VS Code.
67
67
1. Open the **File** menu, and then choose **New Text File** to create a new file.
68
68
1. Save the file as Main.qs.
69
69
70
-
### Create the Bell state $\ket{\phi^+}$
70
+
### Create a Bell state
71
71
72
-
To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
72
+
To create the Bell state :::no-loc text="$\\ket{\\phi^+}$"::: in Q#, follow these steps:
73
73
74
-
1. Import the `Microsoft.Quantum.Diagnostics` namespace from the Q# standard library so that you can use the `DumpMachine` function. This function shows information about the qubit states when you call the function in your code. To import the namespace, copy the following Q# code into your **Main.qs** file:
74
+
1. Import the `Std.Diagnostics` namespace from the Q# standard library so that you can use the `DumpMachine` function. This function shows information about the qubit states when you call the function in your code. To import the namespace, copy the following Q# code into your **Main.qs** file:
> You can use `Std` instead of `Microsoft.Quantum` to import from the standard library. For example, `import Std.Diagnostics.*` is equivalent to `import Microsoft.Quantum.Diagnostics.*`.
82
-
83
80
1. Create the `Main` operation that returns two `Result` type values, which are the measurement results of the qubits.
@@ -103,7 +100,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
103
100
1. Apply the Hadamard gate, `H`, to the control qubit,`q1`. This puts only that qubit into a superposition state. Then apply the CNOT gate, `CNOT`, to both qubits to entangle the two qubits. The first argument to `CNOT` is the control qubit and the second argument is the target qubit.
@@ -116,7 +113,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
116
113
1. Use the `DumpMachine` function to display the state of the qubits after you entangle them. Note that `DumpMachine` doesn't perform a measurement on the qubits, so `DumpMachine` doesn't affect the qubit states.
@@ -177,38 +174,38 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
177
174
178
175
## Create other Bell states
179
176
180
-
To create other Bell states, apply additional Pauli $X$ or $Z$ operations to the qubits.
177
+
To create other Bell states, apply additional Pauli :::no-loc text="$X$"::: or :::no-loc text="$Z$"::: operations to the qubits.
181
178
182
-
For example, to create the Bell state $\ket{\phi^-}=\frac1{\sqrt2}(|00\rangle-|11\rangle)$, apply the Pauli $Z$ operation to the control qubit after you apply the Hadamard gate, but before you apply CNOT. The $Z$ operation flips the state $\ket{+}$ to $\ket{-}$.
179
+
For example, to create the Bell state :::no-loc text="$\\ket{\\phi^-}=\\frac1{\\sqrt2}(\\ket{00}-\\ket{11})$":::, apply the Pauli $Z$ operation to the control qubit after you apply the Hadamard gate, but before you apply CNOT. The :::no-loc text="$Z$"::: operation flips the state :::no-loc text="$\\ket{+}$"::: to :::no-loc text="$\\ket{-}$":::.
183
180
184
181
> [!NOTE]
185
-
> The states $\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)$ and $\frac{1}{\sqrt{2}}(|0\rangle -|1\rangle)$ are also known as $\ket{+}$ and $\ket{-}$, respectively.
182
+
> The states :::no-loc text="$\\frac{1}{\\sqrt{2}}(\\ket{0}+\\ket{1})$"::: and :::no-loc text="$\\frac{1}{\\sqrt{2}}(\\ket{0} - \\ket{1})$"::: are also known as :::no-loc text="$\\ket{+}$"::: and :::no-loc text="$\\ket{-}$":::, respectively.
186
183
187
-
Here's how to create the $\ket{\phi^-}$ state:
184
+
Here's how to create the :::no-loc text="$\\ket{\\phi^-}$"::: state:
188
185
189
-
1. Create two qubits in the state $|00\rangle$.
190
-
1. Put the control qubit into a superposition state with the $H$ operation:
186
+
1. Create two qubits in the state :::no-loc text="$\\ket{00}$":::.
187
+
1. Put the control qubit into a superposition state with the :::no-loc text="$H$"::: operation:
Similarly, you can create the Bell states $\ket{\psi^+}$ and $\ket{\psi^-}$ by applying the Pauli $X$ and $Z$ operations to the qubits.
227
+
Similarly, you can create the Bell states :::no-loc text="$\\ket{\\psi^+}$ and $\\ket{\\psi^-}$"::: by applying the Pauli $X$ and $Z$ operations to the qubits.
231
228
232
-
- To create the Bell state $\ket{\psi^+}=\frac1{\sqrt2}(|01\rangle+|10\rangle)$, apply the Pauli $X$ gate to the target qubit after you apply the Hadamard gate to the control qubit. Then apply the CNOT gate.
233
-
- To create the Bell state $\ket{\psi^-}=\frac1{\sqrt2}(|01\rangle-|10\rangle)$, apply the Pauli $Z$ to the control qubit and the Pauli $X$ to the target qubit after you apply the Hadamard gate to the control qubit. Then apply the CNOT gate.
229
+
- To create the Bell state :::no-loc text="$\\ket{\\psi^+}=\\frac1{\\sqrt2}(\\ket{01}+\\ket{10})$":::, apply the Pauli $X$ gate to the target qubit after you apply the Hadamard gate to the control qubit. Then apply the CNOT gate.
230
+
- To create the Bell state :::no-loc text="$\\ket{\\psi^-}=\\frac1{\\sqrt2}(\\ket{01}-\\ket{10})$":::, apply the Pauli $Z$ to the control qubit and the Pauli $X$ to the target qubit after you apply the Hadamard gate to the control qubit. Then apply the CNOT gate.
234
231
235
232
In the next unit, you learn how to use entanglement to send quantum information, a process known as quantum teleportation.
0 commit comments