From ab5800d92abfc2496e939ad31d47b4f790e08cfe Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Fri, 2 Aug 2024 18:43:59 +0200 Subject: [PATCH 01/18] review of multiqubit systems kata --- katas/content/deutsch_algo/index.md | 2 + katas/content/deutsch_jozsa/index.md | 4 +- katas/content/grovers_search/index.md | 1 + .../bell_state_change_1/solution.md | 12 ++--- .../bell_state_change_2/solution.md | 6 +-- .../bell_state_change_3/solution.md | 8 ++-- katas/content/multi_qubit_systems/index.md | 46 ++++++++++--------- .../learn_basis_state_amplitudes/index.md | 2 +- .../prepare_basis_state/solution.md | 2 +- .../prepare_superposition/solution.md | 8 ++-- .../prepare_with_complex/solution.md | 8 ++-- .../prepare_with_real/solution.md | 6 +-- katas/content/oracles/index.md | 4 +- katas/content/qec_shor/index.md | 2 + katas/content/qubit/index.md | 2 + 15 files changed, 63 insertions(+), 50 deletions(-) diff --git a/katas/content/deutsch_algo/index.md b/katas/content/deutsch_algo/index.md index dec960f0e6..10187daf07 100644 --- a/katas/content/deutsch_algo/index.md +++ b/katas/content/deutsch_algo/index.md @@ -19,6 +19,8 @@ This kata introduces you to Deutsch algorithm - the single-qubit variant of Deut - Basic knowledge of single-qubit gates - Basic knowledge of quantum measurements +If you need a refresher on these topics, you can check out the previous katas. + @[section]({ "id": "deutsch_algo__problem", "title": "The Problem" diff --git a/katas/content/deutsch_jozsa/index.md b/katas/content/deutsch_jozsa/index.md index b53cc8d8bb..258cdc9634 100644 --- a/katas/content/deutsch_jozsa/index.md +++ b/katas/content/deutsch_jozsa/index.md @@ -19,7 +19,9 @@ This kata introduces you to Deutsch-Jozsa algorithm - one of the most famous alg - Basic knowledge of single-qubit gates - Basic knowledge of quantum measurements -- Deutsch algorithm - the single-qubit variant of Deutsch-Jozsa algorithm. If you're not familiar with it, you can find it in the Deutsch algorithm kata. +- Deutsch algorithm - the single-qubit variant of Deutsch-Jozsa algorithm. + +If you need a refresher on these topics, you can check out the previous katas. @[section]({ "id": "deutsch_jozsa__problem", diff --git a/katas/content/grovers_search/index.md b/katas/content/grovers_search/index.md index c4bb82b654..6aa668aadd 100644 --- a/katas/content/grovers_search/index.md +++ b/katas/content/grovers_search/index.md @@ -20,6 +20,7 @@ Note that this tutorial does not cover implementing specific classical functions - Basic knowledge of quantum gates and measurements - Basic understanding of quantum oracles +If you need a refresher on these topics, you can check out the previous katas. @[section]({ "id": "grovers_search__search_problem", diff --git a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md index ccfe6b0d58..2b603414cb 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md @@ -1,15 +1,15 @@ -We recognize that the goal is another Bell state. In fact, it is one of the four Bell states. +You recognize that the goal is another Bell state. In fact, it is one of the four Bell states. -We remember from the Single-Qubit Gates kata that the Pauli Z gate will change the state of the $\ket{1}$ basis state of a single qubit, so this gate seems like a good candidate for what we want to achieve. This gate leaves the sign of the $\ket{0}$ basis state of a superposition unchanged, but flips the sign of the $\ket{1}$ basis state of the superposition. +You remember from the Single-Qubit Gates kata that the Pauli Z gate will change the state of the $\ket{1}$ basis state of a single qubit, so this gate seems like a good candidate for what you want to achieve. This gate leaves the sign of the $\ket{0}$ basis state of a superposition unchanged, but flips the sign of the $\ket{1}$ basis state of the superposition. -Don't forget that the Z gate acts on only a single qubit, and we have two here. +Don't forget that the Z gate acts on only a single qubit, and you have two here. Let's also remember how the Bell state is made up from its individual qubits. -If the two qubits are A and B, where A is `qs[0]` and B is `qs[1]`, we can write that +If the two qubits are A and B, where A is `qs[0]` and B is `qs[1]`, you can write that $\ket{\Phi^{+}} = \frac{1}{\sqrt{2}} \big(\ket{0_{A}0_{B}} + \ket{1_{A}1_{B}}\big)$. -If we apply the Z gate to the qubit A, it will flip the phase of the basis state $\ket{1_A}$. As this phase is in a sense spread across the entangled state, with $\ket{1_A}$ basis state being part of the second half of the superposition, this application has the effect of flipping the sign of the whole basis state $\ket{1_A1_B}$, as you can see by running the solution below. +If you apply the Z gate to the qubit A, it will flip the phase of the basis state $\ket{1_A}$. As this phase is in a sense spread across the entangled state, with $\ket{1_A}$ basis state being part of the second half of the superposition, this application has the effect of flipping the sign of the whole basis state $\ket{1_A1_B}$, as you can see by running the solution below. -The exact same calculations can be done if we apply Z to the qubit B, so that's another possible solution. +The exact same calculations can be done if you apply Z to the qubit B, so that's another possible solution. @[solution]({ "id": "multi_qubit_systems__bell_state_change_1_solution", "codePath": "Solution.qs" diff --git a/katas/content/multi_qubit_systems/bell_state_change_2/solution.md b/katas/content/multi_qubit_systems/bell_state_change_2/solution.md index 5fee5a50c8..8e58cac823 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_2/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_2/solution.md @@ -1,8 +1,8 @@ -We have seen in the Single-Qubit Gates kata that the Pauli X gate flips $\ket{0}$ to $\ket{1}$ and vice versa, and as we seem to need some flipping of states, perhaps this gate may be of use. (Bearing in mind, of course, that the X gate operates on a single qubit). +You have seen in the Single-Qubit Gates kata that the Pauli X gate flips $\ket{0}$ to $\ket{1}$ and vice versa, and as you seem to need some flipping of states, perhaps this gate may be of use. (Bearing in mind, of course, that the X gate operates on a single qubit). -Let's compare the starting state $\frac{1}{\sqrt{2}} \big(\ket{0_A0_B} + \ket{1_A1_B}\big)$ with the goal state $\frac{1}{\sqrt{2}} \big(\ket{1_A0_B} + \ket{0_A1_B}\big)$ term by term and see how we need to transform it to reach the goal. +Let's compare the starting state $\frac{1}{\sqrt{2}} \big(\ket{0_A0_B} + \ket{1_A1_B}\big)$ with the goal state $\frac{1}{\sqrt{2}} \big(\ket{1_A0_B} + \ket{0_A1_B}\big)$ term by term and see how you need to transform it to reach the goal. -Using our nomenclature from "Bell state change 1", we can now see by comparing terms that $\ket{0_{A}}$ has flipped to $\ket{1_A}$ to get the first term, and $\ket{1_{A}}$ has flipped to $\ket{0_A}$ to get the second term. This allows us to say that the correct gate to use is Pauli X, applied to `qs[0]`. +Using the nomenclature from "Bell state change 1", you can now see by comparing terms that $\ket{0_{A}}$ has flipped to $\ket{1_A}$ to get the first term, and $\ket{1_{A}}$ has flipped to $\ket{0_A}$ to get the second term. This allows you to say that the correct gate to use is Pauli X, applied to `qs[0]`. @[solution]({ "id": "multi_qubit_systems__bell_state_change_2_solution", diff --git a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md index 55b1e001c7..271a2115f9 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md @@ -1,9 +1,9 @@ -We remember from the Single-Qubit Gates kata that the Pauli Z gate leaves the sign of the $\ket{0}$ component of the single qubit superposition unchanged but flips the sign of the $\ket{1}$ component of the superposition. We have also just seen in "Bell State Change 2" how to change our input state to the state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, which is almost our goal state (disregarding the phase change for the moment). So it would seem that a combination of these two gates will be what we need here. The remaining question is in what order to apply them, and to which qubit. +You remember from the Single-Qubit Gates kata that the Pauli Z gate leaves the sign of the $\ket{0}$ component of the single qubit superposition unchanged but flips the sign of the $\ket{1}$ component of the superposition. You have also just seen in "Bell State Change 2" how to change our input state to the state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, which is almost your goal state (disregarding the phase change for the moment). So it would seem that a combination of these two gates will be what you need here. The remaining question is in what order to apply them, and to which qubit. -First of all, which qubit? Looking back at the task "Bell state change 2", it seems clear that we need to use qubit `qs[0]`, like we did there. +First of all, which qubit? Looking back at the task "Bell state change 2", it seems clear that you need to use qubit `qs[0]`, like you did there. -Second, in what order should we apply the gates? Remember that the Pauli Z gate flips the phase of the $\ket{1}$ component of the superposition and leaves the $\ket{0}$ component alone. -Let's experiment with applying X to `qs[0]` first. Looking at our "halfway answer" state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, we can see that if we apply the Z gate to `qs[0]`, it will leave the $\ket{0_{A}}$ alone but flip the phase of $\ket{1_{A}}$ to $-\ket{1_{A}}$, thus flipping the phase of the $\ket{11}$ component of our Bell state. +Second, in what order should you apply the gates? Remember that the Pauli Z gate flips the phase of the $\ket{1}$ component of the superposition and leaves the $\ket{0}$ component alone. +Let's experiment with applying X to `qs[0]` first. Looking at our "halfway answer" state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, you can see that if you apply the Z gate to `qs[0]`, it will leave the $\ket{0_{A}}$ alone but flip the phase of $\ket{1_{A}}$ to $-\ket{1_{A}}$, thus flipping the phase of the $\ket{11}$ component of our Bell state. @[solution]({ "id": "multi_qubit_systems__bell_state_change_3_solution", diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index e487e1d165..54dbe61dad 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -17,15 +17,17 @@ If you are not familiar with single-qubit systems, we recommend that you complet **What you should know to start working on this kata:** -- Basic single-qubit gates +- Basic knowledge of single-qubit gates - The concept of tensor product +If you need a refresher on these topics, you can check out the previous katas. + @[section]({ "id": "multi_qubit_systems__introduction", "title": "Multi-Qubit Systems" }) -In The Qubit kata we discussed the concept of a qubit - the basic building block of a quantum computer. +The Qubit kata covers the concept of a qubit - the basic building block of a quantum computer. A multi-qubit system is a collection of multiple qubits, treated as a single system. Let's start by examining a system of two classical bits. Each bit can be in two states: $0$ and $1$. Therefore, a system of two bits can be in four different states: $00$, $01$, $10$, and $11$. Generally, a system of $N$ classical bits can be in any of the $2^N$ states. @@ -47,7 +49,7 @@ $$\begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}$$ -It is easy to see that these vectors form an orthonormal basis. Note that each of these basis states can be represented as a tensor product of some combination of single-qubit basis states: +It's easy to see that these vectors form an orthonormal basis. Note that each of these basis states can be represented as a tensor product of some combination of single-qubit basis states: @@ -78,14 +80,14 @@ The coefficients of the basis vectors define how "close" is the system state to \frac{1}{\sqrt{2}}\begin{bmatrix} 0 \\ 1 \\ 1 \\ 0 \end{bmatrix}, \frac{1}{\sqrt{2}}\begin{bmatrix} 0 \\ 1 \\ -1 \\ 0 \end{bmatrix}$$ > -> You can check that these vectors are normalized, and orthogonal to each other, and that any two-qubit state can be expressed as a linear combination of these vectors. The vectors of Bell basis, however, can not be represented as tensor products of single-qubit basis states. +> You can check that these vectors are normalized, and orthogonal to each other, and that any two-qubit state can be expressed as a linear combination of these vectors. The vectors of Bell basis, however, can't be represented as tensor products of single-qubit basis states. @[section]({ "id": "multi_qubit_systems__separable_states", "title": "Separable States" }) -Sometimes the global state of a multi-qubit system can be separated into the states of individual qubits or subsystems. To do this, you would express the vector state of the global system as a tensor product of the vectors representing each individual qubit/subsystem. Here is an example of a two-qubit state: +Sometimes the global state of a multi-qubit system can be separated into the states of individual qubits or subsystems. To do this, you express the vector state of the global system as a tensor product of the vectors representing each individual qubit/subsystem. Here is an example of a two-qubit state: $$ \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} = @@ -104,14 +106,14 @@ $$
Solution -To separate the state into a tensor product of two single-qubit states, we need to represent it in the following way: +To separate the state into a tensor product of two single-qubit states, you need to represent it in the following way: $$ \begin{bmatrix} \alpha \gamma \\ \alpha \delta \\ \beta \gamma \\ \beta \delta \end{bmatrix} = \begin{bmatrix} \alpha \\ \beta \end{bmatrix} \otimes \begin{bmatrix} \gamma \\ \delta \end{bmatrix} $$ -This brings us to a system of equations: +This brings you to a system of equations: $$ \begin{cases} @@ -119,7 +121,7 @@ $$ \end{cases} $$ -Solving this system of equations gives us the answer: +Solving this system of equations gives the answer: $$\alpha = \frac{1}{\sqrt2}, \beta = \frac{-i}{\sqrt2}, \gamma = \frac{1}{\sqrt2}, \delta = \frac{i}{\sqrt2}$$ @@ -128,7 +130,7 @@ $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ -i \end{bmatrix} \otimes \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ i \end{bmatrix} $$ -Note that finding such representation is not always possible, as you will see in the next exercise. +Note that finding such representation isn't always possible, as you'll see in the next exercise.
## 🔎 Analyze @@ -139,7 +141,7 @@ $$\frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 0 \\ 0 \\ 1 \end{bmatrix}$$
Solution -Let's assume that this state is separable and write down the system of equations to determine the coefficients of individual qubit states in the tensor product, similar to what we did in the previous exercise: +Let's assume that this state is separable and write down the system of equations to determine the coefficients of individual qubit states in the tensor product, similar to what you did in the previous exercise: $$ \begin{cases} @@ -155,7 +157,7 @@ $$ \end{cases} $$ -We can see that this system of equations doesn't have a solution, which means that this state is not separable. +You can see that this system of equations doesn't have a solution, which means that this state is not separable.
@[section]({ @@ -163,7 +165,7 @@ We can see that this system of equations doesn't have a solution, which means th "title": "Entanglement" }) -Sometimes, quantum states cannot be written as individual qubit states. Quantum systems that are not separable are called **entangled** systems. If a state can be written as the product state of the individual subsystems, that state is not entangled. +Sometimes, quantum states can't be written as individual qubit states. Quantum systems that aren't separable are called **entangled** systems. If a state can be written as the product state of the individual subsystems, that state isn't entangled. Entanglement is a quantum correlation, which is very different from classical correlations. In entanglement, the state of the subsystems isn't determined, and you can talk only about the probabilities associated with the outcomes. The global system must be considered as one. @@ -186,7 +188,7 @@ This property is used extensively in many quantum algorithms. Just like with single qubits, Dirac notation provides a useful shorthand for writing down states of multi-qubit systems. -As we've seen earlier, multi-qubit systems have their own canonical bases, and the basis states can be represented as tensor products of single-qubit basis states. Any multi-qubit system can be represented as a linear combination of these basis states: +As you've seen earlier, multi-qubit systems have their own canonical bases, and the basis states can be represented as tensor products of single-qubit basis states. Any multi-qubit system can be represented as a linear combination of these basis states: $$ \begin{bmatrix} x_0 \\ x_1 \\ x_2 \\ x_3 \end{bmatrix} = @@ -215,14 +217,14 @@ Or, more generally: $$\ket{i_0} \otimes \ket{i_1} \otimes \dotsb \otimes \ket{i_n} = \ket{i_0i_1...i_n}$$ -Using this notation simplifies our example: +Using this notation simplifies the example: $$ \begin{bmatrix} x_0 \\ x_1 \\ x_2 \\ x_3 \end{bmatrix} = x_0\ket{00} + x_1\ket{01} + x_2\ket{10} + x_3\ket{11} $$ -Just like with single qubits, we can put arbitrary symbols within the kets the same way variables are used in algebra. +Just like with single qubits, you can put arbitrary symbols within the kets the same way variables are used in algebra. Whether a ket represents a single qubit or an entire system depends on the context. Some ket symbols have a commonly accepted usage, such as the symbols for the Bell basis: @@ -233,7 +235,7 @@ $$\ket{\Psi^-} = \frac{1}{\sqrt{2}}\big(\ket{01} - \ket{10}\big)$$ >## Endianness > -> In classical computing, endianness refers to the order of bits (or bytes) when representing numbers in binary. You're probably familiar with the typical way of writing numbers in binary: $0 = 0_2$, $1 = 1_2$, $2 = 10_2$, $3 = 11_2$, $4 = 100_2$, $5 = 101_2$, $6 = 110_2$, etc. This is known as **big-endian format**. In big-endian format, the *most significant* bits come first. For example: $110_2 = 1 \cdot 4 + 1 \cdot 2 + 0 \cdot 1 = 4 + 2 = 6$. +> In classical computing, *endianness* refers to the order of bits (or bytes) when representing numbers in binary. You're probably familiar with the typical way of writing numbers in binary: $0 = 0_2$, $1 = 1_2$, $2 = 10_2$, $3 = 11_2$, $4 = 100_2$, $5 = 101_2$, $6 = 110_2$, etc. This is known as **big-endian format**. In big-endian format, the *most significant* bits come first. For example: $110_2 = 1 \cdot 4 + 1 \cdot 2 + 0 \cdot 1 = 4 + 2 = 6$. > > There is an alternate way of writing binary numbers - **little-endian format**. In little-endian format, the *least significant* bits come first. For example, $2$ would be written as $01$, $4$ as $001$, and $6$ as $011$. To put it another way, in little endian format, the number is written backwards compared to the big-endian format. > @@ -294,15 +296,15 @@ to the first element of the array.) @[example]({"id": "multi_qubit_systems__multi_qubit_systems_demo", "codePath": "./examples/MultiQubitSystems.qs"}) -> You might have noticed that we've been "resetting" the qubits at the end of our demos, that is, returning them to $\ket{0}$ state. Q# requires you to return your qubits into the $\ket{0}$ state before they are released at the end of their scope. +> You might have noticed that you've been "resetting" the qubits at the end of every demo, that is, returning them to $\ket{0}$ state. Q# requires you to return your qubits into the $\ket{0}$ state before they are released at the end of their scope. > The reason for this is entanglement. > > Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program. -If they are not in zero state by that time, they can potentially be still entangled with the qubits which are not yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior. +If they aren't in zero state by that time, they can potentially be still entangled with the qubits which aren't yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior. > > Resetting the qubits to zero state automatically when they go outside the scope of the block they were allocated in is dangerous as well: if they were entangled with others, measuring them to reset them can affect the state of the unreleased qubits, and thus change the results of the program - without the developer noticing this. > -> The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they are not entangled with unreleased qubits any more. +> The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they aren't entangled with unreleased qubits any more. @[exercise]({ "id": "multi_qubit_systems__learn_basis_state_amplitudes", @@ -315,8 +317,8 @@ If they are not in zero state by that time, they can potentially be still entang "title": "Separable State Preparation" }) -In the following exercises you will learn to prepare separable quantum states by manipulating individual qubits. -You will only need knowledge from the Single-Qubit Gates kata for that. +In the following exercises you'll learn to prepare separable quantum states by manipulating individual qubits. +You'll only need knowledge from the Single-Qubit Gates kata for that. > In each exercise, you'll be given an array of qubits to manipulate; you can access the $i$-th element of the array `qs` as `qs[i]`. Array elements are indexed starting with 0, the first array element corresponds to the leftmost qubit in Dirac notation. @@ -381,4 +383,4 @@ Congratulations! In this kata you learned to prepare separable multi-qubit state - Any two-qubit system can be expressed as some linear combination of the tensor products of single-qubit basis states. - Two qubits are entangled if their states are correlated and if they can't be described as two independent qubits. -Next, you will learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the "Multi-Qubit Gates" kata. +Next, you'll learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the "Multi-Qubit Gates" kata. diff --git a/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md b/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md index 2c2595778f..9f2d4c0f9a 100644 --- a/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md +++ b/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md @@ -10,5 +10,5 @@ once for every run.
Need a hint? - On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, we can use DumpMachine to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again. + On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, you can use DumpMachine to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So you can update the code to return the amplitudes that you've taken note of. Then run the code again.
diff --git a/katas/content/multi_qubit_systems/prepare_basis_state/solution.md b/katas/content/multi_qubit_systems/prepare_basis_state/solution.md index 3a0f4638af..22c896590b 100644 --- a/katas/content/multi_qubit_systems/prepare_basis_state/solution.md +++ b/katas/content/multi_qubit_systems/prepare_basis_state/solution.md @@ -4,7 +4,7 @@ $$ \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \ket{0} \otimes \ket{0} $$ The goal state can be represented as follows: $$ \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} = \ket{1} \otimes \ket{1} $$ -Applying an **X** gate to a qubit in the $\ket{0}$ state transforms the qubit state into the $\ket{1}$ state. So, if we apply the **X** gate on the first qubit and the second qubit, we get the desired state. +Applying an **X** gate to a qubit in the $\ket{0}$ state transforms the qubit state into the $\ket{1}$ state. So, if you apply the **X** gate on the first qubit and the second qubit, you get the desired state. @[solution]({ "id": "multi_qubit_systems__prepare_basis_state_solution", diff --git a/katas/content/multi_qubit_systems/prepare_superposition/solution.md b/katas/content/multi_qubit_systems/prepare_superposition/solution.md index f515a9982f..11296f4be2 100644 --- a/katas/content/multi_qubit_systems/prepare_superposition/solution.md +++ b/katas/content/multi_qubit_systems/prepare_superposition/solution.md @@ -1,15 +1,15 @@ -We begin in the same state as the previous exercise: +You begin in the same state as the previous exercise: $$ \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \ket{0} \otimes \ket{0}$$ The goal state can be separated as follows: $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ -1 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \ket{0} \otimes \frac{1}{\sqrt2}\big(\ket{0} - \ket{1}\big)$$ -This means that the first qubit is already in the state we want it to be, but the second qubit needs to be transformed from the $ \begin{bmatrix} 1 \\ 0 \end{bmatrix} $ into $ \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1\end{bmatrix}$ state. +This means that the first qubit is already in the state you want it to be, but the second qubit needs to be transformed from the $ \begin{bmatrix} 1 \\ 0 \end{bmatrix} $ into $ \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1\end{bmatrix}$ state. -First, we apply the **X** gate to the second qubit; this performs the following transformation: +First, you apply the **X** gate to the second qubit; this performs the following transformation: $$ X \ket{0} = \begin{bmatrix}0 & 1 \\ 1 & 0 \end{bmatrix} \cdot \begin{bmatrix}1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \ket{1} $$ -Second, we apply the **H** gate to the second qubit; this transforms its state into the desired one: +Second, you apply the **H** gate to the second qubit; this transforms its state into the desired one: $$ H\ket{1} = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix}$$ @[solution]({ diff --git a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md index 7695535912..392819897d 100644 --- a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md @@ -8,16 +8,16 @@ $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/2} \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ e^{i\pi/4} \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + e^{i\pi/2}\ket{1}\big) \otimes \frac{1}{\sqrt2}\big(\ket{0} + e^{i\pi/4}\ket{1}\big) $$ -We will again need to adjust the states of both qubits independently. +You will again need to adjust the states of both qubits independently. -For the first qubit, we'll start by applying the **H** gate, getting the state $\frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$, as we've seen in the previous task. Afterwards we'll apply the **S** gate with the following result: +For the first qubit, you'll start by applying the **H** gate, getting the state $\frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$, as you've seen in the previous task. Afterwards you'll apply the **S** gate with the following result: $$ \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \cdot \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ i \end{bmatrix}$$ -If we recall that $i = e^{i\pi/2}$, we can write the final state of the first qubit as: +If you recall that $i = e^{i\pi/2}$, you can write the final state of the first qubit as: $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/2} \end{bmatrix} $$ -For the second qubit. we'll apply the **H** gate, followed by the **T** gate, with the following result: +For the second qubit, you'll apply the **H** gate, followed by the **T** gate, with the following result: $$ \begin{bmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{bmatrix} \cdot \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/4} \end{bmatrix} $$ @[solution]({ diff --git a/katas/content/multi_qubit_systems/prepare_with_real/solution.md b/katas/content/multi_qubit_systems/prepare_with_real/solution.md index 3c1d2c2f45..ebf395a20a 100644 --- a/katas/content/multi_qubit_systems/prepare_with_real/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_real/solution.md @@ -1,12 +1,12 @@ -Again, to start we will represent the goal state as a tensor product of single-qubit states; this gives us the following representation: +Again, to start you will represent the goal state as a tensor product of single-qubit states; this gives you the following representation: $$ \frac{1}{2}\big(\ket{00} - \ket{01} + \ket{10} - \ket{11}\big) = \frac{1}{2}\begin{bmatrix} 1 \\ -1 \\ 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big) \otimes \frac{1}{\sqrt2}\big(\ket{0} - \ket{1}\big) $$ -This time we need to transform both the first and the second qubits. Let's start with the first qubit. Applying the **H** gate transforms its state as follows: +This time you need to transform both the first and the second qubits. Let's start with the first qubit. Applying the **H** gate transforms its state as follows: $$ H\ket{0} = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big)$$ -For the second qubit we can use the same transformation we've seen in the "Prepare a Superposition of Two Basis States" exercise; this will give the desired end state. +For the second qubit you can use the same transformation you've seen in the "Prepare a Superposition of Two Basis States" exercise; this will give the desired end state. @[solution]({ "id": "multi_qubit_systems__prepare_with_real_solution", diff --git a/katas/content/oracles/index.md b/katas/content/oracles/index.md index 28b6c52b52..091509a424 100644 --- a/katas/content/oracles/index.md +++ b/katas/content/oracles/index.md @@ -17,7 +17,9 @@ Quantum oracles are a key part of many quantum algorithms that rely on quantum i **What you should know to start working on this kata:** - Basic knowledge of fundamental quantum concepts -- Basic knowledge of multi-qubit gates, especially controlled gates. If you're not familiar with these concepts, you can find them in the Multi-Qubit Gates kata. +- Basic knowledge of multi-qubit gates, especially controlled gates + +If you need a refresher on these topics, you can check out the previous katas. @[section]({ "id": "oracles__classical_oracles", diff --git a/katas/content/qec_shor/index.md b/katas/content/qec_shor/index.md index 4197bbe353..c9db6d751e 100644 --- a/katas/content/qec_shor/index.md +++ b/katas/content/qec_shor/index.md @@ -20,6 +20,8 @@ This kata introduces you to the basic concepts of quantum error correction using - Basic knowledge of single-qubit and multi-qubit gates - Basic knowledge of single-qubit and multi-qubit quantum measurements and their effect on quantum systems +If you need a refresher on these topics, you can check out the previous katas. + @[section]({ "id": "qec_shor__noise", "title": "Noise in Classical and Quantum Systems" diff --git a/katas/content/qubit/index.md b/katas/content/qubit/index.md index 12a6fa6d34..417b294a48 100644 --- a/katas/content/qubit/index.md +++ b/katas/content/qubit/index.md @@ -22,6 +22,8 @@ This kata introduces you to one of the core concepts in quantum computing - the - Basic knowledge of complex arithmetic - Basic knowledge of linear algebra +If you need a refresher on these topics, you can check out the previous katas. + @[section]({ "id": "qubit__concept", "title": "The Concept of Qubit" From db5675176d459b8ed58c6b86d7783b3c093fdab3 Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:23:24 +0200 Subject: [PATCH 02/18] Update katas/content/multi_qubit_systems/bell_state_change_1/solution.md Co-authored-by: Mariia Mykhailova --- .../content/multi_qubit_systems/bell_state_change_1/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md index 2b603414cb..f1d13aa206 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md @@ -1,6 +1,6 @@ You recognize that the goal is another Bell state. In fact, it is one of the four Bell states. -You remember from the Single-Qubit Gates kata that the Pauli Z gate will change the state of the $\ket{1}$ basis state of a single qubit, so this gate seems like a good candidate for what you want to achieve. This gate leaves the sign of the $\ket{0}$ basis state of a superposition unchanged, but flips the sign of the $\ket{1}$ basis state of the superposition. +You have seen in the Single-Qubit Gates kata that the Pauli Z gate will change the state of the $\ket{1}$ basis state of a single qubit, so this gate seems like a good candidate for what you want to achieve. This gate leaves the sign of the $\ket{0}$ basis state of a superposition unchanged, but flips the sign of the $\ket{1}$ basis state of the superposition. Don't forget that the Z gate acts on only a single qubit, and you have two here. Let's also remember how the Bell state is made up from its individual qubits. From 68569a75bf98a71e7b0549fad253ee5416d02a7e Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:23:34 +0200 Subject: [PATCH 03/18] Update katas/content/multi_qubit_systems/bell_state_change_3/solution.md Co-authored-by: Mariia Mykhailova --- .../content/multi_qubit_systems/bell_state_change_3/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md index 271a2115f9..9704824da6 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md @@ -1,4 +1,4 @@ -You remember from the Single-Qubit Gates kata that the Pauli Z gate leaves the sign of the $\ket{0}$ component of the single qubit superposition unchanged but flips the sign of the $\ket{1}$ component of the superposition. You have also just seen in "Bell State Change 2" how to change our input state to the state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, which is almost your goal state (disregarding the phase change for the moment). So it would seem that a combination of these two gates will be what you need here. The remaining question is in what order to apply them, and to which qubit. +You have seen in the Single-Qubit Gates kata that the Pauli Z gate leaves the sign of the $\ket{0}$ component of the single qubit superposition unchanged but flips the sign of the $\ket{1}$ component of the superposition. You have also just seen in "Bell State Change 2" how to change our input state to the state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, which is almost your goal state (disregarding the phase change for the moment). So it would seem that a combination of these two gates will be what you need here. The remaining question is in what order to apply them, and to which qubit. First of all, which qubit? Looking back at the task "Bell state change 2", it seems clear that you need to use qubit `qs[0]`, like you did there. From 05291fa7895260bc923e1f0ca1345190ea17e368 Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:24:24 +0200 Subject: [PATCH 04/18] Update katas/content/multi_qubit_systems/index.md Co-authored-by: Mariia Mykhailova --- katas/content/multi_qubit_systems/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index 54dbe61dad..d5b43dcf50 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -27,7 +27,7 @@ If you need a refresher on these topics, you can check out the previous katas. "title": "Multi-Qubit Systems" }) -The Qubit kata covers the concept of a qubit - the basic building block of a quantum computer. +The Qubit kata discussed the concept of a qubit - the basic building block of a quantum computer. A multi-qubit system is a collection of multiple qubits, treated as a single system. Let's start by examining a system of two classical bits. Each bit can be in two states: $0$ and $1$. Therefore, a system of two bits can be in four different states: $00$, $01$, $10$, and $11$. Generally, a system of $N$ classical bits can be in any of the $2^N$ states. From 86d6dc1f4e5e79b2f51e0e8e61f5e30aae0d04e8 Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:24:38 +0200 Subject: [PATCH 05/18] Update katas/content/multi_qubit_systems/index.md Co-authored-by: Mariia Mykhailova --- katas/content/multi_qubit_systems/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index d5b43dcf50..477ec1d9af 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -296,7 +296,7 @@ to the first element of the array.) @[example]({"id": "multi_qubit_systems__multi_qubit_systems_demo", "codePath": "./examples/MultiQubitSystems.qs"}) -> You might have noticed that you've been "resetting" the qubits at the end of every demo, that is, returning them to $\ket{0}$ state. Q# requires you to return your qubits into the $\ket{0}$ state before they are released at the end of their scope. +> You might have noticed that every demo has been "resetting" the qubits at the end of the code, that is, returning them to $\ket{0}$ state. Q# requires you to return your qubits into the $\ket{0}$ state before they are released at the end of their scope. > The reason for this is entanglement. > > Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program. From e3e1e7c3dfe2c2843773b11378ea64bdad10132e Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:24:57 +0200 Subject: [PATCH 06/18] Update katas/content/multi_qubit_systems/prepare_with_complex/solution.md Co-authored-by: Mariia Mykhailova --- .../multi_qubit_systems/prepare_with_complex/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md index 392819897d..12a08152f1 100644 --- a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md @@ -10,7 +10,7 @@ $$ You will again need to adjust the states of both qubits independently. -For the first qubit, you'll start by applying the **H** gate, getting the state $\frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$, as you've seen in the previous task. Afterwards you'll apply the **S** gate with the following result: +For the first qubit, you'll start by applying the $H$ gate, getting the state $\frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$, as you've seen in the previous task. Afterwards you'll apply the $S$ gate with the following result: $$ \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \cdot \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ i \end{bmatrix}$$ From b105f87553220263de62fb84afc10f824c92b3bb Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:25:04 +0200 Subject: [PATCH 07/18] Update katas/content/multi_qubit_systems/prepare_with_complex/solution.md Co-authored-by: Mariia Mykhailova --- .../multi_qubit_systems/prepare_with_complex/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md index 12a08152f1..9996e96401 100644 --- a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md @@ -17,7 +17,7 @@ $$ \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} \cdot \frac{1}{\sqrt2} \begin{bm If you recall that $i = e^{i\pi/2}$, you can write the final state of the first qubit as: $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/2} \end{bmatrix} $$ -For the second qubit, you'll apply the **H** gate, followed by the **T** gate, with the following result: +For the second qubit, you'll apply the $H$ gate, followed by the $T$ gate, with the following result: $$ \begin{bmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{bmatrix} \cdot \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/4} \end{bmatrix} $$ @[solution]({ From 36963694d7ff1264a64a182ea6f76b70aab6a45a Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:46:43 +0200 Subject: [PATCH 08/18] Update katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md Co-authored-by: Mariia Mykhailova --- .../multi_qubit_systems/learn_basis_state_amplitudes/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md b/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md index 9f2d4c0f9a..a27c3e38cc 100644 --- a/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md +++ b/katas/content/multi_qubit_systems/learn_basis_state_amplitudes/index.md @@ -10,5 +10,5 @@ once for every run.
Need a hint? - On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, you can use DumpMachine to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So you can update the code to return the amplitudes that you've taken note of. Then run the code again. + On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, you can use DumpMachine to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees that the state will be the same from invocation to invocation. So, you can update the code to return the amplitudes that you've taken note of, then run the code again.
From 8dac62336b5e88bdb122863b7bb0f206e47a70cc Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Tue, 6 Aug 2024 17:42:06 +0200 Subject: [PATCH 09/18] Changing "knowledge" for "concepts" --- katas/content/deutsch_algo/index.md | 4 ++-- katas/content/deutsch_jozsa/index.md | 4 ++-- katas/content/multi_qubit_systems/index.md | 2 +- katas/content/oracles/index.md | 4 ++-- katas/content/qec_shor/index.md | 4 ++-- katas/content/qubit/index.md | 4 ++-- katas/content/random_numbers/index.md | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/katas/content/deutsch_algo/index.md b/katas/content/deutsch_algo/index.md index 10187daf07..a72e15b59f 100644 --- a/katas/content/deutsch_algo/index.md +++ b/katas/content/deutsch_algo/index.md @@ -16,8 +16,8 @@ This kata introduces you to Deutsch algorithm - the single-qubit variant of Deut **What you should know to start working on this kata:** -- Basic knowledge of single-qubit gates -- Basic knowledge of quantum measurements +- Basic concepts of single-qubit gates +- Basic concepts of quantum measurements If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/deutsch_jozsa/index.md b/katas/content/deutsch_jozsa/index.md index 258cdc9634..c2d97fab06 100644 --- a/katas/content/deutsch_jozsa/index.md +++ b/katas/content/deutsch_jozsa/index.md @@ -17,8 +17,8 @@ This kata introduces you to Deutsch-Jozsa algorithm - one of the most famous alg **What you should know to start working on this kata:** -- Basic knowledge of single-qubit gates -- Basic knowledge of quantum measurements +- Basic concepts of single-qubit gates +- Basic concepts of quantum measurements - Deutsch algorithm - the single-qubit variant of Deutsch-Jozsa algorithm. If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index 477ec1d9af..e71baf82e7 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -17,7 +17,7 @@ If you are not familiar with single-qubit systems, we recommend that you complet **What you should know to start working on this kata:** -- Basic knowledge of single-qubit gates +- Basic concepts of single-qubit gates - The concept of tensor product If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/oracles/index.md b/katas/content/oracles/index.md index 091509a424..946d8f7d81 100644 --- a/katas/content/oracles/index.md +++ b/katas/content/oracles/index.md @@ -16,8 +16,8 @@ Quantum oracles are a key part of many quantum algorithms that rely on quantum i **What you should know to start working on this kata:** -- Basic knowledge of fundamental quantum concepts -- Basic knowledge of multi-qubit gates, especially controlled gates +- Basic concepts of fundamental quantum concepts +- Basic concepts of multi-qubit gates, especially controlled gates If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/qec_shor/index.md b/katas/content/qec_shor/index.md index c9db6d751e..eb9d7494be 100644 --- a/katas/content/qec_shor/index.md +++ b/katas/content/qec_shor/index.md @@ -17,8 +17,8 @@ This kata introduces you to the basic concepts of quantum error correction using **What you should know to start working on this kata:** -- Basic knowledge of single-qubit and multi-qubit gates -- Basic knowledge of single-qubit and multi-qubit quantum measurements and their effect on quantum systems +- Basic concepts of single-qubit and multi-qubit gates +- Basic concepts of single-qubit and multi-qubit quantum measurements, and their effect on quantum systems If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/qubit/index.md b/katas/content/qubit/index.md index 417b294a48..fbb6e42214 100644 --- a/katas/content/qubit/index.md +++ b/katas/content/qubit/index.md @@ -19,8 +19,8 @@ This kata introduces you to one of the core concepts in quantum computing - the **What you should know to start working on this kata:** -- Basic knowledge of complex arithmetic -- Basic knowledge of linear algebra +- Basic concepts of complex arithmetic +- Basic concepts of linear algebra If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/random_numbers/index.md b/katas/content/random_numbers/index.md index 034bf5124b..76695beb7e 100644 --- a/katas/content/random_numbers/index.md +++ b/katas/content/random_numbers/index.md @@ -16,8 +16,8 @@ The quantum algorithm for random number generation is one of the simplest applic **What you should know to start working on this kata:** -- Basic knowledge of qubits and measurements -- Basic knowledge of single-qubit gates +- Basic concepts of qubits and measurements +- Basic concepts of single-qubit gates If you need a refresher on these topics, you can check out the previous katas. From 973f5efeeaba2b73754984fb116a41b9e8bc58a8 Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Wed, 7 Aug 2024 12:40:48 +0200 Subject: [PATCH 10/18] review of multiqubit measurements --- .../full_measurements/index.md | 4 +- .../full_measurements/solution.md | 18 +-- .../content/multi_qubit_measurements/index.md | 110 +++++++++--------- .../joint_measurements/solution.md | 8 +- .../solution.md | 2 +- .../state_modification/index.md | 2 +- .../state_modification/solution.md | 4 +- .../state_preparation/solution.md | 24 ++-- 8 files changed, 87 insertions(+), 85 deletions(-) diff --git a/katas/content/multi_qubit_measurements/full_measurements/index.md b/katas/content/multi_qubit_measurements/full_measurements/index.md index 1ba1afe211..f92f121f07 100644 --- a/katas/content/multi_qubit_measurements/full_measurements/index.md +++ b/katas/content/multi_qubit_measurements/full_measurements/index.md @@ -7,6 +7,6 @@ * 2 if they were in the $\ket{10}$ state, * 3 if they were in the $\ket{11}$ state. -In this task and the subsequent ones the order of qubit states in task description matches the order of qubits in the array (i.e., $\ket{10}$ state corresponds to `qs[0]` in state $\ket{1}$ and `qs[1]` in state $\ket{0}$). +In this task and the subsequent ones the order of qubit states in task description matches the order of qubits in the array (that is, $\ket{10}$ state corresponds to `qs[0]` in state $\ket{1}$ and `qs[1]` in state $\ket{0}$). -The state of the qubits at the end of the operation does not matter. +The state of the qubits at the end of the operation doesn't matter. diff --git a/katas/content/multi_qubit_measurements/full_measurements/solution.md b/katas/content/multi_qubit_measurements/full_measurements/solution.md index c549464417..110b990e4c 100644 --- a/katas/content/multi_qubit_measurements/full_measurements/solution.md +++ b/katas/content/multi_qubit_measurements/full_measurements/solution.md @@ -1,23 +1,23 @@ -First, we measure each of the qubits in the input array, convert the measurement results into integers -and store them in variables `m1` and `m2`. We can decode these results like this: +First, you measure each of the qubits in the input array, convert the measurement results into integers +and store them in variables `m1` and `m2`. You can decode these results like this: -- `m1` is $\ket{0}$ and `m2` is $\ket{0}$: we return $0\cdot2+0 = 0$ -- `m1` is $\ket{0}$ and `m2` is $\ket{1}$: we return $0\cdot2+1 = 1$ -- `m1` is $\ket{1}$ and `m2` is $\ket{0}$: we return $1\cdot2+0 = 2$ -- `m1` is $\ket{1}$ and `m2` is $\ket{1}$: we return $1\cdot2+1 = 3$ +- `m1` is $\ket{0}$ and `m2` is $\ket{0}$: the return value is $0\cdot2+0 = 0$ +- `m1` is $\ket{0}$ and `m2` is $\ket{1}$: the return value is $0\cdot2+1 = 1$ +- `m1` is $\ket{1}$ and `m2` is $\ket{0}$: the return value is $1\cdot2+0 = 2$ +- `m1` is $\ket{1}$ and `m2` is $\ket{1}$: the return value is $1\cdot2+1 = 3$ -In other words, we treat the measurement results as the binary notation of the return value in big-endian notation. +In other words, you treat the measurement results as the binary notation of the return value in big-endian notation. @[solution]({ "id": "multi_qubit_measurements__full_measurements_solution", "codePath": "Solution.qs" }) -We can generalize this code to read out an integer in big-endian notation from a qubit array of arbitrary length using several library operations and functions: +You can generalize this code to read out an integer in big-endian notation from a qubit array of arbitrary length using several library operations and functions: - `MeasureEachZ` measures each of the qubits in the array in the computational basis and returns an array of `Result` data type. - `Reversed` reverses the given array. -- `ResultArrayAsInt` converts an array of bits given as `Result` to an integer, assuming little-endian notation (that's why we have to reverse the array before converting it). +- `ResultArrayAsInt` converts an array of bits given as `Result` to an integer, assuming little-endian notation (that's why you have to reverse the array before converting it). @[solution]({ "id": "multi_qubit_measurements__full_measurements_solution_alt", diff --git a/katas/content/multi_qubit_measurements/index.md b/katas/content/multi_qubit_measurements/index.md index 6ce7a13263..4f1b9f859b 100644 --- a/katas/content/multi_qubit_measurements/index.md +++ b/katas/content/multi_qubit_measurements/index.md @@ -5,7 +5,7 @@ "title": "Overview" }) -In the previous kata, we discussed the concept of measurements done on single-qubit systems. +The previous kata discussed the concept of measurements done on single-qubit systems. Building upon those ideas, this kata will introduce you to measurements done on multi-qubit systems, and how to implement such measurements in Q#. This will include measuring a single qubit in a multi-qubit system, as well as measuring multiple qubits simultaneously. @@ -17,27 +17,29 @@ This will include measuring a single qubit in a multi-qubit system, as well as m **What you should know to start working on this kata:** -- Basic linear algebra -- Single and multi-qubit systems -- Single and multi-qubit gates -- Single-qubit system measurements +- Basic concepts of linear algebra +- Basic concepts of single and multi-qubit systems +- Basic concepts of single and multi-qubit gates +- Basic concepts of single-qubit system measurements + +If you need a refresher on any of these topics, you can check out the previous katas. ## Types of Measurements There are several types of measurements you can perform on an $n$-qubit system ($n>1$): -- Measuring all the qubits simultaneously in an orthogonal basis ($2^n$ possible outcomes). As we shall see below, this is a direct generalization of orthogonal basis measurements done in single-qubit systems introduced in the previous kata. +- Measuring all the qubits simultaneously in an orthogonal basis ($2^n$ possible outcomes). As you'll see below, this is a direct generalization of orthogonal basis measurements done in single-qubit systems introduced in the previous kata. - Partial measurement: measuring $m$ qubits out of $n$, for $m Solution -Using the expressions $\ket{0} = \frac{1}{\sqrt{2}} \big( \ket{+} + \ket{-} \big)$ and $\ket{1} = \frac{1}{\sqrt{2}} \big( \ket{+} - \ket{-} \big)$, we first express $\ket{\psi}$ in the Pauli X basis. This gives us +Using the expressions $\ket{0} = \frac{1}{\sqrt{2}} \big( \ket{+} + \ket{-} \big)$ and $\ket{1} = \frac{1}{\sqrt{2}} \big( \ket{+} - \ket{-} \big)$, you first express $\ket{\psi}$ in the Pauli X basis. This gives you $$\ket \psi = \frac{2}{3}\ket {00} + \frac{1}{3} \ket {01} + \frac{2}{3}\ket {11} =$$ $$= \frac{2}{3} \big[ \frac{1}{\sqrt{2}}\big(\ket{+} + \ket{-}\big) \otimes \frac{1}{\sqrt{2}} \big(\ket{+} + \ket{-}\big) \big] + \frac{1}{3} \big[ \frac{1}{\sqrt{2}}\big(\ket{+} + \ket{-}\big) \otimes \frac{1}{\sqrt{2}} \big(\ket{+} - \ket{-}\big) \big] + \frac{2}{3} \big[ \frac{1}{\sqrt{2}}\big(\ket{+} - \ket{-}\big) \otimes \frac{1}{\sqrt{2}} \big(\ket{+} - \ket{-}\big) \big] =$$ @@ -155,14 +157,14 @@ After this, the probabilities of measuring each of the four basis vectors is giv -Now, let's see how we can use Q# to solve these two problems. +Now, let's see how you can use Q# to solve these two problems. -1. We start by preparing the state $\ket \psi$. - To do this, we can represent $\ket \psi$ as follows: +1. You start by preparing the state $\ket \psi$. + To do this, you can represent $\ket \psi$ as follows: $$\frac 2 3 \ket{00} + \big( \frac 1 {\sqrt 5} \ket{0} + \frac 2 {\sqrt 5} \ket{1} \big) \frac {\sqrt 5} 3 \ket{1}$$ - This representation tells us how we should rotate individual qubits. -2. To figure out the measurement outcome probabilities in the computational basis, we can just use the `DumpMachine` function that lists probabilities associated with each basis state present in the superposition. -3. To figure out the measurement outcome probabilities in the Pauli X basis, we can apply a transformation that maps the two-qubit Pauli X basis into the two-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits. + This representation tells you how we should rotate individual qubits. +2. To figure out the measurement outcome probabilities in the computational basis, you can just use the `DumpMachine` function that lists probabilities associated with each basis state present in the superposition. +3. To figure out the measurement outcome probabilities in the Pauli X basis, you can apply a transformation that maps the two-qubit Pauli X basis into the two-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits. 4. View probabilities of each basis state with the `DumpMachine` function. Thanks to the previous step, the following state equivalence holds:
@@ -199,7 +201,7 @@ The amplitudes of the computational basis states after the transformation are th ## Measuring Each Qubit in a System Sequentially -As described in the previous sections, in theory it is possible to measure all the qubits in an $n$-qubit system simultaneously in an orthogonal basis. The post-measurement state of the qubits is then exactly one of the $2^n$ possible basis states. +As described in the previous sections, in theory it's possible to measure all the qubits in an $n$-qubit system simultaneously in an orthogonal basis. The post-measurement state of the qubits is then exactly one of the $2^n$ possible basis states. In practice, this is implemented by measuring all the qubits one after another. For example, if one wants to measure a two-qubit system in the computational basis, one can implement this by first measuring the first qubit in the computational basis to obtain $0$ or $1$, and then measuring the second qubit in the computational basis. This can result in one of the four possible outcomes: $00, 01, 10, 11$. @@ -208,21 +210,21 @@ This can be generalized to measurements in other bases, such as the 2-qubit Paul > Note that measurement of all qubits sequentially can only be done in orthogonal bases $\{ \ket{b_i}\}$, such that each $\ket{b_i}$ is a **tensor product state**. That is, each $\ket{b_i}$ must be of the form $\ket{v_0} \otimes \ket{v_1} \dotsc \otimes \ket{v_{n-1}}$, with each $\ket{v_j}$ being a single-qubit basis state. For example, for the two-qubit Pauli X basis $\ket{++}, \ket{+-}, \ket{-+}, \ket{--}$ each basis state is a tensor product of states $\ket{+}$ and $\ket{-}$, which form a single-qubit basis state. > -> Measuring in orthogonal bases which contain states which are not tensor product states, such as the Bell basis, are trickier to implement, and require appropriate unitary rotations in addition to measuring all qubits one after another. -> We will not discuss such measurements in this kata. +> Measuring in orthogonal bases which contain states which aren't tensor product states, such as the Bell basis, are trickier to implement, and require appropriate unitary rotations in addition to measuring all qubits one after another. +> Such measurements aren't discussed in this kata. > -> If we restrict ourselves to measurements in tensor product states, the distinction between measuring all the qubits simultaneously versus one after another is not important for an ideal quantum computer: in terms of the outcomes and measurement probabilities, both are identical. Furthermore, as long as all the qubits are measured, the sequence in which they are measured is also inconsequential. These factors can be important in the case of real quantum computers with imperfect qubits, but we restrict the discussion to ideal systems in this kata. +> If measurements are restricted to tensor product states, the distinction between measuring all the qubits simultaneously versus one after another is not important for an ideal quantum computer: in terms of the outcomes and measurement probabilities, both approaches are identical. Furthermore, as long as all the qubits are measured, the sequence in which they are measured is also inconsequential. These factors can be important in the case of real quantum computers with imperfect qubits, but the discussion in this kata is limited to ideal systems. @[section]({ "id": "multi_qubit_measurements__measurement_statistics", "title": "Measurement Statistics for Qubit-By-Qubit Full Measurement" }) -This demo illustrates the equivalence of the measurement probabilities for simultaneous measurement on all qubits, and measurements on each of the qubits executed one after another. We show that the measurement probabilities obtained using the `M` operation in Q# are the same as those expected theoretically, using the two-qubit state from the first exercise as an example: +This demo illustrates the equivalence of the measurement probabilities for simultaneous measurement on all qubits, and measurements on each of the qubits executed one after another. It shows that the measurement probabilities obtained using the `M` operation in Q# are the same as those expected theoretically, using the two-qubit state from the first exercise as an example: $$\ket \psi = \frac{1}{3}\ket {00} + \frac{2}{3} \ket {01} + \frac{2}{3}\ket {11}$$ -The simulated probabilities will be different for each run of `DemoBasisMeasurement`. The simulated and theoretical probabilities are not expected to be identical, since measurements are probabilistic. However, we expect the values to be similar, and the simulated probabilities to approach the theoretical probabilities as the parameter `numRuns` is increased. +The simulated probabilities will be different for each run of `DemoBasisMeasurement`. The simulated and theoretical probabilities are not expected to be identical, since measurements are probabilistic. However, the values are expected to be similar, and the simulated probabilities to approach the theoretical probabilities as the parameter `numRuns` is increased. @[example]({ "id": "multi_qubit_measurements__measuring_one_at_a_time", @@ -230,7 +232,7 @@ The simulated probabilities will be different for each run of `DemoBasisMeasurem }) -Full measurements can also be used to identify the state of the system, if it is guaranteed to be in one of several possible orthogonal states. +Full measurements can also be used to identify the state of the system, if it's guaranteed to be in one of several possible orthogonal states. @[exercise]({ "id": "multi_qubit_measurements__full_measurements", @@ -243,21 +245,21 @@ Full measurements can also be used to identify the state of the system, if it is "title": "Partial Measurements" }) -For a system with $n>1$ qubits, it is possible to measure $m1$ qubits, it's possible to measure $m The symbol $\otimes$ represents the tensor product or the Kronecker product of two matrices. It is different from the usual matrix multiplication. +> The symbol $\otimes$ represents the tensor product or the Kronecker product of two matrices. It's different from the usual matrix multiplication. > In the current context, $\ket{b_i} \bra{ b_i} \otimes \mathbb{1}_{n-m}$ simply means that > > - The operator $\ket{b_i} \bra{ b_i}$ acts only on the $m$ qubits being measured. -> - The effect of $P_i$ on the remaining qubits is $\mathbb{1}_{n-m} $, i.e., the identity operator. +> - The effect of $P_i$ on the remaining qubits is $\mathbb{1}_{n-m} $, that is, the identity operator. Analogous to the case for measurements for single-qubit systems, the rules for partial measurement probabilities and outcomes can be summarized as follows: @@ -268,7 +270,7 @@ $$ \frac{P_i \ket{\psi}}{\big|P_i \ket{\psi}\big|}. $$ -For example, consider a two-qubit system in the state $\ket \psi = \frac{1}{\sqrt{2}}\ket{01} - \frac{1}{\sqrt 2}\ket{10}$. Consider a measurement of the first qubit in the computational basis, i.e., in the $\{\ket 0 , \ket 1 \}$ basis. Then, we have two projectors that represent this measurement: +For example, consider a two-qubit system in the state $\ket \psi = \frac{1}{\sqrt{2}}\ket{01} - \frac{1}{\sqrt 2}\ket{10}$. Consider a measurement of the first qubit in the computational basis, that is, in the $\{\ket 0 , \ket 1 \}$ basis. Then, you have two projectors that represent this measurement: $$P_0 = \ket 0\bra 0 \otimes \mathbb{1}$$ $$P_1 = \ket 1 \bra 1 \otimes \mathbb{1}$$ @@ -278,10 +280,10 @@ $$P_0 \ket \psi = \left(\ket 0\bra 0 \otimes \mathbb{1}\right) \frac{1}{\sqrt 2} $$= \frac{1}{\sqrt 2} \big( \ket 0 \braket{0|0} \otimes \mathbb{1} \ket{1} - \ket 0 \braket{0|1} \otimes \mathbb{1} \ket 0 \big) = \frac{1}{\sqrt 2} \ket{01}$$ -Similarly, we obtain +Similarly, you obtain $$P_1 \ket\psi = -\frac{1}{\sqrt 2} \ket{10}$$ -Clearly, we have $\big|P_0 \ket \psi\big| = \big|P_1 \ket \psi\big| = \frac{1}{2}$ in this case. Thus, the probabilities of measuring $0$ and $1$ are both $0.5$, with the post-measurement states of system being $\ket{01}$ and $\ket{10}$, respectively. +Clearly, you have $\big|P_0 \ket \psi\big| = \big|P_1 \ket \psi\big| = \frac{1}{2}$ in this case. Thus, the probabilities of measuring $0$ and $1$ are both $0.5$, with the post-measurement states of system being $\ket{01}$ and $\ket{10}$, respectively. > Similar to the case of single-qubit system measurements, the applicability of the formalism above requires the state of the multi-qubit system, $\ket \psi$, to be normalized. This is required to ensure that all the probabilities of individual outcomes add up to 1. @@ -295,7 +297,7 @@ If only the first qubit is measured in the computational basis, what are the pro
Solution -A measurement outcome of $0$ on the first qubit corresponds to the projection operator $P_0 = \ket{0}\bra{ 0} \otimes \mathbb{1}$. Applying it to the state $\ket \psi$ gives us +A measurement outcome of $0$ on the first qubit corresponds to the projection operator $P_0 = \ket{0}\bra{ 0} \otimes \mathbb{1}$. Applying it to the state $\ket \psi$ gives you $$\big|P_0 \ket{\psi}\big|^2 = \big|\frac{1}{\sqrt{12}} \left(3\ket {00} + \ket{01}\right) \big|^2 = \frac{5}{6}$$ and $$\frac{P_0 \ket{\psi}}{\big|P_0 \ket{\psi}\big|} = \frac{1}{\sqrt{10}} \left( 3\ket{00} + \ket{01}\right)$$ @@ -328,17 +330,16 @@ $$\frac{P_1 \ket{\psi}}{\big|P_1 \ket{\psi}\big|} = \frac{1}{\sqrt{2}} \left(\ke "title": "Measurement Statistics for Partial Measurement" }) -In this demo, we show that the simulated outcome probabilities and post-measurement outcomes match the theoretical values obtained using the projection operators as described above. -We use the Hardy state $\ket \psi = \frac{1}{\sqrt{12}} \big(3\ket{00} + \ket{01} + \ket{10} + \ket{11}\big)$ from the previous exercise and do a computational basis measurement on the first qubit for this purpose. +This demo shows that the simulated outcome probabilities and post-measurement outcomes match the theoretical values obtained using the projection operators as described above. It uses the Hardy state $\ket \psi = \frac{1}{\sqrt{12}} \big(3\ket{00} + \ket{01} + \ket{10} + \ket{11}\big)$ from the previous exercise and do a computational basis measurement on the first qubit for this purpose. -The simulated and theoretical measurement probabilities are not expected to match exactly, but should be close to each other, since measurement is probabilistic. However, the post-measurement states from the simulation should match the expected states calculated in the exercise precisely, since partial state collapse is not a probabilistic process. +The simulated and theoretical measurement probabilities aren't expected to match exactly, but should be close to each other, since measurement is probabilistic. However, the post-measurement states from the simulation should match the expected states calculated in the exercise precisely, since partial state collapse isn't a probabilistic process. @[example]({ "id": "multi_qubit_measurements__partial_measurements_demo", "codePath": "./examples/PartialMeasurementsDemo.qs" }) -In certain situations, it is possible to distinguish between orthogonal states of multi-qubit systems using partial measurements, as illustrated in the next exercise. +In certain situations, it's possible to distinguish between orthogonal states of multi-qubit systems using partial measurements, as illustrated in the next exercise. @[exercise]({ "id": "multi_qubit_measurements__partial_measurements_for_system", @@ -353,9 +354,9 @@ In certain situations, it is possible to distinguish between orthogonal states o Entanglement has an effect on the measurement statistics of the system. If two qubits are entangled, then their measurement outcomes will be correlated, while separable states (which are by definition not entangled) have uncorrelated measurement outcomes. -> It is useful to revisit the concepts of entanglement and separable states, which were introduced in the Multi-Qubit Systems kata. Consider a system of $n>1$ qubits, which we divide into two parts: A, consisting of $m$ qubits, and B, consisting of the remaining $n-m$ qubits. We say that the state $\ket \psi$ of the entire system is separable if it can be expressed as a tensor product of the states of parts A and B: +> It's useful to revisit the concepts of entanglement and separable states, which were introduced in the Multi-Qubit Systems kata. Consider a system of $n>1$ qubits, which is divided into two parts: A, consisting of $m$ qubits, and B, consisting of the remaining $n-m$ qubits. The state $\ket \psi$ of the entire system is separable if it can be expressed as a tensor product of the states of parts A and B: > $$\ket \psi = \ket {\phi_A} \otimes \ket{\phi_B}$$ -> Here $\ket{\phi_A}$ and $\ket{\phi_B}$ are wave functions that describe parts $A$ and $B$, respectively. If it is not possible to express $\ket \psi$ in such a form, then we say that system A is entangled with system B. +> Here $\ket{\phi_A}$ and $\ket{\phi_B}$ are wave functions that describe parts $A$ and $B$, respectively. If it isn't possible to express $\ket \psi$ in such a form, then system A is entangled with system B. Consider a measurement on the subsystem $A$ of a separable state. Let the measurement be done in a basis $\{ \ket{b_0},\dotsc,\ket{b_{2^m-1}}\}$. According to the projection formalism, a projection operator $P_i = \ket{b_i}\bra{b_i} \otimes \mathbb{1}$ is chosen randomly. The corresponding post-measurement state of the system is then given by @@ -378,7 +379,7 @@ Consider two two-qubit states: - The Bell state $\ket{\Phi^{+}} = \frac{1}{\sqrt{2}} \big (\ket{00} + \ket{11}\big)$. - A state $\ket \Theta = \frac{1}{2} \big( \ket{00} + \ket{01} + \ket{10} + \ket{11} \big)$. -For both states, consider a measurement on the first qubit, followed by a measurement on the second qubit, both done in the computational basis. For which state can we expect the measurement outcomes to be correlated? Verify by calculating the sequential measurement probabilities explicitly for both states. +For both states, consider a measurement on the first qubit, followed by a measurement on the second qubit, both done in the computational basis. For which state can you expect the measurement outcomes to be correlated? Verify by calculating the sequential measurement probabilities explicitly for both states.
Solution @@ -391,7 +392,7 @@ For both states, consider a measurement on the first qubit, followed by a measur ## State Modification Using Partial Measurements -For certain multi-qubit systems prepared in a superposition state, it is possible to use partial measurements to collapse a part of the system to some desired state. +For certain multi-qubit systems prepared in a superposition state, it's possible to use partial measurements to collapse a part of the system to some desired state. @[exercise]({ "id": "multi_qubit_measurements__state_modification", @@ -405,8 +406,9 @@ For certain multi-qubit systems prepared in a superposition state, it is possibl }) Any multi-qubit state can be prepared from the $\ket{0...0}$ state using an appropriate combination of quantum gates. -However, sometimes it is easier and more efficient to prepare a state using partial measurements. -You could prepare a simpler state involving additional qubits, which, when measured, result in a collapse of the remaining qubits to the desired state with a high probability. This is called **post-selection**, and is particularly useful if it is easier to prepare the pre-measurement state with the extra qubits than to prepare the desired state directly using unitary gates alone. This is demonstrated by the following exercise. +However, sometimes it's easier and more efficient to prepare a state using partial measurements. +You could prepare a simpler state involving additional qubits, which, when measured, result in a collapse of the remaining qubits to the desired state with a high probability. This is called **post-selection**, and is particularly useful if it' +s easier to prepare the pre-measurement state with the extra qubits than to prepare the desired state directly using unitary gates alone. This is demonstrated by the following exercise. @[exercise]({ "id": "multi_qubit_measurements__state_preparation_using_partial_measurements", @@ -431,7 +433,7 @@ $$Z = \begin{bmatrix} 1 & 0 \\ 0 & -1\end{bmatrix} = \ket{0}\bra{0} - \ket{1}\br The $Z$ operator has two eigenvalues, $1$ and $-1$, with corresponding eigenvectors $\ket{0}$ and $\ket{1}$. A $Z$-measurement is then a measurement in the $\{\ket{0},\ket{1}\}$ basis, with the measurement outcomes being $1$ and $-1$, respectively. In Q#, by convention, an eigenvalue of $1$ corresponds to a `Result` of `Zero`, while an eigenvalue of $-1$ corresponds to a `Result` of `One`. -Similarly, one can implement measurements corresponding to the Pauli X and Y operators. We summarize the various properties below: +Similarly, one can implement measurements corresponding to the Pauli X and Y operators. This table summarizes the various properties:
@@ -483,7 +485,7 @@ Joint measurements are a generalization of this principle for multi-qubit matric The simplest joint measurement is a parity measurement. A parity measurement treats computational basis vectors differently depending on whether the number of 1s in the basis vector is even or odd. -For example, the operator $Z\otimes Z$, or $ZZ$ in short, is the parity measurement operator for a two-qubit system. The eigenvalues $1$ and $-1$ correspond to the subspaces spanned by basis vectors $\{ \ket{00}, \ket{11} \}$ and $\{ \ket{01}, \ket{10} \}$, respectively. That is, when a $ZZ$ measurement results in a `Zero` (i.e., the eigenvalue $+1$), the post-measurement state is a superposition of only those computational basis vectors which have an even number of 1s. On the other hand, a result of `One` corresponds to a post-measurement state with only computational basis vectors which have an odd number of 1s. +For example, the operator $Z\otimes Z$, or $ZZ$ in short, is the parity measurement operator for a two-qubit system. The eigenvalues $1$ and $-1$ correspond to the subspaces spanned by basis vectors $\{ \ket{00}, \ket{11} \}$ and $\{ \ket{01}, \ket{10} \}$, respectively. That is, when a $ZZ$ measurement results in a `Zero` (that is, the eigenvalue $+1$), the post-measurement state is a superposition of only those computational basis vectors which have an even number of 1s. On the other hand, a result of `One` corresponds to a post-measurement state with only computational basis vectors which have an odd number of 1s. > Let's see what happens to various two-qubit states after the parity measurement. The $Z \otimes Z$ matrix for two qubits is: > @@ -497,7 +499,7 @@ Z \otimes Z = \end{bmatrix} $$ > ->When this transformation is applied to a basis state $\ket{00}$, we get +>When this transformation is applied to a basis state $\ket{00}$, you get > >$$ \begin{bmatrix} @@ -512,11 +514,11 @@ $$ > >Comparing this to the characteristic equation for eigenvectors of $Z \otimes Z$ given by $ Z \otimes Z \ket{\psi} = \lambda \ket{\psi}$, -it is easy to see that $\ket{00}$ belongs to the $+1$ eigenspace, hence the $Z \otimes Z$ measurement will return `Zero` and leave the state unchanged. +it's easy to see that $\ket{00}$ belongs to the $+1$ eigenspace, hence the $Z \otimes Z$ measurement will return `Zero` and leave the state unchanged. > >Similarly, it can easily be verified that $\ket{11}$ also belongs to $+1$ eigenspace, while $\ket{01}$ and $\ket{10}$ belong to the $-1$ eigenspace. > ->Now, what happens if we apply a $Z \otimes Z$ measurement to a superposition state $\alpha \ket{00} + \beta \ket{11}$? We can see that +>Now, what happens if you apply a $Z \otimes Z$ measurement to a superposition state $\alpha \ket{00} + \beta \ket{11}$? You can see that > >$$ \begin{bmatrix} @@ -529,7 +531,7 @@ it is easy to see that $\ket{00}$ belongs to the $+1$ eigenspace, hence the $Z \ \begin{bmatrix} \alpha \\ 0 \\ 0 \\ \beta \end{bmatrix} $$ > ->So this state also belongs to the $+1$ eigenspace, and measuring it will return `Zero` and leave the state unchanged. Similarly, we can verify that an $\alpha \ket{01} + \beta \ket{10}$ state belongs to the $-1$ eigenspace, and measuring it will return `One` without changing the state. +>So this state also belongs to the $+1$ eigenspace, and measuring it will return `Zero` and leave the state unchanged. Similarly, you can verify that an $\alpha \ket{01} + \beta \ket{10}$ state belongs to the $-1$ eigenspace, and measuring it will return `One` without changing the state. Similarly, a parity measurement on a higher number of qubits can be implemented using a $Z \otimes \dotsc \otimes Z$ measurement. @@ -545,7 +547,7 @@ Similarly, a parity measurement on a higher number of qubits can be implemented }) Joint measurement is a generalization of the measurement in the computational basis. -Pauli measurements can also be generalized to a larger number of qubits. A multi-qubit Pauli measurement corresponds to an operator $M_1 \otimes \dotsc \otimes M_n$, with each $M_i$ being from the set of gates $\{X,Y,Z,I\}$. If at least one of the operators is not the identity matrix, then the measurement can result in two outcomes: a `Result` of `Zero` corresponding to eigenvalue $+1$ and a `Result` of `One` corresponding to the eigenvalue $-1$. The corresponding projection operators are the projections onto the corresponding eigenspaces. +Pauli measurements can also be generalized to a larger number of qubits. A multi-qubit Pauli measurement corresponds to an operator $M_1 \otimes \dotsc \otimes M_n$, with each $M_i$ being from the set of gates $\{X,Y,Z,I\}$. If at least one of the operators isn't the identity matrix, then the measurement can result in two outcomes: a `Result` of `Zero` corresponding to eigenvalue $+1$ and a `Result` of `One` corresponding to the eigenvalue $-1$. The corresponding projection operators are the projections onto the corresponding eigenspaces. For example, a Pauli/joint measurement corresponding to the $X\otimes Z$ operator can be characterized as follows:
Pauli Operator
@@ -581,7 +583,7 @@ What are the possible outcomes and their associated probabilities, if a measurem
Solution -The first step towards identifying the outcomes and their probabilities for joint measurements is to identify the eigenvectors corresponding to eigenvalues $\pm1$ of the Pauli operator. We note that since $X\ket{\pm}= \pm\ket{\pm}$, we have +The first step towards identifying the outcomes and their probabilities for joint measurements is to identify the eigenvectors corresponding to eigenvalues $\pm1$ of the Pauli operator. Note that since $X\ket{\pm}= \pm\ket{\pm}$, you have $$XX \ket{++} = \ket{++}$$ $$XX \ket{--} = \ket{--}$$ @@ -590,17 +592,17 @@ $$XX \ket{-+} = -\ket{-+}$$ Thus, the $XX$ operator measures the parity in the Hadamard, or the $\ket{\pm}$ basis. That is, it distinguishes basis states with an even number of $+$'s from basis states which have an odd number of $+$'s. -The projector corresponding to a result of `Zero` is given by $P_{+1} = \ket{++}\bra{++} + \ket{--}\bra{--}$, while the projector corresponding to a result of `One` is given by $P_{-1} = \ket{+-}\bra{+-} + \ket{-+}\bra{-+}$. Then, we note that $P_{+1}$ annihilates states with odd parity, while leaving states with even parity unaffected. That is, for any values of the constants +The projector corresponding to a result of `Zero` is given by $P_{+1} = \ket{++}\bra{++} + \ket{--}\bra{--}$, while the projector corresponding to a result of `One` is given by $P_{-1} = \ket{+-}\bra{+-} + \ket{-+}\bra{-+}$. Then, note that $P_{+1}$ annihilates states with odd parity, while leaving states with even parity unaffected. That is, for any values of the constants $$P_{+1} ( \gamma \ket{++} + \delta \ket{--} ) = ( \gamma \ket{++} + \delta \ket{--} )$$ $$P_{+1} ( \mu \ket{-+} + \nu \ket{+-} ) = 0$$ Similarly, $P_{-1}$ annihilates states with even parity, while leaving states with odd parity unaffected. -Now we express the given state in the Hadamard basis. We note that it is possible to go from the computational basis to the Hadamard basis using the following relations: +Now you express the given state in the Hadamard basis. Note that it's possible to go from the computational basis to the Hadamard basis using the following relations: $$\ket{0} = \frac{1}{\sqrt{2}} \left( \ket{+} + \ket{-} \right)$$ $$\ket{1} = \frac{1}{\sqrt{2}} \left( \ket{+} - \ket{-} \right)$$ -Using these, we obtain +Using these, you obtain $$ \alpha \ket{00} + \beta \ket{01} + \beta \ket{10} + \alpha \ket{11} = (\alpha + \beta) \ket{++} + (\alpha - \beta) \ket{--}$$ Thus, this state has an even parity in the Hadamard basis. It follows that an $XX$ Pauli measurement will result in the outcome `Zero` with probability 1, leaving the state unchanged after the measurement.
@@ -616,4 +618,4 @@ Congratulations! In this kata you learned how to apply measurements on multi-qub - Partial measurements: you measure $m$ qubits out of $n$, for $m< n$ ($2^m$ possible outcomes). - Joint measurement: Pauli measurement of all $n$ qubits ($2$ possible outcomes). -Next, you will implement a quantum algorithm to generate random numbers in "Quantum Random Number Generation" kata. +Next, you'll implement a quantum algorithm to generate random numbers in "Quantum Random Number Generation" kata. diff --git a/katas/content/multi_qubit_measurements/joint_measurements/solution.md b/katas/content/multi_qubit_measurements/joint_measurements/solution.md index 7cbd15af48..4845b3b913 100644 --- a/katas/content/multi_qubit_measurements/joint_measurements/solution.md +++ b/katas/content/multi_qubit_measurements/joint_measurements/solution.md @@ -1,11 +1,11 @@ -If we were not asked to maintain the state of the qubits, one approach would be to measure both the qubits separately in the computational basis, and check if the result is the same for both the measurements. If the measurement results are equal, the input state must have been a superposition of $\ket{00}$ and $\ket{11}$, while different measurement outcomes will imply that the input state must have been a superposition of $\ket{01}$ and $\ket{10}$. However, in these measurements we will lose the information about the original superposition states: a state $\alpha \ket{00} + \beta \ket{11}$ will collapse to either $\ket{00}$ or $\ket{11}$, and we won't be able to recover the information about the coefficients $\alpha$ and $\beta$. +If you weren't asked to maintain the state of the qubits, one approach would be to measure both the qubits separately in the computational basis, and check if the result is the same for both the measurements. If the measurement results are equal, the input state must have been a superposition of $\ket{00}$ and $\ket{11}$, while different measurement outcomes will imply that the input state must have been a superposition of $\ket{01}$ and $\ket{10}$. However, in these measurements we will lose the information about the original superposition states: a state $\alpha \ket{00} + \beta \ket{11}$ will collapse to either $\ket{00}$ or $\ket{11}$, and you won't be able to recover the information about the coefficients $\alpha$ and $\beta$. -We need to measure the *parity* of the state without collapsing it all the way to the basis states. Pauli measurements can be used for joint measurements involving multiple qubits. For this task we need to do the $Z \otimes Z$ measurement on both qubits. +You need to measure the *parity* of the state without collapsing it all the way to the basis states. Pauli measurements can be used for joint measurements involving multiple qubits. For this task we need to do the $Z \otimes Z$ measurement on both qubits. A joint measurement using $Z \otimes Z$ operator can be thought of as projecting the measured state to one of the two eigenspaces of $Z \otimes Z$ with $+1$ and $-1$ as the corresponding eigenvalues. The measurement returns `Zero` if the measured state is projected to the space with an eigenvalue of $+1$, and a result of `One` if projected to the space with an eigenvalue of $-1$. -As we've seen in the tutorial, the state $\alpha \ket{00} + \beta \ket{11}$ is an eigenstate of the $Z \otimes Z$ operator with the eigenvalue $+1$, and the state $\alpha \ket{01} + \beta \ket{10}$ is an eigenstate with the eigenvalue $-1$. -Hence, we can use this joint measurement to recognize which of the superposition states we were given while preserving the initial superposition state. +As you've seen in the tutorial, the state $\alpha \ket{00} + \beta \ket{11}$ is an eigenstate of the $Z \otimes Z$ operator with the eigenvalue $+1$, and the state $\alpha \ket{01} + \beta \ket{10}$ is an eigenstate with the eigenvalue $-1$. +Hence, you can use this joint measurement to recognize which of the superposition states we were given while preserving the initial superposition state. In Q#, the operation `Measure` can be used to measure multiple qubits using an array of `Pauli` constants (`PauliI`, `PauliX`, `PauliY`, or `PauliZ`) that define the basis for measurement. diff --git a/katas/content/multi_qubit_measurements/partial_measurements_for_system/solution.md b/katas/content/multi_qubit_measurements/partial_measurements_for_system/solution.md index 7bc7b86ca4..8d6f86abaf 100644 --- a/katas/content/multi_qubit_measurements/partial_measurements_for_system/solution.md +++ b/katas/content/multi_qubit_measurements/partial_measurements_for_system/solution.md @@ -1,4 +1,4 @@ -Since the state of the first qubit is different in these states ($\ket +$ and $\ket -$, respectively), it is sufficient to measure only the first qubit in the Pauli X basis in order to distinguish the two states. Furthermore, this measurement will not change the state of the system, since the post-projection state is identical to the original state regardless of the input state. +Since the state of the first qubit is different in these states ($\ket +$ and $\ket -$, respectively), it's sufficient to measure only the first qubit in the Pauli X basis in order to distinguish the two states. Furthermore, this measurement won't change the state of the system, since the post-projection state is identical to the original state regardless of the input state. @[solution]({ "id": "multi_qubit_measurements__partial_measurements_for_system_solution", diff --git a/katas/content/multi_qubit_measurements/state_modification/index.md b/katas/content/multi_qubit_measurements/state_modification/index.md index 3d860b91e9..b35ef6d9dd 100644 --- a/katas/content/multi_qubit_measurements/state_modification/index.md +++ b/katas/content/multi_qubit_measurements/state_modification/index.md @@ -10,4 +10,4 @@ where the constants $a$ and $b$ satisfying $|a|^2 + |b|^2 = 1$ are unknown. - If $ind$ equals 0, convert the state of the second qubit into $a\ket{0} + b\ket{1}$ - If $ind$ equals 1, convert the state of the second qubit into $b\ket{0} + a\ket{1}$. -The state of the first qubit at the end does not matter (it has to be not entangled with the second qubit). +The state of the first qubit at the end doesn't matter (it has to be not entangled with the second qubit). diff --git a/katas/content/multi_qubit_measurements/state_modification/solution.md b/katas/content/multi_qubit_measurements/state_modification/solution.md index a988be882b..bdd5680c1f 100644 --- a/katas/content/multi_qubit_measurements/state_modification/solution.md +++ b/katas/content/multi_qubit_measurements/state_modification/solution.md @@ -1,6 +1,6 @@ -We note that if we measure the first qubit in the computational basis, then an outcome of $0$ collapses the second qubit to the state $a\ket 0 + b \ket 1$, while an outcome of $1$ collapses the second qubit to the state $b\ket 0 + a \ket 1$. +Note that if you measure the first qubit in the computational basis, then an outcome of $0$ collapses the second qubit to the state $a\ket 0 + b \ket 1$, while an outcome of $1$ collapses the second qubit to the state $b\ket 0 + a \ket 1$. -Thus, if $ind=0$ and we measure $0$ or if $ind=1$ and we measure $1$, then after the measurement the second qubit will be in the desired state. On the other hand, if $ind=1$ and we measure $0$, or if $ind=0$ and we measure $1$, then the state of the second qubit after the measurement is not what we're looking for, but we can adjust it using the Pauli X gate. +Thus, if $ind=0$ and you measure $0$ or if $ind=1$ and we measure $1$, then after the measurement the second qubit will be in the desired state. On the other hand, if $ind=1$ and you measure $0$, or if $ind=0$ and you measure $1$, then the state of the second qubit after the measurement isn't what you're looking for, but you can adjust it using the Pauli X gate. @[solution]({ "id": "multi_qubit_measurements__state_modification_solution", diff --git a/katas/content/multi_qubit_measurements/state_preparation/solution.md b/katas/content/multi_qubit_measurements/state_preparation/solution.md index 0e1afc10d4..fd431a2930 100644 --- a/katas/content/multi_qubit_measurements/state_preparation/solution.md +++ b/katas/content/multi_qubit_measurements/state_preparation/solution.md @@ -1,26 +1,26 @@ -While it is possible to prepare the state $\ket \psi$ directly using unitary rotations, it is simpler to use post-selection for preparing it. +While it's possible to prepare the state $\ket \psi$ directly using unitary rotations, it's simpler to use post-selection for preparing it. -Initially we will prepare an equal superposition of all basis states on the first two qubits by applying the **H** gate to each of them, and allocate an extra qubit in the $\ket{0}$ state: +Initially, you prepare an equal superposition of all basis states on the first two qubits by applying the **H** gate to each of them, and allocate an extra qubit in the $\ket{0}$ state: $$\frac{1}{2} \big(\ket{00} + \ket{01} + \ket{10} + \ket{11}\big) \otimes \ket 0$$ -The state of the first two qubits is a superposition of the state we want to prepare and the $\ket{11}$ state that we would like to discard. +The state of the first two qubits is a superposition of the state you want to prepare and the $\ket{11}$ state that you want to discard. -Now, we want to separate the first three basis states from the last one and to store this separation in the extra qubit. -For example, we can keep the state of the extra qubit $\ket{0}$ for the basis states that we want to keep, and switch it to $\ket{1}$ for the basis states that we would like to discard. +Now, you want to separate the first three basis states from the last one and to store this separation in the extra qubit. +For example, you can keep the state of the extra qubit $\ket{0}$ for the basis states that you want to keep, and switch it to $\ket{1}$ for the basis states that you want to discard. A $CCNOT$ gate can do this, with the first two qubits used as control qubits and the extra qubit as target. -When the gate is applied, the state of the extra qubit will only change to $\ket{1}$ if both control qubits are in the $\ket{11}$ state, which marks exactly the state that we want to discard: +When the gate is applied, the state of the extra qubit will only change to $\ket{1}$ if both control qubits are in the $\ket{11}$ state, which marks exactly the state that you want to discard: $$CCNOT\frac{1}{2} \big(\ket{00\textbf{0}} + \ket{01\textbf{0}} + \ket{10\textbf{0}} + \ket{11\textbf{0}}\big) = \frac{1}{2}\big(\ket{00} + \ket{01} + \ket{10} \big) \otimes \ket{\textbf{0}} + \frac{1}{2}\ket{11} \otimes \ket{\textbf{1}} $$ -Finally, we measure just the extra qubit; this causes a partial collapse of the system to the state defined by the measurement result: -* If the result is $\ket{0}$, the first two qubits collapse to a state that is a linear combination of basis states which had the extra qubit in state $\ket{0}$, i.e., they end up in the target state $\frac{1}{\sqrt3}\big(\ket{00} + \ket{01} + \ket{10}\big)$. -* If the result is $\ket{1}$, the first two qubits collapse to a state $\ket{11}$, so our goal is not achieved. The good thing is, this only happens in 25% of the cases, and we can just reset our qubits to the $\ket{00}$ state and try again. +Finally, you measure just the extra qubit; this causes a partial collapse of the system to the state defined by the measurement result: +* If the result is $\ket{0}$, the first two qubits collapse to a state that is a linear combination of basis states which had the extra qubit in state $\ket{0}$, that is, they end up in the target state $\frac{1}{\sqrt3}\big(\ket{00} + \ket{01} + \ket{10}\big)$. +* If the result is $\ket{1}$, the first two qubits collapse to a state $\ket{11}$, so your goal is not achieved. The good thing is, this only happens in 25% of the cases, and you can just reset our qubits to the $\ket{00}$ state and try again. > Q# has a built-in repeat-until-success (RUS) loop, which comes in handy in this case. -> * We will describe the main operations (applying $H$ and $CCNOT$ gates and the measurement) in the `repeat` part of the loop, which specifies its body. -> * `until` section specifies the condition which will break the loop. In this case the result of the measurement needs to be `Zero` to indicate our success. -> * Finally, the `fixup` section allows us to clean up the results of the loop body execution before trying again if the success criteria is not met. In this case we reset the first two qubits back to the $\ket{00}$ state. +> * You'll describe the main operations (applying $H$ and $CCNOT$ gates and the measurement) in the `repeat` part of the loop, which specifies its body. +> * `until` section specifies the condition which will break the loop. In this case, the result of the measurement needs to be `Zero` to indicate your success. +> * Finally, the `fixup` section allows you to clean up the results of the loop body execution before trying again if the success criteria isn't met. In this case, you reset the first two qubits back to the $\ket{00}$ state. @[solution]({ "id": "multi_qubit_measurements__state_preparation_solution", From 78da1ebabf69809b16d6e639b44b3ce6bf884a18 Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Wed, 7 Aug 2024 21:39:03 +0200 Subject: [PATCH 11/18] Mariia's feedback abour prerequisistes --- katas/content/deutsch_algo/index.md | 4 ++-- katas/content/deutsch_jozsa/index.md | 4 ++-- katas/content/multi_qubit_systems/index.md | 2 +- katas/content/oracles/index.md | 4 ++-- katas/content/qec_shor/index.md | 4 ++-- katas/content/random_numbers/index.md | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/katas/content/deutsch_algo/index.md b/katas/content/deutsch_algo/index.md index a72e15b59f..6817daa1e3 100644 --- a/katas/content/deutsch_algo/index.md +++ b/katas/content/deutsch_algo/index.md @@ -16,8 +16,8 @@ This kata introduces you to Deutsch algorithm - the single-qubit variant of Deut **What you should know to start working on this kata:** -- Basic concepts of single-qubit gates -- Basic concepts of quantum measurements +- Basic single-qubit gates +- Quantum measurements If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/deutsch_jozsa/index.md b/katas/content/deutsch_jozsa/index.md index c2d97fab06..bbeeb7a933 100644 --- a/katas/content/deutsch_jozsa/index.md +++ b/katas/content/deutsch_jozsa/index.md @@ -17,8 +17,8 @@ This kata introduces you to Deutsch-Jozsa algorithm - one of the most famous alg **What you should know to start working on this kata:** -- Basic concepts of single-qubit gates -- Basic concepts of quantum measurements +- Basic single-qubit gates +- Quantum measurements - Deutsch algorithm - the single-qubit variant of Deutsch-Jozsa algorithm. If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index e71baf82e7..9e31bae8ac 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -17,7 +17,7 @@ If you are not familiar with single-qubit systems, we recommend that you complet **What you should know to start working on this kata:** -- Basic concepts of single-qubit gates +- Basic single-qubit gates - The concept of tensor product If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/oracles/index.md b/katas/content/oracles/index.md index 946d8f7d81..0beba3ad83 100644 --- a/katas/content/oracles/index.md +++ b/katas/content/oracles/index.md @@ -16,8 +16,8 @@ Quantum oracles are a key part of many quantum algorithms that rely on quantum i **What you should know to start working on this kata:** -- Basic concepts of fundamental quantum concepts -- Basic concepts of multi-qubit gates, especially controlled gates +- Fundamental quantum concepts +- Basic multi-qubit gates, especially controlled gates If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/qec_shor/index.md b/katas/content/qec_shor/index.md index eb9d7494be..120fa8c4e3 100644 --- a/katas/content/qec_shor/index.md +++ b/katas/content/qec_shor/index.md @@ -17,8 +17,8 @@ This kata introduces you to the basic concepts of quantum error correction using **What you should know to start working on this kata:** -- Basic concepts of single-qubit and multi-qubit gates -- Basic concepts of single-qubit and multi-qubit quantum measurements, and their effect on quantum systems +- Basic single-qubit and multi-qubit gates +- Single-qubit and multi-qubit quantum measurements, and their effect on quantum systems If you need a refresher on these topics, you can check out the previous katas. diff --git a/katas/content/random_numbers/index.md b/katas/content/random_numbers/index.md index 76695beb7e..656149d1e7 100644 --- a/katas/content/random_numbers/index.md +++ b/katas/content/random_numbers/index.md @@ -16,8 +16,8 @@ The quantum algorithm for random number generation is one of the simplest applic **What you should know to start working on this kata:** -- Basic concepts of qubits and measurements -- Basic concepts of single-qubit gates +- Quantum measurements +- Basic single-qubit gates If you need a refresher on these topics, you can check out the previous katas. From d62bab34b824b6af9a54b7645f4f13044d463300 Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Tue, 13 Aug 2024 19:34:17 +0200 Subject: [PATCH 12/18] Update index --- katas/content/multi_qubit_measurements/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/katas/content/multi_qubit_measurements/index.md b/katas/content/multi_qubit_measurements/index.md index 4f1b9f859b..089132fefb 100644 --- a/katas/content/multi_qubit_measurements/index.md +++ b/katas/content/multi_qubit_measurements/index.md @@ -18,9 +18,9 @@ This will include measuring a single qubit in a multi-qubit system, as well as m **What you should know to start working on this kata:** - Basic concepts of linear algebra -- Basic concepts of single and multi-qubit systems -- Basic concepts of single and multi-qubit gates -- Basic concepts of single-qubit system measurements +- Single and multi-qubit systems +- Basic single and multi-qubit gates +- Single-qubit system measurements If you need a refresher on any of these topics, you can check out the previous katas. From 5e15be06805ee1e49e6da605109cea12601fa21d Mon Sep 17 00:00:00 2001 From: Mariia Mykhailova Date: Tue, 13 Aug 2024 10:54:19 -0700 Subject: [PATCH 13/18] Update katas/content/multi_qubit_systems/prepare_with_real/solution.md Co-authored-by: Scott Carda <55811729+ScottCarda-MS@users.noreply.github.com> --- katas/content/multi_qubit_systems/prepare_with_real/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_systems/prepare_with_real/solution.md b/katas/content/multi_qubit_systems/prepare_with_real/solution.md index ebf395a20a..132c7c0a20 100644 --- a/katas/content/multi_qubit_systems/prepare_with_real/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_real/solution.md @@ -2,7 +2,7 @@ $$ \frac{1}{2}\big(\ket{00} - \ket{01} + \ket{10} - \ket{11}\big) = \frac{1}{2}\begin{bmatrix} 1 \\ -1 \\ 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big) \otimes \frac{1}{\sqrt2}\big(\ket{0} - \ket{1}\big) $$ -This time you need to transform both the first and the second qubits. Let's start with the first qubit. Applying the **H** gate transforms its state as follows: +This time you need to transform both the first and the second qubits. Let's start with the first qubit. Applying the $H$ gate transforms its state as follows: $$ H\ket{0} = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big)$$ From b046ebbe9088299957e4773644664df8067066b6 Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Tue, 13 Aug 2024 20:20:50 +0200 Subject: [PATCH 14/18] scrubbing LaTeX --- .../multi_qubit_systems/bell_state_change_1/solution.md | 6 +++--- .../multi_qubit_systems/bell_state_change_2/solution.md | 2 +- .../multi_qubit_systems/bell_state_change_3/solution.md | 2 +- katas/content/multi_qubit_systems/index.md | 2 +- .../multi_qubit_systems/prepare_basis_state/solution.md | 2 +- .../multi_qubit_systems/prepare_superposition/solution.md | 4 ++-- .../multi_qubit_systems/prepare_with_complex/solution.md | 2 +- .../multi_qubit_systems/prepare_with_real/solution.md | 6 +++--- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md index f1d13aa206..f063d9967d 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_1/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_1/solution.md @@ -2,14 +2,14 @@ You recognize that the goal is another Bell state. In fact, it is one of the fou You have seen in the Single-Qubit Gates kata that the Pauli Z gate will change the state of the $\ket{1}$ basis state of a single qubit, so this gate seems like a good candidate for what you want to achieve. This gate leaves the sign of the $\ket{0}$ basis state of a superposition unchanged, but flips the sign of the $\ket{1}$ basis state of the superposition. -Don't forget that the Z gate acts on only a single qubit, and you have two here. +Don't forget that the $Z$ gate acts on only a single qubit, and you have two here. Let's also remember how the Bell state is made up from its individual qubits. If the two qubits are A and B, where A is `qs[0]` and B is `qs[1]`, you can write that $\ket{\Phi^{+}} = \frac{1}{\sqrt{2}} \big(\ket{0_{A}0_{B}} + \ket{1_{A}1_{B}}\big)$. -If you apply the Z gate to the qubit A, it will flip the phase of the basis state $\ket{1_A}$. As this phase is in a sense spread across the entangled state, with $\ket{1_A}$ basis state being part of the second half of the superposition, this application has the effect of flipping the sign of the whole basis state $\ket{1_A1_B}$, as you can see by running the solution below. +If you apply the $Z$ gate to the qubit A, it will flip the phase of the basis state $\ket{1_A}$. As this phase is in a sense spread across the entangled state, with $\ket{1_A}$ basis state being part of the second half of the superposition, this application has the effect of flipping the sign of the whole basis state $\ket{1_A1_B}$, as you can see by running the solution below. -The exact same calculations can be done if you apply Z to the qubit B, so that's another possible solution. +The exact same calculations can be done if you apply $Z$ to the qubit B, so that's another possible solution. @[solution]({ "id": "multi_qubit_systems__bell_state_change_1_solution", "codePath": "Solution.qs" diff --git a/katas/content/multi_qubit_systems/bell_state_change_2/solution.md b/katas/content/multi_qubit_systems/bell_state_change_2/solution.md index 8e58cac823..387e63385d 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_2/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_2/solution.md @@ -1,4 +1,4 @@ -You have seen in the Single-Qubit Gates kata that the Pauli X gate flips $\ket{0}$ to $\ket{1}$ and vice versa, and as you seem to need some flipping of states, perhaps this gate may be of use. (Bearing in mind, of course, that the X gate operates on a single qubit). +You have seen in the Single-Qubit Gates kata that the Pauli X gate flips $\ket{0}$ to $\ket{1}$ and vice versa, and as you seem to need some flipping of states, perhaps this gate may be of use. (Bearing in mind, of course, that the $X$ gate operates on a single qubit). Let's compare the starting state $\frac{1}{\sqrt{2}} \big(\ket{0_A0_B} + \ket{1_A1_B}\big)$ with the goal state $\frac{1}{\sqrt{2}} \big(\ket{1_A0_B} + \ket{0_A1_B}\big)$ term by term and see how you need to transform it to reach the goal. diff --git a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md index 9704824da6..1caa360ff1 100644 --- a/katas/content/multi_qubit_systems/bell_state_change_3/solution.md +++ b/katas/content/multi_qubit_systems/bell_state_change_3/solution.md @@ -3,7 +3,7 @@ You have seen in the Single-Qubit Gates kata that the Pauli Z gate leaves the si First of all, which qubit? Looking back at the task "Bell state change 2", it seems clear that you need to use qubit `qs[0]`, like you did there. Second, in what order should you apply the gates? Remember that the Pauli Z gate flips the phase of the $\ket{1}$ component of the superposition and leaves the $\ket{0}$ component alone. -Let's experiment with applying X to `qs[0]` first. Looking at our "halfway answer" state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, you can see that if you apply the Z gate to `qs[0]`, it will leave the $\ket{0_{A}}$ alone but flip the phase of $\ket{1_{A}}$ to $-\ket{1_{A}}$, thus flipping the phase of the $\ket{11}$ component of our Bell state. +Let's experiment with applying $X$ gate to `qs[0]` first. Looking at our "halfway answer" state $\frac{1}{\sqrt{2}} \big(\ket{01} + \ket{10}\big)$, you can see that if you apply the $Z$ gate to `qs[0]`, it'll leave the $\ket{0_{A}}$ alone but flip the phase of $\ket{1_{A}}$ to $-\ket{1_{A}}$, thus flipping the phase of the $\ket{11}$ component of our Bell state. @[solution]({ "id": "multi_qubit_systems__bell_state_change_3_solution", diff --git a/katas/content/multi_qubit_systems/index.md b/katas/content/multi_qubit_systems/index.md index 9e31bae8ac..1ff8236008 100644 --- a/katas/content/multi_qubit_systems/index.md +++ b/katas/content/multi_qubit_systems/index.md @@ -352,7 +352,7 @@ Array elements are indexed starting with 0, the first array element corresponds "title": "Modifying Entangled States" }) -Entangled quantum states can be manipulated using single-qubit gates. For example, each state in the Bell basis is entangled and can be transformed into another Bell state through the application of single-qubit gates. In this lesson, you'll learn how to do that. (And we will learn more about applying single-qubit gates to multi-qubit states in the next kata.) +Entangled quantum states can be manipulated using single-qubit gates. For example, each state in the Bell basis is entangled and can be transformed into another Bell state through the application of single-qubit gates. In this lesson, you'll learn how to do that (and you'll learn more about applying single-qubit gates to multi-qubit states in the next kata). @[exercise]({ "id": "multi_qubit_systems__bell_state_change_1 ", diff --git a/katas/content/multi_qubit_systems/prepare_basis_state/solution.md b/katas/content/multi_qubit_systems/prepare_basis_state/solution.md index 22c896590b..f2e2f5dc12 100644 --- a/katas/content/multi_qubit_systems/prepare_basis_state/solution.md +++ b/katas/content/multi_qubit_systems/prepare_basis_state/solution.md @@ -4,7 +4,7 @@ $$ \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \ket{0} \otimes \ket{0} $$ The goal state can be represented as follows: $$ \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} = \ket{1} \otimes \ket{1} $$ -Applying an **X** gate to a qubit in the $\ket{0}$ state transforms the qubit state into the $\ket{1}$ state. So, if you apply the **X** gate on the first qubit and the second qubit, you get the desired state. +Applying an $X$ gate to a qubit in the $\ket{0}$ state transforms the qubit state into the $\ket{1}$ state. So, if you apply the $X$ gate on the first qubit and the second qubit, you get the desired state. @[solution]({ "id": "multi_qubit_systems__prepare_basis_state_solution", diff --git a/katas/content/multi_qubit_systems/prepare_superposition/solution.md b/katas/content/multi_qubit_systems/prepare_superposition/solution.md index 11296f4be2..6f665f25e7 100644 --- a/katas/content/multi_qubit_systems/prepare_superposition/solution.md +++ b/katas/content/multi_qubit_systems/prepare_superposition/solution.md @@ -6,10 +6,10 @@ $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ -1 \\ 0 \\ 0 \end{bmatrix} = \begin{bma This means that the first qubit is already in the state you want it to be, but the second qubit needs to be transformed from the $ \begin{bmatrix} 1 \\ 0 \end{bmatrix} $ into $ \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1\end{bmatrix}$ state. -First, you apply the **X** gate to the second qubit; this performs the following transformation: +First, you apply the $X$ gate to the second qubit; this performs the following transformation: $$ X \ket{0} = \begin{bmatrix}0 & 1 \\ 1 & 0 \end{bmatrix} \cdot \begin{bmatrix}1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \ket{1} $$ -Second, you apply the **H** gate to the second qubit; this transforms its state into the desired one: +Second, you apply the $H$ gate to the second qubit; this transforms its state into the desired one: $$ H\ket{1} = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix}$$ @[solution]({ diff --git a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md index 9996e96401..7bf2729537 100644 --- a/katas/content/multi_qubit_systems/prepare_with_complex/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_complex/solution.md @@ -8,7 +8,7 @@ $$ \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ e^{i\pi/2} \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ e^{i\pi/4} \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + e^{i\pi/2}\ket{1}\big) \otimes \frac{1}{\sqrt2}\big(\ket{0} + e^{i\pi/4}\ket{1}\big) $$ -You will again need to adjust the states of both qubits independently. +You'll again need to adjust the states of both qubits independently. For the first qubit, you'll start by applying the $H$ gate, getting the state $\frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$, as you've seen in the previous task. Afterwards you'll apply the $S$ gate with the following result: diff --git a/katas/content/multi_qubit_systems/prepare_with_real/solution.md b/katas/content/multi_qubit_systems/prepare_with_real/solution.md index ebf395a20a..12021edf70 100644 --- a/katas/content/multi_qubit_systems/prepare_with_real/solution.md +++ b/katas/content/multi_qubit_systems/prepare_with_real/solution.md @@ -1,12 +1,12 @@ -Again, to start you will represent the goal state as a tensor product of single-qubit states; this gives you the following representation: +Again, to start you'll represent the goal state as a tensor product of single-qubit states; this gives you the following representation: $$ \frac{1}{2}\big(\ket{00} - \ket{01} + \ket{10} - \ket{11}\big) = \frac{1}{2}\begin{bmatrix} 1 \\ -1 \\ 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} \otimes \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big) \otimes \frac{1}{\sqrt2}\big(\ket{0} - \ket{1}\big) $$ -This time you need to transform both the first and the second qubits. Let's start with the first qubit. Applying the **H** gate transforms its state as follows: +This time you need to transform both the first and the second qubits. Let's start with the first qubit. Applying the $H$ gate transforms its state as follows: $$ H\ket{0} = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \frac{1}{\sqrt2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \frac{1}{\sqrt2}\big(\ket{0} + \ket{1}\big)$$ -For the second qubit you can use the same transformation you've seen in the "Prepare a Superposition of Two Basis States" exercise; this will give the desired end state. +For the second qubit, you can use the same transformation you've seen in the "Prepare a Superposition of Two Basis States" exercise; this will give the desired end state. @[solution]({ "id": "multi_qubit_systems__prepare_with_real_solution", From 9decb7ce57f4343c47c28a51bdaa0212b2d10b3f Mon Sep 17 00:00:00 2001 From: SoniaLopezBravo Date: Tue, 13 Aug 2024 20:37:53 +0200 Subject: [PATCH 15/18] scrubbing LaTeX --- katas/content/multi_qubit_measurements/index.md | 3 +-- .../multi_qubit_measurements/joint_measurements/solution.md | 4 ++-- .../multi_qubit_measurements/state_preparation/index.md | 2 +- .../multi_qubit_measurements/state_preparation/solution.md | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/katas/content/multi_qubit_measurements/index.md b/katas/content/multi_qubit_measurements/index.md index 089132fefb..7d83226aa2 100644 --- a/katas/content/multi_qubit_measurements/index.md +++ b/katas/content/multi_qubit_measurements/index.md @@ -407,8 +407,7 @@ For certain multi-qubit systems prepared in a superposition state, it's possible Any multi-qubit state can be prepared from the $\ket{0...0}$ state using an appropriate combination of quantum gates. However, sometimes it's easier and more efficient to prepare a state using partial measurements. -You could prepare a simpler state involving additional qubits, which, when measured, result in a collapse of the remaining qubits to the desired state with a high probability. This is called **post-selection**, and is particularly useful if it' -s easier to prepare the pre-measurement state with the extra qubits than to prepare the desired state directly using unitary gates alone. This is demonstrated by the following exercise. +You could prepare a simpler state involving additional qubits, which, when measured, result in a collapse of the remaining qubits to the desired state with a high probability. This is called **post-selection**, and is particularly useful if it's easier to prepare the pre-measurement state with the extra qubits than to prepare the desired state directly using unitary gates alone. This is demonstrated by the following exercise. @[exercise]({ "id": "multi_qubit_measurements__state_preparation_using_partial_measurements", diff --git a/katas/content/multi_qubit_measurements/joint_measurements/solution.md b/katas/content/multi_qubit_measurements/joint_measurements/solution.md index 4845b3b913..bef55dc02b 100644 --- a/katas/content/multi_qubit_measurements/joint_measurements/solution.md +++ b/katas/content/multi_qubit_measurements/joint_measurements/solution.md @@ -1,11 +1,11 @@ -If you weren't asked to maintain the state of the qubits, one approach would be to measure both the qubits separately in the computational basis, and check if the result is the same for both the measurements. If the measurement results are equal, the input state must have been a superposition of $\ket{00}$ and $\ket{11}$, while different measurement outcomes will imply that the input state must have been a superposition of $\ket{01}$ and $\ket{10}$. However, in these measurements we will lose the information about the original superposition states: a state $\alpha \ket{00} + \beta \ket{11}$ will collapse to either $\ket{00}$ or $\ket{11}$, and you won't be able to recover the information about the coefficients $\alpha$ and $\beta$. +If you weren't asked to maintain the state of the qubits, one approach would be to measure both the qubits separately in the computational basis, and check if the result is the same for both the measurements. If the measurement results are equal, the input state must have been a superposition of $\ket{00}$ and $\ket{11}$, while different measurement outcomes will imply that the input state must have been a superposition of $\ket{01}$ and $\ket{10}$. However, in these measurements you'll lose the information about the original superposition states: a state $\alpha \ket{00} + \beta \ket{11}$ will collapse to either $\ket{00}$ or $\ket{11}$, and you won't be able to recover the information about the coefficients $\alpha$ and $\beta$. You need to measure the *parity* of the state without collapsing it all the way to the basis states. Pauli measurements can be used for joint measurements involving multiple qubits. For this task we need to do the $Z \otimes Z$ measurement on both qubits. A joint measurement using $Z \otimes Z$ operator can be thought of as projecting the measured state to one of the two eigenspaces of $Z \otimes Z$ with $+1$ and $-1$ as the corresponding eigenvalues. The measurement returns `Zero` if the measured state is projected to the space with an eigenvalue of $+1$, and a result of `One` if projected to the space with an eigenvalue of $-1$. As you've seen in the tutorial, the state $\alpha \ket{00} + \beta \ket{11}$ is an eigenstate of the $Z \otimes Z$ operator with the eigenvalue $+1$, and the state $\alpha \ket{01} + \beta \ket{10}$ is an eigenstate with the eigenvalue $-1$. -Hence, you can use this joint measurement to recognize which of the superposition states we were given while preserving the initial superposition state. +Hence, you can use this joint measurement to recognize which of the superposition states you were given while preserving the initial superposition state. In Q#, the operation `Measure` can be used to measure multiple qubits using an array of `Pauli` constants (`PauliI`, `PauliX`, `PauliY`, or `PauliZ`) that define the basis for measurement. diff --git a/katas/content/multi_qubit_measurements/state_preparation/index.md b/katas/content/multi_qubit_measurements/state_preparation/index.md index 588cf667e8..51b9e09644 100644 --- a/katas/content/multi_qubit_measurements/state_preparation/index.md +++ b/katas/content/multi_qubit_measurements/state_preparation/index.md @@ -6,5 +6,5 @@
Need a hint? Consider a 3-qubit state $\frac{1}{2}(\ket{00} + \ket{01} + \ket{11}) \otimes \ket{0} + \frac{1}{2} \ket{11} \otimes \ket{1}$. - What happens when one measures the third qubit? + What happens when you measure the third qubit?
diff --git a/katas/content/multi_qubit_measurements/state_preparation/solution.md b/katas/content/multi_qubit_measurements/state_preparation/solution.md index fd431a2930..523797cd19 100644 --- a/katas/content/multi_qubit_measurements/state_preparation/solution.md +++ b/katas/content/multi_qubit_measurements/state_preparation/solution.md @@ -1,6 +1,6 @@ While it's possible to prepare the state $\ket \psi$ directly using unitary rotations, it's simpler to use post-selection for preparing it. -Initially, you prepare an equal superposition of all basis states on the first two qubits by applying the **H** gate to each of them, and allocate an extra qubit in the $\ket{0}$ state: +Initially, you prepare an equal superposition of all basis states on the first two qubits by applying the $H$ gate to each of them, and allocate an extra qubit in the $\ket{0}$ state: $$\frac{1}{2} \big(\ket{00} + \ket{01} + \ket{10} + \ket{11}\big) \otimes \ket 0$$ The state of the first two qubits is a superposition of the state you want to prepare and the $\ket{11}$ state that you want to discard. From 4761bed507def8f68e64c771a5414ffa651821a7 Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:58:20 +0200 Subject: [PATCH 16/18] Update katas/content/multi_qubit_measurements/index.md --- katas/content/multi_qubit_measurements/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_measurements/index.md b/katas/content/multi_qubit_measurements/index.md index 7d83226aa2..0b7609a7f1 100644 --- a/katas/content/multi_qubit_measurements/index.md +++ b/katas/content/multi_qubit_measurements/index.md @@ -162,7 +162,7 @@ Now, let's see how you can use Q# to solve these two problems. 1. You start by preparing the state $\ket \psi$. To do this, you can represent $\ket \psi$ as follows: $$\frac 2 3 \ket{00} + \big( \frac 1 {\sqrt 5} \ket{0} + \frac 2 {\sqrt 5} \ket{1} \big) \frac {\sqrt 5} 3 \ket{1}$$ - This representation tells you how we should rotate individual qubits. + This representation tells you how you should rotate individual qubits. 2. To figure out the measurement outcome probabilities in the computational basis, you can just use the `DumpMachine` function that lists probabilities associated with each basis state present in the superposition. 3. To figure out the measurement outcome probabilities in the Pauli X basis, you can apply a transformation that maps the two-qubit Pauli X basis into the two-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits. 4. View probabilities of each basis state with the `DumpMachine` function. Thanks to the previous step, the following state equivalence holds: From 8a59ed4e2138bdd1702906d177ef34f95d8bc1b2 Mon Sep 17 00:00:00 2001 From: Sonia Lopez <74979440+SoniaLopezBravo@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:58:28 +0200 Subject: [PATCH 17/18] Update katas/content/multi_qubit_measurements/state_preparation/solution.md Co-authored-by: Mariia Mykhailova --- .../multi_qubit_measurements/state_preparation/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_measurements/state_preparation/solution.md b/katas/content/multi_qubit_measurements/state_preparation/solution.md index 523797cd19..9bf6788c09 100644 --- a/katas/content/multi_qubit_measurements/state_preparation/solution.md +++ b/katas/content/multi_qubit_measurements/state_preparation/solution.md @@ -18,7 +18,7 @@ Finally, you measure just the extra qubit; this causes a partial collapse of the * If the result is $\ket{1}$, the first two qubits collapse to a state $\ket{11}$, so your goal is not achieved. The good thing is, this only happens in 25% of the cases, and you can just reset our qubits to the $\ket{00}$ state and try again. > Q# has a built-in repeat-until-success (RUS) loop, which comes in handy in this case. -> * You'll describe the main operations (applying $H$ and $CCNOT$ gates and the measurement) in the `repeat` part of the loop, which specifies its body. +> * The main operations (applying $H$ and $CCNOT$ gates and the measurement) are described in the `repeat` part of the loop, which specifies its body. > * `until` section specifies the condition which will break the loop. In this case, the result of the measurement needs to be `Zero` to indicate your success. > * Finally, the `fixup` section allows you to clean up the results of the loop body execution before trying again if the success criteria isn't met. In this case, you reset the first two qubits back to the $\ket{00}$ state. From da10b4caaae11ff53c4b4318b3d5933b2f0b5670 Mon Sep 17 00:00:00 2001 From: Mariia Mykhailova Date: Tue, 20 Aug 2024 11:14:03 -0700 Subject: [PATCH 18/18] Update katas/content/multi_qubit_measurements/index.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: César Zaragoza Cortés --- katas/content/multi_qubit_measurements/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/katas/content/multi_qubit_measurements/index.md b/katas/content/multi_qubit_measurements/index.md index 0b7609a7f1..e24f2cd307 100644 --- a/katas/content/multi_qubit_measurements/index.md +++ b/katas/content/multi_qubit_measurements/index.md @@ -247,7 +247,7 @@ Full measurements can also be used to identify the state of the system, if it's For a system with $n>1$ qubits, it's possible to measure $m