Skip to content

Commit

Permalink
Katas UI review - Multiqubit systems (#1813)
Browse files Browse the repository at this point in the history
Co-authored-by: Mariia Mykhailova <michaylova@gmail.com>
Co-authored-by: Scott Carda <55811729+ScottCarda-MS@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent d19b35b commit f354f54
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 61 deletions.
6 changes: 4 additions & 2 deletions katas/content/deutsch_algo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ 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 single-qubit gates
- Quantum measurements

If you need a refresher on these topics, you can check out the previous katas.

@[section]({
"id": "deutsch_algo__problem",
Expand Down
8 changes: 5 additions & 3 deletions katas/content/deutsch_jozsa/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ 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
- 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.
- 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.

@[section]({
"id": "deutsch_jozsa__problem",
Expand Down
1 change: 1 addition & 0 deletions katas/content/grovers_search/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 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 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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 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 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$ 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",
Expand Down
Loading

0 comments on commit f354f54

Please sign in to comment.