Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Q#

Introduction to Q#

- Quantum Computing Concepts
https://docs.microsoft.com/en-us/quantum/quantum-concepts-1-intro
- Microsoft Q# Coding Contest - Summer 2018 - Warmup
https://codeforces.com/contest/1001
- Microsoft Q# Coding Contest - Summer 2018 - Warmupの問題を解いてみた

https://qiita.com/hatoo@github/items/49b8542029a2100efabf

Hiroshi Kurokawa

August 27, 2018
Tweet

More Decks by Hiroshi Kurokawa

Other Decks in Technology

Transcript

  1. Qubit Bit: 0 or 1 Qubit: superposition of and |0>

    |1> A quibit can be represented as
 
 α|0> + β |1>
 
 where the prob. of |0> and |1>
 is |α|2 and |β|2 respectively
  2. Machine state Classic computerɿ 0110 Quantum computerɿ superposition of |0>

    |0> |0> |0> |0> |0> |0> |1> |0> |0> |1> |0> and and … |0> |0> |1> |1> and
  3. |0> |0> |0‌> |0͏> Machine state Classic computerɿ 0110 Quantum

    computerɿ superposition of |0> |0> |0> |1͏> |0> |0> |1> |0͏> and and … |0> |0> |1> |1͏> and
  4. Matrix operations Hadamard operator: H
 H |0> = 1/√2 (

    |0> + |1> ) = |+>
 H |1> = 1/√2 ( |0> - |1> ) = |-> NOT operator: X
 X |0> = |1>
 X |1> = |0>
  5. Problem https:/ /codeforces.com/contest/1001/ problem/A You are given |0> and an

    integer Convert the qubit to |+> if the integer is 1 |-> if the integer is -1
  6. Solution namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve

    (q : Qubit, sign : Int) : () { body { // q is set as |0> if (sign == 1) { H(q); } else { X(q); // flip q to make it |1> H(q); } } } }
  7. Matrix operations CNOT operator
 CNOT( |0> |0> ) = |0>

    |0>
 CNOT( |0> |1> ) = |0> |1>
 CNOT( |1> |0> ) = |1> |1>
 CNOT( |1> |1> ) = |1> |0>
  8. Solution Hint:
 |+> |0> = 1/√2 (|0> + |1>) |0>


    = 1/√2 (|00> + |10> Remember CNOT:
 CNOT( |0> |0> ) = |0> |0>
 CNOT( |0> |1> ) = |0> |1>
 CNOT( |1> |0> ) = |1> |1>
 CNOT( |1> |1> ) = |1> |0> |11>
  9. Solution namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve

    (qs : Qubit[], index : Int) : () { body { let x = qs[0]; let y = qs[1]; H(x); CNOT(x, y); } } }
  10. Reference Quantum Computing Concepts
 https:/ /docs.microsoft.com/en-us/quantum/quantum- concepts-1-intro Microsoft Q# Coding

    Contest - Summer 2018 - Warmup
 https:/ /codeforces.com/contest/1001 Microsoft Q# Coding Contest - Summer 2018 - Warmupͷ໰୊Λղ͍ͯΈͨ
 https:/ /qiita.com/hatoo@github/items/ 49b8542029a2100efabf