qsharp-lang 1.1.3 → 1.1.4-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.
Files changed (271) hide show
  1. package/dist/katas-content.generated.js +133 -122
  2. package/dist/language-service/language-service.d.ts +3 -1
  3. package/dist/language-service/language-service.js +3 -0
  4. package/dist/language-service/worker-proxy.js +1 -0
  5. package/docs/Microsoft.Quantum.Arrays/All.md +44 -0
  6. package/docs/Microsoft.Quantum.Arrays/Any.md +43 -0
  7. package/docs/Microsoft.Quantum.Arrays/Chunks.md +34 -0
  8. package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +46 -0
  9. package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +47 -0
  10. package/docs/Microsoft.Quantum.Arrays/Count.md +44 -0
  11. package/docs/Microsoft.Quantum.Arrays/Diagonal.md +43 -0
  12. package/docs/Microsoft.Quantum.Arrays/DrawMany.md +44 -0
  13. package/docs/Microsoft.Quantum.Arrays/Enumerated.md +45 -0
  14. package/docs/Microsoft.Quantum.Arrays/Excluding.md +47 -0
  15. package/docs/Microsoft.Quantum.Arrays/Filtered.md +44 -0
  16. package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +46 -0
  17. package/docs/Microsoft.Quantum.Arrays/Flattened.md +38 -0
  18. package/docs/Microsoft.Quantum.Arrays/Fold.md +47 -0
  19. package/docs/Microsoft.Quantum.Arrays/ForEach.md +43 -0
  20. package/docs/Microsoft.Quantum.Arrays/Head.md +32 -0
  21. package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +32 -0
  22. package/docs/Microsoft.Quantum.Arrays/IndexOf.md +40 -0
  23. package/docs/Microsoft.Quantum.Arrays/IndexRange.md +41 -0
  24. package/docs/Microsoft.Quantum.Arrays/Interleaved.md +49 -0
  25. package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +28 -0
  26. package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +42 -0
  27. package/docs/Microsoft.Quantum.Arrays/IsSorted.md +43 -0
  28. package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +42 -0
  29. package/docs/Microsoft.Quantum.Arrays/Mapped.md +43 -0
  30. package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +54 -0
  31. package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +48 -0
  32. package/docs/Microsoft.Quantum.Arrays/Most.md +34 -0
  33. package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +32 -0
  34. package/docs/Microsoft.Quantum.Arrays/Padded.md +50 -0
  35. package/docs/Microsoft.Quantum.Arrays/Partitioned.md +44 -0
  36. package/docs/Microsoft.Quantum.Arrays/Rest.md +34 -0
  37. package/docs/Microsoft.Quantum.Arrays/Reversed.md +34 -0
  38. package/docs/Microsoft.Quantum.Arrays/SequenceI.md +41 -0
  39. package/docs/Microsoft.Quantum.Arrays/SequenceL.md +41 -0
  40. package/docs/Microsoft.Quantum.Arrays/Sorted.md +52 -0
  41. package/docs/Microsoft.Quantum.Arrays/Subarray.md +51 -0
  42. package/docs/Microsoft.Quantum.Arrays/Swapped.md +40 -0
  43. package/docs/Microsoft.Quantum.Arrays/Tail.md +32 -0
  44. package/docs/Microsoft.Quantum.Arrays/Transposed.md +47 -0
  45. package/docs/Microsoft.Quantum.Arrays/Unzipped.md +46 -0
  46. package/docs/Microsoft.Quantum.Arrays/Where.md +36 -0
  47. package/docs/Microsoft.Quantum.Arrays/Windows.md +47 -0
  48. package/docs/Microsoft.Quantum.Arrays/Zipped.md +50 -0
  49. package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +35 -0
  50. package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +42 -0
  51. package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +41 -0
  52. package/docs/Microsoft.Quantum.Canon/ApplyP.md +39 -0
  53. package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +41 -0
  54. package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +47 -0
  55. package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +45 -0
  56. package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +34 -0
  57. package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +38 -0
  58. package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +43 -0
  59. package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +43 -0
  60. package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +43 -0
  61. package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +31 -0
  62. package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +31 -0
  63. package/docs/Microsoft.Quantum.Canon/CX.md +50 -0
  64. package/docs/Microsoft.Quantum.Canon/CY.md +44 -0
  65. package/docs/Microsoft.Quantum.Canon/CZ.md +44 -0
  66. package/docs/Microsoft.Quantum.Canon/Fst.md +20 -0
  67. package/docs/Microsoft.Quantum.Canon/Snd.md +20 -0
  68. package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +25 -0
  69. package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +36 -0
  70. package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +35 -0
  71. package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +25 -0
  72. package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +30 -0
  73. package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +30 -0
  74. package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +30 -0
  75. package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +30 -0
  76. package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +21 -0
  77. package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +36 -0
  78. package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +21 -0
  79. package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +30 -0
  80. package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +34 -0
  81. package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +30 -0
  82. package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +32 -0
  83. package/docs/Microsoft.Quantum.Core/Length.md +28 -0
  84. package/docs/Microsoft.Quantum.Core/RangeEnd.md +38 -0
  85. package/docs/Microsoft.Quantum.Core/RangeReverse.md +32 -0
  86. package/docs/Microsoft.Quantum.Core/RangeStart.md +36 -0
  87. package/docs/Microsoft.Quantum.Core/RangeStep.md +33 -0
  88. package/docs/Microsoft.Quantum.Core/Repeated.md +36 -0
  89. package/docs/Microsoft.Quantum.Diagnostics/CheckAllZero.md +18 -0
  90. package/docs/Microsoft.Quantum.Diagnostics/CheckOperationsAreEqual.md +47 -0
  91. package/docs/Microsoft.Quantum.Diagnostics/CheckZero.md +18 -0
  92. package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +18 -0
  93. package/docs/Microsoft.Quantum.Diagnostics/Fact.md +20 -0
  94. package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +35 -0
  95. package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +47 -0
  96. package/docs/Microsoft.Quantum.Intrinsic/Exp.md +40 -0
  97. package/docs/Microsoft.Quantum.Intrinsic/H.md +34 -0
  98. package/docs/Microsoft.Quantum.Intrinsic/I.md +25 -0
  99. package/docs/Microsoft.Quantum.Intrinsic/M.md +46 -0
  100. package/docs/Microsoft.Quantum.Intrinsic/Measure.md +56 -0
  101. package/docs/Microsoft.Quantum.Intrinsic/Message.md +30 -0
  102. package/docs/Microsoft.Quantum.Intrinsic/R.md +42 -0
  103. package/docs/Microsoft.Quantum.Intrinsic/R1.md +41 -0
  104. package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +57 -0
  105. package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +58 -0
  106. package/docs/Microsoft.Quantum.Intrinsic/Reset.md +27 -0
  107. package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +27 -0
  108. package/docs/Microsoft.Quantum.Intrinsic/Rx.md +44 -0
  109. package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +42 -0
  110. package/docs/Microsoft.Quantum.Intrinsic/Ry.md +44 -0
  111. package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +42 -0
  112. package/docs/Microsoft.Quantum.Intrinsic/Rz.md +44 -0
  113. package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +42 -0
  114. package/docs/Microsoft.Quantum.Intrinsic/S.md +36 -0
  115. package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +49 -0
  116. package/docs/Microsoft.Quantum.Intrinsic/T.md +36 -0
  117. package/docs/Microsoft.Quantum.Intrinsic/X.md +36 -0
  118. package/docs/Microsoft.Quantum.Intrinsic/Y.md +36 -0
  119. package/docs/Microsoft.Quantum.Intrinsic/Z.md +36 -0
  120. package/docs/Microsoft.Quantum.Logical/Xor.md +38 -0
  121. package/docs/Microsoft.Quantum.Math/AbsComplex.md +30 -0
  122. package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +30 -0
  123. package/docs/Microsoft.Quantum.Math/AbsD.md +21 -0
  124. package/docs/Microsoft.Quantum.Math/AbsI.md +21 -0
  125. package/docs/Microsoft.Quantum.Math/AbsL.md +20 -0
  126. package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +30 -0
  127. package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +30 -0
  128. package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +40 -0
  129. package/docs/Microsoft.Quantum.Math/ArcCos.md +21 -0
  130. package/docs/Microsoft.Quantum.Math/ArcCosh.md +21 -0
  131. package/docs/Microsoft.Quantum.Math/ArcSin.md +21 -0
  132. package/docs/Microsoft.Quantum.Math/ArcSinh.md +21 -0
  133. package/docs/Microsoft.Quantum.Math/ArcTan.md +21 -0
  134. package/docs/Microsoft.Quantum.Math/ArcTan2.md +21 -0
  135. package/docs/Microsoft.Quantum.Math/ArcTanh.md +21 -0
  136. package/docs/Microsoft.Quantum.Math/ArgComplex.md +30 -0
  137. package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +28 -0
  138. package/docs/Microsoft.Quantum.Math/Binom.md +34 -0
  139. package/docs/Microsoft.Quantum.Math/BitSizeI.md +23 -0
  140. package/docs/Microsoft.Quantum.Math/BitSizeL.md +23 -0
  141. package/docs/Microsoft.Quantum.Math/Ceiling.md +23 -0
  142. package/docs/Microsoft.Quantum.Math/Complex.md +31 -0
  143. package/docs/Microsoft.Quantum.Math/ComplexPolar.md +29 -0
  144. package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +25 -0
  145. package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +25 -0
  146. package/docs/Microsoft.Quantum.Math/Cos.md +21 -0
  147. package/docs/Microsoft.Quantum.Math/Cosh.md +21 -0
  148. package/docs/Microsoft.Quantum.Math/DivRemI.md +21 -0
  149. package/docs/Microsoft.Quantum.Math/DivRemL.md +21 -0
  150. package/docs/Microsoft.Quantum.Math/DividedByC.md +30 -0
  151. package/docs/Microsoft.Quantum.Math/DividedByCP.md +30 -0
  152. package/docs/Microsoft.Quantum.Math/E.md +28 -0
  153. package/docs/Microsoft.Quantum.Math/ExpModI.md +23 -0
  154. package/docs/Microsoft.Quantum.Math/ExpModL.md +23 -0
  155. package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +23 -0
  156. package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +23 -0
  157. package/docs/Microsoft.Quantum.Math/FactorialI.md +38 -0
  158. package/docs/Microsoft.Quantum.Math/FactorialL.md +32 -0
  159. package/docs/Microsoft.Quantum.Math/Floor.md +23 -0
  160. package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +23 -0
  161. package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +23 -0
  162. package/docs/Microsoft.Quantum.Math/HammingWeightI.md +21 -0
  163. package/docs/Microsoft.Quantum.Math/InverseModI.md +25 -0
  164. package/docs/Microsoft.Quantum.Math/InverseModL.md +25 -0
  165. package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +34 -0
  166. package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +34 -0
  167. package/docs/Microsoft.Quantum.Math/IsInfinite.md +49 -0
  168. package/docs/Microsoft.Quantum.Math/IsNaN.md +30 -0
  169. package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +31 -0
  170. package/docs/Microsoft.Quantum.Math/Lg.md +21 -0
  171. package/docs/Microsoft.Quantum.Math/Log.md +21 -0
  172. package/docs/Microsoft.Quantum.Math/Log10.md +21 -0
  173. package/docs/Microsoft.Quantum.Math/LogFactorialD.md +35 -0
  174. package/docs/Microsoft.Quantum.Math/LogGammaD.md +39 -0
  175. package/docs/Microsoft.Quantum.Math/LogOf2.md +24 -0
  176. package/docs/Microsoft.Quantum.Math/Max.md +28 -0
  177. package/docs/Microsoft.Quantum.Math/MaxD.md +21 -0
  178. package/docs/Microsoft.Quantum.Math/MaxI.md +21 -0
  179. package/docs/Microsoft.Quantum.Math/MaxL.md +21 -0
  180. package/docs/Microsoft.Quantum.Math/Min.md +28 -0
  181. package/docs/Microsoft.Quantum.Math/MinD.md +21 -0
  182. package/docs/Microsoft.Quantum.Math/MinI.md +21 -0
  183. package/docs/Microsoft.Quantum.Math/MinL.md +21 -0
  184. package/docs/Microsoft.Quantum.Math/MinusC.md +30 -0
  185. package/docs/Microsoft.Quantum.Math/MinusCP.md +30 -0
  186. package/docs/Microsoft.Quantum.Math/ModulusI.md +23 -0
  187. package/docs/Microsoft.Quantum.Math/ModulusL.md +23 -0
  188. package/docs/Microsoft.Quantum.Math/NegationC.md +28 -0
  189. package/docs/Microsoft.Quantum.Math/NegationCP.md +28 -0
  190. package/docs/Microsoft.Quantum.Math/PI.md +28 -0
  191. package/docs/Microsoft.Quantum.Math/PNorm.md +34 -0
  192. package/docs/Microsoft.Quantum.Math/PNormalized.md +39 -0
  193. package/docs/Microsoft.Quantum.Math/PlusC.md +30 -0
  194. package/docs/Microsoft.Quantum.Math/PlusCP.md +30 -0
  195. package/docs/Microsoft.Quantum.Math/PowC.md +32 -0
  196. package/docs/Microsoft.Quantum.Math/PowCP.md +32 -0
  197. package/docs/Microsoft.Quantum.Math/RealMod.md +38 -0
  198. package/docs/Microsoft.Quantum.Math/Round.md +23 -0
  199. package/docs/Microsoft.Quantum.Math/SignD.md +21 -0
  200. package/docs/Microsoft.Quantum.Math/SignI.md +21 -0
  201. package/docs/Microsoft.Quantum.Math/SignL.md +21 -0
  202. package/docs/Microsoft.Quantum.Math/Sin.md +21 -0
  203. package/docs/Microsoft.Quantum.Math/Sinh.md +21 -0
  204. package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +30 -0
  205. package/docs/Microsoft.Quantum.Math/Sqrt.md +21 -0
  206. package/docs/Microsoft.Quantum.Math/SquaredNorm.md +32 -0
  207. package/docs/Microsoft.Quantum.Math/Tan.md +21 -0
  208. package/docs/Microsoft.Quantum.Math/Tanh.md +21 -0
  209. package/docs/Microsoft.Quantum.Math/TimesC.md +30 -0
  210. package/docs/Microsoft.Quantum.Math/TimesCP.md +30 -0
  211. package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +23 -0
  212. package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +23 -0
  213. package/docs/Microsoft.Quantum.Math/Truncate.md +23 -0
  214. package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +28 -0
  215. package/docs/Microsoft.Quantum.Measurement/MResetX.md +37 -0
  216. package/docs/Microsoft.Quantum.Measurement/MResetY.md +37 -0
  217. package/docs/Microsoft.Quantum.Measurement/MResetZ.md +37 -0
  218. package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +36 -0
  219. package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +30 -0
  220. package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +36 -0
  221. package/docs/Microsoft.Quantum.Random/DrawRandomDouble.md +40 -0
  222. package/docs/Microsoft.Quantum.Random/DrawRandomInt.md +40 -0
  223. package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +35 -0
  224. package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +23 -0
  225. package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +39 -0
  226. package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +36 -0
  227. package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +23 -0
  228. package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +25 -0
  229. package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +22 -0
  230. package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +23 -0
  231. package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +25 -0
  232. package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +32 -0
  233. package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +23 -0
  234. package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +23 -0
  235. package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +23 -0
  236. package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +23 -0
  237. package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +29 -0
  238. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +23 -0
  239. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +25 -0
  240. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +23 -0
  241. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +25 -0
  242. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +23 -0
  243. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +25 -0
  244. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +23 -0
  245. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +25 -0
  246. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +23 -0
  247. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +25 -0
  248. package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +32 -0
  249. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +27 -0
  250. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +27 -0
  251. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +27 -0
  252. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +27 -0
  253. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +36 -0
  254. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +27 -0
  255. package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +36 -0
  256. package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +34 -0
  257. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +37 -0
  258. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +34 -0
  259. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +34 -0
  260. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +35 -0
  261. package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +68 -0
  262. package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +65 -0
  263. package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +53 -0
  264. package/docs/toc.yml +305 -0
  265. package/lib/node/qsc_wasm.cjs +40 -13
  266. package/lib/node/qsc_wasm.d.cts +15 -0
  267. package/lib/node/qsc_wasm_bg.wasm +0 -0
  268. package/lib/web/qsc_wasm.d.ts +17 -0
  269. package/lib/web/qsc_wasm.js +38 -11
  270. package/lib/web/qsc_wasm_bg.wasm +0 -0
  271. package/package.json +4 -2
@@ -59,8 +59,8 @@ export default {
59
59
  "items": [
60
60
  {
61
61
  "type": "text-content",
62
- "asHtml": "<p>This kata introduces you to one of the core concepts in quantum computing - the qubit, and its representation in mathematical notation and in Q# code.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>The concept of a qubit</li>\n<li>Superposition</li>\n<li>Vector representation of qubit states</li>\n<li>Dirac notation</li>\n<li>Relative and global phase</li>\n<li><code>Qubit</code> data type in Q#</li>\n<li>Visualizing the quantum state using <code>DumpMachine</code></li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Complex arithmetic</li>\n<li>Linear algebra</li>\n</ul>\n",
63
- "asMarkdown": "\nThis kata introduces you to one of the core concepts in quantum computing - the qubit, and its representation in mathematical notation and in Q# code.\n\n**This kata covers the following topics:**\n\n- The concept of a qubit\n- Superposition\n- Vector representation of qubit states\n- Dirac notation\n- Relative and global phase\n- `Qubit` data type in Q#\n- Visualizing the quantum state using `DumpMachine`\n\n**What you should know to start working on this kata:**\n\n- Complex arithmetic\n- Linear algebra"
62
+ "asHtml": "<p>This kata introduces you to one of the core concepts in quantum computing - the qubit, and its representation in mathematical notation and in Q# code.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>The concept of a qubit</li>\n<li>Superposition</li>\n<li>Vector representation of qubit states</li>\n<li>Dirac notation for single-qubit states</li>\n<li>Relative and global phase</li>\n<li><code>Qubit</code> data type in Q#</li>\n<li>Visualizing the quantum state using <code>DumpMachine</code></li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Complex arithmetic</li>\n<li>Linear algebra</li>\n</ul>\n",
63
+ "asMarkdown": "\nThis kata introduces you to one of the core concepts in quantum computing - the qubit, and its representation in mathematical notation and in Q# code.\n\n**This kata covers the following topics:**\n\n- The concept of a qubit\n- Superposition\n- Vector representation of qubit states\n- Dirac notation for single-qubit states\n- Relative and global phase\n- `Qubit` data type in Q#\n- Visualizing the quantum state using `DumpMachine`\n\n**What you should know to start working on this kata:**\n\n- Complex arithmetic\n- Linear algebra"
64
64
  }
65
65
  ]
66
66
  },
@@ -71,8 +71,8 @@ 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>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$\\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
- "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$\\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>."
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 an irreversible 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$\\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 weights $\\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
+ "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 an irreversible 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$\\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 weights $\\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
  ]
78
78
  },
@@ -83,8 +83,8 @@ export default {
83
83
  "items": [
84
84
  {
85
85
  "type": "text-content",
86
- "asHtml": "<p>Dirac notation is a shorthand notation that eases writing quantum states and computing linear algebra. In Dirac notation, a vector is denoted by a symbol called a <strong>ket</strong>. For example, a qubit in state $0$ is represented by the ket $|0\\rangle$, and a qubit in state $1$ is represented by the ket $|1\\rangle$:</p>\n<table>\n <tr>\n <td>$$|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$|1\\rangle = \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\n<p>These two kets represent basis states, so they can be used to represent any other state:</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Dirac notation is not only restricted to vectors $0$ and $1$, but it can be used to represent any arbitrary vector. For example the vector $\\psi$ can be written as:</p>\n<p>$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Other examples of vector states represented in Dirac notation are:</p>\n<table>\n <tr>\n <td>$$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$$</td>\n <td>$$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</td>\n </tr>\n <tr>\n <td>$$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$$</td>\n <td>$$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$$</td>\n </tr>\n</table>\n\n<p>We will learn more about Dirac notation in the next katas, as we introduce quantum gates and multi-qubit systems.</p>\n",
87
- "asMarkdown": "\nDirac notation is a shorthand notation that eases writing quantum states and computing linear algebra. In Dirac notation, a vector is denoted by a symbol called a **ket**. For example, a qubit in state $0$ is represented by the ket $|0\\rangle$, and a qubit in state $1$ is represented by the ket $|1\\rangle$:\n\n<table>\n <tr>\n <td>$$|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$|1\\rangle = \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\nThese two kets represent basis states, so they can be used to represent any other state:\n\n$$\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nDirac notation is not only restricted to vectors $0$ and $1$, but it can be used to represent any arbitrary vector. For example the vector $\\psi$ can be written as:\n\n$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nOther examples of vector states represented in Dirac notation are:\n\n<table>\n <tr>\n <td>$$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$$</td>\n <td>$$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</td>\n </tr>\n <tr>\n <td>$$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$$</td>\n <td>$$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$$</td>\n </tr>\n</table>\n\nWe will learn more about Dirac notation in the next katas, as we introduce quantum gates and multi-qubit systems."
86
+ "asHtml": "<p>Dirac notation is a shorthand notation that eases writing quantum states and computing linear algebra. In Dirac notation, a vector is denoted by a symbol called a <strong>ket</strong>. For example, a qubit in state $0$ is represented by the ket $|0\\rangle$, and a qubit in state $1$ is represented by the ket $|1\\rangle$:</p>\n<table>\n <tr>\n <td>$$|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$|1\\rangle = \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\n<p>These two kets represent basis states, so they can be used to represent any other state:</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Dirac notation is not only restricted to vectors $0$ and $1$; it can be used to represent any vector, simiar to how variable names are used in algebra. For example, we can call the state above &quot;the state $\\psi$&quot; and write it as:</p>\n<p>$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$</p>\n<p>Several ket symbols have a generally accepted use, so you will see them often:</p>\n<table>\n <tr>\n <td>$$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$$</td>\n <td>$$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</td>\n </tr>\n <tr>\n <td>$$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$$</td>\n <td>$$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$$</td>\n </tr>\n</table>\n\n<p>We will learn more about Dirac notation in the next katas, as we introduce quantum gates and multi-qubit systems.</p>\n",
87
+ "asMarkdown": "\nDirac notation is a shorthand notation that eases writing quantum states and computing linear algebra. In Dirac notation, a vector is denoted by a symbol called a **ket**. For example, a qubit in state $0$ is represented by the ket $|0\\rangle$, and a qubit in state $1$ is represented by the ket $|1\\rangle$:\n\n<table>\n <tr>\n <td>$$|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix}$$</td>\n <td>$$|1\\rangle = \\begin{bmatrix} 0 \\\\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\nThese two kets represent basis states, so they can be used to represent any other state:\n\n$$\\begin{bmatrix} \\alpha \\\\\\ \\beta \\end{bmatrix} = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nDirac notation is not only restricted to vectors $0$ and $1$; it can be used to represent any vector, simiar to how variable names are used in algebra. For example, we can call the state above \"the state $\\psi$\" and write it as:\n\n$$|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$$\n\nSeveral ket symbols have a generally accepted use, so you will see them often:\n\n<table>\n <tr>\n <td>$$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$$</td>\n <td>$$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$$</td>\n </tr>\n <tr>\n <td>$$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$$</td>\n <td>$$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$$</td>\n </tr>\n</table>\n\nWe will learn more about Dirac notation in the next katas, as we introduce quantum gates and multi-qubit systems."
88
88
  }
89
89
  ]
90
90
  },
@@ -95,8 +95,8 @@ export default {
95
95
  "items": [
96
96
  {
97
97
  "type": "text-content",
98
- "asHtml": "<p>Complex numbers have a parameter called the phase. If a complex number $z = x + iy$ is written in polar form $z = re^{i\\theta}$, its phase is $\\theta$ where $\\theta = tan^{-1}(\\frac{y}{x})$.</p>\n<p>The probability amplitudes $\\alpha$ and $\\beta$ are complex numbers, therefore $\\alpha$ and $\\beta$ have a phase. For example, consider a qubit in state $\\frac{1 + i}{2}|0\\rangle + \\frac{1 - i}{2}|1\\rangle$. If you do the math, you see that $\\theta = tan^{-1}(1) = \\frac{\\pi}{4}$. Thus, the phase of $|0\\rangle$ is $\\frac{\\pi}{4}$, and the phase of $|1\\rangle$ is $-\\frac{\\pi}{4}$. The difference between these two phases is known as <strong>relative phase</strong>.</p>\n<p>Multiplying the state of the entire system by $e^{i\\theta}$ doesn&#39;t affect the relative phase: $\\alpha|0\\rangle + \\beta|1\\rangle$ has the same relative phase as $e^{i\\theta}\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big)$. In the second expression, $\\theta$ is known as the system&#39;s <strong>global phase</strong>.</p>\n<p>The state of a qubit (or, more generally, the state of a quantum system) is defined by its relative phase - global phase arises as a consequence of using linear algebra to represent qubits, and has no physical meaning. That is, applying a phase to the entire state of a system (multiplying the entire vector by $e^{i\\theta}$ for any real $\\theta$) doesn&#39;t actually affect the state of the system. Because of this, global phase is sometimes known as <strong>unobservable phase</strong> or <strong>hidden phase</strong>.</p>\n",
99
- "asMarkdown": "\nComplex numbers have a parameter called the phase. If a complex number $z = x + iy$ is written in polar form $z = re^{i\\theta}$, its phase is $\\theta$ where $\\theta = tan^{-1}(\\frac{y}{x})$.\n\nThe probability amplitudes $\\alpha$ and $\\beta$ are complex numbers, therefore $\\alpha$ and $\\beta$ have a phase. For example, consider a qubit in state $\\frac{1 + i}{2}|0\\rangle + \\frac{1 - i}{2}|1\\rangle$. If you do the math, you see that $\\theta = tan^{-1}(1) = \\frac{\\pi}{4}$. Thus, the phase of $|0\\rangle$ is $\\frac{\\pi}{4}$, and the phase of $|1\\rangle$ is $-\\frac{\\pi}{4}$. The difference between these two phases is known as **relative phase**.\n\nMultiplying the state of the entire system by $e^{i\\theta}$ doesn't affect the relative phase: $\\alpha|0\\rangle + \\beta|1\\rangle$ has the same relative phase as $e^{i\\theta}\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big)$. In the second expression, $\\theta$ is known as the system's **global phase**.\n\nThe state of a qubit (or, more generally, the state of a quantum system) is defined by its relative phase - global phase arises as a consequence of using linear algebra to represent qubits, and has no physical meaning. That is, applying a phase to the entire state of a system (multiplying the entire vector by $e^{i\\theta}$ for any real $\\theta$) doesn't actually affect the state of the system. Because of this, global phase is sometimes known as **unobservable phase** or **hidden phase**."
98
+ "asHtml": "<p>Complex numbers have a parameter called the phase. If a complex number $z = x + iy$ is written in polar form $z = re^{i\\theta}$, its phase is $\\theta$, where $\\theta = \\atan2(y, x)$.</p>\n<blockquote>\n<p><code>atan2</code> is a useful function available in most programming languages. It takes two arguments and returns an angle $\\theta$\nbetween $-\\pi$ and $\\pi$ that has $\\cos \\theta = x$ and $\\sin \\theta = y$. Unlike using $\\tan^{-1}(\\frac{y}{x})$, <code>atan2</code> computes \nthe correct quadrant for the angle, since it preserves information about the signs of both sine and cosine of the angle.</p>\n</blockquote>\n<p>The probability amplitudes $\\alpha$ and $\\beta$ are complex numbers, therefore $\\alpha$ and $\\beta$ have a phase. For example, consider a qubit in state $\\frac{1 + i}{2}|0\\rangle + \\frac{1 - i}{2}|1\\rangle$. If you do the math, you see that the phase of $|0\\rangle$ is $\\atan2(\\frac12, \\frac12) = \\frac{\\pi}{4}$, and the phase of $|1\\rangle$ is $\\atan2(\\frac12, -\\frac12) = -\\frac{\\pi}{4}$. The difference between these two phases is known as <strong>relative phase</strong>.</p>\n<p>Multiplying the state of the entire system by $e^{i\\theta}$ doesn&#39;t affect the relative phase: $\\alpha|0\\rangle + \\beta|1\\rangle$ has the same relative phase as $e^{i\\theta}\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big)$. In the second expression, $\\theta$ is known as the system&#39;s <strong>global phase</strong>.</p>\n<p>The state of a qubit (or, more generally, the state of a quantum system) is defined by its relative phase - global phase arises as a consequence of using linear algebra to represent qubits, and has no physical meaning. That is, applying a phase to the entire state of a system (multiplying the entire vector by $e^{i\\theta}$ for any real $\\theta$) doesn&#39;t actually affect the state of the system. Because of this, global phase is sometimes known as <strong>unobservable phase</strong> or <strong>hidden phase</strong>.</p>\n",
99
+ "asMarkdown": "\nComplex numbers have a parameter called the phase. If a complex number $z = x + iy$ is written in polar form $z = re^{i\\theta}$, its phase is $\\theta$, where $\\theta = \\atan2(y, x)$.\n\n> `atan2` is a useful function available in most programming languages. It takes two arguments and returns an angle $\\theta$\n> between $-\\pi$ and $\\pi$ that has $\\cos \\theta = x$ and $\\sin \\theta = y$. Unlike using $\\tan^{-1}(\\frac{y}{x})$, `atan2` computes \n> the correct quadrant for the angle, since it preserves information about the signs of both sine and cosine of the angle.\n\nThe probability amplitudes $\\alpha$ and $\\beta$ are complex numbers, therefore $\\alpha$ and $\\beta$ have a phase. For example, consider a qubit in state $\\frac{1 + i}{2}|0\\rangle + \\frac{1 - i}{2}|1\\rangle$. If you do the math, you see that the phase of $|0\\rangle$ is $\\atan2(\\frac12, \\frac12) = \\frac{\\pi}{4}$, and the phase of $|1\\rangle$ is $\\atan2(\\frac12, -\\frac12) = -\\frac{\\pi}{4}$. The difference between these two phases is known as **relative phase**.\n\nMultiplying the state of the entire system by $e^{i\\theta}$ doesn't affect the relative phase: $\\alpha|0\\rangle + \\beta|1\\rangle$ has the same relative phase as $e^{i\\theta}\\big(\\alpha|0\\rangle + \\beta|1\\rangle\\big)$. In the second expression, $\\theta$ is known as the system's **global phase**.\n\nThe state of a qubit (or, more generally, the state of a quantum system) is defined by its relative phase - global phase arises as a consequence of using linear algebra to represent qubits, and has no physical meaning. That is, applying a phase to the entire state of a system (multiplying the entire vector by $e^{i\\theta}$ for any real $\\theta$) doesn't actually affect the state of the system. Because of this, global phase is sometimes known as **unobservable phase** or **hidden phase**."
100
100
  }
101
101
  ]
102
102
  },
@@ -107,8 +107,8 @@ 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>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
- "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#!"
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. The <code>use</code> statement allocates a qubit (or multiple) that can be used until the end of the scope in which the statement was used: <code>use q = Qubit();</code> allocates a qubit and binds it to the variable <code>q</code>.</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 <code>DumpMachine</code> function from the <code>Microsoft.Quantum.Diagnostics</code> namespace 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
+ "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. The `use` statement allocates a qubit (or multiple) that can be used until the end of the scope in which the statement was used: `use q = Qubit();` allocates a qubit and binds it to the variable `q`.\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 `DumpMachine` function from the `Microsoft.Quantum.Diagnostics` namespace 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
  {
114
114
  "type": "example",
@@ -125,7 +125,7 @@ export default {
125
125
  {
126
126
  "type": "exercise",
127
127
  "id": "qubit__learn_single_qubit_state",
128
- "title": "Learn the State of a Single Qubit",
128
+ "title": "Learn the State of a Single Qubit Using DumpMachine",
129
129
  "description": {
130
130
  "type": "text-content",
131
131
  "asHtml": "<p><strong>Input:</strong> A qubit in an unknown state $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$. The amplitudes $\\alpha$ and $\\beta$ will be real and non-negative.</p>\n<p><strong>Output:</strong> A tuple of two numbers $(\\alpha&#39;, \\beta&#39;)$ - your estimates of the amplitudes $\\alpha$ and $\\beta$.\nThe absolute errors $|\\alpha - \\alpha&#39;|$ and $|\\beta - \\beta&#39;|$ should be less than or equal to 0.001.</p>\n<p>Please note that the state parameter is guaranteed to be the same\nif you run the code several times. Your operation will be called\nonce for every run.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n On a physical quantum system, there would be no way to obtain the values of $\\alpha$ and $\\beta$ from a single observation. Since this program runs on a simulator, we can use <code>DumpMachine</code> to inspect the qubit and take a note of its state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again.\n</details>\n",
@@ -152,53 +152,6 @@ export default {
152
152
  ]
153
153
  }
154
154
  },
155
- {
156
- "type": "lesson",
157
- "id": "qubit__visualizing_multi_qubit",
158
- "title": "Display the Quantum State of a Multi-Qubit Program",
159
- "items": [
160
- {
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>Demo: DumpMachine for Multi-Qubit Systems</h2>\n",
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
- },
165
- {
166
- "type": "example",
167
- "id": "qubit__multi_qubit_dump_machine_demo",
168
- "code": "namespace Kata {\n open Microsoft.Quantum.Diagnostics;\n\n @EntryPoint()\n operation MultiQubitDumpMachineDemo() : Unit {\n // This line allocates two qubits in state |00⟩.\n use qs = Qubit[2];\n Message(\"State |00⟩:\");\n\n // This line prints out the state of the quantum system.\n DumpMachine();\n\n // X gate changes the second qubit into state |1⟩.\n // The entire system is now in state |01⟩, or, in little-endian notation, |2⟩.\n X(qs[1]);\n Message(\"State |01⟩:\");\n DumpMachine();\n\n CNOT(qs[1], qs[0]);\n Rx(1.0, qs[0]);\n Ry(2.0, qs[1]);\n Rz(3.0, qs[1]);\n\n Message(\"Uneven superposition state:\");\n DumpMachine();\n\n // This line returns the qubits to state |0⟩ before releasing them.\n ResetAll(qs);\n }\n}\n"
169
- }
170
- ]
171
- },
172
- {
173
- "type": "exercise",
174
- "id": "qubit__learn_basis_state_amplitudes",
175
- "title": "Learn Basis State Amplitudes",
176
- "description": {
177
- "type": "text-content",
178
- "asHtml": "<p><strong>Input:</strong> 2 qubits in an unknown state $|\\psi\\rangle = \\sum_{k = 0}^{3} x_k |k\\rangle$. The amplitudes $x_k$ will be real and non-negative.</p>\n<p><strong>Output:</strong> A tuple of two numbers $(x_1&#39;, x_2&#39;)$ - your estimates of the amplitudes of the state $|1\\rangle$ and $|2\\rangle$, respectively.\nThe absolute errors $|x_1 - x_1&#39;|$ and $|x_2 - x_2&#39;|$ should be less than or equal to 0.001.</p>\n<p>Please note that the state parameter is guaranteed to be the same\nif you run the code several times. Your operation will be called\nonce for every run.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, we can use <code>DumpMachine</code> to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again.\n</details>\n",
179
- "asMarkdown": "\n**Input:** 2 qubits in an unknown state $|\\psi\\rangle = \\sum_{k = 0}^{3} x_k |k\\rangle$. The amplitudes $x_k$ will be real and non-negative.\n\n**Output:** A tuple of two numbers $(x_1', x_2')$ - your estimates of the amplitudes of the state $|1\\rangle$ and $|2\\rangle$, respectively.\nThe absolute errors $|x_1 - x_1'|$ and $|x_2 - x_2'|$ should be less than or equal to 0.001.\n\nPlease note that the state parameter is guaranteed to be the same\nif you run the code several times. Your operation will be called\nonce for every run.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, we can use <code>DumpMachine</code> to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again.\n</details>\n"
180
- },
181
- "sourceIds": [
182
- "KatasLibrary.qs",
183
- "qubit__learn_basis_state_amplitudes__Verification.qs"
184
- ],
185
- "placeholderCode": "namespace Kata {\n operation LearnBasisStateAmplitudes(qs : Qubit[]) : (Double, Double) {\n // Implement your solution here...\n\n return (0.0, 0.0);\n }\n}\n",
186
- "explainedSolution": {
187
- "type": "explained-solution",
188
- "items": [
189
- {
190
- "type": "text-content",
191
- "asHtml": "<p>Learn the amplitudes $x_k$ by calling <code>DumpMachine</code> and return the values shown in the output of this function.</p>\n",
192
- "asMarkdown": "\nLearn the amplitudes $x_k$ by calling `DumpMachine` and return the values shown in the output of this function."
193
- },
194
- {
195
- "type": "solution",
196
- "id": "qubit__learn_basis_state_amplitudes_solution",
197
- "code": "namespace Kata {\n open Microsoft.Quantum.Diagnostics;\n\n operation LearnBasisStateAmplitudes(qs : Qubit[]) : (Double, Double) {\n DumpMachine(); // Only used to learn the amplitudes.\n return (0.3821, 0.339);\n }\n}\n"
198
- }
199
- ]
200
- }
201
- },
202
155
  {
203
156
  "type": "lesson",
204
157
  "id": "qubit__conclusion",
@@ -260,8 +213,8 @@ export default {
260
213
  "items": [
261
214
  {
262
215
  "type": "text-content",
263
- "asHtml": "<p>This section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section is not necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later.</p>\n<p>You can use the properties of <em>eigenvalues</em> and <em>eigenvectors</em> to find the ket-bra decomposition of any gate. Given a gate $A$ and the orthogonal vectors $|\\phi\\rangle$ and $|\\psi\\rangle$, if:</p>\n<p>$$A|\\phi\\rangle = x_\\phi|\\phi\\rangle$$\n$$A|\\psi\\rangle = x_\\psi|\\psi\\rangle$$</p>\n<p>Real numbers $x_\\phi$ and $x_\\psi$ are called eigenvalues and $|\\phi\\rangle$ and $|\\psi\\rangle$ are eigenvectors of $A$. Then:</p>\n<p>$$A = x_\\phi|\\phi\\rangle\\langle\\phi| + x_\\psi|\\psi\\rangle\\langle\\psi|$$</p>\n<p>Let&#39;s use our $X$ gate as a simple example. The $X$ gate has two eigenvectors: $|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and $|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$. Their eigenvalues are $1$ and $-1$ respectively:</p>\n<p>$$X|+\\rangle = |+\\rangle$$\n$$X|-\\rangle = -|-\\rangle$$</p>\n<p>Here&#39;s what the decomposition looks like:\n$$X = |+\\rangle\\langle+| - |-\\rangle\\langle-| =$$\n$$\\frac{1}{2}\\big[\\big(|0\\rangle + |1\\rangle\\big)\\big(\\langle0| + \\langle1|\\big) - \\big(|0\\rangle - |1\\rangle\\big)\\big(\\langle0| - \\langle1|\\big)\\big] =$$\n$$\\frac{1}{2}\\big(|0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| + |1\\rangle\\langle1| - |0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| - |1\\rangle\\langle1|\\big) =$$\n$$\\frac{1}{2}\\big(2|0\\rangle\\langle1| + 2|1\\rangle\\langle0|\\big) =$$\n$$|0\\rangle\\langle1| + |1\\rangle\\langle0|$$</p>\n",
264
- "asMarkdown": "\nThis section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section is not necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later.\n\nYou can use the properties of _eigenvalues_ and _eigenvectors_ to find the ket-bra decomposition of any gate. Given a gate $A$ and the orthogonal vectors $|\\phi\\rangle$ and $|\\psi\\rangle$, if:\n\n$$A|\\phi\\rangle = x_\\phi|\\phi\\rangle$$\n$$A|\\psi\\rangle = x_\\psi|\\psi\\rangle$$\n\nReal numbers $x_\\phi$ and $x_\\psi$ are called eigenvalues and $|\\phi\\rangle$ and $|\\psi\\rangle$ are eigenvectors of $A$. Then:\n\n$$A = x_\\phi|\\phi\\rangle\\langle\\phi| + x_\\psi|\\psi\\rangle\\langle\\psi|$$\n\nLet's use our $X$ gate as a simple example. The $X$ gate has two eigenvectors: $|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and $|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$. Their eigenvalues are $1$ and $-1$ respectively:\n\n$$X|+\\rangle = |+\\rangle$$\n$$X|-\\rangle = -|-\\rangle$$\n\nHere's what the decomposition looks like:\n$$X = |+\\rangle\\langle+| - |-\\rangle\\langle-| =$$\n$$\\frac{1}{2}\\big[\\big(|0\\rangle + |1\\rangle\\big)\\big(\\langle0| + \\langle1|\\big) - \\big(|0\\rangle - |1\\rangle\\big)\\big(\\langle0| - \\langle1|\\big)\\big] =$$\n$$\\frac{1}{2}\\big(|0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| + |1\\rangle\\langle1| - |0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| - |1\\rangle\\langle1|\\big) =$$\n$$\\frac{1}{2}\\big(2|0\\rangle\\langle1| + 2|1\\rangle\\langle0|\\big) =$$\n$$|0\\rangle\\langle1| + |1\\rangle\\langle0|$$"
216
+ "asHtml": "<p>This section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section is not necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later.</p>\n<p>You can use the properties of <em>eigenvalues</em> and <em>eigenvectors</em> to find the ket-bra decomposition of any gate. Given a gate $A$ and the orthogonal vectors $|\\phi\\rangle$ and $|\\psi\\rangle$, if:</p>\n<p>$$A|\\phi\\rangle = x_\\phi|\\phi\\rangle$$\n$$A|\\psi\\rangle = x_\\psi|\\psi\\rangle$$</p>\n<p>Real numbers $x_\\phi$ and $x_\\psi$ are called eigenvalues and $|\\phi\\rangle$ and $|\\psi\\rangle$ are eigenvectors of $A$. Then:</p>\n<p>$$A = x_\\phi|\\phi\\rangle\\langle\\phi| + x_\\psi|\\psi\\rangle\\langle\\psi|$$</p>\n<p>Let&#39;s use our $X$ gate as a simple example. The $X$ gate has two eigenvectors: $|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and $|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$. Their eigenvalues are $1$ and $-1$ respectively:</p>\n<p>$$X|+\\rangle = |+\\rangle$$\n$$X|-\\rangle = -|-\\rangle$$</p>\n<p>Here&#39;s what the decomposition looks like:\n$$X = |+\\rangle\\langle+| - |-\\rangle\\langle-| =$$\n$$= \\frac{1}{2}\\big[\\big(|0\\rangle + |1\\rangle\\big)\\big(\\langle0| + \\langle1|\\big) - \\big(|0\\rangle - |1\\rangle\\big)\\big(\\langle0| - \\langle1|\\big)\\big] =$$\n$$= \\frac{1}{2}\\big(|0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| + |1\\rangle\\langle1| - |0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| - |1\\rangle\\langle1|\\big) =$$\n$$= \\frac{1}{2}\\big(2|0\\rangle\\langle1| + 2|1\\rangle\\langle0|\\big) =$$\n$$= |0\\rangle\\langle1| + |1\\rangle\\langle0|$$</p>\n",
217
+ "asMarkdown": "\nThis section describes a more formal process of finding the ket-bra decompositions of quantum gates. This section is not necessary to start working with quantum gates, so feel free to skip it for now, and come back to it later.\n\nYou can use the properties of _eigenvalues_ and _eigenvectors_ to find the ket-bra decomposition of any gate. Given a gate $A$ and the orthogonal vectors $|\\phi\\rangle$ and $|\\psi\\rangle$, if:\n\n$$A|\\phi\\rangle = x_\\phi|\\phi\\rangle$$\n$$A|\\psi\\rangle = x_\\psi|\\psi\\rangle$$\n\nReal numbers $x_\\phi$ and $x_\\psi$ are called eigenvalues and $|\\phi\\rangle$ and $|\\psi\\rangle$ are eigenvectors of $A$. Then:\n\n$$A = x_\\phi|\\phi\\rangle\\langle\\phi| + x_\\psi|\\psi\\rangle\\langle\\psi|$$\n\nLet's use our $X$ gate as a simple example. The $X$ gate has two eigenvectors: $|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and $|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$. Their eigenvalues are $1$ and $-1$ respectively:\n\n$$X|+\\rangle = |+\\rangle$$\n$$X|-\\rangle = -|-\\rangle$$\n\nHere's what the decomposition looks like:\n$$X = |+\\rangle\\langle+| - |-\\rangle\\langle-| =$$\n$$= \\frac{1}{2}\\big[\\big(|0\\rangle + |1\\rangle\\big)\\big(\\langle0| + \\langle1|\\big) - \\big(|0\\rangle - |1\\rangle\\big)\\big(\\langle0| - \\langle1|\\big)\\big] =$$\n$$= \\frac{1}{2}\\big(|0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| + |1\\rangle\\langle1| - |0\\rangle\\langle0| + |0\\rangle\\langle1| + |1\\rangle\\langle0| - |1\\rangle\\langle1|\\big) =$$\n$$= \\frac{1}{2}\\big(2|0\\rangle\\langle1| + 2|1\\rangle\\langle0|\\big) =$$\n$$= |0\\rangle\\langle1| + |1\\rangle\\langle0|$$"
265
218
  }
266
219
  ]
267
220
  },
@@ -272,8 +225,8 @@ export default {
272
225
  "items": [
273
226
  {
274
227
  "type": "text-content",
275
- "asHtml": "<p>This section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief &quot;cheatsheet&quot; listing their effect on some common qubit states.</p>\n<p>You can use a tool called <a href=\"https://algassert.com/quirk\" target=\"_blank\">Quirk</a> to visualize how these gates interact with various qubit states.</p>\n<p>This section relies on the following notation:</p>\n<table>\n <tr>\n <td>$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$</td>\n <td>$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$</td>\n </tr>\n <tr>\n <td>$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$</td>\n <td>$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$</td>\n </tr>\n</table>\n\n<p>The Pauli gates, named after <a href=\"https://en.wikipedia.org/wiki/Wolfgang_Pauli\" target=\"_blank\">Wolfgang Pauli</a>, are based on the so-called <strong>Pauli matrices</strong>, $X$, $Y$ and $Z$. All three Pauli gates are <strong>self-adjoint</strong>, meaning that each one is its own inverse, $XX = \\mathbb{I}$.</p>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$X$</td>\n <td>$\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle1| + |1\\rangle\\langle0|$</td>\n <td>$X|\\psi\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$</td>\n <td>\n $X|0\\rangle = |1\\rangle$<br>\n $X|1\\rangle = |0\\rangle$<br>\n $X|+\\rangle = |+\\rangle$<br>\n $X|-\\rangle = -|-\\rangle$<br>\n $X|i\\rangle = i|-i\\rangle$<br>\n $X|-i\\rangle = -i|i\\rangle$\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.x\" target=\"_blank\">X</a></td>\n </tr>\n <tr>\n <td>$Y$</td>\n <td>$\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}$</td>\n <td>$i(|1\\rangle\\langle0| - |0\\rangle\\langle1|)$</td>\n <td>$Y|\\psi\\rangle = i\\big(\\alpha|1\\rangle - \\beta|0\\rangle\\big)$</td>\n <td>\n $Y|0\\rangle = i|1\\rangle$<br>\n $Y|1\\rangle = -i|0\\rangle$<br>\n $Y|+\\rangle = -i|-\\rangle$<br>\n $Y|-\\rangle = i|+\\rangle$<br>\n $Y|i\\rangle = |i\\rangle$<br>\n $Y|-i\\rangle = -|-i\\rangle$<br>\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.y\" target=\"_blank\">Y</a></td>\n </tr>\n <tr>\n <td>$Z$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| - |1\\rangle\\langle1|$</td>\n <td>$Z|\\psi\\rangle = \\alpha|0\\rangle - \\beta|1\\rangle$</td>\n <td>\n $Z|0\\rangle = |0\\rangle$<br>\n $Z|1\\rangle = -|1\\rangle$<br>\n $Z|+\\rangle = |-\\rangle$<br>\n $Z|-\\rangle = |+\\rangle$<br>\n $Z|i\\rangle = |-i\\rangle$<br>\n $Z|-i\\rangle = |i\\rangle$<br>\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.z\" target=\"_blank\">Z</a></td>\n </tr>\n</table>\n\n<blockquote>\n<p>The $X$ gate is sometimes referred to as the <strong>bit flip</strong> gate, or the <strong>NOT</strong> gate, because it acts like the classical NOT gate on the computational basis.</p>\n<p>The $Z$ gate is sometimes referred to as the <strong>phase flip</strong> gate.</p>\n</blockquote>\n<p>Here are several properties of the Pauli gates that are easy to verify and convenient to remember:</p>\n<ul>\n<li>Different Pauli gates <em>anti-commute</em>:\n$$XZ = -ZX, XY = -YX, YZ = -ZY$$</li>\n<li>A product of any two Pauli gates equals the third gate, with an extra $i$ (or $-i$) phase:\n$$XY = iZ, YZ = iX, ZX = iY$$ </li>\n<li>A product of all three Pauli gates equals identity (with an extra $i$ phase):\n$$XYZ = iI$$</li>\n</ul>\n",
276
- "asMarkdown": "\nThis section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief \"cheatsheet\" listing their effect on some common qubit states.\n\nYou can use a tool called <a href=\"https://algassert.com/quirk\" target=\"_blank\">Quirk</a> to visualize how these gates interact with various qubit states.\n\nThis section relies on the following notation:\n\n<table>\n <tr>\n <td>$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$</td>\n <td>$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$</td>\n </tr>\n <tr>\n <td>$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$</td>\n <td>$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$</td>\n </tr>\n</table>\n\nThe Pauli gates, named after <a href=\"https://en.wikipedia.org/wiki/Wolfgang_Pauli\" target=\"_blank\">Wolfgang Pauli</a>, are based on the so-called **Pauli matrices**, $X$, $Y$ and $Z$. All three Pauli gates are **self-adjoint**, meaning that each one is its own inverse, $XX = \\mathbb{I}$.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$X$</td>\n <td>$\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle1| + |1\\rangle\\langle0|$</td>\n <td>$X|\\psi\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$</td>\n <td>\n $X|0\\rangle = |1\\rangle$<br>\n $X|1\\rangle = |0\\rangle$<br>\n $X|+\\rangle = |+\\rangle$<br>\n $X|-\\rangle = -|-\\rangle$<br>\n $X|i\\rangle = i|-i\\rangle$<br>\n $X|-i\\rangle = -i|i\\rangle$\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.x\" target=\"_blank\">X</a></td>\n </tr>\n <tr>\n <td>$Y$</td>\n <td>$\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}$</td>\n <td>$i(|1\\rangle\\langle0| - |0\\rangle\\langle1|)$</td>\n <td>$Y|\\psi\\rangle = i\\big(\\alpha|1\\rangle - \\beta|0\\rangle\\big)$</td>\n <td>\n $Y|0\\rangle = i|1\\rangle$<br>\n $Y|1\\rangle = -i|0\\rangle$<br>\n $Y|+\\rangle = -i|-\\rangle$<br>\n $Y|-\\rangle = i|+\\rangle$<br>\n $Y|i\\rangle = |i\\rangle$<br>\n $Y|-i\\rangle = -|-i\\rangle$<br>\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.y\" target=\"_blank\">Y</a></td>\n </tr>\n <tr>\n <td>$Z$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| - |1\\rangle\\langle1|$</td>\n <td>$Z|\\psi\\rangle = \\alpha|0\\rangle - \\beta|1\\rangle$</td>\n <td>\n $Z|0\\rangle = |0\\rangle$<br>\n $Z|1\\rangle = -|1\\rangle$<br>\n $Z|+\\rangle = |-\\rangle$<br>\n $Z|-\\rangle = |+\\rangle$<br>\n $Z|i\\rangle = |-i\\rangle$<br>\n $Z|-i\\rangle = |i\\rangle$<br>\n </td>\n <td><a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic.z\" target=\"_blank\">Z</a></td>\n </tr>\n</table>\n\n> The $X$ gate is sometimes referred to as the **bit flip** gate, or the **NOT** gate, because it acts like the classical NOT gate on the computational basis.\n>\n> The $Z$ gate is sometimes referred to as the **phase flip** gate.\n\nHere are several properties of the Pauli gates that are easy to verify and convenient to remember:\n\n- Different Pauli gates *anti-commute*:\n $$XZ = -ZX, XY = -YX, YZ = -ZY$$\n- A product of any two Pauli gates equals the third gate, with an extra $i$ (or $-i$) phase:\n $$XY = iZ, YZ = iX, ZX = iY$$ \n- A product of all three Pauli gates equals identity (with an extra $i$ phase):\n $$XYZ = iI$$"
228
+ "asHtml": "<p>This section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief &quot;cheatsheet&quot; listing their effect on some common qubit states.</p>\n<p>You can use a tool called <a href=\"https://algassert.com/quirk\" target=\"_blank\">Quirk</a> to visualize how these gates interact with various qubit states.</p>\n<p>This section relies on the following notation:</p>\n<table>\n <tr>\n <td>$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$</td>\n <td>$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$</td>\n </tr>\n <tr>\n <td>$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$</td>\n <td>$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$</td>\n </tr>\n</table>\n\n<p>The Pauli gates, named after <a href=\"https://en.wikipedia.org/wiki/Wolfgang_Pauli\" target=\"_blank\">Wolfgang Pauli</a>, are based on the so-called <strong>Pauli matrices</strong>, $X$, $Y$ and $Z$. All three Pauli gates are <strong>self-adjoint</strong>, meaning that each one is its own inverse, $XX = \\mathbb{I}$.</p>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$X$</td>\n <td>$\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle1| + |1\\rangle\\langle0|$</td>\n <td>$X|\\psi\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$</td>\n <td>\n $X|0\\rangle = |1\\rangle$<br>\n $X|1\\rangle = |0\\rangle$<br>\n $X|+\\rangle = |+\\rangle$<br>\n $X|-\\rangle = -|-\\rangle$<br>\n $X|i\\rangle = i|-i\\rangle$<br>\n $X|-i\\rangle = -i|i\\rangle$\n </td>\n </tr>\n <tr>\n <td>$Y$</td>\n <td>$\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}$</td>\n <td>$i(|1\\rangle\\langle0| - |0\\rangle\\langle1|)$</td>\n <td>$Y|\\psi\\rangle = i\\big(\\alpha|1\\rangle - \\beta|0\\rangle\\big)$</td>\n <td>\n $Y|0\\rangle = i|1\\rangle$<br>\n $Y|1\\rangle = -i|0\\rangle$<br>\n $Y|+\\rangle = -i|-\\rangle$<br>\n $Y|-\\rangle = i|+\\rangle$<br>\n $Y|i\\rangle = |i\\rangle$<br>\n $Y|-i\\rangle = -|-i\\rangle$<br>\n </td>\n </tr>\n <tr>\n <td>$Z$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| - |1\\rangle\\langle1|$</td>\n <td>$Z|\\psi\\rangle = \\alpha|0\\rangle - \\beta|1\\rangle$</td>\n <td>\n $Z|0\\rangle = |0\\rangle$<br>\n $Z|1\\rangle = -|1\\rangle$<br>\n $Z|+\\rangle = |-\\rangle$<br>\n $Z|-\\rangle = |+\\rangle$<br>\n $Z|i\\rangle = |-i\\rangle$<br>\n $Z|-i\\rangle = |i\\rangle$<br>\n </td>\n </tr>\n</table>\n\n<blockquote>\n<p>The $X$ gate is sometimes referred to as the <strong>bit flip</strong> gate, or the <strong>NOT</strong> gate, because it acts like the classical NOT gate on the computational basis.</p>\n<p>The $Z$ gate is sometimes referred to as the <strong>phase flip</strong> gate.</p>\n</blockquote>\n<p>Here are several properties of the Pauli gates that are easy to verify and convenient to remember:</p>\n<ul>\n<li>Different Pauli gates <em>anti-commute</em>:\n$$XZ = -ZX, XY = -YX, YZ = -ZY$$</li>\n<li>A product of any two Pauli gates equals the third gate, with an extra $i$ (or $-i$) phase:\n$$XY = iZ, YZ = iX, ZX = iY$$ </li>\n<li>A product of all three Pauli gates equals identity (with an extra $i$ phase):\n$$XYZ = iI$$</li>\n</ul>\n",
229
+ "asMarkdown": "\nThis section introduces some of the common single-qubit gates, including their matrix form, their ket-bra decomposition, and a brief \"cheatsheet\" listing their effect on some common qubit states.\n\nYou can use a tool called <a href=\"https://algassert.com/quirk\" target=\"_blank\">Quirk</a> to visualize how these gates interact with various qubit states.\n\nThis section relies on the following notation:\n\n<table>\n <tr>\n <td>$|+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$</td>\n <td>$|-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - |1\\rangle\\big)$</td>\n </tr>\n <tr>\n <td>$|i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle + i|1\\rangle\\big)$</td>\n <td>$|-i\\rangle = \\frac{1}{\\sqrt{2}}\\big(|0\\rangle - i|1\\rangle\\big)$</td>\n </tr>\n</table>\n\nThe Pauli gates, named after <a href=\"https://en.wikipedia.org/wiki/Wolfgang_Pauli\" target=\"_blank\">Wolfgang Pauli</a>, are based on the so-called **Pauli matrices**, $X$, $Y$ and $Z$. All three Pauli gates are **self-adjoint**, meaning that each one is its own inverse, $XX = \\mathbb{I}$.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$X$</td>\n <td>$\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle1| + |1\\rangle\\langle0|$</td>\n <td>$X|\\psi\\rangle = \\alpha|1\\rangle + \\beta|0\\rangle$</td>\n <td>\n $X|0\\rangle = |1\\rangle$<br>\n $X|1\\rangle = |0\\rangle$<br>\n $X|+\\rangle = |+\\rangle$<br>\n $X|-\\rangle = -|-\\rangle$<br>\n $X|i\\rangle = i|-i\\rangle$<br>\n $X|-i\\rangle = -i|i\\rangle$\n </td>\n </tr>\n <tr>\n <td>$Y$</td>\n <td>$\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}$</td>\n <td>$i(|1\\rangle\\langle0| - |0\\rangle\\langle1|)$</td>\n <td>$Y|\\psi\\rangle = i\\big(\\alpha|1\\rangle - \\beta|0\\rangle\\big)$</td>\n <td>\n $Y|0\\rangle = i|1\\rangle$<br>\n $Y|1\\rangle = -i|0\\rangle$<br>\n $Y|+\\rangle = -i|-\\rangle$<br>\n $Y|-\\rangle = i|+\\rangle$<br>\n $Y|i\\rangle = |i\\rangle$<br>\n $Y|-i\\rangle = -|-i\\rangle$<br>\n </td>\n </tr>\n <tr>\n <td>$Z$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| - |1\\rangle\\langle1|$</td>\n <td>$Z|\\psi\\rangle = \\alpha|0\\rangle - \\beta|1\\rangle$</td>\n <td>\n $Z|0\\rangle = |0\\rangle$<br>\n $Z|1\\rangle = -|1\\rangle$<br>\n $Z|+\\rangle = |-\\rangle$<br>\n $Z|-\\rangle = |+\\rangle$<br>\n $Z|i\\rangle = |-i\\rangle$<br>\n $Z|-i\\rangle = |i\\rangle$<br>\n </td>\n </tr>\n</table>\n\n> The $X$ gate is sometimes referred to as the **bit flip** gate, or the **NOT** gate, because it acts like the classical NOT gate on the computational basis.\n>\n> The $Z$ gate is sometimes referred to as the **phase flip** gate.\n\nHere are several properties of the Pauli gates that are easy to verify and convenient to remember:\n\n- Different Pauli gates *anti-commute*:\n $$XZ = -ZX, XY = -YX, YZ = -ZY$$\n- A product of any two Pauli gates equals the third gate, with an extra $i$ (or $-i$) phase:\n $$XY = iZ, YZ = iX, ZX = iY$$ \n- A product of all three Pauli gates equals identity (with an extra $i$ phase):\n $$XYZ = iI$$"
277
230
  }
278
231
  ]
279
232
  },
@@ -284,8 +237,8 @@ export default {
284
237
  "items": [
285
238
  {
286
239
  "type": "text-content",
287
- "asHtml": "<p>The following example contains code demonstrating how to apply gates in Q#, using the Pauli $X$ gate as an example. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one.</p>\n<p>In the previous kata we discussed that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit, but doesn&#39;t return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don&#39;t produce any output.</p>\n<p>The same principle applies to successive qubit gates. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $|\\psi\\rangle$ is denoted as $Z(X(|\\psi\\rangle))$ because the result of applying a gate to a state is another state. In Q#, applying a gate doesn&#39;t return anything, so you can&#39;t use its output as an input to another gate - something like <code>Z(X(q))</code> will not produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they are applied:</p>\n<pre><code class=\"language-qsharp\">X(q);\nZ(q);\n</code></pre>\n<p>All the basic gates we will be covering in this kata are part of the <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic\" target=\"_blank\">Intrinsic</a> namespace. We&#39;re also using the function <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics.dumpmachine\" target=\"_blank\">DumpMachine</a> to print the state of the quantum simulator.</p>\n",
288
- "asMarkdown": "\nThe following example contains code demonstrating how to apply gates in Q#, using the Pauli $X$ gate as an example. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one.\n\nIn the previous kata we discussed that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit, but doesn't return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don't produce any output.\n\nThe same principle applies to successive qubit gates. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $|\\psi\\rangle$ is denoted as $Z(X(|\\psi\\rangle))$ because the result of applying a gate to a state is another state. In Q#, applying a gate doesn't return anything, so you can't use its output as an input to another gate - something like `Z(X(q))` will not produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they are applied:\n\n```qsharp\nX(q);\nZ(q);\n```\n\nAll the basic gates we will be covering in this kata are part of the <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic\" target=\"_blank\">Intrinsic</a> namespace. We're also using the function <a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.diagnostics.dumpmachine\" target=\"_blank\">DumpMachine</a> to print the state of the quantum simulator."
240
+ "asHtml": "<p>The following example contains code demonstrating how to apply gates in Q#. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one.</p>\n<p>In the previous kata we discussed that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit, but doesn&#39;t return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don&#39;t produce any output.</p>\n<p>The same principle applies to applying several gates in a row to a qubit. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $|\\psi\\rangle$ is denoted as $Z(X(|\\psi\\rangle))$, because the result of applying a gate to a state is another state. In Q#, applying a gate doesn&#39;t return anything, so you can&#39;t use its output as an input to another gate - something like <code>Z(X(q))</code> will not produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they are applied:</p>\n<pre><code class=\"language-qsharp\">X(q);\nZ(q);\n</code></pre>\n<p>All the basic gates we will be covering in this kata are part of the Intrinsic namespace. We&#39;re also using the function DumpMachine to print the state of the quantum simulator.</p>\n",
241
+ "asMarkdown": "\nThe following example contains code demonstrating how to apply gates in Q#. It sets up a series of quantum states, and then shows the result of applying the $X$ gate to each one.\n\nIn the previous kata we discussed that qubit state in Q# cannot be directly assigned or accessed. The same logic is extended to quantum gates: applying a gate to a qubit modifies the internal state of that qubit, but doesn't return the resulting state of the qubit. This is why we never assign the output of these gates to any variables in this demo - they don't produce any output.\n\nThe same principle applies to applying several gates in a row to a qubit. In the mathematical notation, applying an $X$ gate followed by a $Z$ gate to a state $|\\psi\\rangle$ is denoted as $Z(X(|\\psi\\rangle))$, because the result of applying a gate to a state is another state. In Q#, applying a gate doesn't return anything, so you can't use its output as an input to another gate - something like `Z(X(q))` will not produce the expected result. Instead, to apply several gates to the same qubit, you need to call them separately in the order in which they are applied:\n\n```qsharp\nX(q);\nZ(q);\n```\n\nAll the basic gates we will be covering in this kata are part of the Intrinsic namespace. We're also using the function DumpMachine to print the state of the quantum simulator."
289
242
  },
290
243
  {
291
244
  "type": "example",
@@ -343,13 +296,13 @@ export default {
343
296
  "items": [
344
297
  {
345
298
  "type": "text-content",
346
- "asHtml": "<p>We need to apply a gate which applies a global phase of $i$, i.e. $|\\psi\\rangle \\rightarrow i|\\psi\\rangle$.\nThe matrix representation of such a gate is $\\begin{bmatrix} i &amp; 0 \\\\ 0 &amp; i \\end{bmatrix} = i\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} = iI$.\nSince we are restricted to the Pauli gates, we use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase: $-iXYZ=I$. This can be restated as $XYZ = iI$.\n$$\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\\begin{bmatrix} 0 &amp; -i \\\\ i &amp; 0 \\end{bmatrix}\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix} = \n\\begin{bmatrix} i &amp; 0 \\\\ 0 &amp; i \\end{bmatrix}\n$$</p>\n<blockquote>\n<p>Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence we first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate.</p>\n</blockquote>\n",
347
- "asMarkdown": "\nWe need to apply a gate which applies a global phase of $i$, i.e. $|\\psi\\rangle \\rightarrow i|\\psi\\rangle$.\nThe matrix representation of such a gate is $\\begin{bmatrix} i & 0 \\\\\\ 0 & i \\end{bmatrix} = i\\begin{bmatrix} 1 & 0 \\\\\\ 0 & 1 \\end{bmatrix} = iI$.\nSince we are restricted to the Pauli gates, we use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase: $-iXYZ=I$. This can be restated as $XYZ = iI$.\n$$\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix} = \n\\begin{bmatrix} i & 0 \\\\\\ 0 & i \\end{bmatrix}\n$$\n\n> Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence we first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate."
299
+ "asHtml": "<p>We need to apply a gate which applies a global phase of $i$, i.e. $|\\psi\\rangle \\rightarrow i|\\psi\\rangle$.\nThe matrix representation of such a gate is $\\begin{bmatrix} i &amp; 0 \\\\ 0 &amp; i \\end{bmatrix} = i\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} = iI$.\nSince we are restricted to the Pauli gates, we use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase, therefore the product of all three Pauli gates is $XYZ = iI$.\n$$\n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}\\begin{bmatrix} 0 &amp; -i \\\\ i &amp; 0 \\end{bmatrix}\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix} = \n\\begin{bmatrix} i &amp; 0 \\\\ 0 &amp; i \\end{bmatrix}\n$$</p>\n<blockquote>\n<p>Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence we first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate.</p>\n</blockquote>\n",
300
+ "asMarkdown": "\nWe need to apply a gate which applies a global phase of $i$, i.e. $|\\psi\\rangle \\rightarrow i|\\psi\\rangle$.\nThe matrix representation of such a gate is $\\begin{bmatrix} i & 0 \\\\\\ 0 & i \\end{bmatrix} = i\\begin{bmatrix} 1 & 0 \\\\\\ 0 & 1 \\end{bmatrix} = iI$.\nSince we are restricted to the Pauli gates, we use the property that a product of any two distinct Pauli gates equals the third gate with a $+i$ or a $-i$ global phase, therefore the product of all three Pauli gates is $XYZ = iI$.\n$$\n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix}\\begin{bmatrix} 0 & -i \\\\\\ i & 0 \\end{bmatrix}\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix} = \n\\begin{bmatrix} i & 0 \\\\\\ 0 & i \\end{bmatrix}\n$$\n\n> Remember the rightmost gates in mathematical notation are applied first in Q# code. Hence we first apply the $Z$ gate, followed by the $Y$ gate, and finally the $X$ gate."
348
301
  },
349
302
  {
350
303
  "type": "solution",
351
304
  "id": "single_qubit_gates__global_phase_i_solution",
352
- "code": "namespace Kata {\n operation GlobalPhaseI(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n Y(q);\n }\n}"
305
+ "code": "namespace Kata {\n operation GlobalPhaseI(q : Qubit) : Unit is Adj + Ctl {\n Z(q);\n Y(q);\n X(q);\n }\n}"
353
306
  }
354
307
  ]
355
308
  }
@@ -373,8 +326,8 @@ export default {
373
326
  "items": [
374
327
  {
375
328
  "type": "text-content",
376
- "asHtml": "<p>The first thing to notice is that the gate $\\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix}$ is quite similar to the Pauli $Z$ gate $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix}$.\nThe only difference being that the negative phase is applied on the $|0\\rangle$ instead of $|1\\rangle$. Hence we can simulate this gate by switching $|0\\rangle$ and $|1\\rangle$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate (also called the $NOT$ gate or the bit flip gate) is the perfect gate to flip the state of the qubit and to undo the action afterwards.</p>\n<p>Hence we can express the $Z_0 = \\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix}$ matrix as</p>\n<p>$$\nZ_0 =\n\\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} = \n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix} \\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} = \nXZX\n$$</p>\n",
377
- "asMarkdown": "\nThe first thing to notice is that the gate $\\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix}$ is quite similar to the Pauli $Z$ gate $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$.\nThe only difference being that the negative phase is applied on the $|0\\rangle$ instead of $|1\\rangle$. Hence we can simulate this gate by switching $|0\\rangle$ and $|1\\rangle$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate (also called the $NOT$ gate or the bit flip gate) is the perfect gate to flip the state of the qubit and to undo the action afterwards.\n\nHence we can express the $Z_0 = \\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix}$ matrix as\n\n$$\nZ_0 =\n\\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix} = \n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix} \\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} = \nXZX\n$$"
329
+ "asHtml": "<p>The first thing to notice is that the gate $\\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix}$ is quite similar to the Pauli $Z$ gate $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix}$.\nThe only difference being that the negative phase is applied on the $|0\\rangle$ instead of $|1\\rangle$. Hence we can simulate this gate by switching $|0\\rangle$ and $|1\\rangle$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate is the perfect gate to flip the state of the qubit and to undo the action afterwards.</p>\n<p>Hence we can express the $Z_0 = \\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix}$ matrix as</p>\n<p>$$\nZ_0 =\n\\begin{bmatrix} -1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} = \n\\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix} \\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix} = \nXZX\n$$</p>\n",
330
+ "asMarkdown": "\nThe first thing to notice is that the gate $\\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix}$ is quite similar to the Pauli $Z$ gate $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix}$.\nThe only difference being that the negative phase is applied on the $|0\\rangle$ instead of $|1\\rangle$. Hence we can simulate this gate by switching $|0\\rangle$ and $|1\\rangle$ states, applying the Pauli $Z$ gate and switching them back. The Pauli $X$ gate is the perfect gate to flip the state of the qubit and to undo the action afterwards.\n\nHence we can express the $Z_0 = \\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix}$ matrix as\n\n$$\nZ_0 =\n\\begin{bmatrix} -1 & 0 \\\\\\ 0 & 1 \\end{bmatrix} = \n\\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & -1 \\end{bmatrix} \\begin{bmatrix} 0 & 1 \\\\\\ 1 & 0 \\end{bmatrix} = \nXZX\n$$"
378
331
  },
379
332
  {
380
333
  "type": "solution",
@@ -384,6 +337,30 @@ export default {
384
337
  ]
385
338
  }
386
339
  },
340
+ {
341
+ "type": "lesson",
342
+ "id": "identity_gate",
343
+ "title": "Identity Gate",
344
+ "items": [
345
+ {
346
+ "type": "text-content",
347
+ "asHtml": "<p>The identity gate is mostly here for completeness, at least for now. It will come in handy when dealing with multi-qubit systems and multi-qubit gates. It is represented by the identity matrix, and does not affect the state of the qubit.</p>\n<table>\n<tr>\n<th>Gate</th>\n<th>Matrix</th>\n<th>Ket-Bra</th>\n<th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n</tr>\n<tr>\n<td>$I$</td>\n<td>$\\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}$</td>\n<td>$|0\\rangle\\langle0| + |1\\rangle\\langle1|$</td>\n<td>$I|\\psi\\rangle = |\\psi\\rangle$</td>\n</tr>\n</table>",
348
+ "asMarkdown": "\nThe identity gate is mostly here for completeness, at least for now. It will come in handy when dealing with multi-qubit systems and multi-qubit gates. It is represented by the identity matrix, and does not affect the state of the qubit.\n \n<table>\n<tr>\n<th>Gate</th>\n<th>Matrix</th>\n<th>Ket-Bra</th>\n<th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n</tr>\n<tr>\n<td>$I$</td>\n<td>$\\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}$</td>\n<td>$|0\\rangle\\langle0| + |1\\rangle\\langle1|$</td>\n<td>$I|\\psi\\rangle = |\\psi\\rangle$</td>\n</tr>\n</table>"
349
+ }
350
+ ]
351
+ },
352
+ {
353
+ "type": "lesson",
354
+ "id": "hadamard_gate",
355
+ "title": "Hadamard Gate",
356
+ "items": [
357
+ {
358
+ "type": "text-content",
359
+ "asHtml": "<p>The <strong>Hadamard</strong> gate is an extremely important quantum gate. Unlike the previous gates, applying the Hadamard gate to a qubit in a computational basis state puts that qubit into a superposition.\nLike the Pauli gates, the Hadamard gate is self-adjoint.</p>\n<table>\n<tr>\n<th>Gate</th>\n<th>Matrix</th>\n<th>Ket-Bra</th>\n<th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n<th>Applying to basis states</th>\n</tr>\n<tr>\n<td>$H$</td>\n<td>$\\begin{bmatrix} \\frac{1}{\\sqrt{2}} & \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} & -\\frac{1}{\\sqrt{2}} \\end{bmatrix} = \\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 & 1 \\\\ 1 & -1 \\end{bmatrix}$</td>\n<td>$|0\\rangle\\langle+| + |1\\rangle\\langle-|$</td>\n<td>$H|\\psi\\rangle = \\alpha|+\\rangle + \\beta|-\\rangle = \\frac{\\alpha + \\beta}{\\sqrt{2}}|0\\rangle + \\frac{\\alpha - \\beta}{\\sqrt{2}}|1\\rangle$</td>\n<td>$H|0\\rangle = |+\\rangle$ <br>\n$H|1\\rangle = |-\\rangle$ <br>\n$H|+\\rangle = |0\\rangle$ <br>\n$H|-\\rangle = |1\\rangle$ <br>\n$H|i\\rangle = e^{i\\pi/4}|-i\\rangle$ <br>\n$H|-i\\rangle = e^{-i\\pi/4}|i\\rangle $ <br>\n</tr>\n</table>\n\n<blockquote>\n<p>As a reminder, $e^{i\\pi/4} = \\frac{1}{\\sqrt2} (1 + i)$ and $e^{-i\\pi/4} = \\frac{1}{\\sqrt2} (1 - i)$. This is an application of Euler&#39;s formula, $e^{i\\theta} = \\cos \\theta + i\\sin \\theta$, where $\\theta$ is measured in radians.\nSee this <a href=\"https://en.wikipedia.org/wiki/Euler%27s_formula\">Wikipedia article</a> for an explanation of Euler&#39;s formula and/or <a href=\"https://youtu.be/v0YEaeIClKY\">this video</a> for a more intuitive explanation.</p>\n</blockquote>\n",
360
+ "asMarkdown": "\nThe **Hadamard** gate is an extremely important quantum gate. Unlike the previous gates, applying the Hadamard gate to a qubit in a computational basis state puts that qubit into a superposition.\nLike the Pauli gates, the Hadamard gate is self-adjoint.\n\n<table>\n<tr>\n<th>Gate</th>\n<th>Matrix</th>\n<th>Ket-Bra</th>\n<th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n<th>Applying to basis states</th>\n</tr>\n<tr>\n<td>$H$</td>\n<td>$\\begin{bmatrix} \\frac{1}{\\sqrt{2}} & \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} & -\\frac{1}{\\sqrt{2}} \\end{bmatrix} = \\frac{1}{\\sqrt{2}}\\begin{bmatrix} 1 & 1 \\\\ 1 & -1 \\end{bmatrix}$</td>\n<td>$|0\\rangle\\langle+| + |1\\rangle\\langle-|$</td>\n<td>$H|\\psi\\rangle = \\alpha|+\\rangle + \\beta|-\\rangle = \\frac{\\alpha + \\beta}{\\sqrt{2}}|0\\rangle + \\frac{\\alpha - \\beta}{\\sqrt{2}}|1\\rangle$</td>\n<td>$H|0\\rangle = |+\\rangle$ <br>\n$H|1\\rangle = |-\\rangle$ <br>\n$H|+\\rangle = |0\\rangle$ <br>\n$H|-\\rangle = |1\\rangle$ <br>\n$H|i\\rangle = e^{i\\pi/4}|-i\\rangle$ <br>\n$H|-i\\rangle = e^{-i\\pi/4}|i\\rangle $ <br>\n</tr>\n</table>\n\n> As a reminder, $e^{i\\pi/4} = \\frac{1}{\\sqrt2} (1 + i)$ and $e^{-i\\pi/4} = \\frac{1}{\\sqrt2} (1 - i)$. This is an application of Euler's formula, $e^{i\\theta} = \\cos \\theta + i\\sin \\theta$, where $\\theta$ is measured in radians.\n> See this [Wikipedia article](https://en.wikipedia.org/wiki/Euler%27s_formula) for an explanation of Euler's formula and/or [this video](https://youtu.be/v0YEaeIClKY) for a more intuitive explanation."
361
+ }
362
+ ]
363
+ },
387
364
  {
388
365
  "type": "exercise",
389
366
  "id": "single_qubit_gates__prepare_minus",
@@ -421,8 +398,8 @@ export default {
421
398
  "items": [
422
399
  {
423
400
  "type": "text-content",
424
- "asHtml": "<p>The next two gates are known as phase shift gates. They apply a phase to the $|1\\rangle$ state, and leave the $|0\\rangle$ state unchanged.</p>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$S$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & i \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + i|1\\rangle\\langle1|$</td>\n <td>$S|\\psi\\rangle = \\alpha|0\\rangle + i\\beta|1\\rangle$</td>\n <td>\n $S|0\\rangle = |0\\rangle$<br>\n $S|1\\rangle = i|1\\rangle$<br>\n $S|+\\rangle = |i\\rangle$<br>\n $S|-\\rangle = |-i\\rangle$<br>\n $S|i\\rangle = |-\\rangle$<br>\n $S|-i\\rangle = |+\\rangle$<br>\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.s\" target=\"_blank\">S</a></td>\n </tr>\n <tr>\n <td>$T$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + e^{i\\pi/4}|1\\rangle$$\\langle1|$</td>\n <td>$T|\\psi\\rangle = \\alpha|0\\rangle + e^{i\\pi/4} \\beta |1\\rangle$</td>\n <td>\n $T|0\\rangle = |0\\rangle$<br>\n $T|1\\rangle = e^{i\\pi/4}|1\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.t\" target=\"_blank\">T</a></td>\n </tr>\n</table>\n\n<blockquote>\n<p>Notice that applying the $T$ gate twice is equivalent to applying the $S$ gate, and applying the $S$ gate twice is equivalent to applying the $Z$ gate: \n$$T^2 = S, S^2 = Z$$</p>\n</blockquote>\n",
425
- "asMarkdown": "\nThe next two gates are known as phase shift gates. They apply a phase to the $|1\\rangle$ state, and leave the $|0\\rangle$ state unchanged.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$S$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & i \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + i|1\\rangle\\langle1|$</td>\n <td>$S|\\psi\\rangle = \\alpha|0\\rangle + i\\beta|1\\rangle$</td>\n <td>\n $S|0\\rangle = |0\\rangle$<br>\n $S|1\\rangle = i|1\\rangle$<br>\n $S|+\\rangle = |i\\rangle$<br>\n $S|-\\rangle = |-i\\rangle$<br>\n $S|i\\rangle = |-\\rangle$<br>\n $S|-i\\rangle = |+\\rangle$<br>\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.s\" target=\"_blank\">S</a></td>\n </tr>\n <tr>\n <td>$T$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + e^{i\\pi/4}|1\\rangle$$\\langle1|$</td>\n <td>$T|\\psi\\rangle = \\alpha|0\\rangle + e^{i\\pi/4} \\beta |1\\rangle$</td>\n <td>\n $T|0\\rangle = |0\\rangle$<br>\n $T|1\\rangle = e^{i\\pi/4}|1\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.t\" target=\"_blank\">T</a></td>\n </tr>\n</table>\n\n> Notice that applying the $T$ gate twice is equivalent to applying the $S$ gate, and applying the $S$ gate twice is equivalent to applying the $Z$ gate: \n$$T^2 = S, S^2 = Z$$"
401
+ "asHtml": "<p>The next two gates are known as phase shift gates. They apply a phase to the $|1\\rangle$ state, and leave the $|0\\rangle$ state unchanged.</p>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$S$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\ 0 & i \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + i|1\\rangle\\langle1|$</td>\n <td>$S|\\psi\\rangle = \\alpha|0\\rangle + i\\beta|1\\rangle$</td>\n <td>\n $S|0\\rangle = |0\\rangle$<br>\n $S|1\\rangle = i|1\\rangle$<br>\n $S|+\\rangle = |i\\rangle$<br>\n $S|-\\rangle = |-i\\rangle$<br>\n $S|i\\rangle = |-\\rangle$<br>\n $S|-i\\rangle = |+\\rangle$<br>\n </td>\n </tr>\n <tr>\n <td>$T$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + e^{i\\pi/4}|1\\rangle$$\\langle1|$</td>\n <td>$T|\\psi\\rangle = \\alpha|0\\rangle + e^{i\\pi/4} \\beta |1\\rangle$</td>\n <td>\n $T|0\\rangle = |0\\rangle$<br>\n $T|1\\rangle = e^{i\\pi/4}|1\\rangle$\n </td>\n </tr>\n</table>\n\n<blockquote>\n<p>Notice that applying the $T$ gate twice is equivalent to applying the $S$ gate, and applying the $S$ gate twice is equivalent to applying the $Z$ gate: \n$$T^2 = S, S^2 = Z$$</p>\n</blockquote>\n",
402
+ "asMarkdown": "\nThe next two gates are known as phase shift gates. They apply a phase to the $|1\\rangle$ state, and leave the $|0\\rangle$ state unchanged.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Ket-Bra</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$S$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\ 0 & i \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + i|1\\rangle\\langle1|$</td>\n <td>$S|\\psi\\rangle = \\alpha|0\\rangle + i\\beta|1\\rangle$</td>\n <td>\n $S|0\\rangle = |0\\rangle$<br>\n $S|1\\rangle = i|1\\rangle$<br>\n $S|+\\rangle = |i\\rangle$<br>\n $S|-\\rangle = |-i\\rangle$<br>\n $S|i\\rangle = |-\\rangle$<br>\n $S|-i\\rangle = |+\\rangle$<br>\n </td>\n </tr>\n <tr>\n <td>$T$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$</td>\n <td>$|0\\rangle\\langle0| + e^{i\\pi/4}|1\\rangle$$\\langle1|$</td>\n <td>$T|\\psi\\rangle = \\alpha|0\\rangle + e^{i\\pi/4} \\beta |1\\rangle$</td>\n <td>\n $T|0\\rangle = |0\\rangle$<br>\n $T|1\\rangle = e^{i\\pi/4}|1\\rangle$\n </td>\n </tr>\n</table>\n\n> Notice that applying the $T$ gate twice is equivalent to applying the $S$ gate, and applying the $S$ gate twice is equivalent to applying the $Z$ gate: \n$$T^2 = S, S^2 = Z$$"
426
403
  }
427
404
  ]
428
405
  },
@@ -445,8 +422,8 @@ export default {
445
422
  "items": [
446
423
  {
447
424
  "type": "text-content",
448
- "asHtml": "<p>The three-fourths phase gate above can be expressed as a product of 2 canonical gates - the $T$ gate is $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix}$ and the $S$ gate is $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/2} \\end{bmatrix}$.</p>\n<p>$$\n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i3\\pi/4} \\end{bmatrix} = \n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/2} \\end{bmatrix} = \n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; i \\end{bmatrix} = \nTS\n$$</p>\n<p>Note that $TS = ST$, so it doesn&#39;t matter in what order those gates are applied.</p>\n",
449
- "asMarkdown": "\nThe three-fourths phase gate above can be expressed as a product of 2 canonical gates - the $T$ gate is $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$ and the $S$ gate is $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/2} \\end{bmatrix}$.\n\n$$\n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i3\\pi/4} \\end{bmatrix} = \n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/2} \\end{bmatrix} = \n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & i \\end{bmatrix} = \nTS\n$$\n\nNote that $TS = ST$, so it doesn't matter in what order those gates are applied."
425
+ "asHtml": "<p>The three-fourths phase gate above can be expressed as a product of two canonical gates - the $T$ gate is $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix}$ and the $S$ gate is $\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/2} \\end{bmatrix}$.</p>\n<p>$$\n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i3\\pi/4} \\end{bmatrix} = \n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/2} \\end{bmatrix} = \n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; i \\end{bmatrix} = \nTS\n$$</p>\n<p>Note that $TS = ST$, so it doesn&#39;t matter in what order those gates are applied.</p>\n",
426
+ "asMarkdown": "\nThe three-fourths phase gate above can be expressed as a product of two canonical gates - the $T$ gate is $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix}$ and the $S$ gate is $\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/2} \\end{bmatrix}$.\n\n$$\n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i3\\pi/4} \\end{bmatrix} = \n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/2} \\end{bmatrix} = \n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\pi/4} \\end{bmatrix} \\begin{bmatrix} 1 & 0 \\\\\\ 0 & i \\end{bmatrix} = \nTS\n$$\n\nNote that $TS = ST$, so it doesn't matter in what order those gates are applied."
450
427
  },
451
428
  {
452
429
  "type": "solution",
@@ -463,8 +440,8 @@ export default {
463
440
  "items": [
464
441
  {
465
442
  "type": "text-content",
466
- "asHtml": "<p>The next few gates are parametrized: their exact behavior depends on a numeric parameter - an angle $\\theta$, given in radians. \nThese gates are the $X$ rotation gate $R_x(\\theta)$, $Y$ rotation gate $R_y(\\theta)$, $Z$ rotation gate $R_z(\\theta)$, and the arbitrary phase gate $R_1(\\theta)$. \nNote that for the first three gates the parameter $\\theta$ is multiplied by $\\frac{1}{2}$ within the gate&#39;s matrix.</p>\n<blockquote>\n<p>These gates are known as rotation gates, because they represent rotations around various axes on the Bloch sphere. The Bloch sphere is a way of representing the qubit states visually, mapping them onto the surface of a sphere. \nUnfortunately, this visualization isn&#39;t very useful beyond single-qubit states, which is why we have opted not to go into details in this kata.\nIf you are curious about it, you can learn more in <a href=\"https://en.wikipedia.org/wiki/Bloch_sphere\" target=\"_blank\">this Wikipedia article</a>.</p>\n</blockquote>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$R_x(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -i\\sin\\frac{\\theta}{2} \\\\\\ -i\\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_x(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - i\\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} - i\\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_x(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle - i\\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_x(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - i\\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.rx\" target=\"_blank\">Rx</a></td>\n </tr>\n <tr>\n <td>$R_y(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -\\sin\\frac{\\theta}{2} \\\\\\ \\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_y(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - \\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} + \\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_y(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle + \\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_y(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - \\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.ry\" target=\"_blank\">Ry</a></td>\n </tr>\n <tr>\n <td>$R_z(\\theta)$</td>\n <td>$\\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\\\ 0 & e^{i\\theta/2} \\end{bmatrix}$</td>\n <td>$R_z(\\theta)|\\psi\\rangle = \\alpha e^{-i\\theta/2}|0\\rangle + \\beta e^{i\\theta/2}|1\\rangle$</td>\n <td>\n $R_z(\\theta)|0\\rangle = e^{-i\\theta/2}|0\\rangle$<br>\n $R_z(\\theta)|1\\rangle = e^{i\\theta/2}|1\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.rz\" target=\"_blank\">Rz</a></td>\n </tr>\n <tr>\n <td>$R_1(\\theta)$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}$</td>\n <td>$R_1(\\theta)|\\psi\\rangle = \\alpha|0\\rangle + \\beta e^{i\\theta}|1\\rangle$</td>\n <td>\n $R_1(\\theta)|0\\rangle = |0\\rangle$<br>\n $R_1(\\theta)|1\\rangle = e^{i\\theta}|1\\rangle$\n </td> \n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.r1\" target=\"_blank\">R1</a></td>\n </tr>\n</table>\n\n<p>You have already encountered some special cases of the $R_1$ gate: </p>\n<p>$$T = R_1(\\frac{\\pi}{4}), S = R_1(\\frac{\\pi}{2}), Z = R_1(\\pi)$$</p>\n<p>In addition, this gate is closely related to the $R_z$ gate: applying $R_1$ gate is equivalent to applying the $R_z$ gate, and then applying a global phase: </p>\n<p>$$R_1(\\theta) = e^{i\\theta/2}R_z(\\theta)$$</p>\n<p>In addition, the rotation gates are very closely related to their respective Pauli gates: </p>\n<p>$$X = iR_x(\\pi), Y = iR_y(\\pi), Z = iR_z(\\pi)$$</p>\n",
467
- "asMarkdown": "\nThe next few gates are parametrized: their exact behavior depends on a numeric parameter - an angle $\\theta$, given in radians. \nThese gates are the $X$ rotation gate $R_x(\\theta)$, $Y$ rotation gate $R_y(\\theta)$, $Z$ rotation gate $R_z(\\theta)$, and the arbitrary phase gate $R_1(\\theta)$. \nNote that for the first three gates the parameter $\\theta$ is multiplied by $\\frac{1}{2}$ within the gate's matrix.\n\n> These gates are known as rotation gates, because they represent rotations around various axes on the Bloch sphere. The Bloch sphere is a way of representing the qubit states visually, mapping them onto the surface of a sphere. \n> Unfortunately, this visualization isn't very useful beyond single-qubit states, which is why we have opted not to go into details in this kata.\n> If you are curious about it, you can learn more in <a href=\"https://en.wikipedia.org/wiki/Bloch_sphere\" target=\"_blank\">this Wikipedia article</a>.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n <th>Q# Documentation</th>\n </tr>\n <tr>\n <td>$R_x(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -i\\sin\\frac{\\theta}{2} \\\\\\ -i\\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_x(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - i\\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} - i\\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_x(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle - i\\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_x(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - i\\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.rx\" target=\"_blank\">Rx</a></td>\n </tr>\n <tr>\n <td>$R_y(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -\\sin\\frac{\\theta}{2} \\\\\\ \\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_y(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - \\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} + \\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_y(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle + \\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_y(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - \\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.ry\" target=\"_blank\">Ry</a></td>\n </tr>\n <tr>\n <td>$R_z(\\theta)$</td>\n <td>$\\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\\\ 0 & e^{i\\theta/2} \\end{bmatrix}$</td>\n <td>$R_z(\\theta)|\\psi\\rangle = \\alpha e^{-i\\theta/2}|0\\rangle + \\beta e^{i\\theta/2}|1\\rangle$</td>\n <td>\n $R_z(\\theta)|0\\rangle = e^{-i\\theta/2}|0\\rangle$<br>\n $R_z(\\theta)|1\\rangle = e^{i\\theta/2}|1\\rangle$\n </td>\n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.rz\" target=\"_blank\">Rz</a></td>\n </tr>\n <tr>\n <td>$R_1(\\theta)$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}$</td>\n <td>$R_1(\\theta)|\\psi\\rangle = \\alpha|0\\rangle + \\beta e^{i\\theta}|1\\rangle$</td>\n <td>\n $R_1(\\theta)|0\\rangle = |0\\rangle$<br>\n $R_1(\\theta)|1\\rangle = e^{i\\theta}|1\\rangle$\n </td> \n <td><a href=\"https://docs.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic.r1\" target=\"_blank\">R1</a></td>\n </tr>\n</table>\n\nYou have already encountered some special cases of the $R_1$ gate: \n\n$$T = R_1(\\frac{\\pi}{4}), S = R_1(\\frac{\\pi}{2}), Z = R_1(\\pi)$$\n\nIn addition, this gate is closely related to the $R_z$ gate: applying $R_1$ gate is equivalent to applying the $R_z$ gate, and then applying a global phase: \n\n$$R_1(\\theta) = e^{i\\theta/2}R_z(\\theta)$$\n\nIn addition, the rotation gates are very closely related to their respective Pauli gates: \n\n$$X = iR_x(\\pi), Y = iR_y(\\pi), Z = iR_z(\\pi)$$"
443
+ "asHtml": "<p>The next few gates are parametrized: their exact behavior depends on a numeric parameter - an angle $\\theta$, given in radians. \nThese gates are the $X$ rotation gate $R_x(\\theta)$, $Y$ rotation gate $R_y(\\theta)$, $Z$ rotation gate $R_z(\\theta)$, and the arbitrary phase gate $R_1(\\theta)$. \nNote that for the first three gates the parameter $\\theta$ is multiplied by $\\frac{1}{2}$ within the gate&#39;s matrix.</p>\n<blockquote>\n<p>These gates are known as rotation gates, because they represent rotations around various axes on the Bloch sphere. The Bloch sphere is a way of representing the qubit states visually, mapping them onto the surface of a sphere. \nUnfortunately, this visualization isn&#39;t very useful beyond single-qubit states, which is why we have opted not to go into details in this kata.\nIf you are curious about it, you can learn more in <a href=\"https://en.wikipedia.org/wiki/Bloch_sphere\" target=\"_blank\">this Wikipedia article</a>.</p>\n</blockquote>\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$R_x(\\theta)$</td>\n <td>\n $$\n \\begin{bmatrix} \\cos\\frac{\\theta}{2} & -i\\sin\\frac{\\theta}{2} \\\\\\ -i\\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}\n $$\n </td>\n <td>$R_x(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - i\\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} - i\\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_x(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle - i\\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_x(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - i\\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_y(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -\\sin\\frac{\\theta}{2} \\\\\\ \\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_y(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - \\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} + \\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_y(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle + \\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_y(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - \\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_z(\\theta)$</td>\n <td>$\\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\\\ 0 & e^{i\\theta/2} \\end{bmatrix}$</td>\n <td>$R_z(\\theta)|\\psi\\rangle = \\alpha e^{-i\\theta/2}|0\\rangle + \\beta e^{i\\theta/2}|1\\rangle$</td>\n <td>\n $R_z(\\theta)|0\\rangle = e^{-i\\theta/2}|0\\rangle$<br>\n $R_z(\\theta)|1\\rangle = e^{i\\theta/2}|1\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_1(\\theta)$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}$</td>\n <td>$R_1(\\theta)|\\psi\\rangle = \\alpha|0\\rangle + \\beta e^{i\\theta}|1\\rangle$</td>\n <td>\n $R_1(\\theta)|0\\rangle = |0\\rangle$<br>\n $R_1(\\theta)|1\\rangle = e^{i\\theta}|1\\rangle$\n </td> \n </tr>\n</table>\n\n<p>You have already encountered some special cases of the $R_1$ gate:</p>\n<p>$$T = R_1(\\frac{\\pi}{4}), S = R_1(\\frac{\\pi}{2}), Z = R_1(\\pi)$$</p>\n<p>In addition, this gate is closely related to the $R_z$ gate: applying $R_1$ gate is equivalent to applying the $R_z$ gate, and then applying a global phase: </p>\n<p>$$R_1(\\theta) = e^{i\\theta/2}R_z(\\theta)$$</p>\n<p>In addition, the rotation gates are very closely related to their respective Pauli gates: </p>\n<p>$$X = iR_x(\\pi), Y = iR_y(\\pi), Z = iR_z(\\pi)$$</p>\n",
444
+ "asMarkdown": "\nThe next few gates are parametrized: their exact behavior depends on a numeric parameter - an angle $\\theta$, given in radians. \nThese gates are the $X$ rotation gate $R_x(\\theta)$, $Y$ rotation gate $R_y(\\theta)$, $Z$ rotation gate $R_z(\\theta)$, and the arbitrary phase gate $R_1(\\theta)$. \nNote that for the first three gates the parameter $\\theta$ is multiplied by $\\frac{1}{2}$ within the gate's matrix.\n\n> These gates are known as rotation gates, because they represent rotations around various axes on the Bloch sphere. The Bloch sphere is a way of representing the qubit states visually, mapping them onto the surface of a sphere. \n> Unfortunately, this visualization isn't very useful beyond single-qubit states, which is why we have opted not to go into details in this kata.\n> If you are curious about it, you can learn more in <a href=\"https://en.wikipedia.org/wiki/Bloch_sphere\" target=\"_blank\">this Wikipedia article</a>.\n\n<table>\n <tr>\n <th>Gate</th>\n <th>Matrix</th>\n <th>Applying to $|\\psi\\rangle = \\alpha|0\\rangle + \\beta|1\\rangle$</th>\n <th>Applying to basis states</th>\n </tr>\n <tr>\n <td>$R_x(\\theta)$</td>\n <td>\n $$\n \\begin{bmatrix} \\cos\\frac{\\theta}{2} & -i\\sin\\frac{\\theta}{2} \\\\\\ -i\\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}\n $$\n </td>\n <td>$R_x(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - i\\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} - i\\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_x(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle - i\\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_x(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - i\\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_y(\\theta)$</td>\n <td>$\\begin{bmatrix} \\cos\\frac{\\theta}{2} & -\\sin\\frac{\\theta}{2} \\\\\\ \\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$</td>\n <td>$R_y(\\theta)|\\psi\\rangle = (\\alpha\\cos\\frac{\\theta}{2} - \\beta\\sin\\frac{\\theta}{2})|0\\rangle + (\\beta\\cos\\frac{\\theta}{2} + \\alpha\\sin\\frac{\\theta}{2})|1\\rangle$</td>\n <td>\n $R_y(\\theta)|0\\rangle = \\cos\\frac{\\theta}{2}|0\\rangle + \\sin\\frac{\\theta}{2}|1\\rangle$<br>\n $R_y(\\theta)|1\\rangle = \\cos\\frac{\\theta}{2}|1\\rangle - \\sin\\frac{\\theta}{2}|0\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_z(\\theta)$</td>\n <td>$\\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\\\ 0 & e^{i\\theta/2} \\end{bmatrix}$</td>\n <td>$R_z(\\theta)|\\psi\\rangle = \\alpha e^{-i\\theta/2}|0\\rangle + \\beta e^{i\\theta/2}|1\\rangle$</td>\n <td>\n $R_z(\\theta)|0\\rangle = e^{-i\\theta/2}|0\\rangle$<br>\n $R_z(\\theta)|1\\rangle = e^{i\\theta/2}|1\\rangle$\n </td>\n </tr>\n <tr>\n <td>$R_1(\\theta)$</td>\n <td>$\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}$</td>\n <td>$R_1(\\theta)|\\psi\\rangle = \\alpha|0\\rangle + \\beta e^{i\\theta}|1\\rangle$</td>\n <td>\n $R_1(\\theta)|0\\rangle = |0\\rangle$<br>\n $R_1(\\theta)|1\\rangle = e^{i\\theta}|1\\rangle$\n </td> \n </tr>\n</table>\n\nYou have already encountered some special cases of the $R_1$ gate:\n\n$$T = R_1(\\frac{\\pi}{4}), S = R_1(\\frac{\\pi}{2}), Z = R_1(\\pi)$$\n\nIn addition, this gate is closely related to the $R_z$ gate: applying $R_1$ gate is equivalent to applying the $R_z$ gate, and then applying a global phase: \n\n$$R_1(\\theta) = e^{i\\theta/2}R_z(\\theta)$$\n\nIn addition, the rotation gates are very closely related to their respective Pauli gates: \n\n$$X = iR_x(\\pi), Y = iR_y(\\pi), Z = iR_z(\\pi)$$"
468
445
  }
469
446
  ]
470
447
  },
@@ -517,8 +494,8 @@ export default {
517
494
  "items": [
518
495
  {
519
496
  "type": "text-content",
520
- "asHtml": "<p>This exercise can be done in two steps.</p>\n<ol>\n<li>Convert the state from $|0\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\nIn a similar manner to the &quot;Preparing a Rotated State&quot; exercise, we first prepare an $\\alpha|0\\rangle -i\\beta|1\\rangle$ state using the $R_x$ gate, and then removing the relative phase of $-i$ by applying the $S$ gate, which would turn $\\alpha|0\\rangle -i\\beta|1\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\nAn alternative, simpler approach is to use the $R_y$ gate, which allows us to get the necessary state right away without introducing a relative phase:\n$$\nR_y(2\\arctan\\frac{\\beta}{\\alpha}) = \\begin{bmatrix} \\alpha &amp; -\\beta \\\\ \\beta &amp; \\alpha \\end{bmatrix}\n$$</li>\n<li>Add a phase of $e^{i\\theta}$ to the $|1\\rangle$ basis state using the $R_1(\\theta)$ gate. This would turn $\\alpha|0\\rangle +\\beta|1\\rangle$ to $\\alpha|0\\rangle + e^{i\\theta}\\beta|1\\rangle$.</li>\n</ol>\n<p>The solution can be represented as $R_1(\\theta)R_y(2\\arctan\\frac{\\beta}{\\alpha})$ or in matrix form as:\n$$\n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\theta} \\end{bmatrix}\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ \\beta &amp; \\alpha \\end{bmatrix} = \n\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ e^{i\\theta}\\beta &amp; e^{i\\theta}\\alpha \\end{bmatrix}\n$$</p>\n<p>This turns $|0\\rangle = \\begin{bmatrix} 1 \\\\ 0\\end{bmatrix}$ into $\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ e^{i\\theta}\\beta &amp; e^{i\\theta}\\alpha \\end{bmatrix} \\begin{bmatrix} 1 \\\\ 0\\end{bmatrix} = \\begin{bmatrix} \\alpha \\\\ e^{i\\theta}\\beta \\end{bmatrix} = \\alpha|0\\rangle +e^{i\\theta}\\beta|1\\rangle$.</p>\n",
521
- "asMarkdown": "\nThis exercise can be done in two steps.\n\n1. Convert the state from $|0\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\n In a similar manner to the \"Preparing a Rotated State\" exercise, we first prepare an $\\alpha|0\\rangle -i\\beta|1\\rangle$ state using the $R_x$ gate, and then removing the relative phase of $-i$ by applying the $S$ gate, which would turn $\\alpha|0\\rangle -i\\beta|1\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\n An alternative, simpler approach is to use the $R_y$ gate, which allows us to get the necessary state right away without introducing a relative phase:\n$$\nR_y(2\\arctan\\frac{\\beta}{\\alpha}) = \\begin{bmatrix} \\alpha & -\\beta \\\\\\ \\beta & \\alpha \\end{bmatrix}\n$$\n2. Add a phase of $e^{i\\theta}$ to the $|1\\rangle$ basis state using the $R_1(\\theta)$ gate. This would turn $\\alpha|0\\rangle +\\beta|1\\rangle$ to $\\alpha|0\\rangle + e^{i\\theta}\\beta|1\\rangle$.\n\nThe solution can be represented as $R_1(\\theta)R_y(2\\arctan\\frac{\\beta}{\\alpha})$ or in matrix form as:\n$$\n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}\\begin{bmatrix} \\alpha & -\\beta \\\\\\ \\beta & \\alpha \\end{bmatrix} = \n\\begin{bmatrix} \\alpha & -\\beta \\\\\\ e^{i\\theta}\\beta & e^{i\\theta}\\alpha \\end{bmatrix}\n$$\n\nThis turns $|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0\\end{bmatrix}$ into $\\begin{bmatrix} \\alpha & -\\beta \\\\\\ e^{i\\theta}\\beta & e^{i\\theta}\\alpha \\end{bmatrix} \\begin{bmatrix} 1 \\\\\\ 0\\end{bmatrix} = \\begin{bmatrix} \\alpha \\\\\\ e^{i\\theta}\\beta \\end{bmatrix} = \\alpha|0\\rangle +e^{i\\theta}\\beta|1\\rangle$."
497
+ "asHtml": "<p>This exercise can be done in two steps.</p>\n<ol>\n<li>Convert the state from $|0\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\nThis can be done in a similar manner to the &quot;Preparing a Rotated State&quot; exercise, we first prepare an $\\alpha|0\\rangle -i\\beta|1\\rangle$ state using the $R_x$ gate, and then removing the relative phase of $-i$ by applying the $S$ gate, which would turn $\\alpha|0\\rangle -i\\beta|1\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\nAn alternative, simpler approach is to use the $R_y$ gate, which allows us to get the necessary state right away without introducing a relative phase:\n$$\nR_y(2\\arctan\\frac{\\beta}{\\alpha}) = \\begin{bmatrix} \\alpha &amp; -\\beta \\\\ \\beta &amp; \\alpha \\end{bmatrix}\n$$</li>\n<li>Add a phase of $e^{i\\theta}$ to the $|1\\rangle$ basis state using the $R_1(\\theta)$ gate. This would turn $\\alpha|0\\rangle +\\beta|1\\rangle$ to $\\alpha|0\\rangle + e^{i\\theta}\\beta|1\\rangle$.</li>\n</ol>\n<p>The solution can be represented as $R_1(\\theta)R_y(2\\arctan\\frac{\\beta}{\\alpha})$ or in matrix form as:\n$$\n\\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\theta} \\end{bmatrix}\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ \\beta &amp; \\alpha \\end{bmatrix} = \n\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ e^{i\\theta}\\beta &amp; e^{i\\theta}\\alpha \\end{bmatrix}\n$$</p>\n<p>This turns $|0\\rangle = \\begin{bmatrix} 1 \\\\ 0\\end{bmatrix}$ into $\\begin{bmatrix} \\alpha &amp; -\\beta \\\\ e^{i\\theta}\\beta &amp; e^{i\\theta}\\alpha \\end{bmatrix} \\begin{bmatrix} 1 \\\\ 0\\end{bmatrix} = \\begin{bmatrix} \\alpha \\\\ e^{i\\theta}\\beta \\end{bmatrix} = \\alpha|0\\rangle +e^{i\\theta}\\beta|1\\rangle$.</p>\n",
498
+ "asMarkdown": "\nThis exercise can be done in two steps.\n\n1. Convert the state from $|0\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\n This can be done in a similar manner to the \"Preparing a Rotated State\" exercise, we first prepare an $\\alpha|0\\rangle -i\\beta|1\\rangle$ state using the $R_x$ gate, and then removing the relative phase of $-i$ by applying the $S$ gate, which would turn $\\alpha|0\\rangle -i\\beta|1\\rangle$ to $\\alpha|0\\rangle + \\beta|1\\rangle$.\n An alternative, simpler approach is to use the $R_y$ gate, which allows us to get the necessary state right away without introducing a relative phase:\n$$\nR_y(2\\arctan\\frac{\\beta}{\\alpha}) = \\begin{bmatrix} \\alpha & -\\beta \\\\\\ \\beta & \\alpha \\end{bmatrix}\n$$\n2. Add a phase of $e^{i\\theta}$ to the $|1\\rangle$ basis state using the $R_1(\\theta)$ gate. This would turn $\\alpha|0\\rangle +\\beta|1\\rangle$ to $\\alpha|0\\rangle + e^{i\\theta}\\beta|1\\rangle$.\n\nThe solution can be represented as $R_1(\\theta)R_y(2\\arctan\\frac{\\beta}{\\alpha})$ or in matrix form as:\n$$\n\\begin{bmatrix} 1 & 0 \\\\\\ 0 & e^{i\\theta} \\end{bmatrix}\\begin{bmatrix} \\alpha & -\\beta \\\\\\ \\beta & \\alpha \\end{bmatrix} = \n\\begin{bmatrix} \\alpha & -\\beta \\\\\\ e^{i\\theta}\\beta & e^{i\\theta}\\alpha \\end{bmatrix}\n$$\n\nThis turns $|0\\rangle = \\begin{bmatrix} 1 \\\\\\ 0\\end{bmatrix}$ into $\\begin{bmatrix} \\alpha & -\\beta \\\\\\ e^{i\\theta}\\beta & e^{i\\theta}\\alpha \\end{bmatrix} \\begin{bmatrix} 1 \\\\\\ 0\\end{bmatrix} = \\begin{bmatrix} \\alpha \\\\\\ e^{i\\theta}\\beta \\end{bmatrix} = \\alpha|0\\rangle +e^{i\\theta}\\beta|1\\rangle$."
522
499
  },
523
500
  {
524
501
  "type": "solution",
@@ -535,8 +512,8 @@ export default {
535
512
  "items": [
536
513
  {
537
514
  "type": "text-content",
538
- "asHtml": "<p>Congratulations! In this kata you learned the matrix and the ket-bra representation of quantum gates. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>Single-qubit gates act on individual qubits and are represented by $2 \\times 2$ unitary matrices.</li>\n<li>The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit.</li>\n<li>Applying several quantum gates in sequence is equivalent to performing several matrix multiplications.</li>\n<li>Any square matrix can be represented as a linear combination of the outer products of vectors. The outer product is the matrix product of $|\\phi\\rangle$ and $\\langle\\psi|$, denoted as $|\\phi\\rangle\\langle\\psi|$.</li>\n<li>Pauli gates, phase shift gates, and rotation gates are examples of single-qubit gates. All of them are available in Q#.</li>\n</ul>\n<p>Next, you will learn about multi-qubit systems and the multi-qubit gates in the “Multi-Qubit Systems” kata.</p>\n",
539
- "asMarkdown": "\nCongratulations! In this kata you learned the matrix and the ket-bra representation of quantum gates. Here are a few key concepts to keep in mind:\n* Single-qubit gates act on individual qubits and are represented by $2 \\times 2$ unitary matrices.\n* The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit.\n* Applying several quantum gates in sequence is equivalent to performing several matrix multiplications.\n* Any square matrix can be represented as a linear combination of the outer products of vectors. The outer product is the matrix product of $|\\phi\\rangle$ and $\\langle\\psi|$, denoted as $|\\phi\\rangle\\langle\\psi|$.\n* Pauli gates, phase shift gates, and rotation gates are examples of single-qubit gates. All of them are available in Q#.\n\nNext, you will learn about multi-qubit systems and the multi-qubit gates in the “Multi-Qubit Systems” kata."
515
+ "asHtml": "<p>Congratulations! In this kata you learned the matrix and the ket-bra representation of quantum gates. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>Single-qubit gates act on individual qubits and are represented by $2 \\times 2$ unitary matrices.</li>\n<li>The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit.</li>\n<li>Applying several quantum gates in sequence is equivalent to performing several matrix multiplications.</li>\n<li>Any square matrix can be represented as a linear combination of the outer products of vectors. The outer product is the matrix product of $|\\phi\\rangle$ and $\\langle\\psi|$, denoted as $|\\phi\\rangle\\langle\\psi|$.</li>\n<li>Pauli gates, identity and Hadamard gates, phase shift gates, and rotation gates are examples of single-qubit gates. All of them are available in Q#.</li>\n</ul>\n<p>Next, you will learn about multi-qubit systems in the “Multi-Qubit Systems” kata.</p>\n",
516
+ "asMarkdown": "\nCongratulations! In this kata you learned the matrix and the ket-bra representation of quantum gates. Here are a few key concepts to keep in mind:\n* Single-qubit gates act on individual qubits and are represented by $2 \\times 2$ unitary matrices.\n* The effect of a gate applied to a qubit can be calculated by multiplying the corresponding matrix by the state vector of the qubit.\n* Applying several quantum gates in sequence is equivalent to performing several matrix multiplications.\n* Any square matrix can be represented as a linear combination of the outer products of vectors. The outer product is the matrix product of $|\\phi\\rangle$ and $\\langle\\psi|$, denoted as $|\\phi\\rangle\\langle\\psi|$.\n* Pauli gates, identity and Hadamard gates, phase shift gates, and rotation gates are examples of single-qubit gates. All of them are available in Q#.\n\nNext, you will learn about multi-qubit systems in the “Multi-Qubit Systems” kata."
540
517
  }
541
518
  ]
542
519
  }
@@ -553,8 +530,8 @@ export default {
553
530
  "items": [
554
531
  {
555
532
  "type": "text-content",
556
- "asHtml": "<p>This kata introduces you to multi-qubit systems - their representation in mathematical notation and in Q# code, and the concept of entanglement.</p>\n<p>If you are not familiar with single-qubit systems, we recommend that you complete &quot;The Qubit&quot; kata first.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Vector representation of multi-qubit systems</li>\n<li>Entangled and separable states</li>\n<li>Dirac notation</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Basic single-qubit gates</li>\n<li>The concept of tensor product</li>\n</ul>\n",
557
- "asMarkdown": "\nThis kata introduces you to multi-qubit systems - their representation in mathematical notation and in Q# code, and the concept of entanglement.\n\nIf you are not familiar with single-qubit systems, we recommend that you complete \"The Qubit\" kata first.\n\n**This kata covers the following topics:**\n\n- Vector representation of multi-qubit systems\n- Entangled and separable states\n- Dirac notation\n\n**What you should know to start working on this kata:**\n\n- Basic single-qubit gates\n- The concept of tensor product"
533
+ "asHtml": "<p>This kata introduces you to multi-qubit systems, their representation in mathematical notation and in Q# code, and the concept of entanglement.</p>\n<p>If you are not familiar with single-qubit systems, we recommend that you complete &quot;The Qubit&quot; kata first.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Vector representation of multi-qubit systems</li>\n<li>Entangled and separable states</li>\n<li>Dirac notation for multi-qubit systems</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Basic single-qubit gates</li>\n<li>The concept of tensor product</li>\n</ul>\n",
534
+ "asMarkdown": "\nThis kata introduces you to multi-qubit systems, their representation in mathematical notation and in Q# code, and the concept of entanglement.\n\nIf you are not familiar with single-qubit systems, we recommend that you complete \"The Qubit\" kata first.\n\n**This kata covers the following topics:**\n\n- Vector representation of multi-qubit systems\n- Entangled and separable states\n- Dirac notation for multi-qubit systems\n\n**What you should know to start working on this kata:**\n\n- Basic single-qubit gates\n- The concept of tensor product"
558
535
  }
559
536
  ]
560
537
  },
@@ -565,8 +542,8 @@ export default {
565
542
  "items": [
566
543
  {
567
544
  "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>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
- "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."
545
+ "asHtml": "<p>In The Qubit 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<p>$$\\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\ 1 \\\\ 0 \\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\ 0 \\\\ 1 \\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\ 0 \\\\ 0 \\\\ 1 \\end{bmatrix}$$</p>\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",
546
+ "asMarkdown": "\nIn The Qubit 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$$\\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\\\ 1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 1 \\\\\\ 0 \\end{bmatrix},\n\\begin{bmatrix} 0 \\\\\\ 0 \\\\\\ 0 \\\\\\ 1 \\end{bmatrix}$$\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
547
  }
571
548
  ]
572
549
  },
@@ -577,8 +554,8 @@ export default {
577
554
  "items": [
578
555
  {
579
556
  "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>🔎 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
- "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>"
557
+ "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 the first qubit is in state $\\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and the second qubit is in state $|0\\rangle$. The multi-qubit states that allow such representation are known as <strong>separable states</strong>, or product states, because you can separate the global state into the tensor product of individual subsystems.</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>",
558
+ "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 the first qubit is in state $\\frac{1}{\\sqrt{2}}\\big(|0\\rangle + |1\\rangle\\big)$ and the second qubit is in state $|0\\rangle$. The multi-qubit states that allow such representation are known as **separable states**, or product states, because you can separate the global state into the tensor product of individual subsystems.\n\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
559
  }
583
560
  ]
584
561
  },
@@ -589,8 +566,8 @@ export default {
589
566
  "items": [
590
567
  {
591
568
  "type": "text-content",
592
- "asHtml": "<p>Sometimes, quantum states cannot be written as individual qubit states. Quantum systems that are not separable are called entangled systems. If a state can be written as the product state of the individual subsystems, that state is not entangled.</p>\n<p>Entanglement is a quantum correlation, which is very different from classical correlations. In entanglement, the state of the subsystems isn&#39;t determined, and you can talk only about the probabilities associated with the outcomes. The global system must be considered as one.</p>\n<blockquote>\n<p>For example, every state in the Bell basis is an entangled state.</p>\n</blockquote>\n<p>Entanglement is a huge part of what makes quantum computing so powerful. It allows us to link the qubits so that they stop behaving like individuals and start behaving like a large, more complex system. In entangled systems, measuring one of the qubits modifies the state of the other qubits, and tells us something about their state.</p>\n<p>For example, consider two qubits $A$ and $B$ in superpositions such that the state of the global system is</p>\n<p>$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt2}|00\\rangle + \\frac{1}{\\sqrt2}|11\\rangle$$</p>\n<p>In such a state, only two outcomes are possible when you measure the state of both qubits in the standard basis: $|00\\rangle$ and $|11\\rangle$. Notice that each outcome has the same probability of $\\frac{1}{2}$. There&#39;s zero probability of obtaining $|01\\rangle$ and $|10\\rangle$. If you measure the first qubit and you get that it is in $|0\\rangle$ state, then you can be positive that the second qubit is also in $|0\\rangle$ state, even without measuring it. The measurement outcomes are correlated, and the qubits are <em>entangled</em>.</p>\n<p>This property is used extensively in many quantum algorithms.</p>\n",
593
- "asMarkdown": "\nSometimes, quantum states cannot be written as individual qubit states. Quantum systems that are not separable are called entangled systems. If a state can be written as the product state of the individual subsystems, that state is not entangled.\n\nEntanglement is a quantum correlation, which is very different from classical correlations. In entanglement, the state of the subsystems isn't determined, and you can talk only about the probabilities associated with the outcomes. The global system must be considered as one.\n\n> For example, every state in the Bell basis is an entangled state.\n\nEntanglement is a huge part of what makes quantum computing so powerful. It allows us to link the qubits so that they stop behaving like individuals and start behaving like a large, more complex system. In entangled systems, measuring one of the qubits modifies the state of the other qubits, and tells us something about their state.\n\nFor example, consider two qubits $A$ and $B$ in superpositions such that the state of the global system is\n\n$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt2}|00\\rangle + \\frac{1}{\\sqrt2}|11\\rangle$$\n\nIn such a state, only two outcomes are possible when you measure the state of both qubits in the standard basis: $|00\\rangle$ and $|11\\rangle$. Notice that each outcome has the same probability of $\\frac{1}{2}$. There's zero probability of obtaining $|01\\rangle$ and $|10\\rangle$. If you measure the first qubit and you get that it is in $|0\\rangle$ state, then you can be positive that the second qubit is also in $|0\\rangle$ state, even without measuring it. The measurement outcomes are correlated, and the qubits are _entangled_.\n\nThis property is used extensively in many quantum algorithms."
569
+ "asHtml": "<p>Sometimes, quantum states cannot be written as individual qubit states. Quantum systems that are not separable are called <strong>entangled</strong> systems. If a state can be written as the product state of the individual subsystems, that state is not entangled.</p>\n<p>Entanglement is a quantum correlation, which is very different from classical correlations. In entanglement, the state of the subsystems isn&#39;t determined, and you can talk only about the probabilities associated with the outcomes. The global system must be considered as one.</p>\n<blockquote>\n<p>For example, every state in the Bell basis is an entangled state.</p>\n</blockquote>\n<p>Entanglement is a huge part of what makes quantum computing so powerful. It allows us to link the qubits so that they stop behaving like individuals and start behaving like a large, more complex system. In entangled systems, measuring one of the qubits modifies the state of the other qubits, and tells us something about their state.</p>\n<p>For example, consider two qubits $A$ and $B$ in superposition such that the state of the global system is</p>\n<p>$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt2}|00\\rangle + \\frac{1}{\\sqrt2}|11\\rangle$$</p>\n<p>In such a state, only two outcomes are possible when you measure the state of both qubits in the standard basis: $|00\\rangle$ and $|11\\rangle$. Notice that each outcome has the same probability of $\\frac{1}{2}$. There&#39;s zero probability of obtaining $|01\\rangle$ and $|10\\rangle$. If you measure the first qubit and you get that it is in $|0\\rangle$ state, then you can be positive that the second qubit is also in $|0\\rangle$ state, even without measuring it. The measurement outcomes are correlated, and the qubits are entangled.</p>\n<p>This property is used extensively in many quantum algorithms.</p>\n",
570
+ "asMarkdown": "\nSometimes, quantum states cannot be written as individual qubit states. Quantum systems that are not separable are called **entangled** systems. If a state can be written as the product state of the individual subsystems, that state is not entangled.\n\nEntanglement is a quantum correlation, which is very different from classical correlations. In entanglement, the state of the subsystems isn't determined, and you can talk only about the probabilities associated with the outcomes. The global system must be considered as one.\n\n> For example, every state in the Bell basis is an entangled state.\n\nEntanglement is a huge part of what makes quantum computing so powerful. It allows us to link the qubits so that they stop behaving like individuals and start behaving like a large, more complex system. In entangled systems, measuring one of the qubits modifies the state of the other qubits, and tells us something about their state.\n\nFor example, consider two qubits $A$ and $B$ in superposition such that the state of the global system is\n\n$$|\\psi\\rangle_{AB} = \\frac{1}{\\sqrt2}|00\\rangle + \\frac{1}{\\sqrt2}|11\\rangle$$\n\nIn such a state, only two outcomes are possible when you measure the state of both qubits in the standard basis: $|00\\rangle$ and $|11\\rangle$. Notice that each outcome has the same probability of $\\frac{1}{2}$. There's zero probability of obtaining $|01\\rangle$ and $|10\\rangle$. If you measure the first qubit and you get that it is in $|0\\rangle$ state, then you can be positive that the second qubit is also in $|0\\rangle$ state, even without measuring it. The measurement outcomes are correlated, and the qubits are entangled.\n\nThis property is used extensively in many quantum algorithms."
594
571
  }
595
572
  ]
596
573
  },
@@ -601,8 +578,8 @@ export default {
601
578
  "items": [
602
579
  {
603
580
  "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>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
- "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**."
581
+ "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<p>$$|\\phi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle + |11\\rangle\\big)$$\n$$|\\phi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle - |11\\rangle\\big)$$\n$$|\\psi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle + |10\\rangle\\big)$$\n$$|\\psi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle - |10\\rangle\\big)$$</p>\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",
582
+ "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$$|\\phi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle + |11\\rangle\\big)$$\n$$|\\phi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|00\\rangle - |11\\rangle\\big)$$\n$$|\\psi^+\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle + |10\\rangle\\big)$$\n$$|\\psi^-\\rangle = \\frac{1}{\\sqrt{2}}\\big(|01\\rangle - |10\\rangle\\big)$$\n\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
583
  }
607
584
  ]
608
585
  },
@@ -613,18 +590,60 @@ export default {
613
590
  "items": [
614
591
  {
615
592
  "type": "text-content",
616
- "asHtml": "<p>This demo shows you how to allocate multiple qubits in Q# and examine their joint state. It uses single-qubit gates for manipulating the individual qubit states - if you need a refresher on them, please review the single-qubit gates kata.</p>\n<p>These demos use the function <code>DumpMachine</code> to print the state of the quantum simulator.\nIf you aren&#39;t familiar with the output of this function for single qubits, you should revisit the qubit kata.\nWhen printing the state of multi-qubit systems, this function outputs the same information for each multi-qubit basis state.\nThe qubit kata explains how <code>DumpMachine</code> works for multiple qubits in more detail.</p>\n",
617
- "asMarkdown": "\nThis demo shows you how to allocate multiple qubits in Q# and examine their joint state. It uses single-qubit gates for manipulating the individual qubit states - if you need a refresher on them, please review the single-qubit gates kata.\n\nThese demos use the function `DumpMachine` to print the state of the quantum simulator.\nIf you aren't familiar with the output of this function for single qubits, you should revisit the qubit kata.\nWhen printing the state of multi-qubit systems, this function outputs the same information for each multi-qubit basis state.\nThe qubit kata explains how `DumpMachine` works for multiple qubits in more detail."
593
+ "asHtml": "<p>This demo shows you how to allocate multiple qubits in Q# and examine their joint state. It uses single-qubit gates for manipulating the individual qubit states - if you need a refresher on them, please review the Single-Qubit Gates kata.</p>\n<p>These demos use the function <code>DumpMachine</code> to print the state of the quantum simulator.\nWhen dealing with multi-qubit systems, <code>DumpMachine</code> prints information about each basis state that has a non-zero amplitude, one basis state per row, the same as it does for single-qubit systems. \nThe basis states are represented as bit strings, one bit per the qubit allocated, with the leftmost bit corresponding \nto the qubit that was allocated the earliest. (If the qubits were allocated at once as an array, the leftmost bit corresponds \nto the first element of the array.)</p>\n",
594
+ "asMarkdown": "\nThis demo shows you how to allocate multiple qubits in Q# and examine their joint state. It uses single-qubit gates for manipulating the individual qubit states - if you need a refresher on them, please review the Single-Qubit Gates kata.\n\nThese demos use the function `DumpMachine` to print the state of the quantum simulator.\nWhen dealing with multi-qubit systems, `DumpMachine` prints information about each basis state that has a non-zero amplitude, one basis state per row, the same as it does for single-qubit systems. \nThe basis states are represented as bit strings, one bit per the qubit allocated, with the leftmost bit corresponding \nto the qubit that was allocated the earliest. (If the qubits were allocated at once as an array, the leftmost bit corresponds \nto the first element of the array.)"
618
595
  },
619
596
  {
620
597
  "type": "example",
621
598
  "id": "multi_qubit_systems__multi_qubit_systems_demo",
622
- "code": "namespace Kata {\n open Microsoft.Quantum.Diagnostics;\n\n @EntryPoint()\n operation MultiQubitSystemsDemo () : Unit {\n // This allocates an array of 2 qubits, each of them in state |0⟩.\n // The overall state of the system is |00⟩\n use qs = Qubit[2];\n // X gate changes the first qubit into state |1⟩\n // The entire system is now in state |10⟩\n X(qs[0]);\n\n Message(\"System in state |10⟩:\");\n DumpMachine();\n\n // This changes the second qubit into state |+⟩ = (1/sqrt(2))(|0⟩ + |1⟩).\n // The entire system is now in state (1/sqrt(2))(|10⟩ + |11⟩)\n H(qs[1]);\n\n Message(\"System in state (1/sqrt(2))(|10⟩ + |11⟩):\");\n DumpMachine();\n\n // This changes the first qubit into state |-⟩ = (1/sqrt(2))(|0⟩ - |1⟩)\n // The entire system is now in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩)\n H(qs[0]);\n\n Message(\"System in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩):\");\n DumpMachine();\n\n // The next lines entangle the qubits.\n // Don't worry about what exactly they do for now\n H(qs[1]);\n CNOT(qs[0], qs[1]);\n\n Message(\"Entangled state 0.5(|00⟩ - |11⟩):\");\n DumpMachine();\n\n // Since the states of entangled qubits are inseparable,\n // it makes no sense to examine only one of them\n\n // This returns the system into state |00⟩\n ResetAll(qs);\n }\n}"
599
+ "code": "namespace Kata {\n open Microsoft.Quantum.Diagnostics;\n\n @EntryPoint()\n operation MultiQubitSystemsDemo () : Unit {\n // This allocates an array of 2 qubits, each of them in state |0⟩.\n // The overall state of the system is |00⟩.\n use qs = Qubit[2];\n // X gate changes the first qubit into state |1⟩.\n X(qs[0]);\n Message(\"The system in now in state |10⟩:\");\n DumpMachine();\n\n // This changes the second qubit into state |+⟩ = (1/sqrt(2))(|0⟩ + |1⟩).\n H(qs[1]);\n Message(\"The system in now in state (1/sqrt(2))(|10⟩ + |11⟩):\");\n DumpMachine();\n\n // This changes the first qubit into state |-⟩ = (1/sqrt(2))(|0⟩ - |1⟩)\n H(qs[0]);\n Message(\"The system in now in state 0.5(|00⟩ + |01⟩ - |10⟩ - |11⟩):\");\n DumpMachine();\n\n // The next lines entangle the qubits (don't worry about what exactly they do for now).\n H(qs[1]);\n CNOT(qs[0], qs[1]);\n Message(\"The system in now in entangled state 0.5(|00⟩ - |11⟩):\");\n DumpMachine();\n\n // This returns the system into state |00⟩.\n ResetAll(qs);\n }\n}"
623
600
  },
624
601
  {
625
602
  "type": "text-content",
626
- "asHtml": "<blockquote>\n<p>You might have noticed that we&#39;ve been &quot;resetting&quot; the qubits at the end of our demos, that is, returning them to $|0\\rangle$ state. Q# requires you to return your qubits into the $|0\\rangle$ state before releasing them at the end of the <code>using</code> block.\nThe reason for this is entanglement.</p>\n<p>Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program.\nIf they are not in zero state by that time, they can potentially be still entangled with the qubits which are not yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior.</p>\n<p>Resetting the qubits to zero state automatically when they go outside the scope of their using block is dangerous as well: if they were entangled with others, measuring them to reset them can affect the state of the unreleased qubits, and thus change the results of the program - without the developer noticing this.</p>\n<p>The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they are not entangled with unreleased qubits any more.</p>\n<p>(An alternative way to break entanglement is to measure qubits; in this case Q# allows to release them regardless of the measurement result. You can learn more about measurements in the qubit kata.)</p>\n</blockquote>\n<p>In the following exercises you will learn to prepare separable quantum states by manipulating individual qubits.\nYou will only need knowledge from the single-qubit gates kata for that.</p>\n<blockquote>\n<p>In each exercise, you&#39;ll be given an array of qubits to manipulate; you can access $i$-th element of the array <code>qs</code> as <code>qs[i]</code>.\nArray elements are indexed starting with 0, the first array element corresponds to the leftmost qubit in Dirac notation.</p>\n</blockquote>\n",
627
- "asMarkdown": "\n> You might have noticed that we've been \"resetting\" the qubits at the end of our demos, that is, returning them to $|0\\rangle$ state. Q# requires you to return your qubits into the $|0\\rangle$ state before releasing them at the end of the `using` block.\n> The reason for this is entanglement.\n>\n> Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program.\nIf they are not in zero state by that time, they can potentially be still entangled with the qubits which are not yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior.\n>\n> Resetting the qubits to zero state automatically when they go outside the scope of their using block is dangerous as well: if they were entangled with others, measuring them to reset them can affect the state of the unreleased qubits, and thus change the results of the program - without the developer noticing this.\n>\n> The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they are not entangled with unreleased qubits any more.\n>\n> (An alternative way to break entanglement is to measure qubits; in this case Q# allows to release them regardless of the measurement result. You can learn more about measurements in the qubit kata.)\n\nIn the following exercises you will learn to prepare separable quantum states by manipulating individual qubits.\nYou will only need knowledge from the single-qubit gates kata for that.\n\n> In each exercise, you'll be given an array of qubits to manipulate; you can access $i$-th element of the array `qs` as `qs[i]`.\nArray elements are indexed starting with 0, the first array element corresponds to the leftmost qubit in Dirac notation."
603
+ "asHtml": "<blockquote>\n<p>You might have noticed that we&#39;ve been &quot;resetting&quot; the qubits at the end of our demos, that is, returning them to $|0\\rangle$ state. Q# requires you to return your qubits into the $|0\\rangle$ state before they are released at the end of their scope.\nThe reason for this is entanglement.</p>\n<p>Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program.\nIf they are not in zero state by that time, they can potentially be still entangled with the qubits which are not yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior.</p>\n<p>Resetting the qubits to zero state automatically when they go outside the scope of the block they were allocated in is dangerous as well: if they were entangled with others, measuring them to reset them can affect the state of the unreleased qubits, and thus change the results of the program - without the developer noticing this.</p>\n<p>The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they are not entangled with unreleased qubits any more.</p>\n</blockquote>\n",
604
+ "asMarkdown": "\n> You might have noticed that we've been \"resetting\" the qubits at the end of our demos, that is, returning them to $|0\\rangle$ state. Q# requires you to return your qubits into the $|0\\rangle$ state before they are released at the end of their scope.\n> The reason for this is entanglement.\n>\n> Consider running a program on a quantum computer: the number of qubits is very limited, and you want to reuse the released qubits in other parts of the program.\nIf they are not in zero state by that time, they can potentially be still entangled with the qubits which are not yet released, thus operations you perform on them can affect the state of other parts of the program, causing erroneous and hard to debug behavior.\n>\n> Resetting the qubits to zero state automatically when they go outside the scope of the block they were allocated in is dangerous as well: if they were entangled with others, measuring them to reset them can affect the state of the unreleased qubits, and thus change the results of the program - without the developer noticing this.\n>\n> The requirement that the qubits should be in zero state before they can be released aims to remind the developer to double-check that all necessary information has been properly extracted from the qubits, and that they are not entangled with unreleased qubits any more."
605
+ }
606
+ ]
607
+ },
608
+ {
609
+ "type": "exercise",
610
+ "id": "multi_qubit_systems__learn_basis_state_amplitudes",
611
+ "title": "Learn Basis State Amplitudes Using DumpMachine",
612
+ "description": {
613
+ "type": "text-content",
614
+ "asHtml": "<p><strong>Input:</strong> 2 qubits in an unknown state $|\\psi\\rangle = \\sum_{k = 0}^{3} x_k |k\\rangle$. The amplitudes $x_k$ will be real and non-negative.</p>\n<p><strong>Output:</strong> A tuple of two numbers $(x_1&#39;, x_2&#39;)$ - your estimates of the amplitudes of the state $|01\\rangle$ and $|10\\rangle$, respectively.\nThe absolute errors $|x_1 - x_1&#39;|$ and $|x_2 - x_2&#39;|$ should be less than or equal to 0.001.</p>\n<p>Please note that the state parameter is guaranteed to be the same\nif you run the code several times. Your operation will be called\nonce for every run.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, we can use <code>DumpMachine</code> to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again.\n</details>\n",
615
+ "asMarkdown": "\n**Input:** 2 qubits in an unknown state $|\\psi\\rangle = \\sum_{k = 0}^{3} x_k |k\\rangle$. The amplitudes $x_k$ will be real and non-negative.\n\n**Output:** A tuple of two numbers $(x_1', x_2')$ - your estimates of the amplitudes of the state $|01\\rangle$ and $|10\\rangle$, respectively.\nThe absolute errors $|x_1 - x_1'|$ and $|x_2 - x_2'|$ should be less than or equal to 0.001.\n\nPlease note that the state parameter is guaranteed to be the same\nif you run the code several times. Your operation will be called\nonce for every run.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n On a physical quantum system, there would be no way to obtain these values from a single observation. Since this program runs on a simulator, we can use <code>DumpMachine</code> to inspect the qubits and take a note of their state. Furthermore, the problem statement guarantees, that the state will be the same from invocation to invocation. So we can update the code to return the amplitudes that we've taken note of. Then run the code again.\n</details>\n"
616
+ },
617
+ "sourceIds": [
618
+ "KatasLibrary.qs",
619
+ "multi_qubit_systems__learn_basis_state_amplitudes__verification.qs"
620
+ ],
621
+ "placeholderCode": "namespace Kata {\n operation LearnBasisStateAmplitudes(qs : Qubit[]) : (Double, Double) {\n // Implement your solution here...\n\n return (0.0, 0.0);\n }\n}\n",
622
+ "explainedSolution": {
623
+ "type": "explained-solution",
624
+ "items": [
625
+ {
626
+ "type": "text-content",
627
+ "asHtml": "<p>You can learn the amplitudes of the basis states by calling <code>DumpMachine</code>.\nAfter that, you can hardcode the values into your solution.</p>\n",
628
+ "asMarkdown": "\nYou can learn the amplitudes of the basis states by calling `DumpMachine`.\nAfter that, you can hardcode the values into your solution."
629
+ },
630
+ {
631
+ "type": "solution",
632
+ "id": "multi_qubit_systems__learn_basis_state_amplitudes_solution",
633
+ "code": "namespace Kata {\n open Microsoft.Quantum.Diagnostics;\n\n operation LearnBasisStateAmplitudes(qs : Qubit[]) : (Double, Double) {\n DumpMachine(); // Only used to learn the amplitudes.\n return (0.3390, 0.3821);\n }\n}\n"
634
+ }
635
+ ]
636
+ }
637
+ },
638
+ {
639
+ "type": "lesson",
640
+ "id": "multi_qubit_systems__exercises",
641
+ "title": "Separable State Preparation",
642
+ "items": [
643
+ {
644
+ "type": "text-content",
645
+ "asHtml": "<p>In the following exercises you will learn to prepare separable quantum states by manipulating individual qubits.\nYou will only need knowledge from the Single-Qubit Gates kata for that.</p>\n<blockquote>\n<p>In each exercise, you&#39;ll be given an array of qubits to manipulate; you can access $i$-th element of the array <code>qs</code> as <code>qs[i]</code>.\nArray elements are indexed starting with 0, the first array element corresponds to the leftmost qubit in Dirac notation.</p>\n</blockquote>\n",
646
+ "asMarkdown": "\nIn the following exercises you will learn to prepare separable quantum states by manipulating individual qubits.\nYou will only need knowledge from the Single-Qubit Gates kata for that.\n\n> In each exercise, you'll be given an array of qubits to manipulate; you can access $i$-th element of the array `qs` as `qs[i]`.\nArray elements are indexed starting with 0, the first array element corresponds to the leftmost qubit in Dirac notation."
628
647
  }
629
648
  ]
630
649
  },
@@ -639,7 +658,6 @@ export default {
639
658
  },
640
659
  "sourceIds": [
641
660
  "KatasLibrary.qs",
642
- "multi_qubit_systems__common.qs",
643
661
  "multi_qubit_systems__prepare_basis_state__verification.qs"
644
662
  ],
645
663
  "placeholderCode": "namespace Kata {\n operation PrepareBasisState(qs : Qubit[]) : Unit is Adj + Ctl {\n // Implement your solution here...\n\n }\n}",
@@ -665,12 +683,11 @@ export default {
665
683
  "title": "Prepare a Superposition of Two Basis States",
666
684
  "description": {
667
685
  "type": "text-content",
668
- "asHtml": "<p><strong>Input:</strong> A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \\end{bmatrix}$.</p>\n<p><strong>Goal:</strong> Transform the system into the state $\\frac{1}{\\sqrt2}\\big(|00\\rangle - |01\\rangle\\big) = \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\ -1 \\\\ 0 \\\\ 0 \\end{bmatrix}$.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $|0\\rangle \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle - |1\\rangle\\big) = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\end{bmatrix}$.\n</details>\n",
669
- "asMarkdown": "**Input:** A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}$.\n\n**Goal:** Transform the system into the state $\\frac{1}{\\sqrt2}\\big(|00\\rangle - |01\\rangle\\big) = \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $|0\\rangle \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle - |1\\rangle\\big) = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\end{bmatrix}$.\n</details>\n"
686
+ "asHtml": "<p><strong>Input:</strong> A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}$.</p>\n<p><strong>Goal:</strong> Transform the system into the state $\\frac{1}{\\sqrt2}\\big(|00\\rangle - |01\\rangle\\big) = \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\ -1 \\\\ 0 \\\\ 0 \\end{bmatrix}$.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $|0\\rangle \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle - |1\\rangle\\big) = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\end{bmatrix}$.\n</details>\n",
687
+ "asMarkdown": "**Input:** A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$.\n\n**Goal:** Transform the system into the state $\\frac{1}{\\sqrt2}\\big(|00\\rangle - |01\\rangle\\big) = \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $|0\\rangle \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle - |1\\rangle\\big) = \\begin{bmatrix} 1 \\\\\\ 0 \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ -1 \\end{bmatrix}$.\n</details>\n"
670
688
  },
671
689
  "sourceIds": [
672
690
  "KatasLibrary.qs",
673
- "multi_qubit_systems__common.qs",
674
691
  "multi_qubit_systems__prepare_superposition__verification.qs"
675
692
  ],
676
693
  "placeholderCode": "namespace Kata {\n operation PrepareSuperposition(qs : Qubit[]) : Unit is Adj + Ctl {\n // Implement your solution here...\n\n }\n}",
@@ -701,7 +718,6 @@ export default {
701
718
  },
702
719
  "sourceIds": [
703
720
  "KatasLibrary.qs",
704
- "multi_qubit_systems__common.qs",
705
721
  "multi_qubit_systems__prepare_with_real__verification.qs"
706
722
  ],
707
723
  "placeholderCode": "namespace Kata {\n operation PrepareWithReal(qs : Qubit[]) : Unit is Adj + Ctl {\n // Implement your solution here...\n\n }\n}",
@@ -727,12 +743,11 @@ export default {
727
743
  "title": "Prepare a Superposition with Complex Amplitudes",
728
744
  "description": {
729
745
  "type": "text-content",
730
- "asHtml": "<p><strong>Input:</strong> A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \\end{bmatrix}$.</p>\n<p><strong>Goal:</strong> Transform the system into the state $\\frac{1}{2}\\big(|00\\rangle + e^{i\\pi/4}|01\\rangle + e^{i\\pi/2}|10\\rangle + e^{3i\\pi/4}|11\\rangle\\big) = \\frac{1}{2}\\begin{bmatrix} 1 \\ e^{i\\pi/4} \\ e^{i\\pi/2} \\ e^{3i\\pi/4} \\end{bmatrix}$.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $\\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/2}|1\\rangle\\big) \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/4}|1\\rangle\\big) = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ e^{i\\pi/2} \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ e^{i\\pi/4} \\end{bmatrix}$.\n</details>\n",
731
- "asMarkdown": "\n**Input:** A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}$.\n\n**Goal:** Transform the system into the state $\\frac{1}{2}\\big(|00\\rangle + e^{i\\pi/4}|01\\rangle + e^{i\\pi/2}|10\\rangle + e^{3i\\pi/4}|11\\rangle\\big) = \\frac{1}{2}\\begin{bmatrix} 1 \\\\ e^{i\\pi/4} \\\\ e^{i\\pi/2} \\\\ e^{3i\\pi/4} \\end{bmatrix}$.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $\\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/2}|1\\rangle\\big) \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/4}|1\\rangle\\big) = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ e^{i\\pi/2} \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ e^{i\\pi/4} \\end{bmatrix}$.\n</details>\n"
746
+ "asHtml": "<p><strong>Input:</strong> A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ 0 \\end{bmatrix}$.</p>\n<p><strong>Goal:</strong> Transform the system into the state $\\frac{1}{2}\\big(|00\\rangle + e^{i\\pi/4}|01\\rangle + e^{i\\pi/2}|10\\rangle + e^{3i\\pi/4}|11\\rangle\\big) = \\frac{1}{2}\\begin{bmatrix} 1 \\\\ e^{i\\pi/4} \\\\ e^{i\\pi/2} \\\\ e^{3i\\pi/4} \\end{bmatrix}$.</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $\\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/2}|1\\rangle\\big) \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/4}|1\\rangle\\big) = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ e^{i\\pi/2} \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ e^{i\\pi/4} \\end{bmatrix}$.\n</details>\n",
747
+ "asMarkdown": "\n**Input:** A two-qubit system in the basis state $|00\\rangle = \\begin{bmatrix} 1 \\\\\\ 0 \\\\\\ 0 \\\\\\ 0 \\end{bmatrix}$.\n\n**Goal:** Transform the system into the state $\\frac{1}{2}\\big(|00\\rangle + e^{i\\pi/4}|01\\rangle + e^{i\\pi/2}|10\\rangle + e^{3i\\pi/4}|11\\rangle\\big) = \\frac{1}{2}\\begin{bmatrix} 1 \\\\\\ e^{i\\pi/4} \\\\\\ e^{i\\pi/2} \\\\\\ e^{3i\\pi/4} \\end{bmatrix}$.\n\n<details>\n <summary><b>Need a hint?</b></summary>\n Represent the target state as a tensor product $\\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/2}|1\\rangle\\big) \\otimes \\frac{1}{\\sqrt2}\\big(|0\\rangle + e^{i\\pi/4}|1\\rangle\\big) = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 \\\\\\ e^{i\\pi/2} \\end{bmatrix} \\otimes \\frac{1}{\\sqrt2}\\begin{bmatrix} 1 \\\\\\ e^{i\\pi/4} \\end{bmatrix}$.\n</details>\n"
732
748
  },
733
749
  "sourceIds": [
734
750
  "KatasLibrary.qs",
735
- "multi_qubit_systems__common.qs",
736
751
  "multi_qubit_systems__prepare_with_complex__verification.qs"
737
752
  ],
738
753
  "placeholderCode": "namespace Kata {\n operation PrepareWithComplex(qs : Qubit[]) : Unit is Adj + Ctl {\n // Implement your solution here...\n\n }\n}",
@@ -759,8 +774,8 @@ export default {
759
774
  "items": [
760
775
  {
761
776
  "type": "text-content",
762
- "asHtml": "<p>Congratulations! In this kata you learned to prepare separable multi-qubit states using only single-qubit gates. You also learned the difference between separable states an entangled states. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>A system of $N$ qubits can also be in a superposition of $2^N$ quantum states. The computational basis for an $N$-qubit system is a set of $2^N$ vectors.</li>\n<li>Any two-qubit system can be expressed as some linear combination of the tensor product of single-qubit basis states.</li>\n<li>Two qubits are entangled if their states are correlated and if they can&#39;t be described as two independent qubits.</li>\n</ul>\n<p>Next, you will learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the &quot;Multi-Qubit Gates&quot; kata.</p>\n",
763
- "asMarkdown": "\nCongratulations! In this kata you learned to prepare separable multi-qubit states using only single-qubit gates. You also learned the difference between separable states an entangled states. Here are a few key concepts to keep in mind:\n\n- A system of $N$ qubits can also be in a superposition of $2^N$ quantum states. The computational basis for an $N$-qubit system is a set of $2^N$ vectors.\n- Any two-qubit system can be expressed as some linear combination of the tensor product of single-qubit basis states.\n- Two qubits are entangled if their states are correlated and if they can't be described as two independent qubits.\n\nNext, you will learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the \"Multi-Qubit Gates\" kata."
777
+ "asHtml": "<p>Congratulations! In this kata you learned to prepare separable multi-qubit states using only single-qubit gates. You also learned the difference between separable states and entangled states. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>A system of $N$ qubits can be in a superposition of $2^N$ quantum states. The computational basis for an $N$-qubit system is a set of $2^N$ vectors.</li>\n<li>Any two-qubit system can be expressed as some linear combination of the tensor products of single-qubit basis states.</li>\n<li>Two qubits are entangled if their states are correlated and if they can&#39;t be described as two independent qubits.</li>\n</ul>\n<p>Next, you will learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the &quot;Multi-Qubit Gates&quot; kata.</p>\n",
778
+ "asMarkdown": "\nCongratulations! In this kata you learned to prepare separable multi-qubit states using only single-qubit gates. You also learned the difference between separable states and entangled states. Here are a few key concepts to keep in mind:\n\n- A system of $N$ qubits can be in a superposition of $2^N$ quantum states. The computational basis for an $N$-qubit system is a set of $2^N$ vectors.\n- Any two-qubit system can be expressed as some linear combination of the tensor products of single-qubit basis states.\n- Two qubits are entangled if their states are correlated and if they can't be described as two independent qubits.\n\nNext, you will learn about multi-qubit gates and how they can give you access to all states of multi-qubit systems in the \"Multi-Qubit Gates\" kata."
764
779
  }
765
780
  ]
766
781
  }
@@ -2297,7 +2312,7 @@ export default {
2297
2312
  "globalCodeSources": [
2298
2313
  {
2299
2314
  "id": "KatasLibrary.qs",
2300
- "code": "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nnamespace Microsoft.Quantum.Katas {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Intrinsic;\n\n /// # Summary\n /// Given two operations, checks whether they act identically for all input states.\n /// This operation is implemented by using the Choi–Jamiołkowski isomorphism.\n ///\n /// N.B. Investigate whether this can be done using just 1 control qubit (GitHub issue #535).\n operation CheckOperationsEquivalence(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use (control, target) = (Qubit[inputSize], Qubit[inputSize]);\n within {\n // N.B. The order in which quantum registers are passed to this operation is important.\n EntangleRegisters(control, target);\n }\n apply {\n op(target);\n Adjoint reference(target);\n }\n\n let areEquivalent = CheckAllZero(control + target);\n ResetAll(control + target);\n areEquivalent\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically (including global phase) for all input states.\n /// This is done through controlled versions of the operations instead of plain ones which convert the global phase\n /// into a relative phase that can be detected.\n operation CheckOperationsEquivalenceStrict(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n let controlledOp = register => Controlled op(register[...0], register[1...]);\n let controlledReference = register => Controlled reference(register[...0], register[1...]);\n let areEquivalent = CheckOperationsEquivalence(controlledOp, controlledReference, inputSize + 1);\n areEquivalent\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically on the zero state |0〉 ⊗ |0〉 ⊗ ... ⊗ |0〉 composed of\n /// `inputSize` qubits.\n operation CheckOperationsEquivalenceOnZeroState(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use target = Qubit[inputSize];\n op(target);\n Adjoint reference(target);\n let isCorrect = CheckAllZero(target);\n ResetAll(target);\n isCorrect\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically on the zero state |0〉 ⊗ |0〉 ⊗ ... ⊗ |0〉 composed of\n /// `inputSize` qubits.\n /// This operation introduces a control qubit to convert a global phase into a relative phase to be able to detect\n /// it.\n operation CheckOperationsEquivalenceOnZeroStateStrict(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use control = Qubit();\n use target = Qubit[inputSize];\n within {\n H(control);\n }\n apply {\n Controlled op([control], target);\n Adjoint Controlled reference([control], target);\n }\n\n let isCorrect = CheckAllZero([control] + target);\n ResetAll([control] + target);\n isCorrect\n }\n\n /// # Summary\n /// Shows the effect a quantum operation has on the quantum state.\n operation ShowEffectOnQuantumState(targetRegister : Qubit[], op : (Qubit[] => Unit is Adj + Ctl)) : Unit {\n Message(\"Quantum state before applying the operation:\");\n DumpMachine();\n\n // Apply the operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n Message(\"Quantum state after applying the operation:\");\n op(targetRegister);\n DumpMachine();\n Adjoint op(targetRegister);\n }\n\n /// # Summary\n /// Shows the comparison of the quantum state between a specific operation and a reference operation.\n operation ShowQuantumStateComparison(\n targetRegister : Qubit[],\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl))\n : Unit {\n Message(\"Initial quantum state:\");\n DumpMachine();\n\n // Apply the reference operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n reference(targetRegister);\n Message(\"Expected quantum state after applying the operation:\");\n DumpMachine();\n Adjoint reference(targetRegister);\n\n // Apply the specific operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n op(targetRegister);\n Message(\"Actual quantum state after applying the operation:\");\n DumpMachine();\n Adjoint op(targetRegister);\n }\n\n internal operation EntangleRegisters(\n control : Qubit[],\n target : Qubit[]) : Unit is Adj + Ctl {\n Fact(\n Length(control) == Length(target),\n $\"The length of qubit registers must be the same.\");\n\n for index in IndexRange(control) {\n H(control[index]);\n CNOT(control[index], target[index]);\n }\n }\n}\n"
2315
+ "code": "// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nnamespace Microsoft.Quantum.Katas {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Intrinsic;\n\n /// # Summary\n /// Given two operations, checks whether they act identically for all input states.\n /// This operation is implemented by using the Choi–Jamiołkowski isomorphism.\n operation CheckOperationsEquivalence(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use (control, target) = (Qubit[inputSize], Qubit[inputSize]);\n within {\n EntangleRegisters(control, target);\n }\n apply {\n op(target);\n Adjoint reference(target);\n }\n\n let areEquivalent = CheckAllZero(control + target);\n ResetAll(control + target);\n areEquivalent\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically (including global phase) for all input states.\n /// This is done through controlled versions of the operations instead of plain ones which convert the global phase\n /// into a relative phase that can be detected.\n operation CheckOperationsEquivalenceStrict(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n let controlledOp = register => Controlled op(register[...0], register[1...]);\n let controlledReference = register => Controlled reference(register[...0], register[1...]);\n let areEquivalent = CheckOperationsEquivalence(controlledOp, controlledReference, inputSize + 1);\n areEquivalent\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically on the zero state |0〉 ⊗ |0〉 ⊗ ... ⊗ |0〉 composed of\n /// `inputSize` qubits.\n operation CheckOperationsEquivalenceOnZeroState(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use target = Qubit[inputSize];\n op(target);\n Adjoint reference(target);\n let isCorrect = CheckAllZero(target);\n ResetAll(target);\n isCorrect\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically on the zero state |0〉 ⊗ |0〉 ⊗ ... ⊗ |0〉 composed of\n /// `inputSize` qubits.\n /// This operation introduces a control qubit to convert a global phase into a relative phase to be able to detect\n /// it.\n operation CheckOperationsEquivalenceOnZeroStateStrict(\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int)\n : Bool {\n Fact(inputSize > 0, \"`inputSize` must be positive\");\n use control = Qubit();\n use target = Qubit[inputSize];\n within {\n H(control);\n }\n apply {\n Controlled op([control], target);\n Adjoint Controlled reference([control], target);\n }\n\n let isCorrect = CheckAllZero([control] + target);\n ResetAll([control] + target);\n isCorrect\n }\n\n /// # Summary\n /// Shows the effect a quantum operation has on the quantum state.\n operation ShowEffectOnQuantumState(targetRegister : Qubit[], op : (Qubit[] => Unit is Adj + Ctl)) : Unit {\n Message(\"Quantum state before applying the operation:\");\n DumpMachine();\n\n // Apply the operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n Message(\"Quantum state after applying the operation:\");\n op(targetRegister);\n DumpMachine();\n Adjoint op(targetRegister);\n }\n\n /// # Summary\n /// Shows the comparison of the quantum state between a specific operation and a reference operation.\n operation ShowQuantumStateComparison(\n targetRegister : Qubit[],\n op : (Qubit[] => Unit is Adj + Ctl),\n reference : (Qubit[] => Unit is Adj + Ctl))\n : Unit {\n Message(\"Initial quantum state:\");\n DumpMachine();\n\n // Apply the reference operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n reference(targetRegister);\n Message(\"Expected quantum state after applying the operation:\");\n DumpMachine();\n Adjoint reference(targetRegister);\n\n // Apply the specific operation, dump the simulator state and \"undo\" the operation by applying the adjoint.\n op(targetRegister);\n Message(\"Actual quantum state after applying the operation:\");\n DumpMachine();\n Adjoint op(targetRegister);\n }\n\n /// # Summary\n /// Given two operations, checks whether they act identically on the zero state |0〉 ⊗ |0〉 ⊗ ... ⊗ |0〉 composed of\n /// `inputSize` qubits. If they don't, prints user feedback.\n operation CheckOperationsEquivalenceOnZeroStateWithFeedback(\n testImpl : (Qubit[] => Unit is Adj + Ctl),\n refImpl : (Qubit[] => Unit is Adj + Ctl),\n inputSize : Int\n ) : Bool {\n\n let isCorrect = CheckOperationsEquivalenceOnZeroState(testImpl, refImpl, inputSize);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n use target = Qubit[inputSize];\n ShowQuantumStateComparison(target, testImpl, refImpl);\n ResetAll(target);\n }\n isCorrect\n }\n\n\n internal operation EntangleRegisters(\n control : Qubit[],\n target : Qubit[]) : Unit is Adj + Ctl {\n Fact(\n Length(control) == Length(target),\n $\"The length of qubit registers must be the same.\");\n\n for index in IndexRange(control) {\n H(control[index]);\n CNOT(control[index], target[index]);\n }\n }\n}\n"
2301
2316
  },
2302
2317
  {
2303
2318
  "id": "getting_started__flip_qubit__Verification.qs",
@@ -2307,57 +2322,53 @@ export default {
2307
2322
  "id": "qubit__learn_single_qubit_state__Verification.qs",
2308
2323
  "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Math;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n use q = Qubit();\n\n // Prepare the state that will be passed to the solution.\n let angle = 0.5;\n Ry(angle, q);\n\n // Call the solution and get the answer.\n let (a, b) = Kata.LearnSingleQubitState(q);\n\n // Calculate the expected values based on the rotation angle.\n let (a_exp, b_exp) = (Cos(0.5 * angle), Sin(0.5 * angle));\n\n Reset(q);\n\n let isCorrect =\n (AbsD(a - a_exp) <= 0.001) and\n (AbsD(b - b_exp) <= 0.001);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"All tests passed.\");\n } else {\n Message(\"At least one of the amplitudes was too far from the expected value.\");\n }\n\n isCorrect\n }\n}\n"
2309
2324
  },
2310
- {
2311
- "id": "qubit__learn_basis_state_amplitudes__Verification.qs",
2312
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Math;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n use qs = Qubit[2];\n\n // Prepare the state that will be passed to the solution.\n H(qs[0]);\n ApplyControlledOnInt(0, Ry(1.0, _), [qs[0]], qs[1]);\n ApplyControlledOnInt(1, Ry(2.0, _), [qs[0]], qs[1]);\n\n // Call the solution and get the answer.\n let (x1, x2) = Kata.LearnBasisStateAmplitudes(qs);\n\n // Calculate the expected values based on the rotation angle.\n // We convert |00⟩ + |10⟩ to |0⟩ Ry(1.0)|0⟩ + |1⟩ Ry(2.0)|0⟩, so\n // * the amplitude of |1⟩ = |10⟩ is 1st amp of Ry(2.0)|0⟩\n // * the amplitude of |2⟩ = |01⟩ is 2nd amp of Ry(1.0)|0⟩\n let (x1_exp, x2_exp) = (\n 1.0/Sqrt(2.0) * Cos(0.5 * 2.0),\n 1.0/Sqrt(2.0) * Sin(0.5 * 1.0));\n\n let isCorrect =\n (AbsD(x1 - x1_exp) <= 0.001) and\n (AbsD(x2 - x2_exp) <= 0.001);\n\n ResetAll(qs);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"All tests passed.\");\n } else {\n Message(\"One of the amplitudes was too far from the expected value.\");\n }\n\n isCorrect\n }\n}\n"
2313
- },
2314
2325
  {
2315
2326
  "id": "single_qubit_gates__y_gate__Verification.qs",
2316
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n\n operation ApplyY(q : Qubit) : Unit is Adj + Ctl {\n Y(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.ApplyY(register[0]);\n let reference = register => ApplyY(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the solution was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the |0〉 state and compare it with the effect it \" +\n \"is expected to have.\");\n use target = Qubit[1]; // |0〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n }\n isCorrect\n }\n}\n"
2327
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation ApplyY(q : Qubit) : Unit is Adj + Ctl {\n Y(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.ApplyY(register[0]);\n let reference = register => ApplyY(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the solution was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it \" +\n \"is expected to have.\");\n use initial = Qubit(); // |0〉\n Ry(ArcTan2(0.8, 0.6) * 2.0, initial); // 0.6|0〉 + 0.8|1〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n }\n isCorrect\n }\n}\n"
2317
2328
  },
2318
2329
  {
2319
2330
  "id": "single_qubit_gates__global_phase_i__Verification.qs",
2320
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n\n operation GlobalPhaseI(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n Y(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.GlobalPhaseI(register[0]);\n let reference = register => GlobalPhaseI(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the solution was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the |0〉 state and compare it with the effect it \" +\n \"is expected to have.\");\n use target = Qubit[1]; // |0〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n }\n isCorrect\n }\n}\n"
2331
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation GlobalPhaseI(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n Y(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.GlobalPhaseI(register[0]);\n let reference = register => GlobalPhaseI(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the solution was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it \" +\n \"is expected to have.\");\n use initial = Qubit(); // |0〉\n Ry(ArcTan2(0.8, 0.6) * 2.0, initial); // 0.6|0〉 + 0.8|1〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n }\n isCorrect\n }\n}\n"
2321
2332
  },
2322
2333
  {
2323
2334
  "id": "single_qubit_gates__sign_flip_on_zero__Verification.qs",
2324
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n\n operation SignFlipOnZero(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n X(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.SignFlipOnZero(register[0]);\n let reference = register => SignFlipOnZero(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the |+〉 state and compare it with the effect it \" +\n \"is expected to have.\");\n use target = Qubit[1]; // |0〉\n H(target[0]); // |+〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n }\n isCorrect\n }\n}\n"
2335
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation SignFlipOnZero(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n X(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.SignFlipOnZero(register[0]);\n let reference = register => SignFlipOnZero(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it \" +\n \"is expected to have.\");\n use initial = Qubit(); // |0〉\n Ry(ArcTan2(0.8, 0.6) * 2.0, initial); // 0.6|0〉 + 0.8|1〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n }\n isCorrect\n }\n}\n"
2325
2336
  },
2326
2337
  {
2327
2338
  "id": "single_qubit_gates__prepare_minus__Verification.qs",
2328
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n\n operation PrepareMinus(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n H(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.PrepareMinus(register[0]);\n let reference = register => PrepareMinus(register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the |0〉 state and compare it with the effect it \" +\n \"is expected to have.\");\n use target = Qubit[1]; // |0〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n }\n isCorrect\n }\n}\n"
2339
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareMinus(q : Qubit) : Unit is Adj + Ctl {\n X(q);\n H(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.PrepareMinus(register[0]);\n let reference = register => PrepareMinus(register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the state prepared by your solution and compare it with the state it \" +\n \"is expected to prepare.\");\n use initial = Qubit(); // |0〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n }\n isCorrect\n }\n}\n"
2329
2340
  },
2330
2341
  {
2331
2342
  "id": "single_qubit_gates__three_quarters_pi_phase__Verification.qs",
2332
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Diagnostics;\n\n operation ThreeQuartersPiPhase(q : Qubit) : Unit is Adj + Ctl {\n S(q);\n T(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.ThreeQuartersPiPhase(register[0]);\n let reference = register => ThreeQuartersPiPhase(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"The solution was incorrect for at least one test case.\");\n use target = Qubit[1];\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n }\n isCorrect\n }\n}\n"
2343
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation ThreeQuartersPiPhase(q : Qubit) : Unit is Adj + Ctl {\n S(q);\n T(q);\n }\n\n operation CheckSolution() : Bool {\n let solution = register => Kata.ThreeQuartersPiPhase(register[0]);\n let reference = register => ThreeQuartersPiPhase(register[0]);\n let isCorrect = CheckOperationsEquivalenceStrict(solution, reference, 1);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n Message(\"Hint: examine the effect your solution has on the state 0.6|0〉 + 0.8|1〉 and compare it with the effect it \" +\n \"is expected to have.\");\n use initial = Qubit(); // |0〉\n Ry(ArcTan2(0.8, 0.6) * 2.0, initial); // 0.6|0〉 + 0.8|1〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n }\n isCorrect\n }\n}\n"
2333
2344
  },
2334
2345
  {
2335
2346
  "id": "single_qubit_gates__prepare_rotated_state__Verification.qs",
2336
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Canon;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Katas;\n\n operation PrepareRotatedState (alpha : Double, beta : Double, q : Qubit) : Unit is Adj+Ctl {\n let phi = ArcTan2(beta, alpha);\n Rx(2.0 * phi, q);\n }\n\n operation CheckSolution() : Bool {\n for i in 0 .. 10 {\n let i = IntAsDouble(i);\n let alpha = Cos(i);\n let beta = Sin(i);\n let solution = register => Kata.PrepareRotatedState(alpha, beta, register[0]);\n let reference = register => PrepareRotatedState(alpha, beta, register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n if not isCorrect {\n Message(\"Incorrect.\");\n Message(\"The solution was incorrect for at least one test case.\");\n Message(\"Hint: examine the effect your solution has on the |0〉 state and compare it with the effect \" +\n \"it is expected to have.\");\n use target = Qubit[1]; // |0〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n return false;\n }\n }\n\n Message(\"Correct!\");\n Message(\"The solution was correct for all test cases.\");\n true\n }\n}\n"
2347
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation PrepareRotatedState (alpha : Double, beta : Double, q : Qubit) : Unit is Adj+Ctl {\n let phi = ArcTan2(beta, alpha);\n Rx(2.0 * phi, q);\n }\n\n operation CheckSolution() : Bool {\n for i in 0 .. 10 {\n let i = IntAsDouble(i);\n let alpha = Cos(i);\n let beta = Sin(i);\n let solution = register => Kata.PrepareRotatedState(alpha, beta, register[0]);\n let reference = register => PrepareRotatedState(alpha, beta, register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n if not isCorrect {\n Message(\"Incorrect.\");\n Message($\"The solution was incorrect for the test case alpha = {alpha}, beta = {beta}.\");\n Message(\"Hint: examine the state prepared by your solution and compare it with the state it \" +\n \"is expected to prepare.\");\n use initial = Qubit(); // |0〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n return false;\n }\n }\n\n Message(\"Correct!\");\n Message(\"The solution was correct for all test cases.\");\n true\n }\n}\n"
2337
2348
  },
2338
2349
  {
2339
2350
  "id": "single_qubit_gates__prepare_arbitrary_state__Verification.qs",
2340
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Convert;\n\n operation PrepareArbitraryState (alpha : Double, beta : Double, theta : Double, q : Qubit) : Unit is Adj+Ctl {\n let phi = ArcTan2(beta, alpha);\n Ry(2.0 * phi, q);\n R1(theta, q);\n }\n\n operation CheckSolution() : Bool {\n for i in 0 .. 10 {\n let i = IntAsDouble(i);\n let alpha = Cos(i);\n let beta = Sin(i);\n let theta = Sin(i);\n let solution = register => Kata.PrepareArbitraryState(alpha, beta, theta, register[0]);\n let reference = register => PrepareArbitraryState(alpha, beta, theta, register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n if not isCorrect {\n Message(\"Incorrect.\");\n Message(\"The solution was incorrect for at least one test case.\");\n Message(\"Hint: examine the effect your solution has on the |0〉 state and compare it with the effect \" +\n \"it is expected to have.\");\n use target = Qubit[1]; // |0〉\n ShowQuantumStateComparison(target, solution, reference);\n ResetAll(target);\n return false;\n }\n }\n\n Message(\"Correct!\");\n Message(\"The solution was correct for all test cases.\");\n true\n }\n}\n"
2351
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n\n operation PrepareArbitraryState (alpha : Double, beta : Double, theta : Double, q : Qubit) : Unit is Adj+Ctl {\n let phi = ArcTan2(beta, alpha);\n Ry(2.0 * phi, q);\n R1(theta, q);\n }\n\n operation CheckSolution() : Bool {\n for i in 0 .. 10 {\n let i = IntAsDouble(i);\n let alpha = Cos(i);\n let beta = Sin(i);\n let theta = Sin(i);\n let solution = register => Kata.PrepareArbitraryState(alpha, beta, theta, register[0]);\n let reference = register => PrepareArbitraryState(alpha, beta, theta, register[0]);\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(solution, reference, 1);\n if not isCorrect {\n Message(\"Incorrect.\");\n Message($\"The solution was incorrect for the test case alpha = {alpha}, beta = {beta}, theta = {theta}.\");\n Message(\"Hint: examine the state prepared by your solution and compare it with the state it \" +\n \"is expected to prepare.\");\n use initial = Qubit(); // |0〉\n ShowQuantumStateComparison([initial], solution, reference);\n Reset(initial);\n return false;\n }\n }\n\n Message(\"Correct!\");\n Message(\"The solution was correct for all test cases.\");\n true\n }\n}\n"
2341
2352
  },
2342
2353
  {
2343
- "id": "multi_qubit_systems__common.qs",
2344
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation CheckEqualOnZeroState(\n testImpl : (Qubit[] => Unit is Adj + Ctl),\n refImpl : (Qubit[] => Unit is Adj + Ctl)) : Bool {\n\n let isCorrect = CheckOperationsEquivalenceOnZeroStateStrict(testImpl, refImpl, 2);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n use target = Qubit[2]; // |00〉\n ShowQuantumStateComparison(target, testImpl, refImpl);\n ResetAll(target);\n }\n isCorrect\n }\n\n}\n"
2354
+ "id": "multi_qubit_systems__learn_basis_state_amplitudes__verification.qs",
2355
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Math;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n use qs = Qubit[2];\n\n // Prepare the state that will be passed to the solution.\n H(qs[0]);\n ApplyControlledOnInt(0, Ry(1.0, _), [qs[0]], qs[1]);\n ApplyControlledOnInt(1, Ry(2.0, _), [qs[0]], qs[1]);\n\n // Call the solution and get the answer.\n let (x1, x2) = Kata.LearnBasisStateAmplitudes(qs);\n\n // Calculate the expected values based on the rotation angle.\n // We convert |00⟩ + |10⟩ to |0⟩ Ry(1.0)|0⟩ + |1⟩ Ry(2.0)|0⟩, so\n // * the amplitude of |01⟩ is 2nd amp of Ry(1.0)|0⟩\n // * the amplitude of |10⟩ is 1st amp of Ry(2.0)|0⟩\n let (x1_exp, x2_exp) = (\n 1.0/Sqrt(2.0) * Sin(0.5 * 1.0),\n 1.0/Sqrt(2.0) * Cos(0.5 * 2.0));\n\n let isCorrect =\n (AbsD(x1 - x1_exp) <= 0.001) and\n (AbsD(x2 - x2_exp) <= 0.001);\n\n ResetAll(qs);\n\n // Output different feedback to the user depending on whether the exercise was correct.\n if isCorrect {\n Message(\"All tests passed.\");\n } else {\n Message(\"One of the amplitudes was too far from the expected value.\");\n }\n\n isCorrect\n }\n}\n"
2345
2356
  },
2346
2357
  {
2347
2358
  "id": "multi_qubit_systems__prepare_basis_state__verification.qs",
2348
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareBasisState_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n X(qs[0]);\n X(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckEqualOnZeroState(Kata.PrepareBasisState, PrepareBasisState_Reference)\n }\n}\n"
2359
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareBasisState_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n X(qs[0]);\n X(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckOperationsEquivalenceOnZeroStateWithFeedback(Kata.PrepareBasisState, \n PrepareBasisState_Reference, 2)\n }\n}\n"
2349
2360
  },
2350
2361
  {
2351
2362
  "id": "multi_qubit_systems__prepare_superposition__verification.qs",
2352
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareSuperposition_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n X(qs[1]);\n H(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckEqualOnZeroState(Kata.PrepareSuperposition, PrepareSuperposition_Reference)\n }\n}\n"
2363
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareSuperposition_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n X(qs[1]);\n H(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckOperationsEquivalenceOnZeroStateWithFeedback(Kata.PrepareSuperposition, \n PrepareSuperposition_Reference, 2)\n }\n}\n"
2353
2364
  },
2354
2365
  {
2355
2366
  "id": "multi_qubit_systems__prepare_with_real__verification.qs",
2356
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareWithReal_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n H(qs[0]);\n X(qs[1]);\n H(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckEqualOnZeroState(Kata.PrepareWithReal, PrepareWithReal_Reference)\n }\n}\n"
2367
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareWithReal_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n H(qs[0]);\n X(qs[1]);\n H(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckOperationsEquivalenceOnZeroStateWithFeedback(Kata.PrepareWithReal, \n PrepareWithReal_Reference, 2)\n }\n}\n"
2357
2368
  },
2358
2369
  {
2359
2370
  "id": "multi_qubit_systems__prepare_with_complex__verification.qs",
2360
- "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareWithComplex_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n H(qs[0]);\n H(qs[1]);\n S(qs[0]);\n T(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckEqualOnZeroState(Kata.PrepareWithComplex, PrepareWithComplex_Reference)\n }\n}\n"
2371
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation PrepareWithComplex_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n H(qs[0]);\n H(qs[1]);\n S(qs[0]);\n T(qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n CheckOperationsEquivalenceOnZeroStateWithFeedback(Kata.PrepareWithComplex, \n PrepareWithComplex_Reference, 2)\n }\n}\n"
2361
2372
  },
2362
2373
  {
2363
2374
  "id": "multi_qubit_gates__compound_gate__Verification.qs",