Book Image

Learn Q# Programming

By : Bhagvan Kommadi, Aneesh K Johny
Book Image

Learn Q# Programming

By: Bhagvan Kommadi, Aneesh K Johny

Overview of this book

<p>This book covers the fundamentals of quantum computing and programming with Microsoft’s Q# language. The reader will learn how to design, test and debug algorithms for different quantum applications.</p> <p>The primary focus of this book will be to give the audience an idea about how to get started with the concepts, different aspects, and theories of quantum computing operations, algorithms etc. Through this book, the developer will get a basic idea about the Microsoft Quantum Tool Kit and how to use the embedded Q# language. This will enable the reader to formalize and convert different real world problems to quantum algorithms and optimize them to use with a future quantum computer.</p> <p>By the end of the book, you would have successfully learned to create quantum programs of your own.</p>
Table of Contents (11 chapters)

Pseudo code


The pseudo code for scenarios such as helloworld, state testing, superposition and entanglement is presented in the sections below.

Q# - Hello World

The pseudo code for helloworld is shown below:

  • Quantum Simulator is instantiated
  • The simulator calls the helloworld method
  • The method prints the message
  • The message will print Q#-HelloWorld

State Testing

The pseudo code for state testing is shown below:

  1. Create a Qubit
  2. loop the logic below for number of times equal to count:
    1. initialize number of ones to zero
    2. call the set method with  the initial and  qubit parameters
    3. perform X gate on Qubit
    4. the result is set to measure of the qubit
    5. statistics are gathered for how many zeros and ones.
    6. collect the number of ones
  3. call the set method with zero and qubit parameters
  4. return the number of times zero and 1 is appeared.

Super Position

The superposition is achieved by the following pseudocode.

  1. Create a Qubit
  2. loop the logic below for number of times equal to count:
    1. initialize number of ones to zero
    2. call the set method...