$30 off During Our Annual Pro Sale. View Details »

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. Introduction to Q#
    Hiroshi Kurokawa, Dev Group, Mitene
    2018-08-27
    Vantage LT meetup

    View Slide

  2. What’s Q#?
    Programming Language

    for Quantum Computing

    View Slide

  3. What’s Quantum
    Computing?
    Computing using quantum-
    mechanical phenomena

    View Slide

  4. What’s Quantum
    Computing?
    Probabilistic vector and
    matrix with complex numbers
    Computing using quantum-
    mechanical phenomena

    View Slide

  5. 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

    View Slide

  6. 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

    View Slide

  7. |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

    View Slide

  8. |000‌0͏>
    Machine state
    Classic computerɿ 0110
    Quantum computerɿ superposition of
    |0001͏>
    |0010͏>
    and
    and

    |0011͏>
    and

    View Slide

  9. 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>

    View Slide

  10. 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

    View Slide

  11. Solution
    Remember this:

    H |0> = |+>

    H |1> = |->

    X |0> = |1>

    View Slide

  12. 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);
    }
    }
    }
    }

    View Slide

  13. Matrix operations
    CNOT operator

    CNOT( |0> |0> ) = |0> |0>

    CNOT( |0> |1> ) = |0> |1>

    CNOT( |1> |0> ) = |1> |1>

    CNOT( |1> |1> ) = |1> |0>

    View Slide

  14. Problem
    https:/
    /codeforces.com/contest/1001/
    problem/B
    You are given |00>
    Convert |00> → 1/√2( |00> + |11>)

    View Slide

  15. 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>

    View Slide

  16. 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);
    }
    }
    }

    View Slide

  17. 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

    View Slide