qsharp-lang 1.0.18-dev → 1.0.19-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,7 +71,7 @@ export default {
71
71
  "items": [
72
72
  {
73
73
  "type": "text-content",
74
- "asHtml": "<p>The basic building block of a classical computer is the bit - a single memory cell that is either in state $0$ or in state $1$. Similarly, the basic building block of a quantum computer is the quantum bit, or <strong>qubit</strong>. Like the classical bit, a qubit can be in state $0$ or in state $1$. Unlike the classical bit, however, the qubit isn&#39;t limited to just those two states - it may also be in a combination, or <strong>superposition</strong> of those states.</p>\n<blockquote>\n<p>A common misconception about quantum computing is that a qubit is always in state $1$ or state $0$, we just don&#39;t know which one until we &quot;measure&quot; it. That is not the case. A qubit in a superposition is in a linear combination of the states 0 and 1. When a qubit is measured, it is forced to collapse into one state or the other - in other words, measuring a qubit is a drastic process that changes its initial state.</p>\n</blockquote>\n<h2 id=\"matrix-representation\">Matrix Representation</h2>\n<p>The state of a qubit is represented by a complex vector of size 2:</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}$$</p>\n<p>Here $\\alpha$ and $\\beta$ are complex numbers. $\\alpha$ represents how &quot;close&quot; the qubit is to state $0$, and $\\beta$ represents how &quot;close&quot; the qubit is to state $1$. This vector is normalized: $|\\alpha|^2 + |\\beta|^2 = 1$.\nα and β are known as the probability amplitudes of states 0 and 1, respectively.</p>\n<p>$\\alpha$ and $\\beta$ are known as the probability amplitudes of states $0$ and $1$, respectively.</p>\n<h2 id=\"basis-states\">Basis States</h2>\n<p>A qubit in state $0$ would be represented by the following vector:</p>\n<p>$$\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</p>\n<p>Likewise, a qubit in state $1$ would be represented by this vector:</p>\n<p>$$\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$$</p>\n<p>Note that you can use scalar multiplication and vector addition to express any qubit state $\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}$ as a sum of these two vectors with certain probability amplitudes $\\alpha$ and $\\beta$, known as linear combination.</p>\n<p>$$\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\ 0 \\end{bmatrix} + \\begin{bmatrix} 0 \\\\ \\beta \\end{bmatrix} =\n\\alpha \\cdot \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} + \\beta \\cdot \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>Because of this, qubit states $0$ and $1$ are known as basis states. These two vectors have two properties.</p>\n<ol>\n<li>They are normalized.</li>\n</ol>\n<p>$$\n\\langle \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} \\rangle = 1\n$$</p>\n<ol start=\"2\">\n<li>They are orthogonal to each other.</li>\n</ol>\n<p>$$\n\\langle \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\rangle = 0\n$$</p>\n<blockquote>\n<p>As a reminder, $\\langle V , W \\rangle$ is the inner product of $V$ and $W$.</p>\n</blockquote>\n<p>This means that these vectors form an <strong>orthonormal basis</strong>. The basis of $\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$ and $\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$ is called the <strong>computational basis</strong>, also known as the <strong>canonical basis</strong>.</p>\n<blockquote>\n<p>There exist other orthonormal bases, for example, the <strong>Hadamard basis</strong>, formed by the vectors</p>\n<p>$$\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\text{ and } \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}$$</p>\n<p>You can check that these vectors are normalized, and orthogonal to each other. Any qubit state can be expressed as a linear combination of these vectors:</p>\n<p>$$\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\frac{\\alpha + \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} +\n\\frac{\\alpha - \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}\n$$</p>\n<p>The Hadamard basis is widely used in quantum computing, for example, in the <a href=\"https://en.wikipedia.org/wiki/BB84\" target=\"_blank\">BB84 quantum key distribution protocol</a>.</p>\n</blockquote>\n",
74
+ "asHtml": "<p>The basic building block of a classical computer is the bit - a single memory cell that is either in state $0$ or in state $1$. Similarly, the basic building block of a quantum computer is the quantum bit, or <strong>qubit</strong>. Like the classical bit, a qubit can be in state $0$ or in state $1$. Unlike the classical bit, however, the qubit isn&#39;t limited to just those two states - it may also be in a combination, or <strong>superposition</strong> of those states.</p>\n<blockquote>\n<p>A common misconception about quantum computing is that a qubit is always in state $1$ or state $0$, we just don&#39;t know which one until we &quot;measure&quot; it. That is not the case. A qubit in a superposition is in a linear combination of the states 0 and 1. When a qubit is measured, it is forced to collapse into one state or the other - in other words, measuring a qubit is a drastic process that changes its initial state.</p>\n</blockquote>\n<h2>Matrix Representation</h2>\n<p>The state of a qubit is represented by a complex vector of size 2:</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}$$</p>\n<p>Here $\\alpha$ and $\\beta$ are complex numbers. $\\alpha$ represents how &quot;close&quot; the qubit is to state $0$, and $\\beta$ represents how &quot;close&quot; the qubit is to state $1$. This vector is normalized: $|\\alpha|^2 + |\\beta|^2 = 1$.\nα and β are known as the probability amplitudes of states 0 and 1, respectively.</p>\n<p>$\\alpha$ and $\\beta$ are known as the probability amplitudes of states $0$ and $1$, respectively.</p>\n<h2>Basis States</h2>\n<p>A qubit in state $0$ would be represented by the following vector:</p>\n<p>$$\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</p>\n<p>Likewise, a qubit in state $1$ would be represented by this vector:</p>\n<p>$$\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$$</p>\n<p>Note that you can use scalar multiplication and vector addition to express any qubit state $\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix}$ as a sum of these two vectors with certain probability amplitudes $\\alpha$ and $\\beta$, known as linear combination.</p>\n<p>$$\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\ 0 \\end{bmatrix} + \\begin{bmatrix} 0 \\\\ \\beta \\end{bmatrix} =\n\\alpha \\cdot \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} + \\beta \\cdot \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>Because of this, qubit states $0$ and $1$ are known as basis states. These two vectors have two properties.</p>\n<ol>\n<li>They are normalized.</li>\n</ol>\n<p>$$\n\\langle \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} \\rangle = 1\n$$</p>\n<ol start=\"2\">\n<li>They are orthogonal to each other.</li>\n</ol>\n<p>$$\n\\langle \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} \\rangle = 0\n$$</p>\n<blockquote>\n<p>As a reminder, $\\langle V , W \\rangle$ is the inner product of $V$ and $W$.</p>\n</blockquote>\n<p>This means that these vectors form an <strong>orthonormal basis</strong>. The basis of $\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$ and $\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$ is called the <strong>computational basis</strong>, also known as the <strong>canonical basis</strong>.</p>\n<blockquote>\n<p>There exist other orthonormal bases, for example, the <strong>Hadamard basis</strong>, formed by the vectors</p>\n<p>$$\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\text{ and } \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}$$</p>\n<p>You can check that these vectors are normalized, and orthogonal to each other. Any qubit state can be expressed as a linear combination of these vectors:</p>\n<p>$$\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\frac{\\alpha + \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} +\n\\frac{\\alpha - \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}\n$$</p>\n<p>The Hadamard basis is widely used in quantum computing, for example, in the <a href=\"https://en.wikipedia.org/wiki/BB84\" target=\"_blank\">BB84 quantum key distribution protocol</a>.</p>\n</blockquote>\n",
75
75
  "asMarkdown": "\nThe basic building block of a classical computer is the bit - a single memory cell that is either in state $0$ or in state $1$. Similarly, the basic building block of a quantum computer is the quantum bit, or **qubit**. Like the classical bit, a qubit can be in state $0$ or in state $1$. Unlike the classical bit, however, the qubit isn't limited to just those two states - it may also be in a combination, or **superposition** of those states.\n\n> A common misconception about quantum computing is that a qubit is always in state $1$ or state $0$, we just don't know which one until we \"measure\" it. That is not the case. A qubit in a superposition is in a linear combination of the states 0 and 1. When a qubit is measured, it is forced to collapse into one state or the other - in other words, measuring a qubit is a drastic process that changes its initial state.\n\n## Matrix Representation\n\nThe state of a qubit is represented by a complex vector of size 2:\n\n$$\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix}$$\n\nHere $\\alpha$ and $\\beta$ are complex numbers. $\\alpha$ represents how \"close\" the qubit is to state $0$, and $\\beta$ represents how \"close\" the qubit is to state $1$. This vector is normalized: $|\\alpha|^2 + |\\beta|^2 = 1$.\nα and β are known as the probability amplitudes of states 0 and 1, respectively.\n\n$\\alpha$ and $\\beta$ are known as the probability amplitudes of states $0$ and $1$, respectively.\n\n## Basis States\n\nA qubit in state $0$ would be represented by the following vector:\n\n$$\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$$\n\nLikewise, a qubit in state $1$ would be represented by this vector:\n\n$$\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$$\n\nNote that you can use scalar multiplication and vector addition to express any qubit state $\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix}$ as a sum of these two vectors with certain probability amplitudes $\\alpha$ and $\\beta$, known as linear combination.\n\n$$\n\\begin{bmatrix} \\alpha \\\\\\ \\beta \\\\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\\\ 0 \\end{bmatrix} + \\begin{bmatrix} 0 \\\\\\ \\beta \\\\end{bmatrix} =\n\\alpha \\cdot \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} + \\beta \\cdot \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}\n$$\n\nBecause of this, qubit states $0$ and $1$ are known as basis states. These two vectors have two properties.\n\n1. They are normalized.\n\n$$\n\\langle \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\rangle = 1\n$$\n\n2. They are orthogonal to each other.\n\n$$\n\\langle \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} , \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\rangle =\n\\langle \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} , \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\\\rangle = 0\n$$\n\n> As a reminder, $\\langle V , W \\rangle$ is the inner product of $V$ and $W$.\n\nThis means that these vectors form an **orthonormal basis**. The basis of $\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$ and $\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$ is called the **computational basis**, also known as the **canonical basis**.\n\n> There exist other orthonormal bases, for example, the **Hadamard basis**, formed by the vectors\n>\n> $$\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\text{ and } \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}$$\n>\n> You can check that these vectors are normalized, and orthogonal to each other. Any qubit state can be expressed as a linear combination of these vectors:\n>\n> $$\n> \\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} =\n> \\frac{\\alpha + \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} +\n> \\frac{\\alpha - \\beta}{\\sqrt{2}} \\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ -\\frac{1}{\\sqrt{2}} \\end{bmatrix}\n> $$\n>\n> The Hadamard basis is widely used in quantum computing, for example, in the <a href=\"https://en.wikipedia.org/wiki/BB84\" target=\"_blank\">BB84 quantum key distribution protocol</a>."
76
76
  }
77
77
  ]
@@ -107,7 +107,7 @@ export default {
107
107
  "items": [
108
108
  {
109
109
  "type": "text-content",
110
- "asHtml": "<p>In Q#, qubits are represented by the <code>Qubit</code> data type. On a physical quantum computer, it&#39;s impossible to directly access the state of a qubit, whether to read its exact state, or to set it to a desired state, and this data type reflects that. Instead, you can change the state of a qubit using quantum gates, and extract information about the state of the system using measurements.</p>\n<p>That being said, when you run Q# code on a quantum simulator instead of a physical quantum computer, you can use diagnostic functions that allow you to peek at the state of the quantum system. This is very useful both for learning and for debugging small Q# programs.</p>\n<p>The qubits aren&#39;t an ordinary data type, so the variables of this type have to be declared and initialized (&quot;allocated&quot;) a little differently.</p>\n<p>Freshly allocated qubits start out in state $|0\\rangle$, and have to be returned to that state by the time they are released. If you attempt to release a qubit in any state other than $|0\\rangle$, it will result in a runtime error. We will see why it is important later, when we look at multi-qubit systems.</p>\n<h2 id=\"visualizing-quantum-state\">Visualizing Quantum State</h2>\n<p>Before we continue, let&#39;s learn some techniques to visualize the quantum state of our qubits.</p>\n<h3 id=\"display-the-quantum-state-of-a-single-qubit-program\">Display the Quantum State of a Single-Qubit Program</h3>\n<p>Let&#39;s start with a simple scenario: a program that acts on a single qubit. \nThe state of the quantum system used by this program can be represented as a complex vector of length 2, or, using Dirac notation,</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>If this program runs on a physical quantum system, there is no way to get the information about the values of $\\alpha$ and $\\beta$ at a certain point of the program execution from a single observation. \nYou would need to run the program repeatedly up to this point, perform a measurement on the system, and aggregate the results of multiple measurements to estimate $\\alpha$ and $\\beta$.</p>\n<p>However, at the early stages of quantum program development the program typically runs on a simulator - a classical program which simulates the behavior of a small quantum system while having complete information about its internal state. \nYou can take advantage of this to do some non-physical things, such as peeking at the internals of the quantum system to observe its exact state without disturbing it!</p>\n<p>The <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics.dumpmachine\" target=\"_blank\"><code>DumpMachine</code></a> function from the <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics\" target=\"_blank\"><code>Microsoft.Quantum.Diagnostics namespace</code></a> allows you to do exactly that. The output of <code>DumpMachine</code> is accurate up to a global phase, and remember that global phase does not have any physical meaning. When using <code>DumpMachine</code>, you may see that all probability amplitudes are multiplied by some complex number compared to the state you&#39;re expecting.</p>\n<h3 id=\"demo-dumpmachine-for-single-qubit-systems\">Demo: DumpMachine For Single-Qubit Systems</h3>\n<p>The following demo shows how to allocate a qubit and examine its state in Q#. You&#39;ll use <code>DumpMachine</code> to output the state of the system at any point in the program without affecting the state.</p>\n<blockquote>\n<p>Note that the Q# code doesn&#39;t have access to the output of <code>DumpMachine</code>, so you cannot write any non-physical code in Q#!</p>\n</blockquote>\n",
110
+ "asHtml": "<p>In Q#, qubits are represented by the <code>Qubit</code> data type. On a physical quantum computer, it&#39;s impossible to directly access the state of a qubit, whether to read its exact state, or to set it to a desired state, and this data type reflects that. Instead, you can change the state of a qubit using quantum gates, and extract information about the state of the system using measurements.</p>\n<p>That being said, when you run Q# code on a quantum simulator instead of a physical quantum computer, you can use diagnostic functions that allow you to peek at the state of the quantum system. This is very useful both for learning and for debugging small Q# programs.</p>\n<p>The qubits aren&#39;t an ordinary data type, so the variables of this type have to be declared and initialized (&quot;allocated&quot;) a little differently.</p>\n<p>Freshly allocated qubits start out in state $|0\\rangle$, and have to be returned to that state by the time they are released. If you attempt to release a qubit in any state other than $|0\\rangle$, it will result in a runtime error. We will see why it is important later, when we look at multi-qubit systems.</p>\n<h2>Visualizing Quantum State</h2>\n<p>Before we continue, let&#39;s learn some techniques to visualize the quantum state of our qubits.</p>\n<h3>Display the Quantum State of a Single-Qubit Program</h3>\n<p>Let&#39;s start with a simple scenario: a program that acts on a single qubit. \nThe state of the quantum system used by this program can be represented as a complex vector of length 2, or, using Dirac notation,</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>If this program runs on a physical quantum system, there is no way to get the information about the values of $\\alpha$ and $\\beta$ at a certain point of the program execution from a single observation. \nYou would need to run the program repeatedly up to this point, perform a measurement on the system, and aggregate the results of multiple measurements to estimate $\\alpha$ and $\\beta$.</p>\n<p>However, at the early stages of quantum program development the program typically runs on a simulator - a classical program which simulates the behavior of a small quantum system while having complete information about its internal state. \nYou can take advantage of this to do some non-physical things, such as peeking at the internals of the quantum system to observe its exact state without disturbing it!</p>\n<p>The <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics.dumpmachine\" target=\"_blank\"><code>DumpMachine</code></a> function from the <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics\" target=\"_blank\"><code>Microsoft.Quantum.Diagnostics namespace</code></a> allows you to do exactly that. The output of <code>DumpMachine</code> is accurate up to a global phase, and remember that global phase does not have any physical meaning. When using <code>DumpMachine</code>, you may see that all probability amplitudes are multiplied by some complex number compared to the state you&#39;re expecting.</p>\n<h3>Demo: DumpMachine For Single-Qubit Systems</h3>\n<p>The following demo shows how to allocate a qubit and examine its state in Q#. You&#39;ll use <code>DumpMachine</code> to output the state of the system at any point in the program without affecting the state.</p>\n<blockquote>\n<p>Note that the Q# code doesn&#39;t have access to the output of <code>DumpMachine</code>, so you cannot write any non-physical code in Q#!</p>\n</blockquote>\n",
111
111
  "asMarkdown": "\nIn Q#, qubits are represented by the `Qubit` data type. On a physical quantum computer, it's impossible to directly access the state of a qubit, whether to read its exact state, or to set it to a desired state, and this data type reflects that. Instead, you can change the state of a qubit using quantum gates, and extract information about the state of the system using measurements.\n\nThat being said, when you run Q# code on a quantum simulator instead of a physical quantum computer, you can use diagnostic functions that allow you to peek at the state of the quantum system. This is very useful both for learning and for debugging small Q# programs.\n\nThe qubits aren't an ordinary data type, so the variables of this type have to be declared and initialized (\"allocated\") a little differently.\n\nFreshly allocated qubits start out in state $|0\\rangle$, and have to be returned to that state by the time they are released. If you attempt to release a qubit in any state other than $|0\\rangle$, it will result in a runtime error. We will see why it is important later, when we look at multi-qubit systems.\n\n## Visualizing Quantum State\n\nBefore we continue, let's learn some techniques to visualize the quantum state of our qubits.\n\n### Display the Quantum State of a Single-Qubit Program\n\nLet's start with a simple scenario: a program that acts on a single qubit. \nThe state of the quantum system used by this program can be represented as a complex vector of length 2, or, using Dirac notation,\n\n$$\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nIf this program runs on a physical quantum system, there is no way to get the information about the values of $\\alpha$ and $\\beta$ at a certain point of the program execution from a single observation. \nYou would need to run the program repeatedly up to this point, perform a measurement on the system, and aggregate the results of multiple measurements to estimate $\\alpha$ and $\\beta$.\n\nHowever, at the early stages of quantum program development the program typically runs on a simulator - a classical program which simulates the behavior of a small quantum system while having complete information about its internal state. \nYou can take advantage of this to do some non-physical things, such as peeking at the internals of the quantum system to observe its exact state without disturbing it!\n\nThe <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics.dumpmachine\" target=\"_blank\">`DumpMachine`</a> function from the <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics\" target=\"_blank\">`Microsoft.Quantum.Diagnostics namespace`</a> allows you to do exactly that. The output of `DumpMachine` is accurate up to a global phase, and remember that global phase does not have any physical meaning. When using `DumpMachine`, you may see that all probability amplitudes are multiplied by some complex number compared to the state you're expecting.\n\n### Demo: DumpMachine For Single-Qubit Systems\n\nThe following demo shows how to allocate a qubit and examine its state in Q#. You'll use `DumpMachine` to output the state of the system at any point in the program without affecting the state.\n\n> Note that the Q# code doesn't have access to the output of `DumpMachine`, so you cannot write any non-physical code in Q#!"
112
112
  },
113
113
  {
@@ -159,7 +159,7 @@ export default {
159
159
  "items": [
160
160
  {
161
161
  "type": "text-content",
162
- "asHtml": "<p>Now let&#39;s take a look at the general case: a program that acts on $N$ qubits. \nThe state of the quantum system used by this program can be represented as a complex vector of length $2^N$, or, using Dirac notation,</p>\n<p>$$\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1}\\end{bmatrix} = \\sum_{k = 0}^{2^N-1} x_k |k\\rangle$$</p>\n<p>Same as in the single-qubit case, <code>DumpMachine</code> allows you to see the amplitudes $x_k$ for all basis states $|k\\rangle$ directly.</p>\n<blockquote>\n<p>Note the use of an integer in the ket notation instead of a bit string with one bit per qubit. \n<code>DumpMachine</code> uses big-endian to convert bit strings to integers in the ket notation.\nWe will learn more details on endianness in the &quot;Multi-Qubit Systems&quot; kata.</p>\n</blockquote>\n<h2 id=\"demo-dumpmachine-for-multi-qubit-systems\">Demo: DumpMachine for Multi-Qubit Systems</h2>\n",
162
+ "asHtml": "<p>Now let&#39;s take a look at the general case: a program that acts on $N$ qubits. \nThe state of the quantum system used by this program can be represented as a complex vector of length $2^N$, or, using Dirac notation,</p>\n<p>$$\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1}\\end{bmatrix} = \\sum_{k = 0}^{2^N-1} x_k |k\\rangle$$</p>\n<p>Same as in the single-qubit case, <code>DumpMachine</code> allows you to see the amplitudes $x_k$ for all basis states $|k\\rangle$ directly.</p>\n<blockquote>\n<p>Note the use of an integer in the ket notation instead of a bit string with one bit per qubit. \n<code>DumpMachine</code> uses big-endian to convert bit strings to integers in the ket notation.\nWe will learn more details on endianness in the &quot;Multi-Qubit Systems&quot; kata.</p>\n</blockquote>\n<h2>Demo: DumpMachine for Multi-Qubit Systems</h2>\n",
163
163
  "asMarkdown": "\nNow let's take a look at the general case: a program that acts on $N$ qubits. \nThe state of the quantum system used by this program can be represented as a complex vector of length $2^N$, or, using Dirac notation,\n\n$$\\begin{bmatrix} x_0 \\\\\\ x_1 \\\\\\ \\vdots \\\\\\ x_{2^N-1}\\end{bmatrix} = \\sum_{k = 0}^{2^N-1} x_k |k\\rangle$$\n\nSame as in the single-qubit case, `DumpMachine` allows you to see the amplitudes $x_k$ for all basis states $|k\\rangle$ directly.\n\n> Note the use of an integer in the ket notation instead of a bit string with one bit per qubit. \n`DumpMachine` uses big-endian to convert bit strings to integers in the ket notation.\nWe will learn more details on endianness in the \"Multi-Qubit Systems\" kata.\n\n## Demo: DumpMachine for Multi-Qubit Systems"
164
164
  },
165
165
  {
@@ -236,7 +236,7 @@ export default {
236
236
  "items": [
237
237
  {
238
238
  "type": "text-content",
239
- "asHtml": "<p>There are certain properties common to all quantum gates. This section will introduce those properties, using the $X$ gate as an example.</p>\n<h2 id=\"matrix-representation\">Matrix Representation</h2>\n<p>Quantum gates are represented as $2^N \\times 2^N$ unitary matrices, where $N$ is the number of qubits the gate operates on. \nAs a quick reminder, a unitary matrix is a square matrix whose inverse is its adjoint, thus $U^* U = UU^* = UU^{-1} = \\mathbb{I}$.\nSingle-qubit gates are represented by $2 \\times 2$ matrices.\nOur example for this section, the $X$ gate, is represented by the following matrix:</p>\n<p>$$\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}$$</p>\n<p>You may recall that the state of a qubit is represented by a vector of size $2$. You can apply a gate to a qubit by multiplying the gate&#39;s matrix by the qubit&#39;s state vector. The result will be another vector, representing the new state of the qubit. For example, applying the $X$ gate to the computational basis states looks like this:</p>\n<p>$$\nX|0\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 1 + 1 \\cdot 0 \\\\ 1 \\cdot 1 + 0 \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>$$\nX|1\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 0 + 1 \\cdot 1 \\\\ 1 \\cdot 0 + 0 \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>The general case:</p>\n<p>$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>$$\nX|\\psi\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot \\alpha + 1 \\cdot \\beta \\\\ 1 \\cdot \\alpha + 0 \\cdot \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\beta \\\\ \\alpha \\end{bmatrix}\n$$</p>\n<blockquote>\n<p>If you need a reminder of what $|0\\rangle$, $|1\\rangle$, and $|\\psi\\rangle$ mean, you can review the section on Dirac notation in &quot;The Qubit&quot; kata.</p>\n</blockquote>\n<p>Quantum gates are represented by matrices, just like quantum states are represented by vectors. Because this is the most common way to represent quantum gates, the terms &quot;gate&quot; and &quot;gate matrix&quot; will be used interchangeably in this kata.</p>\n<p>Applying several quantum gates in sequence is equivalent to performing several of these multiplications. \nFor example, if you have gates $A$ and $B$ and a qubit in state $|\\psi\\rangle$, the result of applying $A$ followed by $B$ to that qubit would be $B\\big(A|\\psi\\rangle\\big)$ (the gate closest to the qubit state gets applied first). \nMatrix multiplication is associative, so this is equivalent to multiplying the $B$ matrix by the $A$ matrix, producing a compound gate of the two, and then applying that to the qubit: $\\big(BA\\big)|\\psi\\rangle$.</p>\n<blockquote>\n<p>Note that matrix multiplication isn’t commutative, thus $(BA) \\neq (AB)$.</p>\n</blockquote>\n<p>All quantum gates are reversible - there is another gate which will undo any given gate&#39;s transformation, returning the qubit to its original state. \nThis 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. \nQuantum gates are represented by unitary matrices, so the inverse of a gate is its adjoint; these terms are also used interchangeably in quantum computing.</p>\n<h2 id=\"effects-on-basis-states\">Effects on Basis States</h2>\n<p>There is a simple way to find out what a gate does to the two computational basis states $|0\\rangle$ and $|1\\rangle$. Consider an arbitrary gate:</p>\n<p>$$A = \\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}$$</p>\n<p>Watch what happens when we apply it to these states:</p>\n<p>$$\nA|0\\rangle =\n\\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 1 + \\zeta \\cdot 0 \\\\ \\eta \\cdot 1 + \\mu \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\\\ \\eta \\end{bmatrix} = \\epsilon|0\\rangle + \\eta|1\\rangle\n$$</p>\n<p>$$\nA|1\\rangle =\n\\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 0 + \\zeta \\cdot 1 \\\\ \\eta \\cdot 0 + \\mu \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} \\zeta \\\\ \\mu \\end{bmatrix} = \\zeta|0\\rangle + \\mu|1\\rangle\n$$</p>\n<p>Notice that applying the gate to the $|0\\rangle$ state transforms it into the state written as the first column of the gate&#39;s matrix. Likewise, applying the gate to the $|1\\rangle$ state transforms it into the state written as the second column. This holds true for any quantum gate, including, of course, the $X$ gate:</p>\n<p>$$X = \\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}$$</p>\n<p>$$X|0\\rangle = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} = |1\\rangle$$</p>\n<p>$$X|1\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} = |0\\rangle$$</p>\n<p>Once you understand how a gate affects the computational basis states, you can easily find how it affects any state.\nRecall that any qubit state vector can be written as a linear combination of the basis states:</p>\n<p>$$|\\psi\\rangle = \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Because matrix multiplication distributes over addition, once you know how a gate affects those two basis states, you can calculate how it affects any state:</p>\n<p>$$X|\\psi\\rangle = X\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big) = X\\big(\\alpha|0\\rangle\\big) + X\\big(\\beta|1\\rangle\\big) = \\alpha X|0\\rangle + \\beta X|1\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$$</p>\n<p>That is, applying a gate to a qubit in superposition is equivalent to applying that gate to the basis states that make up that superposition and adding the results with appropriate weights.</p>\n",
239
+ "asHtml": "<p>There are certain properties common to all quantum gates. This section will introduce those properties, using the $X$ gate as an example.</p>\n<h2>Matrix Representation</h2>\n<p>Quantum gates are represented as $2^N \\times 2^N$ unitary matrices, where $N$ is the number of qubits the gate operates on. \nAs a quick reminder, a unitary matrix is a square matrix whose inverse is its adjoint, thus $U^* U = UU^* = UU^{-1} = \\mathbb{I}$.\nSingle-qubit gates are represented by $2 \\times 2$ matrices.\nOur example for this section, the $X$ gate, is represented by the following matrix:</p>\n<p>$$\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}$$</p>\n<p>You may recall that the state of a qubit is represented by a vector of size $2$. You can apply a gate to a qubit by multiplying the gate&#39;s matrix by the qubit&#39;s state vector. The result will be another vector, representing the new state of the qubit. For example, applying the $X$ gate to the computational basis states looks like this:</p>\n<p>$$\nX|0\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 1 + 1 \\cdot 0 \\\\ 1 \\cdot 1 + 0 \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>$$\nX|1\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 0 + 1 \\cdot 1 \\\\ 1 \\cdot 0 + 0 \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>The general case:</p>\n<p>$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>$$\nX|\\psi\\rangle =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot \\alpha + 1 \\cdot \\beta \\\\ 1 \\cdot \\alpha + 0 \\cdot \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\beta \\\\ \\alpha \\end{bmatrix}\n$$</p>\n<blockquote>\n<p>If you need a reminder of what $|0\\rangle$, $|1\\rangle$, and $|\\psi\\rangle$ mean, you can review the section on Dirac notation in &quot;The Qubit&quot; kata.</p>\n</blockquote>\n<p>Quantum gates are represented by matrices, just like quantum states are represented by vectors. Because this is the most common way to represent quantum gates, the terms &quot;gate&quot; and &quot;gate matrix&quot; will be used interchangeably in this kata.</p>\n<p>Applying several quantum gates in sequence is equivalent to performing several of these multiplications. \nFor example, if you have gates $A$ and $B$ and a qubit in state $|\\psi\\rangle$, the result of applying $A$ followed by $B$ to that qubit would be $B\\big(A|\\psi\\rangle\\big)$ (the gate closest to the qubit state gets applied first). \nMatrix multiplication is associative, so this is equivalent to multiplying the $B$ matrix by the $A$ matrix, producing a compound gate of the two, and then applying that to the qubit: $\\big(BA\\big)|\\psi\\rangle$.</p>\n<blockquote>\n<p>Note that matrix multiplication isn’t commutative, thus $(BA) \\neq (AB)$.</p>\n</blockquote>\n<p>All quantum gates are reversible - there is another gate which will undo any given gate&#39;s transformation, returning the qubit to its original state. \nThis 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. \nQuantum gates are represented by unitary matrices, so the inverse of a gate is its adjoint; these terms are also used interchangeably in quantum computing.</p>\n<h2>Effects on Basis States</h2>\n<p>There is a simple way to find out what a gate does to the two computational basis states $|0\\rangle$ and $|1\\rangle$. Consider an arbitrary gate:</p>\n<p>$$A = \\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}$$</p>\n<p>Watch what happens when we apply it to these states:</p>\n<p>$$\nA|0\\rangle =\n\\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 1 + \\zeta \\cdot 0 \\\\ \\eta \\cdot 1 + \\mu \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\\\ \\eta \\end{bmatrix} = \\epsilon|0\\rangle + \\eta|1\\rangle\n$$</p>\n<p>$$\nA|1\\rangle =\n\\begin{bmatrix} \\epsilon &amp; \\zeta \\\\ \\eta &amp; \\mu \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 0 + \\zeta \\cdot 1 \\\\ \\eta \\cdot 0 + \\mu \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} \\zeta \\\\ \\mu \\end{bmatrix} = \\zeta|0\\rangle + \\mu|1\\rangle\n$$</p>\n<p>Notice that applying the gate to the $|0\\rangle$ state transforms it into the state written as the first column of the gate&#39;s matrix. Likewise, applying the gate to the $|1\\rangle$ state transforms it into the state written as the second column. This holds true for any quantum gate, including, of course, the $X$ gate:</p>\n<p>$$X = \\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}$$</p>\n<p>$$X|0\\rangle = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} = |1\\rangle$$</p>\n<p>$$X|1\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} = |0\\rangle$$</p>\n<p>Once you understand how a gate affects the computational basis states, you can easily find how it affects any state.\nRecall that any qubit state vector can be written as a linear combination of the basis states:</p>\n<p>$$|\\psi\\rangle = \\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Because matrix multiplication distributes over addition, once you know how a gate affects those two basis states, you can calculate how it affects any state:</p>\n<p>$$X|\\psi\\rangle = X\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big) = X\\big(\\alpha|0\\rangle\\big) + X\\big(\\beta|1\\rangle\\big) = \\alpha X|0\\rangle + \\beta X|1\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$$</p>\n<p>That is, applying a gate to a qubit in superposition is equivalent to applying that gate to the basis states that make up that superposition and adding the results with appropriate weights.</p>\n",
240
240
  "asMarkdown": "\nThere are certain properties common to all quantum gates. This section will introduce those properties, using the $X$ gate as an example.\n\n## Matrix Representation\n\nQuantum gates are represented as $2^N \\times 2^N$ unitary matrices, where $N$ is the number of qubits the gate operates on. \nAs a quick reminder, a unitary matrix is a square matrix whose inverse is its adjoint, thus $U^* U = UU^* = UU^{-1} = \\mathbb{I}$.\nSingle-qubit gates are represented by $2 \\times 2$ matrices.\nOur example for this section, the $X$ gate, is represented by the following matrix:\n\n$$\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$$\n\nYou may recall that the state of a qubit is represented by a vector of size $2$. You can apply a gate to a qubit by multiplying the gate's matrix by the qubit's state vector. The result will be another vector, representing the new state of the qubit. For example, applying the $X$ gate to the computational basis states looks like this:\n\n$$\nX|0\\rangle =\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 1 + 1 \\cdot 0 \\\\\\ 1 \\cdot 1 + 0 \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}\n$$\n\n$$\nX|1\\rangle =\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot 0 + 1 \\cdot 1 \\\\\\ 1 \\cdot 0 + 0 \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}\n$$\n\nThe general case:\n\n$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\n$$\nX|\\psi\\rangle =\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} 0 \\cdot \\alpha + 1 \\cdot \\beta \\\\\\ 1 \\cdot \\alpha + 0 \\cdot \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\beta \\\\\\ \\alpha \\end{bmatrix}\n$$\n\n> If you need a reminder of what $|0\\rangle$, $|1\\rangle$, and $|\\psi\\rangle$ mean, you can review the section on Dirac notation in \"The Qubit\" kata.\n\nQuantum gates are represented by matrices, just like quantum states are represented by vectors. Because this is the most common way to represent quantum gates, the terms \"gate\" and \"gate matrix\" will be used interchangeably in this kata.\n\nApplying several quantum gates in sequence is equivalent to performing several of these multiplications. \nFor example, if you have gates $A$ and $B$ and a qubit in state $|\\psi\\rangle$, the result of applying $A$ followed by $B$ to that qubit would be $B\\big(A|\\psi\\rangle\\big)$ (the gate closest to the qubit state gets applied first). \nMatrix multiplication is associative, so this is equivalent to multiplying the $B$ matrix by the $A$ matrix, producing a compound gate of the two, and then applying that to the qubit: $\\big(BA\\big)|\\psi\\rangle$.\n\n>Note that matrix multiplication isn’t commutative, thus $(BA) \\neq \\(AB)$.\n\nAll quantum gates are reversible - there is another gate which will undo any given gate's transformation, returning the qubit to its original state. \nThis 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. \nQuantum gates are represented by unitary matrices, so the inverse of a gate is its adjoint; these terms are also used interchangeably in quantum computing.\n\n## Effects on Basis States\n\nThere is a simple way to find out what a gate does to the two computational basis states $|0\\rangle$ and $|1\\rangle$. Consider an arbitrary gate:\n\n$$A = \\begin{bmatrix} \\epsilon & \\zeta \\\\\\ \\eta & \\mu \\end{bmatrix}$$\n\nWatch what happens when we apply it to these states:\n\n$$\nA|0\\rangle =\n\\begin{bmatrix} \\epsilon & \\zeta \\\\\\ \\eta & \\mu \\end{bmatrix}\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 1 + \\zeta \\cdot 0 \\\\\\ \\eta \\cdot 1 + \\mu \\cdot 0 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\\\\\ \\eta \\end{bmatrix} = \\epsilon|0\\rangle + \\eta|1\\rangle\n$$\n\n$$\nA|1\\rangle =\n\\begin{bmatrix} \\epsilon & \\zeta \\\\\\ \\eta & \\mu \\end{bmatrix}\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} \\epsilon \\cdot 0 + \\zeta \\cdot 1 \\\\\\ \\eta \\cdot 0 + \\mu \\cdot 1 \\end{bmatrix} =\n\\begin{bmatrix} \\zeta \\\\\\ \\mu \\end{bmatrix} = \\zeta|0\\rangle + \\mu|1\\rangle\n$$\n\nNotice that applying the gate to the $|0\\rangle$ state transforms it into the state written as the first column of the gate's matrix. Likewise, applying the gate to the $|1\\rangle$ state transforms it into the state written as the second column. This holds true for any quantum gate, including, of course, the $X$ gate:\n\n$$X = \\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$$\n\n$$X|0\\rangle = \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} = |1\\rangle$$\n\n$$X|1\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} = |0\\rangle$$\n\nOnce you understand how a gate affects the computational basis states, you can easily find how it affects any state.\nRecall that any qubit state vector can be written as a linear combination of the basis states:\n\n$$|\\psi\\rangle = \\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nBecause matrix multiplication distributes over addition, once you know how a gate affects those two basis states, you can calculate how it affects any state:\n\n$$X|\\psi\\rangle = X\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big) = X\\big(\\alpha|0\\rangle\\big) + X\\big(\\beta|1\\rangle\\big) = \\alpha X|0\\rangle + \\beta X|1\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$$\n\nThat is, applying a gate to a qubit in superposition is equivalent to applying that gate to the basis states that make up that superposition and adding the results with appropriate weights."
241
241
  }
242
242
  ]
@@ -565,7 +565,7 @@ export default {
565
565
  "items": [
566
566
  {
567
567
  "type": "text-content",
568
- "asHtml": "<p>In a previous kata we discussed the concept of a qubit - the basic building block of a quantum computer.\nA multi-qubit system is a collection of multiple qubits, treated as a single system.</p>\n<p>Let&#39;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.</p>\n<p>A system of $N$ qubits can also be in any of the $2^N$ classical states, but, unlike the classical bits, it can also be in a <strong>superposition</strong> of all these states.</p>\n<p>Similarly to single-qubit systems, a state of an $N$-qubit system can be represented as a complex vector of size $2^N$:\n$$\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1}\\end{bmatrix}$$</p>\n<h2 id=\"basis-states\">Basis States</h2>\n<p>Similarly to single-qubit systems, multi-qubit systems have their own sets of basis states.\nThe computational basis for an $N$-qubit system is a set of $2^N$ vectors, in each of which with one element equals $1$, and the other elements equal $0$.</p>\n<p>For example, this is the <strong>computational basis</strong> for a two-qubit system:</p>\n<table>\n <tr>\n <td>$$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\n<p>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:</p>\n<table>\n <tr>\n <td>$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n </tr>\n</table>\n\n<p>Any two-qubit system can be expressed as some linear combination of those tensor products of single-qubit basis states.</p>\n<p>Similar logic applies to systems of more than two qubits. In general case,</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1} \\end{bmatrix} =\nx_0 \\begin{bmatrix} 1 \\\\ 0 \\\\ \\vdots \\\\ 0 \\end{bmatrix} +\nx_1 \\begin{bmatrix} 0 \\\\ 1 \\\\ \\vdots \\\\ 0 \\end{bmatrix} + \\dotsb +\nx_{2^N-1} \\begin{bmatrix} 0 \\\\ 0 \\\\ \\vdots \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>The coefficients of the basis vectors define how &quot;close&quot; is the system state to the corresponding basis vector.</p>\n<blockquote>\n<p>Just like with single-qubit systems, there exist other orthonormal bases states for multi-qubit systems. An example for a two-qubit system is the <strong>Bell basis</strong>:</p>\n<p>$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ -1 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\ 1 \\\\ 1 \\\\ 0 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\ 1 \\\\ -1 \\\\ 0 \\end{bmatrix}$$</p>\n<p>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.</p>\n</blockquote>\n",
568
+ "asHtml": "<p>In a previous kata we discussed the concept of a qubit - the basic building block of a quantum computer.\nA multi-qubit system is a collection of multiple qubits, treated as a single system.</p>\n<p>Let&#39;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.</p>\n<p>A system of $N$ qubits can also be in any of the $2^N$ classical states, but, unlike the classical bits, it can also be in a <strong>superposition</strong> of all these states.</p>\n<p>Similarly to single-qubit systems, a state of an $N$-qubit system can be represented as a complex vector of size $2^N$:\n$$\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1}\\end{bmatrix}$$</p>\n<h2>Basis States</h2>\n<p>Similarly to single-qubit systems, multi-qubit systems have their own sets of basis states.\nThe computational basis for an $N$-qubit system is a set of $2^N$ vectors, in each of which with one element equals $1$, and the other elements equal $0$.</p>\n<p>For example, this is the <strong>computational basis</strong> for a two-qubit system:</p>\n<table>\n <tr>\n <td>$$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\n<p>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:</p>\n<table>\n <tr>\n <td>$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n </tr>\n</table>\n\n<p>Any two-qubit system can be expressed as some linear combination of those tensor products of single-qubit basis states.</p>\n<p>Similar logic applies to systems of more than two qubits. In general case,</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ \\vdots \\\\ x_{2^N-1} \\end{bmatrix} =\nx_0 \\begin{bmatrix} 1 \\\\ 0 \\\\ \\vdots \\\\ 0 \\end{bmatrix} +\nx_1 \\begin{bmatrix} 0 \\\\ 1 \\\\ \\vdots \\\\ 0 \\end{bmatrix} + \\dotsb +\nx_{2^N-1} \\begin{bmatrix} 0 \\\\ 0 \\\\ \\vdots \\\\ 1 \\end{bmatrix}\n$$</p>\n<p>The coefficients of the basis vectors define how &quot;close&quot; is the system state to the corresponding basis vector.</p>\n<blockquote>\n<p>Just like with single-qubit systems, there exist other orthonormal bases states for multi-qubit systems. An example for a two-qubit system is the <strong>Bell basis</strong>:</p>\n<p>$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ -1 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\ 1 \\\\ 1 \\\\ 0 \\end{bmatrix}$$\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\ 1 \\\\ -1 \\\\ 0 \\end{bmatrix}$$</p>\n<p>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.</p>\n</blockquote>\n",
569
569
  "asMarkdown": "\nIn a previous kata we discussed the concept of a qubit - the basic building block of a quantum computer.\nA multi-qubit system is a collection of multiple qubits, treated as a single system.\n\nLet'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.\n\nA system of $N$ qubits can also be in any of the $2^N$ classical states, but, unlike the classical bits, it can also be in a **superposition** of all these states.\n\nSimilarly to single-qubit systems, a state of an $N$-qubit system can be represented as a complex vector of size $2^N$:\n$$\\begin{bmatrix} x_0 \\\\\\ x_1 \\\\\\ \\vdots \\\\\\ x_{2^N-1}\\end{bmatrix}$$\n\n## Basis States\n\nSimilarly to single-qubit systems, multi-qubit systems have their own sets of basis states.\nThe computational basis for an $N$-qubit system is a set of $2^N$ vectors, in each of which with one element equals $1$, and the other elements equal $0$.\n\nFor example, this is the **computational basis** for a two-qubit system:\n\n<table>\n <tr>\n <td>$$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\nIt 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:\n\n<table>\n <tr>\n <td>$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$</td>\n <td>$\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix} \\otimes \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$</td>\n </tr>\n</table>\n\nAny two-qubit system can be expressed as some linear combination of those tensor products of single-qubit basis states.\n\nSimilar logic applies to systems of more than two qubits. In general case,\n\n$$\n\\begin{bmatrix} x_0 \\\\\\ x_1 \\\\\\ \\vdots \\\\\\ x_{2^N-1} \\end{bmatrix} =\nx_0 \\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ \\vdots \\\\\\ 0 \\end{bmatrix} +\nx_1 \\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ \\vdots \\\\\\ 0 \\end{bmatrix} + \\dotsb +\nx_{2^N-1} \\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ \\vdots \\\\\\ 1 \\end{bmatrix}\n$$\n\nThe coefficients of the basis vectors define how \"close\" is the system state to the corresponding basis vector.\n\n> Just like with single-qubit systems, there exist other orthonormal bases states for multi-qubit systems. An example for a two-qubit system is the **Bell basis**:\n>\n> $$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$\n> $$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ -1 \\end{bmatrix}$$\n> $$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix}$$\n> $$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ -1 \\\\\\ 0 \\end{bmatrix}$$\n>\n> 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."
570
570
  }
571
571
  ]
@@ -577,7 +577,7 @@ export default {
577
577
  "items": [
578
578
  {
579
579
  "type": "text-content",
580
- "asHtml": "<p>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:</p>\n<p>$$\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ 0 \\\\ \\frac{1}{\\sqrt{2}} \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>You can see that qubit 1 is in state $\\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and qubit 2 is in state $|0\\rangle$. The states that allow such representation are known as separable states, or product states, because you can separate the global state into the product of individual subsystems.</p>\n<p>The states that allow such representation are known as <strong>separable states</strong>.</p>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p>Show that the state is separable:\n$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\\\ -i \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} ? \\\\ ? \\end{bmatrix} \\otimes \\begin{bmatrix} ? \\\\ ? \\end{bmatrix}\n$$</p>\n<details>\n<summary><b>Solution</b></summary>\nTo separate the state into a tensor product of two single-qubit states, we need to represent it in the following way:\n\n<p>$$\n\\begin{bmatrix} \\alpha \\gamma \\\\ \\alpha \\delta \\\\ \\beta \\gamma \\\\ \\beta \\delta \\end{bmatrix} = \n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} \\otimes \\begin{bmatrix} \\gamma \\\\ \\delta \\end{bmatrix}\n$$</p>\n<p>This brings us to a system of equations:</p>\n<p>$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{2} \\\\ \\alpha\\delta = \\frac{i}{2} \\\\ \\beta \\gamma = \\frac{-i}{2} \\\\ \\beta \\delta = \\frac{1}{2}\n\\end{cases}\n$$</p>\n<p>Solving this system of equations gives us the answer:</p>\n<p>$$\\alpha = \\frac{1}{\\sqrt2}, \\beta = \\frac{-i}{\\sqrt2}, \\gamma = \\frac{1}{\\sqrt2}, \\delta = \\frac{i}{\\sqrt2}$$</p>\n<p>$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\\\ -i \\\\ 1 \\end{bmatrix} =\n\\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\ -i \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\ i \\end{bmatrix}\n$$</p>\n<p>Note that finding such representation is not always possible, as you will see in the next exercise.</p>\n</details>\n\n<h2 id=\"🔎-analyze-1\">🔎 Analyze</h2>\n<p>Is this state separable?</p>\n<p>$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix}$$</p>\n<details>\n<summary><b>Solution</b></summary>\nLet'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:\n\n<p>$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{\\sqrt2} \\\\ \\alpha\\delta = 0 \\\\ \\beta \\gamma = 0 \\\\ \\beta \\delta = \\frac{1}{\\sqrt2}\n\\end{cases}\n$$</p>\n<p>Now let&#39;s multiply the first and the last equations, and the second and the third equations:</p>\n<p>$$\n\\begin{cases}\n\\alpha\\beta\\gamma\\delta = \\frac{1}{2} \\\\ \\alpha\\beta\\gamma\\delta = 0\n\\end{cases}\n$$</p>\n<p>We can see that this system of equations doesn&#39;t have a solution, which means that this state is <b>not separable</b>.</p>\n</details>",
580
+ "asHtml": "<p>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:</p>\n<p>$$\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ 0 \\\\ \\frac{1}{\\sqrt{2}} \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>You can see that qubit 1 is in state $\\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and qubit 2 is in state $|0\\rangle$. The states that allow such representation are known as separable states, or product states, because you can separate the global state into the product of individual subsystems.</p>\n<p>The states that allow such representation are known as <strong>separable states</strong>.</p>\n<h2>🔎 Analyze</h2>\n<p>Show that the state is separable:\n$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\\\ -i \\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} ? \\\\ ? \\end{bmatrix} \\otimes \\begin{bmatrix} ? \\\\ ? \\end{bmatrix}\n$$</p>\n<details>\n<summary><b>Solution</b></summary>\nTo separate the state into a tensor product of two single-qubit states, we need to represent it in the following way:\n\n<p>$$\n\\begin{bmatrix} \\alpha \\gamma \\\\ \\alpha \\delta \\\\ \\beta \\gamma \\\\ \\beta \\delta \\end{bmatrix} = \n\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} \\otimes \\begin{bmatrix} \\gamma \\\\ \\delta \\end{bmatrix}\n$$</p>\n<p>This brings us to a system of equations:</p>\n<p>$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{2} \\\\ \\alpha\\delta = \\frac{i}{2} \\\\ \\beta \\gamma = \\frac{-i}{2} \\\\ \\beta \\delta = \\frac{1}{2}\n\\end{cases}\n$$</p>\n<p>Solving this system of equations gives us the answer:</p>\n<p>$$\\alpha = \\frac{1}{\\sqrt2}, \\beta = \\frac{-i}{\\sqrt2}, \\gamma = \\frac{1}{\\sqrt2}, \\delta = \\frac{i}{\\sqrt2}$$</p>\n<p>$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\\\ -i \\\\ 1 \\end{bmatrix} =\n\\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\ -i \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\ i \\end{bmatrix}\n$$</p>\n<p>Note that finding such representation is not always possible, as you will see in the next exercise.</p>\n</details>\n\n<h2>🔎 Analyze</h2>\n<p>Is this state separable?</p>\n<p>$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix}$$</p>\n<details>\n<summary><b>Solution</b></summary>\nLet'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:\n\n<p>$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{\\sqrt2} \\\\ \\alpha\\delta = 0 \\\\ \\beta \\gamma = 0 \\\\ \\beta \\delta = \\frac{1}{\\sqrt2}\n\\end{cases}\n$$</p>\n<p>Now let&#39;s multiply the first and the last equations, and the second and the third equations:</p>\n<p>$$\n\\begin{cases}\n\\alpha\\beta\\gamma\\delta = \\frac{1}{2} \\\\ \\alpha\\beta\\gamma\\delta = 0\n\\end{cases}\n$$</p>\n<p>We can see that this system of equations doesn&#39;t have a solution, which means that this state is <b>not separable</b>.</p>\n</details>",
581
581
  "asMarkdown": "\nSometimes 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:\n\n$$\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ 0 \\\\\\ \\frac{1}{\\sqrt{2}} \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} \\frac{1}{\\sqrt{2}} \\\\\\ \\frac{1}{\\sqrt{2}} \\end{bmatrix} \\otimes \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}\n$$\n\nYou can see that qubit 1 is in state $\\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and qubit 2 is in state $|0\\rangle$. The states that allow such representation are known as separable states, or product states, because you can separate the global state into the product of individual subsystems.\n\nThe states that allow such representation are known as **separable states**.\n\n## 🔎 Analyze\n\nShow that the state is separable:\n$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\\\ i \\\\\\ -i \\\\\\ 1 \\end{bmatrix} =\n\\begin{bmatrix} ? \\\\\\ ? \\end{bmatrix} \\otimes \\begin{bmatrix} ? \\\\\\ ? \\end{bmatrix}\n$$\n\n<details>\n<summary><b>Solution</b></summary>\nTo separate the state into a tensor product of two single-qubit states, we need to represent it in the following way:\n\n$$\n\\begin{bmatrix} \\alpha \\gamma \\\\\\ \\alpha \\delta \\\\\\ \\beta \\gamma \\\\\\ \\beta \\delta \\end{bmatrix} = \n\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} \\otimes \\begin{bmatrix} \\gamma \\\\\\ \\delta \\end{bmatrix}\n$$\n\nThis brings us to a system of equations:\n\n$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{2} \\\\\\ \\alpha\\delta = \\frac{i}{2} \\\\\\ \\beta \\gamma = \\frac{-i}{2} \\\\\\ \\beta \\delta = \\frac{1}{2}\n\\end{cases}\n$$\n\nSolving this system of equations gives us the answer:\n\n$$\\alpha = \\frac{1}{\\sqrt2}, \\beta = \\frac{-i}{\\sqrt2}, \\gamma = \\frac{1}{\\sqrt2}, \\delta = \\frac{i}{\\sqrt2}$$\n\n$$\n\\frac{1}{2} \\begin{bmatrix} 1 \\\\\\ i \\\\\\ -i \\\\\\ 1 \\end{bmatrix} =\n\\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ -i \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ i \\end{bmatrix}\n$$\n\nNote that finding such representation is not always possible, as you will see in the next exercise.\n</details>\n\n## 🔎 Analyze\n\nIs this state separable?\n\n$$\\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$\n\n<details>\n<summary><b>Solution</b></summary>\nLet'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:\n\n$$\n\\begin{cases}\n\\alpha\\gamma = \\frac{1}{\\sqrt2} \\\\\\ \\alpha\\delta = 0 \\\\\\ \\beta \\gamma = 0 \\\\\\ \\beta \\delta = \\frac{1}{\\sqrt2}\n\\end{cases}\n$$\n\nNow let's multiply the first and the last equations, and the second and the third equations:\n\n$$\n\\begin{cases}\n\\alpha\\beta\\gamma\\delta = \\frac{1}{2} \\\\\\ \\alpha\\beta\\gamma\\delta = 0\n\\end{cases}\n$$\n\nWe can see that this system of equations doesn't have a solution, which means that this state is <b>not separable</b>.\n</details>"
582
582
  }
583
583
  ]
@@ -601,7 +601,7 @@ export default {
601
601
  "items": [
602
602
  {
603
603
  "type": "text-content",
604
- "asHtml": "<p>Just like with single qubits, Dirac notation provides a useful shorthand for writing down states of multi-qubit systems.</p>\n<p>As we&#39;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:</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ x_2 \\\\ x_3 \\end{bmatrix} =\nx_0\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix} +\nx_1\\begin{bmatrix} 0 \\\\ 1 \\\\ 0 \\\\ 0 \\end{bmatrix} +\nx_2\\begin{bmatrix} 0 \\\\ 0 \\\\ 1 \\\\ 0 \\end{bmatrix} +\nx_3\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix} =\nx_0|0\\rangle \\otimes |0\\rangle +\nx_1|0\\rangle \\otimes |1\\rangle +\nx_2|1\\rangle \\otimes |0\\rangle +\nx_3|1\\rangle \\otimes |1\\rangle\n$$</p>\n<p>To simplify this, tensor products of basis states have their own notation:</p>\n<p>$$|0\\rangle \\otimes |0\\rangle = |00\\rangle$$\n$$|0\\rangle \\otimes |1\\rangle = |01\\rangle$$\n$$|1\\rangle \\otimes |0\\rangle = |10\\rangle$$\n$$|1\\rangle \\otimes |1\\rangle = |11\\rangle$$</p>\n<p>$$|0\\rangle \\otimes |0\\rangle \\otimes |0\\rangle = |000\\rangle$$</p>\n<p>And so on.</p>\n<p>Or, more generally:</p>\n<p>$$|i_0\\rangle \\otimes |i_1\\rangle \\otimes \\dotsb \\otimes |i_n\\rangle = |i_0i_1...i_n\\rangle$$</p>\n<p>Using this notation simplifies our example:</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ x_2 \\\\ x_3 \\end{bmatrix} =\nx_0|00\\rangle + x_1|01\\rangle + x_2|10\\rangle + x_3|11\\rangle\n$$</p>\n<p>Just like with single qubits, we can put arbitrary symbols within the kets the same way variables are used in algebra.\nWhether a ket represents a single qubit or an entire system depends on the context.\nSome ket symbols have a commonly accepted usage, such as the symbols for the Bell basis:</p>\n<table>\n <tr>\n <td>$|\\phi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle + |11\\rangle\\big) \\\\\\ |\\phi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle - |11\\rangle\\big)$</td>\n <td>$|\\psi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle + |10\\rangle\\big) \\\\\\ |\\psi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle - |10\\rangle\\big)$</td>\n </tr>\n</table>\n\n<blockquote>\n<h2 id=\"endianness\">Endianness</h2>\n<p>In classical computing, endianness refers to the order of bits (or bytes) when representing numbers in binary. You&#39;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 <strong>big-endian format</strong>. In big-endian format, the <em>most significant</em> bits come first. For example: $110_2 = 1 \\cdot 4 + 1 \\cdot 2 + 0 \\cdot 1 = 4 + 2 = 6$.</p>\n<p>There is an alternate way of writing binary numbers - <strong>little-endian format</strong>. In little-endian format, the <em>least significant</em> 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.</p>\n<p>In Dirac notation for multi-qubit systems, it&#39;s common to see integer numbers within the kets instead of bit sequences. What those numbers mean depends on the context - whether the notation used is big-endian or little-endian.</p>\n<p>Examples with a 3 qubit system:</p>\n<table>\n <tr>\n <th>Integer Ket</th>\n <td>$|0\\rangle$</td>\n <td>$|1\\rangle$</td>\n <td>$|2\\rangle$</td>\n <td>$|3\\rangle$</td>\n <td>$|4\\rangle$</td>\n <td>$|5\\rangle$</td>\n <td>$|6\\rangle$</td>\n <td>$|7\\rangle$</td>\n </tr>\n <tr>\n <th>Big-endian</th>\n <td>$|000\\rangle$</td>\n <td>$|001\\rangle$</td>\n <td>$|010\\rangle$</td>\n <td>$|011\\rangle$</td>\n <td>$|100\\rangle$</td>\n <td>$|101\\rangle$</td>\n <td>$|110\\rangle$</td>\n <td>$|111\\rangle$</td>\n </tr>\n <tr>\n <th>Little-endian</th>\n <td>$|000\\rangle$</td>\n <td>$|100\\rangle$</td>\n <td>$|010\\rangle$</td>\n <td>$|110\\rangle$</td>\n <td>$|001\\rangle$</td>\n <td>$|101\\rangle$</td>\n <td>$|011\\rangle$</td>\n <td>$|111\\rangle$</td>\n </tr>\n</table>\n\n<p>Multi-qubit quantum systems that store superpositions of numbers are often referred to as <strong>quantum registers</strong>.</p>\n</blockquote>\n",
604
+ "asHtml": "<p>Just like with single qubits, Dirac notation provides a useful shorthand for writing down states of multi-qubit systems.</p>\n<p>As we&#39;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:</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ x_2 \\\\ x_3 \\end{bmatrix} =\nx_0\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix} +\nx_1\\begin{bmatrix} 0 \\\\ 1 \\\\ 0 \\\\ 0 \\end{bmatrix} +\nx_2\\begin{bmatrix} 0 \\\\ 0 \\\\ 1 \\\\ 0 \\end{bmatrix} +\nx_3\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix} =\nx_0|0\\rangle \\otimes |0\\rangle +\nx_1|0\\rangle \\otimes |1\\rangle +\nx_2|1\\rangle \\otimes |0\\rangle +\nx_3|1\\rangle \\otimes |1\\rangle\n$$</p>\n<p>To simplify this, tensor products of basis states have their own notation:</p>\n<p>$$|0\\rangle \\otimes |0\\rangle = |00\\rangle$$\n$$|0\\rangle \\otimes |1\\rangle = |01\\rangle$$\n$$|1\\rangle \\otimes |0\\rangle = |10\\rangle$$\n$$|1\\rangle \\otimes |1\\rangle = |11\\rangle$$</p>\n<p>$$|0\\rangle \\otimes |0\\rangle \\otimes |0\\rangle = |000\\rangle$$</p>\n<p>And so on.</p>\n<p>Or, more generally:</p>\n<p>$$|i_0\\rangle \\otimes |i_1\\rangle \\otimes \\dotsb \\otimes |i_n\\rangle = |i_0i_1...i_n\\rangle$$</p>\n<p>Using this notation simplifies our example:</p>\n<p>$$\n\\begin{bmatrix} x_0 \\\\ x_1 \\\\ x_2 \\\\ x_3 \\end{bmatrix} =\nx_0|00\\rangle + x_1|01\\rangle + x_2|10\\rangle + x_3|11\\rangle\n$$</p>\n<p>Just like with single qubits, we can put arbitrary symbols within the kets the same way variables are used in algebra.\nWhether a ket represents a single qubit or an entire system depends on the context.\nSome ket symbols have a commonly accepted usage, such as the symbols for the Bell basis:</p>\n<table>\n <tr>\n <td>$|\\phi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle + |11\\rangle\\big) \\\\\\ |\\phi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle - |11\\rangle\\big)$</td>\n <td>$|\\psi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle + |10\\rangle\\big) \\\\\\ |\\psi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle - |10\\rangle\\big)$</td>\n </tr>\n</table>\n\n<blockquote>\n<h2>Endianness</h2>\n<p>In classical computing, endianness refers to the order of bits (or bytes) when representing numbers in binary. You&#39;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 <strong>big-endian format</strong>. In big-endian format, the <em>most significant</em> bits come first. For example: $110_2 = 1 \\cdot 4 + 1 \\cdot 2 + 0 \\cdot 1 = 4 + 2 = 6$.</p>\n<p>There is an alternate way of writing binary numbers - <strong>little-endian format</strong>. In little-endian format, the <em>least significant</em> 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.</p>\n<p>In Dirac notation for multi-qubit systems, it&#39;s common to see integer numbers within the kets instead of bit sequences. What those numbers mean depends on the context - whether the notation used is big-endian or little-endian.</p>\n<p>Examples with a 3 qubit system:</p>\n<table>\n <tr>\n <th>Integer Ket</th>\n <td>$|0\\rangle$</td>\n <td>$|1\\rangle$</td>\n <td>$|2\\rangle$</td>\n <td>$|3\\rangle$</td>\n <td>$|4\\rangle$</td>\n <td>$|5\\rangle$</td>\n <td>$|6\\rangle$</td>\n <td>$|7\\rangle$</td>\n </tr>\n <tr>\n <th>Big-endian</th>\n <td>$|000\\rangle$</td>\n <td>$|001\\rangle$</td>\n <td>$|010\\rangle$</td>\n <td>$|011\\rangle$</td>\n <td>$|100\\rangle$</td>\n <td>$|101\\rangle$</td>\n <td>$|110\\rangle$</td>\n <td>$|111\\rangle$</td>\n </tr>\n <tr>\n <th>Little-endian</th>\n <td>$|000\\rangle$</td>\n <td>$|100\\rangle$</td>\n <td>$|010\\rangle$</td>\n <td>$|110\\rangle$</td>\n <td>$|001\\rangle$</td>\n <td>$|101\\rangle$</td>\n <td>$|011\\rangle$</td>\n <td>$|111\\rangle$</td>\n </tr>\n</table>\n\n<p>Multi-qubit quantum systems that store superpositions of numbers are often referred to as <strong>quantum registers</strong>.</p>\n</blockquote>\n",
605
605
  "asMarkdown": "\nJust like with single qubits, Dirac notation provides a useful shorthand for writing down states of multi-qubit systems.\n\nAs 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:\n\n$$\n\\begin{bmatrix} x_0 \\\\\\ x_1 \\\\\\ x_2 \\\\\\ x_3 \\end{bmatrix} =\nx_0\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} +\nx_1\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} +\nx_2\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix} +\nx_3\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix} =\nx_0|0\\rangle \\otimes |0\\rangle +\nx_1|0\\rangle \\otimes |1\\rangle +\nx_2|1\\rangle \\otimes |0\\rangle +\nx_3|1\\rangle \\otimes |1\\rangle\n$$\n\nTo simplify this, tensor products of basis states have their own notation:\n\n$$|0\\rangle \\otimes |0\\rangle = |00\\rangle$$\n$$|0\\rangle \\otimes |1\\rangle = |01\\rangle$$\n$$|1\\rangle \\otimes |0\\rangle = |10\\rangle$$\n$$|1\\rangle \\otimes |1\\rangle = |11\\rangle$$\n\n$$|0\\rangle \\otimes |0\\rangle \\otimes |0\\rangle = |000\\rangle$$\n\nAnd so on.\n\nOr, more generally:\n\n$$|i_0\\rangle \\otimes |i_1\\rangle \\otimes \\dotsb \\otimes |i_n\\rangle = |i_0i_1...i_n\\rangle$$\n\nUsing this notation simplifies our example:\n\n$$\n\\begin{bmatrix} x_0 \\\\\\ x_1 \\\\\\ x_2 \\\\\\ x_3 \\end{bmatrix} =\nx_0|00\\rangle + x_1|01\\rangle + x_2|10\\rangle + x_3|11\\rangle\n$$\n\nJust like with single qubits, we can put arbitrary symbols within the kets the same way variables are used in algebra.\nWhether a ket represents a single qubit or an entire system depends on the context.\nSome ket symbols have a commonly accepted usage, such as the symbols for the Bell basis:\n\n<table>\n <tr>\n <td>$|\\phi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle + |11\\rangle\\big) \\\\\\ |\\phi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle - |11\\rangle\\big)$</td>\n <td>$|\\psi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle + |10\\rangle\\big) \\\\\\ |\\psi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle - |10\\rangle\\big)$</td>\n </tr>\n</table>\n\n>## Endianness\n>\n> 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$.\n>\n> 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.\n>\n> In Dirac notation for multi-qubit systems, it's common to see integer numbers within the kets instead of bit sequences. What those numbers mean depends on the context - whether the notation used is big-endian or little-endian.\n>\n> Examples with a 3 qubit system:\n>\n> <table>\n> <tr>\n> <th>Integer Ket</th>\n> <td>$|0\\rangle$</td>\n> <td>$|1\\rangle$</td>\n> <td>$|2\\rangle$</td>\n> <td>$|3\\rangle$</td>\n> <td>$|4\\rangle$</td>\n> <td>$|5\\rangle$</td>\n> <td>$|6\\rangle$</td>\n> <td>$|7\\rangle$</td>\n> </tr>\n> <tr>\n> <th>Big-endian</th>\n> <td>$|000\\rangle$</td>\n> <td>$|001\\rangle$</td>\n> <td>$|010\\rangle$</td>\n> <td>$|011\\rangle$</td>\n> <td>$|100\\rangle$</td>\n> <td>$|101\\rangle$</td>\n> <td>$|110\\rangle$</td>\n> <td>$|111\\rangle$</td>\n> </tr>\n> <tr>\n> <th>Little-endian</th>\n> <td>$|000\\rangle$</td>\n> <td>$|100\\rangle$</td>\n> <td>$|010\\rangle$</td>\n> <td>$|110\\rangle$</td>\n> <td>$|001\\rangle$</td>\n> <td>$|101\\rangle$</td>\n> <td>$|011\\rangle$</td>\n> <td>$|111\\rangle$</td>\n> </tr>\n></table>\n>\n> Multi-qubit quantum systems that store superpositions of numbers are often referred to as **quantum registers**."
606
606
  }
607
607
  ]
@@ -789,7 +789,7 @@ export default {
789
789
  "items": [
790
790
  {
791
791
  "type": "text-content",
792
- "asHtml": "<p>As a reminder, single-qubit gates are represented by $2\\times2$ unitary matrices.</p>\n<p>The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit to get the resulting state vector.</p>\n<p>Multi-qubit gates are represented by $2^N\\times2^N$ matrices, where $N$ is the number of qubits the gate operates on. To apply this gate, you multiply the matrix by the state vector of the $N$-qubit quantum system.</p>\n<h2 id=\"applying-gates-to-a-part-of-the-system\">Applying Gates to a Part of the System</h2>\n<p>The simplest thing we can do with multi-qubit systems is to apply gates to only a subset of qubits in the system.\nSimilar to how it is sometimes possible to represent the state of a multi-qubit systems as a tensor product of single-qubit states, you can construct gates that modify the state of a multi-qubit system as tensor products of gates that affect parts of the system.</p>\n<p>Let&#39;s consider an example of applying single-qubit gates to one of the qubits of a two-qubit system.\nIf you want to apply an $X$ gate to the first qubit of the system and do nothing to the second qubit, the resulting gate will be represented as a tensor product of an $X$ gate and the identity gate $I$ which corresponds to doing nothing:</p>\n<p>$$\nX \\otimes I =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} =\n\\begin{bmatrix}\n 0 &amp; 0 &amp; 1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0\n\\end{bmatrix}\n$$</p>\n<p>You can use the same approach when applying several gates to independent parts of the system at the same time.\nFor example, applying the $X$ gate to the first qubit and the $H$ gate to the second qubit would be represented as follows:</p>\n<p>$$\nX \\otimes H =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 &amp; 1 \\\\ 1 &amp; -1 \\end{bmatrix} =\n\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n 0 &amp; 0 &amp; 1 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 1 &amp; -1 \\\\ \n 1 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 1 &amp; -1 &amp; 0 &amp; 0\n\\end{bmatrix}\n$$</p>\n<blockquote>\n<p>Note that we can use mixed-multiplication property of tensor product to see that this is equivalent to applying $X$ gate to the first qubit and applying $H$ gate to the second qubit, in either order:</p>\n<p>$$X \\otimes H = (I X) \\otimes (H I) = (I \\otimes H) (X \\otimes I)$$\n$$X \\otimes H = (X I) \\otimes (I H) = (X \\otimes I) (I \\otimes H)$$</p>\n</blockquote>\n<p>This approach can be generalized to larger systems and gates that act on multiple qubits as well.\nIt is more complex when a multi-qubit gate is applied to a subset of qubits that are not &quot;adjacent&quot; to each other in the tensor product; we&#39;ll see an example later in this kata.</p>\n",
792
+ "asHtml": "<p>As a reminder, single-qubit gates are represented by $2\\times2$ unitary matrices.</p>\n<p>The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit to get the resulting state vector.</p>\n<p>Multi-qubit gates are represented by $2^N\\times2^N$ matrices, where $N$ is the number of qubits the gate operates on. To apply this gate, you multiply the matrix by the state vector of the $N$-qubit quantum system.</p>\n<h2>Applying Gates to a Part of the System</h2>\n<p>The simplest thing we can do with multi-qubit systems is to apply gates to only a subset of qubits in the system.\nSimilar to how it is sometimes possible to represent the state of a multi-qubit systems as a tensor product of single-qubit states, you can construct gates that modify the state of a multi-qubit system as tensor products of gates that affect parts of the system.</p>\n<p>Let&#39;s consider an example of applying single-qubit gates to one of the qubits of a two-qubit system.\nIf you want to apply an $X$ gate to the first qubit of the system and do nothing to the second qubit, the resulting gate will be represented as a tensor product of an $X$ gate and the identity gate $I$ which corresponds to doing nothing:</p>\n<p>$$\nX \\otimes I =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} =\n\\begin{bmatrix}\n 0 &amp; 0 &amp; 1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0\n\\end{bmatrix}\n$$</p>\n<p>You can use the same approach when applying several gates to independent parts of the system at the same time.\nFor example, applying the $X$ gate to the first qubit and the $H$ gate to the second qubit would be represented as follows:</p>\n<p>$$\nX \\otimes H =\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 &amp; 1 \\\\ 1 &amp; -1 \\end{bmatrix} =\n\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n 0 &amp; 0 &amp; 1 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 1 &amp; -1 \\\\ \n 1 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 1 &amp; -1 &amp; 0 &amp; 0\n\\end{bmatrix}\n$$</p>\n<blockquote>\n<p>Note that we can use mixed-multiplication property of tensor product to see that this is equivalent to applying $X$ gate to the first qubit and applying $H$ gate to the second qubit, in either order:</p>\n<p>$$X \\otimes H = (I X) \\otimes (H I) = (I \\otimes H) (X \\otimes I)$$\n$$X \\otimes H = (X I) \\otimes (I H) = (X \\otimes I) (I \\otimes H)$$</p>\n</blockquote>\n<p>This approach can be generalized to larger systems and gates that act on multiple qubits as well.\nIt is more complex when a multi-qubit gate is applied to a subset of qubits that are not &quot;adjacent&quot; to each other in the tensor product; we&#39;ll see an example later in this kata.</p>\n",
793
793
  "asMarkdown": "\nAs a reminder, single-qubit gates are represented by $2\\times2$ unitary matrices.\n\nThe effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit to get the resulting state vector.\n\nMulti-qubit gates are represented by $2^N\\\\times2^N$ matrices, where $N$ is the number of qubits the gate operates on. To apply this gate, you multiply the matrix by the state vector of the $N$-qubit quantum system.\n\n## Applying Gates to a Part of the System\n\nThe simplest thing we can do with multi-qubit systems is to apply gates to only a subset of qubits in the system.\nSimilar to how it is sometimes possible to represent the state of a multi-qubit systems as a tensor product of single-qubit states, you can construct gates that modify the state of a multi-qubit system as tensor products of gates that affect parts of the system.\n\nLet's consider an example of applying single-qubit gates to one of the qubits of a two-qubit system.\nIf you want to apply an $X$ gate to the first qubit of the system and do nothing to the second qubit, the resulting gate will be represented as a tensor product of an $X$ gate and the identity gate $I$ which corresponds to doing nothing:\n\n$$\nX \\otimes I =\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} \\otimes \\begin{bmatrix} 1 & 0 \\\\\\ 0 & 1 \\end{bmatrix} =\n\\begin{bmatrix}\n 0 & 0 & 1 & 0 \\\\\\ \n 0 & 0 & 0 & 1 \\\\\\ \n 1 & 0 & 0 & 0 \\\\\\ \n 0 & 1 & 0 & 0\n\\end{bmatrix}\n$$\n\nYou can use the same approach when applying several gates to independent parts of the system at the same time.\nFor example, applying the $X$ gate to the first qubit and the $H$ gate to the second qubit would be represented as follows:\n\n$$\nX \\otimes H =\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 & 1 \\\\\\ 1 & -1 \\end{bmatrix} =\n\\frac{1}{\\sqrt{2}}\\begin{bmatrix}\n 0 & 0 & 1 & 1 \\\\\\ \n 0 & 0 & 1 & -1 \\\\\\ \n 1 & 1 & 0 & 0 \\\\\\ \n 1 & -1 & 0 & 0\n\\end{bmatrix}\n$$\n\n> Note that we can use mixed-multiplication property of tensor product to see that this is equivalent to applying $X$ gate to the first qubit and applying $H$ gate to the second qubit, in either order:\n>\n> $$X \\otimes H = (I X) \\otimes (H I) = (I \\otimes H) (X \\otimes I)$$\n> $$X \\otimes H = (X I) \\otimes (I H) = (X \\otimes I) (I \\otimes H)$$\n\nThis approach can be generalized to larger systems and gates that act on multiple qubits as well.\nIt is more complex when a multi-qubit gate is applied to a subset of qubits that are not \"adjacent\" to each other in the tensor product; we'll see an example later in this kata."
794
794
  }
795
795
  ]
@@ -939,7 +939,7 @@ export default {
939
939
  "items": [
940
940
  {
941
941
  "type": "text-content",
942
- "asHtml": "<p>In the above examples the <code>CNOT</code> gate acted on two adjacent qubits. However, multi-qubit gates can act on non-adjacent qubits as well. Let&#39;s see how to work out the math of the system state change in this case.</p>\n<p>Take 3 qubits in an arbitrary state $|\\psi\\rangle = x_{000} |000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{100}|100\\rangle + x_{101}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle $.</p>\n<p>We can apply the <code>CNOT</code> gate on 1st and 3rd qubits, with the 1st qubit as control and the 3rd qubit as target. Let&#39;s label the 3-qubit gate that describes the effect of this on the whole system as <code>CINOT</code>. The <code>CINOT</code> ignores the 2nd qubit (leaves it unchanged) and applies the <code>CNOT</code> gate as specified above.</p>\n<h2 id=\"q\">Q#</h2>\n<p>In Q# we describe the operation as the sequence of gates that are applied to the qubits, regardless of whether the qubits are adjacent or not.</p>\n<pre><code class=\"language-qsharp\">operation CINOT (qs: Qubit[]) : Unit {\n CNOT(qs[0], qs[2]); // Length of qs is assumed to be 3\n}\n</code></pre>\n<h2 id=\"dirac-notation\">Dirac Notation</h2>\n<p>In Dirac notation we can consider the effect of the gate on each basis vector separately: each basis vector $|a_1a_2a_3\\rangle$ remains unchanged if $a_1 = 0$, and becomes $|a_1a_2(\\neg a_3)\\rangle$ if $a_1 = 1$. The full effect on the state becomes:</p>\n<p>$$\\text{CINOT}|\\psi\\rangle = x_{000} \\text{CINOT}|000\\rangle + x_{001} \\text{CINOT}|001\\rangle + x_{010} \\text{CINOT}|010\\rangle + x_{011} \\text{CINOT}|011\\rangle+$$\n$$x_{100} \\text{CINOT}|100\\rangle + x_{101} \\text{CINOT}|101\\rangle + x_{110} \\text{CINOT}|110\\rangle + x_{111} \\text{CINOT}|111\\rangle =$$\n$$x_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle $$</p>\n<h2 id=\"matrix-form\">Matrix Form</h2>\n<p>$\\text{CINOT}$ can also be represented in matrix form as a $2^3 \\times 2^3$ matrix:\n$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0\n\\end{bmatrix}\n$$</p>\n<p>Applying $\\text{CINOT}$ to $|\\psi\\rangle$ gives us\n$$\n\\text{CINOT} \\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0\n\\end{bmatrix}\n\\begin{bmatrix}\n x_{000} \\\\ x_{001} \\\\ x_{010} \\\\ x_{011} \\\\ x_{100} \\\\ x_{101} \\\\ x_{110} \\\\ x_{111}\n\\end{bmatrix} =\n\\begin{bmatrix}\n x_{000} \\\\ x_{001} \\\\ x_{010} \\\\ x_{011} \\\\ x_{101} \\\\ x_{100} \\\\ x_{111} \\\\ x_{110}\n\\end{bmatrix}\n$$</p>\n<p>However, as $N$ gets larger, creating a full size matrix can be extremely unwieldy. To express the matrix without spelling out its elements, we can use the following trick:</p>\n<ol>\n<li>Apply the <code>SWAP</code> gate on the 1st and 2nd qubits.\nThis will bring the qubits on which the <code>CNOT</code> gate acts next to each other, without any extra qubits between them.</li>\n<li>Apply the <code>CNOT</code> on 2nd and 3rd qubits.\nSince now the gate acts on adjacent qubits, this can be represented as a tensor product of the gate we&#39;re applying and <code>I</code> gates.</li>\n<li>Apply the <code>SWAP</code> gate on the 1st and 2nd qubits again.</li>\n</ol>\n<p>These can be represented as applying the following gates on the 3 qubits.</p>\n<ol>\n<li><p>$\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{100}|010\\rangle + x_{101}|011\\rangle +\nx_{010}|100\\rangle + x_{011}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle\n$$</p>\n</li>\n<li><p>$I \\otimes \\text{CNOT}$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{101}|010\\rangle + x_{100}|011\\rangle +\nx_{010}|100\\rangle + x_{011}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$</p>\n</li>\n<li><p>$\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle +\nx_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$</p>\n</li>\n</ol>\n<p>The result is the the $\\text{CINOT}$ gate as we intended; so we can write</p>\n<p>$$\\text{CINOT} = (\\text{SWAP} \\otimes I)(I \\otimes \\text{CNOT})(\\text{SWAP} \\otimes I)$$</p>\n<blockquote>\n<p>Note that in matrix notation we always apply a gate to the complete system, so we must apply $\\text{SWAP} \\otimes I$, spelling the identity gate explicitly.\nHowever, when implementing the unitary $\\text{SWAP} \\otimes I$ in Q#, we need only to call <code>SWAP(qs[0], qs[1])</code> - the remaining qubit <code>qs[2]</code> will not change, which is equivalent to applying an implicit identity gate.</p>\n<p>We can also spell out all gates applied explicitly (this makes for a much longer code, though):</p>\n<pre><code class=\"language-qsharp\">operation CINOT (qs: Qubit[]) : Unit {\n // First step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n // Second step\n I(qs[0]);\n CNOT(qs[1], qs[2]);\n // Third step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n}\n</code></pre>\n</blockquote>\n",
942
+ "asHtml": "<p>In the above examples the <code>CNOT</code> gate acted on two adjacent qubits. However, multi-qubit gates can act on non-adjacent qubits as well. Let&#39;s see how to work out the math of the system state change in this case.</p>\n<p>Take 3 qubits in an arbitrary state $|\\psi\\rangle = x_{000} |000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{100}|100\\rangle + x_{101}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle $.</p>\n<p>We can apply the <code>CNOT</code> gate on 1st and 3rd qubits, with the 1st qubit as control and the 3rd qubit as target. Let&#39;s label the 3-qubit gate that describes the effect of this on the whole system as <code>CINOT</code>. The <code>CINOT</code> ignores the 2nd qubit (leaves it unchanged) and applies the <code>CNOT</code> gate as specified above.</p>\n<h2>Q#</h2>\n<p>In Q# we describe the operation as the sequence of gates that are applied to the qubits, regardless of whether the qubits are adjacent or not.</p>\n<pre><code class=\"language-qsharp\">operation CINOT (qs: Qubit[]) : Unit {\n CNOT(qs[0], qs[2]); // Length of qs is assumed to be 3\n}\n</code></pre>\n<h2>Dirac Notation</h2>\n<p>In Dirac notation we can consider the effect of the gate on each basis vector separately: each basis vector $|a_1a_2a_3\\rangle$ remains unchanged if $a_1 = 0$, and becomes $|a_1a_2(\\neg a_3)\\rangle$ if $a_1 = 1$. The full effect on the state becomes:</p>\n<p>$$\\text{CINOT}|\\psi\\rangle = x_{000} \\text{CINOT}|000\\rangle + x_{001} \\text{CINOT}|001\\rangle + x_{010} \\text{CINOT}|010\\rangle + x_{011} \\text{CINOT}|011\\rangle+$$\n$$x_{100} \\text{CINOT}|100\\rangle + x_{101} \\text{CINOT}|101\\rangle + x_{110} \\text{CINOT}|110\\rangle + x_{111} \\text{CINOT}|111\\rangle =$$\n$$x_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle $$</p>\n<h2>Matrix Form</h2>\n<p>$\\text{CINOT}$ can also be represented in matrix form as a $2^3 \\times 2^3$ matrix:\n$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0\n\\end{bmatrix}\n$$</p>\n<p>Applying $\\text{CINOT}$ to $|\\psi\\rangle$ gives us\n$$\n\\text{CINOT} \\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0\n\\end{bmatrix}\n\\begin{bmatrix}\n x_{000} \\\\ x_{001} \\\\ x_{010} \\\\ x_{011} \\\\ x_{100} \\\\ x_{101} \\\\ x_{110} \\\\ x_{111}\n\\end{bmatrix} =\n\\begin{bmatrix}\n x_{000} \\\\ x_{001} \\\\ x_{010} \\\\ x_{011} \\\\ x_{101} \\\\ x_{100} \\\\ x_{111} \\\\ x_{110}\n\\end{bmatrix}\n$$</p>\n<p>However, as $N$ gets larger, creating a full size matrix can be extremely unwieldy. To express the matrix without spelling out its elements, we can use the following trick:</p>\n<ol>\n<li>Apply the <code>SWAP</code> gate on the 1st and 2nd qubits.\nThis will bring the qubits on which the <code>CNOT</code> gate acts next to each other, without any extra qubits between them.</li>\n<li>Apply the <code>CNOT</code> on 2nd and 3rd qubits.\nSince now the gate acts on adjacent qubits, this can be represented as a tensor product of the gate we&#39;re applying and <code>I</code> gates.</li>\n<li>Apply the <code>SWAP</code> gate on the 1st and 2nd qubits again.</li>\n</ol>\n<p>These can be represented as applying the following gates on the 3 qubits.</p>\n<ol>\n<li><p>$\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{100}|010\\rangle + x_{101}|011\\rangle +\nx_{010}|100\\rangle + x_{011}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle\n$$</p>\n</li>\n<li><p>$I \\otimes \\text{CNOT}$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{101}|010\\rangle + x_{100}|011\\rangle +\nx_{010}|100\\rangle + x_{011}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$</p>\n</li>\n<li><p>$\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle +\nx_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$</p>\n</li>\n</ol>\n<p>The result is the the $\\text{CINOT}$ gate as we intended; so we can write</p>\n<p>$$\\text{CINOT} = (\\text{SWAP} \\otimes I)(I \\otimes \\text{CNOT})(\\text{SWAP} \\otimes I)$$</p>\n<blockquote>\n<p>Note that in matrix notation we always apply a gate to the complete system, so we must apply $\\text{SWAP} \\otimes I$, spelling the identity gate explicitly.\nHowever, when implementing the unitary $\\text{SWAP} \\otimes I$ in Q#, we need only to call <code>SWAP(qs[0], qs[1])</code> - the remaining qubit <code>qs[2]</code> will not change, which is equivalent to applying an implicit identity gate.</p>\n<p>We can also spell out all gates applied explicitly (this makes for a much longer code, though):</p>\n<pre><code class=\"language-qsharp\">operation CINOT (qs: Qubit[]) : Unit {\n // First step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n // Second step\n I(qs[0]);\n CNOT(qs[1], qs[2]);\n // Third step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n}\n</code></pre>\n</blockquote>\n",
943
943
  "asMarkdown": "\nIn the above examples the `CNOT` gate acted on two adjacent qubits. However, multi-qubit gates can act on non-adjacent qubits as well. Let's see how to work out the math of the system state change in this case.\n\nTake 3 qubits in an arbitrary state $|\\psi\\rangle = x_{000} |000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{100}|100\\rangle + x_{101}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle $.\n\nWe can apply the `CNOT` gate on 1st and 3rd qubits, with the 1st qubit as control and the 3rd qubit as target. Let's label the 3-qubit gate that describes the effect of this on the whole system as `CINOT`. The `CINOT` ignores the 2nd qubit (leaves it unchanged) and applies the `CNOT` gate as specified above.\n\n## Q#\n\nIn Q# we describe the operation as the sequence of gates that are applied to the qubits, regardless of whether the qubits are adjacent or not.\n\n```qsharp\noperation CINOT (qs: Qubit[]) : Unit {\n CNOT(qs[0], qs[2]); // Length of qs is assumed to be 3\n}\n```\n\n## Dirac Notation\n\nIn Dirac notation we can consider the effect of the gate on each basis vector separately: each basis vector $|a_1a_2a_3\\rangle$ remains unchanged if $a_1 = 0$, and becomes $|a_1a_2(\\neg a_3)\\rangle$ if $a_1 = 1$. The full effect on the state becomes:\n\n$$\\text{CINOT}|\\psi\\rangle = x_{000} \\text{CINOT}|000\\rangle + x_{001} \\text{CINOT}|001\\rangle + x_{010} \\text{CINOT}|010\\rangle + x_{011} \\text{CINOT}|011\\rangle+$$\n$$x_{100} \\text{CINOT}|100\\rangle + x_{101} \\text{CINOT}|101\\rangle + x_{110} \\text{CINOT}|110\\rangle + x_{111} \\text{CINOT}|111\\rangle =$$\n$$x_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + x_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle $$\n\n## Matrix Form\n\n$\\text{CINOT}$ can also be represented in matrix form as a $2^3 \\times 2^3$ matrix:\n$$\n\\begin{bmatrix}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n\\end{bmatrix}\n$$\n\nApplying $\\text{CINOT}$ to $|\\psi\\rangle$ gives us\n$$\n\\text{CINOT} \\begin{bmatrix}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\\ \n 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n\\end{bmatrix}\n\\begin{bmatrix}\n x_{000} \\\\\\ x_{001} \\\\\\ x_{010} \\\\\\ x_{011} \\\\\\ x_{100} \\\\\\ x_{101} \\\\\\ x_{110} \\\\\\ x_{111}\n\\end{bmatrix} =\n\\begin{bmatrix}\n x_{000} \\\\\\ x_{001} \\\\\\ x_{010} \\\\\\ x_{011} \\\\\\ x_{101} \\\\\\ x_{100} \\\\\\ x_{111} \\\\\\ x_{110}\n\\end{bmatrix}\n$$\n\nHowever, as $N$ gets larger, creating a full size matrix can be extremely unwieldy. To express the matrix without spelling out its elements, we can use the following trick:\n\n1. Apply the `SWAP` gate on the 1st and 2nd qubits.\n This will bring the qubits on which the `CNOT` gate acts next to each other, without any extra qubits between them.\n2. Apply the `CNOT` on 2nd and 3rd qubits.\n Since now the gate acts on adjacent qubits, this can be represented as a tensor product of the gate we're applying and `I` gates.\n3. Apply the `SWAP` gate on the 1st and 2nd qubits again.\n\nThese can be represented as applying the following gates on the 3 qubits.\n\n1. $\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{100}|010\\rangle + x_{101}|011\\rangle +\nx_{010}|100\\rangle + x_{011}|101\\rangle + x_{110}|110\\rangle + x_{111}|111\\rangle\n$$\n\n2. $I \\otimes \\text{CNOT}$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{101}|010\\rangle + x_{100}|011\\rangle +\nx_{010}|100\\\\rangle + x_{011}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$\n\n3. $\\text{SWAP} \\otimes I$\n$$\nx_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle +\nx_{101}|100\\rangle + x_{100}|101\\rangle + x_{111}|110\\rangle + x_{110}|111\\rangle\n$$\n\nThe result is the the $\\text{CINOT}$ gate as we intended; so we can write\n\n$$\\text{CINOT} = (\\text{SWAP} \\otimes I)(I \\otimes \\text{CNOT})(\\text{SWAP} \\otimes I)$$\n\n> Note that in matrix notation we always apply a gate to the complete system, so we must apply $\\text{SWAP} \\otimes I$, spelling the identity gate explicitly.\n> However, when implementing the unitary $\\text{SWAP} \\otimes I$ in Q#, we need only to call `SWAP(qs[0], qs[1])` - the remaining qubit `qs[2]` will not change, which is equivalent to applying an implicit identity gate.\n>\n> We can also spell out all gates applied explicitly (this makes for a much longer code, though):\n> ```qsharp\noperation CINOT (qs: Qubit[]) : Unit {\n // First step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n // Second step\n I(qs[0]);\n CNOT(qs[1], qs[2]);\n // Third step\n SWAP(qs[0], qs[1]);\n I(qs[2]);\n}\n```"
944
944
  }
945
945
  ]
@@ -1005,7 +1005,7 @@ export default {
1005
1005
  "items": [
1006
1006
  {
1007
1007
  "type": "text-content",
1008
- "asHtml": "<p>Typically, the term &quot;controlled <code>U</code> gate&quot; refers to the type of gate we&#39;ve described previously, which applies the gate <code>U</code> only if the control qubit(s) are in the $|1\\rangle$ state.</p>\n<p>It is possible, however, to define variants of controlled gates that use different states as control states.\nFor example, an <strong>anti-controlled</strong> <code>U</code> gate (sometimes called <strong>zero-controlled</strong>) applies a gate only if the control qubit is in the $|0\\rangle$ state.\nIt is also possible to define control conditions in other bases, for example, applying the gate if the control qubit is in the $|+\\rangle$ state.</p>\n<p>All the variants of controlled gates can be expressed in terms of the controls described in previous sections, using the following sequence of steps:</p>\n<ul>\n<li>First, apply a transformation on control qubits that will transform the state you want to use as control into the $|1...1\\rangle$ state.</li>\n<li>Apply the regular controlled version of the gate.</li>\n<li>Finally, undo the transformation on control qubits from the first step using the adjoint version of it.</li>\n</ul>\n<blockquote>\n<p>Why do we need this last step? Remember that controlled gates are defined in terms of their effect on the basis states:\nwe apply the gate on the target qubit if and only if the control qubit is in the state we want to control on, and we don&#39;t change the state of the control qubit at all.\nIf we don&#39;t undo the transformation we did on the first step, applying our gate to a basis state will modify not only the state of the target qubit but also the state of the control qubit, which is not what we&#39;re looking for.</p>\n<p>For example, consider an anti-controlled <code>X</code> gate - a gate that should apply an $X$ gate to the second qubit if the first qubit is in the $|0\\rangle$ state.\nHere is the effect we expect this gate to have on each of the 2-qubit basis states:</p>\n<table>\n <tr>\n <th>Input state</th>\n <th>Output state</th>\n </tr>\n <tr>\n <td>$|00\\rangle$</td>\n <td>$|01\\rangle$</td>\n </tr>\n <tr>\n <td>$|01\\rangle$</td>\n <td>$|00\\rangle$</td>\n </tr>\n <tr>\n <td>$|10\\rangle$</td>\n <td>$|10\\rangle$</td>\n </tr>\n <tr>\n <td>$|11\\rangle$</td>\n <td>$|11\\rangle$</td>\n </tr>\n</blockquote>\n</table>\n\n<blockquote>\n<p>Let&#39;s apply the anti-controlled <code>X</code> gate to the $|00\\rangle$ state step by step:</p>\n<ol>\n<li>Transform the state of the control qubit to $|1\\rangle$: we can do that by applying the $X$ gate to the first qubit:\n$$|00\\rangle \\rightarrow |10\\rangle$$</li>\n<li>Apply the regular <code>CNOT</code> gate:\n$$|10\\rangle \\rightarrow |11\\rangle$$</li>\n<li>Now, if we don&#39;t undo the change we did on the first step, we&#39;ll end up with a gate that transforms $|00\\rangle$ into $|11\\rangle$, which is not the transformation we&#39;re trying to implement.\nHowever, if we undo it by applying the <code>X</code> gate to the first qubit again, we&#39;ll get the correct state:\n$$|11\\rangle \\rightarrow |01\\rangle$$</li>\n</ol>\n<p>You can check that getting the right behavior of the operation on the rest of the basis states also requires that last step.</p>\n</blockquote>\n<p>Finally, let&#39;s take a look at a very useful operation <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.canon.controlledonbitstring\" target=\"_blank\">ControlledOnBitString</a> provided by the Q# Standard library.\nIt defines a variant of a gate controlled on a state specified by a bit mask; for example, bit mask <code>[true, false]</code> means that the gate should be applied only if the two control qubits are in the $|10\\rangle$ state.</p>\n<p>The sequence of steps that implement this variant are:</p>\n<ol>\n<li>Apply the <code>X</code> gate to each control qubit that corresponds to a <code>false</code> element of the bit mask (in the example, that&#39;s just the second qubit). After this, if the control qubits started in the $|10\\rangle$ state, they&#39;ll end up in the $|11\\rangle$ state, and if they started in any other state, they&#39;ll end up in any state but $|11\\rangle$.</li>\n<li>Apply the regular controlled version of the gate.</li>\n<li>Apply the $X$ gate to the same qubits to return them to their original state.</li>\n</ol>\n",
1008
+ "asHtml": "<p>Typically, the term &quot;controlled <code>U</code> gate&quot; refers to the type of gate we&#39;ve described previously, which applies the gate <code>U</code> only if the control qubit(s) are in the $|1\\rangle$ state.</p>\n<p>It is possible, however, to define variants of controlled gates that use different states as control states.\nFor example, an <strong>anti-controlled</strong> <code>U</code> gate (sometimes called <strong>zero-controlled</strong>) applies a gate only if the control qubit is in the $|0\\rangle$ state.\nIt is also possible to define control conditions in other bases, for example, applying the gate if the control qubit is in the $|+\\rangle$ state.</p>\n<p>All the variants of controlled gates can be expressed in terms of the controls described in previous sections, using the following sequence of steps:</p>\n<ul>\n<li>First, apply a transformation on control qubits that will transform the state you want to use as control into the $|1...1\\rangle$ state.</li>\n<li>Apply the regular controlled version of the gate.</li>\n<li>Finally, undo the transformation on control qubits from the first step using the adjoint version of it.</li>\n</ul>\n<blockquote>\n<p>Why do we need this last step? Remember that controlled gates are defined in terms of their effect on the basis states:\nwe apply the gate on the target qubit if and only if the control qubit is in the state we want to control on, and we don&#39;t change the state of the control qubit at all.\nIf we don&#39;t undo the transformation we did on the first step, applying our gate to a basis state will modify not only the state of the target qubit but also the state of the control qubit, which is not what we&#39;re looking for.</p>\n<p>For example, consider an anti-controlled <code>X</code> gate - a gate that should apply an $X$ gate to the second qubit if the first qubit is in the $|0\\rangle$ state.\nHere is the effect we expect this gate to have on each of the 2-qubit basis states:</p>\n<table>\n <tr>\n <th>Input state</th>\n <th>Output state</th>\n </tr>\n <tr>\n <td>$|00\\rangle$</td>\n <td>$|01\\rangle$</td>\n </tr>\n <tr>\n <td>$|01\\rangle$</td>\n <td>$|00\\rangle$</td>\n </tr>\n <tr>\n <td>$|10\\rangle$</td>\n <td>$|10\\rangle$</td>\n </tr>\n <tr>\n <td>$|11\\rangle$</td>\n <td>$|11\\rangle$</td>\n </tr></blockquote>\n</table>\n\n<blockquote>\n<p>Let&#39;s apply the anti-controlled <code>X</code> gate to the $|00\\rangle$ state step by step:</p>\n<ol>\n<li>Transform the state of the control qubit to $|1\\rangle$: we can do that by applying the $X$ gate to the first qubit:\n$$|00\\rangle \\rightarrow |10\\rangle$$</li>\n<li>Apply the regular <code>CNOT</code> gate:\n$$|10\\rangle \\rightarrow |11\\rangle$$</li>\n<li>Now, if we don&#39;t undo the change we did on the first step, we&#39;ll end up with a gate that transforms $|00\\rangle$ into $|11\\rangle$, which is not the transformation we&#39;re trying to implement.\nHowever, if we undo it by applying the <code>X</code> gate to the first qubit again, we&#39;ll get the correct state:\n$$|11\\rangle \\rightarrow |01\\rangle$$</li>\n</ol>\n<p>You can check that getting the right behavior of the operation on the rest of the basis states also requires that last step.</p>\n</blockquote>\n<p>Finally, let&#39;s take a look at a very useful operation <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.canon.controlledonbitstring\" target=\"_blank\">ControlledOnBitString</a> provided by the Q# Standard library.\nIt defines a variant of a gate controlled on a state specified by a bit mask; for example, bit mask <code>[true, false]</code> means that the gate should be applied only if the two control qubits are in the $|10\\rangle$ state.</p>\n<p>The sequence of steps that implement this variant are:</p>\n<ol>\n<li>Apply the <code>X</code> gate to each control qubit that corresponds to a <code>false</code> element of the bit mask (in the example, that&#39;s just the second qubit). After this, if the control qubits started in the $|10\\rangle$ state, they&#39;ll end up in the $|11\\rangle$ state, and if they started in any other state, they&#39;ll end up in any state but $|11\\rangle$.</li>\n<li>Apply the regular controlled version of the gate.</li>\n<li>Apply the $X$ gate to the same qubits to return them to their original state.</li>\n</ol>\n",
1009
1009
  "asMarkdown": "\nTypically, the term \"controlled `U` gate\" refers to the type of gate we've described previously, which applies the gate `U` only if the control qubit(s) are in the $|1\\rangle$ state.\n\nIt is possible, however, to define variants of controlled gates that use different states as control states.\nFor example, an **anti-controlled** `U` gate (sometimes called **zero-controlled**) applies a gate only if the control qubit is in the $|0\\rangle$ state.\nIt is also possible to define control conditions in other bases, for example, applying the gate if the control qubit is in the $|+\\rangle$ state.\n\nAll the variants of controlled gates can be expressed in terms of the controls described in previous sections, using the following sequence of steps:\n* First, apply a transformation on control qubits that will transform the state you want to use as control into the $|1...1\\rangle$ state.\n* Apply the regular controlled version of the gate.\n* Finally, undo the transformation on control qubits from the first step using the adjoint version of it.\n\n> Why do we need this last step? Remember that controlled gates are defined in terms of their effect on the basis states:\n> we apply the gate on the target qubit if and only if the control qubit is in the state we want to control on, and we don't change the state of the control qubit at all.\n> If we don't undo the transformation we did on the first step, applying our gate to a basis state will modify not only the state of the target qubit but also the state of the control qubit, which is not what we're looking for.\n>\n> For example, consider an anti-controlled `X` gate - a gate that should apply an $X$ gate to the second qubit if the first qubit is in the $|0\\rangle$ state.\n> Here is the effect we expect this gate to have on each of the 2-qubit basis states:\n>\n> <table>\n <tr>\n <th>Input state</th>\n <th>Output state</th>\n </tr>\n <tr>\n <td>$|00\\rangle$</td>\n <td>$|01\\rangle$</td>\n </tr>\n <tr>\n <td>$|01\\rangle$</td>\n <td>$|00\\rangle$</td>\n </tr>\n <tr>\n <td>$|10\\rangle$</td>\n <td>$|10\\rangle$</td>\n </tr>\n <tr>\n <td>$|11\\rangle$</td>\n <td>$|11\\rangle$</td>\n </tr>\n</table>\n\n> Let's apply the anti-controlled `X` gate to the $|00\\rangle$ state step by step:\n> 1. Transform the state of the control qubit to $|1\\rangle$: we can do that by applying the $X$ gate to the first qubit:\n> $$|00\\rangle \\rightarrow |10\\rangle$$\n> 2. Apply the regular `CNOT` gate:\n> $$|10\\rangle \\rightarrow |11\\rangle$$\n> 3. Now, if we don't undo the change we did on the first step, we'll end up with a gate that transforms $|00\\rangle$ into $|11\\rangle$, which is not the transformation we're trying to implement.\n> However, if we undo it by applying the `X` gate to the first qubit again, we'll get the correct state:\n> $$|11\\rangle \\rightarrow |01\\rangle$$\n>\n> You can check that getting the right behavior of the operation on the rest of the basis states also requires that last step.\n\nFinally, let's take a look at a very useful operation <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.canon.controlledonbitstring\" target=\"_blank\">ControlledOnBitString</a> provided by the Q# Standard library.\nIt defines a variant of a gate controlled on a state specified by a bit mask; for example, bit mask `[true, false]` means that the gate should be applied only if the two control qubits are in the $|10\\rangle$ state.\n\nThe sequence of steps that implement this variant are:\n1. Apply the `X` gate to each control qubit that corresponds to a `false` element of the bit mask (in the example, that's just the second qubit). After this, if the control qubits started in the $|10\\rangle$ state, they'll end up in the $|11\\rangle$ state, and if they started in any other state, they'll end up in any state but $|11\\rangle$.\n2. Apply the regular controlled version of the gate.\n3. Apply the $X$ gate to the same qubits to return them to their original state."
1010
1010
  }
1011
1011
  ]
@@ -1097,7 +1097,7 @@ export default {
1097
1097
  "items": [
1098
1098
  {
1099
1099
  "type": "text-content",
1100
- "asHtml": "<p>In this section, we will discuss the simplest type of qubit measurements - measurements in the computational basis. This is the &quot;default&quot; type of measurements. Unless otherwise specified, &quot;measurement&quot; refers to this type.</p>\n<p>The state $\\ket{\\psi}$ of a single qubit can always be expressed in Dirac notation as:\n$$\\ket{\\psi} = \\alpha \\ket{0} + \\beta \\ket{1}$$\nwhere $\\alpha$ and $\\beta$ are complex numbers, and the state is normalized, $|\\alpha|^2 + |\\beta|^2 = 1$.</p>\n<p>To get some information about the qubit state, we can measure the qubit. Similar to the classical case of measuring a bit, the outcome of a measurement can be $0$ or $1$. However, unlike the classical case, quantum measurement is a probabilistic process.</p>\n<p>The probabilities of the measurement outcomes being $0$ and $1$ are $|\\alpha|^2$ and $|\\beta|^2$, respectively. Additionally, the state of the qubit is modified by the measurement - if the outcome of the measurement is $0$, then the post-measurement state of the qubit is $\\ket{0}$, and if the outcome is $1$, the state is $\\ket{1}$. In quantum mechanics, this is referred to as the <a href=\"https://en.wikipedia.org/wiki/Wave_function_collapse\" target=\"_blank\">collapse of the wave function</a>.</p>\n<p>The outcomes of computational basis measurements and their probabilities are summarized in the table below:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$|\\alpha|^2$</td>\n <td>$\\ket 0$</td>\n </tr>\n <tr>\n <td>$1$</td>\n <td>$|\\beta|^2$</td>\n <td>$\\ket 1$</td>\n </tr>\n</table>\n\n<blockquote>\n<p>Unlike quantum gates which are unitary and reversible operations, measurements are neither unitary nor reversible. Since the outcomes of a measurement are probabilistic, any two isolated qubits which are initially prepared in identical superposition states are in general not guaranteed to have the same measurement outcomes after each qubit has been measured separately. As we will see below, measurements are modeled by projection operators instead of unitary operators.</p>\n<p>Additionally, the assumption of the wave function being <strong>normalized</strong> is important, since the probability outcomes must sum up to $1$. If the wave function is not normalized, it is important to normalize it first in order to obtain the correct measurement probabilities.</p>\n</blockquote>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p>The qubit is in the following state:\n$$\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1 \\equiv \\begin{bmatrix} 0.6 \\\\ 0.8\\end{bmatrix}.$$</p>\n<p>If this qubit is measured in the computational basis, what are the outcome probabilities?</p>\n<details>\n<summary><b>Solution</b></summary>\nThe given state $\\ket \\psi$ is normalized, since $0.6^2 + 0.8^2 = 1$. Hence, the probability of measuring $0$ is $|0.6|^2 = 0.36$, and the probability of measuring $1$ is $|0.8|^2 = 0.64$.\n</details>",
1100
+ "asHtml": "<p>In this section, we will discuss the simplest type of qubit measurements - measurements in the computational basis. This is the &quot;default&quot; type of measurements. Unless otherwise specified, &quot;measurement&quot; refers to this type.</p>\n<p>The state $\\ket{\\psi}$ of a single qubit can always be expressed in Dirac notation as:\n$$\\ket{\\psi} = \\alpha \\ket{0} + \\beta \\ket{1}$$\nwhere $\\alpha$ and $\\beta$ are complex numbers, and the state is normalized, $|\\alpha|^2 + |\\beta|^2 = 1$.</p>\n<p>To get some information about the qubit state, we can measure the qubit. Similar to the classical case of measuring a bit, the outcome of a measurement can be $0$ or $1$. However, unlike the classical case, quantum measurement is a probabilistic process.</p>\n<p>The probabilities of the measurement outcomes being $0$ and $1$ are $|\\alpha|^2$ and $|\\beta|^2$, respectively. Additionally, the state of the qubit is modified by the measurement - if the outcome of the measurement is $0$, then the post-measurement state of the qubit is $\\ket{0}$, and if the outcome is $1$, the state is $\\ket{1}$. In quantum mechanics, this is referred to as the <a href=\"https://en.wikipedia.org/wiki/Wave_function_collapse\" target=\"_blank\">collapse of the wave function</a>.</p>\n<p>The outcomes of computational basis measurements and their probabilities are summarized in the table below:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$|\\alpha|^2$</td>\n <td>$\\ket 0$</td>\n </tr>\n <tr>\n <td>$1$</td>\n <td>$|\\beta|^2$</td>\n <td>$\\ket 1$</td>\n </tr>\n</table>\n\n<blockquote>\n<p>Unlike quantum gates which are unitary and reversible operations, measurements are neither unitary nor reversible. Since the outcomes of a measurement are probabilistic, any two isolated qubits which are initially prepared in identical superposition states are in general not guaranteed to have the same measurement outcomes after each qubit has been measured separately. As we will see below, measurements are modeled by projection operators instead of unitary operators.</p>\n<p>Additionally, the assumption of the wave function being <strong>normalized</strong> is important, since the probability outcomes must sum up to $1$. If the wave function is not normalized, it is important to normalize it first in order to obtain the correct measurement probabilities.</p>\n</blockquote>\n<h2>🔎 Analyze</h2>\n<p>The qubit is in the following state:\n$$\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1 \\equiv \\begin{bmatrix} 0.6 \\\\ 0.8\\end{bmatrix}.$$</p>\n<p>If this qubit is measured in the computational basis, what are the outcome probabilities?</p>\n<details>\n<summary><b>Solution</b></summary>\nThe given state $\\ket \\psi$ is normalized, since $0.6^2 + 0.8^2 = 1$. Hence, the probability of measuring $0$ is $|0.6|^2 = 0.36$, and the probability of measuring $1$ is $|0.8|^2 = 0.64$.\n</details>",
1101
1101
  "asMarkdown": "\nIn this section, we will discuss the simplest type of qubit measurements - measurements in the computational basis. This is the \"default\" type of measurements. Unless otherwise specified, \"measurement\" refers to this type.\n\nThe state $\\ket{\\psi}$ of a single qubit can always be expressed in Dirac notation as:\n$$\\ket{\\psi} = \\alpha \\ket{0} + \\beta \\ket{1}$$\nwhere $\\alpha$ and $\\beta$ are complex numbers, and the state is normalized, $|\\alpha|^2 + |\\beta|^2 = 1$.\n\nTo get some information about the qubit state, we can measure the qubit. Similar to the classical case of measuring a bit, the outcome of a measurement can be $0$ or $1$. However, unlike the classical case, quantum measurement is a probabilistic process.\n\nThe probabilities of the measurement outcomes being $0$ and $1$ are $|\\alpha|^2$ and $|\\beta|^2$, respectively. Additionally, the state of the qubit is modified by the measurement - if the outcome of the measurement is $0$, then the post-measurement state of the qubit is $\\ket{0}$, and if the outcome is $1$, the state is $\\ket{1}$. In quantum mechanics, this is referred to as the <a href=\"https://en.wikipedia.org/wiki/Wave_function_collapse\" target=\"_blank\">collapse of the wave function</a>.\n\nThe outcomes of computational basis measurements and their probabilities are summarized in the table below:\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$|\\alpha|^2$</td>\n <td>$\\ket 0$</td>\n </tr>\n <tr>\n <td>$1$</td>\n <td>$|\\beta|^2$</td>\n <td>$\\ket 1$</td>\n </tr>\n</table>\n\n>Unlike quantum gates which are unitary and reversible operations, measurements are neither unitary nor reversible. Since the outcomes of a measurement are probabilistic, any two isolated qubits which are initially prepared in identical superposition states are in general not guaranteed to have the same measurement outcomes after each qubit has been measured separately. As we will see below, measurements are modeled by projection operators instead of unitary operators.\n>\n>Additionally, the assumption of the wave function being **normalized** is important, since the probability outcomes must sum up to $1$. If the wave function is not normalized, it is important to normalize it first in order to obtain the correct measurement probabilities.\n\n## 🔎 Analyze\n\nThe qubit is in the following state:\n$$\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1 \\equiv \\begin{bmatrix} 0.6 \\\\\\ 0.8\\end{bmatrix}.$$\n\nIf this qubit is measured in the computational basis, what are the outcome probabilities?\n\n<details>\n<summary><b>Solution</b></summary>\nThe given state $\\ket \\psi$ is normalized, since $0.6^2 + 0.8^2 = 1$. Hence, the probability of measuring $0$ is $|0.6|^2 = 0.36$, and the probability of measuring $1$ is $|0.8|^2 = 0.64$.\n</details>"
1102
1102
  }
1103
1103
  ]
@@ -1222,7 +1222,7 @@ export default {
1222
1222
  "items": [
1223
1223
  {
1224
1224
  "type": "text-content",
1225
- "asHtml": "<p>It is possible to measure a qubit in orthogonal bases other than the Pauli bases. Suppose one wants to measure a qubit in an orthonormal basis $\\ket {b_0}$ and $\\ket {b_1}$. Let the state of the qubit be represented by the normalized vector $\\ket \\psi$. Then, one can always express the state in terms of the basis vectors $\\ket{b_0}$ and $\\ket{b_1}$, i.e., there exist complex numbers $c_0, c_1$, such that\n$$\n\\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1}.\n$$\nThe rule for obtaining the probabilities of measurement outcomes is exactly the same as that for the computation basis measurement. For a measurement in a ${ b_0, b_1}$ basis we get</p>\n<ul>\n<li>Outcome $b_0$ with probability $|c_0|^2$ and the post-measurement qubit state of $\\ket {b_0}$</li>\n<li>Outcome $b_1$ with probability $|c_1|^2$ and the post-measurement qubit state of $\\ket {b_1}$</li>\n</ul>\n<p>This can be summarized in the following table:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_0$</td>\n <td>$|c_0|^2$</td>\n <td>$\\ket{b_0}$</td>\n </tr>\n <tr>\n <td>$b_1$</td>\n <td>$|c_1|^2$</td>\n <td>$\\ket{b_1}$</td>\n </tr>\n</table>\n\n<p>As before, the assumption of $\\ket \\psi$ being normalized is important, since it guarantees that the two probabilities add to $1$.</p>\n<blockquote>\n<p>As you may recall, a global phase is said to be hidden or unobservable.\nThis is explained by the fact that global phases have no impact on quantum measurements. For example, consider two isolated qubits which are in (normalized) states $\\ket \\psi$ and $e^{i\\theta}\\ket \\psi$.\nIf both are measured in an orthogonal basis ${ \\ket{b_0},\\ket{b_1}}$, the probabilities of measuring $b_0$ or $b_1$ are identical in both cases, since $|\\bra{b_i}\\ket{\\psi}|^2 = |\\bra{b_i}e^{i\\theta}\\ket{\\psi}|^2 $.\nSimilarly, for either qubit, if $b_i$ is the measurement outcome, the post-measurement state of the qubit is $\\ket{b_i}$ for both qubits. Hence, the measurements are independent of the global phase $\\theta$.</p>\n</blockquote>\n<h2 id=\"measurements-as-projection-operations\">Measurements as Projection Operations</h2>\n<p>Just as qubits are represented by vectors and quantum gates are represented by matrices, quantum measurements are represented by orthogonal projection operators. An orthogonal projection operator is a matrix $P$ which satisfies the following property:\n$$\nP^2 = P^\\dagger = P.\n$$\n(As usual, the $\\dagger$ symbol denotes conjugate transposition.)</p>\n<p>As the name implies, orthogonal projection operators project the state of the qubit onto an orthogonal subspace. Using the ket-bra representation, one can represent a projection matrix in the Dirac notation.\nFor example, one may construct a projector onto the $\\ket{0}$ subspace as:\n$$\nP = \\ket 0 \\bra 0 \\equiv \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 0\\end{bmatrix}.\n$$</p>\n<p>A measurement in an orthogonal basis ${ \\ket{b_0}, \\ket{b_1}}$ is described by a pair of projectors $P_0 = \\ket{b_0}\\bra{b_0}$ and $P_1 = \\ket{b_1}\\bra{b_1}$. Since $\\ket{b_0}$ and $\\ket{b_1}$ are orthogonal, their projectors are also orthogonal, i.e., $P_0 P_1 = P_1 P_0 = 0$. The rules for measurements in this basis can then be summarized as follows:</p>\n<ul>\n<li>Measuring a qubit in a state $\\ket \\psi$ is done by picking one of these projection operators at random.</li>\n<li>Projection $P_0$ is chosen with probability $|P_0 \\ket{\\psi}|^2$, and the projector $P_1$ is chosen with probability $|P_1\\ket{\\psi}|^2.$</li>\n<li>If projector $P_0$ is chosen, the post-measurement state of the qubit is given by\n$$\n\\frac1{|P_0 \\ket{\\psi}|}P_0 \\ket\\psi,\n$$\nand similarly for $P_1$.</li>\n</ul>\n<p>Although this formalism looks different from the previous sections, it is in fact equivalent. If $\\ket \\psi = c_0 \\ket{b_0} + c_1 \\ket{b_1}$, we have\n$$\nP_0 \\ket \\psi = c_0 \\ket{b_0}, \\text{so that } | P_0\\ket \\psi| = c_0,\n$$\nand similarly,\n$$\nP_1 \\ket \\psi = c_1 \\ket{b_1}, \\text{so that } |P_1\\ket \\psi| = c_1.\n$$</p>\n<p>Thus, as before, the probability of measuring $b_0$ is $|P_0\\ket\\psi|^2 = |c_0|^2$, and the probability of measuring $b_1$ is $|P_1\\ket\\psi|^2 = |c_1|^2$. Similarly, one can verify that the post-measurement outcomes are also $\\ket{b_0}$ and $\\ket{b_1}$ respectively (up to unobservable global phases).</p>\n<p>Although the projector formalism for single-qubit systems may seem superfluous, its importance will become clear later while considering measurements for multi-qubit systems.</p>\n<h2 id=\"arbitrary-basis-measurements-implementation\">Arbitrary Basis Measurements Implementation</h2>\n<p>In the previous section, we discussed measurements in Pauli bases using the built-in <code>Measure</code> operation. We will now show that it is always possible to measure a qubit in any orthogonal basis using just unitary rotation matrices and computation basis measurements.</p>\n<p>Consider a state $ \\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1} $ which we would like to measure in an orthonormal basis ${ \\ket{b_0}, \\ket{b_1}}$. First, we construct the following unitary matrix:\n$$\nU = \\ket{0} \\bra{b_0} + \\ket{1} \\bra{b_1}\n$$</p>\n<p>The conjugate transpose of this unitary is the operator\n$$\nU^\\dagger = \\ket{b_0} \\bra{0} + \\ket{b_1} \\bra{1}\n$$</p>\n<p>(One may verify that $U$ is indeed a unitary matrix, by checking that $U^\\dagger U = U U^\\dagger = I$)</p>\n<p>Note that the effect of these matrices on the two bases is the following:\n$$U\\ket{b_0} = \\ket{0},$$\n$$U\\ket{b_1} = \\ket{1},$$\n$$U^\\dagger \\ket{0} = \\ket{b_0},$$\n$$U^\\dagger \\ket 1 = \\ket{b_1}.$$</p>\n<p>In order to implement a measurement in the ${ \\ket{b_0}, \\ket{b_1} }$ basis, we do the following:</p>\n<ol>\n<li>Apply $U$ to $\\ket \\psi$.<br>The resulting state is $U\\ket \\psi = c_0 \\ket 0 + c_1 \\ket 1 $.</li>\n<li>Measure the state $U\\ket{\\psi}$ in the computational basis.<br>The outcomes $0$ and $1$ occur with probabilities $|c_0|^2$ and $|c_1|^2$.</li>\n<li>Apply $U^\\dagger$ to the post-measurement state.<br>This transforms the states $\\ket 0$ and $\\ket 1$ to the states $\\ket{b_0}$ and $\\ket{b_1}$, respectively.</li>\n</ol>\n<p>Thus, $b_0$ and $b_1$ are measured with probabilities $|c_0|^2$ and $|c_1|^2$, respectively, with the end state being $\\ket{b_0}$ and $\\ket{b_1}$ - which is exactly the measurement we want to implement.</p>\n<p>This procedure can be used to distinguish arbitrary orthogonal states as well, as will become clear from the following exercises.</p>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p><strong>The outcome probabilities for a measurement in a specified basis</strong></p>\n<ol>\n<li><p>What are the outcome probabilities of measuring a qubit in the $\\ket{0}$ state in the Pauli X basis, i.e., the ${ \\ket +, \\ket -}$ basis?</p>\n</li>\n<li><p>What are the outcome probabilities of measuring a qubit in the $0.6\\ket{0} + 0.8 \\ket{1}$ state in the Pauli Y basis, i.e., the ${ \\ket i, \\ket{-i}}$ basis?</p>\n</li>\n</ol>\n<details>\n<summary><b>Solution</b></summary>\n\n<ol>\n<li><p>To find the probabilities of measuring $+$ and $-$, we first need to express the state $\\ket 0$ in terms of $\\ket +$ and $\\ket -$. Using the fact that $\\ket{\\pm} = \\frac{1}{\\sqrt{2}} (\\ket{0} \\pm \\ket{1})$, we can show that\n $$\n \\ket 0 = \\frac{1}{\\sqrt{2}} \\ket{+} + \\frac{1}{\\sqrt{2}} \\ket{-}.\n $$\n Thus, the probability of measuring $+$ is $|\\frac1{\\sqrt2}|^2 = 0.5$, and similarly, the probability of measuring $-$ is $0.5$.</p>\n</li>\n<li><p>Similar to the first part, we need to express the state $\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1$ in the $\\ket{\\pm i}$ basis. For this calculation, we use the projection matrix approach.</p>\n<p> First, we recall that the states $\\ket{\\pm i}$ are given by\n $$\n \\ket{\\pm i} = \\frac1{\\sqrt2} (\\ket 0 \\pm i \\ket 1).\n $$</p>\n<p> We can now construct the two projectors $P_{\\pm i}$ onto states $\\ket {\\pm i}$ as follows:\n $$P_{i} = \\ket{i}\\bra{i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\end{bmatrix} \\begin{bmatrix} 1 &amp; -i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 &amp; -i \\\\ i &amp; 1\\end{bmatrix},$$\n $$P_{-i} = \\ket{-i}\\bra{-i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\ -i \\end{bmatrix} \\begin{bmatrix} 1 &amp; i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 &amp; i \\\\ -i &amp; 1\\end{bmatrix}.$$</p>\n<p> Recalling that the probabilities of measuring $\\pm i$ are equal to the norm of the vectors $P_{\\pm i}\\ket \\psi$, we now apply $P_{\\pm i}$ to $\\ket \\psi$:\n $$P_{+i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 &amp; -i \\\\ i &amp; 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 - 0.8i \\\\ 0.8 + 0.6i \\end{bmatrix},$$\n $$P_{-i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 &amp; i \\\\ -i &amp; 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 + 0.8i \\\\ 0.8 - 0.6i \\end{bmatrix}.$$</p>\n<p> Hence, the probabilities of measuring $\\pm i$, which we denote by $p(\\pm i)$, are:\n $$p(+i) = |P_{+i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 - 0.8i|^2 + |0.8 + 0.6i|^2) = \\frac{1}{2},$$\n $$p(-i) = |P_{-i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 + 0.8i|^2 + |0.8 - 0.6i|^2) = \\frac{1}{2}.$$</p>\n</li>\n</ol>\n</details>",
1225
+ "asHtml": "<p>It is possible to measure a qubit in orthogonal bases other than the Pauli bases. Suppose one wants to measure a qubit in an orthonormal basis $\\ket {b_0}$ and $\\ket {b_1}$. Let the state of the qubit be represented by the normalized vector $\\ket \\psi$. Then, one can always express the state in terms of the basis vectors $\\ket{b_0}$ and $\\ket{b_1}$, i.e., there exist complex numbers $c_0, c_1$, such that\n$$\n\\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1}.\n$$\nThe rule for obtaining the probabilities of measurement outcomes is exactly the same as that for the computation basis measurement. For a measurement in a ${ b_0, b_1}$ basis we get</p>\n<ul>\n<li>Outcome $b_0$ with probability $|c_0|^2$ and the post-measurement qubit state of $\\ket {b_0}$</li>\n<li>Outcome $b_1$ with probability $|c_1|^2$ and the post-measurement qubit state of $\\ket {b_1}$</li>\n</ul>\n<p>This can be summarized in the following table:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_0$</td>\n <td>$|c_0|^2$</td>\n <td>$\\ket{b_0}$</td>\n </tr>\n <tr>\n <td>$b_1$</td>\n <td>$|c_1|^2$</td>\n <td>$\\ket{b_1}$</td>\n </tr>\n</table>\n\n<p>As before, the assumption of $\\ket \\psi$ being normalized is important, since it guarantees that the two probabilities add to $1$.</p>\n<blockquote>\n<p>As you may recall, a global phase is said to be hidden or unobservable.\nThis is explained by the fact that global phases have no impact on quantum measurements. For example, consider two isolated qubits which are in (normalized) states $\\ket \\psi$ and $e^{i\\theta}\\ket \\psi$.\nIf both are measured in an orthogonal basis ${ \\ket{b_0},\\ket{b_1}}$, the probabilities of measuring $b_0$ or $b_1$ are identical in both cases, since $|\\bra{b_i}\\ket{\\psi}|^2 = |\\bra{b_i}e^{i\\theta}\\ket{\\psi}|^2 $.\nSimilarly, for either qubit, if $b_i$ is the measurement outcome, the post-measurement state of the qubit is $\\ket{b_i}$ for both qubits. Hence, the measurements are independent of the global phase $\\theta$.</p>\n</blockquote>\n<h2>Measurements as Projection Operations</h2>\n<p>Just as qubits are represented by vectors and quantum gates are represented by matrices, quantum measurements are represented by orthogonal projection operators. An orthogonal projection operator is a matrix $P$ which satisfies the following property:\n$$\nP^2 = P^\\dagger = P.\n$$\n(As usual, the $\\dagger$ symbol denotes conjugate transposition.)</p>\n<p>As the name implies, orthogonal projection operators project the state of the qubit onto an orthogonal subspace. Using the ket-bra representation, one can represent a projection matrix in the Dirac notation.\nFor example, one may construct a projector onto the $\\ket{0}$ subspace as:\n$$\nP = \\ket 0 \\bra 0 \\equiv \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 0\\end{bmatrix}.\n$$</p>\n<p>A measurement in an orthogonal basis ${ \\ket{b_0}, \\ket{b_1}}$ is described by a pair of projectors $P_0 = \\ket{b_0}\\bra{b_0}$ and $P_1 = \\ket{b_1}\\bra{b_1}$. Since $\\ket{b_0}$ and $\\ket{b_1}$ are orthogonal, their projectors are also orthogonal, i.e., $P_0 P_1 = P_1 P_0 = 0$. The rules for measurements in this basis can then be summarized as follows:</p>\n<ul>\n<li>Measuring a qubit in a state $\\ket \\psi$ is done by picking one of these projection operators at random.</li>\n<li>Projection $P_0$ is chosen with probability $|P_0 \\ket{\\psi}|^2$, and the projector $P_1$ is chosen with probability $|P_1\\ket{\\psi}|^2.$</li>\n<li>If projector $P_0$ is chosen, the post-measurement state of the qubit is given by\n$$\n\\frac1{|P_0 \\ket{\\psi}|}P_0 \\ket\\psi,\n$$\nand similarly for $P_1$.</li>\n</ul>\n<p>Although this formalism looks different from the previous sections, it is in fact equivalent. If $\\ket \\psi = c_0 \\ket{b_0} + c_1 \\ket{b_1}$, we have\n$$\nP_0 \\ket \\psi = c_0 \\ket{b_0}, \\text{so that } | P_0\\ket \\psi| = c_0,\n$$\nand similarly,\n$$\nP_1 \\ket \\psi = c_1 \\ket{b_1}, \\text{so that } |P_1\\ket \\psi| = c_1.\n$$</p>\n<p>Thus, as before, the probability of measuring $b_0$ is $|P_0\\ket\\psi|^2 = |c_0|^2$, and the probability of measuring $b_1$ is $|P_1\\ket\\psi|^2 = |c_1|^2$. Similarly, one can verify that the post-measurement outcomes are also $\\ket{b_0}$ and $\\ket{b_1}$ respectively (up to unobservable global phases).</p>\n<p>Although the projector formalism for single-qubit systems may seem superfluous, its importance will become clear later while considering measurements for multi-qubit systems.</p>\n<h2>Arbitrary Basis Measurements Implementation</h2>\n<p>In the previous section, we discussed measurements in Pauli bases using the built-in <code>Measure</code> operation. We will now show that it is always possible to measure a qubit in any orthogonal basis using just unitary rotation matrices and computation basis measurements.</p>\n<p>Consider a state $ \\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1} $ which we would like to measure in an orthonormal basis ${ \\ket{b_0}, \\ket{b_1}}$. First, we construct the following unitary matrix:\n$$\nU = \\ket{0} \\bra{b_0} + \\ket{1} \\bra{b_1}\n$$</p>\n<p>The conjugate transpose of this unitary is the operator\n$$\nU^\\dagger = \\ket{b_0} \\bra{0} + \\ket{b_1} \\bra{1}\n$$</p>\n<p>(One may verify that $U$ is indeed a unitary matrix, by checking that $U^\\dagger U = U U^\\dagger = I$)</p>\n<p>Note that the effect of these matrices on the two bases is the following:\n$$U\\ket{b_0} = \\ket{0},$$\n$$U\\ket{b_1} = \\ket{1},$$\n$$U^\\dagger \\ket{0} = \\ket{b_0},$$\n$$U^\\dagger \\ket 1 = \\ket{b_1}.$$</p>\n<p>In order to implement a measurement in the ${ \\ket{b_0}, \\ket{b_1} }$ basis, we do the following:</p>\n<ol>\n<li>Apply $U$ to $\\ket \\psi$.<br>The resulting state is $U\\ket \\psi = c_0 \\ket 0 + c_1 \\ket 1 $.</li>\n<li>Measure the state $U\\ket{\\psi}$ in the computational basis.<br>The outcomes $0$ and $1$ occur with probabilities $|c_0|^2$ and $|c_1|^2$.</li>\n<li>Apply $U^\\dagger$ to the post-measurement state.<br>This transforms the states $\\ket 0$ and $\\ket 1$ to the states $\\ket{b_0}$ and $\\ket{b_1}$, respectively.</li>\n</ol>\n<p>Thus, $b_0$ and $b_1$ are measured with probabilities $|c_0|^2$ and $|c_1|^2$, respectively, with the end state being $\\ket{b_0}$ and $\\ket{b_1}$ - which is exactly the measurement we want to implement.</p>\n<p>This procedure can be used to distinguish arbitrary orthogonal states as well, as will become clear from the following exercises.</p>\n<h2>🔎 Analyze</h2>\n<p><strong>The outcome probabilities for a measurement in a specified basis</strong></p>\n<ol>\n<li><p>What are the outcome probabilities of measuring a qubit in the $\\ket{0}$ state in the Pauli X basis, i.e., the ${ \\ket +, \\ket -}$ basis?</p>\n</li>\n<li><p>What are the outcome probabilities of measuring a qubit in the $0.6\\ket{0} + 0.8 \\ket{1}$ state in the Pauli Y basis, i.e., the ${ \\ket i, \\ket{-i}}$ basis?</p>\n</li>\n</ol>\n<details>\n<summary><b>Solution</b></summary>\n\n<ol>\n<li><p>To find the probabilities of measuring $+$ and $-$, we first need to express the state $\\ket 0$ in terms of $\\ket +$ and $\\ket -$. Using the fact that $\\ket{\\pm} = \\frac{1}{\\sqrt{2}} (\\ket{0} \\pm \\ket{1})$, we can show that\n $$\n \\ket 0 = \\frac{1}{\\sqrt{2}} \\ket{+} + \\frac{1}{\\sqrt{2}} \\ket{-}.\n $$\n Thus, the probability of measuring $+$ is $|\\frac1{\\sqrt2}|^2 = 0.5$, and similarly, the probability of measuring $-$ is $0.5$.</p>\n</li>\n<li><p>Similar to the first part, we need to express the state $\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1$ in the $\\ket{\\pm i}$ basis. For this calculation, we use the projection matrix approach.</p>\n<p> First, we recall that the states $\\ket{\\pm i}$ are given by\n $$\n \\ket{\\pm i} = \\frac1{\\sqrt2} (\\ket 0 \\pm i \\ket 1).\n $$</p>\n<p> We can now construct the two projectors $P_{\\pm i}$ onto states $\\ket {\\pm i}$ as follows:\n $$P_{i} = \\ket{i}\\bra{i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\ i \\end{bmatrix} \\begin{bmatrix} 1 &amp; -i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 &amp; -i \\\\ i &amp; 1\\end{bmatrix},$$\n $$P_{-i} = \\ket{-i}\\bra{-i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\ -i \\end{bmatrix} \\begin{bmatrix} 1 &amp; i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 &amp; i \\\\ -i &amp; 1\\end{bmatrix}.$$</p>\n<p> Recalling that the probabilities of measuring $\\pm i$ are equal to the norm of the vectors $P_{\\pm i}\\ket \\psi$, we now apply $P_{\\pm i}$ to $\\ket \\psi$:\n $$P_{+i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 &amp; -i \\\\ i &amp; 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 - 0.8i \\\\ 0.8 + 0.6i \\end{bmatrix},$$\n $$P_{-i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 &amp; i \\\\ -i &amp; 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 + 0.8i \\\\ 0.8 - 0.6i \\end{bmatrix}.$$</p>\n<p> Hence, the probabilities of measuring $\\pm i$, which we denote by $p(\\pm i)$, are:\n $$p(+i) = |P_{+i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 - 0.8i|^2 + |0.8 + 0.6i|^2) = \\frac{1}{2},$$\n $$p(-i) = |P_{-i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 + 0.8i|^2 + |0.8 - 0.6i|^2) = \\frac{1}{2}.$$</p>\n</li>\n</ol>\n</details>",
1226
1226
  "asMarkdown": "\nIt is possible to measure a qubit in orthogonal bases other than the Pauli bases. Suppose one wants to measure a qubit in an orthonormal basis $\\ket {b_0}$ and $\\ket {b_1}$. Let the state of the qubit be represented by the normalized vector $\\ket \\psi$. Then, one can always express the state in terms of the basis vectors $\\ket{b_0}$ and $\\ket{b_1}$, i.e., there exist complex numbers $c_0, c_1$, such that\n$$\n\\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1}.\n$$\nThe rule for obtaining the probabilities of measurement outcomes is exactly the same as that for the computation basis measurement. For a measurement in a $\\{ b_0, b_1\\}$ basis we get\n\n- Outcome $b_0$ with probability $|c_0|^2$ and the post-measurement qubit state of $\\ket {b_0}$\n- Outcome $b_1$ with probability $|c_1|^2$ and the post-measurement qubit state of $\\ket {b_1}$\n\nThis can be summarized in the following table:\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_0$</td>\n <td>$|c_0|^2$</td>\n <td>$\\ket{b_0}$</td>\n </tr>\n <tr>\n <td>$b_1$</td>\n <td>$|c_1|^2$</td>\n <td>$\\ket{b_1}$</td>\n </tr>\n</table>\n\nAs before, the assumption of $\\ket \\psi$ being normalized is important, since it guarantees that the two probabilities add to $1$.\n\n> As you may recall, a global phase is said to be hidden or unobservable.\nThis is explained by the fact that global phases have no impact on quantum measurements. For example, consider two isolated qubits which are in (normalized) states $\\ket \\psi$ and $e^{i\\theta}\\ket \\psi$.\nIf both are measured in an orthogonal basis $\\{ \\ket{b_0},\\ket{b_1}\\}$, the probabilities of measuring $b_0$ or $b_1$ are identical in both cases, since $|\\bra{b_i}\\ket{\\psi}|^2 = |\\bra{b_i}e^{i\\theta}\\ket{\\psi}|^2 $.\nSimilarly, for either qubit, if $b_i$ is the measurement outcome, the post-measurement state of the qubit is $\\ket{b_i}$ for both qubits. Hence, the measurements are independent of the global phase $\\theta$.\n\n## Measurements as Projection Operations\n\nJust as qubits are represented by vectors and quantum gates are represented by matrices, quantum measurements are represented by orthogonal projection operators. An orthogonal projection operator is a matrix $P$ which satisfies the following property:\n$$\nP^2 = P^\\dagger = P.\n$$\n(As usual, the $\\dagger$ symbol denotes conjugate transposition.)\n\nAs the name implies, orthogonal projection operators project the state of the qubit onto an orthogonal subspace. Using the ket-bra representation, one can represent a projection matrix in the Dirac notation.\nFor example, one may construct a projector onto the $\\ket{0}$ subspace as:\n$$\nP = \\ket 0 \\bra 0 \\equiv \\begin{bmatrix} 1 & 0 \\\\\\ 0 & 0\\end{bmatrix}.\n$$\n\nA measurement in an orthogonal basis $\\{ \\ket{b_0}, \\ket{b_1}\\}$ is described by a pair of projectors $P_0 = \\ket{b_0}\\bra{b_0}$ and $P_1 = \\ket{b_1}\\bra{b_1}$. Since $\\ket{b_0}$ and $\\ket{b_1}$ are orthogonal, their projectors are also orthogonal, i.e., $P_0 P_1 = P_1 P_0 = 0$. The rules for measurements in this basis can then be summarized as follows:\n\n- Measuring a qubit in a state $\\ket \\psi$ is done by picking one of these projection operators at random.\n- Projection $P_0$ is chosen with probability $|P_0 \\ket{\\psi}|^2$, and the projector $P_1$ is chosen with probability $|P_1\\ket{\\psi}|^2.$\n- If projector $P_0$ is chosen, the post-measurement state of the qubit is given by\n$$\n\\frac1{|P_0 \\ket{\\psi}|}P_0 \\ket\\psi,\n$$\nand similarly for $P_1$.\n\nAlthough this formalism looks different from the previous sections, it is in fact equivalent. If $\\ket \\psi = c_0 \\ket{b_0} + c_1 \\ket{b_1}$, we have\n$$\nP_0 \\ket \\psi = c_0 \\ket{b_0}, \\text{so that } | P_0\\ket \\psi| = c_0,\n$$\nand similarly,\n$$\nP_1 \\ket \\psi = c_1 \\ket{b_1}, \\text{so that } |P_1\\ket \\psi| = c_1.\n$$\n\nThus, as before, the probability of measuring $b_0$ is $|P_0\\ket\\psi|^2 = |c_0|^2$, and the probability of measuring $b_1$ is $|P_1\\ket\\psi|^2 = |c_1|^2$. Similarly, one can verify that the post-measurement outcomes are also $\\ket{b_0}$ and $\\ket{b_1}$ respectively (up to unobservable global phases).\n\nAlthough the projector formalism for single-qubit systems may seem superfluous, its importance will become clear later while considering measurements for multi-qubit systems.\n\n## Arbitrary Basis Measurements Implementation\n\nIn the previous section, we discussed measurements in Pauli bases using the built-in `Measure` operation. We will now show that it is always possible to measure a qubit in any orthogonal basis using just unitary rotation matrices and computation basis measurements.\n\nConsider a state $ \\ket \\psi = c_0 \\ket {b_0} + c_1 \\ket {b_1} $ which we would like to measure in an orthonormal basis $\\{ \\ket{b_0}, \\ket{b_1}\\}$. First, we construct the following unitary matrix:\n$$\nU = \\ket{0} \\bra{b_0} + \\ket{1} \\bra{b_1}\n$$\n\nThe conjugate transpose of this unitary is the operator\n$$\nU^\\dagger = \\ket{b_0} \\bra{0} + \\ket{b_1} \\bra{1}\n$$\n\n(One may verify that $U$ is indeed a unitary matrix, by checking that $U^\\dagger U = U U^\\dagger = I$)\n\nNote that the effect of these matrices on the two bases is the following:\n$$U\\ket{b_0} = \\ket{0},$$\n$$U\\ket{b_1} = \\ket{1},$$\n$$U^\\dagger \\ket{0} = \\ket{b_0},$$\n$$U^\\dagger \\ket 1 = \\ket{b_1}.$$\n\nIn order to implement a measurement in the ${ \\ket{b_0}, \\ket{b_1} }$ basis, we do the following:\n\n1. Apply $U$ to $\\ket \\psi$. \n The resulting state is $U\\ket \\psi = c_0 \\ket 0 + c_1 \\ket 1 $.\n2. Measure the state $U\\ket{\\psi}$ in the computational basis. \n The outcomes $0$ and $1$ occur with probabilities $|c_0|^2$ and $|c_1|^2$.\n3. Apply $U^\\dagger$ to the post-measurement state. \n This transforms the states $\\ket 0$ and $\\ket 1$ to the states $\\ket{b_0}$ and $\\ket{b_1}$, respectively.\n\nThus, $b_0$ and $b_1$ are measured with probabilities $|c_0|^2$ and $|c_1|^2$, respectively, with the end state being $\\ket{b_0}$ and $\\ket{b_1}$ - which is exactly the measurement we want to implement.\n\nThis procedure can be used to distinguish arbitrary orthogonal states as well, as will become clear from the following exercises.\n\n## 🔎 Analyze\n\n**The outcome probabilities for a measurement in a specified basis**\n\n1. What are the outcome probabilities of measuring a qubit in the $\\ket{0}$ state in the Pauli X basis, i.e., the $\\{ \\ket +, \\ket -\\}$ basis?\n\n2. What are the outcome probabilities of measuring a qubit in the $0.6\\ket{0} + 0.8 \\ket{1}$ state in the Pauli Y basis, i.e., the $\\{ \\ket i, \\ket{-i}\\}$ basis?\n\n<details>\n<summary><b>Solution</b></summary>\n\n1. To find the probabilities of measuring $+$ and $-$, we first need to express the state $\\ket 0$ in terms of $\\ket +$ and $\\ket -$. Using the fact that $\\ket{\\pm} = \\frac{1}{\\sqrt{2}} (\\ket{0} \\pm \\ket{1})$, we can show that\n $$\n \\ket 0 = \\frac{1}{\\sqrt{2}} \\ket{+} + \\frac{1}{\\sqrt{2}} \\ket{-}.\n $$\n Thus, the probability of measuring $+$ is $|\\frac1{\\sqrt2}|^2 = 0.5$, and similarly, the probability of measuring $-$ is $0.5$.\n\n2. Similar to the first part, we need to express the state $\\ket \\psi = 0.6 \\ket 0 + 0.8 \\ket 1$ in the $\\ket{\\pm i}$ basis. For this calculation, we use the projection matrix approach.\n\n First, we recall that the states $\\ket{\\pm i}$ are given by\n $$\n \\ket{\\pm i} = \\frac1{\\sqrt2} (\\ket 0 \\pm i \\ket 1).\n $$\n\n We can now construct the two projectors $P_{\\pm i}$ onto states $\\ket {\\pm i}$ as follows:\n $$P_{i} = \\ket{i}\\bra{i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\\\\\ i \\end{bmatrix} \\begin{bmatrix} 1 & -i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 & -i \\\\\\\\ i & 1\\end{bmatrix},$$\n $$P_{-i} = \\ket{-i}\\bra{-i} = \\frac{1}{2} \\begin{bmatrix} 1 \\\\\\\\ -i \\end{bmatrix} \\begin{bmatrix} 1 & i \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix}1 & i \\\\\\\\ -i & 1\\end{bmatrix}.$$\n\n Recalling that the probabilities of measuring $\\pm i$ are equal to the norm of the vectors $P_{\\pm i}\\ket \\psi$, we now apply $P_{\\pm i}$ to $\\ket \\psi$:\n $$P_{+i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 & -i \\\\\\\\ i & 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\\\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 - 0.8i \\\\\\\\ 0.8 + 0.6i \\end{bmatrix},$$\n $$P_{-i} \\ket \\psi = \\frac{1}{2} \\begin{bmatrix}1 & i \\\\\\\\ -i & 1\\end{bmatrix} \\begin{bmatrix} 0.6 \\\\\\\\ 0.8 \\end{bmatrix} = \\frac{1}{2} \\begin{bmatrix} 0.6 + 0.8i \\\\\\\\ 0.8 - 0.6i \\end{bmatrix}.$$\n\n Hence, the probabilities of measuring $\\pm i$, which we denote by $p(\\pm i)$, are:\n $$p(+i) = |P_{+i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 - 0.8i|^2 + |0.8 + 0.6i|^2) = \\frac{1}{2},$$\n $$p(-i) = |P_{-i} \\ket \\psi|^2 = \\frac{1}{4}(|0.6 + 0.8i|^2 + |0.8 - 0.6i|^2) = \\frac{1}{2}.$$\n\n</details>"
1227
1227
  }
1228
1228
  ]
@@ -1357,7 +1357,7 @@ export default {
1357
1357
  "items": [
1358
1358
  {
1359
1359
  "type": "text-content",
1360
- "asHtml": "<p>There are several types of measurements you can perform on an $n$-qubit system ($n&gt;1$):</p>\n<ul>\n<li>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.</li>\n<li>Partial measurement: measuring $m$ qubits out of $n$, for $m&lt;n$ ($2^m$ possible outcomes). Partial measurements involve a partial collapse of the system&#39;s wave function, since only some of the qubits are measured.</li>\n<li>Joint measurement: measuring a joint property of all $n$ qubits ($2$ possible outcomes).</li>\n</ul>\n<p>We will discuss these concepts in the same order as in the list above.</p>\n<h2 id=\"full-measurements-measurements-in-multi-qubit-bases\">Full Measurements: Measurements in Multi-Qubit Bases</h2>\n<p>Consider a system consisting of $n\\geq1$ qubits. The wave function of such a system belongs to a vector space of dimension $2^n$. Thus, the vector space is spanned by an orthogonal basis, such as the computational basis which consists of the vectors $|0\\dotsc0\\rangle, \\dotsc, |1\\dotsc 1\\rangle$. For generality, we consider an arbitrary orthonormal basis, which we denote by ${ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle }$.</p>\n<p>Then, the state $|\\psi\\rangle$ of the multi-qubit system can be expressed as a linear combination of the $2^n$ basis vectors $|b_i\\rangle$. That is, there exist complex numbers $c_0,c_1,\\dotsc, c_{2^n-1}$ such that</p>\n<p>$$\n|\\psi\\rangle = \\sum_{i=0}^{2^n-1} c_i|b_i\\rangle \\equiv \\begin{pmatrix} c_0 \\\\ c_1 \\\\ \\vdots \\\\ c_{2^n-1} \\end{pmatrix}\n$$</p>\n<p>In line with the usual convention, we choose the wave function to be normalized, so that $|c_0|^2 + \\dotsc + |c_{2^n-1}|^2 =1$. Then, a quantum measurement in the ${ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle }$ basis satisfies the following rules:</p>\n<ul>\n<li>The measurement outcome $b_i$ occurs with probability $|c_i|^2$.</li>\n<li>Whenever the measurement outcome is $b_i$, the wave function collapses to the state $|b_i\\rangle$. That is, the post-measurement state of the system is equal to $|b_i\\rangle$.</li>\n</ul>\n<p>This can be summarized in the following table:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_i$</td>\n <td>$|c_i|^2$</td>\n <td>$\\ket{b_i}$</td>\n </tr>\n</table>\n\n<blockquote>\n<p>Similar to measurements in single-qubit systems, the assumption of normalization of the original wave function is required in order to ensure that the sum of all the outcome probabilities is 1.</p>\n</blockquote>\n<h2 id=\"multi-qubit-measurement-outcome-probabilities-i\">Multi-Qubit Measurement Outcome Probabilities I</h2>\n<p>Suppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{1}{3}\\ket {00} + \\frac{2}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>If all the qubits are measured simultaneously in the computational basis, what are the outcome probabilities?</p>\n<p>The wave function $|\\psi\\rangle$ is normalized, since $\\left(\\frac{1}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 = 1$. Hence, the probabilities of measuring each of the computational basis states is simply the square of the absolute value of the corresponding coefficients. That is, the probabilities of measuring $00$, $01$ and $11$ are $\\frac{1}{9}$, $\\frac{4}{9}$ and $\\frac{4}{9}$, respectively, and the probability of measuring the basis state $10$ that is not part of the superposition is $0$:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$00$</td>\n <td>$\\left( \\frac{1}{3}\\right)^2 = \\frac{1}{9}$</td>\n </tr> \n <tr>\n <td>$01$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n <tr>\n <td>$10$</td>\n <td>$\\left( 0\\right)^2 = 0$</td>\n </tr> \n <tr>\n <td>$11$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n</table>\n</details>\n\n<h2 id=\"multi-qubit-measurement-outcome-probabilities-ii\">Multi-Qubit Measurement Outcome Probabilities II</h2>\n<p>Suppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>If all the qubits are measured simultaneously in the Pauli X basis, that is, in the ${ \\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}}$ basis, what are the outcome probabilities?</p>\n<h3 id=\"analytical-solution\">Analytical Solution</h3>\n<p>Using the expressions $|0\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle + |-\\rangle \\big)$ and $|1\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle - |-\\rangle \\big)$, we first express $|\\psi\\rangle$ in the Pauli X basis. This gives us\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>$$= \\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]$$</p>\n<p>$$= \\frac{1}{3} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} + \\ket{-}\\big) \\big] + \\frac{1}{6} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big] + \\frac{1}{3} \\big[ \\big(\\ket{+} - \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big]$$</p>\n<p>$$= \\frac{1}{3} \\big[ \\ket{++} + \\ket{+-} + \\ket{-+} + \\ket{--} \\big] + \\frac{1}{6} \\big[ \\ket{++} - \\ket{+-} + \\ket{-+} - \\ket{--} \\big] + \\frac{1}{3} \\big[ \\ket{++} - \\ket{+-} - \\ket{-+} + \\ket{--} \\big]$$</p>\n<p>$$= (\\frac{1}{3} + \\frac{1}{6} + \\frac{1}{3})\\ket{++} + (\\frac{1}{3} - \\frac{1}{6} - \\frac{1}{3})\\ket{+-} + (\\frac{1}{3} + \\frac{1}{6} - \\frac{1}{3})\\ket{-+} + (\\frac{1}{3} - \\frac{1}{6} + \\frac{1}{3})\\ket{--}$$</p>\n<p>$$= \\frac{5}{6}\\ket{++} - \\frac{1}{6}\\ket{+-} + \\frac{1}{6}\\ket{-+} + \\frac{1}{2}\\ket{--}$$</p>\n<p>After this, the probabilities of measuring each of the four basis vectors is given by the square of the absolute value of its amplitude in the superposition:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$++$</td>\n <td>$\\left( \\frac{5}{6}\\right)^2 = \\frac{25}{36}$</td>\n </tr> \n <tr>\n <td>$+-$</td>\n <td>$\\left( -\\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr> \n <tr>\n <td>$-+$</td>\n <td>$\\left( \\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr>\n <tr>\n <td>$--$</td>\n <td>$\\left( \\frac{1}{2}\\right)^2 = \\frac{1}{4}$</td>\n </tr> \n</table>\n\n<h3 id=\"code-based-solution\">Code-Based Solution</h3>\n<p>We can also use Q# to solve this problem. It can be achieved in three steps:</p>\n<ol>\n<li>Prepare the state $\\ket \\psi$.</li>\n<li>Apply a transformation that maps the 2-qubit Pauli X basis into the 2-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits.</li>\n<li>View probabilities of each basis state with the <code>DumpMachine</code> function. Thanks to the previous step, the following state equivalence holds:</li>\n</ol>\n<table>\n <tr>\n <th>Before basis transformation</th>\n <th>After basis transformation</th>\n </tr>\n <tr>\n <td>$\\ket {++}$</td>\n <td>$\\ket {00}$</td>\n </tr> \n <tr>\n <td>$\\ket {+-}$</td>\n <td>$\\ket {01}$</td>\n </tr> \n <tr>\n <td>$\\ket {-+}$</td>\n <td>$\\ket {10}$</td>\n </tr>\n <tr>\n <td>$\\ket {--}$</td>\n <td>$\\ket {11}$</td>\n </tr> \n</table>\n\n<p>The amplitudes of the computational basis states after the transformation are the same as the amplitudes of the basis states of the Pauli X basis before the transformation!</p>\n<blockquote>\n<p>To implement the first step, we can represent $\\ket \\psi$ as<br>$$\\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}$$\nThis representation tells us how we should rotate individual qubits.</p>\n<p>Notice that we start by rotating the second qubit, as this gives a simpler implementation. If we started by rotating the first qubit, we would need to use a CNOT gate and a controlled $R_y$ gate to achieve the same result.</p>\n</blockquote>\n",
1360
+ "asHtml": "<p>There are several types of measurements you can perform on an $n$-qubit system ($n&gt;1$):</p>\n<ul>\n<li>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.</li>\n<li>Partial measurement: measuring $m$ qubits out of $n$, for $m&lt;n$ ($2^m$ possible outcomes). Partial measurements involve a partial collapse of the system&#39;s wave function, since only some of the qubits are measured.</li>\n<li>Joint measurement: measuring a joint property of all $n$ qubits ($2$ possible outcomes).</li>\n</ul>\n<p>We will discuss these concepts in the same order as in the list above.</p>\n<h2>Full Measurements: Measurements in Multi-Qubit Bases</h2>\n<p>Consider a system consisting of $n\\geq1$ qubits. The wave function of such a system belongs to a vector space of dimension $2^n$. Thus, the vector space is spanned by an orthogonal basis, such as the computational basis which consists of the vectors $|0\\dotsc0\\rangle, \\dotsc, |1\\dotsc 1\\rangle$. For generality, we consider an arbitrary orthonormal basis, which we denote by ${ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle }$.</p>\n<p>Then, the state $|\\psi\\rangle$ of the multi-qubit system can be expressed as a linear combination of the $2^n$ basis vectors $|b_i\\rangle$. That is, there exist complex numbers $c_0,c_1,\\dotsc, c_{2^n-1}$ such that</p>\n<p>$$\n|\\psi\\rangle = \\sum_{i=0}^{2^n-1} c_i|b_i\\rangle \\equiv \\begin{pmatrix} c_0 \\\\ c_1 \\\\ \\vdots \\\\ c_{2^n-1} \\end{pmatrix}\n$$</p>\n<p>In line with the usual convention, we choose the wave function to be normalized, so that $|c_0|^2 + \\dotsc + |c_{2^n-1}|^2 =1$. Then, a quantum measurement in the ${ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle }$ basis satisfies the following rules:</p>\n<ul>\n<li>The measurement outcome $b_i$ occurs with probability $|c_i|^2$.</li>\n<li>Whenever the measurement outcome is $b_i$, the wave function collapses to the state $|b_i\\rangle$. That is, the post-measurement state of the system is equal to $|b_i\\rangle$.</li>\n</ul>\n<p>This can be summarized in the following table:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_i$</td>\n <td>$|c_i|^2$</td>\n <td>$\\ket{b_i}$</td>\n </tr>\n</table>\n\n<blockquote>\n<p>Similar to measurements in single-qubit systems, the assumption of normalization of the original wave function is required in order to ensure that the sum of all the outcome probabilities is 1.</p>\n</blockquote>\n<h2>Multi-Qubit Measurement Outcome Probabilities I</h2>\n<p>Suppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{1}{3}\\ket {00} + \\frac{2}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>If all the qubits are measured simultaneously in the computational basis, what are the outcome probabilities?</p>\n<p>The wave function $|\\psi\\rangle$ is normalized, since $\\left(\\frac{1}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 = 1$. Hence, the probabilities of measuring each of the computational basis states is simply the square of the absolute value of the corresponding coefficients. That is, the probabilities of measuring $00$, $01$ and $11$ are $\\frac{1}{9}$, $\\frac{4}{9}$ and $\\frac{4}{9}$, respectively, and the probability of measuring the basis state $10$ that is not part of the superposition is $0$:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$00$</td>\n <td>$\\left( \\frac{1}{3}\\right)^2 = \\frac{1}{9}$</td>\n </tr> \n <tr>\n <td>$01$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n <tr>\n <td>$10$</td>\n <td>$\\left( 0\\right)^2 = 0$</td>\n </tr> \n <tr>\n <td>$11$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n</table>\n</details>\n\n<h2>Multi-Qubit Measurement Outcome Probabilities II</h2>\n<p>Suppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>If all the qubits are measured simultaneously in the Pauli X basis, that is, in the ${ \\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}}$ basis, what are the outcome probabilities?</p>\n<h3>Analytical Solution</h3>\n<p>Using the expressions $|0\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle + |-\\rangle \\big)$ and $|1\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle - |-\\rangle \\big)$, we first express $|\\psi\\rangle$ in the Pauli X basis. This gives us\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$</p>\n<p>$$= \\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]$$</p>\n<p>$$= \\frac{1}{3} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} + \\ket{-}\\big) \\big] + \\frac{1}{6} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big] + \\frac{1}{3} \\big[ \\big(\\ket{+} - \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big]$$</p>\n<p>$$= \\frac{1}{3} \\big[ \\ket{++} + \\ket{+-} + \\ket{-+} + \\ket{--} \\big] + \\frac{1}{6} \\big[ \\ket{++} - \\ket{+-} + \\ket{-+} - \\ket{--} \\big] + \\frac{1}{3} \\big[ \\ket{++} - \\ket{+-} - \\ket{-+} + \\ket{--} \\big]$$</p>\n<p>$$= (\\frac{1}{3} + \\frac{1}{6} + \\frac{1}{3})\\ket{++} + (\\frac{1}{3} - \\frac{1}{6} - \\frac{1}{3})\\ket{+-} + (\\frac{1}{3} + \\frac{1}{6} - \\frac{1}{3})\\ket{-+} + (\\frac{1}{3} - \\frac{1}{6} + \\frac{1}{3})\\ket{--}$$</p>\n<p>$$= \\frac{5}{6}\\ket{++} - \\frac{1}{6}\\ket{+-} + \\frac{1}{6}\\ket{-+} + \\frac{1}{2}\\ket{--}$$</p>\n<p>After this, the probabilities of measuring each of the four basis vectors is given by the square of the absolute value of its amplitude in the superposition:</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$++$</td>\n <td>$\\left( \\frac{5}{6}\\right)^2 = \\frac{25}{36}$</td>\n </tr> \n <tr>\n <td>$+-$</td>\n <td>$\\left( -\\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr> \n <tr>\n <td>$-+$</td>\n <td>$\\left( \\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr>\n <tr>\n <td>$--$</td>\n <td>$\\left( \\frac{1}{2}\\right)^2 = \\frac{1}{4}$</td>\n </tr> \n</table>\n\n<h3>Code-Based Solution</h3>\n<p>We can also use Q# to solve this problem. It can be achieved in three steps:</p>\n<ol>\n<li>Prepare the state $\\ket \\psi$.</li>\n<li>Apply a transformation that maps the 2-qubit Pauli X basis into the 2-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits.</li>\n<li>View probabilities of each basis state with the <code>DumpMachine</code> function. Thanks to the previous step, the following state equivalence holds:</li>\n</ol>\n<table>\n <tr>\n <th>Before basis transformation</th>\n <th>After basis transformation</th>\n </tr>\n <tr>\n <td>$\\ket {++}$</td>\n <td>$\\ket {00}$</td>\n </tr> \n <tr>\n <td>$\\ket {+-}$</td>\n <td>$\\ket {01}$</td>\n </tr> \n <tr>\n <td>$\\ket {-+}$</td>\n <td>$\\ket {10}$</td>\n </tr>\n <tr>\n <td>$\\ket {--}$</td>\n <td>$\\ket {11}$</td>\n </tr> \n</table>\n\n<p>The amplitudes of the computational basis states after the transformation are the same as the amplitudes of the basis states of the Pauli X basis before the transformation!</p>\n<blockquote>\n<p>To implement the first step, we can represent $\\ket \\psi$ as<br>$$\\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}$$\nThis representation tells us how we should rotate individual qubits.</p>\n<p>Notice that we start by rotating the second qubit, as this gives a simpler implementation. If we started by rotating the first qubit, we would need to use a CNOT gate and a controlled $R_y$ gate to achieve the same result.</p>\n</blockquote>\n",
1361
1361
  "asMarkdown": "\nThere are several types of measurements you can perform on an $n$-qubit system ($n>1$):\n\n- 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.\n- Partial measurement: measuring $m$ qubits out of $n$, for $m<n$ ($2^m$ possible outcomes). Partial measurements involve a partial collapse of the system's wave function, since only some of the qubits are measured.\n- Joint measurement: measuring a joint property of all $n$ qubits ($2$ possible outcomes).\n\nWe will discuss these concepts in the same order as in the list above.\n\n## Full Measurements: Measurements in Multi-Qubit Bases\n\nConsider a system consisting of $n\\geq1$ qubits. The wave function of such a system belongs to a vector space of dimension $2^n$. Thus, the vector space is spanned by an orthogonal basis, such as the computational basis which consists of the vectors $|0\\dotsc0\\rangle, \\dotsc, |1\\dotsc 1\\rangle$. For generality, we consider an arbitrary orthonormal basis, which we denote by $\\{ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle \\}$.\n\nThen, the state $|\\psi\\rangle$ of the multi-qubit system can be expressed as a linear combination of the $2^n$ basis vectors $|b_i\\rangle$. That is, there exist complex numbers $c_0,c_1,\\dotsc, c_{2^n-1}$ such that\n\n$$\n|\\psi\\rangle = \\sum_{i=0}^{2^n-1} c_i|b_i\\rangle \\equiv \\begin{pmatrix} c_0 \\\\\\ c_1 \\\\\\ \\vdots \\\\\\ c_{2^n-1} \\end{pmatrix}\n$$\n\nIn line with the usual convention, we choose the wave function to be normalized, so that $|c_0|^2 + \\dotsc + |c_{2^n-1}|^2 =1$. Then, a quantum measurement in the $\\{ |b_0\\rangle, |b_1\\rangle, \\dotsc, |b_{2^n-1}\\rangle \\}$ basis satisfies the following rules:\n\n- The measurement outcome $b_i$ occurs with probability $|c_i|^2$.\n- Whenever the measurement outcome is $b_i$, the wave function collapses to the state $|b_i\\rangle$. That is, the post-measurement state of the system is equal to $|b_i\\rangle$.\n\nThis can be summarized in the following table:\n\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>State after measurement</th>\n </tr>\n <tr>\n <td>$b_i$</td>\n <td>$|c_i|^2$</td>\n <td>$\\ket{b_i}$</td>\n </tr>\n</table>\n\n> Similar to measurements in single-qubit systems, the assumption of normalization of the original wave function is required in order to ensure that the sum of all the outcome probabilities is 1.\n\n## Multi-Qubit Measurement Outcome Probabilities I\n\nSuppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{1}{3}\\ket {00} + \\frac{2}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$\n\nIf all the qubits are measured simultaneously in the computational basis, what are the outcome probabilities?\n\nThe wave function $|\\psi\\rangle$ is normalized, since $\\left(\\frac{1}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 + \\left(\\frac{2}{3}\\right)^2 = 1$. Hence, the probabilities of measuring each of the computational basis states is simply the square of the absolute value of the corresponding coefficients. That is, the probabilities of measuring $00$, $01$ and $11$ are $\\frac{1}{9}$, $\\frac{4}{9}$ and $\\frac{4}{9}$, respectively, and the probability of measuring the basis state $10$ that is not part of the superposition is $0$:\n\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$00$</td>\n <td>$\\left( \\frac{1}{3}\\right)^2 = \\frac{1}{9}$</td>\n </tr> \n <tr>\n <td>$01$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n <tr>\n <td>$10$</td>\n <td>$\\left( 0\\right)^2 = 0$</td>\n </tr> \n <tr>\n <td>$11$</td>\n <td>$\\left( \\frac{2}{3}\\right)^2 = \\frac{4}{9}$</td>\n </tr> \n</table>\n</details>\n\n## Multi-Qubit Measurement Outcome Probabilities II\n\nSuppose that a two-qubit system is known to be in the following state:\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$\n\nIf all the qubits are measured simultaneously in the Pauli X basis, that is, in the $\\{ \\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}\\}$ basis, what are the outcome probabilities?\n\n### Analytical Solution\n\nUsing the expressions $|0\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle + |-\\rangle \\big)$ and $|1\\rangle = \\frac{1}{\\sqrt{2}} \\big( |+\\rangle - |-\\rangle \\big)$, we first express $|\\psi\\rangle$ in the Pauli X basis. This gives us\n$$\\ket \\psi = \\frac{2}{3}\\ket {00} + \\frac{1}{3} \\ket {01} + \\frac{2}{3}\\ket {11}$$\n\n$$= \\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]$$\n\n$$= \\frac{1}{3} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} + \\ket{-}\\big) \\big] + \\frac{1}{6} \\big[ \\big(\\ket{+} + \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big] + \\frac{1}{3} \\big[ \\big(\\ket{+} - \\ket{-}\\big) \\otimes \\big(\\ket{+} - \\ket{-}\\big) \\big]$$\n\n$$= \\frac{1}{3} \\big[ \\ket{++} + \\ket{+-} + \\ket{-+} + \\ket{--} \\big] + \\frac{1}{6} \\big[ \\ket{++} - \\ket{+-} + \\ket{-+} - \\ket{--} \\big] + \\frac{1}{3} \\big[ \\ket{++} - \\ket{+-} - \\ket{-+} + \\ket{--} \\big]$$\n\n$$= (\\frac{1}{3} + \\frac{1}{6} + \\frac{1}{3})\\ket{++} + (\\frac{1}{3} - \\frac{1}{6} - \\frac{1}{3})\\ket{+-} + (\\frac{1}{3} + \\frac{1}{6} - \\frac{1}{3})\\ket{-+} + (\\frac{1}{3} - \\frac{1}{6} + \\frac{1}{3})\\ket{--}$$\n\n$$= \\frac{5}{6}\\ket{++} - \\frac{1}{6}\\ket{+-} + \\frac{1}{6}\\ket{-+} + \\frac{1}{2}\\ket{--}$$\n\nAfter this, the probabilities of measuring each of the four basis vectors is given by the square of the absolute value of its amplitude in the superposition:\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n </tr>\n <tr>\n <td>$++$</td>\n <td>$\\left( \\frac{5}{6}\\right)^2 = \\frac{25}{36}$</td>\n </tr> \n <tr>\n <td>$+-$</td>\n <td>$\\left( -\\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr> \n <tr>\n <td>$-+$</td>\n <td>$\\left( \\frac{1}{6}\\right)^2 = \\frac{1}{36}$</td>\n </tr>\n <tr>\n <td>$--$</td>\n <td>$\\left( \\frac{1}{2}\\right)^2 = \\frac{1}{4}$</td>\n </tr> \n</table>\n\n### Code-Based Solution\n\nWe can also use Q# to solve this problem. It can be achieved in three steps:\n1. Prepare the state $\\ket \\psi$.\n2. Apply a transformation that maps the 2-qubit Pauli X basis into the 2-qubit computational basis. This transformation just applies a Hadamard gate to each of the qubits.\n3. View probabilities of each basis state with the `DumpMachine` function. Thanks to the previous step, the following state equivalence holds:\n\n<table>\n <tr>\n <th>Before basis transformation</th>\n <th>After basis transformation</th>\n </tr>\n <tr>\n <td>$\\ket {++}$</td>\n <td>$\\ket {00}$</td>\n </tr> \n <tr>\n <td>$\\ket {+-}$</td>\n <td>$\\ket {01}$</td>\n </tr> \n <tr>\n <td>$\\ket {-+}$</td>\n <td>$\\ket {10}$</td>\n </tr>\n <tr>\n <td>$\\ket {--}$</td>\n <td>$\\ket {11}$</td>\n </tr> \n</table>\n\nThe amplitudes of the computational basis states after the transformation are the same as the amplitudes of the basis states of the Pauli X basis before the transformation!\n\n>To implement the first step, we can represent $\\ket \\psi$ as \n>$$\\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}$$\n>This representation tells us how we should rotate individual qubits.\n>\n>Notice that we start by rotating the second qubit, as this gives a simpler implementation. If we started by rotating the first qubit, we would need to use a CNOT gate and a controlled $R_y$ gate to achieve the same result."
1362
1362
  },
1363
1363
  {
@@ -1367,7 +1367,7 @@ export default {
1367
1367
  },
1368
1368
  {
1369
1369
  "type": "text-content",
1370
- "asHtml": "<h2 id=\"measuring-each-qubit-in-a-system-sequentially\">Measuring Each Qubit in a System Sequentially</h2>\n<p>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.</p>\n<p>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$.</p>\n<p>This can be generalized to measurements in other bases, such as the 2-qubit Pauli X basis $\\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}$, and the bases for larger numbers of qubits.</p>\n<blockquote>\n<p>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.\nFor example, for the 2-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.</p>\n<p>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.\nWe will not discuss such measurements in this kata.</p>\n<p>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.</p>\n</blockquote>\n",
1370
+ "asHtml": "<h2>Measuring Each Qubit in a System Sequentially</h2>\n<p>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.</p>\n<p>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$.</p>\n<p>This can be generalized to measurements in other bases, such as the 2-qubit Pauli X basis $\\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}$, and the bases for larger numbers of qubits.</p>\n<blockquote>\n<p>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.\nFor example, for the 2-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.</p>\n<p>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.\nWe will not discuss such measurements in this kata.</p>\n<p>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.</p>\n</blockquote>\n",
1371
1371
  "asMarkdown": "\n## Measuring Each Qubit in a System Sequentially\n\nAs 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.\n\nIn 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$.\n\nThis can be generalized to measurements in other bases, such as the 2-qubit Pauli X basis $\\ket{++}, \\ket{+-}, \\ket{-+}, \\ket{--}$, and the bases for larger numbers of qubits.\n\n> 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.\nFor example, for the 2-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.\n>\n> 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.\n> We will not discuss such measurements in this kata.\n>\n> 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."
1372
1372
  }
1373
1373
  ]
@@ -1389,7 +1389,7 @@ export default {
1389
1389
  },
1390
1390
  {
1391
1391
  "type": "text-content",
1392
- "asHtml": "<h2 id=\"using-full-measurements-to-identify-the-state-of-the-system\">Using Full Measurements to Identify the State of the System</h2>\n<p>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.</p>\n",
1392
+ "asHtml": "<h2>Using Full Measurements to Identify the State of the System</h2>\n<p>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.</p>\n",
1393
1393
  "asMarkdown": "\n## Using Full Measurements to Identify the State of the System\n\nFull 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."
1394
1394
  }
1395
1395
  ]
@@ -1442,7 +1442,7 @@ export default {
1442
1442
  "items": [
1443
1443
  {
1444
1444
  "type": "text-content",
1445
- "asHtml": "<p>For a system with $n&gt;1$ qubits, it is possible to measure $m&lt;n$ qubits one after another. The number of measurement outcomes is then $2^m$ instead of $2^n$. The probabilities of each of the outcomes and the post-measurement states of the qubits can be found using the projection formalism for measurements.</p>\n<p>First, we recall the concept of projection operators introduced in the single-qubit systems measurements kata. Measurements are modeled by orthogonal projection operators - matrices that satisfy\n$$P^2 = P^\\dagger = P$$\nConsider an $n$-qubit system in a state $|\\psi\\rangle$, for which the first $m&lt;n$ qubits are measured in an orthogonal basis ${ |b_0\\rangle , |b_1\\rangle, \\dotsc, |b_{2^m-1}\\rangle}$ corresponding to the $m$ qubits being measured. Then we define $2^m$ projectors corresponding to each of the $|b_i\\rangle$ states as</p>\n<p>$$P_i = |b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m} $$</p>\n<p>where $\\mathbb{1}_{n-m}$ is the identity operator over the remaining $(n-m)$ qubits.</p>\n<p>The symbol $\\otimes$ represents the tensor product or the Kronecker product of two matrices. It is different from the usual matrix multiplication.\nIn the current context, $|b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m}$ simply means that </p>\n<ul>\n<li>The operator $|b_i\\rangle \\langle b_i|$ acts only on the $m$ qubits being measured.</li>\n<li>The effect of $P_i$ on the remaining qubits is $\\mathbb{1}_{n-m} $, i.e., the identity operator.</li>\n</ul>\n<p>Analogous to the case for measurements for single-qubit systems, the rules for partial measurement probabilities and outcomes can be summarized as follows:</p>\n<ul>\n<li>When a measurement is done, one of these projectors is chosen randomly. The probability of choosing projector $P_i$ is $\\big|P_i|\\psi\\rangle\\big|^2$.</li>\n<li>If the projector $P_i$ is chosen, the measurement outcome is $b_i$, and the state of the system after the measurement is given by\n$$\n\\frac{P_i |\\psi\\rangle}{\\big|P_i |\\psi\\rangle\\big|}.\n$$</li>\n</ul>\n<p>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:\n$$P_0 = \\ket 0\\bra 0 \\otimes \\mathbb{1}$$\n$$P_1 = \\ket 1 \\bra 1 \\otimes \\mathbb{1}$$</p>\n<p>The action of $P_0$ on $\\ket \\psi$ is</p>\n<p>$$P_0 \\ket \\psi$$</p>\n<p>$$= \\left(\\ket 0\\bra 0 \\otimes \\mathbb{1}\\right) \\frac{1}{\\sqrt 2}\\big(\\ket{01} - \\ket{10}\\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt 2} \\big( \\ket 0\\bra 0 0\\rangle \\otimes \\mathbb{1} \\ket{1} - \\ket 0 \\bra 0 1\\rangle \\otimes \\mathbb{1} \\ket 0 \\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt 2} \\ket{01}$$</p>\n<p>Similarly, we obtain\n$$P_1 \\ket\\psi = -\\frac{1}{\\sqrt 2} \\ket{10}$$</p>\n<p>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.</p>\n<blockquote>\n<p>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.</p>\n</blockquote>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p><strong>Partial measurement probabilities for the Hardy state</strong></p>\n<p>Consider a 2-qubit system in the state $\\ket \\psi = \\frac{1}{\\sqrt{12}} \\big(3|00\\rangle + |01\\rangle + |10\\rangle + |11\\rangle\\big)$.</p>\n<p>If only the first qubit is measured in the computational basis, what are the probabilities of the outcomes, and the post-measurement states of the system?</p>\n<details>\n<summary><b>Solution</b></summary>\nA measurement outcome of $0$ on the first qubit corresponds to the projection operator $P_0 = |0\\rangle\\langle 0| \\otimes \\mathbb{1}$. Applying it to the state $\\ket \\psi$ gives us \n$$\\big|P_0 \\ket{\\psi}\\big|^2 = \\big|\\frac{1}{\\sqrt{12}} \\left(3\\ket {00} + \\ket{01}\\right) \\big|^2 = \\frac{5}{6}$$\nand \n$$\\frac{P_0 \\ket{\\psi}}{\\big|P_0 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$$\n\n<p>Similarly, $P_1 = |1\\rangle \\langle 1 | \\otimes \\mathbb{1}$ is the projector corresponding to a measurement outcome of $1$ on the first qubit. Applying $P_1$ on $\\ket{\\psi}$ gives us $\\big|P_1 \\ket{\\psi}\\big|^2 = \\frac{1}{6}$ and </p>\n<p>$$\\frac{P_1 \\ket{\\psi}}{\\big|P_1 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$$</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>Post-measurement state</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$\\frac{5}{6}$</td>\n <td>$\\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$</td>\n </tr> \n <tr>\n <td>$1$</td>\n <td>$\\frac{1}{6}$</td>\n <td>$\\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$</td>\n </tr> \n</table>\n</details>",
1445
+ "asHtml": "<p>For a system with $n&gt;1$ qubits, it is possible to measure $m&lt;n$ qubits one after another. The number of measurement outcomes is then $2^m$ instead of $2^n$. The probabilities of each of the outcomes and the post-measurement states of the qubits can be found using the projection formalism for measurements.</p>\n<p>First, we recall the concept of projection operators introduced in the single-qubit systems measurements kata. Measurements are modeled by orthogonal projection operators - matrices that satisfy\n$$P^2 = P^\\dagger = P$$\nConsider an $n$-qubit system in a state $|\\psi\\rangle$, for which the first $m&lt;n$ qubits are measured in an orthogonal basis ${ |b_0\\rangle , |b_1\\rangle, \\dotsc, |b_{2^m-1}\\rangle}$ corresponding to the $m$ qubits being measured. Then we define $2^m$ projectors corresponding to each of the $|b_i\\rangle$ states as</p>\n<p>$$P_i = |b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m} $$</p>\n<p>where $\\mathbb{1}_{n-m}$ is the identity operator over the remaining $(n-m)$ qubits.</p>\n<p>The symbol $\\otimes$ represents the tensor product or the Kronecker product of two matrices. It is different from the usual matrix multiplication.\nIn the current context, $|b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m}$ simply means that </p>\n<ul>\n<li>The operator $|b_i\\rangle \\langle b_i|$ acts only on the $m$ qubits being measured.</li>\n<li>The effect of $P_i$ on the remaining qubits is $\\mathbb{1}_{n-m} $, i.e., the identity operator.</li>\n</ul>\n<p>Analogous to the case for measurements for single-qubit systems, the rules for partial measurement probabilities and outcomes can be summarized as follows:</p>\n<ul>\n<li>When a measurement is done, one of these projectors is chosen randomly. The probability of choosing projector $P_i$ is $\\big|P_i|\\psi\\rangle\\big|^2$.</li>\n<li>If the projector $P_i$ is chosen, the measurement outcome is $b_i$, and the state of the system after the measurement is given by\n$$\n\\frac{P_i |\\psi\\rangle}{\\big|P_i |\\psi\\rangle\\big|}.\n$$</li>\n</ul>\n<p>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:\n$$P_0 = \\ket 0\\bra 0 \\otimes \\mathbb{1}$$\n$$P_1 = \\ket 1 \\bra 1 \\otimes \\mathbb{1}$$</p>\n<p>The action of $P_0$ on $\\ket \\psi$ is</p>\n<p>$$P_0 \\ket \\psi$$</p>\n<p>$$= \\left(\\ket 0\\bra 0 \\otimes \\mathbb{1}\\right) \\frac{1}{\\sqrt 2}\\big(\\ket{01} - \\ket{10}\\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt 2} \\big( \\ket 0\\bra 0 0\\rangle \\otimes \\mathbb{1} \\ket{1} - \\ket 0 \\bra 0 1\\rangle \\otimes \\mathbb{1} \\ket 0 \\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt 2} \\ket{01}$$</p>\n<p>Similarly, we obtain\n$$P_1 \\ket\\psi = -\\frac{1}{\\sqrt 2} \\ket{10}$$</p>\n<p>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.</p>\n<blockquote>\n<p>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.</p>\n</blockquote>\n<h2>🔎 Analyze</h2>\n<p><strong>Partial measurement probabilities for the Hardy state</strong></p>\n<p>Consider a 2-qubit system in the state $\\ket \\psi = \\frac{1}{\\sqrt{12}} \\big(3|00\\rangle + |01\\rangle + |10\\rangle + |11\\rangle\\big)$.</p>\n<p>If only the first qubit is measured in the computational basis, what are the probabilities of the outcomes, and the post-measurement states of the system?</p>\n<details>\n<summary><b>Solution</b></summary>\nA measurement outcome of $0$ on the first qubit corresponds to the projection operator $P_0 = |0\\rangle\\langle 0| \\otimes \\mathbb{1}$. Applying it to the state $\\ket \\psi$ gives us \n$$\\big|P_0 \\ket{\\psi}\\big|^2 = \\big|\\frac{1}{\\sqrt{12}} \\left(3\\ket {00} + \\ket{01}\\right) \\big|^2 = \\frac{5}{6}$$\nand \n$$\\frac{P_0 \\ket{\\psi}}{\\big|P_0 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$$\n\n<p>Similarly, $P_1 = |1\\rangle \\langle 1 | \\otimes \\mathbb{1}$ is the projector corresponding to a measurement outcome of $1$ on the first qubit. Applying $P_1$ on $\\ket{\\psi}$ gives us $\\big|P_1 \\ket{\\psi}\\big|^2 = \\frac{1}{6}$ and </p>\n<p>$$\\frac{P_1 \\ket{\\psi}}{\\big|P_1 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$$</p>\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>Post-measurement state</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$\\frac{5}{6}$</td>\n <td>$\\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$</td>\n </tr> \n <tr>\n <td>$1$</td>\n <td>$\\frac{1}{6}$</td>\n <td>$\\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$</td>\n </tr> \n</table>\n</details>",
1446
1446
  "asMarkdown": "\nFor a system with $n>1$ qubits, it is possible to measure $m<n$ qubits one after another. The number of measurement outcomes is then $2^m$ instead of $2^n$. The probabilities of each of the outcomes and the post-measurement states of the qubits can be found using the projection formalism for measurements.\n\nFirst, we recall the concept of projection operators introduced in the single-qubit systems measurements kata. Measurements are modeled by orthogonal projection operators - matrices that satisfy\n$$P^2 = P^\\dagger = P$$\nConsider an $n$-qubit system in a state $|\\psi\\rangle$, for which the first $m<n$ qubits are measured in an orthogonal basis $\\{ |b_0\\rangle , |b_1\\rangle, \\dotsc, |b_{2^m-1}\\rangle\\}$ corresponding to the $m$ qubits being measured. Then we define $2^m$ projectors corresponding to each of the $|b_i\\rangle$ states as\n\n$$P_i = |b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m} $$\n\nwhere $\\mathbb{1}_{n-m}$ is the identity operator over the remaining $(n-m)$ qubits.\n\nThe symbol $\\otimes$ represents the tensor product or the Kronecker product of two matrices. It is different from the usual matrix multiplication.\nIn the current context, $|b_i\\rangle \\langle b_i| \\otimes \\mathbb{1}_{n-m}$ simply means that \n- The operator $|b_i\\rangle \\langle b_i|$ acts only on the $m$ qubits being measured.\n- The effect of $P_i$ on the remaining qubits is $\\mathbb{1}_{n-m} $, i.e., the identity operator.\n\nAnalogous to the case for measurements for single-qubit systems, the rules for partial measurement probabilities and outcomes can be summarized as follows:\n- When a measurement is done, one of these projectors is chosen randomly. The probability of choosing projector $P_i$ is $\\big|P_i|\\psi\\rangle\\big|^2$.\n- If the projector $P_i$ is chosen, the measurement outcome is $b_i$, and the state of the system after the measurement is given by\n$$\n\\frac{P_i |\\psi\\rangle}{\\big|P_i |\\psi\\rangle\\big|}.\n$$\n\nFor 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:\n$$P_0 = \\ket 0\\bra 0 \\otimes \\mathbb{1}$$\n$$P_1 = \\ket 1 \\bra 1 \\otimes \\mathbb{1}$$\n\nThe action of $P_0$ on $\\ket \\psi$ is\n\n$$P_0 \\ket \\psi$$\n\n$$= \\left(\\ket 0\\bra 0 \\otimes \\mathbb{1}\\right) \\frac{1}{\\sqrt 2}\\big(\\ket{01} - \\ket{10}\\big)$$\n\n$$= \\frac{1}{\\sqrt 2} \\big( \\ket 0\\bra 0 0\\rangle \\otimes \\mathbb{1} \\ket{1} - \\ket 0 \\bra 0 1\\rangle \\otimes \\mathbb{1} \\ket 0 \\big)$$\n\n$$= \\frac{1}{\\sqrt 2} \\ket{01}$$\n\nSimilarly, we obtain\n$$P_1 \\ket\\psi = -\\frac{1}{\\sqrt 2} \\ket{10}$$\n\nClearly, 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.\n\n> 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.\n\n## 🔎 Analyze\n\n**Partial measurement probabilities for the Hardy state**\n\nConsider a 2-qubit system in the state $\\ket \\psi = \\frac{1}{\\sqrt{12}} \\big(3|00\\rangle + |01\\rangle + |10\\rangle + |11\\rangle\\big)$.\n\nIf only the first qubit is measured in the computational basis, what are the probabilities of the outcomes, and the post-measurement states of the system?\n\n<details>\n<summary><b>Solution</b></summary>\nA measurement outcome of $0$ on the first qubit corresponds to the projection operator $P_0 = |0\\rangle\\langle 0| \\otimes \\mathbb{1}$. Applying it to the state $\\ket \\psi$ gives us \n$$\\big|P_0 \\ket{\\psi}\\big|^2 = \\big|\\frac{1}{\\sqrt{12}} \\left(3\\ket {00} + \\ket{01}\\right) \\big|^2 = \\frac{5}{6}$$\nand \n$$\\frac{P_0 \\ket{\\psi}}{\\big|P_0 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$$\n\nSimilarly, $P_1 = |1\\rangle \\langle 1 | \\otimes \\mathbb{1}$ is the projector corresponding to a measurement outcome of $1$ on the first qubit. Applying $P_1$ on $\\ket{\\psi}$ gives us $\\big|P_1 \\ket{\\psi}\\big|^2 = \\frac{1}{6}$ and \n\n$$\\frac{P_1 \\ket{\\psi}}{\\big|P_1 \\ket{\\psi}\\big|} = \\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$$\n\n<table>\n <tr>\n <th>Measurement outcome</th>\n <th>Probability of outcome</th>\n <th>Post-measurement state</th>\n </tr>\n <tr>\n <td>$0$</td>\n <td>$\\frac{5}{6}$</td>\n <td>$\\frac{1}{\\sqrt{10}} \\left( 3\\ket{00} + \\ket{01}\\right)$</td>\n </tr> \n <tr>\n <td>$1$</td>\n <td>$\\frac{1}{6}$</td>\n <td>$\\frac{1}{\\sqrt{2}} \\left(\\ket{10} + \\ket{11}\\right)$</td>\n </tr> \n</table>\n</details>"
1447
1447
  }
1448
1448
  ]
@@ -1464,7 +1464,7 @@ export default {
1464
1464
  },
1465
1465
  {
1466
1466
  "type": "text-content",
1467
- "asHtml": "<h2 id=\"using-partial-measurements-to-identify-the-state-of-the-system\">Using Partial Measurements to Identify the State of the System</h2>\n<p>In certain situations, it is possible to distinguish between orthogonal states of multi-qubit systems using partial measurements, as illustrated in the next exercise.</p>\n",
1467
+ "asHtml": "<h2>Using Partial Measurements to Identify the State of the System</h2>\n<p>In certain situations, it is possible to distinguish between orthogonal states of multi-qubit systems using partial measurements, as illustrated in the next exercise.</p>\n",
1468
1468
  "asMarkdown": "\n## Using Partial Measurements to Identify the State of the System\n\nIn certain situations, it is possible to distinguish between orthogonal states of multi-qubit systems using partial measurements, as illustrated in the next exercise."
1469
1469
  }
1470
1470
  ]
@@ -1507,7 +1507,7 @@ export default {
1507
1507
  "items": [
1508
1508
  {
1509
1509
  "type": "text-content",
1510
- "asHtml": "<p>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.</p>\n<blockquote>\n<p>It is useful to revisit the concepts of entanglement and separable states, which were introduced in the kata on multi-qubit systems. Consider a system of $n&gt;1$ number of 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:\n$$\n\\ket \\psi = \\ket {\\phi_A} \\otimes \\ket{\\phi_B}\n$$\nwhere $\\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.</p>\n</blockquote>\n<p>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</p>\n<p>$$\\ket{\\psi}_{i} \\equiv \\frac{P_i \\ket{\\psi}}{\\big|P_i \\ket{\\psi}\\big|}$$</p>\n<p>$$= \\frac{\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}\\big|}$$</p>\n<p>$$= \\frac{\\bra{b_i}\\phi_A\\rangle \\cdot \\ket{b_i} \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\big| \\cdot \\bra{b_i}\\phi_A\\rangle \\cdot \\big| \\ket {\\phi_B}\\big|}$$</p>\n<p>$$= \\ket{b_i} \\otimes \\ket{\\phi_B}$$</p>\n<p>Thus, the state of subsystem $B$ after the measurement is $\\ket{\\phi_B}$ independently of the outcome $i$ of the measurement on the first qubit. The results of a subsequent measurement on subsystem $B$, including outcome probabilities, will be independent of the result of the first measurement. In other words, the outcomes of the two measurements will be uncorrelated.</p>\n<p>On the other hand, if the system is entangled, then the measurement outcomes will be correlated, in a manner dictated by the bases chosen for the measurements on the two subsystems. The following exercise illustrates this phenomenon.</p>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p><strong>Sequential measurements on an entangled state and a separable state</strong></p>\n<p>Consider two two-qubit states:</p>\n<ul>\n<li>The Bell state $|\\Phi^{+}\\rangle = \\frac{1}{\\sqrt{2}} \\big (|00\\rangle + |11\\rangle\\big)$.</li>\n<li>A state $\\ket \\Theta = \\frac{1}{2} \\big( \\ket{00} + \\ket{01} + \\ket{10} + \\ket{11} \\big)$.</li>\n</ul>\n<p>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. </p>\n<details>\n<summary><b>Solution</b></summary>\n<p><b>The Bell state</b>: If the measurement outcome on the first qubit is $0$, a subsequent measurement on the second qubit *always* results in an outcome of $0$, with probability $1$. Similarly, if the measurement outcome on the first qubit is $1$, then the second qubit measurement always results in $1$. Thus, sequential measurements are perfectly *correlated*.</p>\n\n<p><b>Separable state $\\ket \\theta$</b>: Irrespective of whether the first qubit measurement outcome is $0$ of $1$ (each of which occurs with a probability of $0.5$), a subsequent measurement on the second qubit results in an outcome of $0$ or $1$ (both with a probability of $0.5$). Thus, sequential measurements are perfectly <b>uncorrelated</b>.</p>\n\n<p>This aligns with the fact that the Bell state is entangled, while the $\\ket{\\theta}$ is separable and can be expressed as $\\ket \\theta = \\ket + \\otimes \\ket +$.</p>\n</details>\n\n<h2 id=\"state-modification-using-partial-measurements\">State Modification Using Partial Measurements</h2>\n<p>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.</p>\n",
1510
+ "asHtml": "<p>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.</p>\n<blockquote>\n<p>It is useful to revisit the concepts of entanglement and separable states, which were introduced in the kata on multi-qubit systems. Consider a system of $n&gt;1$ number of 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:\n$$\n\\ket \\psi = \\ket {\\phi_A} \\otimes \\ket{\\phi_B}\n$$\nwhere $\\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.</p>\n</blockquote>\n<p>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</p>\n<p>$$\\ket{\\psi}_{i} \\equiv \\frac{P_i \\ket{\\psi}}{\\big|P_i \\ket{\\psi}\\big|}$$</p>\n<p>$$= \\frac{\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}\\big|}$$</p>\n<p>$$= \\frac{\\bra{b_i}\\phi_A\\rangle \\cdot \\ket{b_i} \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\big| \\cdot \\bra{b_i}\\phi_A\\rangle \\cdot \\big| \\ket {\\phi_B}\\big|}$$</p>\n<p>$$= \\ket{b_i} \\otimes \\ket{\\phi_B}$$</p>\n<p>Thus, the state of subsystem $B$ after the measurement is $\\ket{\\phi_B}$ independently of the outcome $i$ of the measurement on the first qubit. The results of a subsequent measurement on subsystem $B$, including outcome probabilities, will be independent of the result of the first measurement. In other words, the outcomes of the two measurements will be uncorrelated.</p>\n<p>On the other hand, if the system is entangled, then the measurement outcomes will be correlated, in a manner dictated by the bases chosen for the measurements on the two subsystems. The following exercise illustrates this phenomenon.</p>\n<h2>🔎 Analyze</h2>\n<p><strong>Sequential measurements on an entangled state and a separable state</strong></p>\n<p>Consider two two-qubit states:</p>\n<ul>\n<li>The Bell state $|\\Phi^{+}\\rangle = \\frac{1}{\\sqrt{2}} \\big (|00\\rangle + |11\\rangle\\big)$.</li>\n<li>A state $\\ket \\Theta = \\frac{1}{2} \\big( \\ket{00} + \\ket{01} + \\ket{10} + \\ket{11} \\big)$.</li>\n</ul>\n<p>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. </p>\n<details>\n<summary><b>Solution</b></summary>\n<p><b>The Bell state</b>: If the measurement outcome on the first qubit is $0$, a subsequent measurement on the second qubit *always* results in an outcome of $0$, with probability $1$. Similarly, if the measurement outcome on the first qubit is $1$, then the second qubit measurement always results in $1$. Thus, sequential measurements are perfectly *correlated*.</p>\n\n<p><b>Separable state $\\ket \\theta$</b>: Irrespective of whether the first qubit measurement outcome is $0$ of $1$ (each of which occurs with a probability of $0.5$), a subsequent measurement on the second qubit results in an outcome of $0$ or $1$ (both with a probability of $0.5$). Thus, sequential measurements are perfectly <b>uncorrelated</b>.</p>\n\n<p>This aligns with the fact that the Bell state is entangled, while the $\\ket{\\theta}$ is separable and can be expressed as $\\ket \\theta = \\ket + \\otimes \\ket +$.</p>\n</details>\n\n<h2>State Modification Using Partial Measurements</h2>\n<p>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.</p>\n",
1511
1511
  "asMarkdown": "\nEntanglement 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.\n\n> It is useful to revisit the concepts of entanglement and separable states, which were introduced in the kata on multi-qubit systems. Consider a system of $n>1$ number of 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:\n$$\n\\ket \\psi = \\ket {\\phi_A} \\otimes \\ket{\\phi_B}\n$$\nwhere $\\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.\n\nConsider 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\n\n$$\\ket{\\psi}_{i} \\equiv \\frac{P_i \\ket{\\psi}}{\\big|P_i \\ket{\\psi}\\big|}$$\n\n$$= \\frac{\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\bra{b_i}\\phi_A\\rangle \\otimes \\ket {\\phi_B}\\big|}$$\n\n$$= \\frac{\\bra{b_i}\\phi_A\\rangle \\cdot \\ket{b_i} \\otimes \\ket {\\phi_B}}{\\big|\\ket{b_i}\\big| \\cdot \\bra{b_i}\\phi_A\\rangle \\cdot \\big| \\ket {\\phi_B}\\big|}$$\n\n$$= \\ket{b_i} \\otimes \\ket{\\phi_B}$$\n\nThus, the state of subsystem $B$ after the measurement is $\\ket{\\phi_B}$ independently of the outcome $i$ of the measurement on the first qubit. The results of a subsequent measurement on subsystem $B$, including outcome probabilities, will be independent of the result of the first measurement. In other words, the outcomes of the two measurements will be uncorrelated.\n\nOn the other hand, if the system is entangled, then the measurement outcomes will be correlated, in a manner dictated by the bases chosen for the measurements on the two subsystems. The following exercise illustrates this phenomenon.\n\n## 🔎 Analyze\n\n**Sequential measurements on an entangled state and a separable state**\n\nConsider two two-qubit states:\n- The Bell state $|\\Phi^{+}\\rangle = \\frac{1}{\\sqrt{2}} \\big (|00\\rangle + |11\\rangle\\big)$.\n- A state $\\ket \\Theta = \\frac{1}{2} \\big( \\ket{00} + \\ket{01} + \\ket{10} + \\ket{11} \\big)$.\n\nFor 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. \n\n<details>\n<summary><b>Solution</b></summary>\n<p><b>The Bell state</b>: If the measurement outcome on the first qubit is $0$, a subsequent measurement on the second qubit *always* results in an outcome of $0$, with probability $1$. Similarly, if the measurement outcome on the first qubit is $1$, then the second qubit measurement always results in $1$. Thus, sequential measurements are perfectly *correlated*.</p>\n\n<p><b>Separable state $\\ket \\theta$</b>: Irrespective of whether the first qubit measurement outcome is $0$ of $1$ (each of which occurs with a probability of $0.5$), a subsequent measurement on the second qubit results in an outcome of $0$ or $1$ (both with a probability of $0.5$). Thus, sequential measurements are perfectly <b>uncorrelated</b>.</p>\n\n<p>This aligns with the fact that the Bell state is entangled, while the $\\ket{\\theta}$ is separable and can be expressed as $\\ket \\theta = \\ket + \\otimes \\ket +$.</p>\n</details>\n\n## State Modification Using Partial Measurements\n\nFor 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."
1512
1512
  }
1513
1513
  ]
@@ -1593,7 +1593,7 @@ export default {
1593
1593
  "items": [
1594
1594
  {
1595
1595
  "type": "text-content",
1596
- "asHtml": "<p>Joint measurements, also known as Pauli measurements, are a generalization of 2-outcome measurements to multiple qubits and other bases. In Q#, joint measurements in Pauli bases are implemented using the <a href=\"https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.measure\" target=\"_blank\"><code>Measure</code></a> operation. Let&#39;s review single-qubit measurements in a different light before discussing joint measurements.</p>\n<h2 id=\"single-qubit-pauli-measurement\">Single-Qubit Pauli Measurement</h2>\n<p>For single-qubit systems, any measurement corresponding to an orthogonal basis can be associated with a Hermitian matrix with eigenvalues $\\pm 1$. The possible measurement outcomes (represented as <code>Result</code> in Q#) are the eigenvalues of the Hermitian matrix, and the corresponding projection matrices for the measurement are the projection operators onto the <em>eigenspaces</em> corresponding to the eigenvalues.</p>\n<p>For example, consider the computational basis measurement, which can result in outcomes <code>Zero</code> or <code>One</code> corresponding to states $\\ket 0$ and $\\ket 1$. This measurement is associated with the Pauli Z operator, which is given by</p>\n<p>$$Z = \\begin{pmatrix} 1 &amp; 0 \\\\ 0 &amp; -1\\end{pmatrix} = \\ket{0}\\bra{0} - \\ket{1}\\bra{1}$$</p>\n<p>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 <code>Result</code> of <code>Zero</code>, while an eigenvalue of $-1$ corresponds to a <code>Result</code> of <code>One</code>.</p>\n<p>Similarly, one can implement measurements corresponding to the Pauli X and Y operators. We summarize the various properties below:</p>\n<table>\n <tr>\n <th>Pauli Operator</th>\n <th>Matrix</th>\n <th>Eigenvalue</th>\n <th>Eigenvector/post-measurement state</th>\n <th>Measurement Result in Q#</th>\n </tr>\n <tr>\n <td rowspan=\"2\">$X$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{+}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Y$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & -i \\\\ i & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{i}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-i}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Z$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{0}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{1}$</td>\n <td>One</td>\n </tr>\n</table>\n\n<p>In general, any measurement on a single qubit which results in two outcomes corresponds to the Hermitian operator $U Z U^\\dagger$, for some $2\\times 2$ unitary matrix $U$.</p>\n<p>Joint measurements are a generalization of this principle for multi-qubit matrices.</p>\n<h2 id=\"parity-measurements\">Parity Measurements</h2>\n<p>The simplest joint measurement is a parity measurement. A parity measurement treats computational basis vectors differently depending on whether the number of 1&#39;s in the basis vector is even or odd.</p>\n<p>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 ${ |00\\rangle, |11\\rangle }$ and ${ |01\\rangle, |10\\rangle }$, respectively. That is, when a $ZZ$ measurement results in a <code>Zero</code> (i.e. the eigenvalue $+1$), the post-measurement state is a superposition of only those computational basis vectors which have an even number of $1$&#39;s. On the other hand, a result of <code>One</code> corresponds to a post-measurement state with only odd parity computational basis vectors.</p>\n<p>Let&#39;s see what happens to various two-qubit states after the parity measurement. The $Z \\otimes Z$ matrix for two qubits is:</p>\n<p>$$\nZ \\otimes Z =\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n$$</p>\n<p>When this transformation is applied to a basis state $|00\\rangle$, we get</p>\n<p>$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>Comparing this to the characteristic equation for eigenvectors of $Z \\otimes Z$ given by\n$ Z \\otimes Z |\\psi\\rangle = \\lambda |\\psi\\rangle$,\nit is easy to see that $|00\\rangle$ belongs to the $+1$ eigenspace, hence the $Z \\otimes Z$ measurement will return <code>Zero</code> and leave the state unchanged.</p>\n<p>Similarly, it can easily be verified that $|11\\rangle$ also belongs to $+1$ eigenspace, while $|01\\rangle$ and $|10\\rangle$ belong to the $-1$ eigenspace.</p>\n<p>Now, what happens if we apply a $Z \\otimes Z$ measurement to a superposition state $\\alpha |00\\rangle + \\beta |11\\rangle$? We can see that</p>\n<p>$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\ 0 \\\\ 0 \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\ 0 \\\\ 0 \\\\ \\beta \\end{bmatrix}\n$$</p>\n<p>So this state also belongs to the $+1$ eigenspace, and measuring it will return <code>Zero</code> and leave the state unchanged. Similarly, we can verify that an $\\alpha |01\\rangle + \\beta |10\\rangle$ state belongs to the $-1$ eigenspace, and measuring it will return <code>One</code> without changing the state.</p>\n<p>Similarly, a parity measurement on a higher number of qubits can be implemented using a $Z \\otimes \\dotsc \\otimes Z$ measurement.</p>\n",
1596
+ "asHtml": "<p>Joint measurements, also known as Pauli measurements, are a generalization of 2-outcome measurements to multiple qubits and other bases. In Q#, joint measurements in Pauli bases are implemented using the <a href=\"https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.measure\" target=\"_blank\"><code>Measure</code></a> operation. Let&#39;s review single-qubit measurements in a different light before discussing joint measurements.</p>\n<h2>Single-Qubit Pauli Measurement</h2>\n<p>For single-qubit systems, any measurement corresponding to an orthogonal basis can be associated with a Hermitian matrix with eigenvalues $\\pm 1$. The possible measurement outcomes (represented as <code>Result</code> in Q#) are the eigenvalues of the Hermitian matrix, and the corresponding projection matrices for the measurement are the projection operators onto the <em>eigenspaces</em> corresponding to the eigenvalues.</p>\n<p>For example, consider the computational basis measurement, which can result in outcomes <code>Zero</code> or <code>One</code> corresponding to states $\\ket 0$ and $\\ket 1$. This measurement is associated with the Pauli Z operator, which is given by</p>\n<p>$$Z = \\begin{pmatrix} 1 &amp; 0 \\\\ 0 &amp; -1\\end{pmatrix} = \\ket{0}\\bra{0} - \\ket{1}\\bra{1}$$</p>\n<p>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 <code>Result</code> of <code>Zero</code>, while an eigenvalue of $-1$ corresponds to a <code>Result</code> of <code>One</code>.</p>\n<p>Similarly, one can implement measurements corresponding to the Pauli X and Y operators. We summarize the various properties below:</p>\n<table>\n <tr>\n <th>Pauli Operator</th>\n <th>Matrix</th>\n <th>Eigenvalue</th>\n <th>Eigenvector/post-measurement state</th>\n <th>Measurement Result in Q#</th>\n </tr>\n <tr>\n <td rowspan=\"2\">$X$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{+}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Y$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & -i \\\\ i & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{i}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-i}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Z$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{0}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{1}$</td>\n <td>One</td>\n </tr>\n</table>\n\n<p>In general, any measurement on a single qubit which results in two outcomes corresponds to the Hermitian operator $U Z U^\\dagger$, for some $2\\times 2$ unitary matrix $U$.</p>\n<p>Joint measurements are a generalization of this principle for multi-qubit matrices.</p>\n<h2>Parity Measurements</h2>\n<p>The simplest joint measurement is a parity measurement. A parity measurement treats computational basis vectors differently depending on whether the number of 1&#39;s in the basis vector is even or odd.</p>\n<p>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 ${ |00\\rangle, |11\\rangle }$ and ${ |01\\rangle, |10\\rangle }$, respectively. That is, when a $ZZ$ measurement results in a <code>Zero</code> (i.e. the eigenvalue $+1$), the post-measurement state is a superposition of only those computational basis vectors which have an even number of $1$&#39;s. On the other hand, a result of <code>One</code> corresponds to a post-measurement state with only odd parity computational basis vectors.</p>\n<p>Let&#39;s see what happens to various two-qubit states after the parity measurement. The $Z \\otimes Z$ matrix for two qubits is:</p>\n<p>$$\nZ \\otimes Z =\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n$$</p>\n<p>When this transformation is applied to a basis state $|00\\rangle$, we get</p>\n<p>$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}\n$$</p>\n<p>Comparing this to the characteristic equation for eigenvectors of $Z \\otimes Z$ given by\n$ Z \\otimes Z |\\psi\\rangle = \\lambda |\\psi\\rangle$,\nit is easy to see that $|00\\rangle$ belongs to the $+1$ eigenspace, hence the $Z \\otimes Z$ measurement will return <code>Zero</code> and leave the state unchanged.</p>\n<p>Similarly, it can easily be verified that $|11\\rangle$ also belongs to $+1$ eigenspace, while $|01\\rangle$ and $|10\\rangle$ belong to the $-1$ eigenspace.</p>\n<p>Now, what happens if we apply a $Z \\otimes Z$ measurement to a superposition state $\\alpha |00\\rangle + \\beta |11\\rangle$? We can see that</p>\n<p>$$\n\\begin{bmatrix}\n 1 &amp; 0 &amp; 0 &amp; 0 \\\\ \n 0 &amp; -1 &amp; 0 &amp; 0 \\\\ \n 0 &amp; 0 &amp; -1 &amp; 0 \\\\ \n 0 &amp; 0 &amp; 0 &amp; 1 \\\\ \n\\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\ 0 \\\\ 0 \\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\ 0 \\\\ 0 \\\\ \\beta \\end{bmatrix}\n$$</p>\n<p>So this state also belongs to the $+1$ eigenspace, and measuring it will return <code>Zero</code> and leave the state unchanged. Similarly, we can verify that an $\\alpha |01\\rangle + \\beta |10\\rangle$ state belongs to the $-1$ eigenspace, and measuring it will return <code>One</code> without changing the state.</p>\n<p>Similarly, a parity measurement on a higher number of qubits can be implemented using a $Z \\otimes \\dotsc \\otimes Z$ measurement.</p>\n",
1597
1597
  "asMarkdown": "\nJoint measurements, also known as Pauli measurements, are a generalization of 2-outcome measurements to multiple qubits and other bases. In Q#, joint measurements in Pauli bases are implemented using the <a href=\"https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.measure\" target=\"_blank\">`Measure`</a> operation. Let's review single-qubit measurements in a different light before discussing joint measurements.\n\n## Single-Qubit Pauli Measurement\nFor single-qubit systems, any measurement corresponding to an orthogonal basis can be associated with a Hermitian matrix with eigenvalues $\\pm 1$. The possible measurement outcomes (represented as `Result` in Q#) are the eigenvalues of the Hermitian matrix, and the corresponding projection matrices for the measurement are the projection operators onto the *eigenspaces* corresponding to the eigenvalues.\n\nFor example, consider the computational basis measurement, which can result in outcomes `Zero` or `One` corresponding to states $\\ket 0$ and $\\ket 1$. This measurement is associated with the Pauli Z operator, which is given by\n\n$$Z = \\begin{pmatrix} 1 & 0 \\\\\\ 0 & -1\\end{pmatrix} = \\ket{0}\\bra{0} - \\ket{1}\\bra{1}$$\n\nThe $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`.\n\nSimilarly, one can implement measurements corresponding to the Pauli X and Y operators. We summarize the various properties below:\n<table>\n <tr>\n <th>Pauli Operator</th>\n <th>Matrix</th>\n <th>Eigenvalue</th>\n <th>Eigenvector/post-measurement state</th>\n <th>Measurement Result in Q#</th>\n </tr>\n <tr>\n <td rowspan=\"2\">$X$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{+}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Y$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 0 & -i \\\\ i & 0 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{i}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{-i}$</td>\n <td>One</td>\n </tr>\n <tr>\n <td rowspan=\"2\">$Z$</td>\n <td rowspan=\"2\">$\\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>+1</td>\n <td>$\\ket{0}$</td>\n <td>Zero</td>\n </tr><tr>\n <td>-1</td>\n <td>$\\ket{1}$</td>\n <td>One</td>\n </tr>\n</table>\n\nIn general, any measurement on a single qubit which results in two outcomes corresponds to the Hermitian operator $U Z U^\\dagger$, for some $2\\times 2$ unitary matrix $U$.\n\nJoint measurements are a generalization of this principle for multi-qubit matrices.\n\n## Parity Measurements\nThe simplest joint measurement is a parity measurement. A parity measurement treats computational basis vectors differently depending on whether the number of 1's in the basis vector is even or odd.\n\nFor 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 $\\{ |00\\rangle, |11\\rangle \\}$ and $\\{ |01\\rangle, |10\\rangle \\}$, 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 $1$'s. On the other hand, a result of `One` corresponds to a post-measurement state with only odd parity computational basis vectors.\n\nLet's see what happens to various two-qubit states after the parity measurement. The $Z \\otimes Z$ matrix for two qubits is:\n\n$$\nZ \\otimes Z =\n\\begin{bmatrix}\n 1 & 0 & 0 & 0 \\\\\\ \n 0 & -1 & 0 & 0 \\\\\\ \n 0 & 0 & -1 & 0 \\\\\\ \n 0 & 0 & 0 & 1 \\\\\\ \n\\end{bmatrix}\n$$\n\nWhen this transformation is applied to a basis state $|00\\rangle$, we get\n\n$$\n\\begin{bmatrix}\n 1 & 0 & 0 & 0 \\\\\\ \n 0 & -1 & 0 & 0 \\\\\\ \n 0 & 0 & -1 & 0 \\\\\\ \n 0 & 0 & 0 & 1 \\\\\\ \n\\end{bmatrix}\n\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix} =\n\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}\n$$\n\nComparing this to the characteristic equation for eigenvectors of $Z \\otimes Z$ given by\n$ Z \\otimes Z |\\psi\\rangle = \\lambda |\\psi\\rangle$,\nit is easy to see that $|00\\rangle$ belongs to the $+1$ eigenspace, hence the $Z \\otimes Z$ measurement will return `Zero` and leave the state unchanged.\n\nSimilarly, it can easily be verified that $|11\\rangle$ also belongs to $+1$ eigenspace, while $|01\\rangle$ and $|10\\rangle$ belong to the $-1$ eigenspace.\n\nNow, what happens if we apply a $Z \\otimes Z$ measurement to a superposition state $\\alpha |00\\rangle + \\beta |11\\rangle$? We can see that\n\n$$\n\\begin{bmatrix}\n 1 & 0 & 0 & 0 \\\\\\ \n 0 & -1 & 0 & 0 \\\\\\ \n 0 & 0 & -1 & 0 \\\\\\ \n 0 & 0 & 0 & 1 \\\\\\ \n\\end{bmatrix}\n\\begin{bmatrix} \\alpha \\\\\\ 0 \\\\\\ 0 \\\\\\ \\beta \\end{bmatrix} =\n\\begin{bmatrix} \\alpha \\\\\\ 0 \\\\\\ 0 \\\\\\ \\beta \\end{bmatrix}\n$$\n\nSo 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 |01\\rangle + \\beta |10\\rangle$ state belongs to the $-1$ eigenspace, and measuring it will return `One` without changing the state.\n\nSimilarly, a parity measurement on a higher number of qubits can be implemented using a $Z \\otimes \\dotsc \\otimes Z$ measurement."
1598
1598
  }
1599
1599
  ]
@@ -1636,7 +1636,7 @@ export default {
1636
1636
  "items": [
1637
1637
  {
1638
1638
  "type": "text-content",
1639
- "asHtml": "<p>Joint measurement is a generalization of the measurement in the computational basis.\nPauli 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 <code>Result</code> of <code>Zero</code> corresponding to eigenvalue $+1$ and a <code>Result</code> of <code>One</code> corresponding to the eigenvalue $-1$. The corresponding projection operators are the projections onto the corresponding eigenspaces.</p>\n<p>For example, a Pauli/joint measurement corresponding to the $X\\otimes Z$ operator can be characterized as follows:</p>\n<table>\n <tr>\n <th>Eigenvalue</th>\n <th>Measurement Result in Q#</th>\n <th>Eigenbasis</th>\n <th>Measurement Projector</th>\n </tr>\n <tr>\n <td>$+1$</td>\n <td>Zero</td>\n <td>$\\{ \\ket{0,+}, \\ket{1,-} \\}$</td>\n <td>$P_{+1} = \\ket{0,+}\\bra{0,+} + \\ket{1,-} \\bra{1,-}$</td>\n </tr>\n <tr>\n <td>$-1$</td>\n <td>One</td>\n <td>$\\{ \\ket{0,-}, \\ket{1,+} \\}$</td>\n <td>$P_{-1} = \\ket{0,-}\\bra{0,-} + \\ket{1,+} \\bra{1,+}$</td>\n </tr>\n </table>\n\n<p> The rules for measurements are then the same as those outlined in the partial measurements section, with the projection operators in the table.</p>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p><strong>Parity measurement in different basis</strong></p>\n<p>Consider a system which is in a state $\\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle$.</p>\n<p>What are the possible outcomes and their associated probabilities, if a measurement in an $XX$ Pauli measurement is done?</p>\n<details>\n<summary><b>Solution</b></summary>\nThe 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\n\n<p>$$XX \\ket{++} = \\ket{++}$$\n$$XX \\ket{--} = \\ket{--}$$\n$$XX \\ket{+-} = -\\ket{+-}$$\n$$XX \\ket{-+} = -\\ket{-+}$$</p>\n<p>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 $+$&#39;s from basis states which have an odd number of $+$&#39;s.</p>\n<p>The projector corresponding to a result of <code>Zero</code> is given by $P_{+1} = \\ket{++}\\bra{++} + \\ket{--}\\bra{--}$, while the projector corresponding to a result of <code>One</code> 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 \n$$P_{+1} ( \\gamma \\ket{++} + \\delta \\ket{--} ) =$$\n$$( \\gamma \\ket{++} + \\delta \\ket{--} )P_{+1} ( \\mu \\ket{-+} + \\nu \\ket{+-} ) = 0$$</p>\n<p>Similarly, $P_{-1}$ annihilates states with even parity, while leaving states with odd parity unaffected.</p>\n<p>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:\n$$\\ket{0} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} + \\ket{-} \\right)$$\n$$\\ket{1} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} - \\ket{-} \\right)$$</p>\n<p>Using these, we obtain\n$$ \\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle = (\\alpha + \\beta) |++\\rangle + (\\alpha - \\beta) |--\\rangle$$\nThus, this state has an even parity in the Hadamard basis. It follows that an $XX$ Pauli measurement will result in the outcome <code>Zero</code> with probability 1, leaving the state unchanged after the measurement.</p>\n</details>",
1639
+ "asHtml": "<p>Joint measurement is a generalization of the measurement in the computational basis.\nPauli 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 <code>Result</code> of <code>Zero</code> corresponding to eigenvalue $+1$ and a <code>Result</code> of <code>One</code> corresponding to the eigenvalue $-1$. The corresponding projection operators are the projections onto the corresponding eigenspaces.</p>\n<p>For example, a Pauli/joint measurement corresponding to the $X\\otimes Z$ operator can be characterized as follows:</p>\n<table>\n <tr>\n <th>Eigenvalue</th>\n <th>Measurement Result in Q#</th>\n <th>Eigenbasis</th>\n <th>Measurement Projector</th>\n </tr>\n <tr>\n <td>$+1$</td>\n <td>Zero</td>\n <td>$\\{ \\ket{0,+}, \\ket{1,-} \\}$</td>\n <td>$P_{+1} = \\ket{0,+}\\bra{0,+} + \\ket{1,-} \\bra{1,-}$</td>\n </tr>\n <tr>\n <td>$-1$</td>\n <td>One</td>\n <td>$\\{ \\ket{0,-}, \\ket{1,+} \\}$</td>\n <td>$P_{-1} = \\ket{0,-}\\bra{0,-} + \\ket{1,+} \\bra{1,+}$</td>\n </tr>\n </table>\n\n<p> The rules for measurements are then the same as those outlined in the partial measurements section, with the projection operators in the table.</p>\n<h2>🔎 Analyze</h2>\n<p><strong>Parity measurement in different basis</strong></p>\n<p>Consider a system which is in a state $\\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle$.</p>\n<p>What are the possible outcomes and their associated probabilities, if a measurement in an $XX$ Pauli measurement is done?</p>\n<details>\n<summary><b>Solution</b></summary>\nThe 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\n\n<p>$$XX \\ket{++} = \\ket{++}$$\n$$XX \\ket{--} = \\ket{--}$$\n$$XX \\ket{+-} = -\\ket{+-}$$\n$$XX \\ket{-+} = -\\ket{-+}$$</p>\n<p>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 $+$&#39;s from basis states which have an odd number of $+$&#39;s.</p>\n<p>The projector corresponding to a result of <code>Zero</code> is given by $P_{+1} = \\ket{++}\\bra{++} + \\ket{--}\\bra{--}$, while the projector corresponding to a result of <code>One</code> 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 \n$$P_{+1} ( \\gamma \\ket{++} + \\delta \\ket{--} ) =$$\n$$( \\gamma \\ket{++} + \\delta \\ket{--} )P_{+1} ( \\mu \\ket{-+} + \\nu \\ket{+-} ) = 0$$</p>\n<p>Similarly, $P_{-1}$ annihilates states with even parity, while leaving states with odd parity unaffected.</p>\n<p>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:\n$$\\ket{0} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} + \\ket{-} \\right)$$\n$$\\ket{1} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} - \\ket{-} \\right)$$</p>\n<p>Using these, we obtain\n$$ \\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle = (\\alpha + \\beta) |++\\rangle + (\\alpha - \\beta) |--\\rangle$$\nThus, this state has an even parity in the Hadamard basis. It follows that an $XX$ Pauli measurement will result in the outcome <code>Zero</code> with probability 1, leaving the state unchanged after the measurement.</p>\n</details>",
1640
1640
  "asMarkdown": "\nJoint measurement is a generalization of the measurement in the computational basis.\nPauli 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.\n\nFor example, a Pauli/joint measurement corresponding to the $X\\otimes Z$ operator can be characterized as follows:\n<table>\n <tr>\n <th>Eigenvalue</th>\n <th>Measurement Result in Q#</th>\n <th>Eigenbasis</th>\n <th>Measurement Projector</th>\n </tr>\n <tr>\n <td>$+1$</td>\n <td>Zero</td>\n <td>$\\{ \\ket{0,+}, \\ket{1,-} \\}$</td>\n <td>$P_{+1} = \\ket{0,+}\\bra{0,+} + \\ket{1,-} \\bra{1,-}$</td>\n </tr>\n <tr>\n <td>$-1$</td>\n <td>One</td>\n <td>$\\{ \\ket{0,-}, \\ket{1,+} \\}$</td>\n <td>$P_{-1} = \\ket{0,-}\\bra{0,-} + \\ket{1,+} \\bra{1,+}$</td>\n </tr>\n </table>\n\n The rules for measurements are then the same as those outlined in the partial measurements section, with the projection operators in the table.\n\n## 🔎 Analyze\n\n**Parity measurement in different basis**\n\nConsider a system which is in a state $\\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle$.\n\nWhat are the possible outcomes and their associated probabilities, if a measurement in an $XX$ Pauli measurement is done?\n\n<details>\n<summary><b>Solution</b></summary>\nThe 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\n\n$$XX \\ket{++} = \\ket{++}$$\n$$XX \\ket{--} = \\ket{--}$$\n$$XX \\ket{+-} = -\\ket{+-}$$\n$$XX \\ket{-+} = -\\ket{-+}$$\n\nThus, 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.\n\nThe 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 \n$$P_{+1} ( \\gamma \\ket{++} + \\delta \\ket{--} ) =$$\n$$( \\gamma \\ket{++} + \\delta \\ket{--} )P_{+1} ( \\mu \\ket{-+} + \\nu \\ket{+-} ) = 0$$\n\nSimilarly, $P_{-1}$ annihilates states with even parity, while leaving states with odd parity unaffected.\n\nNow 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:\n$$\\ket{0} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} + \\ket{-} \\right)$$\n$$\\ket{1} = \\frac{1}{\\sqrt{2}} \\left( \\ket{+} - \\ket{-} \\right)$$\n\nUsing these, we obtain\n$$ \\alpha |00\\rangle + \\beta |01\\rangle + \\beta |10\\rangle + \\alpha |11\\rangle = (\\alpha + \\beta) |++\\rangle + (\\alpha - \\beta) |--\\rangle$$\nThus, 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.\n</details>"
1641
1641
  }
1642
1642
  ]
@@ -1913,7 +1913,7 @@ export default {
1913
1913
  "items": [
1914
1914
  {
1915
1915
  "type": "text-content",
1916
- "asHtml": "<p>An oracle in the quantum world is a &quot;black box&quot; operation that is used as input to an algorithm (such as Deutsch-Jozsa algorithm or Grover&#39;s search algorithm). \nMany quantum algorithms assume an oracle implementation of some classical function as input, but this is a very strong assumption - sometimes implementing the oracle for a function is a lot more complex than the algorithm that will use this oracle!<br>In this kata, you will learn the properties of quantum oracles and how to implement them.</p>\n<p>A quantum oracle implements a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}^m$, where the input is $n$-bits of the form $x = (x_{0}, x_{1}, \\dots, x_{n-1})$. In most commonly used cases $m=1$, that is, the function can return values $0$ or $1$. In this kata, we will focus on this class of functions.</p>\n<p>Quantum oracles operate on qubit arrays (and can take classical parameters as well). The classical input is encoded into the state of an $n$-qubit register:<br>$$|x\\rangle = |x_0\\rangle \\otimes |x_1\\rangle \\otimes ... \\otimes |x_{n-1}\\rangle,$$ \nwhere $|x_i\\rangle$ represents the state of the $i$-th qubit. </p>\n<p>Oracles must be unitary transformations, and follow the same rules of linear algebra as other quantum operations.\nThis allows us to define quantum oracles based on their effect on the basis states - tensor products of single-qubit basis states $|0\\rangle$ and $|1\\rangle$. </p>\n<blockquote>\n<p>For example, an oracle that implements a function that takes 2 bits of input will be defined using its effect on basis states $|00\\rangle$, $|01\\rangle$, $|10\\rangle$, and $|11\\rangle$. </p>\n</blockquote>\n<p>There are two types of quantum oracles: phase oracles and marking oracles. Let&#39;s take a closer look at them.</p>\n<h2 id=\"phase-oracles\">Phase Oracles</h2>\n<p>For a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}$, the phase oracle $U_{\\text{phase}}$ encodes the the values $f(0)$ and $f(1)$ in the relative phases of basis states $\\ket{0}$ and $\\ket{1}$, respectively.</p>\n<p>$$U_{phase} |\\vec{x}\\rangle = (-1)^{f(x)}|\\vec{x}\\rangle$$</p>\n<p>Thus, the phase oracle $U_{\\text{phase}}$ doesn&#39;t change the phase of the basis states for which $f(x)=0$, but multiplies the phase of the basis states for which $f(x)=1$ by $-1$.</p>\n<p>The effect of such an oracle on any single basis state is not particularly interesting: it just adds a global phase which is not something you can observe. However, if you apply this oracle to a <em>superposition</em> of basis states, its effect becomes noticeable. \nRemember that quantum operations are linear: if you define the effect of an operation on the basis states, you&#39;ll be able to deduce its effect on superposition states (which are just linear combinations of the basis states) using its linearity. </p>\n<p>A phase oracle doesn&#39;t have an &quot;output&quot;, unlike the function it implements; the effect of the oracle application is the change in the state of the system.</p>\n",
1916
+ "asHtml": "<p>An oracle in the quantum world is a &quot;black box&quot; operation that is used as input to an algorithm (such as Deutsch-Jozsa algorithm or Grover&#39;s search algorithm). \nMany quantum algorithms assume an oracle implementation of some classical function as input, but this is a very strong assumption - sometimes implementing the oracle for a function is a lot more complex than the algorithm that will use this oracle!<br>In this kata, you will learn the properties of quantum oracles and how to implement them.</p>\n<p>A quantum oracle implements a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}^m$, where the input is $n$-bits of the form $x = (x_{0}, x_{1}, \\dots, x_{n-1})$. In most commonly used cases $m=1$, that is, the function can return values $0$ or $1$. In this kata, we will focus on this class of functions.</p>\n<p>Quantum oracles operate on qubit arrays (and can take classical parameters as well). The classical input is encoded into the state of an $n$-qubit register:<br>$$|x\\rangle = |x_0\\rangle \\otimes |x_1\\rangle \\otimes ... \\otimes |x_{n-1}\\rangle,$$ \nwhere $|x_i\\rangle$ represents the state of the $i$-th qubit. </p>\n<p>Oracles must be unitary transformations, and follow the same rules of linear algebra as other quantum operations.\nThis allows us to define quantum oracles based on their effect on the basis states - tensor products of single-qubit basis states $|0\\rangle$ and $|1\\rangle$. </p>\n<blockquote>\n<p>For example, an oracle that implements a function that takes 2 bits of input will be defined using its effect on basis states $|00\\rangle$, $|01\\rangle$, $|10\\rangle$, and $|11\\rangle$. </p>\n</blockquote>\n<p>There are two types of quantum oracles: phase oracles and marking oracles. Let&#39;s take a closer look at them.</p>\n<h2>Phase Oracles</h2>\n<p>For a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}$, the phase oracle $U_{\\text{phase}}$ encodes the the values $f(0)$ and $f(1)$ in the relative phases of basis states $\\ket{0}$ and $\\ket{1}$, respectively.</p>\n<p>$$U_{phase} |\\vec{x}\\rangle = (-1)^{f(x)}|\\vec{x}\\rangle$$</p>\n<p>Thus, the phase oracle $U_{\\text{phase}}$ doesn&#39;t change the phase of the basis states for which $f(x)=0$, but multiplies the phase of the basis states for which $f(x)=1$ by $-1$.</p>\n<p>The effect of such an oracle on any single basis state is not particularly interesting: it just adds a global phase which is not something you can observe. However, if you apply this oracle to a <em>superposition</em> of basis states, its effect becomes noticeable. \nRemember that quantum operations are linear: if you define the effect of an operation on the basis states, you&#39;ll be able to deduce its effect on superposition states (which are just linear combinations of the basis states) using its linearity. </p>\n<p>A phase oracle doesn&#39;t have an &quot;output&quot;, unlike the function it implements; the effect of the oracle application is the change in the state of the system.</p>\n",
1917
1917
  "asMarkdown": "\nAn oracle in the quantum world is a \"black box\" operation that is used as input to an algorithm (such as Deutsch-Jozsa algorithm or Grover's search algorithm). \nMany quantum algorithms assume an oracle implementation of some classical function as input, but this is a very strong assumption - sometimes implementing the oracle for a function is a lot more complex than the algorithm that will use this oracle! \nIn this kata, you will learn the properties of quantum oracles and how to implement them.\n\nA quantum oracle implements a function $f: \\\\{0,1\\\\}^n \\rightarrow \\\\{0,1\\\\}^m$, where the input is $n$-bits of the form $x = (x_{0}, x_{1}, \\dots, x_{n-1})$. In most commonly used cases $m=1$, that is, the function can return values $0$ or $1$. In this kata, we will focus on this class of functions.\n\nQuantum oracles operate on qubit arrays (and can take classical parameters as well). The classical input is encoded into the state of an $n$-qubit register: \n$$|x\\rangle = |x_0\\rangle \\otimes |x_1\\rangle \\otimes ... \\otimes |x_{n-1}\\rangle,$$ \nwhere $|x_i\\rangle$ represents the state of the $i$-th qubit. \n\nOracles must be unitary transformations, and follow the same rules of linear algebra as other quantum operations.\nThis allows us to define quantum oracles based on their effect on the basis states - tensor products of single-qubit basis states $|0\\rangle$ and $|1\\rangle$. \n\n> For example, an oracle that implements a function that takes 2 bits of input will be defined using its effect on basis states $|00\\rangle$, $|01\\rangle$, $|10\\rangle$, and $|11\\rangle$. \n\nThere are two types of quantum oracles: phase oracles and marking oracles. Let's take a closer look at them.\n\n## Phase Oracles\n\nFor a function $f: \\\\{0,1\\\\}^n \\rightarrow \\\\{0,1\\\\}$, the phase oracle $U_{\\text{phase}}$ encodes the the values $f(0)$ and $f(1)$ in the relative phases of basis states $\\ket{0}$ and $\\ket{1}$, respectively.\n\n$$U_{phase} |\\vec{x}\\rangle = (-1)^{f(x)}|\\vec{x}\\rangle$$\n\nThus, the phase oracle $U_{\\text{phase}}$ doesn't change the phase of the basis states for which $f(x)=0$, but multiplies the phase of the basis states for which $f(x)=1$ by $-1$.\n\nThe effect of such an oracle on any single basis state is not particularly interesting: it just adds a global phase which is not something you can observe. However, if you apply this oracle to a *superposition* of basis states, its effect becomes noticeable. \nRemember that quantum operations are linear: if you define the effect of an operation on the basis states, you'll be able to deduce its effect on superposition states (which are just linear combinations of the basis states) using its linearity. \n\nA phase oracle doesn't have an \"output\", unlike the function it implements; the effect of the oracle application is the change in the state of the system."
1918
1918
  }
1919
1919
  ]
@@ -1978,7 +1978,7 @@ export default {
1978
1978
  "items": [
1979
1979
  {
1980
1980
  "type": "text-content",
1981
- "asHtml": "<p>A marking oracle $U_{mark}$ is an oracle that encodes the value of the classical function $f$ it implements in the <em>amplitude</em> of the qubit state. When provided an input array of qubits in the basis state $|\\vec{x}\\rangle$ and an output qubit in the basis state $|y\\rangle$, it flips the state of the output qubit if $f(x)=1$. (You can also represent this as addition modulo 2 between $f(x)$ and $y$.) Hence $U_{mark}$ is an operator that performs the following operation:</p>\n<p>$$U_{mark}|\\vec{x}\\rangle |y\\rangle = U_{mark}\\big(|\\vec{x}\\rangle \\otimes |y\\rangle\\big) = |\\vec{x}\\rangle \\otimes |y \\oplus f(x)\\rangle$$</p>\n<p>Again, since all quantum operations are linear, you can figure out the effect of this operation on superposition state knowing its effect on the basis states using its linearity. </p>\n<p>A marking oracle has distinct &quot;input&quot; and &quot;output&quot; qubits, but in general the effect of the oracle application is the change in the state of the whole system rather than of the &quot;output&quot; qubits only. We will look at this closer in a moment.</p>\n<h2 id=\"marking-oracle-for-alternating-bit-pattern-function\">Marking Oracle for Alternating Bit Pattern Function</h2>\n<p>Consider the function $f(x)$ that takes $3$ bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise (it is the same function we&#39;ve seen in the demo &quot;Phase oracle for alternating bit pattern function&quot;).</p>\n<p>The marking oracle that implements this function will take an array of 3 qubits as an &quot;input&quot; register and an &quot;output&quot; qubit, and will flip the state of the output qubit if the input qubit was in basis state $|101\\rangle$ or $|010\\rangle$, and do nothing otherwise. Let&#39;s see the effect of this oracle on a superposition state.</p>\n",
1981
+ "asHtml": "<p>A marking oracle $U_{mark}$ is an oracle that encodes the value of the classical function $f$ it implements in the <em>amplitude</em> of the qubit state. When provided an input array of qubits in the basis state $|\\vec{x}\\rangle$ and an output qubit in the basis state $|y\\rangle$, it flips the state of the output qubit if $f(x)=1$. (You can also represent this as addition modulo 2 between $f(x)$ and $y$.) Hence $U_{mark}$ is an operator that performs the following operation:</p>\n<p>$$U_{mark}|\\vec{x}\\rangle |y\\rangle = U_{mark}\\big(|\\vec{x}\\rangle \\otimes |y\\rangle\\big) = |\\vec{x}\\rangle \\otimes |y \\oplus f(x)\\rangle$$</p>\n<p>Again, since all quantum operations are linear, you can figure out the effect of this operation on superposition state knowing its effect on the basis states using its linearity. </p>\n<p>A marking oracle has distinct &quot;input&quot; and &quot;output&quot; qubits, but in general the effect of the oracle application is the change in the state of the whole system rather than of the &quot;output&quot; qubits only. We will look at this closer in a moment.</p>\n<h2>Marking Oracle for Alternating Bit Pattern Function</h2>\n<p>Consider the function $f(x)$ that takes $3$ bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise (it is the same function we&#39;ve seen in the demo &quot;Phase oracle for alternating bit pattern function&quot;).</p>\n<p>The marking oracle that implements this function will take an array of 3 qubits as an &quot;input&quot; register and an &quot;output&quot; qubit, and will flip the state of the output qubit if the input qubit was in basis state $|101\\rangle$ or $|010\\rangle$, and do nothing otherwise. Let&#39;s see the effect of this oracle on a superposition state.</p>\n",
1982
1982
  "asMarkdown": "\nA marking oracle $U_{mark}$ is an oracle that encodes the value of the classical function $f$ it implements in the *amplitude* of the qubit state. When provided an input array of qubits in the basis state $|\\vec{x}\\rangle$ and an output qubit in the basis state $|y\\rangle$, it flips the state of the output qubit if $f(x)=1$. (You can also represent this as addition modulo 2 between $f(x)$ and $y$.) Hence $U_{mark}$ is an operator that performs the following operation:\n\n$$U_{mark}|\\vec{x}\\rangle |y\\rangle = U_{mark}\\big(|\\vec{x}\\rangle \\otimes |y\\rangle\\big) = |\\vec{x}\\rangle \\otimes |y \\oplus f(x)\\rangle$$\n\nAgain, since all quantum operations are linear, you can figure out the effect of this operation on superposition state knowing its effect on the basis states using its linearity. \n\nA marking oracle has distinct \"input\" and \"output\" qubits, but in general the effect of the oracle application is the change in the state of the whole system rather than of the \"output\" qubits only. We will look at this closer in a moment.\n\n## Marking Oracle for Alternating Bit Pattern Function\n\nConsider the function $f(x)$ that takes $3$ bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise (it is the same function we've seen in the demo \"Phase oracle for alternating bit pattern function\").\n\nThe marking oracle that implements this function will take an array of 3 qubits as an \"input\" register and an \"output\" qubit, and will flip the state of the output qubit if the input qubit was in basis state $|101\\rangle$ or $|010\\rangle$, and do nothing otherwise. Let's see the effect of this oracle on a superposition state."
1983
1983
  },
1984
1984
  {
@@ -2031,7 +2031,7 @@ export default {
2031
2031
  "items": [
2032
2032
  {
2033
2033
  "type": "text-content",
2034
- "asHtml": "<p>Previously we considered applying marking oracles when the register $|x\\rangle$ was in a basis state or a superposition state, and the target qubit $|y\\rangle$ in a basis state. How might the effect of applying marking oracles change if the target is also in a superposition state? In this case we will observe <strong>phase kickback</strong> - the relative phase from the target qubit affecting (&quot;kicked back&quot; into) the state of the input qubits.</p>\n<p>In order to observe phase kickback, we use the target qubit $|y\\rangle=|-\\rangle$.</p>\n<blockquote>\n<p>This is the standard choice for two reasons. \nFirst, for phase kickback to occur, the target qubit must have a difference in relative phase between the basis states $|0\\rangle$ and $|1\\rangle$. \nSecond, the target qubit must be in an equal superposition, otherwise it will become entangled with the input register.</p>\n</blockquote>\n<p>Let&#39;s see the results of applying a marking oracle $U_{mark}$ which implements the function $f(x)$ to the input register $|x\\rangle$ and the target qubit in state $|-\\rangle$:</p>\n<ul>\n<li>If the input register $|x\\rangle$ is in a basis state:</li>\n</ul>\n<p>$$U_{mark} |x\\rangle |-\\rangle = \\frac1{\\sqrt2} \\big(U_{mark}|x\\rangle|0\\rangle - U_{mark}|x\\rangle |1\\rangle\\big)$$</p>\n<p>$$= \\frac1{\\sqrt2} \\big(|x\\rangle|0\\oplus f(x)\\rangle - |x\\rangle |1\\oplus f(x)\\rangle\\big)$$</p>\n<p>$$= \n\\begin{cases} \n\\frac1{\\sqrt2} \\big(|x\\rangle|0\\rangle - |x\\rangle |1\\rangle\\big) = |x\\rangle|-\\rangle \\text{ if } f(x) = 0 \\\\ \n\\frac1{\\sqrt2} \\big(|x\\rangle|1\\rangle - |x\\rangle |0\\rangle\\big) = -|x\\rangle|-\\rangle \\text{ if } f(x) = 1\n\\end{cases}\n$$</p>\n<p>$$= (-1)^{f(x)}|x\\rangle |-\\rangle$$</p>\n<ul>\n<li>If the input register is in a superposition state, say $|x\\rangle = \\frac1{\\sqrt2} \\big(|b_1\\rangle + |b_2\\rangle\\big)$, where $|b_1\\rangle$ and $|b_2\\rangle$ are basis states:</li>\n</ul>\n<p>$$U_{mark} |x\\rangle |-\\rangle = U_{mark} \\frac{1}{\\sqrt{2}} \\big(|b_1\\rangle + |b_2\\rangle\\big) |-\\rangle$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( U_{mark}|b_1\\rangle|-\\rangle + U_{mark}|b_2\\rangle|-\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big) |-\\rangle$$</p>\n<p>We see that in both cases applying $U_{mark}$ does not change the state of the target qubit, but it does change the state of the input register. \nThus we can drop the target qubit without any repercussions after the application of the oracle. \nNotice that the input register is now in the following state:\n$$|\\psi\\rangle = \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big),$$</p>\n<p>which looks exactly as if we applied a phase oracle to $|x\\rangle$ instead of applying a marking oracle to $|x\\rangle|-\\rangle$! This is a very important application of phase kickback: it allows to convert a marking oracle into a phase oracle - which you will implement in the next task.</p>\n<blockquote>\n<p>Another important application of this effect is <strong>phase estimation</strong> algorithm, which allows to estimate an eigenvalue of an eigenvector.</p>\n</blockquote>\n<p>Consider the following example using the $U_{7,mark}$ oracle. Let&#39;s begin with $|x\\rangle$ as an equal superposition of the $6$ and $7$ basis states and $|y\\rangle=|-\\rangle$, the overall state is:</p>\n<p>$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle\\big)$$</p>\n<p>How does $U_{7,mark}$ act on this state?</p>\n<p>$$U_{7,mark}|\\eta\\rangle = U_{7,mark} \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\big( U_{7,mark}|110\\rangle|0\\rangle + U_{7,mark}|111\\rangle|0\\rangle - U_{7,mark}|110\\rangle|1\\rangle - U_{7,mark}|111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle \\big) := |\\xi\\rangle$$</p>\n<p>Now we would like to observe how our input state $|\\eta\\rangle$ was modified by the oracle. Let&#39;s simplify the resulting state $|\\xi\\rangle$:</p>\n<p>$$|\\xi\\rangle = \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle + |111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\Big[|110\\rangle \\otimes \\big(|0\\rangle - |1\\rangle \\big) + |111\\rangle \\otimes \\big(|1\\rangle - |0\\rangle\\big)\\Big]$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes \\Big[ \\frac{1}{\\sqrt{2}} \\big( |0\\rangle - |1\\rangle \\big) \\Big]$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes |-\\rangle$$</p>\n<p>Finally, let&#39;s compare $|\\eta\\rangle$ and $|\\xi\\rangle$; below are the final equations repeated for your convenience:\n$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$\n$$|\\xi\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle - |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$</p>\n<p>We can see that these two equations are identical, except for the $-1$ phase that appeared on the $|111\\rangle$ basis state (representing $7$). This is a specific example of the phase kickback effect, as the phase from $|-\\rangle$ has been <em>kicked back</em> into $|x\\rangle$.</p>\n<h2 id=\"🔎-analyze\">🔎 Analyze</h2>\n<p><strong>Distinguishing states</strong></p>\n<p>How could we distinguish the states $|\\eta\\rangle = |11+\\rangle |-\\rangle$ and $|\\xi\\rangle = |11-\\rangle |-\\rangle$? Take a moment to think.</p>\n<details>\n<summary><b>Solution</b></summary>\nRecall that we can only observe alterations to out input state by performing a measurement.\nIf we apply Hadamard gate to the third qubit, we will be able to distinguish between the input state and the output state. \n $$(I\\otimes I \\otimes H)|11+\\rangle = |110\\rangle \\\\ (I\\otimes I \\otimes H)|11-\\rangle = |111\\rangle$$ \nNow if we were to measure the third qubit, we'll be able to distinguish the starting state and the state after phase kickback occurred.\n</details>",
2034
+ "asHtml": "<p>Previously we considered applying marking oracles when the register $|x\\rangle$ was in a basis state or a superposition state, and the target qubit $|y\\rangle$ in a basis state. How might the effect of applying marking oracles change if the target is also in a superposition state? In this case we will observe <strong>phase kickback</strong> - the relative phase from the target qubit affecting (&quot;kicked back&quot; into) the state of the input qubits.</p>\n<p>In order to observe phase kickback, we use the target qubit $|y\\rangle=|-\\rangle$.</p>\n<blockquote>\n<p>This is the standard choice for two reasons. \nFirst, for phase kickback to occur, the target qubit must have a difference in relative phase between the basis states $|0\\rangle$ and $|1\\rangle$. \nSecond, the target qubit must be in an equal superposition, otherwise it will become entangled with the input register.</p>\n</blockquote>\n<p>Let&#39;s see the results of applying a marking oracle $U_{mark}$ which implements the function $f(x)$ to the input register $|x\\rangle$ and the target qubit in state $|-\\rangle$:</p>\n<ul>\n<li>If the input register $|x\\rangle$ is in a basis state:</li>\n</ul>\n<p>$$U_{mark} |x\\rangle |-\\rangle = \\frac1{\\sqrt2} \\big(U_{mark}|x\\rangle|0\\rangle - U_{mark}|x\\rangle |1\\rangle\\big)$$</p>\n<p>$$= \\frac1{\\sqrt2} \\big(|x\\rangle|0\\oplus f(x)\\rangle - |x\\rangle |1\\oplus f(x)\\rangle\\big)$$</p>\n<p>$$= \n\\begin{cases} \n\\frac1{\\sqrt2} \\big(|x\\rangle|0\\rangle - |x\\rangle |1\\rangle\\big) = |x\\rangle|-\\rangle \\text{ if } f(x) = 0 \\\\ \n\\frac1{\\sqrt2} \\big(|x\\rangle|1\\rangle - |x\\rangle |0\\rangle\\big) = -|x\\rangle|-\\rangle \\text{ if } f(x) = 1\n\\end{cases}\n$$</p>\n<p>$$= (-1)^{f(x)}|x\\rangle |-\\rangle$$</p>\n<ul>\n<li>If the input register is in a superposition state, say $|x\\rangle = \\frac1{\\sqrt2} \\big(|b_1\\rangle + |b_2\\rangle\\big)$, where $|b_1\\rangle$ and $|b_2\\rangle$ are basis states:</li>\n</ul>\n<p>$$U_{mark} |x\\rangle |-\\rangle = U_{mark} \\frac{1}{\\sqrt{2}} \\big(|b_1\\rangle + |b_2\\rangle\\big) |-\\rangle$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( U_{mark}|b_1\\rangle|-\\rangle + U_{mark}|b_2\\rangle|-\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big) |-\\rangle$$</p>\n<p>We see that in both cases applying $U_{mark}$ does not change the state of the target qubit, but it does change the state of the input register. \nThus we can drop the target qubit without any repercussions after the application of the oracle. \nNotice that the input register is now in the following state:\n$$|\\psi\\rangle = \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big),$$</p>\n<p>which looks exactly as if we applied a phase oracle to $|x\\rangle$ instead of applying a marking oracle to $|x\\rangle|-\\rangle$! This is a very important application of phase kickback: it allows to convert a marking oracle into a phase oracle - which you will implement in the next task.</p>\n<blockquote>\n<p>Another important application of this effect is <strong>phase estimation</strong> algorithm, which allows to estimate an eigenvalue of an eigenvector.</p>\n</blockquote>\n<p>Consider the following example using the $U_{7,mark}$ oracle. Let&#39;s begin with $|x\\rangle$ as an equal superposition of the $6$ and $7$ basis states and $|y\\rangle=|-\\rangle$, the overall state is:</p>\n<p>$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle\\big)$$</p>\n<p>How does $U_{7,mark}$ act on this state?</p>\n<p>$$U_{7,mark}|\\eta\\rangle = U_{7,mark} \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\big( U_{7,mark}|110\\rangle|0\\rangle + U_{7,mark}|111\\rangle|0\\rangle - U_{7,mark}|110\\rangle|1\\rangle - U_{7,mark}|111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle \\big) := |\\xi\\rangle$$</p>\n<p>Now we would like to observe how our input state $|\\eta\\rangle$ was modified by the oracle. Let&#39;s simplify the resulting state $|\\xi\\rangle$:</p>\n<p>$$|\\xi\\rangle = \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle\\big)$$</p>\n<p>$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle + |111\\rangle|1\\rangle \\big)$$</p>\n<p>$$= \\frac{1}{2} \\Big[|110\\rangle \\otimes \\big(|0\\rangle - |1\\rangle \\big) + |111\\rangle \\otimes \\big(|1\\rangle - |0\\rangle\\big)\\Big]$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes \\Big[ \\frac{1}{\\sqrt{2}} \\big( |0\\rangle - |1\\rangle \\big) \\Big]$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes |-\\rangle$$</p>\n<p>Finally, let&#39;s compare $|\\eta\\rangle$ and $|\\xi\\rangle$; below are the final equations repeated for your convenience:\n$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$\n$$|\\xi\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle - |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$</p>\n<p>We can see that these two equations are identical, except for the $-1$ phase that appeared on the $|111\\rangle$ basis state (representing $7$). This is a specific example of the phase kickback effect, as the phase from $|-\\rangle$ has been <em>kicked back</em> into $|x\\rangle$.</p>\n<h2>🔎 Analyze</h2>\n<p><strong>Distinguishing states</strong></p>\n<p>How could we distinguish the states $|\\eta\\rangle = |11+\\rangle |-\\rangle$ and $|\\xi\\rangle = |11-\\rangle |-\\rangle$? Take a moment to think.</p>\n<details>\n<summary><b>Solution</b></summary>\nRecall that we can only observe alterations to out input state by performing a measurement.\nIf we apply Hadamard gate to the third qubit, we will be able to distinguish between the input state and the output state. \n $$(I\\otimes I \\otimes H)|11+\\rangle = |110\\rangle \\\\ (I\\otimes I \\otimes H)|11-\\rangle = |111\\rangle$$ \nNow if we were to measure the third qubit, we'll be able to distinguish the starting state and the state after phase kickback occurred.\n</details>",
2035
2035
  "asMarkdown": "\nPreviously we considered applying marking oracles when the register $|x\\rangle$ was in a basis state or a superposition state, and the target qubit $|y\\rangle$ in a basis state. How might the effect of applying marking oracles change if the target is also in a superposition state? In this case we will observe **phase kickback** - the relative phase from the target qubit affecting (\"kicked back\" into) the state of the input qubits.\n\nIn order to observe phase kickback, we use the target qubit $|y\\rangle=|-\\rangle$.\n\n> This is the standard choice for two reasons. \n> First, for phase kickback to occur, the target qubit must have a difference in relative phase between the basis states $|0\\rangle$ and $|1\\rangle$. \n> Second, the target qubit must be in an equal superposition, otherwise it will become entangled with the input register.\n\nLet's see the results of applying a marking oracle $U_{mark}$ which implements the function $f(x)$ to the input register $|x\\rangle$ and the target qubit in state $|-\\rangle$:\n* If the input register $|x\\rangle$ is in a basis state:\n\n$$U_{mark} |x\\rangle |-\\rangle = \\frac1{\\sqrt2} \\big(U_{mark}|x\\rangle|0\\rangle - U_{mark}|x\\rangle |1\\rangle\\big)$$\n\n$$= \\frac1{\\sqrt2} \\big(|x\\rangle|0\\oplus f(x)\\rangle - |x\\rangle |1\\oplus f(x)\\rangle\\big)$$\n\n$$= \n\\begin{cases} \n\\frac1{\\sqrt2} \\big(|x\\rangle|0\\rangle - |x\\rangle |1\\rangle\\big) = |x\\rangle|-\\rangle \\text{ if } f(x) = 0 \\\\\\ \n\\frac1{\\sqrt2} \\big(|x\\rangle|1\\rangle - |x\\rangle |0\\rangle\\big) = -|x\\rangle|-\\rangle \\text{ if } f(x) = 1\n\\end{cases}\n$$\n\n$$= (-1)^{f(x)}|x\\rangle |-\\rangle$$\n\n\n* If the input register is in a superposition state, say $|x\\rangle = \\frac1{\\sqrt2} \\big(|b_1\\rangle + |b_2\\rangle\\big)$, where $|b_1\\rangle$ and $|b_2\\rangle$ are basis states:\n\n$$U_{mark} |x\\rangle |-\\rangle = U_{mark} \\frac{1}{\\sqrt{2}} \\big(|b_1\\rangle + |b_2\\rangle\\big) |-\\rangle$$\n\n$$= \\frac{1}{\\sqrt{2}} \\big( U_{mark}|b_1\\rangle|-\\rangle + U_{mark}|b_2\\rangle|-\\rangle\\big)$$\n\n$$= \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big) |-\\rangle$$\n\nWe see that in both cases applying $U_{mark}$ does not change the state of the target qubit, but it does change the state of the input register. \nThus we can drop the target qubit without any repercussions after the application of the oracle. \nNotice that the input register is now in the following state:\n$$|\\psi\\rangle = \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}|b_1\\rangle + (-1)^{f(b_2)}|b_2\\rangle\\big),$$\n\nwhich looks exactly as if we applied a phase oracle to $|x\\rangle$ instead of applying a marking oracle to $|x\\rangle|-\\rangle$! This is a very important application of phase kickback: it allows to convert a marking oracle into a phase oracle - which you will implement in the next task.\n\n> Another important application of this effect is **phase estimation** algorithm, which allows to estimate an eigenvalue of an eigenvector.\n\nConsider the following example using the $U_{7,mark}$ oracle. Let's begin with $|x\\rangle$ as an equal superposition of the $6$ and $7$ basis states and $|y\\rangle=|-\\rangle$, the overall state is:\n\n$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$\n\n$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle\\big)$$\n\nHow does $U_{7,mark}$ act on this state?\n\n$$U_{7,mark}|\\eta\\rangle = U_{7,mark} \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|1\\rangle \\big)$$\n\n$$= \\frac{1}{2} \\big( U_{7,mark}|110\\rangle|0\\rangle + U_{7,mark}|111\\rangle|0\\rangle - U_{7,mark}|110\\rangle|1\\rangle - U_{7,mark}|111\\rangle|1\\rangle \\big)$$\n\n$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle \\big) := |\\xi\\rangle$$\n\nNow we would like to observe how our input state $|\\eta\\rangle$ was modified by the oracle. Let's simplify the resulting state $|\\xi\\rangle$:\n\n$$|\\xi\\rangle = \\frac{1}{2} \\big(|110\\rangle|0\\rangle + |111\\rangle|1\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle\\big)$$\n\n$$= \\frac{1}{2} \\big(|110\\rangle|0\\rangle - |110\\rangle|1\\rangle - |111\\rangle|0\\rangle + |111\\rangle|1\\rangle \\big)$$\n\n$$= \\frac{1}{2} \\Big[|110\\rangle \\otimes \\big(|0\\rangle - |1\\rangle \\big) + |111\\rangle \\otimes \\big(|1\\rangle - |0\\rangle\\big)\\Big]$$\n\n$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes \\Big[ \\frac{1}{\\sqrt{2}} \\big( |0\\rangle - |1\\rangle \\big) \\Big]$$\n\n$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( |110\\rangle - |111\\rangle \\big) \\Big] \\otimes |-\\rangle$$\n\nFinally, let's compare $|\\eta\\rangle$ and $|\\xi\\rangle$; below are the final equations repeated for your convenience:\n$$|\\eta\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle + |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$\n$$|\\xi\\rangle = \\Big[\\frac{1}{\\sqrt{2}}\\big(|110\\rangle - |111\\rangle\\big)\\Big] \\otimes |-\\rangle$$\n\nWe can see that these two equations are identical, except for the $-1$ phase that appeared on the $|111\\rangle$ basis state (representing $7$). This is a specific example of the phase kickback effect, as the phase from $|-\\rangle$ has been *kicked back* into $|x\\rangle$.\n\n## 🔎 Analyze\n\n**Distinguishing states**\n\nHow could we distinguish the states $|\\eta\\rangle = |11+\\rangle |-\\rangle$ and $|\\xi\\rangle = |11-\\rangle |-\\rangle$? Take a moment to think.\n\n<details>\n<summary><b>Solution</b></summary>\nRecall that we can only observe alterations to out input state by performing a measurement.\nIf we apply Hadamard gate to the third qubit, we will be able to distinguish between the input state and the output state. \n $$(I\\otimes I \\otimes H)|11+\\rangle = |110\\rangle \\\\ (I\\otimes I \\otimes H)|11-\\rangle = |111\\rangle$$ \nNow if we were to measure the third qubit, we'll be able to distinguish the starting state and the state after phase kickback occurred.\n</details>"
2036
2036
  }
2037
2037
  ]
@@ -2286,8 +2286,8 @@ export default {
2286
2286
  "items": [
2287
2287
  {
2288
2288
  "type": "text-content",
2289
- "asHtml": "<p>Congratulations! In this kata you have learned to build quantum oracles. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>A quantum oracle is an &quot;opaque box&quot; operation that is used as input to another algorithm.</li>\n<li>Phase oracles encode the information in the relative phase of basis states. If $f(x)=0$, the oracle doesn&#39;t change the basis state $\\ket{x}$, and if $f(x)=1$ it multiplies the phase of the basis state $\\ket{x}$ by $-1$.</li>\n<li>Marking oracles use an extra qubit $\\ket{y}$ and encode the information in the state of that qubit. If $f(x)=0$, it doen&#39;t change the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$, and if $f(x)=1$ it flips the state of the qubit $\\ket{y} for the basis state $\\ket{x}$.</li>\n</ul>\n<p><strong>Next Steps</strong></p>\n<p>We hope you enjoyed this kata! If you&#39;re looking to learn more about quantum oracles and Q#, here are some suggestions:</p>\n<ul>\n<li>To learn about the Grover&#39;s algorithm, you can check <a href=\"https://learn.microsoft.com/en-us/training/modules/solve-graph-coloring-problems-grovers-search/\" target=\"_blank\">Microsoft Learn module &quot;Solve graph coloring problems by using Grover&#39;s search&quot;</a>.</li>\n<li>To learn more about the Q# libraries, you can check the <a href=\"https://learn.microsoft.com/en-us/azure/quantum/user-guide/libraries/?tabs=tabid-clivscode\" target=\"_blank\">The Q# user guide</a>.</li>\n</ul>\n",
2290
- "asMarkdown": "\nCongratulations! In this kata you have learned to build quantum oracles. Here are a few key concepts to keep in mind:\n* A quantum oracle is an \"opaque box\" operation that is used as input to another algorithm.\n* Phase oracles encode the information in the relative phase of basis states. If $f(x)=0$, the oracle doesn't change the basis state $\\ket{x}$, and if $f(x)=1$ it multiplies the phase of the basis state $\\ket{x}$ by $-1$.\n* Marking oracles use an extra qubit $\\ket{y}$ and encode the information in the state of that qubit. If $f(x)=0$, it doen't change the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$, and if $f(x)=1$ it flips the state of the qubit $\\ket{y} for the basis state $\\ket{x}$.\n\n**Next Steps**\n\nWe hope you enjoyed this kata! If you're looking to learn more about quantum oracles and Q#, here are some suggestions:\n* To learn about the Grover's algorithm, you can check <a href=\"https://learn.microsoft.com/en-us/training/modules/solve-graph-coloring-problems-grovers-search/\" target=\"_blank\">Microsoft Learn module \"Solve graph coloring problems by using Grover's search\"</a>.\n* To learn more about the Q# libraries, you can check the <a href=\"https://learn.microsoft.com/en-us/azure/quantum/user-guide/libraries/?tabs=tabid-clivscode\" target=\"_blank\">The Q# user guide</a>."
2289
+ "asHtml": "<p>Congratulations! In this kata you have learned to build quantum oracles. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>A quantum oracle is an &quot;opaque box&quot; operation that is used as input to another algorithm.</li>\n<li>Phase oracles encode the information in the relative phase of basis states. If $f(x)=0$, the oracle doesn&#39;t change the basis state $\\ket{x}$, and if $f(x)=1$ it multiplies the phase of the basis state $\\ket{x}$ by $-1$.</li>\n<li>Marking oracles use an extra qubit $\\ket{y}$ and encode the information in the state of that qubit. If $f(x)=0$, it doen&#39;t change the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$, and if $f(x)=1$ it flips the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$.</li>\n</ul>\n<p><strong>Next Steps</strong></p>\n<p>We hope you enjoyed this kata! If you&#39;re looking to learn more about quantum oracles and Q#, here are some suggestions:</p>\n<ul>\n<li>To learn about the Grover&#39;s algorithm, you can check <a href=\"https://learn.microsoft.com/en-us/training/modules/solve-graph-coloring-problems-grovers-search/\" target=\"_blank\">Microsoft Learn module &quot;Solve graph coloring problems by using Grover&#39;s search&quot;</a>.</li>\n<li>To learn more about the Q# libraries, you can check the <a href=\"https://learn.microsoft.com/en-us/azure/quantum/user-guide/libraries/?tabs=tabid-clivscode\" target=\"_blank\">The Q# user guide</a>.</li>\n</ul>\n",
2290
+ "asMarkdown": "\nCongratulations! In this kata you have learned to build quantum oracles. Here are a few key concepts to keep in mind:\n* A quantum oracle is an \"opaque box\" operation that is used as input to another algorithm.\n* Phase oracles encode the information in the relative phase of basis states. If $f(x)=0$, the oracle doesn't change the basis state $\\ket{x}$, and if $f(x)=1$ it multiplies the phase of the basis state $\\ket{x}$ by $-1$.\n* Marking oracles use an extra qubit $\\ket{y}$ and encode the information in the state of that qubit. If $f(x)=0$, it doen't change the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$, and if $f(x)=1$ it flips the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$.\n\n**Next Steps**\n\nWe hope you enjoyed this kata! If you're looking to learn more about quantum oracles and Q#, here are some suggestions:\n* To learn about the Grover's algorithm, you can check <a href=\"https://learn.microsoft.com/en-us/training/modules/solve-graph-coloring-problems-grovers-search/\" target=\"_blank\">Microsoft Learn module \"Solve graph coloring problems by using Grover's search\"</a>.\n* To learn more about the Q# libraries, you can check the <a href=\"https://learn.microsoft.com/en-us/azure/quantum/user-guide/libraries/?tabs=tabid-clivscode\" target=\"_blank\">The Q# user guide</a>."
2291
2291
  }
2292
2292
  ]
2293
2293
  }