Skip to content

Commit 7e192ed

Browse files
Merge pull request #52833 from jlehnersd/fix-equations-entanglement
Trying to fix aligned equation rendering, and no-locing eqns
2 parents 8d59315 + 2d69659 commit 7e192ed

2 files changed

Lines changed: 53 additions & 56 deletions

File tree

learn-pr/quantum/explore-entanglement/includes/3-create-entanglement-qsharp.md

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,81 @@ First, let's understand how these operations work and why they create entangled
66

77
## The Hadamard operation
88

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.
1010

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}$$":::
1313

1414
The first step to create your Bell state is to perform a Hadamard operation on one of the qubits.
1515

1616
## The Controlled-NOT (CNOT) operation
1717

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.
1919

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.
2121

2222
For example, in the following two-qubit states, the control qubit is the leftmost qubit and the target qubit is the rightmost qubit.
2323

24-
| Input to `CNOT` | Output from `CNOT` |
25-
|-----------------|--------------------|
26-
| $\ket{00}$ | $\ket{00}$ |
27-
| $\ket{01}$ | $\ket{01}$ |
28-
| $\ket{10}$ | $\ket{11}$ |
29-
| $\ket{11}$ | $\ket{10}$ |
24+
| Input to `CNOT` | Output from `CNOT` |
25+
|---------------------------------|---------------------------------|
26+
| :::no-loc text="$\\ket{00}$"::: | :::no-loc text="$\\ket{00}$"::: |
27+
| :::no-loc text="$\\ket{01}$"::: | :::no-loc text="$\\ket{01}$"::: |
28+
| :::no-loc text="$\\ket{10}$"::: | :::no-loc text="$\\ket{11}$"::: |
29+
| :::no-loc text="$\\ket{11}$"::: | :::no-loc text="$\\ket{10}$"::: |
3030

3131
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`.
3232

3333
## Entanglement with Hadamard and CNOT operations
3434

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.
3636

3737
Here's how it works:
3838

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.
4040
1. Put only the control qubit into an equal superposition state. To do so, apply an H operation to only the control qubit:
4141

42-
$$H |0_c\rangle= \frac{1}{\sqrt{2}}(|0_c\rangle+|1_c\rangle)$$
42+
:::no-loc text="$$H \\ket{0_c} = \\frac{1}{\\sqrt{2}}(\\ket{0_c} + \\ket{1_c})$$":::
4343

4444
> [!NOTE]
45-
> 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.
4646
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.
4848

4949
$$
50-
\begin{align*}
51-
CNOT \frac{1}{\sqrt{2}}(\ket{0_c}+\ket{1_c})\ket{0}_t &= CNOT \frac{1}{\sqrt2}(\ket{0_c 0_t}+|\ket{1_c 0_t})\\
52-
&= \frac{1}{\sqrt2}(CNOT \ket{0_c 0_t} + CNOT \ket{1_c 0_t})\\
53-
&= \frac{1}{\sqrt2}(\ket{0_c 0_t}+\ket{1_c 1_t})
54-
\end{align*}
50+
\\begin{aligned}
51+
CNOT \\frac{1}{\\sqrt{2}}(\\ket{0_c}+\\ket{1_c})\\ket{0_t} &= CNOT \\frac{1}{\\sqrt2}(\\ket{0_c 0_t}+\\ket{1_c 0_t})\\\\
52+
&= \\frac{1}{\\sqrt2}(CNOT \\ket{0_c 0_t} + CNOT \\ket{1_c 0_t})\\\\
53+
&= \\frac{1}{\\sqrt2}(\\ket{0_c 0_t}+\\ket{1_c 1_t})
54+
\\end{aligned}
5555
$$
5656

57-
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^{+}}$":::.
5858

5959
> [!NOTE]
6060
> In quantum computing, operations are often called gates. For example, the H gate and the CNOT gate.
6161
62-
## Create quantum entanglement in Q#
62+
## Create quantum entanglement in Q\#
6363

6464
To create a Bell state with Q# code, follow these steps in Visual Studio Code (VS Code):
6565

6666
1. Open VS Code.
6767
1. Open the **File** menu, and then choose **New Text File** to create a new file.
6868
1. Save the file as Main.qs.
6969

70-
### Create the Bell state $\ket{\phi^+}$
70+
### Create a Bell state
7171

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:
7373

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:
7575

7676
```qsharp
77-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
77+
import Std.Diagnostics.*;
7878
```
7979
80-
> [!TIP]
81-
> 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-
8380
1. Create the `Main` operation that returns two `Result` type values, which are the measurement results of the qubits.
8481
8582
```qsharp
86-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
83+
import Std.Diagnostics.*;
8784
8885
operation Main() : (Result, Result) {
8986
// Your code goes here
@@ -93,7 +90,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
9390
1. Inside the `Main` operation, allocate two qubits to be entangled, `q1` and `q2`.
9491
9592
```qsharp
96-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
93+
import Std.Diagnostics.*;
9794
9895
operation Main() : (Result, Result) {
9996
use (q1, q2) = (Qubit(), Qubit());
@@ -103,7 +100,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
103100
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.
104101
105102
```qsharp
106-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
103+
import Std.Diagnostics.*;
107104
108105
operation Main() : (Result, Result) {
109106
use (q1, q2) = (Qubit(), Qubit());
@@ -116,7 +113,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
116113
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.
117114
118115
```qsharp
119-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
116+
import Std.Diagnostics.*;
120117
121118
operation Main() : (Result, Result) {
122119
use (q1, q2) = (Qubit(), Qubit());
@@ -131,7 +128,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
131128
1. Use the `M` operation to measure the qubits, and store the results in `m1` and `m2`. Then use the `Reset` operation to reset the qubits.
132129
133130
```qsharp
134-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
131+
import Std.Diagnostics.*;
135132
136133
operation Main() : (Result, Result) {
137134
@@ -151,7 +148,7 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
151148
1. Return the measurement results of the qubits with the `return` statement. Here is final program in your **Main.qs** file:
152149
153150
```qsharp
154-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
151+
import Std.Diagnostics.*;
155152
156153
operation Main() : (Result, Result) {
157154
use (q1, q2) = (Qubit(), Qubit());
@@ -177,38 +174,38 @@ To create the Bell state $\ket{\phi^+}$ in Q#, follow these steps:
177174
178175
## Create other Bell states
179176
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.
181178
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{-}$":::.
183180
184181
> [!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.
186183
187-
Here's how to create the $\ket{\phi^-}$ state:
184+
Here's how to create the :::no-loc text="$\\ket{\\phi^-}$"::: state:
188185
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:
191188
192-
$$H |0_c\rangle= \frac{1}{\sqrt{2}}(|0_c\rangle+|1_c\rangle) = \ket{+}_c$$
189+
:::no-loc text="$$H \\ket{0_c} = \\frac{1}{\\sqrt{2}}(\\ket{0_c} + \\ket{1_c}) = \\ket{+_c}$$":::
193190
194-
1. Apply the $Z$ operation to the control qubit.
191+
1. Apply the :::no-loc text="$Z$"::: operation to the control qubit.
195192
196-
$$Z \frac{1}{\sqrt{2}}(|0_c\rangle+|1_c\rangle)= \frac{1}{\sqrt{2}}(|0_c\rangle-|1_c\rangle)= \ket{-}_c$$
193+
:::no-loc text="$$Z \\frac{1}{\\sqrt{2}}(\\ket{0_c} + \\ket{1_c}) = \\frac{1}{\\sqrt{2}}(\\ket{0_c} - \\ket{1_c}) = \\ket{-_c}$$":::
197194
198-
1. Apply the $CNOT$ operation to the control qubit and the target qubit, which is in the $|0_t\rangle$ state.
195+
1. Apply the CNOT operation to the control qubit and the target qubit, which is in the :::no-loc text="$\\ket{0_t}$"::: state.
199196
200197
$$
201-
\begin{align*}
202-
CNOT \frac{1}{\sqrt{2}}(\ket{0_c}-\ket{1_c})\ket{0}_t = CNOT \frac{1}{\sqrt2}(\ket{0_c 0_t}-|\ket{1_c 0_t})\\
203-
&= \frac{1}{\sqrt2}(CNOT \ket{0_c 0_t} - CNOT \ket{1_c 0_t})\\
204-
&= \frac{1}{\sqrt2}(\ket{0_c 0_t}-\ket{1_c 1_t})
205-
\end{align*}
198+
\\begin{aligned}
199+
CNOT \\frac{1}{\\sqrt{2}}(\\ket{0_c}-\\ket{1_c})\\ket{0_t} &= CNOT \\frac{1}{\\sqrt2}(\\ket{0_c 0_t}-\\ket{1_c 0_t})\\\\
200+
&= \\frac{1}{\\sqrt2}(CNOT \\ket{0_c 0_t} - CNOT \\ket{1_c 0_t})\\\\
201+
&= \\frac{1}{\\sqrt2}(\\ket{0_c 0_t}-\\ket{1_c 1_t})
202+
\\end{aligned}
206203
$$
207204
208-
To create the $\ket{\phi^-}$ Bell state in Q#, replace the code in the your **Main.qs** with the following code:
205+
To create the :::no-loc text="$\\ket{\\phi^-}$"::: Bell state in Q#, replace the code in the your **Main.qs** with the following code:
209206
210207
```qsharp
211-
import Microsoft.Quantum.Diagnostics.*; // Aka Std.Diagnostics.*;
208+
import Std.Diagnostics.*;
212209
213210
operation Main() : (Result, Result) {
214211
use (q1, q2) = (Qubit(), Qubit());
@@ -227,9 +224,9 @@ operation Main() : (Result, Result) {
227224
}
228225
```
229226

230-
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.
231228

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.
234231

235232
In the next unit, you learn how to use entanglement to send quantum information, a process known as quantum teleportation.
3.4 KB
Loading

0 commit comments

Comments
 (0)