diff --git a/BasicGates/Workbook_BasicGates.ipynb b/BasicGates/Workbook_BasicGates.ipynb index 440513ec9ff..a84928ca0ef 100644 --- a/BasicGates/Workbook_BasicGates.ipynb +++ b/BasicGates/Workbook_BasicGates.ipynb @@ -2,7 +2,6 @@ "cells": [ { "cell_type": "markdown", - "id": "08b341ed", "metadata": { "tags": [] }, @@ -20,7 +19,6 @@ }, { "cell_type": "markdown", - "id": "3518d868", "metadata": {}, "source": [ "**What you should know for this workbook**\n", @@ -37,7 +35,6 @@ }, { "cell_type": "markdown", - "id": "ac84ea42", "metadata": {}, "source": [ "# Part 1. Single-Qubit Gates" @@ -45,7 +42,6 @@ }, { "cell_type": "markdown", - "id": "d8fb9f6f", "metadata": { "jp-MarkdownHeadingCollapsed": true, "tags": [] @@ -66,7 +62,6 @@ }, { "cell_type": "markdown", - "id": "9352232d", "metadata": {}, "source": [ "### Solution" @@ -74,7 +69,6 @@ }, { "cell_type": "markdown", - "id": "8eed54c9", "metadata": {}, "source": [ "We can recognize that the Pauli X gate will change the state $|0\\rangle$ to $|1\\rangle$ and vice versa, and $\\alpha |0\\rangle + \\beta |1\\rangle$ to $\\alpha |1\\rangle + \\beta |0\\rangle$.\n", @@ -84,7 +78,6 @@ }, { "cell_type": "markdown", - "id": "571ec0ad", "metadata": {}, "source": [ "$$\n", @@ -100,7 +93,6 @@ }, { "cell_type": "markdown", - "id": "4783f3bc", "metadata": {}, "source": [ "$$X|0\\rangle= \n", @@ -128,7 +120,6 @@ }, { "cell_type": "markdown", - "id": "ea904409", "metadata": {}, "source": [ "Similarly, we can consider the effect of the X gate on the superposition state $|\\psi\\rangle = 0.6|0\\rangle + 0.8|1\\rangle$:" @@ -136,7 +127,6 @@ }, { "cell_type": "markdown", - "id": "cca0689e", "metadata": {}, "source": [ "$$X|\\psi\\rangle= \n", @@ -165,7 +155,6 @@ { "cell_type": "code", "execution_count": null, - "id": "eb5280e4", "metadata": {}, "outputs": [], "source": [ @@ -178,7 +167,6 @@ }, { "cell_type": "markdown", - "id": "d641d015", "metadata": {}, "source": [ "[Return to Task 1.1 of the Basic Gates kata.](./BasicGates.ipynb#Task-1.1.-State-flip:-$|0\\rangle$-to-$|1\\rangle$-and-vice-versa)" @@ -186,7 +174,6 @@ }, { "cell_type": "markdown", - "id": "b7334694", "metadata": { "tags": [] }, @@ -203,7 +190,6 @@ }, { "cell_type": "markdown", - "id": "37723ac7", "metadata": {}, "source": [ "### Solution" @@ -211,7 +197,6 @@ }, { "cell_type": "markdown", - "id": "9ae4bd06", "metadata": { "tags": [] }, @@ -223,7 +208,6 @@ }, { "cell_type": "markdown", - "id": "4affd231", "metadata": { "tags": [] }, @@ -240,7 +224,6 @@ }, { "cell_type": "markdown", - "id": "3e9cff65", "metadata": { "tags": [] }, @@ -271,7 +254,6 @@ }, { "cell_type": "markdown", - "id": "902e503e", "metadata": {}, "source": [ "Similarly, we can consider the effect of the Hadamard gate on the superposition state $|\\psi\\rangle = 0.6|0\\rangle + 0.8|1\\rangle$ (rounding the numbers to 4 decimal places):" @@ -279,7 +261,6 @@ }, { "cell_type": "markdown", - "id": "6be890e3", "metadata": {}, "source": [ "$$\n", @@ -312,7 +293,6 @@ { "cell_type": "code", "execution_count": null, - "id": "c31ba04d", "metadata": {}, "outputs": [], "source": [ @@ -325,7 +305,6 @@ }, { "cell_type": "markdown", - "id": "0ed1eb80", "metadata": {}, "source": [ "[Return to Task 1.2 of the Basic Gates kata](./BasicGates.ipynb#Task-1.2.-Basis-change:-$|0\\rangle$-to-$|+\\rangle$-and-$|1\\rangle$-to-$|-\\rangle$-(and-vice-versa))." @@ -333,7 +312,6 @@ }, { "cell_type": "markdown", - "id": "040d446b", "metadata": {}, "source": [ " " @@ -341,7 +319,6 @@ }, { "cell_type": "markdown", - "id": "d2f58d77", "metadata": {}, "source": [ "## Task 1.3. Sign flip: $|+\\rangle$ to $|-\\rangle$ and vice versa.\n", @@ -353,7 +330,6 @@ }, { "cell_type": "markdown", - "id": "d98d3f8c", "metadata": {}, "source": [ "### Solution" @@ -361,7 +337,6 @@ }, { "cell_type": "markdown", - "id": "708e93ff", "metadata": {}, "source": [ "The action of the Pauli Z gate is exactly what is required by this question.\n", @@ -372,7 +347,6 @@ }, { "cell_type": "markdown", - "id": "23394efb", "metadata": {}, "source": [ "$$\n", @@ -416,7 +390,6 @@ }, { "cell_type": "markdown", - "id": "a3677492", "metadata": {}, "source": [ "In general applying the Z gate to a single qubit superposition state $|\\psi\\rangle = \\alpha |0\\rangle + \\beta |1\\rangle$ gives" @@ -424,7 +397,6 @@ }, { "cell_type": "markdown", - "id": "2d1e7e97", "metadata": {}, "source": [ "$$\n", @@ -454,7 +426,6 @@ { "cell_type": "code", "execution_count": null, - "id": "0c4e1d89", "metadata": { "tags": [] }, @@ -469,7 +440,6 @@ }, { "cell_type": "markdown", - "id": "f7807d03", "metadata": {}, "source": [ "[Return to Task 1.3 of the Basic Gates kata](./BasicGates.ipynb#Task-1.3.-Sign-flip:-$|+\\rangle$--to-$|-\\rangle$--and-vice-versa.)." @@ -477,7 +447,6 @@ }, { "cell_type": "markdown", - "id": "0f805114", "metadata": { "tags": [] }, @@ -497,7 +466,6 @@ }, { "cell_type": "markdown", - "id": "6fe379f8", "metadata": {}, "source": [ "### Solution" @@ -505,7 +473,6 @@ }, { "cell_type": "markdown", - "id": "ae7f2616", "metadata": {}, "source": [ "We can recognize that we need to use one of the rotation gates Rx, Ry, and Rz (named because they \"rotate\" the qubit state in the three dimensional space visualized as the Bloch sphere about the x, y, and z axes, respectively), since they involve angle parameters. Of these three gates, only Ry rotates the basis states $|0\\rangle$ and $|1\\rangle$ to have real amplitudes (the other two gates introduce complex coefficients).\n", @@ -515,7 +482,6 @@ }, { "cell_type": "markdown", - "id": "57777d72", "metadata": {}, "source": [ "$$\n", @@ -529,7 +495,6 @@ }, { "cell_type": "markdown", - "id": "b33786ab", "metadata": {}, "source": [ "Let's see its effect on the $|0\\rangle$ state:" @@ -537,7 +502,6 @@ }, { "cell_type": "markdown", - "id": "731e2fc6", "metadata": {}, "source": [ "$$\n", @@ -566,7 +530,6 @@ }, { "cell_type": "markdown", - "id": "0610a9fe", "metadata": {}, "source": [ "Recall that when applying a gate, you can tell what its matrix does to the basis states by looking at its columns: the first column of the matrix is the state into which it will transform the $|0\\rangle$ state, and the second column is the state into which it will transform the $|1\\rangle$ state." @@ -574,7 +537,6 @@ }, { "cell_type": "markdown", - "id": "10a1735f", "metadata": {}, "source": [ "In the example used by the testing harness we are given $\\beta = 0.6, \\gamma = 0.8$ and $\\alpha = 1.0471975511965976 = \\frac{\\pi}{3}$." @@ -582,7 +544,6 @@ }, { "cell_type": "markdown", - "id": "7987103d", "metadata": {}, "source": [ "Since $\\cos \\frac{\\pi}{3} = 0.5$ and $\\sin \\frac{\\pi}{3} = 0.8660$, working to 4 decimal places, we can compute:" @@ -590,7 +551,6 @@ }, { "cell_type": "markdown", - "id": "79a3cf4a", "metadata": {}, "source": [ "$$\n", @@ -629,7 +589,6 @@ }, { "cell_type": "markdown", - "id": "a9925bef", "metadata": {}, "source": [ "Notice that we used $\\frac{\\theta}{2} = \\alpha$; this means that in the Q# code we need to pass the angle $\\theta = 2\\alpha$." @@ -638,7 +597,6 @@ { "cell_type": "code", "execution_count": null, - "id": "76806a63", "metadata": {}, "outputs": [], "source": [ @@ -651,7 +609,6 @@ }, { "cell_type": "markdown", - "id": "0f633d2e", "metadata": {}, "source": [ "[Return to Task 1.4 of the Basic Gates kata](./BasicGates.ipynb#Task-1.4.-Amplitude-change:-$|0\\rangle$-to-$\\cos{α}-|0\\rangle-+-\\sin{α}-|1\\rangle$.)." @@ -659,7 +616,6 @@ }, { "cell_type": "markdown", - "id": "f602eca2", "metadata": {}, "source": [ "## Task 1.5. Phase flip\n", @@ -671,7 +627,6 @@ }, { "cell_type": "markdown", - "id": "53979f74", "metadata": {}, "source": [ "### Solution\n", @@ -681,7 +636,6 @@ }, { "cell_type": "markdown", - "id": "f6bf8c81", "metadata": {}, "source": [ "$$\n", @@ -695,7 +649,6 @@ }, { "cell_type": "markdown", - "id": "529f3a15", "metadata": {}, "source": [ "Let's see the effect of this gate on the general superposition $|\\psi\\rangle = \\alpha |0\\rangle + \\beta |1\\rangle$." @@ -703,7 +656,6 @@ }, { "cell_type": "markdown", - "id": "e915ee67", "metadata": {}, "source": [ "$$\n", @@ -730,7 +682,6 @@ }, { "cell_type": "markdown", - "id": "673ab60c", "metadata": {}, "source": [ "It is therefore easy to see that when $|\\psi\\rangle = 0.6|0\\rangle + 0.8|1\\rangle, S|\\psi\\rangle = 0.6|0\\rangle + 0.8i|1\\rangle$." @@ -739,7 +690,6 @@ { "cell_type": "code", "execution_count": null, - "id": "d18c3b7d", "metadata": {}, "outputs": [], "source": [ @@ -752,7 +702,6 @@ }, { "cell_type": "markdown", - "id": "ed15b83a", "metadata": {}, "source": [ "### Solution 2\n", @@ -763,7 +712,6 @@ { "cell_type": "code", "execution_count": null, - "id": "e1709a88", "metadata": {}, "outputs": [], "source": [ @@ -778,7 +726,6 @@ }, { "cell_type": "markdown", - "id": "96ad3638", "metadata": {}, "source": [ "[Return to Task 1.5 of the Basic Gates kata](./BasicGates.ipynb#Task-1.5.-Phase-flip)." @@ -786,7 +733,6 @@ }, { "cell_type": "markdown", - "id": "6f01ebf6", "metadata": {}, "source": [ "## Task 1.6. Phase change\n", @@ -804,7 +750,6 @@ }, { "cell_type": "markdown", - "id": "e47dd632", "metadata": {}, "source": [ "### Solution\n", @@ -813,7 +758,6 @@ }, { "cell_type": "markdown", - "id": "99e25061", "metadata": {}, "source": [ "$$\n", @@ -828,7 +772,6 @@ }, { "cell_type": "markdown", - "id": "77bcb993", "metadata": {}, "source": [ "So we have:" @@ -836,7 +779,6 @@ }, { "cell_type": "markdown", - "id": "cb9570f7", "metadata": {}, "source": [ "$$\n", @@ -865,7 +807,6 @@ }, { "cell_type": "markdown", - "id": "6d87c8ad", "metadata": {}, "source": [ "> Note that the results produced by the test harness can be unexpected.\n", @@ -883,7 +824,6 @@ { "cell_type": "code", "execution_count": null, - "id": "4fe80339", "metadata": {}, "outputs": [], "source": [ @@ -896,7 +836,6 @@ }, { "cell_type": "markdown", - "id": "5c1711c7", "metadata": {}, "source": [ "Suppose now that $\\alpha = \\frac{\\pi}{2}$.\n", @@ -907,7 +846,6 @@ }, { "cell_type": "markdown", - "id": "56490e4e", "metadata": {}, "source": [ "[Return to Task 1.6 of the Basic Gates kata](./BasicGates.ipynb#Task-1.6.-Phase-Change)." @@ -915,7 +853,6 @@ }, { "cell_type": "markdown", - "id": "5e4885b0", "metadata": {}, "source": [ "## Task 1.7. Global phase change\n", @@ -930,7 +867,6 @@ }, { "cell_type": "markdown", - "id": "e74f38aa", "metadata": {}, "source": [ "### Solution\n", @@ -944,7 +880,6 @@ }, { "cell_type": "markdown", - "id": "fee6138f", "metadata": {}, "source": [ "For the problem at hand, we'll use the rotation gate $R_{\\mu}(\\theta) = \\exp(\\frac{\\theta}{2}i\\cdot\\sigma_{\\mu})$ with $\\sigma_{\\mu} = I$. \n", @@ -954,7 +889,6 @@ }, { "cell_type": "markdown", - "id": "0af70ee2", "metadata": {}, "source": [ "$$\n", @@ -994,7 +928,6 @@ }, { "cell_type": "markdown", - "id": "a25311a9", "metadata": {}, "source": [ "The test harness for this test shows the result of applying the *controlled* variant of your solution to be able to detect the phase change." @@ -1003,7 +936,6 @@ { "cell_type": "code", "execution_count": null, - "id": "ce9e8cd8", "metadata": {}, "outputs": [], "source": [ @@ -1018,7 +950,6 @@ }, { "cell_type": "markdown", - "id": "6f1b9945", "metadata": {}, "source": [ "[Return to Task 1.7 of the Basic Gates kata](./BasicGates.ipynb#Task-1.7.-Global-phase-change)." @@ -1026,7 +957,6 @@ }, { "cell_type": "markdown", - "id": "50909364", "metadata": {}, "source": [ "## Task 1.8. Bell state change - 1\n", @@ -1038,7 +968,6 @@ }, { "cell_type": "markdown", - "id": "cf8dec6b", "metadata": {}, "source": [ "### Solution" @@ -1046,7 +975,6 @@ }, { "cell_type": "markdown", - "id": "1e90fc5e", "metadata": {}, "source": [ "We recognize that the goal is another Bell state. In fact, it is one of the four Bell states.\n", @@ -1062,7 +990,6 @@ }, { "cell_type": "markdown", - "id": "63ea5481", "metadata": {}, "source": [ "If we apply the Z gate to the qubit A, it will flip the phase of the basis state $|1_A\\rangle$. As this phase is in a sense spread across the entangled state, with $|1_A\\rangle$ basis state being part of the second half of the superposition, this application has the effect of flipping the sign of the whole basis state $|1_A1_B\\rangle$, as you can see by running the solution below. \n", @@ -1078,7 +1005,6 @@ { "cell_type": "code", "execution_count": null, - "id": "212bf887", "metadata": {}, "outputs": [], "source": [ @@ -1091,7 +1017,6 @@ }, { "cell_type": "markdown", - "id": "7573cc28", "metadata": {}, "source": [ "[Return to Task 1.8 of the Basic Gates kata](./BasicGates.ipynb#Task-1.8.-Bell-state-change---1)." @@ -1099,7 +1024,6 @@ }, { "cell_type": "markdown", - "id": "5031d150", "metadata": {}, "source": [ "## Task 1.9. Bell state change - 2\n", @@ -1111,7 +1035,6 @@ }, { "cell_type": "markdown", - "id": "d2b7a7bc", "metadata": {}, "source": [ "### Solution ##\n", @@ -1125,7 +1048,6 @@ { "cell_type": "code", "execution_count": null, - "id": "fac2ab43", "metadata": { "scrolled": true }, @@ -1140,7 +1062,6 @@ }, { "cell_type": "markdown", - "id": "2fad3a01", "metadata": {}, "source": [ "[Return to Task 1.9 of the Basic Gates kata](./BasicGates.ipynb#Task-1.9.-Bell-state-change---2)." @@ -1148,7 +1069,6 @@ }, { "cell_type": "markdown", - "id": "8d15a443", "metadata": {}, "source": [ "## Task 1.10. Bell state change - 3\n", @@ -1160,7 +1080,6 @@ }, { "cell_type": "markdown", - "id": "ab78ed82", "metadata": {}, "source": [ "### Solution ##\n", @@ -1175,7 +1094,6 @@ { "cell_type": "code", "execution_count": null, - "id": "5cba6fcf", "metadata": {}, "outputs": [], "source": [ @@ -1189,7 +1107,6 @@ }, { "cell_type": "markdown", - "id": "2580bcc0", "metadata": {}, "source": [ "[Return to Task 1.10 of the Basic Gates kata](./BasicGates.ipynb#Task-1.10.-Bell-state-change---3)." @@ -1197,7 +1114,6 @@ }, { "cell_type": "markdown", - "id": "e852abeb", "metadata": {}, "source": [ "# Part II. Multi-Qubit Gates\n", @@ -1213,7 +1129,6 @@ }, { "cell_type": "markdown", - "id": "06172f60", "metadata": {}, "source": [ "### Solution\n", @@ -1228,7 +1143,6 @@ { "cell_type": "code", "execution_count": null, - "id": "3f8c13e6", "metadata": {}, "outputs": [], "source": [ @@ -1241,7 +1155,6 @@ }, { "cell_type": "markdown", - "id": "d1c26753", "metadata": {}, "source": [ "[Return to Task 2.1 of the Basic Gates kata](./BasicGates.ipynb#Task-2.1.-Two-qubit-gate---1)." @@ -1249,7 +1162,6 @@ }, { "cell_type": "markdown", - "id": "acb00b18", "metadata": {}, "source": [ "## Task 2.2. Two-qubit gate - 2\n", @@ -1262,7 +1174,6 @@ }, { "cell_type": "markdown", - "id": "8eb87a61", "metadata": {}, "source": [ "### Solution\n", @@ -1271,7 +1182,6 @@ }, { "cell_type": "markdown", - "id": "190868fc", "metadata": {}, "source": [ "In vector form the transformation we need is \n", @@ -1294,7 +1204,6 @@ }, { "cell_type": "markdown", - "id": "17aa3939", "metadata": {}, "source": [ "All that needs to happen to change the input into the goal is that the $|11\\rangle$ basis state needs to have its sign flipped. \n", @@ -1305,7 +1214,6 @@ }, { "cell_type": "markdown", - "id": "6a90f3d3", "metadata": {}, "source": [ "Similarly to task 2.1, the phase shift only occurs on one of the basis states, so this suggests it might be a conditional shift. If we could have our phase shift applied to `qs[1]` conditional on `qs[0]` being in the state $|1\\rangle$, then we would have a description of our gate. If we now look though a list of gates in the [Single-qubit gates tutorial](../tutorials/SingleQubitGates/SingleQubitGates.ipynb), we'll find the R1 phase shift gate with angle parameter $\\theta$ (radians), defined as\n", @@ -1322,7 +1230,6 @@ }, { "cell_type": "markdown", - "id": "d7146bed", "metadata": {}, "source": [ "The controlled variant of this gate will look like this:\n", @@ -1339,7 +1246,6 @@ }, { "cell_type": "markdown", - "id": "94ab2ff7", "metadata": {}, "source": [ "This gate is almost Pauli I, the identity gate, with the different in just the last column, showing what will happen to the $|11\\rangle$ basis state. Applying it to our input state for $\\alpha = \\pi$, we'll get:" @@ -1347,7 +1253,6 @@ }, { "cell_type": "markdown", - "id": "96773152", "metadata": {}, "source": [ "$$\n", @@ -1379,7 +1284,6 @@ }, { "cell_type": "markdown", - "id": "21b2b412", "metadata": {}, "source": [ "The last thing we notice if we look through the [list of operations in the Microsoft.Quantum.Canon namespace](https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.canon) is the CZ (Controlled Z) gate, a special case of CR1 that implements exactly this gate." @@ -1388,7 +1292,6 @@ { "cell_type": "code", "execution_count": null, - "id": "bf116783", "metadata": { "scrolled": true }, @@ -1403,7 +1306,6 @@ }, { "cell_type": "markdown", - "id": "df30893f", "metadata": {}, "source": [ "Alternatively, we can express this gate using the intrinsic gate Z and its controlled variant using the Controlled functor:" @@ -1412,7 +1314,6 @@ { "cell_type": "code", "execution_count": null, - "id": "faca3173", "metadata": {}, "outputs": [], "source": [ @@ -1425,7 +1326,6 @@ }, { "cell_type": "markdown", - "id": "e4721003", "metadata": {}, "source": [ "[Return to Task 2.2 of the Basic Gates kata](./BasicGates.ipynb#Task-2.2.-Two-qubit-gate---2)." @@ -1433,7 +1333,6 @@ }, { "cell_type": "markdown", - "id": "024fd8b5", "metadata": {}, "source": [ "## Task 2.3. Two-qubit gate - 3\n", @@ -1448,7 +1347,6 @@ }, { "cell_type": "markdown", - "id": "414cea33", "metadata": {}, "source": [ "## Solution\n", @@ -1460,7 +1358,6 @@ }, { "cell_type": "markdown", - "id": "45ead206", "metadata": {}, "source": [ "$$\n", @@ -1476,7 +1373,6 @@ }, { "cell_type": "markdown", - "id": "624f23bd", "metadata": {}, "source": [ "and our input state vector is:" @@ -1484,7 +1380,6 @@ }, { "cell_type": "markdown", - "id": "ea2da222", "metadata": {}, "source": [ "$$\n", @@ -1498,7 +1393,6 @@ }, { "cell_type": "markdown", - "id": "5f1ab7ea", "metadata": {}, "source": [ "So operating on our input state vector with the SWAP gate gives us" @@ -1506,7 +1400,6 @@ }, { "cell_type": "markdown", - "id": "ea5bfd55", "metadata": {}, "source": [ "$$\n", @@ -1536,7 +1429,6 @@ }, { "cell_type": "markdown", - "id": "70ec1d62", "metadata": {}, "source": [ "and we can confirm this with the task solution:" @@ -1545,7 +1437,6 @@ { "cell_type": "code", "execution_count": null, - "id": "fc61a027", "metadata": {}, "outputs": [], "source": [ @@ -1558,7 +1449,6 @@ }, { "cell_type": "markdown", - "id": "a73e1253", "metadata": {}, "source": [ "> If you run this solution a few times you might see an apparent anomaly. The test harness uses an input state that has positive values of $\\alpha$ and $\\delta$ and negative values of $\\beta$ and $\\gamma$, while\n", @@ -1568,7 +1458,6 @@ }, { "cell_type": "markdown", - "id": "6bbccd7e", "metadata": {}, "source": [ "Let's now follow the hint in the question and try to express the solution using several (possibly controlled) Pauli gates.\n", @@ -1618,7 +1507,6 @@ { "cell_type": "code", "execution_count": null, - "id": "fde34c0d", "metadata": {}, "outputs": [], "source": [ @@ -1633,7 +1521,6 @@ }, { "cell_type": "markdown", - "id": "d59151ae", "metadata": {}, "source": [ "[Return to Task 2.3 of the Basic Gates kata](./BasicGates.ipynb#Task-2.3.-Two-qubit-gate---3)." @@ -1641,7 +1528,6 @@ }, { "cell_type": "markdown", - "id": "dba10187", "metadata": {}, "source": [ "## Task 2.4. Toffoli gate\n", @@ -1658,7 +1544,6 @@ }, { "cell_type": "markdown", - "id": "987cce48", "metadata": {}, "source": [ "$$\n", @@ -1677,7 +1562,6 @@ }, { "cell_type": "markdown", - "id": "5ca33aa9", "metadata": {}, "source": [ "and our initial state is:" @@ -1685,7 +1569,6 @@ }, { "cell_type": "markdown", - "id": "fa81e5e2", "metadata": {}, "source": [ "$$\n", @@ -1704,7 +1587,6 @@ }, { "cell_type": "markdown", - "id": "b52168aa", "metadata": {}, "source": [ "So we have:" @@ -1712,7 +1594,6 @@ }, { "cell_type": "markdown", - "id": "f2edd717", "metadata": {}, "source": [ "$$\n", @@ -1755,7 +1636,6 @@ { "cell_type": "code", "execution_count": null, - "id": "a19e7f27", "metadata": {}, "outputs": [], "source": [ @@ -1768,7 +1648,6 @@ }, { "cell_type": "markdown", - "id": "3638bc88", "metadata": {}, "source": [ "[Return to Task 2.4 of the Basic Gates kata](./BasicGates.ipynb#Task-2.4.-Toffoli-gate)." @@ -1776,7 +1655,6 @@ }, { "cell_type": "markdown", - "id": "12f55c25", "metadata": {}, "source": [ "## Task 2.5. Fredkin gate\n", @@ -1795,7 +1673,6 @@ }, { "cell_type": "markdown", - "id": "16ef03ce", "metadata": {}, "source": [ "$$\n", @@ -1814,7 +1691,6 @@ }, { "cell_type": "markdown", - "id": "5ca334bd", "metadata": {}, "source": [ "and our initial state is:" @@ -1822,7 +1698,6 @@ }, { "cell_type": "markdown", - "id": "320458ec", "metadata": {}, "source": [ "$$\n", @@ -1841,7 +1716,6 @@ }, { "cell_type": "markdown", - "id": "95174e4a", "metadata": {}, "source": [ "So we have:" @@ -1849,7 +1723,6 @@ }, { "cell_type": "markdown", - "id": "2b28ca69", "metadata": {}, "source": [ "$$\n", @@ -1891,7 +1764,6 @@ }, { "cell_type": "markdown", - "id": "a23843de", "metadata": {}, "source": [ "Notice carefully how the qubits are passed to the gate: `[qs[0]], (qs[1], [qs[2])`. The `Controlled` functor produces an operation that takes two parameters: the first one is an array of control qubits (in this case a single-element array consisting of the first qubit), and the second parameter is a tuple of all parameters you'd pass to the original gate (in this gate two single-qubit parameters that would be arguments to a SWAP gate)." @@ -1900,7 +1772,6 @@ { "cell_type": "code", "execution_count": null, - "id": "188c0344", "metadata": {}, "outputs": [], "source": [ @@ -1913,7 +1784,6 @@ }, { "cell_type": "markdown", - "id": "1cc1e356", "metadata": {}, "source": [ "[Return to Task 2.5 of the Basic Gates kata](./BasicGates.ipynb#Task-2.5.-Fredkin-gate)." @@ -1930,7 +1800,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.14" + "version": "0.24" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/tutorials/MultiQubitGates/MultiQubitGates.ipynb b/tutorials/MultiQubitGates/MultiQubitGates.ipynb index 4c6ad30cd99..8989558631a 100644 --- a/tutorials/MultiQubitGates/MultiQubitGates.ipynb +++ b/tutorials/MultiQubitGates/MultiQubitGates.ipynb @@ -392,7 +392,7 @@ "\n", "#### Q# #\n", "\n", - "In Q# we describe the operation as the sequence of gates that are applied to the qubitsm regardless of whether the qubits are adjacent or not.\n", + "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.\n", "\n", "```C#\n", "operation CINOT (qs: Qubit[]) : Unit {\n", @@ -405,7 +405,7 @@ "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:\n", "\n", "$$\\text{CINOT}|\\psi\\rangle \n", - "= 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_{000} \\text{CINOT}|000\\rangle + x_{001} \\text{CINOT}|001\\rangle + x_{010} \\text{CINOT}|010\\rangle + x_{011} \\text{CINOT}|011\\rangle+$$\n", "$$+ {\\color{red}{x_{100}}} \\text{CINOT}|{\\color{red}{100}}\\rangle + {\\color{red}{x_{101}}} \\text{CINOT}|{\\color{red}{101}}\\rangle + {\\color{red}{x_{110}}} \\text{CINOT}|{\\color{red}{110}}\\rangle + {\\color{red}{x_{111}}} \\text{CINOT}|{\\color{red}{111}}\\rangle =$$\n", "$$= x_{000}|000\\rangle + x_{001}|001\\rangle + x_{010}|010\\rangle + x_{011}|011\\rangle + {\\color{red}{x_{101}}}|100\\rangle + {\\color{red}{x_{100}}}|101\\rangle + {\\color{red}{x_{111}}}|110\\rangle + {\\color{red}{x_{110}}}|111\\rangle $$\n", "\n",