Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fix math mode rendering in GitHub preview, part 1 (#814)
Browse files Browse the repository at this point in the history
Per the discussion in #809, fix the first batch of tutorials and workbooks, up to the MultiQubitGates tutorial.
  • Loading branch information
remilvus authored Aug 4, 2022
1 parent 97b4b5b commit 02916ea
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 125 deletions.
20 changes: 10 additions & 10 deletions BasicGates/BasicGates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"\n",
"**Input:** A qubit in state $|\\psi\\rangle = \\alpha |0\\rangle + \\beta |1\\rangle$.\n",
"\n",
"**Goal:** Change the qubit state to $\\alpha |0\\rangle + \\color{red}i\\beta |1\\rangle$ (add a relative phase $i$ to $|1\\rangle$ component of the superposition).\n"
"**Goal:** Change the qubit state to $\\alpha |0\\rangle + {\\color{red}i}\\beta |1\\rangle$ (add a relative phase $i$ to $|1\\rangle$ component of the superposition).\n"
]
},
{
Expand Down Expand Up @@ -251,7 +251,7 @@
"**Goal:** Change the state of the qubit as follows:\n",
"- If the qubit is in state $|0\\rangle$, don't change its state.\n",
"- If the qubit is in state $|1\\rangle$, change its state to $e^{i\\alpha} |1\\rangle$.\n",
"- If the qubit is in superposition, change its state according to the effect on basis vectors: $\\beta |0\\rangle + \\color{red}{e^{i\\alpha}} \\gamma |1\\rangle$.\n"
"- If the qubit is in superposition, change its state according to the effect on basis vectors: $\\beta |0\\rangle + {\\color{red}{e^{i\\alpha}}} \\gamma |1\\rangle$.\n"
]
},
{
Expand Down Expand Up @@ -479,10 +479,10 @@
"source": [
"### Task 2.2. Two-qubit gate - 2\n",
"\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in state $|+\\rangle \\otimes |+\\rangle = \\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle \\color{blue}+ |11\\rangle \\big)$.\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in state $|+\\rangle \\otimes |+\\rangle = \\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle {\\color{blue}+} |11\\rangle \\big)$.\n",
"\n",
"\n",
"**Goal:** Change the two-qubit state to $\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle \\color{red}- |11\\rangle \\big)$.\n",
"**Goal:** Change the two-qubit state to $\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle {\\color{red}-} |11\\rangle \\big)$.\n",
"\n",
"> Note that while the starting state can be represented as a tensor product of single-qubit states,\n",
"> the resulting two-qubit state can not be represented in such a way."
Expand Down Expand Up @@ -514,10 +514,10 @@
"source": [
"### Task 2.3. Two-qubit gate - 3\n",
"\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in an arbitrary two-qubit state $\\alpha |00\\rangle + \\color{blue}\\beta |01\\rangle + \\color{blue}\\gamma |10\\rangle + \\delta |11\\rangle$.\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in an arbitrary two-qubit state $\\alpha |00\\rangle + {\\color{blue}\\beta} |01\\rangle + {\\color{blue}\\gamma} |10\\rangle + \\delta |11\\rangle$.\n",
"\n",
"\n",
"**Goal:** Change the two-qubit state to $\\alpha |00\\rangle + \\color{red}\\gamma |01\\rangle + \\color{red}\\beta |10\\rangle + \\delta |11\\rangle$.\n",
"**Goal:** Change the two-qubit state to $\\alpha |00\\rangle + {\\color{red}\\gamma} |01\\rangle + {\\color{red}\\beta} |10\\rangle + \\delta |11\\rangle$.\n",
"\n",
"> This task can be solved using one intrinsic gate; as an exercise, try to express the solution using several (possibly controlled) Pauli gates."
]
Expand Down Expand Up @@ -549,9 +549,9 @@
"### Task 2.4. Toffoli gate\n",
"\n",
"**Input:** Three qubits (stored in an array of length 3) in an arbitrary three-qubit state \n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + \\color{blue}\\eta|110\\rangle + \\color{blue}\\theta|111\\rangle$.\n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + {\\color{blue}\\eta}|110\\rangle + {\\color{blue}\\theta}|111\\rangle$.\n",
"\n",
"**Goal:** Flip the state of the third qubit if the state of the first two is $|11\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + \\color{red}\\theta|110\\rangle + \\color{red}\\eta|111\\rangle$."
"**Goal:** Flip the state of the third qubit if the state of the first two is $|11\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + {\\color{red}\\theta}|110\\rangle + {\\color{red}\\eta}|111\\rangle$."
]
},
{
Expand Down Expand Up @@ -581,9 +581,9 @@
"### Task 2.5. Fredkin gate\n",
"\n",
"**Input:** Three qubits (stored in an array of length 3) in an arbitrary three-qubit state \n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\color{blue}\\zeta|101\\rangle + \\color{blue}\\eta|110\\rangle + \\theta|111\\rangle$.\n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + {\\color{blue}\\zeta}|101\\rangle + {\\color{blue}\\eta}|110\\rangle + \\theta|111\\rangle$.\n",
"\n",
"**Goal:** Swap the states of second and third qubit if and only if the state of the first qubit is $|1\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\color{red}\\eta|101\\rangle + \\color{red}\\zeta|110\\rangle + \\theta|111\\rangle$."
"**Goal:** Swap the states of second and third qubit if and only if the state of the first qubit is $|1\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + {\\color{red}\\eta}|101\\rangle + {\\color{red}\\zeta}|110\\rangle + \\theta|111\\rangle$."
]
},
{
Expand Down
36 changes: 18 additions & 18 deletions BasicGates/Workbook_BasicGates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
"\n",
"**Input:** A qubit in state $|\\psi\\rangle = \\alpha |0\\rangle + \\beta |1\\rangle$.\n",
"\n",
"**Goal:** Change the qubit state to $\\alpha |0\\rangle + \\color{red}i\\beta |1\\rangle$ (add a relative phase $i$ to $|1\\rangle$ component of the superposition).\n"
"**Goal:** Change the qubit state to $\\alpha |0\\rangle + {\\color{red}i}\\beta |1\\rangle$ (add a relative phase $i$ to $|1\\rangle$ component of the superposition).\n"
]
},
{
Expand Down Expand Up @@ -745,7 +745,7 @@
"**Goal:** Change the state of the qubit as follows:\n",
"- If the qubit is in state $|0\\rangle$, don't change its state.\n",
"- If the qubit is in state $|1\\rangle$, change its state to $e^{i\\alpha} |1\\rangle$.\n",
"- If the qubit is in superposition, change its state according to the effect on basis vectors: $\\beta |0\\rangle + \\color{red}{e^{i\\alpha}} \\gamma |1\\rangle$."
"- If the qubit is in superposition, change its state according to the effect on basis vectors: $\\beta |0\\rangle + {\\color{red}{e^{i\\alpha}}} \\gamma |1\\rangle$."
]
},
{
Expand Down Expand Up @@ -794,14 +794,14 @@
" =\n",
"\\begin{bmatrix}\n",
" 1.\\beta + 0.\\gamma\\\\\n",
" 0.\\beta + \\color{red}{e^{i\\alpha}}\\gamma\n",
" 0.\\beta + {\\color{red}{e^{i\\alpha}}}\\gamma\n",
" \\end{bmatrix} \n",
" =\n",
" \\begin{bmatrix}\n",
" \\beta\\\\\n",
" \\color{red}{e^{i\\alpha}}\\gamma\n",
" {\\color{red}{e^{i\\alpha}}}\\gamma\n",
" \\end{bmatrix} \n",
" = \\beta |0\\rangle + \\color{red}{e^{i\\alpha}} \\gamma |1\\rangle\n",
" = \\beta |0\\rangle + {\\color{red}{e^{i\\alpha}}} \\gamma |1\\rangle\n",
"$$"
]
},
Expand Down Expand Up @@ -1166,10 +1166,10 @@
"source": [
"## Task 2.2. Two-qubit gate - 2\n",
"\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in state $|+\\rangle \\otimes |+\\rangle = \\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle \\color{blue}+ |11\\rangle \\big)$.\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in state $|+\\rangle \\otimes |+\\rangle = \\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle {\\color{blue}+} |11\\rangle \\big)$.\n",
"\n",
"\n",
"**Goal:** Change the two-qubit state to $\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle \\color{red}- |11\\rangle \\big)$."
"**Goal:** Change the two-qubit state to $\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle {\\color{red}-} |11\\rangle \\big)$."
]
},
{
Expand Down Expand Up @@ -1278,7 +1278,7 @@
" 1\\cdot\\color{red}{e^{i\\alpha}}\\\\\n",
"\\end{bmatrix}\n",
"=\n",
"\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle \\color{red}- |11\\rangle \\big)\n",
"\\frac{1}{2} \\big( |00\\rangle + |01\\rangle + |10\\rangle {\\color{red}-} |11\\rangle \\big)\n",
"$$"
]
},
Expand Down Expand Up @@ -1337,10 +1337,10 @@
"source": [
"## Task 2.3. Two-qubit gate - 3\n",
"\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in an arbitrary two-qubit state $\\alpha |00\\rangle + \\color{blue}\\beta |01\\rangle + \\color{blue}\\gamma |10\\rangle + \\delta |11\\rangle$.\n",
"**Input:** Two unentangled qubits (stored in an array of length 2) in an arbitrary two-qubit state $\\alpha |00\\rangle + {\\color{blue}\\beta} |01\\rangle + {\\color{blue}\\gamma} |10\\rangle + \\delta |11\\rangle$.\n",
"\n",
"\n",
"**Goal:** Change the two-qubit state to $\\alpha |00\\rangle + \\color{red}\\gamma |01\\rangle + \\color{red}\\beta |10\\rangle + \\delta |11\\rangle$.\n",
"**Goal:** Change the two-qubit state to $\\alpha |00\\rangle + {\\color{red}\\gamma} |01\\rangle + {\\color{red}\\beta} |10\\rangle + \\delta |11\\rangle$.\n",
"\n",
"> This task can be solved using one intrinsic gate; as an exercise, try to express the solution using several (possibly controlled) Pauli gates."
]
Expand Down Expand Up @@ -1423,7 +1423,7 @@
" \\delta\\\\\n",
"\\end{bmatrix}\n",
"=\n",
"|00\\rangle + \\color{red}\\gamma |01\\rangle + \\color{red}\\beta |10\\rangle + \\delta |11\\rangle\n",
"|00\\rangle + {\\color{red}\\gamma} |01\\rangle + {\\color{red}\\beta} |10\\rangle + \\delta |11\\rangle\n",
"$$"
]
},
Expand Down Expand Up @@ -1533,9 +1533,9 @@
"## Task 2.4. Toffoli gate\n",
"\n",
"**Input:** Three qubits (stored in an array of length 3) in an arbitrary three-qubit state \n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + \\color{blue}\\eta|110\\rangle + \\color{blue}\\theta|111\\rangle$.\n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + {\\color{blue}\\eta}|110\\rangle + {\\color{blue}\\theta}|111\\rangle$.\n",
"\n",
"**Goal:** Flip the state of the third qubit if the state of the first two is $|11\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + \\color{red}\\theta|110\\rangle + \\color{red}\\eta|111\\rangle$.\n",
"**Goal:** Flip the state of the third qubit if the state of the first two is $|11\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + {\\color{red}\\theta}|110\\rangle + {\\color{red}\\eta}|111\\rangle$.\n",
"\n",
"### Solution\n",
"\n",
Expand Down Expand Up @@ -1629,7 +1629,7 @@
" \\color{red}\\eta\\\\ \n",
"\\end{bmatrix}\n",
"=\n",
"\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + \\color{red}\\theta|110\\rangle + \\color{red}\\eta|111\\rangle\n",
"\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\zeta|101\\rangle + {\\color{red}\\theta}|110\\rangle + {\\color{red}\\eta}|111\\rangle\n",
"$$"
]
},
Expand Down Expand Up @@ -1660,9 +1660,9 @@
"## Task 2.5. Fredkin gate\n",
"\n",
"**Input:** Three qubits (stored in an array of length 3) in an arbitrary three-qubit state \n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\color{blue}\\zeta|101\\rangle + \\color{blue}\\eta|110\\rangle + \\theta|111\\rangle$.\n",
"$\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + {\\color{blue}\\zeta}|101\\rangle + {\\color{blue}\\eta}|110\\rangle + \\theta|111\\rangle$.\n",
"\n",
"**Goal:** Swap the states of second and third qubit if and only if the state of the first qubit is $|1\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\color{red}\\eta|101\\rangle + \\color{red}\\zeta|110\\rangle + \\theta|111\\rangle$.\n",
"**Goal:** Swap the states of second and third qubit if and only if the state of the first qubit is $|1\\rangle$, i.e., change the three-qubit state to $\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + {\\color{red}\\eta}|101\\rangle + {\\color{red}\\zeta}|110\\rangle + \\theta|111\\rangle$.\n",
"\n",
"\n",
"### Solution\n",
Expand Down Expand Up @@ -1758,7 +1758,7 @@
" \\theta\\\\ \n",
"\\end{bmatrix}\n",
"=\n",
"\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + \\color{red}\\eta|101\\rangle + \\color{red}\\zeta|110\\rangle + \\theta|111\\rangle\n",
"\\alpha |000\\rangle + \\beta |001\\rangle + \\gamma |010\\rangle + \\delta |011\\rangle + \\epsilon |100\\rangle + {\\color{red}\\eta}|101\\rangle + {\\color{red}\\zeta}|110\\rangle + \\theta|111\\rangle\n",
"$$"
]
},
Expand Down Expand Up @@ -1800,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": {
Expand Down
12 changes: 6 additions & 6 deletions tutorials/ComplexArithmetic/ComplexArithmetic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
"\n",
"As we said before, $i$ can't be a real number. In that case, we'll call it an **imaginary unit**. However, there is no reason for us to define it as acting any different from any other number, other than the fact that $i^2 = -1$:\n",
"\n",
"$$i + i = 2i \\\\\n",
"i - i = 0 \\\\\n",
"-1 \\cdot i = -i \\\\\n",
"(-i)^{2} = -1$$\n",
"$$i + i = 2i$$\n",
"$$i - i = 0$$\n",
"$$-1 \\cdot i = -i$$\n",
"$$(-i)^{2} = -1$$\n",
"\n",
"We'll call the number $i$ and its real multiples **imaginary numbers**.\n",
"\n",
Expand Down Expand Up @@ -251,8 +251,8 @@
"\n",
"Another property of the conjugate is that it distributes over both complex addition and complex multiplication:\n",
"\n",
"$$\\overline{x + y} = \\overline{x} + \\overline{y} \\\\\n",
"\\overline{x \\cdot y} = \\overline{x} \\cdot \\overline{y}$$"
"$$\\overline{x + y} = \\overline{x} + \\overline{y}$$\n",
"$$\\overline{x \\cdot y} = \\overline{x} \\cdot \\overline{y}$$"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions tutorials/LinearAlgebra/LinearAlgebra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@
"\n",
"Another, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:\n",
"\n",
"$$A^{-1}(AB) = A(A^{-1}B) = B \\\\\n",
"(CA)A^{-1} = (CA^{-1})A = C$$\n",
"$$A^{-1}(AB) = A(A^{-1}B) = B$$\n",
"$$(CA)A^{-1} = (CA^{-1})A = C$$\n",
"\n",
"A square matrix has a property called the **determinant**, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.\n",
"\n",
Expand Down Expand Up @@ -948,8 +948,8 @@
" A_{n-1,0} \\cdot \\color{blue} {\\begin{bmatrix}B_{0,0} & \\dotsb & B_{0,l-1} \\\\ \\vdots & \\ddots & \\vdots \\\\ B_{k-1,0} & \\dotsb & B_{k-1,l-1} \\end{bmatrix}} & \\dotsb &\n",
" A_{n-1,m-1} \\cdot \\color{red} {\\begin{bmatrix}B_{0,0} & \\dotsb & B_{0,l-1} \\\\ \\vdots & \\ddots & \\vdots \\\\ B_{k-1,0} & \\dotsb & B_{k-1,l-1} \\end{bmatrix}}\n",
"\\end{bmatrix}\n",
"= \\\\\n",
"=\n",
"=$$\n",
"$$=\n",
"\\begin{bmatrix}\n",
" A_{0,0} \\cdot \\color{red} {B_{0,0}} & \\dotsb & A_{0,0} \\cdot \\color{red} {B_{0,l-1}} & \\dotsb & A_{0,m-1} \\cdot \\color{blue} {B_{0,0}} & \\dotsb & A_{0,m-1} \\cdot \\color{blue} {B_{0,l-1}} \\\\\n",
" \\vdots & \\ddots & \\vdots & \\dotsb & \\vdots & \\ddots & \\vdots \\\\\n",
Expand Down
Loading

0 comments on commit 02916ea

Please sign in to comment.