qsharp-lang 1.5.4-dev → 1.5.6-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 (273) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/compiler/compiler.d.ts +1 -1
  3. package/dist/compiler/compiler.js +6 -4
  4. package/dist/katas-content.generated.d.ts +1 -0
  5. package/dist/katas-content.generated.js +952 -64
  6. package/dist/katas.d.ts +4 -1
  7. package/dist/katas.js +3 -3
  8. package/dist/language-service/language-service.d.ts +3 -1
  9. package/dist/language-service/language-service.js +4 -0
  10. package/dist/samples.generated.js +3 -3
  11. package/docs/Microsoft.Quantum.Arrays/All.md +1 -1
  12. package/docs/Microsoft.Quantum.Arrays/Any.md +1 -1
  13. package/docs/Microsoft.Quantum.Arrays/Chunks.md +1 -1
  14. package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +1 -1
  15. package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +1 -1
  16. package/docs/Microsoft.Quantum.Arrays/Count.md +1 -1
  17. package/docs/Microsoft.Quantum.Arrays/Diagonal.md +1 -1
  18. package/docs/Microsoft.Quantum.Arrays/DrawMany.md +1 -1
  19. package/docs/Microsoft.Quantum.Arrays/Enumerated.md +1 -1
  20. package/docs/Microsoft.Quantum.Arrays/Excluding.md +1 -1
  21. package/docs/Microsoft.Quantum.Arrays/Filtered.md +1 -1
  22. package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +1 -1
  23. package/docs/Microsoft.Quantum.Arrays/Flattened.md +1 -1
  24. package/docs/Microsoft.Quantum.Arrays/Fold.md +1 -1
  25. package/docs/Microsoft.Quantum.Arrays/ForEach.md +1 -1
  26. package/docs/Microsoft.Quantum.Arrays/Head.md +1 -1
  27. package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +1 -1
  28. package/docs/Microsoft.Quantum.Arrays/IndexOf.md +1 -1
  29. package/docs/Microsoft.Quantum.Arrays/IndexRange.md +1 -1
  30. package/docs/Microsoft.Quantum.Arrays/Interleaved.md +1 -1
  31. package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +1 -1
  32. package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +1 -1
  33. package/docs/Microsoft.Quantum.Arrays/IsSorted.md +1 -1
  34. package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +1 -1
  35. package/docs/Microsoft.Quantum.Arrays/Mapped.md +1 -1
  36. package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +1 -1
  37. package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +1 -1
  38. package/docs/Microsoft.Quantum.Arrays/Most.md +1 -1
  39. package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +1 -1
  40. package/docs/Microsoft.Quantum.Arrays/Padded.md +1 -1
  41. package/docs/Microsoft.Quantum.Arrays/Partitioned.md +1 -1
  42. package/docs/Microsoft.Quantum.Arrays/Rest.md +1 -1
  43. package/docs/Microsoft.Quantum.Arrays/Reversed.md +1 -1
  44. package/docs/Microsoft.Quantum.Arrays/SequenceI.md +1 -1
  45. package/docs/Microsoft.Quantum.Arrays/SequenceL.md +1 -1
  46. package/docs/Microsoft.Quantum.Arrays/Sorted.md +1 -1
  47. package/docs/Microsoft.Quantum.Arrays/Subarray.md +1 -1
  48. package/docs/Microsoft.Quantum.Arrays/Swapped.md +1 -1
  49. package/docs/Microsoft.Quantum.Arrays/Tail.md +1 -1
  50. package/docs/Microsoft.Quantum.Arrays/Transposed.md +1 -1
  51. package/docs/Microsoft.Quantum.Arrays/Unzipped.md +1 -1
  52. package/docs/Microsoft.Quantum.Arrays/Where.md +1 -1
  53. package/docs/Microsoft.Quantum.Arrays/Windows.md +1 -1
  54. package/docs/Microsoft.Quantum.Arrays/Zipped.md +1 -1
  55. package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +1 -1
  56. package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +1 -1
  57. package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +1 -1
  58. package/docs/Microsoft.Quantum.Canon/ApplyP.md +1 -1
  59. package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +1 -1
  60. package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +1 -1
  61. package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +1 -1
  62. package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +1 -1
  63. package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +1 -1
  64. package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +1 -1
  65. package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +1 -1
  66. package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +1 -1
  67. package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +1 -1
  68. package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +1 -1
  69. package/docs/Microsoft.Quantum.Canon/CX.md +1 -1
  70. package/docs/Microsoft.Quantum.Canon/CY.md +1 -1
  71. package/docs/Microsoft.Quantum.Canon/CZ.md +1 -1
  72. package/docs/Microsoft.Quantum.Canon/Fst.md +1 -1
  73. package/docs/Microsoft.Quantum.Canon/Snd.md +1 -1
  74. package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +1 -1
  75. package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +1 -1
  76. package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +1 -1
  77. package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +1 -1
  78. package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +29 -0
  79. package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +29 -0
  80. package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +1 -1
  81. package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +1 -1
  82. package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +1 -1
  83. package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +1 -1
  84. package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +1 -1
  85. package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +29 -0
  86. package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +34 -0
  87. package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +29 -0
  88. package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +1 -1
  89. package/docs/Microsoft.Quantum.Core/Length.md +1 -1
  90. package/docs/Microsoft.Quantum.Core/RangeEnd.md +1 -1
  91. package/docs/Microsoft.Quantum.Core/RangeReverse.md +1 -1
  92. package/docs/Microsoft.Quantum.Core/RangeStart.md +1 -1
  93. package/docs/Microsoft.Quantum.Core/RangeStep.md +1 -1
  94. package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
  95. package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +1 -1
  96. package/docs/Microsoft.Quantum.Diagnostics/DumpRegister.md +1 -1
  97. package/docs/Microsoft.Quantum.Diagnostics/Fact.md +1 -1
  98. package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +1 -1
  99. package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +1 -1
  100. package/docs/Microsoft.Quantum.Intrinsic/Exp.md +1 -1
  101. package/docs/Microsoft.Quantum.Intrinsic/H.md +1 -1
  102. package/docs/Microsoft.Quantum.Intrinsic/I.md +1 -1
  103. package/docs/Microsoft.Quantum.Intrinsic/M.md +1 -1
  104. package/docs/Microsoft.Quantum.Intrinsic/Measure.md +1 -1
  105. package/docs/Microsoft.Quantum.Intrinsic/Message.md +1 -1
  106. package/docs/Microsoft.Quantum.Intrinsic/R.md +1 -1
  107. package/docs/Microsoft.Quantum.Intrinsic/R1.md +1 -1
  108. package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +1 -1
  109. package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +1 -1
  110. package/docs/Microsoft.Quantum.Intrinsic/Reset.md +1 -1
  111. package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +1 -1
  112. package/docs/Microsoft.Quantum.Intrinsic/Rx.md +1 -1
  113. package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +1 -1
  114. package/docs/Microsoft.Quantum.Intrinsic/Ry.md +1 -1
  115. package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +1 -1
  116. package/docs/Microsoft.Quantum.Intrinsic/Rz.md +1 -1
  117. package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +1 -1
  118. package/docs/Microsoft.Quantum.Intrinsic/S.md +1 -1
  119. package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +1 -1
  120. package/docs/Microsoft.Quantum.Intrinsic/T.md +1 -1
  121. package/docs/Microsoft.Quantum.Intrinsic/X.md +1 -1
  122. package/docs/Microsoft.Quantum.Intrinsic/Y.md +1 -1
  123. package/docs/Microsoft.Quantum.Intrinsic/Z.md +1 -1
  124. package/docs/Microsoft.Quantum.Logical/Xor.md +1 -1
  125. package/docs/Microsoft.Quantum.Math/AbsComplex.md +1 -1
  126. package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +1 -1
  127. package/docs/Microsoft.Quantum.Math/AbsD.md +1 -1
  128. package/docs/Microsoft.Quantum.Math/AbsI.md +1 -1
  129. package/docs/Microsoft.Quantum.Math/AbsL.md +1 -1
  130. package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +1 -1
  131. package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +1 -1
  132. package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +1 -1
  133. package/docs/Microsoft.Quantum.Math/ArcCos.md +1 -1
  134. package/docs/Microsoft.Quantum.Math/ArcCosh.md +1 -1
  135. package/docs/Microsoft.Quantum.Math/ArcSin.md +1 -1
  136. package/docs/Microsoft.Quantum.Math/ArcSinh.md +1 -1
  137. package/docs/Microsoft.Quantum.Math/ArcTan.md +1 -1
  138. package/docs/Microsoft.Quantum.Math/ArcTan2.md +1 -1
  139. package/docs/Microsoft.Quantum.Math/ArcTanh.md +1 -1
  140. package/docs/Microsoft.Quantum.Math/ArgComplex.md +1 -1
  141. package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +1 -1
  142. package/docs/Microsoft.Quantum.Math/Binom.md +1 -1
  143. package/docs/Microsoft.Quantum.Math/BitSizeI.md +1 -1
  144. package/docs/Microsoft.Quantum.Math/BitSizeL.md +1 -1
  145. package/docs/Microsoft.Quantum.Math/Ceiling.md +1 -1
  146. package/docs/Microsoft.Quantum.Math/Complex.md +1 -1
  147. package/docs/Microsoft.Quantum.Math/ComplexPolar.md +1 -1
  148. package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +1 -1
  149. package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +1 -1
  150. package/docs/Microsoft.Quantum.Math/Cos.md +1 -1
  151. package/docs/Microsoft.Quantum.Math/Cosh.md +1 -1
  152. package/docs/Microsoft.Quantum.Math/DivRemI.md +1 -1
  153. package/docs/Microsoft.Quantum.Math/DivRemL.md +1 -1
  154. package/docs/Microsoft.Quantum.Math/DividedByC.md +1 -1
  155. package/docs/Microsoft.Quantum.Math/DividedByCP.md +1 -1
  156. package/docs/Microsoft.Quantum.Math/E.md +1 -1
  157. package/docs/Microsoft.Quantum.Math/ExpModI.md +1 -1
  158. package/docs/Microsoft.Quantum.Math/ExpModL.md +1 -1
  159. package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +1 -1
  160. package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +1 -1
  161. package/docs/Microsoft.Quantum.Math/FactorialI.md +1 -1
  162. package/docs/Microsoft.Quantum.Math/FactorialL.md +1 -1
  163. package/docs/Microsoft.Quantum.Math/Floor.md +1 -1
  164. package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +1 -1
  165. package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +1 -1
  166. package/docs/Microsoft.Quantum.Math/HammingWeightI.md +1 -1
  167. package/docs/Microsoft.Quantum.Math/InverseModI.md +1 -1
  168. package/docs/Microsoft.Quantum.Math/InverseModL.md +1 -1
  169. package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +1 -1
  170. package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +1 -1
  171. package/docs/Microsoft.Quantum.Math/IsInfinite.md +1 -1
  172. package/docs/Microsoft.Quantum.Math/IsNaN.md +1 -1
  173. package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +1 -1
  174. package/docs/Microsoft.Quantum.Math/Lg.md +1 -1
  175. package/docs/Microsoft.Quantum.Math/Log.md +1 -1
  176. package/docs/Microsoft.Quantum.Math/Log10.md +1 -1
  177. package/docs/Microsoft.Quantum.Math/LogFactorialD.md +1 -1
  178. package/docs/Microsoft.Quantum.Math/LogGammaD.md +1 -1
  179. package/docs/Microsoft.Quantum.Math/LogOf2.md +1 -1
  180. package/docs/Microsoft.Quantum.Math/Max.md +1 -1
  181. package/docs/Microsoft.Quantum.Math/MaxD.md +1 -1
  182. package/docs/Microsoft.Quantum.Math/MaxI.md +1 -1
  183. package/docs/Microsoft.Quantum.Math/MaxL.md +1 -1
  184. package/docs/Microsoft.Quantum.Math/Min.md +1 -1
  185. package/docs/Microsoft.Quantum.Math/MinD.md +1 -1
  186. package/docs/Microsoft.Quantum.Math/MinI.md +1 -1
  187. package/docs/Microsoft.Quantum.Math/MinL.md +1 -1
  188. package/docs/Microsoft.Quantum.Math/MinusC.md +1 -1
  189. package/docs/Microsoft.Quantum.Math/MinusCP.md +1 -1
  190. package/docs/Microsoft.Quantum.Math/ModulusI.md +1 -1
  191. package/docs/Microsoft.Quantum.Math/ModulusL.md +1 -1
  192. package/docs/Microsoft.Quantum.Math/NegationC.md +1 -1
  193. package/docs/Microsoft.Quantum.Math/NegationCP.md +1 -1
  194. package/docs/Microsoft.Quantum.Math/PI.md +1 -1
  195. package/docs/Microsoft.Quantum.Math/PNorm.md +1 -1
  196. package/docs/Microsoft.Quantum.Math/PNormalized.md +1 -1
  197. package/docs/Microsoft.Quantum.Math/PlusC.md +1 -1
  198. package/docs/Microsoft.Quantum.Math/PlusCP.md +1 -1
  199. package/docs/Microsoft.Quantum.Math/PowC.md +1 -1
  200. package/docs/Microsoft.Quantum.Math/PowCP.md +1 -1
  201. package/docs/Microsoft.Quantum.Math/RealMod.md +1 -1
  202. package/docs/Microsoft.Quantum.Math/Round.md +1 -1
  203. package/docs/Microsoft.Quantum.Math/SignD.md +1 -1
  204. package/docs/Microsoft.Quantum.Math/SignI.md +1 -1
  205. package/docs/Microsoft.Quantum.Math/SignL.md +1 -1
  206. package/docs/Microsoft.Quantum.Math/Sin.md +1 -1
  207. package/docs/Microsoft.Quantum.Math/Sinh.md +1 -1
  208. package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +1 -1
  209. package/docs/Microsoft.Quantum.Math/Sqrt.md +1 -1
  210. package/docs/Microsoft.Quantum.Math/SquaredNorm.md +1 -1
  211. package/docs/Microsoft.Quantum.Math/Tan.md +1 -1
  212. package/docs/Microsoft.Quantum.Math/Tanh.md +1 -1
  213. package/docs/Microsoft.Quantum.Math/TimesC.md +1 -1
  214. package/docs/Microsoft.Quantum.Math/TimesCP.md +1 -1
  215. package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +1 -1
  216. package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +1 -1
  217. package/docs/Microsoft.Quantum.Math/Truncate.md +1 -1
  218. package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +1 -1
  219. package/docs/Microsoft.Quantum.Measurement/MResetX.md +1 -1
  220. package/docs/Microsoft.Quantum.Measurement/MResetY.md +1 -1
  221. package/docs/Microsoft.Quantum.Measurement/MResetZ.md +1 -1
  222. package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +1 -1
  223. package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +1 -1
  224. package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +34 -0
  225. package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +1 -1
  226. package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +1 -1
  227. package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +1 -1
  228. package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +1 -1
  229. package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +1 -1
  230. package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +1 -1
  231. package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +1 -1
  232. package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +1 -1
  233. package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +1 -1
  234. package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +1 -1
  235. package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +1 -1
  236. package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +1 -1
  237. package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +1 -1
  238. package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +1 -1
  239. package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +1 -1
  240. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +1 -1
  241. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +1 -1
  242. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +1 -1
  243. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +1 -1
  244. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
  245. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
  246. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +1 -1
  247. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +1 -1
  248. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
  249. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
  250. package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +1 -1
  251. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +1 -1
  252. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +1 -1
  253. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +1 -1
  254. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +1 -1
  255. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +1 -1
  256. package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +1 -1
  257. package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +1 -1
  258. package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +1 -1
  259. package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +1 -1
  260. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +1 -1
  261. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +1 -1
  262. package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
  263. package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
  264. package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +1 -1
  265. package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +53 -0
  266. package/docs/toc.yml +11 -1
  267. package/lib/node/qsc_wasm.cjs +55 -29
  268. package/lib/node/qsc_wasm.d.cts +18 -2
  269. package/lib/node/qsc_wasm_bg.wasm +0 -0
  270. package/lib/web/qsc_wasm.d.ts +21 -4
  271. package/lib/web/qsc_wasm.js +54 -28
  272. package/lib/web/qsc_wasm_bg.wasm +0 -0
  273. package/package.json +1 -1
@@ -46,7 +46,8 @@ export default {
46
46
  ]
47
47
  }
48
48
  }
49
- ]
49
+ ],
50
+ "published": true
50
51
  },
51
52
  {
52
53
  "id": "complex_arithmetic",
@@ -489,7 +490,8 @@ export default {
489
490
  }
490
491
  ]
491
492
  }
492
- ]
493
+ ],
494
+ "published": true
493
495
  },
494
496
  {
495
497
  "id": "linear_algebra",
@@ -502,8 +504,8 @@ export default {
502
504
  "items": [
503
505
  {
504
506
  "type": "text-content",
505
- "asHtml": "<p>This kata introduces you to the basics of linear algebra. Linear algebra is a branch of mathematics dedicated to studying the properties of matrices and vectors, which are used extensively in quantum computing to represent quantum states and operations on them.\nThis kata doesn't come close to covering the full breadth of the topic, but it should be enough to get you comfortable with the main concepts of linear algebra used in quantum computing.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Matrices and vectors</li>\n<li>Basic matrix operations</li>\n<li>Operations and properties of complex-valued matrices</li>\n<li>Inner and outer vector products</li>\n<li>Tensor product</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Complex numbers. If you need a review of this topic, we recommend that you complete the Complex Arithmetic kata before tackling this one.</li>\n</ul>\n<p><em>In this kata, the exercises focus on pen-and-paper work rather than on writing programs, since you're much more likely to do the linear algebra for a quantum computing problem before you start writing the code for it than to do it in Q#. Every task asks you to fill in the results of a math calculation for a specific example that you can do by hand. The Q# code is used as a way to check the results of the calculations rather than as a way to carry them out.</em></p>\n",
506
- "asMarkdown": "\nThis kata introduces you to the basics of linear algebra. Linear algebra is a branch of mathematics dedicated to studying the properties of matrices and vectors, which are used extensively in quantum computing to represent quantum states and operations on them.\nThis kata doesn't come close to covering the full breadth of the topic, but it should be enough to get you comfortable with the main concepts of linear algebra used in quantum computing.\n\n**This kata covers the following topics:**\n\n* Matrices and vectors\n* Basic matrix operations\n* Operations and properties of complex-valued matrices\n* Inner and outer vector products\n* Tensor product\n\n**What you should know to start working on this kata:**\n\n* Complex numbers. If you need a review of this topic, we recommend that you complete the Complex Arithmetic kata before tackling this one.\n\n*In this kata, the exercises focus on pen-and-paper work rather than on writing programs, since you're much more likely to do the linear algebra for a quantum computing problem before you start writing the code for it than to do it in Q#. Every task asks you to fill in the results of a math calculation for a specific example that you can do by hand. The Q# code is used as a way to check the results of the calculations rather than as a way to carry them out.*"
507
+ "asHtml": "<p>This kata introduces you to the basics of linear algebra. Linear algebra is a branch of mathematics dedicated to studying the properties of matrices and vectors, which are used extensively in quantum computing to represent quantum states and operations on them.\nThis kata doesn't come close to covering the full breadth of the topic, but it helps you get started with the main concepts of linear algebra used in quantum computing.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Matrices and vectors</li>\n<li>Basic matrix operations</li>\n<li>Operations and properties of complex-valued matrices</li>\n<li>Inner and outer vector products</li>\n<li>Tensor product</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Basic knowledge of complex numbers. If you need a review of this topic, you can check out the Complex Arithmetic kata before tackling this one.</li>\n</ul>\n<p><em>In this kata, the exercises focus on pen-and-paper work rather than on writing programs, since you're much more likely to do the linear algebra for a quantum computing problem before you start writing the code for it than to do it in Q#. Every task asks you to fill in the results of a math calculation for a specific example that you can do by hand. The Q# code is used as a way to check the results of the calculations rather than as a way to carry them out.</em></p>\n",
508
+ "asMarkdown": "\nThis kata introduces you to the basics of linear algebra. Linear algebra is a branch of mathematics dedicated to studying the properties of matrices and vectors, which are used extensively in quantum computing to represent quantum states and operations on them.\nThis kata doesn't come close to covering the full breadth of the topic, but it helps you get started with the main concepts of linear algebra used in quantum computing.\n\n**This kata covers the following topics:**\n\n* Matrices and vectors\n* Basic matrix operations\n* Operations and properties of complex-valued matrices\n* Inner and outer vector products\n* Tensor product\n\n**What you should know to start working on this kata:**\n\n* Basic knowledge of complex numbers. If you need a review of this topic, you can check out the Complex Arithmetic kata before tackling this one.\n\n*In this kata, the exercises focus on pen-and-paper work rather than on writing programs, since you're much more likely to do the linear algebra for a quantum computing problem before you start writing the code for it than to do it in Q#. Every task asks you to fill in the results of a math calculation for a specific example that you can do by hand. The Q# code is used as a way to check the results of the calculations rather than as a way to carry them out.*"
507
509
  }
508
510
  ]
509
511
  },
@@ -514,8 +516,8 @@ export default {
514
516
  "items": [
515
517
  {
516
518
  "type": "text-content",
517
- "asHtml": "<p>A <strong>matrix</strong> is set of numbers arranged in a rectangular grid. Here is a $2$ by $2$ matrix:</p>\n<p>$$A =\n\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix}$$</p>\n<p>$A_{i,j}$ refers to the element in row $i$ and column $j$ of matrix $A$ (all indices are 0-based). In the above example, $A_{0,1} = 2$.</p>\n<p>An $n \\times m$ matrix will have $n$ rows and $m$ columns:</p>\n<p>$$\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>A $1 \\times 1$ matrix is equivalent to a scalar:</p>\n<p>$$\\begin{bmatrix} 3 \\end{bmatrix} = 3$$</p>\n<p>Quantum computing uses complex-valued matrices: the elements of a matrix can be complex numbers. This, for example, is a valid complex-valued matrix:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; i \\\\\n -2i &amp; 3 + 4i\n\\end{bmatrix}$$</p>\n<p>Finally, a <strong>vector</strong> is an $n \\times 1$ matrix. Here, for example, is a $3 \\times 1$ vector:</p>\n<p>$$V = \\begin{bmatrix} 1 \\\\ 2i \\\\ 3 + 4i \\end{bmatrix}$$</p>\n<p>Since vectors always have a width of $1$, vector elements are sometimes written using only one index. In the above example, $V_0 = 1$ and $V_1 = 2i$.</p>\n",
518
- "asMarkdown": "\nA **matrix** is set of numbers arranged in a rectangular grid. Here is a $2$ by $2$ matrix:\n\n$$A =\n\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix}$$\n\n$A_{i,j}$ refers to the element in row $i$ and column $j$ of matrix $A$ (all indices are 0-based). In the above example, $A_{0,1} = 2$.\n\nAn $n \\times m$ matrix will have $n$ rows and $m$ columns:\n\n$$\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nA $1 \\times 1$ matrix is equivalent to a scalar:\n\n$$\\begin{bmatrix} 3 \\end{bmatrix} = 3$$\n\nQuantum computing uses complex-valued matrices: the elements of a matrix can be complex numbers. This, for example, is a valid complex-valued matrix:\n\n$$\\begin{bmatrix}\n 1 & i \\\\\n -2i & 3 + 4i\n\\end{bmatrix}$$\n\nFinally, a **vector** is an $n \\times 1$ matrix. Here, for example, is a $3 \\times 1$ vector:\n\n$$V = \\begin{bmatrix} 1 \\\\ 2i \\\\ 3 + 4i \\end{bmatrix}$$\n\nSince vectors always have a width of $1$, vector elements are sometimes written using only one index. In the above example, $V_0 = 1$ and $V_1 = 2i$."
519
+ "asHtml": "<p>A <strong>matrix</strong> is set of numbers arranged in a rectangular grid. Here is a $2$ by $2$ matrix:</p>\n<p>$$A =\n\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix}$$</p>\n<p>The notation $A_{i,j}$ refers to the element in row $i$ and column $j$ of matrix $A$ (all indices are 0-based). In the above example, $A_{0,1} = 2$.</p>\n<p>An $n \\times m$ matrix will have $n$ rows and $m$ columns:</p>\n<p>$$\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>A $1 \\times 1$ matrix is equivalent to a scalar:</p>\n<p>$$\\begin{bmatrix} 3 \\end{bmatrix} = 3$$</p>\n<p>Quantum computing uses complex-valued matrices: the elements of a matrix can be complex numbers. This, for example, is a valid complex-valued matrix:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; i \\\\\n -2i &amp; 3 + 4i\n\\end{bmatrix}$$</p>\n<p>Finally, a <strong>vector</strong> is an $n \\times 1$ matrix. Here, for example, is a $3 \\times 1$ vector:</p>\n<p>$$V = \\begin{bmatrix} 1 \\\\ 2i \\\\ 3 + 4i \\end{bmatrix}$$</p>\n<p>Since vectors always have a width of $1$, vector elements are sometimes written using only one index. In the above example, $V_0 = 1$ and $V_1 = 2i$.</p>\n",
520
+ "asMarkdown": "\nA **matrix** is set of numbers arranged in a rectangular grid. Here is a $2$ by $2$ matrix:\n\n$$A =\n\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix}$$\n\nThe notation $A_{i,j}$ refers to the element in row $i$ and column $j$ of matrix $A$ (all indices are 0-based). In the above example, $A_{0,1} = 2$.\n\nAn $n \\times m$ matrix will have $n$ rows and $m$ columns:\n\n$$\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nA $1 \\times 1$ matrix is equivalent to a scalar:\n\n$$\\begin{bmatrix} 3 \\end{bmatrix} = 3$$\n\nQuantum computing uses complex-valued matrices: the elements of a matrix can be complex numbers. This, for example, is a valid complex-valued matrix:\n\n$$\\begin{bmatrix}\n 1 & i \\\\\n -2i & 3 + 4i\n\\end{bmatrix}$$\n\nFinally, a **vector** is an $n \\times 1$ matrix. Here, for example, is a $3 \\times 1$ vector:\n\n$$V = \\begin{bmatrix} 1 \\\\ 2i \\\\ 3 + 4i \\end{bmatrix}$$\n\nSince vectors always have a width of $1$, vector elements are sometimes written using only one index. In the above example, $V_0 = 1$ and $V_1 = 2i$."
519
521
  }
520
522
  ]
521
523
  },
@@ -526,8 +528,8 @@ export default {
526
528
  "items": [
527
529
  {
528
530
  "type": "text-content",
529
- "asHtml": "<p>The easiest matrix operation is <strong>matrix addition</strong>. Matrix addition works between two matrices of the same size, and adds each number from the first matrix to the number in the same position in the second matrix:</p>\n<p>$$\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix} +$$\n$$+ \\begin{bmatrix}\n y_{0,0} &amp; y_{0,1} &amp; \\dotsb &amp; y_{0,m-1} \\\\\n y_{1,0} &amp; y_{1,1} &amp; \\dotsb &amp; y_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n y_{n-1,0} &amp; y_{n-1,1} &amp; \\dotsb &amp; y_{n-1,m-1}\n\\end{bmatrix} =$$\n$$= \\begin{bmatrix}\n x_{0,0} + y_{0,0} &amp; x_{0,1} + y_{0,1} &amp; \\dotsb &amp; x_{0,m-1} + y_{0,m-1} \\\\\n x_{1,0} + y_{1,0} &amp; x_{1,1} + y_{1,1} &amp; \\dotsb &amp; x_{1,m-1} + y_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} + y_{n-1,0} &amp; x_{n-1,1} + y_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1} + y_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>Similarly, we can compute $A - B$ by subtracting elements of $B$ from corresponding elements of $A$.</p>\n<p>Matrix addition has the following properties:</p>\n<ul>\n<li>Commutativity: $A + B = B + A$</li>\n<li>Associativity: $(A + B) + C = A + (B + C)$</li>\n</ul>\n",
530
- "asMarkdown": "\nThe easiest matrix operation is **matrix addition**. Matrix addition works between two matrices of the same size, and adds each number from the first matrix to the number in the same position in the second matrix:\n\n$$\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix} +$$\n$$+ \\begin{bmatrix}\n y_{0,0} & y_{0,1} & \\dotsb & y_{0,m-1} \\\\\n y_{1,0} & y_{1,1} & \\dotsb & y_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n y_{n-1,0} & y_{n-1,1} & \\dotsb & y_{n-1,m-1}\n\\end{bmatrix} =$$\n$$= \\begin{bmatrix}\n x_{0,0} + y_{0,0} & x_{0,1} + y_{0,1} & \\dotsb & x_{0,m-1} + y_{0,m-1} \\\\\n x_{1,0} + y_{1,0} & x_{1,1} + y_{1,1} & \\dotsb & x_{1,m-1} + y_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} + y_{n-1,0} & x_{n-1,1} + y_{n-1,1} & \\dotsb & x_{n-1,m-1} + y_{n-1,m-1}\n\\end{bmatrix}$$\n\nSimilarly, we can compute $A - B$ by subtracting elements of $B$ from corresponding elements of $A$.\n\nMatrix addition has the following properties:\n\n* Commutativity: $A + B = B + A$\n* Associativity: $(A + B) + C = A + (B + C)$"
531
+ "asHtml": "<p>The easiest matrix operation is <strong>matrix addition</strong>. Matrix addition works between two matrices of the same size, and adds each number from the first matrix to the number in the same position in the second matrix:</p>\n<p>$$\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix} +$$\n$$+ \\begin{bmatrix}\n y_{0,0} &amp; y_{0,1} &amp; \\dotsb &amp; y_{0,m-1} \\\\\n y_{1,0} &amp; y_{1,1} &amp; \\dotsb &amp; y_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n y_{n-1,0} &amp; y_{n-1,1} &amp; \\dotsb &amp; y_{n-1,m-1}\n\\end{bmatrix} =$$\n$$= \\begin{bmatrix}\n x_{0,0} + y_{0,0} &amp; x_{0,1} + y_{0,1} &amp; \\dotsb &amp; x_{0,m-1} + y_{0,m-1} \\\\\n x_{1,0} + y_{1,0} &amp; x_{1,1} + y_{1,1} &amp; \\dotsb &amp; x_{1,m-1} + y_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} + y_{n-1,0} &amp; x_{n-1,1} + y_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1} + y_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>Similarly, you can compute $A - B$ by subtracting elements of $B$ from corresponding elements of $A$.</p>\n<p>Matrix addition has the following properties:</p>\n<ul>\n<li>Commutativity: $A + B = B + A$</li>\n<li>Associativity: $(A + B) + C = A + (B + C)$</li>\n</ul>\n",
532
+ "asMarkdown": "\nThe easiest matrix operation is **matrix addition**. Matrix addition works between two matrices of the same size, and adds each number from the first matrix to the number in the same position in the second matrix:\n\n$$\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix} +$$\n$$+ \\begin{bmatrix}\n y_{0,0} & y_{0,1} & \\dotsb & y_{0,m-1} \\\\\n y_{1,0} & y_{1,1} & \\dotsb & y_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n y_{n-1,0} & y_{n-1,1} & \\dotsb & y_{n-1,m-1}\n\\end{bmatrix} =$$\n$$= \\begin{bmatrix}\n x_{0,0} + y_{0,0} & x_{0,1} + y_{0,1} & \\dotsb & x_{0,m-1} + y_{0,m-1} \\\\\n x_{1,0} + y_{1,0} & x_{1,1} + y_{1,1} & \\dotsb & x_{1,m-1} + y_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} + y_{n-1,0} & x_{n-1,1} + y_{n-1,1} & \\dotsb & x_{n-1,m-1} + y_{n-1,m-1}\n\\end{bmatrix}$$\n\nSimilarly, you can compute $A - B$ by subtracting elements of $B$ from corresponding elements of $A$.\n\nMatrix addition has the following properties:\n\n* Commutativity: $A + B = B + A$\n* Associativity: $(A + B) + C = A + (B + C)$"
531
533
  }
532
534
  ]
533
535
  },
@@ -592,8 +594,8 @@ export default {
592
594
  "items": [
593
595
  {
594
596
  "type": "text-content",
595
- "asHtml": "<p>We can again follow the definition given: to calculate the product of a number and a matrix, multiply each matrix element by that number.</p>\n<p>$$0.5 \\cdot \\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} =\n= \\begin{bmatrix} 0.5 \\cdot 1 &amp; 0.5 \\cdot 2 \\\\ 0.5 \\cdot 3 &amp; 0.5 \\cdot 4\\end{bmatrix} = \\begin{bmatrix} 0.5 &amp; 1 \\\\ 1.5 &amp; 2 \\end{bmatrix}$$</p>\n",
596
- "asMarkdown": "\nWe can again follow the definition given: to calculate the product of a number and a matrix, multiply each matrix element by that number. \n\n$$0.5 \\cdot \\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} =\n= \\begin{bmatrix} 0.5 \\cdot 1 & 0.5 \\cdot 2 \\\\ 0.5 \\cdot 3 & 0.5 \\cdot 4\\end{bmatrix} = \\begin{bmatrix} 0.5 & 1 \\\\ 1.5 & 2 \\end{bmatrix}$$"
597
+ "asHtml": "<p>You can again follow the definition given: to calculate the product of a number and a matrix, multiply each matrix element by that number.</p>\n<p>$$0.5 \\cdot \\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} =\n= \\begin{bmatrix} 0.5 \\cdot 1 &amp; 0.5 \\cdot 2 \\\\ 0.5 \\cdot 3 &amp; 0.5 \\cdot 4\\end{bmatrix} = \\begin{bmatrix} 0.5 &amp; 1 \\\\ 1.5 &amp; 2 \\end{bmatrix}$$</p>\n",
598
+ "asMarkdown": "\nYou can again follow the definition given: to calculate the product of a number and a matrix, multiply each matrix element by that number. \n\n$$0.5 \\cdot \\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} =\n= \\begin{bmatrix} 0.5 \\cdot 1 & 0.5 \\cdot 2 \\\\ 0.5 \\cdot 3 & 0.5 \\cdot 4\\end{bmatrix} = \\begin{bmatrix} 0.5 & 1 \\\\ 1.5 & 2 \\end{bmatrix}$$"
597
599
  },
598
600
  {
599
601
  "type": "solution",
@@ -610,8 +612,8 @@ export default {
610
612
  "items": [
611
613
  {
612
614
  "type": "text-content",
613
- "asHtml": "<p><strong>Matrix multiplication</strong> is a very important and somewhat unusual operation. The unusual thing about it is that neither its operands nor its output are the same size: an $n \\times m$ matrix multiplied by an $m \\times k$ matrix results in an $n \\times k$ matrix.\nThat is, for matrix multiplication to be applicable, the number of columns in the first matrix must equal the number of rows in the second matrix.</p>\n<p>Here is how matrix product is calculated: if we are calculating $AB = C$, then</p>\n<p>$$C_{i,j} = A_{i,0} \\cdot B_{0,j} + A_{i,1} \\cdot B_{1,j} + \\dotsb + A_{i,m-1} \\cdot B_{m-1,j} = \\sum_{t = 0}^{m-1} A_{i,t} \\cdot B_{t,j}$$</p>\n<p>Here is a small example:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 &amp; 3 \\\\\n 4 &amp; 5 &amp; 6\n\\end{bmatrix}\n\\begin{bmatrix}\n 1 \\\\\n 2 \\\\\n 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 1 \\cdot 1 + 2 \\cdot 2 + 3 \\cdot 3 \\\\\n 4 \\cdot 1 + 5 \\cdot 2 + 6 \\cdot 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 14 \\\\\n 32\n\\end{bmatrix}$$</p>\n<p>Matrix multiplication has the following properties:</p>\n<ul>\n<li>Associativity: $A(BC) = (AB)C$</li>\n<li>Distributivity over matrix addition: $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$</li>\n<li>Associativity with scalar multiplication: $xAB = x(AB) = A(xB)$</li>\n</ul>\n<blockquote>\n<p>Note that matrix multiplication is <strong>not commutative:</strong> $AB$ rarely equals $BA$.</p>\n</blockquote>\n<p>Another very important property of matrix multiplication is that a matrix multiplied by a vector produces another vector.</p>\n<p>An <strong>identity matrix</strong> $I_n$ is a special $n \\times n$ matrix which has $1$s on the main diagonal, and $0$s everywhere else:</p>\n<p>$$I_n =\n\\begin{bmatrix}\n 1 &amp; 0 &amp; \\dotsb &amp; 0 \\\\\n 0 &amp; 1 &amp; \\dotsb &amp; 0 \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n 0 &amp; 0 &amp; \\dotsb &amp; 1\n\\end{bmatrix}$$</p>\n<p>What makes it special is that multiplying any matrix (of compatible size) by $I_n$ returns the original matrix. To put it another way, if $A$ is an $n \\times m$ matrix:</p>\n<p>$$AI_m = I_nA = A$$</p>\n<p>This is why $I_n$ is called an identity matrix - it acts as a <strong>multiplicative identity</strong>. In other words, it is the matrix equivalent of the number $1$.</p>\n",
614
- "asMarkdown": "\n**Matrix multiplication** is a very important and somewhat unusual operation. The unusual thing about it is that neither its operands nor its output are the same size: an $n \\times m$ matrix multiplied by an $m \\times k$ matrix results in an $n \\times k$ matrix. \nThat is, for matrix multiplication to be applicable, the number of columns in the first matrix must equal the number of rows in the second matrix.\n\nHere is how matrix product is calculated: if we are calculating $AB = C$, then\n\n$$C_{i,j} = A_{i,0} \\cdot B_{0,j} + A_{i,1} \\cdot B_{1,j} + \\dotsb + A_{i,m-1} \\cdot B_{m-1,j} = \\sum_{t = 0}^{m-1} A_{i,t} \\cdot B_{t,j}$$\n\nHere is a small example:\n\n$$\\begin{bmatrix}\n 1 & 2 & 3 \\\\\n 4 & 5 & 6\n\\end{bmatrix}\n\\begin{bmatrix}\n 1 \\\\\n 2 \\\\\n 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 1 \\cdot 1 + 2 \\cdot 2 + 3 \\cdot 3 \\\\\n 4 \\cdot 1 + 5 \\cdot 2 + 6 \\cdot 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 14 \\\\\n 32\n\\end{bmatrix}$$\n\nMatrix multiplication has the following properties:\n\n* Associativity: $A(BC) = (AB)C$\n* Distributivity over matrix addition: $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$\n* Associativity with scalar multiplication: $xAB = x(AB) = A(xB)$\n\n> Note that matrix multiplication is **not commutative:** $AB$ rarely equals $BA$.\n\nAnother very important property of matrix multiplication is that a matrix multiplied by a vector produces another vector.\n\nAn **identity matrix** $I_n$ is a special $n \\times n$ matrix which has $1$s on the main diagonal, and $0$s everywhere else:\n\n$$I_n =\n\\begin{bmatrix}\n 1 & 0 & \\dotsb & 0 \\\\\n 0 & 1 & \\dotsb & 0 \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n 0 & 0 & \\dotsb & 1\n\\end{bmatrix}$$\n\nWhat makes it special is that multiplying any matrix (of compatible size) by $I_n$ returns the original matrix. To put it another way, if $A$ is an $n \\times m$ matrix:\n\n$$AI_m = I_nA = A$$\n\nThis is why $I_n$ is called an identity matrix - it acts as a **multiplicative identity**. In other words, it is the matrix equivalent of the number $1$."
615
+ "asHtml": "<p><strong>Matrix multiplication</strong> is a very important and somewhat unusual operation. The unusual thing about it is that neither its operands nor its output are the same size: an $n \\times m$ matrix multiplied by an $m \\times k$ matrix results in an $n \\times k$ matrix.\nThat is, for matrix multiplication to be applicable, the number of columns in the first matrix must equal the number of rows in the second matrix.</p>\n<p>Here's how matrix product is calculated: if you're calculating $AB = C$, then</p>\n<p>$$C_{i,j} = A_{i,0} \\cdot B_{0,j} + A_{i,1} \\cdot B_{1,j} + \\dotsb + A_{i,m-1} \\cdot B_{m-1,j} = \\sum_{t = 0}^{m-1} A_{i,t} \\cdot B_{t,j}$$</p>\n<p>Here's a small example:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 &amp; 3 \\\\\n 4 &amp; 5 &amp; 6\n\\end{bmatrix}\n\\begin{bmatrix}\n 1 \\\\\n 2 \\\\\n 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 1 \\cdot 1 + 2 \\cdot 2 + 3 \\cdot 3 \\\\\n 4 \\cdot 1 + 5 \\cdot 2 + 6 \\cdot 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 14 \\\\\n 32\n\\end{bmatrix}$$</p>\n<p>Matrix multiplication has the following properties:</p>\n<ul>\n<li>Associativity: $A(BC) = (AB)C$</li>\n<li>Distributivity over matrix addition: $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$</li>\n<li>Associativity with scalar multiplication: $xAB = x(AB) = A(xB)$</li>\n</ul>\n<blockquote>\n<p>Note that matrix multiplication is <strong>not commutative:</strong> $AB$ rarely equals $BA$.</p>\n</blockquote>\n<p>Another very important property of matrix multiplication is that a matrix multiplied by a vector produces another vector.</p>\n<p>An <strong>identity matrix</strong> $I_n$ is a special $n \\times n$ matrix which has $1$s on the main diagonal, and $0$s everywhere else:</p>\n<p>$$I_n =\n\\begin{bmatrix}\n 1 &amp; 0 &amp; \\dotsb &amp; 0 \\\\\n 0 &amp; 1 &amp; \\dotsb &amp; 0 \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n 0 &amp; 0 &amp; \\dotsb &amp; 1\n\\end{bmatrix}$$</p>\n<p>What makes an identity matrix $I_n$ special is that multiplying any matrix (of compatible size) by $I_n$ returns the original matrix. That is, if $A$ is an $n \\times m$ matrix:</p>\n<p>$$AI_m = I_nA = A$$</p>\n<p>This is why $I_n$ is called an identity matrix - it acts as a <strong>multiplicative identity</strong>. In other words, it's the matrix equivalent of the number $1$.</p>\n",
616
+ "asMarkdown": "\n**Matrix multiplication** is a very important and somewhat unusual operation. The unusual thing about it is that neither its operands nor its output are the same size: an $n \\times m$ matrix multiplied by an $m \\times k$ matrix results in an $n \\times k$ matrix. \nThat is, for matrix multiplication to be applicable, the number of columns in the first matrix must equal the number of rows in the second matrix.\n\nHere's how matrix product is calculated: if you're calculating $AB = C$, then\n\n$$C_{i,j} = A_{i,0} \\cdot B_{0,j} + A_{i,1} \\cdot B_{1,j} + \\dotsb + A_{i,m-1} \\cdot B_{m-1,j} = \\sum_{t = 0}^{m-1} A_{i,t} \\cdot B_{t,j}$$\n\nHere's a small example:\n\n$$\\begin{bmatrix}\n 1 & 2 & 3 \\\\\n 4 & 5 & 6\n\\end{bmatrix}\n\\begin{bmatrix}\n 1 \\\\\n 2 \\\\\n 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 1 \\cdot 1 + 2 \\cdot 2 + 3 \\cdot 3 \\\\\n 4 \\cdot 1 + 5 \\cdot 2 + 6 \\cdot 3\n\\end{bmatrix} =\n\\begin{bmatrix}\n 14 \\\\\n 32\n\\end{bmatrix}$$\n\nMatrix multiplication has the following properties:\n\n* Associativity: $A(BC) = (AB)C$\n* Distributivity over matrix addition: $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$\n* Associativity with scalar multiplication: $xAB = x(AB) = A(xB)$\n\n> Note that matrix multiplication is **not commutative:** $AB$ rarely equals $BA$.\n\nAnother very important property of matrix multiplication is that a matrix multiplied by a vector produces another vector.\n\nAn **identity matrix** $I_n$ is a special $n \\times n$ matrix which has $1$s on the main diagonal, and $0$s everywhere else:\n\n$$I_n =\n\\begin{bmatrix}\n 1 & 0 & \\dotsb & 0 \\\\\n 0 & 1 & \\dotsb & 0 \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n 0 & 0 & \\dotsb & 1\n\\end{bmatrix}$$\n\nWhat makes an identity matrix $I_n$ special is that multiplying any matrix (of compatible size) by $I_n$ returns the original matrix. That is, if $A$ is an $n \\times m$ matrix:\n\n$$AI_m = I_nA = A$$\n\nThis is why $I_n$ is called an identity matrix - it acts as a **multiplicative identity**. In other words, it's the matrix equivalent of the number $1$."
615
617
  }
616
618
  ]
617
619
  },
@@ -634,8 +636,8 @@ export default {
634
636
  "items": [
635
637
  {
636
638
  "type": "text-content",
637
- "asHtml": "<p>Following the definition, we can calculate the product of these two matrices as follows:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} \\cdot \\begin{bmatrix} 5 &amp; 6 \\\\ 7 &amp; 8 \\end{bmatrix} = $$\n$$= \\begin{bmatrix} 1 \\cdot 5 + 2 \\cdot 7 &amp; 1 \\cdot 6 + 2 \\cdot 8 \\\\ 3 \\cdot 5 + 4 \\cdot 7 &amp; 3 \\cdot 6 + 4 \\cdot 8 \\end{bmatrix} = \\begin{bmatrix} 19 &amp; 22 \\\\ 43 &amp; 50 \\end{bmatrix}$$</p>\n",
638
- "asMarkdown": "\nFollowing the definition, we can calculate the product of these two matrices as follows:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} \\cdot \\begin{bmatrix} 5 & 6 \\\\ 7 & 8 \\end{bmatrix} = $$\n$$= \\begin{bmatrix} 1 \\cdot 5 + 2 \\cdot 7 & 1 \\cdot 6 + 2 \\cdot 8 \\\\ 3 \\cdot 5 + 4 \\cdot 7 & 3 \\cdot 6 + 4 \\cdot 8 \\end{bmatrix} = \\begin{bmatrix} 19 & 22 \\\\ 43 & 50 \\end{bmatrix}$$"
639
+ "asHtml": "<p>Following the definition, you can calculate the product of these two matrices as follows:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} \\cdot \\begin{bmatrix} 5 &amp; 6 \\\\ 7 &amp; 8 \\end{bmatrix} = $$\n$$= \\begin{bmatrix} 1 \\cdot 5 + 2 \\cdot 7 &amp; 1 \\cdot 6 + 2 \\cdot 8 \\\\ 3 \\cdot 5 + 4 \\cdot 7 &amp; 3 \\cdot 6 + 4 \\cdot 8 \\end{bmatrix} = \\begin{bmatrix} 19 &amp; 22 \\\\ 43 &amp; 50 \\end{bmatrix}$$</p>\n",
640
+ "asMarkdown": "\nFollowing the definition, you can calculate the product of these two matrices as follows:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} \\cdot \\begin{bmatrix} 5 & 6 \\\\ 7 & 8 \\end{bmatrix} = $$\n$$= \\begin{bmatrix} 1 \\cdot 5 + 2 \\cdot 7 & 1 \\cdot 6 + 2 \\cdot 8 \\\\ 3 \\cdot 5 + 4 \\cdot 7 & 3 \\cdot 6 + 4 \\cdot 8 \\end{bmatrix} = \\begin{bmatrix} 19 & 22 \\\\ 43 & 50 \\end{bmatrix}$$"
639
641
  },
640
642
  {
641
643
  "type": "solution",
@@ -652,8 +654,8 @@ export default {
652
654
  "items": [
653
655
  {
654
656
  "type": "text-content",
655
- "asHtml": "<p>A square $n \\times n$ matrix $A$ is <strong>invertible</strong> if it has an inverse $n \\times n$ matrix $A^{-1}$ with the following property:</p>\n<p>$$AA^{-1} = A^{-1}A = I_n$$</p>\n<p>In other words, $A^{-1}$ acts as the <strong>multiplicative inverse</strong> of $A$.</p>\n<p>Another, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:</p>\n<p>$$A^{-1}(AB) = A(A^{-1}B) = B$$\n$$(CA)A^{-1} = (CA^{-1})A = C$$</p>\n<p>A square matrix has a property called the <strong>determinant</strong>, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.</p>\n<p>For a $2 \\times 2$ matrix $A$, the determinant is defined as $|A| = A_{0,0} \\cdot A_{1,1} - A_{0,1} \\cdot A_{1,0}$.</p>\n<p>For larger matrices, the determinant is defined through determinants of sub-matrices. You can learn more from <a href=\"https://en.wikipedia.org/wiki/Determinant\">Wikipedia</a> or from <a href=\"http://mathworld.wolfram.com/Determinant.html\">Wolfram MathWorld</a>.</p>\n",
656
- "asMarkdown": "\nA square $n \\times n$ matrix $A$ is **invertible** if it has an inverse $n \\times n$ matrix $A^{-1}$ with the following property:\n\n$$AA^{-1} = A^{-1}A = I_n$$\n\nIn other words, $A^{-1}$ acts as the **multiplicative inverse** of $A$.\n\nAnother, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:\n\n$$A^{-1}(AB) = A(A^{-1}B) = B$$\n$$(CA)A^{-1} = (CA^{-1})A = C$$\n\nA square matrix has a property called the **determinant**, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.\n\nFor a $2 \\times 2$ matrix $A$, the determinant is defined as $|A| = A_{0,0} \\cdot A_{1,1} - A_{0,1} \\cdot A_{1,0}$.\n\nFor larger matrices, the determinant is defined through determinants of sub-matrices. You can learn more from [Wikipedia](https://en.wikipedia.org/wiki/Determinant) or from [Wolfram MathWorld](http://mathworld.wolfram.com/Determinant.html)."
657
+ "asHtml": "<p>A square $n \\times n$ matrix $A$ is <strong>invertible</strong> if it has an inverse $n \\times n$ matrix $A^{-1}$ with the following property:</p>\n<p>$$AA^{-1} = A^{-1}A = I_n$$</p>\n<p>In other words, $A^{-1}$ acts as the <strong>multiplicative inverse</strong> of $A$.</p>\n<p>Another, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:</p>\n<p>$$A^{-1}(AB) = A(A^{-1}B) = B$$\n$$(CA)A^{-1} = (CA^{-1})A = C$$</p>\n<p>A square matrix has a property called the <strong>determinant</strong>, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.</p>\n<p>For a $2 \\times 2$ matrix $A$, the determinant is defined as $|A| = A_{0,0} \\cdot A_{1,1} - A_{0,1} \\cdot A_{1,0}$.</p>\n<p>For larger matrices, the determinant is defined through determinants of sub-matrices. You can learn more about the determinant of matrices from <a href=\"https://en.wikipedia.org/wiki/Determinant\">Wikipedia</a> or from <a href=\"http://mathworld.wolfram.com/Determinant.html\">Wolfram MathWorld</a>.</p>\n",
658
+ "asMarkdown": "\nA square $n \\times n$ matrix $A$ is **invertible** if it has an inverse $n \\times n$ matrix $A^{-1}$ with the following property:\n\n$$AA^{-1} = A^{-1}A = I_n$$\n\nIn other words, $A^{-1}$ acts as the **multiplicative inverse** of $A$.\n\nAnother, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:\n\n$$A^{-1}(AB) = A(A^{-1}B) = B$$\n$$(CA)A^{-1} = (CA^{-1})A = C$$\n\nA square matrix has a property called the **determinant**, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.\n\nFor a $2 \\times 2$ matrix $A$, the determinant is defined as $|A| = A_{0,0} \\cdot A_{1,1} - A_{0,1} \\cdot A_{1,0}$.\n\nFor larger matrices, the determinant is defined through determinants of sub-matrices. You can learn more about the determinant of matrices from [Wikipedia](https://en.wikipedia.org/wiki/Determinant) or from [Wolfram MathWorld](http://mathworld.wolfram.com/Determinant.html)."
657
659
  }
658
660
  ]
659
661
  },
@@ -663,8 +665,8 @@ export default {
663
665
  "title": "Invert a Matrix",
664
666
  "description": {
665
667
  "type": "text-content",
666
- "asHtml": "<p><strong>Input:</strong> None.</p>\n<p><strong>Goal:</strong> Return the inverse of the following matrix:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix}$$</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n<p>You may find <a href=\"https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices\">this Wikipedia article</a> useful.</p>\n</details>\n",
667
- "asMarkdown": "**Input:** None.\n\n**Goal:** Return the inverse of the following matrix:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix}$$\n\n<details>\n <summary><b>Need a hint?</b></summary>\n \nYou may find [this Wikipedia article](https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices) useful.\n\n</details>\n"
668
+ "asHtml": "<p><strong>Input:</strong> None.</p>\n<p><strong>Goal:</strong> Return the inverse of the following matrix:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix}$$</p>\n<details>\n <summary><b>Need a hint?</b></summary>\n<p>You can check out <a href=\"https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices\">this Wikipedia article</a> about invertible matrices.</p>\n</details>\n",
669
+ "asMarkdown": "**Input:** None.\n\n**Goal:** Return the inverse of the following matrix:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix}$$\n\n<details>\n <summary><b>Need a hint?</b></summary>\n \nYou can check out [this Wikipedia article](https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices) about invertible matrices.\n\n</details>\n"
668
670
  },
669
671
  "sourceIds": [
670
672
  "linear_algebra__inverse__Verification.qs",
@@ -676,8 +678,8 @@ export default {
676
678
  "items": [
677
679
  {
678
680
  "type": "text-content",
679
- "asHtml": "<p>We will follow the algorithm described in the <a href=\"https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices\">Wikipedia article</a> for $2 \\times 2$ matrices:</p>\n<p>$$ A = \\begin{bmatrix} a &amp; b \\\\ c &amp; d \\end{bmatrix} $$</p>\n<p>Then the determinant of the matrix is defined as\n$$ |A| = a \\cdot d - b \\cdot c = 1 \\cdot 4 - 2 \\cdot 3 = -2$$</p>\n<p>And the inverse of the matrix is</p>\n<p>$$A^{-1} = \\frac{1}{|A|} \\cdot \\begin{bmatrix} d &amp; -b \\\\ -c &amp; a \\end{bmatrix} = -\\frac12 \\begin{bmatrix} 4 &amp; -2 \\\\ -3 &amp; 1 \\end{bmatrix} = \\begin{bmatrix} -2 &amp; 1 \\\\ \\frac32 &amp; -\\frac12 \\end{bmatrix}$$</p>\n",
680
- "asMarkdown": "\nWe will follow the algorithm described in the [Wikipedia article](https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices) for $2 \\times 2$ matrices:\n\n$$ A = \\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix} $$\n\nThen the determinant of the matrix is defined as \n$$ |A| = a \\cdot d - b \\cdot c = 1 \\cdot 4 - 2 \\cdot 3 = -2$$\n\nAnd the inverse of the matrix is\n\n$$A^{-1} = \\frac{1}{|A|} \\cdot \\begin{bmatrix} d & -b \\\\ -c & a \\end{bmatrix} = -\\frac12 \\begin{bmatrix} 4 & -2 \\\\ -3 & 1 \\end{bmatrix} = \\begin{bmatrix} -2 & 1 \\\\ \\frac32 & -\\frac12 \\end{bmatrix}$$"
681
+ "asHtml": "<p>You can follow the algorithm described in the <a href=\"https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices\">Wikipedia article</a> for $2 \\times 2$ matrices:</p>\n<p>$$ A = \\begin{bmatrix} a &amp; b \\\\ c &amp; d \\end{bmatrix} $$</p>\n<p>Then the determinant of the matrix is defined as\n$$ |A| = a \\cdot d - b \\cdot c = 1 \\cdot 4 - 2 \\cdot 3 = -2$$</p>\n<p>And the inverse of the matrix is</p>\n<p>$$A^{-1} = \\frac{1}{|A|} \\cdot \\begin{bmatrix} d &amp; -b \\\\ -c &amp; a \\end{bmatrix} = -\\frac12 \\begin{bmatrix} 4 &amp; -2 \\\\ -3 &amp; 1 \\end{bmatrix} = \\begin{bmatrix} -2 &amp; 1 \\\\ \\frac32 &amp; -\\frac12 \\end{bmatrix}$$</p>\n",
682
+ "asMarkdown": "\nYou can follow the algorithm described in the [Wikipedia article](https://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2_%C3%97_2_matrices) for $2 \\times 2$ matrices:\n\n$$ A = \\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix} $$\n\nThen the determinant of the matrix is defined as \n$$ |A| = a \\cdot d - b \\cdot c = 1 \\cdot 4 - 2 \\cdot 3 = -2$$\n\nAnd the inverse of the matrix is\n\n$$A^{-1} = \\frac{1}{|A|} \\cdot \\begin{bmatrix} d & -b \\\\ -c & a \\end{bmatrix} = -\\frac12 \\begin{bmatrix} 4 & -2 \\\\ -3 & 1 \\end{bmatrix} = \\begin{bmatrix} -2 & 1 \\\\ \\frac32 & -\\frac12 \\end{bmatrix}$$"
681
683
  },
682
684
  {
683
685
  "type": "solution",
@@ -694,8 +696,8 @@ export default {
694
696
  "items": [
695
697
  {
696
698
  "type": "text-content",
697
- "asHtml": "<p>The <strong>transpose</strong> operation, denoted as $A^T$, is essentially a reflection of the matrix across the diagonal: $A^T_{i,j} = A_{j,i}$.</p>\n<p>Given an $n \\times m$ matrix $A$, its transpose is the $m \\times n$ matrix $A^T$, such that if:</p>\n<p>$$A =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>then:</p>\n<p>$$A^T =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{1,0} &amp; \\dotsb &amp; x_{n-1,0} \\\\\n x_{0,1} &amp; x_{1,1} &amp; \\dotsb &amp; x_{n-1,1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{0,m-1} &amp; x_{1,m-1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>For example:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 \\\\\n 3 &amp; 4 \\\\\n 5 &amp; 6\n\\end{bmatrix}^T =\n\\begin{bmatrix}\n 1 &amp; 3 &amp; 5 \\\\\n 2 &amp; 4 &amp; 6\n\\end{bmatrix}$$</p>\n<p>A <strong>symmetric</strong> matrix is a square matrix which equals its own transpose: $A = A^T$. To put it another way, it has reflection symmetry (hence the name) across the main diagonal. For example, the following matrix is symmetric:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 &amp; 3 \\\\\n 2 &amp; 4 &amp; 5 \\\\\n 3 &amp; 5 &amp; 6\n\\end{bmatrix}$$</p>\n<p>The transpose of a matrix product is equal to the product of transposed matrices, taken in reverse order:</p>\n<p>$$(AB)^T = B^TA^T$$</p>\n",
698
- "asMarkdown": "\nThe **transpose** operation, denoted as $A^T$, is essentially a reflection of the matrix across the diagonal: $A^T_{i,j} = A_{j,i}$.\n\nGiven an $n \\times m$ matrix $A$, its transpose is the $m \\times n$ matrix $A^T$, such that if:\n\n$$A =\n\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nthen:\n\n$$A^T =\n\\begin{bmatrix}\n x_{0,0} & x_{1,0} & \\dotsb & x_{n-1,0} \\\\\n x_{0,1} & x_{1,1} & \\dotsb & x_{n-1,1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{0,m-1} & x_{1,m-1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nFor example:\n\n$$\\begin{bmatrix}\n 1 & 2 \\\\\n 3 & 4 \\\\\n 5 & 6\n\\end{bmatrix}^T =\n\\begin{bmatrix}\n 1 & 3 & 5 \\\\\n 2 & 4 & 6\n\\end{bmatrix}$$\n\nA **symmetric** matrix is a square matrix which equals its own transpose: $A = A^T$. To put it another way, it has reflection symmetry (hence the name) across the main diagonal. For example, the following matrix is symmetric:\n\n$$\\begin{bmatrix}\n 1 & 2 & 3 \\\\\n 2 & 4 & 5 \\\\\n 3 & 5 & 6\n\\end{bmatrix}$$\n\nThe transpose of a matrix product is equal to the product of transposed matrices, taken in reverse order:\n\n$$(AB)^T = B^TA^T$$"
699
+ "asHtml": "<p>The <strong>transpose</strong> operation, denoted as $A^T$, is essentially a reflection of the matrix across the diagonal: $A^T_{i,j} = A_{j,i}$.</p>\n<p>Given an $n \\times m$ matrix $A$, its transpose is the $m \\times n$ matrix $A^T$, such that if:</p>\n<p>$$A =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>then:</p>\n<p>$$A^T =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{1,0} &amp; \\dotsb &amp; x_{n-1,0} \\\\\n x_{0,1} &amp; x_{1,1} &amp; \\dotsb &amp; x_{n-1,1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{0,m-1} &amp; x_{1,m-1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>For example:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 \\\\\n 3 &amp; 4 \\\\\n 5 &amp; 6\n\\end{bmatrix}^T =\n\\begin{bmatrix}\n 1 &amp; 3 &amp; 5 \\\\\n 2 &amp; 4 &amp; 6\n\\end{bmatrix}$$</p>\n<p>A <strong>symmetric</strong> matrix is a square matrix which equals its own transpose: $A = A^T$. That is, it has reflection symmetry (hence the name) across the main diagonal. For example, the following matrix is symmetric:</p>\n<p>$$\\begin{bmatrix}\n 1 &amp; 2 &amp; 3 \\\\\n 2 &amp; 4 &amp; 5 \\\\\n 3 &amp; 5 &amp; 6\n\\end{bmatrix}$$</p>\n<p>The transpose of a matrix product is equal to the product of transposed matrices, taken in reverse order:</p>\n<p>$$(AB)^T = B^TA^T$$</p>\n",
700
+ "asMarkdown": "\nThe **transpose** operation, denoted as $A^T$, is essentially a reflection of the matrix across the diagonal: $A^T_{i,j} = A_{j,i}$.\n\nGiven an $n \\times m$ matrix $A$, its transpose is the $m \\times n$ matrix $A^T$, such that if:\n\n$$A =\n\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nthen:\n\n$$A^T =\n\\begin{bmatrix}\n x_{0,0} & x_{1,0} & \\dotsb & x_{n-1,0} \\\\\n x_{0,1} & x_{1,1} & \\dotsb & x_{n-1,1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{0,m-1} & x_{1,m-1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nFor example:\n\n$$\\begin{bmatrix}\n 1 & 2 \\\\\n 3 & 4 \\\\\n 5 & 6\n\\end{bmatrix}^T =\n\\begin{bmatrix}\n 1 & 3 & 5 \\\\\n 2 & 4 & 6\n\\end{bmatrix}$$\n\nA **symmetric** matrix is a square matrix which equals its own transpose: $A = A^T$. That is, it has reflection symmetry (hence the name) across the main diagonal. For example, the following matrix is symmetric:\n\n$$\\begin{bmatrix}\n 1 & 2 & 3 \\\\\n 2 & 4 & 5 \\\\\n 3 & 5 & 6\n\\end{bmatrix}$$\n\nThe transpose of a matrix product is equal to the product of transposed matrices, taken in reverse order:\n\n$$(AB)^T = B^TA^T$$"
699
701
  }
700
702
  ]
701
703
  },
@@ -718,8 +720,8 @@ export default {
718
720
  "items": [
719
721
  {
720
722
  "type": "text-content",
721
- "asHtml": "<p>Following the definition of matrix transpose, we just need to fill the transpose matrix with the elements of the original matrix in the right order: the elements on the main diagonal remain in their places, and the elements off the main diagonal are swapped.</p>\n",
722
- "asMarkdown": "\nFollowing the definition of matrix transpose, we just need to fill the transpose matrix with the elements of the original matrix in the right order: the elements on the main diagonal remain in their places, and the elements off the main diagonal are swapped."
723
+ "asHtml": "<p>Following the definition of matrix transpose, you just need to fill the transpose matrix with the elements of the original matrix in the right order: the elements on the main diagonal remain in their places, and the elements off the main diagonal are swapped.</p>\n",
724
+ "asMarkdown": "\nFollowing the definition of matrix transpose, you just need to fill the transpose matrix with the elements of the original matrix in the right order: the elements on the main diagonal remain in their places, and the elements off the main diagonal are swapped."
723
725
  },
724
726
  {
725
727
  "type": "solution",
@@ -736,8 +738,8 @@ export default {
736
738
  "items": [
737
739
  {
738
740
  "type": "text-content",
739
- "asHtml": "<p>The next important single-matrix operation is the <strong>matrix conjugate</strong>, denoted as $\\overline{A}$. This operation makes sense only for complex-valued matrices; as the name might suggest, it involves taking the complex conjugate of every element of the matrix: if</p>\n<p>$$A =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>Then:</p>\n<p>$$\\overline{A} =\n\\begin{bmatrix}\n \\overline{x}_{0,0} &amp; \\overline{x}_{0,1} &amp; \\dotsb &amp; \\overline{x}_{0,m-1} \\\\\n \\overline{x}_{1,0} &amp; \\overline{x}_{1,1} &amp; \\dotsb &amp; \\overline{x}_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n \\overline{x}_{n-1,0} &amp; \\overline{x}_{n-1,1} &amp; \\dotsb &amp; \\overline{x}_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<blockquote>\n<p>As a reminder, a conjugate of a complex number $x = a + bi$ is $\\overline{x} = a - bi$.</p>\n</blockquote>\n<p>The conjugate of a matrix product equals to the product of conjugates of the matrices:</p>\n<p>$$\\overline{AB} = (\\overline{A})(\\overline{B})$$</p>\n",
740
- "asMarkdown": "\nThe next important single-matrix operation is the **matrix conjugate**, denoted as $\\overline{A}$. This operation makes sense only for complex-valued matrices; as the name might suggest, it involves taking the complex conjugate of every element of the matrix: if\n\n$$A =\n\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nThen:\n\n$$\\overline{A} =\n\\begin{bmatrix}\n \\overline{x}_{0,0} & \\overline{x}_{0,1} & \\dotsb & \\overline{x}_{0,m-1} \\\\\n \\overline{x}_{1,0} & \\overline{x}_{1,1} & \\dotsb & \\overline{x}_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n \\overline{x}_{n-1,0} & \\overline{x}_{n-1,1} & \\dotsb & \\overline{x}_{n-1,m-1}\n\\end{bmatrix}$$\n\n> As a reminder, a conjugate of a complex number $x = a + bi$ is $\\overline{x} = a - bi$.\n\nThe conjugate of a matrix product equals to the product of conjugates of the matrices:\n\n$$\\overline{AB} = (\\overline{A})(\\overline{B})$$"
741
+ "asHtml": "<p>The next important single-matrix operation is the <strong>matrix conjugate</strong>, denoted as $\\overline{A}$. This operation makes sense only for complex-valued matrices; as the name might suggest, it involves taking the complex conjugate of every element of the matrix. In matrix form, if</p>\n<p>$$A =\n\\begin{bmatrix}\n x_{0,0} &amp; x_{0,1} &amp; \\dotsb &amp; x_{0,m-1} \\\\\n x_{1,0} &amp; x_{1,1} &amp; \\dotsb &amp; x_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n x_{n-1,0} &amp; x_{n-1,1} &amp; \\dotsb &amp; x_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<p>Then:</p>\n<p>$$\\overline{A} =\n\\begin{bmatrix}\n \\overline{x}_{0,0} &amp; \\overline{x}_{0,1} &amp; \\dotsb &amp; \\overline{x}_{0,m-1} \\\\\n \\overline{x}_{1,0} &amp; \\overline{x}_{1,1} &amp; \\dotsb &amp; \\overline{x}_{1,m-1} \\\\\n \\vdots &amp; \\vdots &amp; \\ddots &amp; \\vdots \\\\\n \\overline{x}_{n-1,0} &amp; \\overline{x}_{n-1,1} &amp; \\dotsb &amp; \\overline{x}_{n-1,m-1}\n\\end{bmatrix}$$</p>\n<blockquote>\n<p>As a reminder, a conjugate of a complex number $x = a + bi$ is $\\overline{x} = a - bi$.</p>\n</blockquote>\n<p>The conjugate of a matrix product equals to the product of conjugates of the matrices:</p>\n<p>$$\\overline{AB} = (\\overline{A})(\\overline{B})$$</p>\n",
742
+ "asMarkdown": "\nThe next important single-matrix operation is the **matrix conjugate**, denoted as $\\overline{A}$. This operation makes sense only for complex-valued matrices; as the name might suggest, it involves taking the complex conjugate of every element of the matrix. In matrix form, if\n\n$$A =\n\\begin{bmatrix}\n x_{0,0} & x_{0,1} & \\dotsb & x_{0,m-1} \\\\\n x_{1,0} & x_{1,1} & \\dotsb & x_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n x_{n-1,0} & x_{n-1,1} & \\dotsb & x_{n-1,m-1}\n\\end{bmatrix}$$\n\nThen:\n\n$$\\overline{A} =\n\\begin{bmatrix}\n \\overline{x}_{0,0} & \\overline{x}_{0,1} & \\dotsb & \\overline{x}_{0,m-1} \\\\\n \\overline{x}_{1,0} & \\overline{x}_{1,1} & \\dotsb & \\overline{x}_{1,m-1} \\\\\n \\vdots & \\vdots & \\ddots & \\vdots \\\\\n \\overline{x}_{n-1,0} & \\overline{x}_{n-1,1} & \\dotsb & \\overline{x}_{n-1,m-1}\n\\end{bmatrix}$$\n\n> As a reminder, a conjugate of a complex number $x = a + bi$ is $\\overline{x} = a - bi$.\n\nThe conjugate of a matrix product equals to the product of conjugates of the matrices:\n\n$$\\overline{AB} = (\\overline{A})(\\overline{B})$$"
741
743
  }
742
744
  ]
743
745
  },
@@ -760,8 +762,8 @@ export default {
760
762
  "items": [
761
763
  {
762
764
  "type": "text-content",
763
- "asHtml": "<p>Following the definition of matrix conjugate, we just need to fill the transpose matrix with the elements of the original matrix, remembering to flip the signs of imaginary parts of the numbers.</p>\n",
764
- "asMarkdown": "\nFollowing the definition of matrix conjugate, we just need to fill the transpose matrix with the elements of the original matrix, remembering to flip the signs of imaginary parts of the numbers."
765
+ "asHtml": "<p>Following the definition of matrix conjugate, you just need to fill the transpose matrix with the elements of the original matrix, remembering to flip the signs of imaginary parts of the numbers.</p>\n",
766
+ "asMarkdown": "\nFollowing the definition of matrix conjugate, you just need to fill the transpose matrix with the elements of the original matrix, remembering to flip the signs of imaginary parts of the numbers."
765
767
  },
766
768
  {
767
769
  "type": "solution",
@@ -802,8 +804,8 @@ export default {
802
804
  "items": [
803
805
  {
804
806
  "type": "text-content",
805
- "asHtml": "<p>To get the adjoint, we perform both transpose and conjugate operations on the input matrix, in any order.\nThe easiest way is to start with the conjugate of the matrix that we found in the previous exercise, and then transpose it.</p>\n",
806
- "asMarkdown": "\nTo get the adjoint, we perform both transpose and conjugate operations on the input matrix, in any order.\nThe easiest way is to start with the conjugate of the matrix that we found in the previous exercise, and then transpose it."
807
+ "asHtml": "<p>To get the adjoint, you perform both transpose and conjugate operations on the input matrix, in any order.\nThe easiest way is to start with the conjugate of the matrix that you found in the previous exercise, and then transpose it.</p>\n",
808
+ "asMarkdown": "\nTo get the adjoint, you perform both transpose and conjugate operations on the input matrix, in any order.\nThe easiest way is to start with the conjugate of the matrix that you found in the previous exercise, and then transpose it."
807
809
  },
808
810
  {
809
811
  "type": "solution",
@@ -820,8 +822,8 @@ export default {
820
822
  "items": [
821
823
  {
822
824
  "type": "text-content",
823
- "asHtml": "<p><strong>Unitary matrices</strong> are very important for quantum computing. A matrix is unitary when it is invertible, and its inverse is equal to its adjoint: $U^{-1} = U^\\dagger$. That is, an $n \\times n$ square matrix $U$ is unitary if and only if $UU^\\dagger = U^\\dagger U = I_n$.</p>\n<h2>🔎 Analyze</h2>\n<p>Is this matrix unitary?</p>\n<p>$$A = \\begin{bmatrix}\n \\frac{1}{\\sqrt{2}} &amp; \\frac{1}{\\sqrt{2}} \\\\\n \\frac{i}{\\sqrt{2}} &amp; \\frac{-i}{\\sqrt{2}}\n\\end{bmatrix} = \n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 &amp; 1 \\\\\n i &amp; -i\n\\end{bmatrix}$$</p>\n<details>\n<summary><b>Solution</b></summary>\nTo check whether the input matrix is unitary, we will need to perform the following steps:\n<ol>\n<li>Calculate the adjoint of the input matrix $A^\\dagger$.</li>\n</ol>\n<p>$$A^\\dagger = \\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 &amp; -i \\\\\n 1 &amp; i\n\\end{bmatrix}$$</p>\n<ol start=\"2\">\n<li>Multiply it by the input matrix.</li>\n</ol>\n<p>$$AA^\\dagger = \\frac12 \\begin{bmatrix}\n 1 &amp; 1 \\\\\n i &amp; -i\n\\end{bmatrix} \\begin{bmatrix}\n 1 &amp; -i \\\\\n 1 &amp; i\n\\end{bmatrix} = \\frac12 \\begin{bmatrix}\n 1 \\cdot 1 + 1 \\cdot 1 &amp; 1 \\cdot (-i) + 1 \\cdot i \\\\\n i \\cdot 1 + (-i) \\cdot 1 &amp; i \\cdot (-i) + (-i) \\cdot i\n\\end{bmatrix} = \\begin{bmatrix}\n 1 &amp; 0 \\\\\n 0 &amp; 1\n\\end{bmatrix}$$</p>\n<p>If the multiplication result $AA^\\dagger$ is an identity matrix, which is indeed the case,\nand the product $A^\\dagger A$ is also an identity matrix (which you can verify in a similar manner),\nthe matrix is unitary.</p>\n</details>",
824
- "asMarkdown": "\n**Unitary matrices** are very important for quantum computing. A matrix is unitary when it is invertible, and its inverse is equal to its adjoint: $U^{-1} = U^\\dagger$. That is, an $n \\times n$ square matrix $U$ is unitary if and only if $UU^\\dagger = U^\\dagger U = I_n$.\n\n## 🔎 Analyze\n\nIs this matrix unitary?\n\n$$A = \\begin{bmatrix}\n \\frac{1}{\\sqrt{2}} & \\frac{1}{\\sqrt{2}} \\\\\n \\frac{i}{\\sqrt{2}} & \\frac{-i}{\\sqrt{2}}\n\\end{bmatrix} = \n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 & 1 \\\\\n i & -i\n\\end{bmatrix}$$\n\n<details>\n<summary><b>Solution</b></summary>\nTo check whether the input matrix is unitary, we will need to perform the following steps:\n\n1. Calculate the adjoint of the input matrix $A^\\dagger$.\n\n$$A^\\dagger = \\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 & -i \\\\\n 1 & i\n\\end{bmatrix}$$\n\n2. Multiply it by the input matrix.\n\n$$AA^\\dagger = \\frac12 \\begin{bmatrix}\n 1 & 1 \\\\\n i & -i\n\\end{bmatrix} \\begin{bmatrix}\n 1 & -i \\\\\n 1 & i\n\\end{bmatrix} = \\frac12 \\begin{bmatrix}\n 1 \\cdot 1 + 1 \\cdot 1 & 1 \\cdot (-i) + 1 \\cdot i \\\\\n i \\cdot 1 + (-i) \\cdot 1 & i \\cdot (-i) + (-i) \\cdot i\n\\end{bmatrix} = \\begin{bmatrix}\n 1 & 0 \\\\\n 0 & 1\n\\end{bmatrix}$$\n\nIf the multiplication result $AA^\\dagger$ is an identity matrix, which is indeed the case, \nand the product $A^\\dagger A$ is also an identity matrix (which you can verify in a similar manner),\nthe matrix is unitary.\n\n</details>"
825
+ "asHtml": "<p><strong>Unitary matrices</strong> are very important for quantum computing. A matrix is unitary when it's invertible, and its inverse is equal to its adjoint: $U^{-1} = U^\\dagger$. That is, an $n \\times n$ square matrix $U$ is unitary if and only if $UU^\\dagger = U^\\dagger U = I_n$.</p>\n<h2>🔎 Analyze</h2>\n<p>Is this matrix unitary?</p>\n<p>$$A = \\begin{bmatrix}\n \\frac{1}{\\sqrt{2}} &amp; \\frac{1}{\\sqrt{2}} \\\\\n \\frac{i}{\\sqrt{2}} &amp; \\frac{-i}{\\sqrt{2}}\n\\end{bmatrix} = \n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 &amp; 1 \\\\\n i &amp; -i\n\\end{bmatrix}$$</p>\n<details>\n<summary><b>Solution</b></summary>\nTo check whether the input matrix is unitary, you need to perform the following steps:\n<ol>\n<li>\n<p>Calculate the adjoint of the input matrix $A^\\dagger$.</p>\n<p>$$A^\\dagger = \\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 &amp; -i \\\\\n 1 &amp; i\n \\end{bmatrix}$$</p>\n</li>\n<li>\n<p>Multiply it by the input matrix.</p>\n<p>$$AA^\\dagger = \\frac12 \\begin{bmatrix}\n 1 &amp; 1 \\\\\n i &amp; -i\n \\end{bmatrix} \\begin{bmatrix}\n 1 &amp; -i \\\\\n 1 &amp; i\n \\end{bmatrix} = \\frac12 \\begin{bmatrix}\n 1 \\cdot 1 + 1 \\cdot 1 &amp; 1 \\cdot (-i) + 1 \\cdot i \\\\\n i \\cdot 1 + (-i) \\cdot 1 &amp; i \\cdot (-i) + (-i) \\cdot i\n \\end{bmatrix} = \\begin{bmatrix}\n 1 &amp; 0 \\\\\n 0 &amp; 1\n \\end{bmatrix}$$</p>\n</li>\n</ol>\n<p>You can see that the multiplication result $AA^\\dagger$ is an identity matrix, and the product $A^\\dagger A$ is also an identity matrix (which you can verify in a similar manner), so\nthe matrix is unitary.</p>\n</details>",
826
+ "asMarkdown": "\n**Unitary matrices** are very important for quantum computing. A matrix is unitary when it's invertible, and its inverse is equal to its adjoint: $U^{-1} = U^\\dagger$. That is, an $n \\times n$ square matrix $U$ is unitary if and only if $UU^\\dagger = U^\\dagger U = I_n$.\n\n## 🔎 Analyze\n\nIs this matrix unitary?\n\n$$A = \\begin{bmatrix}\n \\frac{1}{\\sqrt{2}} & \\frac{1}{\\sqrt{2}} \\\\\n \\frac{i}{\\sqrt{2}} & \\frac{-i}{\\sqrt{2}}\n\\end{bmatrix} = \n\\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 & 1 \\\\\n i & -i\n\\end{bmatrix}$$\n\n<details>\n<summary><b>Solution</b></summary>\nTo check whether the input matrix is unitary, you need to perform the following steps:\n\n1. Calculate the adjoint of the input matrix $A^\\dagger$.\n\n $$A^\\dagger = \\frac{1}{\\sqrt{2}} \\begin{bmatrix}\n 1 & -i \\\\\n 1 & i\n \\end{bmatrix}$$\n\n2. Multiply it by the input matrix.\n\n $$AA^\\dagger = \\frac12 \\begin{bmatrix}\n 1 & 1 \\\\\n i & -i\n \\end{bmatrix} \\begin{bmatrix}\n 1 & -i \\\\\n 1 & i\n \\end{bmatrix} = \\frac12 \\begin{bmatrix}\n 1 \\cdot 1 + 1 \\cdot 1 & 1 \\cdot (-i) + 1 \\cdot i \\\\\n i \\cdot 1 + (-i) \\cdot 1 & i \\cdot (-i) + (-i) \\cdot i\n \\end{bmatrix} = \\begin{bmatrix}\n 1 & 0 \\\\\n 0 & 1\n \\end{bmatrix}$$\n\nYou can see that the multiplication result $AA^\\dagger$ is an identity matrix, and the product $A^\\dagger A$ is also an identity matrix (which you can verify in a similar manner), so\nthe matrix is unitary.\n\n</details>"
825
827
  }
826
828
  ]
827
829
  },
@@ -832,8 +834,8 @@ export default {
832
834
  "items": [
833
835
  {
834
836
  "type": "text-content",
835
- "asHtml": "<p>The <strong>inner product</strong> is yet another important matrix operation that is only applied to vectors. Given two vectors $V$ and $W$ of the same size, their inner product $\\langle V , W \\rangle$ is defined as a product of matrices $V^\\dagger$ and $W$:</p>\n<p>$$\\langle V , W \\rangle = V^\\dagger W$$</p>\n<p>Let's break this down so it's a bit easier to understand. A $1 \\times n$ matrix (the adjoint of an $n \\times 1$ vector) multiplied by an $n \\times 1$ vector results in a $1 \\times 1$ matrix (which is equivalent to a scalar). The result of an inner product is that scalar.</p>\n<p>To put it another way, to calculate the inner product of two vectors, take the corresponding elements $V_k$ and $W_k$, multiply the complex conjugate of $V_k$ by $W_k$, and add up those products:</p>\n<p>$$\\langle V , W \\rangle = \\sum_{k=0}^{n-1}\\overline{V_k}W_k$$</p>\n<p>If you are familiar with the <strong>dot product</strong>, you will notice that it is equivalent to inner product for real-numbered vectors.</p>\n<blockquote>\n<p>We use our definition for these tutorials because it matches the notation used in quantum computing. You might encounter other sources which define the inner product a little differently: $\\langle V , W \\rangle = W^\\dagger V = V^T\\overline{W}$, in contrast to the $V^\\dagger W$ that we use. These definitions are almost equivalent, with some differences in the scalar multiplication by a complex number.</p>\n</blockquote>\n<p>An immediate application for the inner product is computing the <strong>vector norm</strong>. The norm of vector $V$ is defined as $||V|| = \\sqrt{\\langle V , V \\rangle}$. This condenses the vector down to a single non-negative real value. If the vector represents coordinates in space, the norm happens to be the length of the vector. A vector is called <strong>normalized</strong> if its norm is equal to $1$.</p>\n<p>The inner product has the following properties:</p>\n<ul>\n<li>Distributivity over addition: $\\langle V + W , X \\rangle = \\langle V , X \\rangle + \\langle W , X \\rangle$ and $\\langle V , W + X \\rangle = \\langle V , W \\rangle + \\langle V , X \\rangle$</li>\n<li>Partial associativity with scalar multiplication: $x \\cdot \\langle V , W \\rangle = \\langle \\overline{x}V , W \\rangle = \\langle V , xW \\rangle$</li>\n<li>Skew symmetry: $\\langle V , W \\rangle = \\overline{\\langle W , V \\rangle}$</li>\n<li>Multiplying a vector by a unitary matrix <strong>preserves the vector's inner product with itself</strong> (and therefore the vector's norm): $\\langle UV , UV \\rangle = \\langle V , V \\rangle$</li>\n</ul>\n<blockquote>\n<p>Note that just like matrix multiplication, the inner product is <strong>not commutative</strong>: $\\langle V , W \\rangle$ won't always equal $\\langle W , V \\rangle$.</p>\n</blockquote>\n",
836
- "asMarkdown": "\nThe **inner product** is yet another important matrix operation that is only applied to vectors. Given two vectors $V$ and $W$ of the same size, their inner product $\\langle V , W \\rangle$ is defined as a product of matrices $V^\\dagger$ and $W$:\n\n$$\\langle V , W \\rangle = V^\\dagger W$$\n\nLet's break this down so it's a bit easier to understand. A $1 \\times n$ matrix (the adjoint of an $n \\times 1$ vector) multiplied by an $n \\times 1$ vector results in a $1 \\times 1$ matrix (which is equivalent to a scalar). The result of an inner product is that scalar. \n\nTo put it another way, to calculate the inner product of two vectors, take the corresponding elements $V_k$ and $W_k$, multiply the complex conjugate of $V_k$ by $W_k$, and add up those products:\n\n$$\\langle V , W \\rangle = \\sum_{k=0}^{n-1}\\overline{V_k}W_k$$\n\nIf you are familiar with the **dot product**, you will notice that it is equivalent to inner product for real-numbered vectors.\n\n> We use our definition for these tutorials because it matches the notation used in quantum computing. You might encounter other sources which define the inner product a little differently: $\\langle V , W \\rangle = W^\\dagger V = V^T\\overline{W}$, in contrast to the $V^\\dagger W$ that we use. These definitions are almost equivalent, with some differences in the scalar multiplication by a complex number.\n\nAn immediate application for the inner product is computing the **vector norm**. The norm of vector $V$ is defined as $||V|| = \\sqrt{\\langle V , V \\rangle}$. This condenses the vector down to a single non-negative real value. If the vector represents coordinates in space, the norm happens to be the length of the vector. A vector is called **normalized** if its norm is equal to $1$.\n\nThe inner product has the following properties:\n\n* Distributivity over addition: $\\langle V + W , X \\rangle = \\langle V , X \\rangle + \\langle W , X \\rangle$ and $\\langle V , W + X \\rangle = \\langle V , W \\rangle + \\langle V , X \\rangle$\n* Partial associativity with scalar multiplication: $x \\cdot \\langle V , W \\rangle = \\langle \\overline{x}V , W \\rangle = \\langle V , xW \\rangle$\n* Skew symmetry: $\\langle V , W \\rangle = \\overline{\\langle W , V \\rangle}$\n* Multiplying a vector by a unitary matrix **preserves the vector's inner product with itself** (and therefore the vector's norm): $\\langle UV , UV \\rangle = \\langle V , V \\rangle$\n\n> Note that just like matrix multiplication, the inner product is **not commutative**: $\\langle V , W \\rangle$ won't always equal $\\langle W , V \\rangle$."
837
+ "asHtml": "<p>The <strong>inner product</strong> is yet another important matrix operation that is only applied to vectors. Given two vectors $V$ and $W$ of the same size, their inner product $\\langle V , W \\rangle$ is defined as a product of matrices $V^\\dagger$ and $W$:</p>\n<p>$$\\langle V , W \\rangle = V^\\dagger W$$</p>\n<p>Let's break this down so it's a bit easier to understand. A $1 \\times n$ matrix (the adjoint of an $n \\times 1$ vector) multiplied by an $n \\times 1$ vector results in a $1 \\times 1$ matrix, which is equivalent to a scalar. The result of an inner product is that scalar.</p>\n<p>That is, to calculate the inner product of two vectors, take the corresponding elements $V_k$ and $W_k$, multiply the complex conjugate of $V_k$ by $W_k$, and add up those products:</p>\n<p>$$\\langle V , W \\rangle = \\sum_{k=0}^{n-1}\\overline{V_k}W_k$$</p>\n<p>If you're familiar with the <strong>dot product</strong>, you'll notice that it's equivalent to inner product for real-numbered vectors.</p>\n<blockquote>\n<p>We use our definition for these tutorials because it matches the notation used in quantum computing. You might encounter other sources which define the inner product a little differently: $\\langle V , W \\rangle = W^\\dagger V = V^T\\overline{W}$, in contrast to the $V^\\dagger W$ that is used here. These definitions are almost equivalent, with some differences in the scalar multiplication by a complex number.</p>\n</blockquote>\n<p>An immediate application for the inner product is computing the <strong>vector norm</strong>. The norm of vector $V$ is defined as $||V|| = \\sqrt{\\langle V , V \\rangle}$. This condenses the vector down to a single non-negative real value. If the vector represents coordinates in space, the norm happens to be the length of the vector. A vector is called <strong>normalized</strong> if its norm is equal to $1$.</p>\n<p>The inner product has the following properties:</p>\n<ul>\n<li>Distributivity over addition: $\\langle V + W , X \\rangle = \\langle V , X \\rangle + \\langle W , X \\rangle$ and $\\langle V , W + X \\rangle = \\langle V , W \\rangle + \\langle V , X \\rangle$</li>\n<li>Partial associativity with scalar multiplication: $x \\cdot \\langle V , W \\rangle = \\langle \\overline{x}V , W \\rangle = \\langle V , xW \\rangle$</li>\n<li>Skew symmetry: $\\langle V , W \\rangle = \\overline{\\langle W , V \\rangle}$</li>\n<li>Multiplying a vector by a unitary matrix <strong>preserves the vector's inner product with itself</strong> (and therefore the vector's norm): $\\langle UV , UV \\rangle = \\langle V , V \\rangle$</li>\n</ul>\n<blockquote>\n<p>Note that just like matrix multiplication, the inner product <strong>isn't commutative</strong>: $\\langle V , W \\rangle$ won't always equal $\\langle W , V \\rangle$.</p>\n</blockquote>\n",
838
+ "asMarkdown": "\nThe **inner product** is yet another important matrix operation that is only applied to vectors. Given two vectors $V$ and $W$ of the same size, their inner product $\\langle V , W \\rangle$ is defined as a product of matrices $V^\\dagger$ and $W$:\n\n$$\\langle V , W \\rangle = V^\\dagger W$$\n\nLet's break this down so it's a bit easier to understand. A $1 \\times n$ matrix (the adjoint of an $n \\times 1$ vector) multiplied by an $n \\times 1$ vector results in a $1 \\times 1$ matrix, which is equivalent to a scalar. The result of an inner product is that scalar. \n\nThat is, to calculate the inner product of two vectors, take the corresponding elements $V_k$ and $W_k$, multiply the complex conjugate of $V_k$ by $W_k$, and add up those products:\n\n$$\\langle V , W \\rangle = \\sum_{k=0}^{n-1}\\overline{V_k}W_k$$\n\nIf you're familiar with the **dot product**, you'll notice that it's equivalent to inner product for real-numbered vectors.\n\n> We use our definition for these tutorials because it matches the notation used in quantum computing. You might encounter other sources which define the inner product a little differently: $\\langle V , W \\rangle = W^\\dagger V = V^T\\overline{W}$, in contrast to the $V^\\dagger W$ that is used here. These definitions are almost equivalent, with some differences in the scalar multiplication by a complex number.\n\nAn immediate application for the inner product is computing the **vector norm**. The norm of vector $V$ is defined as $||V|| = \\sqrt{\\langle V , V \\rangle}$. This condenses the vector down to a single non-negative real value. If the vector represents coordinates in space, the norm happens to be the length of the vector. A vector is called **normalized** if its norm is equal to $1$.\n\nThe inner product has the following properties:\n\n* Distributivity over addition: $\\langle V + W , X \\rangle = \\langle V , X \\rangle + \\langle W , X \\rangle$ and $\\langle V , W + X \\rangle = \\langle V , W \\rangle + \\langle V , X \\rangle$\n* Partial associativity with scalar multiplication: $x \\cdot \\langle V , W \\rangle = \\langle \\overline{x}V , W \\rangle = \\langle V , xW \\rangle$\n* Skew symmetry: $\\langle V , W \\rangle = \\overline{\\langle W , V \\rangle}$\n* Multiplying a vector by a unitary matrix **preserves the vector's inner product with itself** (and therefore the vector's norm): $\\langle UV , UV \\rangle = \\langle V , V \\rangle$\n\n> Note that just like matrix multiplication, the inner product **isn't commutative**: $\\langle V , W \\rangle$ won't always equal $\\langle W , V \\rangle$."
837
839
  }
838
840
  ]
839
841
  },
@@ -886,8 +888,8 @@ export default {
886
888
  "items": [
887
889
  {
888
890
  "type": "text-content",
889
- "asHtml": "<p>We start by calculating the norm of the vector</p>\n<p>$$||V|| = \\sqrt{\\langle V , V \\rangle} = \\sqrt{-6 \\cdot (-6) + (-8i) \\cdot 8i} = \\sqrt{6^2 + 8^2} = 10$$</p>\n<p>Then the normalized vector can be obtained by dividing each element of the original vector by its norm:</p>\n<p>$$\\frac{V}{||V||} = \\begin{bmatrix} -0.6 \\\\ 0.8i \\end{bmatrix}$$</p>\n",
890
- "asMarkdown": "\nWe start by calculating the norm of the vector\n\n$$||V|| = \\sqrt{\\langle V , V \\rangle} = \\sqrt{-6 \\cdot (-6) + (-8i) \\cdot 8i} = \\sqrt{6^2 + 8^2} = 10$$\n\nThen the normalized vector can be obtained by dividing each element of the original vector by its norm:\n \n$$\\frac{V}{||V||} = \\begin{bmatrix} -0.6 \\\\ 0.8i \\end{bmatrix}$$"
891
+ "asHtml": "<p>You start by calculating the norm of the vector</p>\n<p>$$||V|| = \\sqrt{\\langle V , V \\rangle} = \\sqrt{-6 \\cdot (-6) + (-8i) \\cdot 8i} = \\sqrt{6^2 + 8^2} = 10$$</p>\n<p>Then the normalized vector can be obtained by dividing each element of the original vector by its norm:</p>\n<p>$$\\frac{V}{||V||} = \\begin{bmatrix} -0.6 \\\\ 0.8i \\end{bmatrix}$$</p>\n",
892
+ "asMarkdown": "\nYou start by calculating the norm of the vector\n\n$$||V|| = \\sqrt{\\langle V , V \\rangle} = \\sqrt{-6 \\cdot (-6) + (-8i) \\cdot 8i} = \\sqrt{6^2 + 8^2} = 10$$\n\nThen the normalized vector can be obtained by dividing each element of the original vector by its norm:\n \n$$\\frac{V}{||V||} = \\begin{bmatrix} -0.6 \\\\ 0.8i \\end{bmatrix}$$"
891
893
  },
892
894
  {
893
895
  "type": "solution",
@@ -957,8 +959,8 @@ export default {
957
959
  "title": "Tensor Product of Two Matrices",
958
960
  "description": {
959
961
  "type": "text-content",
960
- "asHtml": "<p><strong>Input:</strong> None.</p>\n<p><strong>Goal:</strong> Return the tensor product of the following two matrices:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} \\otimes \\begin{bmatrix} 5 &amp; 6 \\\\ 7 &amp; 8 \\end{bmatrix}$$</p>\n<blockquote>\n<p>In this task we're using real-valued matrices represented as Q# <code>Double[][]</code> type again for simplicity.</p>\n</blockquote>\n",
961
- "asMarkdown": "**Input:** None.\n\n**Goal:** Return the tensor product of the following two matrices:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} \\otimes \\begin{bmatrix} 5 & 6 \\\\ 7 & 8 \\end{bmatrix}$$\n\n> In this task we're using real-valued matrices represented as Q# `Double[][]` type again for simplicity.\n"
962
+ "asHtml": "<p><strong>Input:</strong> None.</p>\n<p><strong>Goal:</strong> Return the tensor product of the following two matrices:</p>\n<p>$$\\begin{bmatrix} 1 &amp; 2 \\\\ 3 &amp; 4 \\end{bmatrix} \\otimes \\begin{bmatrix} 5 &amp; 6 \\\\ 7 &amp; 8 \\end{bmatrix}$$</p>\n<blockquote>\n<p>In this task, we're using real-valued matrices represented as Q# <code>Double[][]</code> type again for simplicity.</p>\n</blockquote>\n",
963
+ "asMarkdown": "**Input:** None.\n\n**Goal:** Return the tensor product of the following two matrices:\n\n$$\\begin{bmatrix} 1 & 2 \\\\ 3 & 4 \\end{bmatrix} \\otimes \\begin{bmatrix} 5 & 6 \\\\ 7 & 8 \\end{bmatrix}$$\n\n> In this task, we're using real-valued matrices represented as Q# `Double[][]` type again for simplicity.\n"
962
964
  },
963
965
  "sourceIds": [
964
966
  "linear_algebra__tensor_product__Verification.qs",
@@ -993,7 +995,8 @@ export default {
993
995
  }
994
996
  ]
995
997
  }
996
- ]
998
+ ],
999
+ "published": true
997
1000
  },
998
1001
  {
999
1002
  "id": "qubit",
@@ -1006,8 +1009,8 @@ export default {
1006
1009
  "items": [
1007
1010
  {
1008
1011
  "type": "text-content",
1009
- "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",
1010
- "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"
1012
+ "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>Basic knowledge of complex arithmetic</li>\n<li>Basic knowledge of linear algebra</li>\n</ul>\n",
1013
+ "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- Basic knowledge of complex arithmetic\n- Basic knowledge of linear algebra"
1011
1014
  }
1012
1015
  ]
1013
1016
  },
@@ -1018,8 +1021,8 @@ export default {
1018
1021
  "items": [
1019
1022
  {
1020
1023
  "type": "text-content",
1021
- "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'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'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",
1022
- "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>."
1024
+ "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'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$, and we just don't know which one until we &quot;measure&quot; it. That's 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's 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 <strong>basis states</strong>. These two vectors have two properties.</p>\n<ol>\n<li>\n<p>They are normalized.</p>\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</li>\n<li>\n<p>They are orthogonal to each other.</p>\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</li>\n</ol>\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",
1025
+ "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$, and we just don't know which one until we \"measure\" it. That's 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's 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>."
1023
1026
  }
1024
1027
  ]
1025
1028
  },
@@ -1030,8 +1033,8 @@ export default {
1030
1033
  "items": [
1031
1034
  {
1032
1035
  "type": "text-content",
1033
- "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 $\\ket{0}$, and a qubit in state $1$ is represented by the ket $\\ket{1}$:</p>\n<table>\n <tr>\n <td>$$\\ket{0} = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\ket{1} = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\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\\ket{0} + \\beta\\ket{1}$$</p>\n<p>Dirac notation is not only restricted to vectors $0$ and $1$; it can be used to represent any vector, similar 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>$$\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$$</p>\n<p>Several ket symbols have a generally accepted use, so you will see them often:</p>\n<table>\n <tr>\n <td>$$\\ket{+} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + \\ket{1}\\big)$$</td>\n <td>$$\\ket{-} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - \\ket{1}\\big)$$</td>\n </tr>\n <tr>\n <td>$$\\ket{i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + i\\ket{1}\\big)$$</td>\n <td>$$\\ket{-i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - i\\ket{1}\\big)$$</td>\n </tr>\n</table>\n<p>We will learn more about Dirac notation in the next katas, as we introduce quantum gates and multi-qubit systems.</p>\n",
1034
- "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 $\\ket{0}$, and a qubit in state $1$ is represented by the ket $\\ket{1}$:\n\n<table>\n <tr>\n <td>$$\\ket{0} = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\ket{1} = \\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\\ket{0} + \\beta\\ket{1}$$\n\nDirac notation is not only restricted to vectors $0$ and $1$; it can be used to represent any vector, similar 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$$\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$$\n\nSeveral ket symbols have a generally accepted use, so you will see them often:\n\n<table>\n <tr>\n <td>$$\\ket{+} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + \\ket{1}\\big)$$</td>\n <td>$$\\ket{-} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - \\ket{1}\\big)$$</td>\n </tr>\n <tr>\n <td>$$\\ket{i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + i\\ket{1}\\big)$$</td>\n <td>$$\\ket{-i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - i\\ket{1}\\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."
1036
+ "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 $\\ket{0}$, and a qubit in state $1$ is represented by the ket $\\ket{1}$:</p>\n<table>\n <tr>\n <td>$$\\ket{0} = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\ket{1} = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n<p>The kets $\\ket{0}$ and $\\ket{1}$ represent basis states, so they can be used to represent any other state:</p>\n<p>$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha\\ket{0} + \\beta\\ket{1}$$</p>\n<p>Dirac notation isn't restricted to vectors $0$ and $1$; it can be used to represent any vector, similar to how variable names are used in algebra. For example, you can call the above state &quot;$\\psi$&quot; and write it as:</p>\n<p>$$\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$$</p>\n<p>Several ket symbols have a generally accepted use, so you will see them often. For example, the following kets are commonly used:</p>\n<table>\n <tr>\n <td>$$\\ket{+} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + \\ket{1}\\big)$$</td>\n <td>$$\\ket{-} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - \\ket{1}\\big)$$</td>\n </tr>\n <tr>\n <td>$$\\ket{i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + i\\ket{1}\\big)$$</td>\n <td>$$\\ket{-i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - i\\ket{1}\\big)$$</td>\n </tr>\n</table>\n<p>You will learn more about Dirac notation in the next katas, as you get introduced to quantum gates and multi-qubit systems.</p>\n",
1037
+ "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 $\\ket{0}$, and a qubit in state $1$ is represented by the ket $\\ket{1}$:\n\n<table>\n <tr>\n <td>$$\\ket{0} = \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix}$$</td>\n <td>$$\\ket{1} = \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix}$$</td>\n </tr>\n</table>\n\nThe kets $\\ket{0}$ and $\\ket{1}$ represent basis states, so they can be used to represent any other state:\n\n$$\\begin{bmatrix} \\alpha \\\\ \\beta \\end{bmatrix} = \\alpha\\ket{0} + \\beta\\ket{1}$$\n\nDirac notation isn't restricted to vectors $0$ and $1$; it can be used to represent any vector, similar to how variable names are used in algebra. For example, you can call the above state \"$\\psi$\" and write it as:\n\n$$\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$$\n\nSeveral ket symbols have a generally accepted use, so you will see them often. For example, the following kets are commonly used:\n\n<table>\n <tr>\n <td>$$\\ket{+} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + \\ket{1}\\big)$$</td>\n <td>$$\\ket{-} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - \\ket{1}\\big)$$</td>\n </tr>\n <tr>\n <td>$$\\ket{i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} + i\\ket{1}\\big)$$</td>\n <td>$$\\ket{-i} = \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - i\\ket{1}\\big)$$</td>\n </tr>\n</table>\n\nYou will learn more about Dirac notation in the next katas, as you get introduced to quantum gates and multi-qubit systems."
1035
1038
  }
1036
1039
  ]
1037
1040
  },
@@ -1054,8 +1057,8 @@ export default {
1054
1057
  "items": [
1055
1058
  {
1056
1059
  "type": "text-content",
1057
- "asHtml": "<p>In Q#, qubits are represented by the <code>Qubit</code> 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.</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'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 $\\ket{0}$, 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 $\\ket{0}$, 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'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'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\\ket{0} + \\beta\\ket{1}$$</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'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'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't have access to the output of <code>DumpMachine</code>, so you cannot write any non-physical code in Q#!</p>\n</blockquote>\n",
1058
- "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 $\\ket{0}$, 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 $\\ket{0}$, 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\\ket{0} + \\beta\\ket{1}$$\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#!"
1060
+ "asHtml": "<p>In Q#, qubits are represented by the <code>Qubit</code> 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.</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>Qubits aren'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 $\\ket{0}$, 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 $\\ket{0}$, it will result in a runtime error. You will see why it is important later, when you look at multi-qubit systems.</p>\n<h2>Visualizing Quantum State</h2>\n<p>Before we continue, let'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'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\\ket{0} + \\beta\\ket{1}$$</p>\n<p>If this program runs on a physical quantum system, there's 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'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'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't have access to the output of <code>DumpMachine</code>, so you can't write any non-physical code in Q#!</p>\n</blockquote>\n",
1061
+ "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\nQubits 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 $\\ket{0}$, 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 $\\ket{0}$, it will result in a runtime error. You will see why it is important later, when you 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\\ket{0} + \\beta\\ket{1}$$\n\nIf this program runs on a physical quantum system, there's 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 can't write any non-physical code in Q#!"
1059
1062
  },
1060
1063
  {
1061
1064
  "type": "example",
@@ -1064,8 +1067,8 @@ export default {
1064
1067
  },
1065
1068
  {
1066
1069
  "type": "text-content",
1067
- "asHtml": "<p>The exact behavior of this operation called <code>RunExample</code> depends on the quantum simulator or processor you are using.</p>\n<p>On the simulator used in these demos, this function prints the information on each basis state that has a non-zero amplitude, one basis state per row.\nThis includes information about the amplitude of the state, the probability of measuring that state, and the phase of the state.</p>\n<p>Note that each row has the following format:</p>\n<table>\n <thead>\n <tr>\n <th>Basis State</th>\n <th>Amplitude</th>\n <th>Measurement Probability</th>\n <th>Phase</th>\n </tr>\n </thead>\n</table>\n<p>For example, the state $\\ket{0}$ would be represented as follows:</p>\n<table>\n <tbody>\n <tr>\n <td>|0⟩</td>\n <td>1.0000+0.0000𝑖</td>\n <td>100.0000%</td>\n <td>↑ 0.0000</td></tr>\n </tbody>\n</table>\n<blockquote>\n<p>It is important to note that although we reason about quantum systems in terms of their state, Q# does not have any representation of the quantum state in the language. Instead, state is an internal property of the quantum system, modified using gates. For more information, see <a href=\"https://learn.microsoft.com/azure/quantum/concepts-dirac-notation#q-gate-sequences-equivalent-to-quantum-states\" target=\"_blank\">Q# documentation on quantum states</a>.</p>\n</blockquote>\n",
1068
- "asMarkdown": "\nThe exact behavior of this operation called `RunExample` depends on the quantum simulator or processor you are using.\n\nOn the simulator used in these demos, this function prints the information on each basis state that has a non-zero amplitude, one basis state per row.\nThis includes information about the amplitude of the state, the probability of measuring that state, and the phase of the state.\n\nNote that each row has the following format:\n\n<table>\n <thead>\n <tr>\n <th>Basis State</th>\n <th>Amplitude</th>\n <th>Measurement Probability</th>\n <th>Phase</th>\n </tr>\n </thead>\n</table>\n\nFor example, the state $\\ket{0}$ would be represented as follows:\n\n<table>\n <tbody>\n <tr>\n <td>|0⟩</td>\n <td>1.0000+0.0000𝑖</td>\n <td>100.0000%</td>\n <td>↑ 0.0000</td></tr>\n </tbody>\n</table>\n\n> It is important to note that although we reason about quantum systems in terms of their state, Q# does not have any representation of the quantum state in the language. Instead, state is an internal property of the quantum system, modified using gates. For more information, see <a href=\"https://learn.microsoft.com/azure/quantum/concepts-dirac-notation#q-gate-sequences-equivalent-to-quantum-states\" target=\"_blank\">Q# documentation on quantum states</a>."
1070
+ "asHtml": "<p>The exact behavior of the <code>RunExample</code> operation depends on the quantum simulator or processor you're using.</p>\n<p>On the simulator used in these demos, this function prints the information on each basis state that has a non-zero amplitude, one basis state per row.\nThis includes information about the amplitude of the state, the probability of measuring that state, and the phase of the state.</p>\n<p>Note that each row has the following format:</p>\n<table>\n <thead>\n <tr>\n <th>Basis State</th>\n <th>Amplitude</th>\n <th>Measurement Probability</th>\n <th>Phase</th>\n </tr>\n </thead>\n</table>\n<p>For example, the state $\\ket{0}$ would be represented as follows:</p>\n<table>\n <tbody>\n <tr>\n <td>|0⟩</td>\n <td>1.0000+0.0000𝑖</td>\n <td>100.0000%</td>\n <td>↑ 0.0000</td></tr>\n </tbody>\n</table>\n<blockquote>\n<p>It's important to note that although we talk about quantum systems in terms of their state, Q# does not have any representation of the quantum state in the language. Instead, state is an internal property of the quantum system, modified using gates. For more information, see <a href=\"https://learn.microsoft.com/azure/quantum/concepts-dirac-notation#q-gate-sequences-equivalent-to-quantum-states\" target=\"_blank\">Q# documentation on quantum states</a>.</p>\n</blockquote>\n",
1071
+ "asMarkdown": "\nThe exact behavior of the `RunExample` operation depends on the quantum simulator or processor you're using.\n\nOn the simulator used in these demos, this function prints the information on each basis state that has a non-zero amplitude, one basis state per row.\nThis includes information about the amplitude of the state, the probability of measuring that state, and the phase of the state.\n\nNote that each row has the following format:\n\n<table>\n <thead>\n <tr>\n <th>Basis State</th>\n <th>Amplitude</th>\n <th>Measurement Probability</th>\n <th>Phase</th>\n </tr>\n </thead>\n</table>\n\nFor example, the state $\\ket{0}$ would be represented as follows:\n\n<table>\n <tbody>\n <tr>\n <td>|0⟩</td>\n <td>1.0000+0.0000𝑖</td>\n <td>100.0000%</td>\n <td>↑ 0.0000</td></tr>\n </tbody>\n</table>\n\n> It's important to note that although we talk about quantum systems in terms of their state, Q# does not have any representation of the quantum state in the language. Instead, state is an internal property of the quantum system, modified using gates. For more information, see <a href=\"https://learn.microsoft.com/azure/quantum/concepts-dirac-notation#q-gate-sequences-equivalent-to-quantum-states\" target=\"_blank\">Q# documentation on quantum states</a>."
1069
1072
  }
1070
1073
  ]
1071
1074
  },
@@ -1075,8 +1078,8 @@ export default {
1075
1078
  "title": "Learn the State of a Single Qubit Using DumpMachine",
1076
1079
  "description": {
1077
1080
  "type": "text-content",
1078
- "asHtml": "<p><strong>Input:</strong> A qubit in an unknown state $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$. The amplitudes $\\alpha$ and $\\beta$ will be real and non-negative.</p>\n<p><strong>Output:</strong> A tuple of two numbers $(\\alpha&#039;, \\beta&#039;)$ - your estimates of the amplitudes $\\alpha$ and $\\beta$.\nThe absolute errors $|\\alpha - \\alpha&#039;|$ and $|\\beta - \\beta&#039;|$ 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",
1079
- "asMarkdown": "\n**Input:** A qubit in an unknown state $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$. The amplitudes $\\alpha$ and $\\beta$ will be real and non-negative.\n\n**Output:** A tuple of two numbers $(\\alpha', \\beta')$ - your estimates of the amplitudes $\\alpha$ and $\\beta$.\nThe absolute errors $|\\alpha - \\alpha'|$ and $|\\beta - \\beta'|$ 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 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"
1081
+ "asHtml": "<p><strong>Input:</strong> A qubit in an unknown state $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$. The amplitudes $\\alpha$ and $\\beta$ will be real and non-negative.</p>\n<p><strong>Output:</strong> A tuple of two numbers $(\\alpha&#039;, \\beta&#039;)$ - your estimates of the amplitudes $\\alpha$ and $\\beta$.\nThe absolute errors $|\\alpha - \\alpha&#039;|$ and $|\\beta - \\beta&#039;|$ 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's no way to obtain the values of $\\alpha$ and $\\beta$ from a single observation. Since this program runs on a simulator, you 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 you can update the code to return the amplitudes that you've taken note of. Then run the code again.\n</details>\n",
1082
+ "asMarkdown": "\n**Input:** A qubit in an unknown state $\\ket{\\psi} = \\alpha\\ket{0} + \\beta\\ket{1}$. The amplitudes $\\alpha$ and $\\beta$ will be real and non-negative.\n\n**Output:** A tuple of two numbers $(\\alpha', \\beta')$ - your estimates of the amplitudes $\\alpha$ and $\\beta$.\nThe absolute errors $|\\alpha - \\alpha'|$ and $|\\beta - \\beta'|$ 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's no way to obtain the values of $\\alpha$ and $\\beta$ from a single observation. Since this program runs on a simulator, you 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 you can update the code to return the amplitudes that you've taken note of. Then run the code again.\n</details>\n"
1080
1083
  },
1081
1084
  "sourceIds": [
1082
1085
  "qubit__learn_single_qubit_state__Verification.qs",
@@ -1111,7 +1114,8 @@ export default {
1111
1114
  }
1112
1115
  ]
1113
1116
  }
1114
- ]
1117
+ ],
1118
+ "published": true
1115
1119
  },
1116
1120
  {
1117
1121
  "id": "single_qubit_gates",
@@ -1684,7 +1688,8 @@ export default {
1684
1688
  }
1685
1689
  ]
1686
1690
  }
1687
- ]
1691
+ ],
1692
+ "published": true
1688
1693
  },
1689
1694
  {
1690
1695
  "id": "multi_qubit_systems",
@@ -2048,7 +2053,8 @@ export default {
2048
2053
  }
2049
2054
  ]
2050
2055
  }
2051
- ]
2056
+ ],
2057
+ "published": true
2052
2058
  },
2053
2059
  {
2054
2060
  "id": "multi_qubit_gates",
@@ -2538,7 +2544,8 @@ export default {
2538
2544
  }
2539
2545
  ]
2540
2546
  }
2541
- ]
2547
+ ],
2548
+ "published": true
2542
2549
  },
2543
2550
  {
2544
2551
  "id": "preparing_states",
@@ -3331,7 +3338,8 @@ export default {
3331
3338
  }
3332
3339
  ]
3333
3340
  }
3334
- ]
3341
+ ],
3342
+ "published": true
3335
3343
  },
3336
3344
  {
3337
3345
  "id": "single_qubit_measurements",
@@ -3586,7 +3594,8 @@ export default {
3586
3594
  }
3587
3595
  ]
3588
3596
  }
3589
- ]
3597
+ ],
3598
+ "published": true
3590
3599
  },
3591
3600
  {
3592
3601
  "id": "multi_qubit_measurements",
@@ -3902,7 +3911,485 @@ export default {
3902
3911
  }
3903
3912
  ]
3904
3913
  }
3905
- ]
3914
+ ],
3915
+ "published": true
3916
+ },
3917
+ {
3918
+ "id": "distinguishing_unitaries",
3919
+ "title": "Distinguishing Unitaries",
3920
+ "sections": [
3921
+ {
3922
+ "type": "lesson",
3923
+ "id": "distinguishing_unitaries__overview",
3924
+ "title": "Overview",
3925
+ "items": [
3926
+ {
3927
+ "type": "text-content",
3928
+ "asHtml": "<p>This kata offers you a series of tasks in which you are given one unitary from the given list and have to figure out which one it is by designing and performing experiments on it.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>quantum measurements,</li>\n<li>designing experiments to analyze behavior of unitary transformations.</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Dirac notation for single-qubit and multi-qubit quantum systems</li>\n<li>Basic single-qubit and multi-qubit gates</li>\n<li>Quantum measurements and their effect on quantum systems</li>\n</ul>\n",
3929
+ "asMarkdown": "\nThis kata offers you a series of tasks in which you are given one unitary from the given list and have to figure out which one it is by designing and performing experiments on it.\n\n**This kata covers the following topics:**\n\n- quantum measurements,\n- designing experiments to analyze behavior of unitary transformations.\n\n**What you should know to start working on this kata:**\n\n- Dirac notation for single-qubit and multi-qubit quantum systems\n- Basic single-qubit and multi-qubit gates\n- Quantum measurements and their effect on quantum systems"
3930
+ }
3931
+ ]
3932
+ },
3933
+ {
3934
+ "type": "lesson",
3935
+ "id": "distinguishing_unitaries__single_qubit",
3936
+ "title": "Distinguishing Single-Qubit Gates",
3937
+ "items": []
3938
+ },
3939
+ {
3940
+ "type": "exercise",
3941
+ "id": "distinguishing_unitaries__i_x",
3942
+ "title": "Identity or X?",
3943
+ "description": {
3944
+ "type": "text-content",
3945
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the identity $I$ or the Pauli $X$ gate.</p>\n<p><strong>Output:</strong> 0 if the given operation is the $I$ gate, 1 if the given operation is the $X$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou can apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
3946
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the identity $I$ or the Pauli $X$ gate. \n\n**Output:** 0 if the given operation is the $I$ gate, 1 if the given operation is the $X$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou can apply the given operation and its adjoint/controlled variants exactly **once**.\n"
3947
+ },
3948
+ "sourceIds": [
3949
+ "distinguishing_unitaries__i_x__Verification.qs",
3950
+ "KatasLibrary.qs",
3951
+ "distinguishing_unitaries__Common.qs"
3952
+ ],
3953
+ "placeholderCode": "namespace Kata {\n operation DistinguishIfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
3954
+ "explainedSolution": {
3955
+ "type": "explained-solution",
3956
+ "items": [
3957
+ {
3958
+ "type": "text-content",
3959
+ "asHtml": "<p>The only way to extract information out of a quantum system is measurement.\nMeasurements give us information about the states of a system, so to get information about the gate, we need to find a way to convert it into information about a state.\nIf we want to distinguish two gates, we need to figure out to prepare a state and perform a measurement on it that will give us a result that we can interpret.\nTo do this, we'll need to find a qubit state that, by applying to it $I$ gate or $X$ gate, will be transformed into states that can be distinguished using measurement, i.e., orthogonal states.\nLet's find such state.</p>\n<blockquote>\n<p>As a reminder, here are the matrices that correspond to the given gates:\n$$I = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix}, X = \\begin{bmatrix} 0 &amp; 1 \\\\ 1 &amp; 0 \\end{bmatrix}$$</p>\n</blockquote>\n<p>Consider the effects of these gates on the basis state $\\ket{0}$.</p>\n<p>$$I\\ket{0} = \\ket{0}$$\n$$X\\ket{0} = \\ket{1}$$</p>\n<p>We see that the $I$ gate leaves the $\\ket{0}$ state unchanged, and the $X$ gate transforms it into the $\\ket{1}$ state.\nSo the easiest thing to do is to prepare a $\\ket{0}$ state, apply the given unitary to it, and measure the resulting state in the computational basis:</p>\n<ul>\n<li>If the measurement result is <code>Zero</code>, the measured state was $\\ket{0}$, and we know the unitary applied to it was the $I$ gate.</li>\n<li>If the measurement result is <code>One</code>, the measured state was $\\ket{1}$, and we know the unitary applied to it was the $X$ gate.</li>\n</ul>\n<blockquote>\n<p>In Q#, the freshly allocated qubits start in the $\\ket{0}$ state, so you don't need to do anything to prepare the necessary state before applying the unitary to it.\nYou also have to return the qubits you allocated to the $\\ket{0}$ state before releasing them.\nYou can do that by measuring the qubit using the <code>M</code> operation and applying the $X$ gate if it was measured in the $\\ket{1}$ state, or you can use <a href=\"https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.measurement/mresetz\"><code>MResetZ</code></a> operation that wraps this measurement and qubit reset into one operation.</p>\n</blockquote>\n",
3960
+ "asMarkdown": "\nThe only way to extract information out of a quantum system is measurement. \nMeasurements give us information about the states of a system, so to get information about the gate, we need to find a way to convert it into information about a state.\nIf we want to distinguish two gates, we need to figure out to prepare a state and perform a measurement on it that will give us a result that we can interpret.\nTo do this, we'll need to find a qubit state that, by applying to it $I$ gate or $X$ gate, will be transformed into states that can be distinguished using measurement, i.e., orthogonal states. \nLet's find such state.\n\n> As a reminder, here are the matrices that correspond to the given gates:\n> $$I = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}, X = \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$$\n\nConsider the effects of these gates on the basis state $\\ket{0}$.\n\n$$I\\ket{0} = \\ket{0}$$\n$$X\\ket{0} = \\ket{1}$$\n\nWe see that the $I$ gate leaves the $\\ket{0}$ state unchanged, and the $X$ gate transforms it into the $\\ket{1}$ state. \nSo the easiest thing to do is to prepare a $\\ket{0}$ state, apply the given unitary to it, and measure the resulting state in the computational basis:\n* If the measurement result is `Zero`, the measured state was $\\ket{0}$, and we know the unitary applied to it was the $I$ gate.\n* If the measurement result is `One`, the measured state was $\\ket{1}$, and we know the unitary applied to it was the $X$ gate.\n\n> In Q#, the freshly allocated qubits start in the $\\ket{0}$ state, so you don't need to do anything to prepare the necessary state before applying the unitary to it.\n> You also have to return the qubits you allocated to the $\\ket{0}$ state before releasing them. \n> You can do that by measuring the qubit using the `M` operation and applying the $X$ gate if it was measured in the $\\ket{1}$ state, or you can use [`MResetZ`](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.measurement/mresetz) operation that wraps this measurement and qubit reset into one operation."
3961
+ },
3962
+ {
3963
+ "type": "solution",
3964
+ "id": "distinguishing_unitaries__i_x_solution",
3965
+ "code": "namespace Kata {\n operation DistinguishIfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use q = Qubit();\n unitary(q);\n return MResetZ(q) == Zero ? 0 | 1;\n }\n}\n"
3966
+ }
3967
+ ]
3968
+ }
3969
+ },
3970
+ {
3971
+ "type": "exercise",
3972
+ "id": "distinguishing_unitaries__i_z",
3973
+ "title": "Identity or Z?",
3974
+ "description": {
3975
+ "type": "text-content",
3976
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the identity $I$ or the Pauli $Z$ gate.</p>\n<p><strong>Output:</strong> 0 if the given operation is the $I$ gate, 1 if the given operation is the $Z$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
3977
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the identity $I$ or the Pauli $Z$ gate.\n\n**Output:** 0 if the given operation is the $I$ gate, 1 if the given operation is the $Z$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
3978
+ },
3979
+ "sourceIds": [
3980
+ "distinguishing_unitaries__i_z__Verification.qs",
3981
+ "KatasLibrary.qs",
3982
+ "distinguishing_unitaries__Common.qs"
3983
+ ],
3984
+ "placeholderCode": "namespace Kata {\n operation DistinguishIfromZ(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
3985
+ "explainedSolution": {
3986
+ "type": "explained-solution",
3987
+ "items": [
3988
+ {
3989
+ "type": "text-content",
3990
+ "asHtml": "<blockquote>\n<p>As a reminder, $$Z = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix}$$</p>\n</blockquote>\n<p>We won't be able to distinguish $I$ from $Z$ by applying them to the basis states, since they both leave the $\\ket{0}$ state unchanged and add a phase to the $\\ket{1}$ state:</p>\n<p>$$I\\ket{0} = \\ket{0}, I\\ket{1} = \\ket{1}$$\n$$Z\\ket{0} = \\ket{0}, Z\\ket{1} = -\\ket{1}$$</p>\n<p>However, if we try applying these gates to a superposition of basis states, we'll start seeing a difference between the resulting states:</p>\n<p>$$I \\big(\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})\\big) = \\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})$$\n$$Z \\big(\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})\\big) = \\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1})$$</p>\n<p>These two states are orthogonal and can be distinguished by measuring them in the $\\{ \\ket{+}, \\ket{-}\\}$ basis using <a href=\"https://learn.microsoft.com/en-us/qsharp/api/qsharp-lang/microsoft.quantum.measurement/mresetx\"><code>MResetX</code></a> operation (which is equivalent to applying an $H$ gate and measuring in the computational basis).</p>\n<blockquote>\n<p>The task of distinguishing these two states is covered in more detail in the Distinguishing Quantum States kata.</p>\n</blockquote>\n",
3991
+ "asMarkdown": "\n> As a reminder, $$Z = \\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$$\n\nWe won't be able to distinguish $I$ from $Z$ by applying them to the basis states, since they both leave the $\\ket{0}$ state unchanged and add a phase to the $\\ket{1}$ state: \n\n$$I\\ket{0} = \\ket{0}, I\\ket{1} = \\ket{1}$$\n$$Z\\ket{0} = \\ket{0}, Z\\ket{1} = -\\ket{1}$$\n\nHowever, if we try applying these gates to a superposition of basis states, we'll start seeing a difference between the resulting states:\n\n$$I \\big(\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})\\big) = \\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})$$\n$$Z \\big(\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})\\big) = \\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1})$$\n\nThese two states are orthogonal and can be distinguished by measuring them in the $\\{ \\ket{+}, \\ket{-}\\}$ basis using [`MResetX`](https://learn.microsoft.com/en-us/qsharp/api/qsharp-lang/microsoft.quantum.measurement/mresetx) operation (which is equivalent to applying an $H$ gate and measuring in the computational basis).\n\n> The task of distinguishing these two states is covered in more detail in the Distinguishing Quantum States kata."
3992
+ },
3993
+ {
3994
+ "type": "solution",
3995
+ "id": "distinguishing_unitaries__i_z_solution",
3996
+ "code": "namespace Kata {\n operation DistinguishIfromZ(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use q = Qubit();\n H(q);\n unitary(q);\n return MResetX(q) == Zero ? 0 | 1;\n }\n}\n"
3997
+ }
3998
+ ]
3999
+ }
4000
+ },
4001
+ {
4002
+ "type": "exercise",
4003
+ "id": "distinguishing_unitaries__z_s",
4004
+ "title": "Z or S?",
4005
+ "description": {
4006
+ "type": "text-content",
4007
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the $Z$ gate or the $S$ gate.</p>\n<p><strong>Output:</strong> 0 if the given operation is the $Z$ gate, 1 if the given operation is the $S$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most <strong>twice</strong>.</p>\n",
4008
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the $Z$ gate or the $S$ gate. \n\n**Output:** 0 if the given operation is the $Z$ gate, 1 if the given operation is the $S$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most **twice**.\n"
4009
+ },
4010
+ "sourceIds": [
4011
+ "distinguishing_unitaries__z_s__Verification.qs",
4012
+ "KatasLibrary.qs",
4013
+ "distinguishing_unitaries__Common.qs"
4014
+ ],
4015
+ "placeholderCode": "namespace Kata {\n operation DistinguishZfromS(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4016
+ "explainedSolution": {
4017
+ "type": "explained-solution",
4018
+ "items": [
4019
+ {
4020
+ "type": "text-content",
4021
+ "asHtml": "<blockquote>\n<p>As a reminder, $$S = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; i \\end{bmatrix}$$</p>\n</blockquote>\n<p>This task differs from the previous two in that it allows you to apply the given unitary <strong>twice</strong>.\nLet's treat this as a hint that it is, and check how the given gates looks when applied twice.\nIf you square the corresponding matrices (which is quite simple to do for diagonal matrices), you'll get</p>\n<p>$$Z^2 = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; 1 \\end{bmatrix} = I, S^2 = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; -1 \\end{bmatrix} = Z$$</p>\n<p>This means that the task of identifying the <em>square</em> of the given unitary transformation is the same as distinguishing $I$ from $Z$ gates - and that's exactly the previous task.</p>\n",
4022
+ "asMarkdown": "\n> As a reminder, $$S = \\begin{bmatrix} 1 & 0 \\\\ 0 & i \\end{bmatrix}$$\n\nThis task differs from the previous two in that it allows you to apply the given unitary **twice**. \nLet's treat this as a hint that it is, and check how the given gates looks when applied twice. \nIf you square the corresponding matrices (which is quite simple to do for diagonal matrices), you'll get\n\n$$Z^2 = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix} = I, S^2 = \\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix} = Z$$\n\nThis means that the task of identifying the *square* of the given unitary transformation is the same as distinguishing $I$ from $Z$ gates - and that's exactly the previous task."
4023
+ },
4024
+ {
4025
+ "type": "solution",
4026
+ "id": "distinguishing_unitaries__z_s_solution",
4027
+ "code": "namespace Kata {\n operation DistinguishZfromS(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use q = Qubit();\n H(q);\n unitary(q);\n unitary(q);\n return MResetX(q) == Zero ? 0 | 1;\n }\n}\n"
4028
+ }
4029
+ ]
4030
+ }
4031
+ },
4032
+ {
4033
+ "type": "exercise",
4034
+ "id": "distinguishing_unitaries__h_x",
4035
+ "title": "Hadamard or X?",
4036
+ "description": {
4037
+ "type": "text-content",
4038
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the $H$ gate or the $X$ gate.</p>\n<p><strong>Output:</strong> 0 if the given operation is the $H$ gate, 1 if the given operation is the $X$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most <strong>twice</strong>.</p>\n",
4039
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the $H$ gate or the $X$ gate. \n\n**Output:** 0 if the given operation is the $H$ gate, 1 if the given operation is the $X$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most **twice**.\n"
4040
+ },
4041
+ "sourceIds": [
4042
+ "distinguishing_unitaries__h_x__Verification.qs",
4043
+ "KatasLibrary.qs",
4044
+ "distinguishing_unitaries__Common.qs"
4045
+ ],
4046
+ "placeholderCode": "namespace Kata {\n operation DistinguishHfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4047
+ "explainedSolution": {
4048
+ "type": "explained-solution",
4049
+ "items": [
4050
+ {
4051
+ "type": "text-content",
4052
+ "asHtml": "<blockquote>\n<p>As a reminder, $$H = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 &amp; 1 \\\\ 1 &amp; -1 \\end{bmatrix}$$</p>\n</blockquote>\n<p>The solution relies on the well-known identity $HXH = Z$ (i.e., Hadamard gate can be used to convert $X$ to $Z$ and vice versa). Applying a sequence of gates &quot;given unitary - $X$ - given unitary&quot; will be equivalent to $XXX = X$ gate if the unitary was $X$, and to $HXH = Z$ if the unitary was $H$. With this observation we need to distinguish $X$ from $Z$, which can be done using the $\\ket{0}$ state: $X$ gate will change it to $\\ket{1}$, and $Z$ gate will leave it unchanged.</p>\n",
4053
+ "asMarkdown": "\n> As a reminder, $$H = \\frac{1}{\\sqrt2} \\begin{bmatrix} 1 & 1 \\\\ 1 & -1 \\end{bmatrix}$$\n\nThe solution relies on the well-known identity $HXH = Z$ (i.e., Hadamard gate can be used to convert $X$ to $Z$ and vice versa). Applying a sequence of gates \"given unitary - $X$ - given unitary\" will be equivalent to $XXX = X$ gate if the unitary was $X$, and to $HXH = Z$ if the unitary was $H$. With this observation we need to distinguish $X$ from $Z$, which can be done using the $\\ket{0}$ state: $X$ gate will change it to $\\ket{1}$, and $Z$ gate will leave it unchanged."
4054
+ },
4055
+ {
4056
+ "type": "solution",
4057
+ "id": "distinguishing_unitaries__h_x_solution",
4058
+ "code": "namespace Kata {\n operation DistinguishHfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use q = Qubit();\n within {\n unitary(q);\n } apply {\n X(q);\n }\n return MResetZ(q) == Zero ? 0 | 1;\n }\n}\n"
4059
+ }
4060
+ ]
4061
+ }
4062
+ },
4063
+ {
4064
+ "type": "exercise",
4065
+ "id": "distinguishing_unitaries__z_minusz",
4066
+ "title": "Z or -Z?",
4067
+ "description": {
4068
+ "type": "text-content",
4069
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the $Z$ gate or the minus $Z$ gate (i.e., the gate $-\\ket{0}\\bra{0} + \\ket{1}\\bra{1}$).</p>\n<p><strong>Output:</strong> 0 if the given operation is the $Z$ gate, 1 if the given operation is the $-Z$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4070
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the $Z$ gate or the minus $Z$ gate (i.e., the gate $-\\ket{0}\\bra{0} + \\ket{1}\\bra{1}$). \n\n**Output:** 0 if the given operation is the $Z$ gate, 1 if the given operation is the $-Z$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4071
+ },
4072
+ "sourceIds": [
4073
+ "distinguishing_unitaries__z_minusz__Verification.qs",
4074
+ "KatasLibrary.qs",
4075
+ "distinguishing_unitaries__Common.qs"
4076
+ ],
4077
+ "placeholderCode": "namespace Kata {\n operation DistinguishZfromMinusZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4078
+ "explainedSolution": {
4079
+ "type": "explained-solution",
4080
+ "items": [
4081
+ {
4082
+ "type": "text-content",
4083
+ "asHtml": "<p>This task is more interesting: the given gates differ by a global phase they introduce (i.e., each of them is a multiple of the other), and the results of applying them to any single-qubit state are going to be indistinguishable by any measurement you can devise.</p>\n<p>Fortunately, we are given not just the unitary itself, but also its controlled variant, i.e., the gate which applies the given unitary if the control qubit is in the $\\ket{1}$ state and does nothing if it is in the $\\ket{0}$ state.\nThis allows us to use so called &quot;phase kickback&quot; trick, in which applying a controlled version of a gate allows us to observe the phase introduced by this gate on the control qubit. Indeed,</p>\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">Controlled Z</th>\n <th style=\"text-align:center\">Controlled $-Z$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\color{blue}{\\ket{10}}$</td>\n <td style=\"text-align:center\">$\\color{blue}{-\\ket{10}}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\color{blue}{-\\ket{11}}$</td>\n <td style=\"text-align:center\">$\\color{blue}{\\ket{11}}$</td>\n </tr>\n</table>\n<p>We see that both controlled gates don't modify the states with the control qubit in the $\\ket{0}$ state, but if the control qubit is in the $\\ket{1}$ state, they introduce a $-1$ phase to different basis states.\nWe can take advantage of this if we apply the controlled gate to a state in which the <em>control qubit</em> is in superposition, such as $\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0}$:</p>\n<p>$$\\text{Controlled Z}\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0} = \\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0}$$\n$$\\text{Controlled }-\\text{Z}\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0} = \\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1}) \\otimes \\ket{0}$$</p>\n<p>After this we can measure the first qubit to distinguish $\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})$ from $\\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1})$, like we did in task 'Identity or Z'.</p>\n<blockquote>\n<p>In Q# we can express controlled version of a gate using <a href=\"https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/expressions/functorapplication#controlled-functor\">Controlled functor</a>: the first argument of the resulting gate will be an array of control qubits, and the second one - the arguments of the original gate (in this case just the target qubit).</p>\n</blockquote>\n",
4084
+ "asMarkdown": "\nThis task is more interesting: the given gates differ by a global phase they introduce (i.e., each of them is a multiple of the other), and the results of applying them to any single-qubit state are going to be indistinguishable by any measurement you can devise.\n\nFortunately, we are given not just the unitary itself, but also its controlled variant, i.e., the gate which applies the given unitary if the control qubit is in the $\\ket{1}$ state and does nothing if it is in the $\\ket{0}$ state.\nThis allows us to use so called \"phase kickback\" trick, in which applying a controlled version of a gate allows us to observe the phase introduced by this gate on the control qubit. Indeed,\n\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">Controlled Z</th>\n <th style=\"text-align:center\">Controlled $-Z$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\color{blue}{\\ket{10}}$</td>\n <td style=\"text-align:center\">$\\color{blue}{-\\ket{10}}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\color{blue}{-\\ket{11}}$</td>\n <td style=\"text-align:center\">$\\color{blue}{\\ket{11}}$</td>\n </tr>\n</table>\n\nWe see that both controlled gates don't modify the states with the control qubit in the $\\ket{0}$ state, but if the control qubit is in the $\\ket{1}$ state, they introduce a $-1$ phase to different basis states. \nWe can take advantage of this if we apply the controlled gate to a state in which the *control qubit* is in superposition, such as $\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0}$:\n\n$$\\text{Controlled Z}\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0} = \\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0}$$\n$$\\text{Controlled }-\\text{Z}\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1}) \\otimes \\ket{0} = \\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1}) \\otimes \\ket{0}$$\n\nAfter this we can measure the first qubit to distinguish $\\frac{1}{\\sqrt2}(\\ket{0} + \\ket{1})$ from $\\frac{1}{\\sqrt2}(\\ket{0} - \\ket{1})$, like we did in task 'Identity or Z'.\n\n> In Q# we can express controlled version of a gate using [Controlled functor](https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/expressions/functorapplication#controlled-functor): the first argument of the resulting gate will be an array of control qubits, and the second one - the arguments of the original gate (in this case just the target qubit)."
4085
+ },
4086
+ {
4087
+ "type": "solution",
4088
+ "id": "distinguishing_unitaries__z_minusz_solution",
4089
+ "code": "namespace Kata {\n operation DistinguishZfromMinusZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use qs = Qubit[2];\n H(qs[0]);\n Controlled unitary(qs[0..0], qs[1]);\n return MResetX(qs[0]) == Zero ? 0 | 1;\n } \n}\n"
4090
+ }
4091
+ ]
4092
+ }
4093
+ },
4094
+ {
4095
+ "type": "exercise",
4096
+ "id": "distinguishing_unitaries__rz_r1",
4097
+ "title": "Rz or R1?",
4098
+ "description": {
4099
+ "type": "text-content",
4100
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the <a href=\"https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz\">$R_z$ gate</a> or the <a href=\"https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/r1\">$R1$ gate</a>.</p>\n<p>This operation will take two parameters: the first parameter is the rotation angle, in radians, and the second parameter is the qubit to which the gate should be applied (matching normal <code>Rz</code> and <code>R1</code> gates in Q#).</p>\n<blockquote>\n<p>As a reminder, $$R_z(\\theta) = \\begin{bmatrix} e^{-i\\theta/2} &amp; 0 \\\\ 0 &amp; e^{i\\theta/2} \\end{bmatrix} \\text{, } \nR_1(\\theta) = \\begin{bmatrix} 1 &amp; 0 \\\\ 0 &amp; e^{i\\theta} \\end{bmatrix} = e^{i\\theta/2} R_z(\\theta)$$</p>\n</blockquote>\n<p><strong>Output:</strong> 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R1$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4101
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the [$R_z$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz) or the [$R1$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/r1). \n\nThis operation will take two parameters: the first parameter is the rotation angle, in radians, and the second parameter is the qubit to which the gate should be applied (matching normal `Rz` and `R1` gates in Q#).\n\n> As a reminder, $$R_z(\\theta) = \\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{bmatrix} \\text{, } \nR_1(\\theta) = \\begin{bmatrix} 1 & 0 \\\\ 0 & e^{i\\theta} \\end{bmatrix} = e^{i\\theta/2} R_z(\\theta)$$\n\n**Output:** 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R1$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4102
+ },
4103
+ "sourceIds": [
4104
+ "distinguishing_unitaries__rz_r1__Verification.qs",
4105
+ "KatasLibrary.qs",
4106
+ "distinguishing_unitaries__Common.qs"
4107
+ ],
4108
+ "placeholderCode": "namespace Kata {\n open Microsoft.Quantum.Math;\n \n operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4109
+ "explainedSolution": {
4110
+ "type": "explained-solution",
4111
+ "items": [
4112
+ {
4113
+ "type": "text-content",
4114
+ "asHtml": "<p>We see that these two gates differ by a global phase $e^{i\\theta/2}$.\nIn this problem we're free to choose the angle parameter which we'll pass to our gate, so we can choose an angle that make this global phase difference something easy to detect: for $\\theta = 2\\pi$ $e^{i\\theta/2} = -1$, so $R_z(\\theta) = -I$, and $R_1(\\theta) = I$.</p>\n<p>Now we need to distinguish $I$ gate from $-I$ gate, which can be done using controlled variant of the gate in exactly the same way as distinguishing $Z$ gate from $-Z$ gate in the task 'Z or -Z'.</p>\n",
4115
+ "asMarkdown": "\nWe see that these two gates differ by a global phase $e^{i\\theta/2}$.\nIn this problem we're free to choose the angle parameter which we'll pass to our gate, so we can choose an angle that make this global phase difference something easy to detect: for $\\theta = 2\\pi$ $e^{i\\theta/2} = -1$, so $R_z(\\theta) = -I$, and $R_1(\\theta) = I$.\n\nNow we need to distinguish $I$ gate from $-I$ gate, which can be done using controlled variant of the gate in exactly the same way as distinguishing $Z$ gate from $-Z$ gate in the task 'Z or -Z'."
4116
+ },
4117
+ {
4118
+ "type": "solution",
4119
+ "id": "distinguishing_unitaries__rz_r1_solution",
4120
+ "code": "namespace Kata {\n open Microsoft.Quantum.Math; \n operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj+Ctl)) : Int {\n use qs = Qubit[2];\n H(qs[0]);\n Controlled unitary(qs[0..0], (2.0 * PI(), qs[1]));\n return MResetX(qs[0]) == Zero ? 1 | 0;\n }\n}\n"
4121
+ }
4122
+ ]
4123
+ }
4124
+ },
4125
+ {
4126
+ "type": "exercise",
4127
+ "id": "distinguishing_unitaries__y_xz",
4128
+ "title": "Y or XZ?",
4129
+ "description": {
4130
+ "type": "text-content",
4131
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the $Y$ gate or the sequence of Pauli $Z$ and Pauli $X$ gates (equivalent to applying the $Z$ gate followed by the $X$ gate).</p>\n<p><strong>Output:</strong> 0 if the given operation is the $Y$ gate, 1 if the given operation is the $XZ$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most <strong>twice</strong>.</p>\n",
4132
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the $Y$ gate or the sequence of Pauli $Z$ and Pauli $X$ gates (equivalent to applying the $Z$ gate followed by the $X$ gate).\n\n**Output:** 0 if the given operation is the $Y$ gate, 1 if the given operation is the $XZ$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most **twice**."
4133
+ },
4134
+ "sourceIds": [
4135
+ "distinguishing_unitaries__y_xz__Verification.qs",
4136
+ "KatasLibrary.qs",
4137
+ "distinguishing_unitaries__Common.qs"
4138
+ ],
4139
+ "placeholderCode": "namespace Kata {\n operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4140
+ "explainedSolution": {
4141
+ "type": "explained-solution",
4142
+ "items": [
4143
+ {
4144
+ "type": "text-content",
4145
+ "asHtml": "<blockquote>\n<p>As a reminder, $$Y = \\begin{bmatrix} 0 &amp; -i \\\\ i &amp; 0 \\end{bmatrix} = iXZ$$</p>\n</blockquote>\n<p>We see that these two gates differ by a global phase $i = e^{i\\pi}$. Applying the gates twice will give us gates $Y^2 = I$ and $(XZ)^2 = XZXZ = -XXZZ = -I$, respectively.</p>\n<p>Now we need to distinguish $I$ gate from $-I$ gate, which is the same thing we did in the previous task.</p>\n",
4146
+ "asMarkdown": "\n> As a reminder, $$Y = \\begin{bmatrix} 0 & -i \\\\ i & 0 \\end{bmatrix} = iXZ$$\n\nWe see that these two gates differ by a global phase $i = e^{i\\pi}$. Applying the gates twice will give us gates $Y^2 = I$ and $(XZ)^2 = XZXZ = -XXZZ = -I$, respectively.\n\nNow we need to distinguish $I$ gate from $-I$ gate, which is the same thing we did in the previous task."
4147
+ },
4148
+ {
4149
+ "type": "solution",
4150
+ "id": "distinguishing_unitaries__y_xz_solution",
4151
+ "code": "namespace Kata {\n operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n use qs = Qubit[2];\n H(qs[0]);\n Controlled unitary(qs[0..0], qs[1]);\n Controlled unitary(qs[0..0], qs[1]);\n return MResetX(qs[0]) == Zero ? 0 | 1;\n }\n}\n"
4152
+ }
4153
+ ]
4154
+ }
4155
+ },
4156
+ {
4157
+ "type": "exercise",
4158
+ "id": "distinguishing_unitaries__y_xz_minusy_minusxz",
4159
+ "title": "Y or XZ or -Y or -XZ?",
4160
+ "description": {
4161
+ "type": "text-content",
4162
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the $Y$ gate (possibly with an extra global phase of $-1$) or the sequence of Pauli $Z$ and Pauli $X$ gates (possibly with an extra global phase of $-1$).</p>\n<p><strong>Output:</strong></p>\n<ul>\n<li>0 if the given operation is the $Y$ gate,</li>\n<li>1 if the given operation is the $-XZ$ gate,</li>\n<li>2 if the given operation is the $-Y$ gate,</li>\n<li>3 if the given operation is the $XZ$ gate.</li>\n</ul>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most <strong>three times</strong>.</p>\n",
4163
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the $Y$ gate (possibly with an extra global phase of $-1$) or the sequence of Pauli $Z$ and Pauli $X$ gates (possibly with an extra global phase of $-1$).\n\n**Output:** \n* 0 if the given operation is the $Y$ gate,\n* 1 if the given operation is the $-XZ$ gate,\n* 2 if the given operation is the $-Y$ gate,\n* 3 if the given operation is the $XZ$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most **three times**."
4164
+ },
4165
+ "sourceIds": [
4166
+ "distinguishing_unitaries__y_xz_minusy_minusxz__Verification.qs",
4167
+ "KatasLibrary.qs",
4168
+ "distinguishing_unitaries__Common.qs"
4169
+ ],
4170
+ "placeholderCode": "namespace Kata {\n operation DistinguishYfromXZWithPhases (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4171
+ "explainedSolution": {
4172
+ "type": "explained-solution",
4173
+ "items": [
4174
+ {
4175
+ "type": "text-content",
4176
+ "asHtml": "<p>In this task we have to distinguish 4 gates that were identical up to a global phase, i.e., gates $Y$, $iY$, $-Y$ and $-iY$ (in that order).</p>\n<p>One way to do this is &quot;by hand&quot;, similar to the previous tasks. First we'll apply the controlled variant of the unitary twice and check whether the result is $I$ or $-I$ (which allows us to distinguish $\\pm Y$ and $\\pm iY$, since the first two gates squared will be equivalent to the $I$ gate, and the last two to the $-I$ gate). Then we distinguish the gates in each group ($Y$ from $-Y$ or $iY$ from $-iY$) by applying the controlled variant of the unitary once.</p>\n",
4177
+ "asMarkdown": "\nIn this task we have to distinguish 4 gates that were identical up to a global phase, i.e., gates $Y$, $iY$, $-Y$ and $-iY$ (in that order). \n\nOne way to do this is \"by hand\", similar to the previous tasks. First we'll apply the controlled variant of the unitary twice and check whether the result is $I$ or $-I$ (which allows us to distinguish $\\pm Y$ and $\\pm iY$, since the first two gates squared will be equivalent to the $I$ gate, and the last two to the $-I$ gate). Then we distinguish the gates in each group ($Y$ from $-Y$ or $iY$ from $-iY$) by applying the controlled variant of the unitary once."
4178
+ },
4179
+ {
4180
+ "type": "solution",
4181
+ "id": "distinguishing_unitaries__y_xz_minusy_minusxz_solution",
4182
+ "code": "namespace Kata {\n operation DistinguishYfromXZWithPhases (unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n use (control, target) = (Qubit(), Qubit());\n // Distinguish Y from iY\n within {\n H(control);\n } apply {\n Controlled unitary([control], target);\n Controlled unitary([control], target);\n }\n Reset(target);\n let isY = MResetZ(control) == Zero;\n\n // Distinguish Y from -Y and iY from -iY\n within {\n H(control);\n } apply {\n Controlled unitary([control], target);\n // apply controlled variant of the gate we're expecting to compensate effect on target qubit\n if isY {\n CY(control, target);\n } else {\n CZ(control, target);\n CX(control, target);\n }\n }\n let result = isY ? M(control) == Zero ? 0 | 2 \n | M(control) == Zero ? 1 | 3;\n Reset(control);\n return result;\n \n }\n}\n"
4183
+ }
4184
+ ]
4185
+ }
4186
+ },
4187
+ {
4188
+ "type": "exercise",
4189
+ "id": "distinguishing_unitaries__i_x_y_z",
4190
+ "title": "Distinguish Four Pauli Unitaries",
4191
+ "description": {
4192
+ "type": "text-content",
4193
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a single-qubit unitary transformation:\neither the identity ($I$ gate) or one of the Pauli gates ($X$, $Y$ or $Z$ gate).</p>\n<p><strong>Output:</strong></p>\n<ul>\n<li>0 if the given operation is the $I$ gate,</li>\n<li>1 if the given operation is the $X$ gate,</li>\n<li>2 if the given operation is the $Y$ gate,</li>\n<li>3 if the given operation is the $Z$ gate.</li>\n</ul>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4194
+ "asMarkdown": "**Input:** An operation that implements a single-qubit unitary transformation:\neither the identity ($I$ gate) or one of the Pauli gates ($X$, $Y$ or $Z$ gate).\n\n**Output:** \n* 0 if the given operation is the $I$ gate,\n* 1 if the given operation is the $X$ gate,\n* 2 if the given operation is the $Y$ gate,\n* 3 if the given operation is the $Z$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4195
+ },
4196
+ "sourceIds": [
4197
+ "distinguishing_unitaries__i_x_y_z__Verification.qs",
4198
+ "KatasLibrary.qs",
4199
+ "distinguishing_unitaries__Common.qs"
4200
+ ],
4201
+ "placeholderCode": "namespace Kata {\n operation DistinguishPaulis (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4202
+ "explainedSolution": {
4203
+ "type": "explained-solution",
4204
+ "items": [
4205
+ {
4206
+ "type": "text-content",
4207
+ "asHtml": "<p>This task is quite different from the previous tasks in this section;\nat the first glance it might seem impossible to distinguish four different unitaries (i.e., get two bits of information) with just one unitary application!</p>\n<p>However, since the unitaries were chosen carefully (and you're not limited in the number of measurements you can do), it is possible.\nThe solution uses the Bell states: the four orthogonal states which you can prepare by starting with the first of them $\\frac{1}{\\sqrt2}(\\ket{00} + \\ket{11})$ and applying the gates $I$, $X$, $Z$ and $Y$, respectively, to the first qubit.\nThus the solution becomes: prepare the $\\frac{1}{\\sqrt2}(\\ket{00} + \\ket{11})$ state, apply the unitary and measure the resulting state in Bell basis to figure out which of the Bell states it is. See the Distinguish Quantum States kata, task 'Distinguish Four Bell states' for the details on how to do that.</p>\n",
4208
+ "asMarkdown": "\nThis task is quite different from the previous tasks in this section; \nat the first glance it might seem impossible to distinguish four different unitaries (i.e., get two bits of information) with just one unitary application! \n\nHowever, since the unitaries were chosen carefully (and you're not limited in the number of measurements you can do), it is possible. \nThe solution uses the Bell states: the four orthogonal states which you can prepare by starting with the first of them $\\frac{1}{\\sqrt2}(\\ket{00} + \\ket{11})$ and applying the gates $I$, $X$, $Z$ and $Y$, respectively, to the first qubit. \nThus the solution becomes: prepare the $\\frac{1}{\\sqrt2}(\\ket{00} + \\ket{11})$ state, apply the unitary and measure the resulting state in Bell basis to figure out which of the Bell states it is. See the Distinguish Quantum States kata, task 'Distinguish Four Bell states' for the details on how to do that."
4209
+ },
4210
+ {
4211
+ "type": "solution",
4212
+ "id": "distinguishing_unitaries__i_x_y_z_solution",
4213
+ "code": "namespace Kata {\n operation DistinguishPaulis (unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // apply operation to the 1st qubit of a Bell state and measure in Bell basis\n use qs = Qubit[2];\n within {\n H(qs[0]);\n CNOT(qs[0], qs[1]);\n } apply {\n unitary(qs[0]);\n }\n\n // after this I -> 00, X -> 01, Y -> 11, Z -> 10\n let ind = MeasureInteger(qs);\n let returnValues = [0, 3, 1, 2];\n return returnValues[ind];\n }\n}\n"
4214
+ }
4215
+ ]
4216
+ }
4217
+ },
4218
+ {
4219
+ "type": "exercise",
4220
+ "id": "distinguishing_unitaries__rz_ry",
4221
+ "title": "Rz or Ry?",
4222
+ "description": {
4223
+ "type": "text-content",
4224
+ "asHtml": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>An angle $\\theta \\in [0.01 \\pi; 0.99 \\pi]$.</li>\n<li>An operation that implements a single-qubit unitary transformation:\neither the <a href=\"https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz\">$R_z(\\theta)$ gate</a> or the <a href=\"https://learn.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic/ry\">$R_y(\\theta)$ gate</a>.</li>\n</ol>\n<blockquote>\n<p>As a reminder,</p>\n<p>$$R_z(\\theta) = \\begin{bmatrix} e^{-i\\theta/2} &amp; 0 \\\\ 0 &amp; e^{i\\theta/2} \\end{bmatrix}$$\n$$R_y(\\theta) = \\begin{bmatrix} \\cos\\frac{\\theta}{2} &amp; -\\sin\\frac{\\theta}{2} \\\\ \\sin\\frac{\\theta}{2} &amp; \\cos\\frac{\\theta}{2} \\end{bmatrix}$$</p>\n</blockquote>\n<p><strong>Output:</strong> 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R_y$ gate.</p>\n<p>The operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants <strong>any number of times</strong>.</p>\n",
4225
+ "asMarkdown": "**Inputs:** \n\n1. An angle $\\theta \\in [0.01 \\pi; 0.99 \\pi]$.\n2. An operation that implements a single-qubit unitary transformation:\neither the [$R_z(\\theta)$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz) or the [$R_y(\\theta)$ gate](https://learn.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic/ry). \n\n> As a reminder,\n> \n> $$R_z(\\theta) = \\begin{bmatrix} e^{-i\\theta/2} & 0 \\\\ 0 & e^{i\\theta/2} \\end{bmatrix}$$\n> $$R_y(\\theta) = \\begin{bmatrix} \\cos\\frac{\\theta}{2} & -\\sin\\frac{\\theta}{2} \\\\ \\sin\\frac{\\theta}{2} & \\cos\\frac{\\theta}{2} \\end{bmatrix}$$\n\n**Output:** 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R_y$ gate.\n\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants **any number of times**."
4226
+ },
4227
+ "sourceIds": [
4228
+ "distinguishing_unitaries__rz_ry__Verification.qs",
4229
+ "KatasLibrary.qs",
4230
+ "distinguishing_unitaries__Common.qs"
4231
+ ],
4232
+ "placeholderCode": "namespace Kata {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Math;\n \n operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4233
+ "explainedSolution": {
4234
+ "type": "explained-solution",
4235
+ "items": [
4236
+ {
4237
+ "type": "text-content",
4238
+ "asHtml": "<p>The key observation here is that $R_z$ is a diagonal matrix and $R_y$ is not, so when applied to the $\\ket{0}$ state, the former will leave it unchanged (with an extra phase which is not observable), and the latter will convert it to a superposition $\\cos\\frac{\\theta}{2} \\ket{0} + \\sin\\frac{\\theta}{2} \\ket{1}$. The question is, how to distinguish those two states if they are not orthogonal (and for most values of $\\theta$ they will not be)?</p>\n<p>The task description gives you a big hint: it allows you to use the given unitary unlimited number of times, which points to a probabilistic solution (as opposed to deterministic solutions in all previous problems in this kata). Apply the unitary to the $\\ket{0}$ state and measure the result; if it is $\\ket{1}$, the unitary must be $R_y$, otherwise you can repeat the experiment again. After several iterations of measuring $\\ket{0}$ you can conclude that with high probability the unitary is $R_z$.</p>\n<p>To reduce the number of iterations after which you make the decision, you could apply the unitary several times to bring the overall rotation angle closer to $\\pi$: in case of $R_y$ gate this would allow you to rotate the state closer to the $\\ket{1}$ state, so that you'd detect it with higher probability.</p>\n",
4239
+ "asMarkdown": "\nThe key observation here is that $R_z$ is a diagonal matrix and $R_y$ is not, so when applied to the $\\ket{0}$ state, the former will leave it unchanged (with an extra phase which is not observable), and the latter will convert it to a superposition $\\cos\\frac{\\theta}{2} \\ket{0} + \\sin\\frac{\\theta}{2} \\ket{1}$. The question is, how to distinguish those two states if they are not orthogonal (and for most values of $\\theta$ they will not be)?\n\nThe task description gives you a big hint: it allows you to use the given unitary unlimited number of times, which points to a probabilistic solution (as opposed to deterministic solutions in all previous problems in this kata). Apply the unitary to the $\\ket{0}$ state and measure the result; if it is $\\ket{1}$, the unitary must be $R_y$, otherwise you can repeat the experiment again. After several iterations of measuring $\\ket{0}$ you can conclude that with high probability the unitary is $R_z$.\n\nTo reduce the number of iterations after which you make the decision, you could apply the unitary several times to bring the overall rotation angle closer to $\\pi$: in case of $R_y$ gate this would allow you to rotate the state closer to the $\\ket{1}$ state, so that you'd detect it with higher probability."
4240
+ },
4241
+ {
4242
+ "type": "solution",
4243
+ "id": "distinguishing_unitaries__rz_ry_solution",
4244
+ "code": "namespace Kata {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Math;\n\n function ComputeRepetitions(angle : Double, offset : Int, accuracy : Double) : Int {\n mutable pifactor = 0;\n while (true) {\n let pimultiple = PI() * IntAsDouble(2 * pifactor + offset);\n let times = Round(pimultiple / angle);\n if AbsD(pimultiple - (IntAsDouble(times) * angle)) / PI() < accuracy {\n return times;\n }\n set pifactor += 1;\n }\n return 0;\n }\n\n operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {\n use q = Qubit();\n let times = ComputeRepetitions(theta, 1, 0.1);\n mutable attempt = 1;\n mutable measuredOne = false;\n repeat {\n for _ in 1 .. times {\n unitary(q);\n }\n // for Rz, we'll never venture away from |0⟩ state, so as soon as we got |1⟩ we know it's not Rz\n if MResetZ(q) == One {\n set measuredOne = true;\n }\n // if we try several times and still only get |0⟩s, chances are that it is Rz\n } until (attempt == 4 or measuredOne) \n fixup {\n set attempt += 1;\n }\n return measuredOne ? 1 | 0;\n }\n}\n"
4245
+ }
4246
+ ]
4247
+ }
4248
+ },
4249
+ {
4250
+ "type": "lesson",
4251
+ "id": "distinguishing_unitaries__multi_qubit",
4252
+ "title": "Distinguishing Multi-Qubit Gates",
4253
+ "items": []
4254
+ },
4255
+ {
4256
+ "type": "exercise",
4257
+ "id": "distinguishing_unitaries__ix_cnot",
4258
+ "title": "I⊗X or CNOT?",
4259
+ "description": {
4260
+ "type": "text-content",
4261
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a two-qubit unitary transformation:\neither the $I \\otimes X$ (the $X$ gate applied to the second qubit) or the $CNOT$ gate with the first qubit as control and the second qubit as target.</p>\n<p><strong>Output:</strong> 0 if the given operation is $I \\otimes X$, 1 if the given operation is the $CNOT$ gate.</p>\n<p>The operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4262
+ "asMarkdown": "**Input:** An operation that implements a two-qubit unitary transformation:\neither the $I \\otimes X$ (the $X$ gate applied to the second qubit) or the $CNOT$ gate with the first qubit as control and the second qubit as target.\n\n**Output:** 0 if the given operation is $I \\otimes X$, 1 if the given operation is the $CNOT$ gate.\n\nThe operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4263
+ },
4264
+ "sourceIds": [
4265
+ "distinguishing_unitaries__ix_cnot__Verification.qs",
4266
+ "KatasLibrary.qs",
4267
+ "distinguishing_unitaries__Common.qs"
4268
+ ],
4269
+ "placeholderCode": "namespace Kata {\n operation DistinguishIXfromCNOT (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4270
+ "explainedSolution": {
4271
+ "type": "explained-solution",
4272
+ "items": [
4273
+ {
4274
+ "type": "text-content",
4275
+ "asHtml": "<p>Let's consider the effect of these gates on the basis states:</p>\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$I \\otimes X$</th>\n <th style=\"text-align:center\">$CNOT$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n</table>\n<p>We can see that applying these two gates to states with the first qubit in the $\\ket{1}$ state yields identical results, but applying them to states with the first qubit in the $\\ket{0}$ state produces states that differ in the second qubuit.\nThis makes sense, since the $CNOT$ gate is defined as &quot;apply $X$ gate to the target qubit if the control qubit is in the $\\ket{1}$ state, and do nothing if it is in the $\\ket{0}$ state&quot;.</p>\n<p>Thus, the easiest solution is: allocate two qubits in the $\\ket{00}$ state and apply the unitary to them, then measure the second qubit; if it is <code>One</code>, the gate is $I \\otimes X$, otherwise it's $CNOT$.</p>\n",
4276
+ "asMarkdown": "\nLet's consider the effect of these gates on the basis states:\n\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$I \\otimes X$</th>\n <th style=\"text-align:center\">$CNOT$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n</table>\n\nWe can see that applying these two gates to states with the first qubit in the $\\ket{1}$ state yields identical results, but applying them to states with the first qubit in the $\\ket{0}$ state produces states that differ in the second qubuit.\nThis makes sense, since the $CNOT$ gate is defined as \"apply $X$ gate to the target qubit if the control qubit is in the $\\ket{1}$ state, and do nothing if it is in the $\\ket{0}$ state\".\n\nThus, the easiest solution is: allocate two qubits in the $\\ket{00}$ state and apply the unitary to them, then measure the second qubit; if it is `One`, the gate is $I \\otimes X$, otherwise it's $CNOT$."
4277
+ },
4278
+ {
4279
+ "type": "solution",
4280
+ "id": "distinguishing_unitaries__ix_cnot_solution",
4281
+ "code": "namespace Kata {\n operation DistinguishIXfromCNOT (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n use qs = Qubit[2];\n unitary(qs);\n return MResetZ(qs[1]) == One ? 0 | 1;\n }\n}\n"
4282
+ }
4283
+ ]
4284
+ }
4285
+ },
4286
+ {
4287
+ "type": "exercise",
4288
+ "id": "distinguishing_unitaries__cnot_direction",
4289
+ "title": "CNOT Direction",
4290
+ "description": {
4291
+ "type": "text-content",
4292
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a two-qubit unitary transformation:\neither the $CNOT$ gate with the first qubit as control and the second qubit as target ($CNOT_{12}$)\nor the $CNOT$ gate with the second qubit as control and the first qubit as target ($CNOT_{21}$).</p>\n<p><strong>Output:</strong> 0 if the given operation is $CNOT_{12}$, 1 if the given operation is $CNOT_{21}$.</p>\n<p>The operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4293
+ "asMarkdown": "**Input:** An operation that implements a two-qubit unitary transformation:\neither the $CNOT$ gate with the first qubit as control and the second qubit as target ($CNOT_{12}$)\nor the $CNOT$ gate with the second qubit as control and the first qubit as target ($CNOT_{21}$).\n\n**Output:** 0 if the given operation is $CNOT_{12}$, 1 if the given operation is $CNOT_{21}$.\n\nThe operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4294
+ },
4295
+ "sourceIds": [
4296
+ "distinguishing_unitaries__cnot_direction__Verification.qs",
4297
+ "KatasLibrary.qs",
4298
+ "distinguishing_unitaries__Common.qs"
4299
+ ],
4300
+ "placeholderCode": "namespace Kata {\n operation CNOTDirection (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4301
+ "explainedSolution": {
4302
+ "type": "explained-solution",
4303
+ "items": [
4304
+ {
4305
+ "type": "text-content",
4306
+ "asHtml": "<p>Again, let's consider the effect of these gates on the basis states:</p>\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$CNOT_{12}$</th>\n <th style=\"text-align:center\">$CNOT_{21}$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n</table>\n<p>We can see that applying these two gates to any basis state other than $\\ket{00}$ yields different results, and we can use any of these states to distinguish the unitaries.</p>\n<p>Thus, the easiest solution is: prepare two qubits in the $\\ket{01}$ state and apply the unitary to them, then measure the first qubit; if it is still <code>Zero</code>, the gate is $CNOT_{12}$, otherwise it's $CNOT_{21}$.</p>\n",
4307
+ "asMarkdown": "\nAgain, let's consider the effect of these gates on the basis states:\n\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$CNOT_{12}$</th>\n <th style=\"text-align:center\">$CNOT_{21}$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n</table>\n\nWe can see that applying these two gates to any basis state other than $\\ket{00}$ yields different results, and we can use any of these states to distinguish the unitaries.\n\nThus, the easiest solution is: prepare two qubits in the $\\ket{01}$ state and apply the unitary to them, then measure the first qubit; if it is still `Zero`, the gate is $CNOT_{12}$, otherwise it's $CNOT_{21}$."
4308
+ },
4309
+ {
4310
+ "type": "solution",
4311
+ "id": "distinguishing_unitaries__cnot_direction_solution",
4312
+ "code": "namespace Kata {\n operation CNOTDirection (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n use qs = Qubit[2];\n within { X(qs[1]); }\n apply { unitary(qs); }\n return MResetZ(qs[0]) == Zero ? 0 | 1;\n }\n}\n"
4313
+ }
4314
+ ]
4315
+ }
4316
+ },
4317
+ {
4318
+ "type": "exercise",
4319
+ "id": "distinguishing_unitaries__cnot_swap",
4320
+ "title": "CNOT or SWAP?",
4321
+ "description": {
4322
+ "type": "text-content",
4323
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a two-qubit unitary transformation:\neither the $CNOT$ gate with the first qubit as control and the second qubit as target ($CNOT_{12}$)\nor the $SWAP$ gate.</p>\n<p><strong>Output:</strong> 0 if the given operation is $CNOT_{12}$, 1 if the given operation is $SWAP$.</p>\n<p>The operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly <strong>once</strong>.</p>\n",
4324
+ "asMarkdown": "**Input:** An operation that implements a two-qubit unitary transformation:\neither the $CNOT$ gate with the first qubit as control and the second qubit as target ($CNOT_{12}$)\nor the $SWAP$ gate.\n\n**Output:** 0 if the given operation is $CNOT_{12}$, 1 if the given operation is $SWAP$.\n\nThe operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants exactly **once**."
4325
+ },
4326
+ "sourceIds": [
4327
+ "distinguishing_unitaries__cnot_swap__Verification.qs",
4328
+ "KatasLibrary.qs",
4329
+ "distinguishing_unitaries__Common.qs"
4330
+ ],
4331
+ "placeholderCode": "namespace Kata {\n operation DistinguishCNOTfromSWAP (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4332
+ "explainedSolution": {
4333
+ "type": "explained-solution",
4334
+ "items": [
4335
+ {
4336
+ "type": "text-content",
4337
+ "asHtml": "<p>Again, let's consider the effect of these gates on the basis states:</p>\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$CNOT_{12}$</th>\n <th style=\"text-align:center\">$SWAP$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n</table>\n<p>Same as in the previous task, applying these two gates to any basis state other than $\\ket{00}$ yields different results, and we can use any of these states to distinguish the unitaries.</p>\n<p>The easiest solution is: prepare two qubits in the $\\ket{01}$ state and apply the unitary to them, then measure the first qubit; if it is still <code>Zero</code>, the gate is $CNOT_{12}$, otherwise it's $SWAP$. Remember that this time the second qubit might end up in $\\ket{1}$ state, so it needs to be reset to $\\ket{0}$ before releasing it.</p>\n",
4338
+ "asMarkdown": "\nAgain, let's consider the effect of these gates on the basis states:\n\n<table>\n <tr>\n <th style=\"text-align:center\">State</th>\n <th style=\"text-align:center\">$CNOT_{12}$</th>\n <th style=\"text-align:center\">$SWAP$</th> \n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n <td style=\"text-align:center\">$\\ket{00}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{01}$</td>\n </tr>\n <tr>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n <td style=\"text-align:center\">$\\ket{10}$</td>\n <td style=\"text-align:center\">$\\ket{11}$</td>\n </tr>\n</table>\n\nSame as in the previous task, applying these two gates to any basis state other than $\\ket{00}$ yields different results, and we can use any of these states to distinguish the unitaries.\n\nThe easiest solution is: prepare two qubits in the $\\ket{01}$ state and apply the unitary to them, then measure the first qubit; if it is still `Zero`, the gate is $CNOT_{12}$, otherwise it's $SWAP$. Remember that this time the second qubit might end up in $\\ket{1}$ state, so it needs to be reset to $\\ket{0}$ before releasing it."
4339
+ },
4340
+ {
4341
+ "type": "solution",
4342
+ "id": "distinguishing_unitaries__cnot_swap_solution",
4343
+ "code": "namespace Kata {\n operation DistinguishCNOTfromSWAP (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n use qs = Qubit[2];\n X(qs[1]);\n unitary(qs);\n Reset(qs[1]);\n return MResetZ(qs[0]) == Zero ? 0 | 1;\n }\n}\n"
4344
+ }
4345
+ ]
4346
+ }
4347
+ },
4348
+ {
4349
+ "type": "exercise",
4350
+ "id": "distinguishing_unitaries__i_cnot_swap",
4351
+ "title": "Distinguish Two-Qubit Unitaries",
4352
+ "description": {
4353
+ "type": "text-content",
4354
+ "asHtml": "<p><strong>Input:</strong> An operation that implements a two-qubit unitary transformation:\neither the identity ($I \\otimes I$), the $CNOT$ gate with one of the qubits as control and the other qubit as a target, or the $SWAP$ gate.</p>\n<p><strong>Output:</strong></p>\n<ul>\n<li>0 if the given operation is $I \\otimes I$,</li>\n<li>1 if the given operation is $CNOT_{12}$,</li>\n<li>2 if the given operation is $CNOT_{21}$,</li>\n<li>3 if the given operation is $SWAP$.</li>\n</ul>\n<p>The operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most <strong>twice</strong>.</p>\n",
4355
+ "asMarkdown": "**Input:** An operation that implements a two-qubit unitary transformation:\neither the identity ($I \\otimes I$), the $CNOT$ gate with one of the qubits as control and the other qubit as a target, or the $SWAP$ gate.\n\n**Output:** \n\n* 0 if the given operation is $I \\otimes I$, \n* 1 if the given operation is $CNOT_{12}$,\n* 2 if the given operation is $CNOT_{21}$,\n* 3 if the given operation is $SWAP$.\n\nThe operation will accept an array of qubits as input, but it will fail if the array is empty or has one or more than two qubits.\nThe operation will have Adjoint and Controlled variants defined.\nYou are allowed to apply the given operation and its adjoint/controlled variants at most **twice**."
4356
+ },
4357
+ "sourceIds": [
4358
+ "distinguishing_unitaries__i_cnot_swap__Verification.qs",
4359
+ "KatasLibrary.qs",
4360
+ "distinguishing_unitaries__Common.qs"
4361
+ ],
4362
+ "placeholderCode": "namespace Kata {\n operation DistinguishTwoQubitUnitaries (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n // Implement your solution here...\n\n return -1;\n }\n}\n",
4363
+ "explainedSolution": {
4364
+ "type": "explained-solution",
4365
+ "items": [
4366
+ {
4367
+ "type": "text-content",
4368
+ "asHtml": "<p>In this problem we are allowed to use the given unitary twice, so we can split our decision-making process in two phases:</p>\n<ol>\n<li>Apply the unitary to the $\\ket{11}$ state; $CNOT_{12}$ will yield the $\\ket{10}$ state, $CNOT_{21}$ — $\\ket{01}$, and both $I \\otimes I$ and $SWAP$ gates will leave the state unchanged.</li>\n<li>Now to distinguish $I \\otimes I$ from $SWAP$, we can use the $\\ket{01}$ state: $I \\otimes I$ gate will leave it unchanged, while $SWAP$ will yield $\\ket{10}$.</li>\n</ol>\n<p>Library operation <code>MeasureInteger</code> measures all qubits of the array, resets them to $\\ket{0}$, and returns the measurement results, using little-endian to convert the bit array to an integer.</p>\n",
4369
+ "asMarkdown": "\nIn this problem we are allowed to use the given unitary twice, so we can split our decision-making process in two phases:\n\n1. Apply the unitary to the $\\ket{11}$ state; $CNOT_{12}$ will yield the $\\ket{10}$ state, $CNOT_{21}$ &mdash; $\\ket{01}$, and both $I \\otimes I$ and $SWAP$ gates will leave the state unchanged.\n2. Now to distinguish $I \\otimes I$ from $SWAP$, we can use the $\\ket{01}$ state: $I \\otimes I$ gate will leave it unchanged, while $SWAP$ will yield $\\ket{10}$.\n\nLibrary operation `MeasureInteger` measures all qubits of the array, resets them to $\\ket{0}$, and returns the measurement results, using little-endian to convert the bit array to an integer."
4370
+ },
4371
+ {
4372
+ "type": "solution",
4373
+ "id": "distinguishing_unitaries__i_cnot_swap_solution",
4374
+ "code": "namespace Kata {\n operation DistinguishTwoQubitUnitaries (unitary : (Qubit[] => Unit is Adj + Ctl)) : Int {\n // First run: apply to |11⟩;\n // CNOT₁₂ will give |10⟩, CNOT₂₁ will give |01⟩, I⊗I and SWAP will remain |11⟩\n use qs = Qubit[2];\n ApplyToEach(X, qs);\n unitary(qs);\n let ind1 = MeasureInteger(qs);\n\n // Second run: to distinguish I⊗I from SWAP, apply to |01⟩: \n // I⊗I will remain |01⟩, SWAP will become |10⟩\n X(qs[1]);\n unitary(qs);\n let ind2 = MeasureInteger(qs);\n\n if ind1 == 1 or ind1 == 2 {\n // Respective CNOT\n return ind1;\n } else {\n return ind2 == 1 ? 3 | 0;\n }\n }\n}\n"
4375
+ }
4376
+ ]
4377
+ }
4378
+ },
4379
+ {
4380
+ "type": "lesson",
4381
+ "id": "distinguishing_unitaries__conclusion",
4382
+ "title": "Conclusion",
4383
+ "items": [
4384
+ {
4385
+ "type": "text-content",
4386
+ "asHtml": "<p>Congratulations! In this kata you learned to use measurements and basic quantum computing gates to identify unknown unitaries.</p>\n",
4387
+ "asMarkdown": "\nCongratulations! In this kata you learned to use measurements and basic quantum computing gates to identify unknown unitaries."
4388
+ }
4389
+ ]
4390
+ }
4391
+ ],
4392
+ "published": true
3906
4393
  },
3907
4394
  {
3908
4395
  "id": "random_numbers",
@@ -4099,7 +4586,8 @@ export default {
4099
4586
  }
4100
4587
  ]
4101
4588
  }
4102
- ]
4589
+ ],
4590
+ "published": true
4103
4591
  },
4104
4592
  {
4105
4593
  "id": "superdense_coding",
@@ -4250,7 +4738,8 @@ export default {
4250
4738
  }
4251
4739
  ]
4252
4740
  }
4253
- ]
4741
+ ],
4742
+ "published": true
4254
4743
  },
4255
4744
  {
4256
4745
  "id": "oracles",
@@ -4755,7 +5244,8 @@ export default {
4755
5244
  }
4756
5245
  ]
4757
5246
  }
4758
- ]
5247
+ ],
5248
+ "published": true
4759
5249
  },
4760
5250
  {
4761
5251
  "id": "deutsch_algo",
@@ -4903,7 +5393,8 @@ export default {
4903
5393
  }
4904
5394
  ]
4905
5395
  }
4906
- ]
5396
+ ],
5397
+ "published": true
4907
5398
  },
4908
5399
  {
4909
5400
  "id": "deutsch_jozsa",
@@ -5123,7 +5614,8 @@ export default {
5123
5614
  }
5124
5615
  ]
5125
5616
  }
5126
- ]
5617
+ ],
5618
+ "published": true
5127
5619
  },
5128
5620
  {
5129
5621
  "id": "qec_shor",
@@ -5472,7 +5964,307 @@ export default {
5472
5964
  }
5473
5965
  ]
5474
5966
  }
5475
- ]
5967
+ ],
5968
+ "published": true
5969
+ },
5970
+ {
5971
+ "id": "distinguishing_states",
5972
+ "title": "Distinguishing Quantum States",
5973
+ "sections": [
5974
+ {
5975
+ "type": "lesson",
5976
+ "id": "distinguishing_states__overview",
5977
+ "title": "Overview",
5978
+ "items": [
5979
+ {
5980
+ "type": "text-content",
5981
+ "asHtml": "<p>This kata is designed to get you familiar with the concept of measurements and using them for analyzing quantum states and with Q# programming.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>single-qubit measurements,</li>\n<li>distinguishing orthogonal and non-orthogonal states.</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Dirac notation for single-qubit and multi-qubit quantum systems</li>\n<li>Basic single-qubit and multi-qubit gates</li>\n<li>Single-qubit quantum measurements and their effect on quantum systems</li>\n</ul>\n",
5982
+ "asMarkdown": "\nThis kata is designed to get you familiar with the concept of measurements and using them for analyzing quantum states and with Q# programming.\n\n**This kata covers the following topics:**\n\n- single-qubit measurements,\n- distinguishing orthogonal and non-orthogonal states.\n\n**What you should know to start working on this kata:**\n\n- Dirac notation for single-qubit and multi-qubit quantum systems\n- Basic single-qubit and multi-qubit gates\n- Single-qubit quantum measurements and their effect on quantum systems"
5983
+ }
5984
+ ]
5985
+ },
5986
+ {
5987
+ "type": "lesson",
5988
+ "id": "distinguishing_states__orthogonal_states",
5989
+ "title": "Distinguishing Orthogonal States",
5990
+ "items": []
5991
+ },
5992
+ {
5993
+ "type": "exercise",
5994
+ "id": "distinguishing_states__zero_one",
5995
+ "title": "|0〉 or |1〉?",
5996
+ "description": {
5997
+ "type": "text-content",
5998
+ "asHtml": "<p><strong>Input:</strong> A qubit which is guaranteed to be in either the $\\ket{0}$ or the $\\ket{1}$ state.</p>\n<p><strong>Output:</strong> <code>true</code> if the qubit was in the $\\ket{1}$ state, or <code>false</code> if it was in the $\\ket{0}$ state. The state of the qubit at the end of the operation does not matter.</p>\n",
5999
+ "asMarkdown": "**Input:** A qubit which is guaranteed to be in either the $\\ket{0}$ or the $\\ket{1}$ state.\n\n**Output:** `true` if the qubit was in the $\\ket{1}$ state, or `false` if it was in the $\\ket{0}$ state. The state of the qubit at the end of the operation does not matter.\n"
6000
+ },
6001
+ "sourceIds": [
6002
+ "distinguishing_states__zero_one__Verification.qs",
6003
+ "KatasLibrary.qs"
6004
+ ],
6005
+ "placeholderCode": "namespace Kata {\n operation IsQubitOne (q : Qubit) : Bool {\n // Implement your solution here...\n\n return false;\n }\n}\n",
6006
+ "explainedSolution": {
6007
+ "type": "explained-solution",
6008
+ "items": [
6009
+ {
6010
+ "type": "text-content",
6011
+ "asHtml": "<p>The input qubit is guaranteed to be either in basis state $\\ket{0}$ or $\\ket{1}$. This means that when measuring the qubit in the computational basis, the measurement will report the input state without any doubt.</p>\n<p>In Q# the operation <code>M</code> can be used to measure a single qubit in the computational basis. The measurement result is a value of type <code>Result</code> - the operation <code>M</code> will return <code>One</code> if the input qubit was in the $\\ket{1}$ state and <code>Zero</code> if the input qubit was in the $\\ket{0}$ state. Since we need to encode the first case as <code>true</code> and the second one as <code>false</code>, we can return the result of equality comparison between measurement result and <code>One</code>.</p>\n",
6012
+ "asMarkdown": "\nThe input qubit is guaranteed to be either in basis state $\\ket{0}$ or $\\ket{1}$. This means that when measuring the qubit in the computational basis, the measurement will report the input state without any doubt.\n\nIn Q# the operation `M` can be used to measure a single qubit in the computational basis. The measurement result is a value of type `Result` - the operation `M` will return `One` if the input qubit was in the $\\ket{1}$ state and `Zero` if the input qubit was in the $\\ket{0}$ state. Since we need to encode the first case as `true` and the second one as `false`, we can return the result of equality comparison between measurement result and `One`."
6013
+ },
6014
+ {
6015
+ "type": "solution",
6016
+ "id": "distinguishing_states__zero_one_solution",
6017
+ "code": "namespace Kata {\n operation IsQubitOne (q : Qubit) : Bool {\n return M(q) == One;\n }\n}\n"
6018
+ }
6019
+ ]
6020
+ }
6021
+ },
6022
+ {
6023
+ "type": "exercise",
6024
+ "id": "distinguishing_states__plus_minus",
6025
+ "title": "|+〉 or |-〉?",
6026
+ "description": {
6027
+ "type": "text-content",
6028
+ "asHtml": "<p><strong>Input:</strong> A qubit which is guaranteed to be in either the $\\ket{+}$ or the $\\ket{-}$ state.</p>\n<p><strong>Output:</strong> <code>true</code> if the qubit was in the $\\ket{+}$ state, or <code>false</code> if it was in the $\\ket{-}$ state. The state of the qubit at the end of the operation does not matter.</p>\n",
6029
+ "asMarkdown": "**Input:** A qubit which is guaranteed to be in either the $\\ket{+}$ or the $\\ket{-}$ state.\n\n**Output:** `true` if the qubit was in the $\\ket{+}$ state, or `false` if it was in the $\\ket{-}$ state. The state of the qubit at the end of the operation does not matter.\n"
6030
+ },
6031
+ "sourceIds": [
6032
+ "distinguishing_states__plus_minus__Verification.qs",
6033
+ "KatasLibrary.qs"
6034
+ ],
6035
+ "placeholderCode": "namespace Kata {\n operation IsQubitPlus(q : Qubit) : Bool {\n // Implement your solution here...\n\n return false;\n }\n}\n",
6036
+ "explainedSolution": {
6037
+ "type": "explained-solution",
6038
+ "items": [
6039
+ {
6040
+ "type": "text-content",
6041
+ "asHtml": "<p>Both input states are superposition states, with equal absolute values of amplitudes of both basis states. This means if the sate is measured in the Pauli $Z$ basis, there is a 50-50 chance of measuring <code>One</code> or <code>Zero</code>, which won't give us the necessary information.</p>\n<p>To determine in which state the input qubit is with certainty, we want to transform the qubit into a state where there is no superposition with respect to the basis in which we perform the measurement.</p>\n<p>Consider how we can prepare the input states, starting with basis states: $H\\ket{0} = \\ket{+}$ and $H\\ket{1} = \\ket{-}$. This transformation can also be undone by applying the $H$ gate again (remember that the $H$ gate is self-adjoint, i.e., it equals its own inverse): $H\\ket{+} = \\ket{0}$ and $H\\ket{-} = \\ket{1}$.</p>\n<p>Once we have the $\\ket{0}$ or $\\ket{1}$ state, we can use the same principle as in previous task $\\ket{0}$ or $\\ket{1}$ to measure the state and report the outcome. Note that in this task return value <code>true</code> corresponds to input state $\\ket{+}$, so we compare the measurement result with <code>Zero</code>.</p>\n",
6042
+ "asMarkdown": "\nBoth input states are superposition states, with equal absolute values of amplitudes of both basis states. This means if the sate is measured in the Pauli $Z$ basis, there is a 50-50 chance of measuring `One` or `Zero`, which won't give us the necessary information.\n\nTo determine in which state the input qubit is with certainty, we want to transform the qubit into a state where there is no superposition with respect to the basis in which we perform the measurement.\n\nConsider how we can prepare the input states, starting with basis states: $H\\ket{0} = \\ket{+}$ and $H\\ket{1} = \\ket{-}$. This transformation can also be undone by applying the $H$ gate again (remember that the $H$ gate is self-adjoint, i.e., it equals its own inverse): $H\\ket{+} = \\ket{0}$ and $H\\ket{-} = \\ket{1}$.\n\nOnce we have the $\\ket{0}$ or $\\ket{1}$ state, we can use the same principle as in previous task $\\ket{0}$ or $\\ket{1}$ to measure the state and report the outcome. Note that in this task return value `true` corresponds to input state $\\ket{+}$, so we compare the measurement result with `Zero`."
6043
+ },
6044
+ {
6045
+ "type": "solution",
6046
+ "id": "distinguishing_states__plus_minus_solution_a",
6047
+ "code": "namespace Kata {\n operation IsQubitPlus(q : Qubit) : Bool {\n H(q);\n return M(q) == Zero;\n }\n}\n"
6048
+ },
6049
+ {
6050
+ "type": "text-content",
6051
+ "asHtml": "<h4>Alternative solution</h4>\n<p>Another possible solution could be to measure in the Pauli $X$ basis ($\\ket{+}, \\ket{-}$ basis), this means a transformation with the $H$ gate before measurement is not needed. Again, measurement result <code>Zero</code> would correspond to state $\\ket{+}$.</p>\n<p>In Q#, measuring in another Pauli basis can be done with the <code>Measure()</code> operation.</p>\n",
6052
+ "asMarkdown": "\n#### Alternative solution\n\nAnother possible solution could be to measure in the Pauli $X$ basis ($\\ket{+}, \\ket{-}$ basis), this means a transformation with the $H$ gate before measurement is not needed. Again, measurement result `Zero` would correspond to state $\\ket{+}$.\n\nIn Q#, measuring in another Pauli basis can be done with the `Measure()` operation."
6053
+ },
6054
+ {
6055
+ "type": "solution",
6056
+ "id": "distinguishing_states__plus_minus_solution_b",
6057
+ "code": "namespace Kata {\n operation IsQubitPlus(q : Qubit) : Bool {\n return Measure([PauliX], [q]) == Zero;\n }\n}\n"
6058
+ }
6059
+ ]
6060
+ }
6061
+ },
6062
+ {
6063
+ "type": "lesson",
6064
+ "id": "distinguishing_states__nonorthogonal_states",
6065
+ "title": "Distinguishing Non-orthogonal States",
6066
+ "items": []
6067
+ },
6068
+ {
6069
+ "type": "exercise",
6070
+ "id": "distinguishing_states__zero_plus",
6071
+ "title": "|0〉 or |+〉?",
6072
+ "description": {
6073
+ "type": "text-content",
6074
+ "asHtml": "<p><strong>Input:</strong> A qubit which is guaranteed to be in either the $\\ket{0}$ or the $\\ket{+}$ state.</p>\n<p><strong>Output:</strong> <code>true</code> if the qubit was in the $\\ket{0}$ state, or <code>false</code> if it was in the $\\ket{+}$ state. The state of the qubit at the end of the operation does not matter.</p>\n<p>In this task your solution will be called multiple times, with one of the states picked with equal probability every time. You have to get overall accuracy of at least 80%.</p>\n<blockquote>\n<p>This task is an example of quantum hypothesis testing, or state discrimination with minimum error.</p>\n</blockquote>\n",
6075
+ "asMarkdown": "**Input:** A qubit which is guaranteed to be in either the $\\ket{0}$ or the $\\ket{+}$ state.\n \n**Output:** `true` if the qubit was in the $\\ket{0}$ state, or `false` if it was in the $\\ket{+}$ state. The state of the qubit at the end of the operation does not matter.\n\nIn this task your solution will be called multiple times, with one of the states picked with equal probability every time. You have to get overall accuracy of at least 80%.\n\n> This task is an example of quantum hypothesis testing, or state discrimination with minimum error.\n"
6076
+ },
6077
+ "sourceIds": [
6078
+ "distinguishing_states__zero_plus__Verification.qs",
6079
+ "KatasLibrary.qs",
6080
+ "distinguishing_states__Common.qs"
6081
+ ],
6082
+ "placeholderCode": "namespace Kata {\n operation IsQubitZeroOrPlus (q : Qubit) : Bool {\n // Implement your solution here...\n return true;\n }\n}\n",
6083
+ "explainedSolution": {
6084
+ "type": "explained-solution",
6085
+ "items": [
6086
+ {
6087
+ "type": "text-content",
6088
+ "asHtml": "<p>Let ${\\ket{E_a}, \\ket{E_b}}$ be a measurement with two outcomes $a$ and $b$, which we identify with the answers, i.e., outcome &quot;a&quot; means we answer &quot;state was $\\ket{0}$&quot; and outcome &quot;b&quot; means we answer &quot;state was $\\ket{+}$&quot;. Then we define</p>\n<ul>\n<li>$P(a|0)$ = probability to observe first outcome given that the state was $\\ket{0}$</li>\n<li>$P(b|0)$ = probability to observe second outcome given that the state was $\\ket{0}$</li>\n<li>$P(a|+)$ = probability to observe first outcome given that the state was $\\ket{+}$</li>\n<li>$P(b|+)$ = probability to observe second outcome given that the state was $\\ket{+}$</li>\n</ul>\n<p>The task is to maximize the probability to be correct on a single shot experiment, which is the same as to minimize the probability to be wrong on a single shot.</p>\n<p>Since the task promises uniform prior distribution of the inputs $\\ket{0}$ and $\\ket{+}$, i.e., $P(+) = P(0) = \\frac{1}{2}$, we get the following expression for the probability of giving a correct answer:</p>\n<p>$$P_{correct} = P(0) P(a|0) + P(+) P(b|+) = \\frac{1}{2} (P(a|0) + P(b|+))$$</p>\n<p>We can represent our measurement as a von Neumann measurement of the following form:</p>\n<p>$$\\ket{E_a} = R_y(2\\alpha) \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} = \\begin{bmatrix} \\cos \\alpha \\\\ \\sin \\alpha \\end{bmatrix}$$\n$$\\ket{E_b} = R_y(2\\alpha) \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} = \\begin{bmatrix} - \\sin \\alpha \\\\ \\cos \\alpha \\end{bmatrix}$$</p>\n<p>Using this representation, we can express our probabilities as follows:</p>\n<p>$$P(a|0) = |\\braket{E_a|0}|^2 = \\cos^2 \\alpha$$</p>\n<p>$$P(b|+) = |\\braket{E_b|+}|^2 = \\frac{1}{2} - \\cos \\alpha \\sin \\alpha$$</p>\n<p>$$P_{correct} = \\frac{1}{2} (\\cos^2 \\alpha + \\frac{1}{2} - \\cos \\alpha \\sin \\alpha)$$</p>\n<p>Maximizing this for $\\alpha$, we get max $P_{success} = \\frac{1}{2} (1 + \\frac{1}{\\sqrt{2}}) = 0.8535...$, which is attained for $\\alpha = -\\pi/8$.</p>\n<p>This means that $\\ket{E_a}$ and $\\ket{E_b}$ are the result of rotating $\\ket{0}$ and $\\ket{1}$, respectively, by $-\\pi/8$. If we rotate the whole system by $-\\alpha = \\pi/8$, we will get $\\ket{E_a}=\\ket{0}$ and $\\ket{E_b}=\\ket{1}$, and a measurement in the computational basis will give us the correct result with a probability of 85%.</p>\n<blockquote>\n<p>In Q#, rotating the input state by some angle $\\theta$ can be done by applying $Ry$ gate with angle parameter $2\\theta$.</p>\n</blockquote>\n",
6089
+ "asMarkdown": "\nLet ${\\ket{E_a}, \\ket{E_b}}$ be a measurement with two outcomes $a$ and $b$, which we identify with the answers, i.e., outcome \"a\" means we answer \"state was $\\ket{0}$\" and outcome \"b\" means we answer \"state was $\\ket{+}$\". Then we define\n\n* $P(a|0)$ = probability to observe first outcome given that the state was $\\ket{0}$\n* $P(b|0)$ = probability to observe second outcome given that the state was $\\ket{0}$\n* $P(a|+)$ = probability to observe first outcome given that the state was $\\ket{+}$\n* $P(b|+)$ = probability to observe second outcome given that the state was $\\ket{+}$\n\nThe task is to maximize the probability to be correct on a single shot experiment, which is the same as to minimize the probability to be wrong on a single shot.\n\nSince the task promises uniform prior distribution of the inputs $\\ket{0}$ and $\\ket{+}$, i.e., $P(+) = P(0) = \\frac{1}{2}$, we get the following expression for the probability of giving a correct answer:\n\n$$P_{correct} = P(0) P(a|0) + P(+) P(b|+) = \\frac{1}{2} (P(a|0) + P(b|+))$$\n\nWe can represent our measurement as a von Neumann measurement of the following form:\n\n$$\\ket{E_a} = R_y(2\\alpha) \\begin{bmatrix} 1 \\\\ 0 \\end{bmatrix} = \\begin{bmatrix} \\cos \\alpha \\\\ \\sin \\alpha \\end{bmatrix}$$\n$$\\ket{E_b} = R_y(2\\alpha) \\begin{bmatrix} 0 \\\\ 1 \\end{bmatrix} = \\begin{bmatrix} - \\sin \\alpha \\\\ \\cos \\alpha \\end{bmatrix}$$\n\nUsing this representation, we can express our probabilities as follows:\n\n$$P(a|0) = |\\braket{E_a|0}|^2 = \\cos^2 \\alpha$$\n \n$$P(b|+) = |\\braket{E_b|+}|^2 = \\frac{1}{2} - \\cos \\alpha \\sin \\alpha$$\n \n$$P_{correct} = \\frac{1}{2} (\\cos^2 \\alpha + \\frac{1}{2} - \\cos \\alpha \\sin \\alpha)$$\n \nMaximizing this for $\\alpha$, we get max $P_{success} = \\frac{1}{2} (1 + \\frac{1}{\\sqrt{2}}) = 0.8535...$, which is attained for $\\alpha = -\\pi/8$.\n \nThis means that $\\ket{E_a}$ and $\\ket{E_b}$ are the result of rotating $\\ket{0}$ and $\\ket{1}$, respectively, by $-\\pi/8$. If we rotate the whole system by $-\\alpha = \\pi/8$, we will get $\\ket{E_a}=\\ket{0}$ and $\\ket{E_b}=\\ket{1}$, and a measurement in the computational basis will give us the correct result with a probability of 85%.\n \n> In Q#, rotating the input state by some angle $\\theta$ can be done by applying $Ry$ gate with angle parameter $2\\theta$."
6090
+ },
6091
+ {
6092
+ "type": "solution",
6093
+ "id": "measurements_nonorthogonal_states_solution",
6094
+ "code": "namespace Kata {\n open Microsoft.Quantum.Math;\n \n operation IsQubitZeroOrPlus (q : Qubit) : Bool {\n Ry(0.25 * PI(), q);\n return M(q) == Zero;\n }\n}\n"
6095
+ }
6096
+ ]
6097
+ }
6098
+ },
6099
+ {
6100
+ "type": "lesson",
6101
+ "id": "distinguishing_states__conclusion",
6102
+ "title": "Conclusion",
6103
+ "items": [
6104
+ {
6105
+ "type": "text-content",
6106
+ "asHtml": "<p>Congratulations! In this kata you learned to use measurements and basic quantum computing gates to distinguish quantum states. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>TODO</li>\n</ul>\n",
6107
+ "asMarkdown": "\nCongratulations! In this kata you learned to use measurements and basic quantum computing gates to distinguish quantum states. Here are a few key concepts to keep in mind:\n\n- TODO"
6108
+ }
6109
+ ]
6110
+ }
6111
+ ],
6112
+ "published": false
6113
+ },
6114
+ {
6115
+ "id": "teleportation",
6116
+ "title": "Teleportation",
6117
+ "sections": [
6118
+ {
6119
+ "type": "lesson",
6120
+ "id": "teleportation__overview",
6121
+ "title": "Overview",
6122
+ "items": [
6123
+ {
6124
+ "type": "text-content",
6125
+ "asHtml": "<p>Quantum teleportation protocol allows us to communicate a quantum state using only classical communication and previously shared quantum entanglement.</p>\n<ul>\n<li>Teleportation is described in <a href=\"https://en.wikipedia.org/wiki/Quantum_teleportation\">this Wikipedia article</a>.</li>\n<li>An interactive demonstration can be found <a href=\"http://demonstrations.wolfram.com/QuantumTeleportation/\">on the Wolfram Demonstrations Project</a>.</li>\n</ul>\n",
6126
+ "asMarkdown": "\nQuantum teleportation protocol allows us to communicate a quantum state using only classical communication and previously shared quantum entanglement.\n\n- Teleportation is described in [this Wikipedia article](https://en.wikipedia.org/wiki/Quantum_teleportation).\n- An interactive demonstration can be found [on the Wolfram Demonstrations Project](http://demonstrations.wolfram.com/QuantumTeleportation/)."
6127
+ }
6128
+ ]
6129
+ },
6130
+ {
6131
+ "type": "lesson",
6132
+ "id": "teleportation__standard_teleportation",
6133
+ "title": "Standard Teleportation",
6134
+ "items": [
6135
+ {
6136
+ "type": "text-content",
6137
+ "asHtml": "<p>In the standard teleportation protocol, two parties, the sender (typically referred to as Alice) and the receiver (Bob) start by sharing an entangled pair of qubits. The goal of the protocol is for Alice to transfer an unknown quantum state to Bob using their shared qubit pair and a classical communication channel.</p>\n<p>We split the teleportation protocol into several steps:</p>\n<ul>\n<li>Preparation (creating the entangled pair of qubits that are sent to Alice and Bob).</li>\n<li>Sending the message (Alice's task): Entangling the message qubit with Alice's qubit and extracting two classical bits to be sent to Bob.</li>\n<li>Reconstructing the message (Bob's task): Using the two classical bits Bob received from Alice to get Bob's qubit into the state in which the message qubit had been originally.</li>\n<li>Finally, we compose these steps into the complete teleportation protocol.</li>\n</ul>\n",
6138
+ "asMarkdown": "\nIn the standard teleportation protocol, two parties, the sender (typically referred to as Alice) and the receiver (Bob) start by sharing an entangled pair of qubits. The goal of the protocol is for Alice to transfer an unknown quantum state to Bob using their shared qubit pair and a classical communication channel.\n\nWe split the teleportation protocol into several steps:\n\n- Preparation (creating the entangled pair of qubits that are sent to Alice and Bob).\n- Sending the message (Alice's task): Entangling the message qubit with Alice's qubit and extracting two classical bits to be sent to Bob.\n- Reconstructing the message (Bob's task): Using the two classical bits Bob received from Alice to get Bob's qubit into the state in which the message qubit had been originally.\n- Finally, we compose these steps into the complete teleportation protocol."
6139
+ }
6140
+ ]
6141
+ },
6142
+ {
6143
+ "type": "exercise",
6144
+ "id": "teleportation__entangled_pair",
6145
+ "title": "Entangled Pair",
6146
+ "description": {
6147
+ "type": "text-content",
6148
+ "asHtml": "<p><strong>Input:</strong>\nTwo qubits <code>qAlice</code> and <code>qBob</code>, each in $\\ket{0}$ state.</p>\n<p><strong>Goal:</strong>\nPrepare a Bell state $\\ket{\\Phi^{+}} = \\frac{1}{\\sqrt{2}}(\\ket{00} + \\ket{11})$ on these qubits.</p>\n",
6149
+ "asMarkdown": "**Input:** \nTwo qubits `qAlice` and `qBob`, each in $\\ket{0}$ state.\n\n**Goal:**\nPrepare a Bell state $\\ket{\\Phi^{+}} = \\frac{1}{\\sqrt{2}}(\\ket{00} + \\ket{11})$ on these qubits."
6150
+ },
6151
+ "sourceIds": [
6152
+ "teleportation__entangled_pair__Verification.qs",
6153
+ "KatasLibrary.qs",
6154
+ "teleportation__Common.qs"
6155
+ ],
6156
+ "placeholderCode": "namespace Kata {\n operation Entangle (qAlice : Qubit, qBob : Qubit) : Unit is Adj {\n // Implement your solution here...\n\n }\n}\n\n",
6157
+ "explainedSolution": {
6158
+ "type": "explained-solution",
6159
+ "items": [
6160
+ {
6161
+ "type": "text-content",
6162
+ "asHtml": "<p>It is worth remembering the state we have already seen in &quot;Multi-Qubit Gates&quot; and &quot;Preparing Quantum States&quot; katas.</p>\n<p>The solution can be divided in two steps:</p>\n<ul>\n<li>Apply Hadamard gate to Alice's qubit:\n$\\big(\\frac{\\ket{0} + \\ket{1}}{\\sqrt{2}}\\big) \\otimes \\ket{0}$</li>\n<li>Apply a $CNOT$ gate with Alice's qubit as the control and Bob's qubit as target.</li>\n</ul>\n",
6163
+ "asMarkdown": "\nIt is worth remembering the state we have already seen in \"Multi-Qubit Gates\" and \"Preparing Quantum States\" katas.\n\nThe solution can be divided in two steps:\n- Apply Hadamard gate to Alice's qubit: \n$\\big(\\frac{\\ket{0} + \\ket{1}}{\\sqrt{2}}\\big) \\otimes \\ket{0}$\n- Apply a $CNOT$ gate with Alice's qubit as the control and Bob's qubit as target."
6164
+ },
6165
+ {
6166
+ "type": "solution",
6167
+ "id": "teleportation__entangled_pair_solution",
6168
+ "code": "namespace Kata {\n operation Entangle (qAlice : Qubit, qBob : Qubit) : Unit is Adj {\n H(qAlice);\n CNOT(qAlice, qBob);\n }\n}\n"
6169
+ }
6170
+ ]
6171
+ }
6172
+ },
6173
+ {
6174
+ "type": "exercise",
6175
+ "id": "teleportation__send_message",
6176
+ "title": "Send Message (Alice's Task)",
6177
+ "description": {
6178
+ "type": "text-content",
6179
+ "asHtml": "<p>Entangle the message qubit with Alice's qubit and extract two classical bits to be sent to Bob.</p>\n<p><strong>Inputs:</strong></p>\n<ol>\n<li>Alice's part of the entangled pair of qubits <code>qAlice</code>.</li>\n<li>The message qubit <code>qMessage</code>.</li>\n</ol>\n<p><strong>Output:</strong>\nTwo classical bits Alice will send to Bob via classical channel as a tuple of Boolean values. The first bit in the tuple should hold the result of measurement of the message qubit, the second bit - the result of measurement of Alice's qubit. Represent measurement result <code>One</code> as <code>true</code> and <code>Zero</code> as <code>false</code>. The state of the qubits in the end of the operation doesn't matter.</p>\n",
6180
+ "asMarkdown": "Entangle the message qubit with Alice's qubit and extract two classical bits to be sent to Bob.\n\n**Inputs:** \n1. Alice's part of the entangled pair of qubits `qAlice`.\n2. The message qubit `qMessage`.\n\n**Output:** \nTwo classical bits Alice will send to Bob via classical channel as a tuple of Boolean values. The first bit in the tuple should hold the result of measurement of the message qubit, the second bit - the result of measurement of Alice's qubit. Represent measurement result `One` as `true` and `Zero` as `false`. The state of the qubits in the end of the operation doesn't matter."
6181
+ },
6182
+ "sourceIds": [
6183
+ "teleportation__send_message__Verification.qs",
6184
+ "KatasLibrary.qs",
6185
+ "teleportation__Common.qs"
6186
+ ],
6187
+ "placeholderCode": "namespace Kata {\n operation SendMessage(qAlice : Qubit, qMessage : Qubit) : (Bool, Bool) {\n // Implement your solution here...\n return (false, false);\n }\n}",
6188
+ "explainedSolution": {
6189
+ "type": "explained-solution",
6190
+ "items": [
6191
+ {
6192
+ "type": "text-content",
6193
+ "asHtml": "<p>Requirement is to perform measurement in bell state:</p>\n<ul>\n<li>Apply $CNOT$ with $qMessage$ as control qubit</li>\n<li>Apply Hadamard on $qMessage$ qubit</li>\n<li>Measure both the qubits and report in boolean format</li>\n</ul>\n",
6194
+ "asMarkdown": "\nRequirement is to perform measurement in bell state:\n- Apply $CNOT$ with $qMessage$ as control qubit\n- Apply Hadamard on $qMessage$ qubit\n- Measure both the qubits and report in boolean format"
6195
+ },
6196
+ {
6197
+ "type": "solution",
6198
+ "id": "teleportation__send_the_message_solution",
6199
+ "code": "namespace Kata {\n operation SendMessage(qAlice : Qubit, qMessage : Qubit) : (Bool, Bool) {\n CNOT(qMessage, qAlice);\n H(qMessage);\n return (M(qMessage) == One, M(qAlice) == One);\n }\n}"
6200
+ }
6201
+ ]
6202
+ }
6203
+ },
6204
+ {
6205
+ "type": "exercise",
6206
+ "id": "teleportation__reconstruct_message",
6207
+ "title": "Reconstruct Message (Bob's Task)",
6208
+ "description": {
6209
+ "type": "text-content",
6210
+ "asHtml": "<p>Transform Bob's qubit into the required state using the two classical bits received from Alice.</p>\n<p><strong>Inputs:</strong></p>\n<ol>\n<li>Bob's part of the entangled pair of qubits <code>qBob</code>.</li>\n<li>The tuple of classical bits received from Alice, in the format used in previous exercise.</li>\n</ol>\n<p><strong>Goal:</strong>\nTransform Bob's qubit <code>qBob</code> into the state in which the message qubit had been originally.</p>\n",
6211
+ "asMarkdown": "Transform Bob's qubit into the required state using the two classical bits received from Alice.\n\n**Inputs:** \n1. Bob's part of the entangled pair of qubits `qBob`.\n2. The tuple of classical bits received from Alice, in the format used in previous exercise.\n\n**Goal:** \nTransform Bob's qubit `qBob` into the state in which the message qubit had been originally."
6212
+ },
6213
+ "sourceIds": [
6214
+ "teleportation__reconstruct_message__Verification.qs",
6215
+ "KatasLibrary.qs",
6216
+ "teleportation__Common.qs"
6217
+ ],
6218
+ "placeholderCode": "namespace Kata {\n operation ReconstructMessage(qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n // Implement your solution here...\n }\n}",
6219
+ "explainedSolution": {
6220
+ "type": "explained-solution",
6221
+ "items": [
6222
+ {
6223
+ "type": "text-content",
6224
+ "asHtml": "<p>Bob's qubit now contains the information about the amplitudes of the teleported state, but it needs correction based on the classical message received for his qubit to match the teleported state precisely:</p>\n<ul>\n<li>For 00, no change is required.</li>\n<li>For 01, only Z correction is required.</li>\n<li>For 10, only X correction is required.</li>\n<li>For 11, both Z and X correction is requried.</li>\n</ul>\n",
6225
+ "asMarkdown": "\nBob's qubit now contains the information about the amplitudes of the teleported state, but it needs correction based on the classical message received for his qubit to match the teleported state precisely:\n- For 00, no change is required.\n- For 01, only Z correction is required.\n- For 10, only X correction is required.\n- For 11, both Z and X correction is requried."
6226
+ },
6227
+ {
6228
+ "type": "solution",
6229
+ "id": "teleportation__reconstruct_the_message_solution",
6230
+ "code": "namespace Kata {\n operation ReconstructMessage(qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n if b1 {\n Z(qBob);\n }\n if b2 {\n X(qBob);\n }\n }\n}"
6231
+ }
6232
+ ]
6233
+ }
6234
+ },
6235
+ {
6236
+ "type": "exercise",
6237
+ "id": "teleportation__standard_teleportation_protocol",
6238
+ "title": "Standard Teleportation Protocol",
6239
+ "description": {
6240
+ "type": "text-content",
6241
+ "asHtml": "<p>Put together the steps implemented in previous three exercises to implement the full teleportation protocol.</p>\n<p><strong>Inputs:</strong></p>\n<ol>\n<li>The two qubits <code>qAlice</code> and <code>qBob</code> in $\\ket{0}$ state.</li>\n<li>The message qubit <code>qMessage</code> in the state $\\ket{\\psi}$ to be teleported.</li>\n</ol>\n<p><strong>Goal:</strong>\nTransform Bob's qubit <code>qBob</code> into the state $\\ket{\\psi}$. The state of the qubits <code>qAlice</code> and <code>qMessage</code> in the end of the operation doesn't matter.</p>\n",
6242
+ "asMarkdown": "Put together the steps implemented in previous three exercises to implement the full teleportation protocol.\n\n**Inputs:** \n1. The two qubits `qAlice` and `qBob` in $\\ket{0}$ state.\n2. The message qubit `qMessage` in the state $\\ket{\\psi}$ to be teleported.\n\n**Goal:** \nTransform Bob's qubit `qBob` into the state $\\ket{\\psi}$. The state of the qubits `qAlice` and `qMessage` in the end of the operation doesn't matter."
6243
+ },
6244
+ "sourceIds": [
6245
+ "teleportation__standard_teleportation_protocol__Verification.qs",
6246
+ "KatasLibrary.qs",
6247
+ "teleportation__Common.qs"
6248
+ ],
6249
+ "placeholderCode": "namespace Kata {\n operation StandardTeleport(qAlice : Qubit, qBob : Qubit, qMessage : Qubit) : Unit {\n // Implement your solution here...\n }\n \n // You might find these helper operations from earlier tasks useful.\n operation Entangle(qAlice : Qubit, qBob : Qubit) : Unit is Adj + Ctl {\n H(qAlice);\n CNOT(qAlice, qBob);\n }\n\n operation SendMessage(qAlice: Qubit, qMessage: Qubit) : (Bool, Bool) {\n CNOT(qMessage, qAlice);\n H(qMessage);\n return (M(qMessage) == One, M(qAlice) == One);\n }\n\n operation ReconstructMessage(qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n if b1 {\n Z(qBob);\n }\n if b2 {\n X(qBob);\n }\n }\n}",
6250
+ "explainedSolution": {
6251
+ "type": "explained-solution",
6252
+ "items": [
6253
+ {
6254
+ "type": "text-content",
6255
+ "asHtml": "<p>Combine solutions of all three exercises in the correct order</p>\n<ul>\n<li>Entangle qubits of Alice and Bob</li>\n<li>Send the message using Alice's qubit and message qubit</li>\n<li>Based on the message qubit, reconstruct the state of Bob's qubit</li>\n</ul>\n",
6256
+ "asMarkdown": "\nCombine solutions of all three exercises in the correct order\n\n- Entangle qubits of Alice and Bob\n- Send the message using Alice's qubit and message qubit\n- Based on the message qubit, reconstruct the state of Bob's qubit"
6257
+ },
6258
+ {
6259
+ "type": "solution",
6260
+ "id": "teleportation__standard_teleportation_protocol_solution",
6261
+ "code": "namespace Kata {\n operation StandardTeleport(qAlice : Qubit, qBob : Qubit, qMessage : Qubit) : Unit {\n Entangle(qAlice, qBob);\n let classicalBits = SendMessage(qAlice, qMessage);\n ReconstructMessage(qBob, classicalBits);\n }\n\n operation Entangle(qAlice : Qubit, qBob : Qubit) : Unit is Adj + Ctl {\n H(qAlice);\n CNOT(qAlice, qBob);\n }\n\n operation SendMessage(qAlice: Qubit, qMessage: Qubit) : (Bool, Bool) {\n CNOT(qMessage, qAlice);\n H(qMessage);\n return (M(qMessage) == One, M(qAlice) == One);\n }\n\n operation ReconstructMessage(qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n if b1 {\n Z(qBob);\n }\n if b2 {\n X(qBob);\n }\n }\n}"
6262
+ }
6263
+ ]
6264
+ }
6265
+ }
6266
+ ],
6267
+ "published": false
5476
6268
  }
5477
6269
  ],
5478
6270
  "globalCodeSources": [
@@ -5840,6 +6632,66 @@ export default {
5840
6632
  "id": "multi_qubit_measurements__joint_measurements__Verification.qs",
5841
6633
  "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n // Two qubit parity Measurement\n operation StatePrep_ParityMeasurement(qs : Qubit[], state : Int, alpha : Double) : Unit is Adj {\n // prep cos(alpha) * |0..0⟩ + sin(alpha) * |1..1⟩\n Ry(2.0 * alpha, qs[0]);\n CNOT(qs[0], qs[1]);\n\n if state == 1 {\n // flip the state of the first qubit\n X(qs[0]);\n }\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n let isCorrect = DistinguishStates_MultiQubit(\n 2,\n 2,\n StatePrep_ParityMeasurement,\n Kata.ParityMeasurement,\n true,\n [\"α|00⟩ + β|11⟩\", \"α|01⟩ + β|10⟩\"]);\n\n if (isCorrect) {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n }\n\n isCorrect\n }\n}\n"
5842
6634
  },
6635
+ {
6636
+ "id": "distinguishing_unitaries__i_x__Verification.qs",
6637
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([I, X], Kata.DistinguishIfromX, [\"I\", \"X\"], 1)\n }\n}\n"
6638
+ },
6639
+ {
6640
+ "id": "distinguishing_unitaries__Common.qs",
6641
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Random;\n\n // \"Framework\" operation for testing tasks for distinguishing unitaries\n // \"unitaries\" is the list of unitaries that can be passed to the task\n // \"testImpl\" - the solution to be tested\n // \"unitaryNames\" - the labels of unitaries in the list\n // \"maxCalls\" - max # of calls to the unitary that are allowed (-1 means unlimited) - currently unused, TODO use after #1154\n operation DistinguishUnitaries_Framework<'UInput> (\n unitaries : ('UInput => Unit is Adj + Ctl)[], \n testImpl : ('UInput => Unit is Adj + Ctl) => Int,\n unitaryNames : String[],\n maxCalls : Int\n ) : Bool {\n\n let nUnitaries = Length(unitaries);\n let nTotal = 100;\n mutable wrongClassifications = [0, size = nUnitaries * nUnitaries]; // [i * nU + j] number of times unitary i was classified as j\n mutable unknownClassifications = [0, size = nUnitaries]; // number of times unitary i was classified as something unknown\n \n for i in 1 .. nTotal {\n // get a random integer to define the unitary used\n let actualIndex = DrawRandomInt(0, nUnitaries - 1);\n \n // get the solution's answer and verify that it's a match\n let returnedIndex = testImpl(unitaries[actualIndex]);\n\n if returnedIndex != actualIndex {\n if returnedIndex < 0 or returnedIndex >= nUnitaries {\n set unknownClassifications w/= actualIndex <- unknownClassifications[actualIndex] + 1;\n } else {\n let index = actualIndex * nUnitaries + returnedIndex;\n set wrongClassifications w/= index <- wrongClassifications[index] + 1;\n }\n }\n }\n \n mutable totalMisclassifications = 0;\n for i in 0 .. nUnitaries - 1 {\n for j in 0 .. nUnitaries - 1 {\n let misclassifiedIasJ = wrongClassifications[(i * nUnitaries) + j];\n if misclassifiedIasJ != 0 {\n set totalMisclassifications += misclassifiedIasJ;\n Message($\"Misclassified {unitaryNames[i]} as {unitaryNames[j]} in {misclassifiedIasJ} test runs.\");\n }\n }\n if unknownClassifications[i] != 0 {\n set totalMisclassifications += unknownClassifications[i];\n Message($\"Failed to classify {unitaryNames[i]} in {unknownClassifications[i]} test runs.\");\n }\n }\n // This check will tell the total number of failed classifications\n if totalMisclassifications != 0 {\n Message($\"{totalMisclassifications} test runs out of {nTotal} returned incorrect state.\");\n Message(\"Incorrect.\");\n return false;\n }\n Message(\"Correct!\");\n true\n }\n\n operation MinusZ (q : Qubit) : Unit is Adj + Ctl {\n within { \n X(q);\n }\n apply {\n Z(q);\n }\n }\n\n operation XZ (q : Qubit) : Unit is Adj + Ctl {\n Z(q);\n X(q);\n }\n\n operation MinusY (q : Qubit) : Unit is Adj + Ctl {\n within {\n X(q);\n }\n apply {\n Y(q);\n }\n }\n\n operation MinusXZ (q : Qubit) : Unit is Adj + Ctl {\n X(q);\n Z(q);\n }\n}\n"
6642
+ },
6643
+ {
6644
+ "id": "distinguishing_unitaries__i_z__Verification.qs",
6645
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([I, Z], Kata.DistinguishIfromZ, [\"I\", \"Z\"], 1)\n }\n}\n"
6646
+ },
6647
+ {
6648
+ "id": "distinguishing_unitaries__z_s__Verification.qs",
6649
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([Z, S], Kata.DistinguishZfromS, [\"Z\", \"S\"], 1)\n }\n}\n"
6650
+ },
6651
+ {
6652
+ "id": "distinguishing_unitaries__h_x__Verification.qs",
6653
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([H, X], Kata.DistinguishHfromX, [\"H\", \"X\"], 1)\n }\n}\n"
6654
+ },
6655
+ {
6656
+ "id": "distinguishing_unitaries__z_minusz__Verification.qs",
6657
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([Z, MinusZ], Kata.DistinguishZfromMinusZ, [\"Z\", \"-Z\"], 1)\n }\n}\n"
6658
+ },
6659
+ {
6660
+ "id": "distinguishing_unitaries__rz_r1__Verification.qs",
6661
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([Rz, R1], Kata.DistinguishRzFromR1, [\"Rz\", \"R1\"], 1)\n }\n}\n"
6662
+ },
6663
+ {
6664
+ "id": "distinguishing_unitaries__y_xz__Verification.qs",
6665
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([Y, XZ], Kata.DistinguishYfromXZ, [\"Y\", \"XZ\"], 1)\n }\n}\n"
6666
+ },
6667
+ {
6668
+ "id": "distinguishing_unitaries__y_xz_minusy_minusxz__Verification.qs",
6669
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([Y, MinusXZ, MinusY, XZ], Kata.DistinguishYfromXZWithPhases, [\"Y\", \"-XZ\", \"-Y\", \"XZ\"], 1)\n }\n}\n"
6670
+ },
6671
+ {
6672
+ "id": "distinguishing_unitaries__i_x_y_z__Verification.qs",
6673
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([I, X, Y, Z], Kata.DistinguishPaulis, [\"I\", \"X\", \"Y\", \"Z\"], 1)\n }\n}\n"
6674
+ },
6675
+ {
6676
+ "id": "distinguishing_unitaries__rz_ry__Verification.qs",
6677
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n for theta in [0.04, 0.1, 0.25, 0.31, 0.5, 0.87, 1.05, 1.41, 1.66, 1.75, 2.0, 2.16, 2.22, 2.51, 2.93, 3.0, 3.1] {\n Message($\"Testing theta = {theta}...\"); \n if not DistinguishUnitaries_Framework([Rz(theta, _), Ry(theta, _)], Kata.DistinguishRzFromRy(theta, _), [\"Rz\", \"Ry\"], -1) {\n return false;\n }\n }\n return true;\n }\n}\n"
6678
+ },
6679
+ {
6680
+ "id": "distinguishing_unitaries__ix_cnot__Verification.qs",
6681
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([qs => X(qs[1]), qs => CNOT(qs[0], qs[1])], Kata.DistinguishIXfromCNOT, [\"I⊗X\", \"CNOT\"], 1)\n }\n}\n"
6682
+ },
6683
+ {
6684
+ "id": "distinguishing_unitaries__cnot_direction__Verification.qs",
6685
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([qs => CNOT(qs[0], qs[1]), qs => CNOT(qs[1], qs[0])], Kata.CNOTDirection, [\"CNOT_12\", \"CNOT_21\"], 1)\n }\n}\n"
6686
+ },
6687
+ {
6688
+ "id": "distinguishing_unitaries__cnot_swap__Verification.qs",
6689
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([qs => CNOT(qs[0], qs[1]), qs => SWAP(qs[0], qs[1])], Kata.DistinguishCNOTfromSWAP, [\"CNOT\", \"SWAP\"], 1)\n }\n}\n"
6690
+ },
6691
+ {
6692
+ "id": "distinguishing_unitaries__i_cnot_swap__Verification.qs",
6693
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n DistinguishUnitaries_Framework([ApplyToEachCA(I, _), qs => CNOT(qs[0], qs[1]), qs => CNOT(qs[1], qs[0]), qs => SWAP(qs[0], qs[1])], Kata.DistinguishTwoQubitUnitaries, [\"I⊗I\", \"CNOT_12\", \"CNOT_21\", \"SWAP\"], 2)\n }\n} \n"
6694
+ },
5843
6695
  {
5844
6696
  "id": "random_numbers__random_bit__Verification.qs",
5845
6697
  "code": "namespace Kata.Verification {\n @EntryPoint()\n operation CheckSolution() : Bool {\n let randomnessVerifier = () => CheckUniformDistribution(Kata.RandomBit, 0, 1, 1000);\n let isCorrect = IsSufficientlyRandom(randomnessVerifier);\n if isCorrect {\n Message(\"Correct!\");\t\n\t }\n isCorrect\n }\n\n}\n"
@@ -5987,6 +6839,42 @@ export default {
5987
6839
  {
5988
6840
  "id": "qec_shor__shor_detect__Verification.qs",
5989
6841
  "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Random;\n\n operation ShorEncode (qs : Qubit[]) : Unit is Adj + Ctl {\n BitflipEncode(qs[0 .. 3 .. 8]);\n ApplyToEachCA(H, qs[0 .. 3 .. 8]);\n for i in 0 .. 2 {\n BitflipEncode(qs[3 * i .. 3 * i + 2]);\n }\n }\n\n operation BitflipEncode (qs : Qubit[]) : Unit is Adj + Ctl {\n CNOT(qs[0], qs[1]);\n CNOT(qs[0], qs[2]);\n }\n\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n for err_ind in -1 .. 8 {\n for err in [PauliX, PauliZ, PauliY] {\n for _ in 1 .. 10 {\n mutable correct = true;\n mutable msg = \"\";\n use qs = Qubit[9];\n let theta = DrawRandomDouble(0.0, 1.0);\n within {\n // Prepare logical state on first qubit\n Ry(2.0 * theta * PI(), qs[0]);\n // Encode the state in multiple qubits\n ShorEncode(qs);\n // Introduce the error\n if err_ind > -1 {\n if err == PauliX {\n X(qs[err_ind]);\n } elif err == PauliZ {\n Z(qs[err_ind]);\n } else {\n Y(qs[err_ind]);\n }\n }\n } apply {\n // Call solution to detect error\n let (detected_ind, detected_err) = Kata.ShorDetectError(qs);\n // Check that it is correct\n if err_ind == -1 {\n // No error\n if detected_ind != -1 {\n set correct = false;\n set msg = $\"There was no error, but the solution detected error at qubit {detected_ind}\";\n }\n } else {\n // There was an error\n if detected_err != err {\n set correct = false;\n set msg = $\"There was a {err} error, but the solution detected {detected_err} error\";\n } else {\n if err == PauliX or err == PauliY {\n if detected_ind != err_ind {\n set correct = false;\n set msg = $\"There was a {err} error at qubit {err_ind}, but the solution detected it at qubit {detected_ind}\";\n }\n } else {\n // For PauliZ errors, cannot say for certain in which qubit of the triplet it happened, so identify triplet\n if detected_ind != err_ind / 3 {\n set correct = false;\n set msg = $\"There was a {err} error at qubit {err_ind}, but the solution detected it at qubit triplet {detected_ind}\";\n }\n }\n }\n }\n }\n // Check that the state was not modified by the solution\n if not CheckAllZero(qs) {\n set correct = false;\n set msg = \"The state of the qubits changed after the solution was applied\";\n }\n\n if not correct {\n Message(\"Incorrect.\");\n Message(msg);\n ResetAll(qs);\n return false;\n }\n }\n }\n }\n\n Message(\"Correct!\");\n true\n }\n}\n"
6842
+ },
6843
+ {
6844
+ "id": "distinguishing_states__zero_one__Verification.qs",
6845
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n\n operation StatePrep_IsQubitOne (q : Qubit, state : Int) : Unit is Adj {\n if state == 1 {\n // convert |0⟩ to |1⟩\n X(q);\n }\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n let isCorrect = DistinguishTwoStates_SingleQubit(\n StatePrep_IsQubitOne,\n Kata.IsQubitOne,\n [\"|0⟩\", \"|1⟩\"],\n false);\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n }\n isCorrect\n }\n\n}\n"
6846
+ },
6847
+ {
6848
+ "id": "distinguishing_states__plus_minus__Verification.qs",
6849
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation StatePrep_IsQubitPlus(q : Qubit, state : Int) : Unit is Adj {\n if state == 1 {\n // convert |0⟩ to |+⟩\n H(q);\n } else {\n // convert |0⟩ to |-⟩\n X(q);\n H(q);\n }\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n let isCorrect = DistinguishTwoStates_SingleQubit(\n StatePrep_IsQubitPlus,\n Kata.IsQubitPlus,\n [\"|-⟩\", \"|+⟩\"],\n false\n );\n if isCorrect {\n Message(\"Correct!\");\n } else {\n Message(\"Incorrect.\");\n }\n isCorrect\n }\n}\n"
6850
+ },
6851
+ {
6852
+ "id": "distinguishing_states__zero_plus__Verification.qs",
6853
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n operation SetQubitZeroOrPlus (q : Qubit, state : Int) : Unit {\n if state != 0 {\n H(q);\n }\n }\n\n @EntryPoint()\n operation CheckSolution () : Bool {\n return DistinguishStates_MultiQubit_Threshold(1, 2, 0.8, SetQubitZeroOrPlus, Kata.IsQubitZeroOrPlus);\n }\n}\n"
6854
+ },
6855
+ {
6856
+ "id": "distinguishing_states__Common.qs",
6857
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Random;\n\n operation DistinguishStates_MultiQubit_Threshold (nQubit : Int, \n nState : Int, \n threshold : Double, \n statePrep : ((Qubit, Int) => Unit), \n testImpl : (Qubit => Bool)) : Bool {\n let nTotal = 1000;\n mutable nOk = 0;\n\n use qs = Qubit[nQubit];\n for i in 1 .. nTotal {\n // get a random integer to define the state of the qubits\n let state = DrawRandomInt(0, nState - 1);\n\n // do state prep: convert |0⟩ to outcome with return equal to state\n statePrep(qs[0], state);\n\n // get the solution's answer and verify that it's a match\n let ans = testImpl(qs[0]);\n if ans == (state == 0) {\n set nOk += 1;\n }\n\n // we're not checking the state of the qubit after the operation\n ResetAll(qs);\n }\n\n if IntAsDouble(nOk) < threshold * IntAsDouble(nTotal) {\n Message($\"{nTotal - nOk} test runs out of {nTotal} returned incorrect state, which does not meet the required threshold of at least {threshold * 100.0}%.\");\n Message(\"Incorrect.\");\n return false;\n } else {\n Message(\"Correct!\");\n return true;\n }\n }\n}\n"
6858
+ },
6859
+ {
6860
+ "id": "teleportation__entangled_pair__Verification.qs",
6861
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n\n operation Entangle_Wrapper (qs : Qubit[]) : Unit is Adj {\n Kata.Entangle(qs[0], qs[1]);\n }\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n \n return CheckOperationsEquivalenceOnZeroStateWithFeedback(\n Entangle_Wrapper,\n EntangleWrapper_Reference,\n 2\n );\n \n }\n}\n"
6862
+ },
6863
+ {
6864
+ "id": "teleportation__Common.qs",
6865
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Math;\n\n operation EntangleWrapper_Reference(qs : Qubit[]) : Unit is Adj + Ctl {\n let (qAlice, qBob) = (qs[0], qs[1]);\n H(qAlice);\n CNOT(qAlice, qBob);\n }\n\n // ------------------------------------------------------\n // Helper which prepares proper Bell state on two qubits\n // 0 - |Φ⁺⟩ = (|00⟩ + |11⟩) / sqrt(2)\n // 1 - |Φ⁻⟩ = (|00⟩ - |11⟩) / sqrt(2)\n // 2 - |Ψ⁺⟩ = (|01⟩ + |10⟩) / sqrt(2)\n // 3 - |Ψ⁻⟩ = (|01⟩ - |10⟩) / sqrt(2)\n operation StatePrep_BellState(q1 : Qubit, q2 : Qubit, state : Int) : Unit {\n H(q1);\n CNOT(q1, q2);\n \n // now we have |00⟩ + |11⟩ - modify it based on state arg\n if state % 2 == 1 {\n // negative phase\n Z(q2);\n }\n \n if state / 2 == 1 {\n X(q2);\n }\n }\n\n // ------------------------------------------------------\n // Helper operation that run teleportation using the given operations to prepare the message qubit\n // and the entangled pair, and to run sender and receiver parts of the protocol.\n operation ComposeTeleportation(\n bellPrepOp : ((Qubit, Qubit) => Unit), \n getDescriptionOp : ((Qubit, Qubit) => (Bool, Bool)), \n reconstructOp : ((Qubit, (Bool, Bool)) => Unit),\n qAlice : Qubit, \n qBob : Qubit, \n qMessage : Qubit) : Unit {\n\n bellPrepOp(qAlice, qBob);\n let classicalBits = getDescriptionOp(qAlice, qMessage);\n \n // Alice sends the classical bits to Bob.\n // Bob uses these bits to transform his part of the entangled pair into the message.\n reconstructOp(qBob, classicalBits);\n }\n \n operation SendMessage_Reference(qAlice: Qubit, qMessage: Qubit) : (Bool, Bool) {\n CNOT(qMessage, qAlice);\n H(qMessage);\n return (M(qMessage) == One, M(qAlice) == One);\n }\n\n operation ReconstructMessage_Reference(qBob : Qubit, (b1 : Bool, b2 : Bool)) : Unit {\n if b1 {\n Z(qBob);\n }\n if b2 {\n X(qBob);\n }\n }\n\n // ------------------------------------------------------\n // Helper operation that runs a teleportation operation (specified by teleportOp).\n // The state to teleport is set up using an operation (specified by setupPsiOp).\n //\n // Specifying the state to teleport through an operation allows to get the inverse\n // which makes testing easier.\n operation TeleportTestHelper(\n teleportOp : ((Qubit, Qubit, Qubit) => Unit), \n setupPsiOp : (Qubit => Unit is Adj),\n psiName: String) : Bool {\n \n use (qMessage, qAlice, qBob) = (Qubit(), Qubit(), Qubit());\n setupPsiOp(qMessage);\n \n // This should modify qBob to be identical to the state\n // of qMessage before the function call.\n teleportOp(qAlice, qBob, qMessage);\n \n // Applying the inverse of the setup operation to qBob\n // should make it Zero.\n Adjoint setupPsiOp(qBob);\n if not CheckZero(qBob) {\n Message($\"Incorrect. The state {psiName} was teleported incorrectly.\");\n setupPsiOp(qBob);\n Message(\"The state of the qubits [qMessage, qAlice, qBob] after teleportation:\");\n DumpMachine();\n ResetAll([qMessage, qAlice, qBob]);\n return false;\n }\n ResetAll([qMessage, qAlice, qBob]);\n return true;\n }\n\n // ------------------------------------------------------\n // Run teleportation for a number of different states.\n // After each teleportation success is asserted.\n // Also repeats for each state several times as\n // code is expected to take different paths each time because\n // measurements done by Alice are not deterministic.\n operation TeleportTestLoop(teleportOp : ((Qubit, Qubit, Qubit) => Unit)) : Bool {\n // Define setup operations for the message qubit\n // on which to test teleportation: |0⟩, |1⟩, |0⟩ + |1⟩, unequal superposition.\n let setupPsiOps = [(I, \"|0⟩\"), (X, \"|1⟩\"), (H, \"|+⟩\"), (Ry(ArcCos(0.6) * 2.0, _), \"0.6|0⟩ + 0.8|1⟩\")];\n \n // As part of teleportation Alice runs some measurements\n // with nondeterministic outcome.\n // Depending on the outcomes different paths are taken on Bob's side.\n // We repeat each test run several times to ensure that all paths are checked.\n let numRepetitions = 100;\n for (psiOp, psiName) in setupPsiOps {\n for j in 1 .. numRepetitions {\n if not TeleportTestHelper(teleportOp, psiOp, psiName) {\n return false;\n }\n }\n }\n Message(\"Correct.\");\n return true;\n }\n}"
6866
+ },
6867
+ {
6868
+ "id": "teleportation__send_message__Verification.qs",
6869
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool { \n let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 0), Kata.SendMessage, ReconstructMessage_Reference, _, _, _);\n return TeleportTestLoop(teleport); \n }\n}"
6870
+ },
6871
+ {
6872
+ "id": "teleportation__reconstruct_message__Verification.qs",
6873
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n let teleport = ComposeTeleportation(StatePrep_BellState(_, _, 0), SendMessage_Reference, Kata.ReconstructMessage, _, _, _);\n return TeleportTestLoop(teleport); \n }\n}"
6874
+ },
6875
+ {
6876
+ "id": "teleportation__standard_teleportation_protocol__Verification.qs",
6877
+ "code": "namespace Kata.Verification {\n open Microsoft.Quantum.Katas;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n let teleport = Kata.StandardTeleport;\n return TeleportTestLoop(teleport);\n }\n\n}"
5990
6878
  }
5991
6879
  ]
5992
6880
  };