diff --git a/katas/content/single_qubit_gates/amplitude_change/solution.md b/katas/content/single_qubit_gates/amplitude_change/solution.md index 561d1c2a78..589ea6b829 100644 --- a/katas/content/single_qubit_gates/amplitude_change/solution.md +++ b/katas/content/single_qubit_gates/amplitude_change/solution.md @@ -1,4 +1,4 @@ -We can recognize that we need to use one of the rotation gates Rx, Ry, and Rz (named because they "rotate" the qubit state in the three dimensional space visualized as the Bloch sphere about the x, y, and z axes, respectively), since they involve angle parameters. Of these three gates, only Ry rotates the basis states $\ket{0}$ and $\ket{1}$ to have real amplitudes (the other two gates introduce complex coefficients). +You can recognize that you need to use one of the rotation gates Rx, Ry, and Rz (named because they "rotate" the qubit state in the three dimensional space visualized as the Bloch sphere about the x, y, and z axes, respectively), since they involve angle parameters. Of these three gates, only Ry rotates the basis states $\ket{0}$ and $\ket{1}$ to have real amplitudes (the other two gates introduce complex coefficients). As a reminder, @@ -20,8 +20,8 @@ R_y(\theta)\ket{0} = $$ Recall that when applying a gate, you can tell what its matrix does to the basis states by looking at its columns: the first column of the matrix is the state into which it will transform the $\ket{0}$ state, and the second column is the state into which it will transform the $\ket{1}$ state. -One of the examples used by the testing harness has $\beta = 0.6, \gamma = 0.8$ and $\alpha = \frac{\pi}{3} = 1.0472$. -Since $\cos \frac{\pi}{3} = 0.5$ and $\sin \frac{\pi}{3} = 0.8660$, working to 4 decimal places, we can use $\frac{\theta}{2} = \alpha$ to compute: +One of the examples used by the testing harness has $\beta = 0.6, \gamma = 0.8$ and $\alpha = \frac{\pi}{3} ≈ 1.0472$. +Since $\cos \frac{\pi}{3} = 0.5$ and $\sin \frac{\pi}{3} = 0.8660$, working to 4 decimal places, you can use $\frac{\theta}{2} = \alpha$ to compute: $$ R_{y}(\theta) \ket{\psi}= @@ -33,7 +33,7 @@ R_{y}(\theta) \ket{\psi}= \begin{bmatrix}-0.3928\\ 0.9196\\ \end{bmatrix} $$ -Notice that we used $\frac{\theta}{2} = \alpha$; this means that in the Q# code we need to pass the angle $\theta = 2\alpha$. +Notice that $\frac{\theta}{2} = \alpha$; this means that in the Q# code you need to pass the angle $\theta = 2\alpha$. @[solution]({ "id": "single_qubit_gates__amplitude_change_solution", diff --git a/katas/content/single_qubit_gates/basis_change/solution.md b/katas/content/single_qubit_gates/basis_change/solution.md index 3f53e0b1f5..6de576453f 100644 --- a/katas/content/single_qubit_gates/basis_change/solution.md +++ b/katas/content/single_qubit_gates/basis_change/solution.md @@ -1,4 +1,4 @@ -We can recognize that the Hadamard gate changes states $\ket{0}$ and $\ket{1}$ to $\ket{+}$ and $\ket{-}$, respectively, and vice versa. +You can recognize that the Hadamard gate changes states $\ket{0}$ and $\ket{1}$ to $\ket{+}$ and $\ket{-}$, respectively, and vice versa. As a reminder, the Hadamard gate is defined by the following matrix: @@ -6,7 +6,7 @@ $$ \frac{1}{\sqrt{2}}\begin{bmatrix}1 & 1 \\1 & -1\end{bmatrix} $$ -For example, we can work out $H\ket{1}$ as follows: +For example, you can work out $H\ket{1}$ as follows: $$ H\ket{1}= @@ -17,7 +17,7 @@ H\ket{1}= \frac{1}{\sqrt{2}} \big(\ket{0} - \ket{1}\big) = \ket{-} $$ -Similarly, we can consider the effect of the Hadamard gate on the superposition state $\ket{\psi} = 0.6\ket{0} + 0.8\ket{1}$ (rounding the numbers to 4 decimal places): +Similarly, you can consider the effect of the Hadamard gate on the superposition state $\ket{\psi} = 0.6\ket{0} + 0.8\ket{1}$ (rounding the numbers to 4 decimal places): $$ H|\psi⟩ = diff --git a/katas/content/single_qubit_gates/complex_phase/solution.md b/katas/content/single_qubit_gates/complex_phase/solution.md index 3455033b35..d18f534da3 100644 --- a/katas/content/single_qubit_gates/complex_phase/solution.md +++ b/katas/content/single_qubit_gates/complex_phase/solution.md @@ -1,11 +1,11 @@ -We know that: +You know that: $$ R1(\alpha)= \begin{bmatrix}1 & 0 \\ 0 & \color{red}{e^{i\alpha}}\end{bmatrix} $$ -So we have: +So you have: $$ R1(\beta \ket{0} + \gamma \ket{1}) = @@ -18,8 +18,8 @@ $$ > Suppose now that $\alpha = \frac{\pi}{2}$. > Then $e^{i\alpha}= \cos\frac{\pi}{2} + i\sin\frac{\pi}{2}$. -> And, since $\cos\frac{\pi}{2}= 0$ and $\sin\frac{\pi}{2} = 1$, then we have that $\cos\frac{\pi}{2} + i \sin\frac{\pi}{2} = i$, and -> $R1(\frac{\pi}{2}) = S$, which we used in the second solution to the task "Relative Phase i". +> And, since $\cos\frac{\pi}{2}= 0$ and $\sin\frac{\pi}{2} = 1$, then you have that $\cos\frac{\pi}{2} + i \sin\frac{\pi}{2} = i$, and +> $R1(\frac{\pi}{2}) = S$, which you used in the second solution to the task "Relative Phase i". @[solution]({ "id": "single_qubit_gates__complex_phase_solution", diff --git a/katas/content/single_qubit_gates/global_phase_i/solution.md b/katas/content/single_qubit_gates/global_phase_i/solution.md index bfbd3d0f0c..e8a448e252 100644 --- a/katas/content/single_qubit_gates/global_phase_i/solution.md +++ b/katas/content/single_qubit_gates/global_phase_i/solution.md @@ -1,12 +1,12 @@ -We need to apply a gate which applies a global phase of $i$, i.e. $\ket{\psi} \rightarrow i\ket{\psi}$. +You need to apply a gate which applies a global phase of $i$, that is, $\ket{\psi} \rightarrow i\ket{\psi}$. The matrix representation of such a gate is $\begin{bmatrix} i & 0 \\ 0 & i \end{bmatrix} = i\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = iI$. -Since we are restricted to the Pauli gates, we use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase, therefore the product of all three Pauli gates is $XYZ = iI$. +Since you're restricted to the Pauli gates, you can use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase, therefore the product of all three Pauli gates is $XYZ = iI$. $$ \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} = \begin{bmatrix} i & 0 \\ 0 & i \end{bmatrix} $$ -> Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence we first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate. +> Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence you first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate. @[solution]({ "id": "single_qubit_gates__global_phase_i_solution", diff --git a/katas/content/single_qubit_gates/global_phase_minusone/index.md b/katas/content/single_qubit_gates/global_phase_minusone/index.md index 9d4d763f53..0ed2b5b89a 100644 --- a/katas/content/single_qubit_gates/global_phase_minusone/index.md +++ b/katas/content/single_qubit_gates/global_phase_minusone/index.md @@ -2,6 +2,6 @@ **Goal**: Change the state of the qubit to $- \beta \ket{0} - \gamma \ket{1}$. -> This change on its own is not observable - there is no experiment you can do on a standalone qubit to figure out whether it acquired the global phase or not. +> This change on its own is not observable - there's no experiment you can do on a standalone qubit to figure out whether it acquired the global phase or not. > However, you can use a controlled version of this operation to observe the global phase it introduces. > This is used in later katas as part of more complicated tasks. diff --git a/katas/content/single_qubit_gates/global_phase_minusone/solution.md b/katas/content/single_qubit_gates/global_phase_minusone/solution.md index 5b15cb430e..93cffd61d4 100644 --- a/katas/content/single_qubit_gates/global_phase_minusone/solution.md +++ b/katas/content/single_qubit_gates/global_phase_minusone/solution.md @@ -1,10 +1,10 @@ -A global phase is a phase factor that multiplies the entire quantum state. It is not observable when measuring the qubit's state, as the probabilities remain unchanged. However, it is significant when considering quantum state transformations. +A global phase is a phase factor that multiplies the entire quantum state. It isn't observable when measuring the qubit's state, as the probabilities remain unchanged. However, it's significant when considering quantum state transformations. Our task is to implement an operation that transforms the given qubit state from $\ket{\psi} = \beta \ket{0} + \gamma \ket{1}$ to $- \beta \ket{0} - \gamma \ket{1}$. -To do that, we utilize a sequence of gates. The Pauli Z gate followed by the Pauli X gate can be used to achieve this effect when applied in succession twice. +To do that, you use a sequence of gates. The Pauli Z gate followed by the Pauli X gate can be used to achieve this effect when applied in succession twice. -1. **Apply the Pauli Z gate**: The Z gate multiplies the $\ket{1}$ state by $-1$ but does not change the $\ket{0}$ state, converting our state $\beta \ket{0} + \gamma \ket{1}$ to $\beta \ket{0} - \gamma \ket{1}$. +1. **Apply the Pauli Z gate**: The Z gate multiplies the $\ket{1}$ state by $-1$ but doen't change the $\ket{0}$ state, converting our state $\beta \ket{0} + \gamma \ket{1}$ to $\beta \ket{0} - \gamma \ket{1}$. The matrix representation of the Z gate is: @@ -13,7 +13,7 @@ To do that, we utilize a sequence of gates. The Pauli Z gate followed by the Pau \begin{bmatrix}1 & 0 \\ 0 & -1 \end{bmatrix} $$ -2. **Apply the Pauli X gate**: The X gate flips the $\ket{0}$ and $\ket{1}$ basis states, converting our $\beta \ket{0} - \gamma \ket{1}$ state to $\beta \ket{1} - \gamma \ket{0}$. +2. **Apply the Pauli X gate**: The X gate flips the $\ket{0}$ and $\ket{1}$ basis states, converting $\beta \ket{0} - \gamma \ket{1}$ state to $\beta \ket{1} - \gamma \ket{0}$. The matrix representation of the X gate is: @@ -22,7 +22,7 @@ To do that, we utilize a sequence of gates. The Pauli Z gate followed by the Pau \begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix} $$ -3. **Repeat the Z and X gates**: Applying the Z gate again will multiply the $\ket{1}$ state (that used to be $\ket{0}$), converting our state $\beta \ket{1} - \gamma \ket{0}$ to $- \beta \ket{1} - \gamma \ket{0}$. Finally, the second X gate will restore the original basis states, but now with both amplitudes having acquired an additional phase of $-1$. This means our state has been multiplied by $-1$, achieving the required global phase change. +3. **Repeat the Z and X gates**: Applying the Z gate again will multiply the $\ket{1}$ state (that used to be $\ket{0}$), converting the state $\beta \ket{1} - \gamma \ket{0}$ to $- \beta \ket{1} - \gamma \ket{0}$. Finally, the second X gate will restore the original basis states, but now with both amplitudes having acquired an additional phase of $-1$. This means the state has been multiplied by $-1$, achieving the required global phase change. @[solution]({ "id": "single_qubit_gates__global_phase_minusone_solution", diff --git a/katas/content/single_qubit_gates/index.md b/katas/content/single_qubit_gates/index.md index e27966609b..04d3acee84 100644 --- a/katas/content/single_qubit_gates/index.md +++ b/katas/content/single_qubit_gates/index.md @@ -15,15 +15,17 @@ This kata introduces you to single-qubit gates. Quantum gates are the quantum co **What you should know to start working on this kata:** -- Basic linear algebra +- Basic knowledge of linear algebra - The concept of qubit +If you need a refresher on these topics, you can check out the previous katas. + @[section]({ "id": "single_qubit_gates__basics", "title": "The Basics" }) -There are certain properties common to all quantum gates. This section will introduce those properties, using the $X$ gate as an example. +There are certain properties common to all quantum gates. This section introduces those properties, using the $X$ gate as an example. ## Matrix Representation @@ -74,7 +76,7 @@ Matrix multiplication is associative, so this is equivalent to multiplying the $ >Note that matrix multiplication isn’t commutative, thus $(BA) \neq (AB)$. -All quantum gates are reversible - there is another gate which will undo any given gate's transformation, returning the qubit to its original state. +All quantum gates are reversible, that is, there exists another gate which will undo any given gate's transformation, returning the qubit to its original state. This means that when dealing with quantum gates, information about qubit states is never lost, as opposed to classical logic gates, some of which destroy information. Quantum gates are represented by unitary matrices, so the inverse of a gate is its adjoint; these terms are also used interchangeably in quantum computing. @@ -84,7 +86,7 @@ There is a simple way to find out what a gate does to the two computational basi $$A = \begin{bmatrix} \epsilon & \zeta \\ \eta & \mu \end{bmatrix}$$ -Watch what happens when we apply it to these states: +Watch what happens when applying $A$ to these states: $$ A\ket{0} = @@ -102,7 +104,7 @@ A\ket{1} = \begin{bmatrix} \zeta \\ \mu \end{bmatrix} = \zeta\ket{0} + \mu\ket{1} $$ -Notice that applying the gate to the $\ket{0}$ state transforms it into the state written as the first column of the gate's matrix. Likewise, applying the gate to the $\ket{1}$ state transforms it into the state written as the second column. This holds true for any quantum gate, including, of course, the $X$ gate: +Notice that applying the $A$ gate to the $\ket{0}$ state transforms it into the state written as the first column of the gate's matrix. Likewise, applying the $A$ gate to the $\ket{1}$ state transforms it into the state written as the second column. This holds true for any quantum gate, including, of course, the $X$ gate: $$X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$$ @@ -126,7 +128,7 @@ That is, applying a gate to a qubit in superposition is equivalent to applying t "title": "Ket-Bra Representation" }) -There is another way to represent quantum gates, this time using Dirac notation. However, the kets we've been using aren't enough to represent arbitrary matrices. We need to introduce another piece of notation: the **bra** (this is why Dirac notation is sometimes called **bra-ket notation**). +There is another way to represent quantum gates, this time using Dirac notation. However, kets aren't enough to represent arbitrary matrices. An additional notation is required: the **bra** (this is why Dirac notation is sometimes called **bra-ket notation**). Recall that kets represent column vectors; a bra is a ket's row vector counterpart. For any ket $\ket{\psi}$, the corresponding bra is its adjoint (conjugate transpose): $\bra{\psi} = \ket{\psi}^\dagger$. @@ -161,7 +163,7 @@ Some examples: Kets and bras give us a neat way to express inner and outer products. The inner product of $\ket{\phi}$ and $\ket{\psi}$ is the matrix product of $\bra{\phi}$ and $\ket{\psi}$, denoted as $\braket{\phi|\psi}$, and their outer product is the matrix product of $\ket{\phi}$ and $\bra{\psi}$, denoted as $\ket{\phi}\bra{\psi}$. Notice that the norm of $\ket{\psi}$ is $\sqrt{\braket{\psi|\psi}}$. -This brings us to representing matrices. Recall that the outer product of two vectors of the same size produces a square matrix. We can use a linear combination of several outer products of simple vectors (such as basis vectors) to express any square matrix. For example, the $X$ gate can be expressed as follows: +This leads to the representation of matrices via outer products. Recall that the outer product of two vectors of the same size produces a square matrix. You can use a linear combination of several outer products of simple vectors (such as basis vectors) to express any square matrix. For example, the $X$ gate can be expressed as follows: $$X = \ket{0}\bra{1} + \ket{1}\bra{0}$$ @@ -177,7 +179,7 @@ This representation can be used to carry out calculations in Dirac notation with $$X\ket{0} = \big(\ket{0}\bra{1} + \ket{1}\bra{0}\big)\ket{0} = \ket{0}\braket{1|0} + \ket{1}\braket{0|0} = \ket{0}\big(\braket{1|0}\big) + \ket{1}\big(\braket{0|0}\big) = \ket{0}(0) + \ket{1}(1) = \ket{1}$$ -> That last step may seem a bit confusing. Recall that $\ket{0}$ and $\ket{1}$ form an **orthonormal basis**. That is, they are both normalized, and they are orthogonal to each other. +> That last step may seem a bit confusing. Recall that $\ket{0}$ and $\ket{1}$ form an **orthonormal basis**. That is, they're both normalized, and they're orthogonal to each other. > > A vector is normalized if its norm is equal to $1$, which only happens if its inner product with itself is equal to $1$. This means that $\braket{0|0} = \braket{1|1} = 1$ > @@ -193,7 +195,7 @@ $$A = a_{00} \ket{0}\bra{0} + a_{01} \ket{0}\bra{1} + a_{10} \ket{1}\bra{0} + a_ "title": "Ket-Bra Decomposition" }) -This section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section is not necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later. +This section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section isn't necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later. You can use the properties of _eigenvalues_ and _eigenvectors_ to find the ket-bra decomposition of any gate. Given a gate $A$ and the orthogonal vectors $\ket{\phi}$ and $\ket{\psi}$, if: @@ -221,7 +223,7 @@ $$= \ket{0}\bra{1} + \ket{1}\bra{0}$$ "title": "Pauli Gates" }) -This section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief "cheatsheet" listing their effect on some common qubit states. +This section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief "cheat sheet" listing their effect on some common qubit states. You can use a tool called Quirk to visualize how these gates interact with various qubit states. @@ -312,16 +314,16 @@ Here are several properties of the Pauli gates that are easy to verify and conve The following example contains code demonstrating how to apply gates in Q#. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one. -In the previous kata we discussed that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit, but doesn't return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don't produce any output. +The previous kata mentioned that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit but doesn't return the resulting state of the qubit. That's the reason why you never assign the output of these gates to any variables in this demo - they don't produce any output. -The same principle applies to applying several gates in a row to a qubit. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $\ket{\psi}$ is denoted as $Z(X(\ket{\psi}))$, because the result of applying a gate to a state is another state. In Q#, applying a gate doesn't return anything, so you can't use its output as an input to another gate - something like `Z(X(q))` will not produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they are applied: +The same principle applies to applying several gates in a row to a qubit. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $\ket{\psi}$ is denoted as $Z(X(\ket{\psi}))$, because the result of applying a gate to a state is another state. In Q#, applying a gate doesn't return anything, so you can't use its output as an input to another gate - something like `Z(X(q))` won't produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they're applied: ```qsharp X(q); Z(q); ``` -All the basic gates we will be covering in this kata are part of the Intrinsic namespace. We're also using the function DumpMachine to print the state of the quantum simulator. +All the basic gates covered in this kata are part of the Intrinsic namespace. Additionally, the function `DumpMachine` from the Diagnostics namespace is used to print the state of the quantum simulator. @[example]({"id": "single_qubit_gates__pauli_gates_in_qsharp_demo", "codePath": "./examples/PauliGates.qs"}) @@ -367,7 +369,7 @@ All the basic gates we will be covering in this kata are part of the Intrinsic n "title": "Identity Gate" }) -The identity gate is mostly here for completeness, at least for now. It will come in handy when dealing with multi-qubit systems and multi-qubit gates. It is represented by the identity matrix, and does not affect the state of the qubit. +The identity gate is mostly here for completeness, at least for now. It will come in handy when dealing with multi-qubit systems and multi-qubit gates. It's represented by the identity matrix, and doesn't affect the state of the qubit. @@ -435,7 +437,7 @@ $H\ket{-i} = e^{-i\pi/4}\ket{i} $
"title": "Phase Shift Gates" }) -The next two gates are known as phase shift gates. They apply a phase to the $\ket{1}$ state, and leave the $\ket{0}$ state unchanged. +The next two gates are known as **phase shift gates**. They apply a phase to the $\ket{1}$ state, and leave the $\ket{0}$ state unchanged.
@@ -496,8 +498,8 @@ These gates are the $X$ rotation gate $R_x(\theta)$, $Y$ rotation gate $R_y(\the Note that for the first three gates the parameter $\theta$ is multiplied by $\frac{1}{2}$ within the gate's matrix. > These gates are known as rotation gates, because they represent rotations around various axes on the Bloch sphere. The Bloch sphere is a way of representing the qubit states visually, mapping them onto the surface of a sphere. -> Unfortunately, this visualization isn't very useful beyond single-qubit states, which is why we have opted not to go into details in this kata. -> If you are curious about it, you can learn more in this Wikipedia article. +> Unfortunately, this visualization isn't very useful beyond single-qubit states, which is why this kata doesn't go into details. +> If you're curious about it, you can learn more in this Wikipedia article.
@@ -597,4 +599,4 @@ Congratulations! In this kata you learned the matrix and the ket-bra representa - Any square matrix can be represented as a linear combination of the outer products of vectors. The outer product is the matrix product of $\ket{\phi}$ and $\bra{\psi}$, denoted as $\ket{\phi}\bra{\psi}$. - Pauli gates, identity and Hadamard gates, phase shift gates, and rotation gates are examples of single-qubit gates. All of them are available in Q#. -Next, you will learn about multi-qubit systems in the “Multi-Qubit Systems” kata. +Next, you'll learn about multi-qubit systems in the “Multi-Qubit Systems” kata. diff --git a/katas/content/single_qubit_gates/phase_i/solution.md b/katas/content/single_qubit_gates/phase_i/solution.md index 35a523820f..8cccbb91f8 100644 --- a/katas/content/single_qubit_gates/phase_i/solution.md +++ b/katas/content/single_qubit_gates/phase_i/solution.md @@ -1,6 +1,6 @@ #### Solution 1 -We can recognize that the $S$ gate performs this particular relative phase addition to the $\ket{1}$ basis state. As a reminder, +You can recognize that the $S$ gate performs this particular relative phase addition to the $\ket{1}$ basis state. As a reminder, $$ S = diff --git a/katas/content/single_qubit_gates/prepare_arbitrary_state/index.md b/katas/content/single_qubit_gates/prepare_arbitrary_state/index.md index 41d367c4cb..e0ef5ea196 100644 --- a/katas/content/single_qubit_gates/prepare_arbitrary_state/index.md +++ b/katas/content/single_qubit_gates/prepare_arbitrary_state/index.md @@ -7,4 +7,4 @@ **Goal:** Transform the qubit into state $\alpha\ket{0} + e^{i\theta}\beta\ket{1}$. -> Since only the relative amplitudes and relative phase have any physical meaning, this allows us to prepare any single-qubit quantum state we want to. \ No newline at end of file +> Since only the relative amplitudes and relative phase have any physical meaning, this allows you to prepare any single-qubit quantum state you want to. diff --git a/katas/content/single_qubit_gates/prepare_arbitrary_state/solution.md b/katas/content/single_qubit_gates/prepare_arbitrary_state/solution.md index 41c69eb2e7..f135c3fef8 100644 --- a/katas/content/single_qubit_gates/prepare_arbitrary_state/solution.md +++ b/katas/content/single_qubit_gates/prepare_arbitrary_state/solution.md @@ -2,7 +2,7 @@ This exercise can be done in two steps. 1. Convert the state from $\ket{0}$ to $\alpha\ket{0} + \beta\ket{1}$. This can be done in a similar manner to the "Preparing a Rotated State" exercise, we first prepare an $\alpha\ket{0} -i\beta\ket{1}$ state using the $R_x$ gate, and then removing the relative phase of $-i$ by applying the $S$ gate, which would turn $\alpha\ket{0} -i\beta\ket{1}$ to $\alpha\ket{0} + \beta\ket{1}$. - An alternative, simpler approach is to use the $R_y$ gate, which allows us to get the necessary state right away without introducing a relative phase: + An alternative, simpler approach is to use the $R_y$ gate, which allows you to get the necessary state right away without introducing a relative phase: $$ R_y(2\arctan\frac{\beta}{\alpha}) = \begin{bmatrix} \alpha & -\beta \\ \beta & \alpha \end{bmatrix} $$ diff --git a/katas/content/single_qubit_gates/prepare_minus/solution.md b/katas/content/single_qubit_gates/prepare_minus/solution.md index 35761b7f68..fcce962d71 100644 --- a/katas/content/single_qubit_gates/prepare_minus/solution.md +++ b/katas/content/single_qubit_gates/prepare_minus/solution.md @@ -1,5 +1,5 @@ -We know that applying the Hadamard gate $H$ on the computational basis states $\ket{0}$ and $\ket{1}$ results in Hadamard basis states $\ket{+}$ and $\ket{-}$, respectively. -We are given a qubit in the state $\ket{0}$. We first apply the Pauli $X$ gate to turn it into $X\ket{0}=\ket{1}$, and then apply the $H$ gate, turning the qubit into the required $H\ket{1}=\ket{-}$ state. +You know that applying the Hadamard gate $H$ on the computational basis states $\ket{0}$ and $\ket{1}$ results in Hadamard basis states $\ket{+}$ and $\ket{-}$, respectively. +You're given a qubit in the state $\ket{0}$. You first apply the Pauli $X$ gate to turn it into $X\ket{0}=\ket{1}$, and then apply the $H$ gate, turning the qubit into the required $H\ket{1}=\ket{-}$ state. @[solution]({ "id": "single_qubit_gates__prepare_minus_solution", diff --git a/katas/content/single_qubit_gates/prepare_rotated_state/index.md b/katas/content/single_qubit_gates/prepare_rotated_state/index.md index a6480989c9..d68844cfe6 100644 --- a/katas/content/single_qubit_gates/prepare_rotated_state/index.md +++ b/katas/content/single_qubit_gates/prepare_rotated_state/index.md @@ -5,6 +5,6 @@ **Goal:** Use a rotation gate to transform the qubit into state $\alpha\ket{0} -i\beta\ket{1}$. -> You will probably need functions from the `Microsoft.Quantum.Math` namespace, specifically ArcTan2. +> You'll probably need functions from the `Microsoft.Quantum.Math` namespace, specifically ArcTan2. > > You can assign variables in Q# by using the `let` keyword: `let num = 3;` or `let result = Function(input);` diff --git a/katas/content/single_qubit_gates/prepare_rotated_state/solution.md b/katas/content/single_qubit_gates/prepare_rotated_state/solution.md index 4cfaa7b7fc..a04c31b536 100644 --- a/katas/content/single_qubit_gates/prepare_rotated_state/solution.md +++ b/katas/content/single_qubit_gates/prepare_rotated_state/solution.md @@ -1,9 +1,9 @@ -We use the rotation gate $R_x(\theta)$. This gate turns the state $\ket{0}$ into $R_x(\theta)\ket{0} = \cos\frac{\theta}{2}\ket{0} - i\sin\frac{\theta}{2}\ket{1}$. -This is similar to the state we need. We just need to find an angle $\theta$ such that $\cos\frac{\theta}{2}=\alpha$ and $\sin\frac{\theta}{2}=\beta$. We can use these two equations to solve for $\theta$: $\theta = 2\arctan\frac{\beta}{\alpha}$. (*Note: It is given that $\alpha^2 + \beta^2=1$*). +You use the rotation gate $R_x(\theta)$. This gate turns the state $\ket{0}$ into $R_x(\theta)\ket{0} = \cos\frac{\theta}{2}\ket{0} - i\sin\frac{\theta}{2}\ket{1}$. +This is similar to the state you need. You just need to find an angle $\theta$ such that $\cos\frac{\theta}{2}=\alpha$ and $\sin\frac{\theta}{2}=\beta$. You can use these two equations to solve for $\theta$: $\theta = 2\arctan\frac{\beta}{\alpha}$. (*Note: It's given that $\alpha^2 + \beta^2=1$*). Hence the required gate is $R_x(2\arctan\frac{\beta}{\alpha})$, which in matrix form is $\begin{bmatrix} \alpha & -i\beta \\ -i\beta & \alpha \end{bmatrix}$. This gate turns $\ket{0} = \begin{bmatrix} 1 \\ 0\end{bmatrix}$ into $\begin{bmatrix} \alpha & -i\beta \\ -i\beta & \alpha \end{bmatrix} \begin{bmatrix} 1 \\ 0\end{bmatrix} = \begin{bmatrix} \alpha \\ -i\beta \end{bmatrix} = \alpha\ket{0} -i\beta\ket{1}$. -> Trigonometric functions are available in Q# via the `Microsoft.Quantum.Math` namespace. In this case we will need ArcTan2. +> Trigonometric functions are available in Q# via the `Microsoft.Quantum.Math` namespace. In this case, you'll need ArcTan2. @[solution]({ "id": "single_qubit_gates__prepare_rotated_state_solution", diff --git a/katas/content/single_qubit_gates/sign_flip/index.md b/katas/content/single_qubit_gates/sign_flip/index.md index c7cc9318e0..17ad67315a 100644 --- a/katas/content/single_qubit_gates/sign_flip/index.md +++ b/katas/content/single_qubit_gates/sign_flip/index.md @@ -1,3 +1,3 @@ **Input**: A qubit in state $\ket{\psi} = \alpha \ket{0} + \beta \ket{1}$. -**Goal** : Change the qubit state to $\alpha \ket{0} - \beta \ket{1}$ (i.e., flip the sign of the $\ket{1}$ component of the superposition). +**Goal** : Change the qubit state to $\alpha \ket{0} - \beta \ket{1}$, that is, flip the sign of the $\ket{1}$ component of the superposition. diff --git a/katas/content/single_qubit_gates/sign_flip_on_zero/index.md b/katas/content/single_qubit_gates/sign_flip_on_zero/index.md index 1777a019a2..83abf2b50f 100644 --- a/katas/content/single_qubit_gates/sign_flip_on_zero/index.md +++ b/katas/content/single_qubit_gates/sign_flip_on_zero/index.md @@ -1,5 +1,5 @@ **Input:** A qubit in an arbitrary state $\ket{\psi} = \alpha\ket{0} + \beta\ket{1}$. -**Goal:** Use several Pauli gates to change the qubit state to $- \alpha\ket{0} + \beta\ket{1}$, i.e., apply the transformation represented by the following matrix: +**Goal:** Use several Pauli gates to change the qubit state to $- \alpha\ket{0} + \beta\ket{1}$, that is, apply the transformation represented by the following matrix: $$\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}$$ diff --git a/katas/content/single_qubit_gates/sign_flip_on_zero/solution.md b/katas/content/single_qubit_gates/sign_flip_on_zero/solution.md index 25102579be..34b502898a 100644 --- a/katas/content/single_qubit_gates/sign_flip_on_zero/solution.md +++ b/katas/content/single_qubit_gates/sign_flip_on_zero/solution.md @@ -1,7 +1,7 @@ The first thing to notice is that the gate $\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}$ is quite similar to the Pauli $Z$ gate $\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$. -The only difference being that the negative phase is applied on the $\ket{0}$ instead of $\ket{1}$. Hence we can simulate this gate by switching $\ket{0}$ and $\ket{1}$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate is the perfect gate to flip the state of the qubit and to undo the action afterwards. +The only difference being that the negative phase is applied on the $\ket{0}$ instead of $\ket{1}$. Hence you can simulate this gate by switching $\ket{0}$ and $\ket{1}$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate is the perfect gate to flip the state of the qubit and to undo the action afterwards. -Hence we can express the $Z_0 = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}$ matrix as +Hence you can express the $Z_0 = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}$ matrix as $$ Z_0 = diff --git a/katas/content/single_qubit_gates/state_flip/solution.md b/katas/content/single_qubit_gates/state_flip/solution.md index be8a74d817..234ba2f7d5 100644 --- a/katas/content/single_qubit_gates/state_flip/solution.md +++ b/katas/content/single_qubit_gates/state_flip/solution.md @@ -1,4 +1,4 @@ -We can recognize that the Pauli $X$ gate will change the state $\ket{0}$ to $\ket{1}$ and vice versa, and $\alpha\ket{0} + \beta\ket{1}$ to $\alpha\ket{1} + \beta\ket{0}$. +You can recognize that the Pauli $X$ gate will change the state $\ket{0}$ to $\ket{1}$ and vice versa, and $\alpha\ket{0} + \beta\ket{1}$ to $\alpha\ket{1} + \beta\ket{0}$. As a reminder, the Pauli $X$ gate is defined by the following matrix: @@ -7,7 +7,7 @@ X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} $$ -We can see how it affects, for example, the basis state $\ket{0}$: +You can see how it affects, for example, the basis state $\ket{0}$: $$ X\ket{0} = @@ -18,7 +18,7 @@ X\ket{0} = \ket{1} $$ -Similarly, we can consider the effect of the $X$ gate on the superposition state $\ket{\psi} = 0.6\ket{0} + 0.8\ket{1}$: +Similarly, you can consider the effect of the $X$ gate on the superposition state $\ket{\psi} = 0.6\ket{0} + 0.8\ket{1}$: $$ X\ket{\psi} = diff --git a/katas/content/single_qubit_gates/y_gate/index.md b/katas/content/single_qubit_gates/y_gate/index.md index 710a905006..56a2c1f949 100644 --- a/katas/content/single_qubit_gates/y_gate/index.md +++ b/katas/content/single_qubit_gates/y_gate/index.md @@ -1,3 +1,3 @@ **Input:** A qubit in an arbitrary state $\ket{\psi} = \alpha\ket{0} + \beta\ket{1}$. -**Goal:** Apply the Y gate to the qubit, i.e., transform the given state into $i\alpha\ket{1} - i\beta\ket{0}$. +**Goal:** Apply the Y gate to the qubit, that is, transform the given state into $i\alpha\ket{1} - i\beta\ket{0}$. diff --git a/katas/content/single_qubit_gates/y_gate/solution.md b/katas/content/single_qubit_gates/y_gate/solution.md index 4b7d05a235..e7bf1d66c6 100644 --- a/katas/content/single_qubit_gates/y_gate/solution.md +++ b/katas/content/single_qubit_gates/y_gate/solution.md @@ -1,4 +1,4 @@ -We have to do exactly what the task asks us to do: apply the Pauli gate $Y=\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}$. +You have to do exactly what the task asks us to do: apply the Pauli gate $Y=\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}$. This has the effect of turning $\ket{\psi} = \alpha\ket{0} + \beta\ket{1}$ into $Y\ket{\psi} = i\alpha\ket{1} - i\beta\ket{0}$, which in matrix form looks as follows: $$