Learn Quantum Computing with Python and Q#
A hands-on approach
Sarah C. Kaiser and Christopher E. Granade
  • MEAP began April 2019
  • Publication in Fall 2020 (estimated)
  • ISBN 9781617296130
  • 300 pages (estimated)
  • printed in black & white

A great introduction to the exciting new world of quantum computing.

William Wheeler
Learn Quantum Computing with Python and Q# demystifies quantum computing. Using Python and the new quantum programming language Q#, you’ll build your own quantum simulator and apply quantum programming techniques to real-world examples including cryptography and chemical analysis.

About the Technology

Quantum computing is the next step in computing power and scalability, with the potential to impact everything from data science to information security. Using qubits, the fundamental unit of quantum information, quantum computers can solve problems beyond the scale of classical computing. Software packages like Microsoft's Quantum Development Kit and the Q# language are now emerging to give programmers a quick path to exploring quantum development for the first time.

About the book

Learn Quantum Computing with Python and Q# demystifies quantum computing. Using Microsoft’s Quantum Development Kit to abstract away the mathematical complexities, this book builds your understanding of quantum computers by actively developing for them. You’ll start by learning QC fundamentals by creating your own quantum simulator in Python. Soon you’ll move on to using the QDK and the new Q# language for writing and running algorithms very different to those found in classical computing. When you’re finished you’ll be able to apply quantum programming techniques to applications like quantum key distribution, and tackle real-world examples such as chemistry simulations and searching unsorted databases.
Table of Contents detailed table of contents

Part 1: Getting Started with Quantum

1 Introducing Quantum Computing

1.1 Who This Book is For

1.2 Who This Book is Not For

1.2.1 Textbooks and other resources for learning further

1.3 How this book is organized

1.4 Why does quantum computing matter?

1.4.1 Decisions that are strongly impacted by quantum computing

1.5 What Can Quantum Computers Do?

1.5.1 Some useful quantum algorithms

1.6 What is a Quantum Computer?

1.7 How will we use quantum computers?

1.7.1 Exotic cloud computing resources

1.8 What can’t Quantum computer do?

1.8.1 Factoring N classically.

1.9 What is a program?

1.10 What is a Quantum program?

1.11 Summary

2 Qubits: The Building Blocks

2.1 Why do we need random numbers?

2.1.1 Things some humans like to use randomness for

2.1.2 Statements about probability

2.1.3 Quantum random number generator algorithm

2.2 What are Classical Bits?

2.2.1 What Can We Do With Classical Bits?

2.2.2 Abstractions are our friend

2.3 Qubits: States and Operations

2.3.1 State of the qubit

2.3.2 The game of Operations

2.3.3 A mouthful of math

2.3.4 Measuring Qubits

2.3.5 Generalizing measurement: basis independence

2.3.6 Simulating qubits in code

2.4 Pprogramming a working QRNG

2.4.1 QRNG

2.4.2 Quantum device interface requirements.

2.4.3 Qubit interface requirements.

2.5 Summary

3 Sharing Secrets with Quantum Key Distribution

3.1 All’s Fair in Love and Encryption

3.2 Quantum NOT operations

3.2.1 Algorithm for sending a random classical bit string encoded in qubits.

3.3 Sharing classical bits with qubits

3.4 A tale of two bases

3.5 Quantum Key Distribution: BB84

3.5.1 Steps of the BB84 protocol:

3.6 Using our secret key to send secret messages

3.7 Summary

4 Nonlocal Games: Working with multiple qubits

4.1 Nonlocal Games

4.2 What are nonlocal games?

4.3 Testing quantum physics itself: The CHSH game

4.3.1 Steps for one round of the CHSH game

4.4 Classical strategy

4.5 Working with multiple qubit states

4.6 Registers

4.6.1 Example three-qubit states

4.7 Why is it hard to simulate quantum computers?

4.8 Tensor products for state preparation

4.9 Tensor products for qubit operations on registers

4.10 QuTiP of the Iceberg

4.11 Quantum objects in QuTiP

4.11.1 Selected metadata that the Qobj class tracks:

4.12 Upgrading the simulator

4.13 Measuring up: How can we measure multiple qubits?

4.14 CHSH: Quantum strategy

4.15 Summary

5 Teleportation and entanglement: Moving quantum data around

5.1 Moving quantum data

5.2 Swapping out our simulator

5.3 What other two-qubit gates are there?

5.4 All the single (qubit) rotations

5.5 Relating rotations to coordinates: The Pauli operations

5.6 Teleportation

5.7 Part I: Conclusion

Part 2: Programming Quantum Algorithms In Q#

6 Changing the odds: An introduction to Q#

6.1 Introducing the Quantum Development Kit

6.2 Functions and Operations in Q#

6.2.1 Morgana’s side game

6.3 Passing Operations as Arguments

6.4 Playing Morgana’s Game in Q#

6.5 Summary

7 What is a Quantum Algorithm?

7.1 Classical and quantum algorithms

7.1.1 Quicksort algorithm

7.2 Deutsch—​Jozsa Algorithm: moderate improvements for searching

7.3 Lady of the (Quantum) Lake

7.3.1 Kingmaker game rules

7.3.2 Nimue’s objectives

7.3.3 Merlin’s strategies:

7.4 Oracles: representing classical functions in quantum algorithms

7.4.1 Our strategy for representing classical functions as quantum oracles

7.4.2 Deutsch–Jozsa Algorithm

7.5 Simulating the Deutsch—​Jozsa algorithm in Q#

7.6 Exploring the Deutsch—​Jozsa Algorithm by example

7.7 Step 1. preparing the input state for Deutsch–Jozsa

7.8 step 2. applying the oracle

7.9 Steps 3 and 4. undo the preparation on the target qubit and measure.

7.10 Reflecting back

7.11 Shoes and socks: applying and undoing quantum operations

7.12 Using hadamard instructions to flip control and target

7.13 Phase kickback

7.14 Summary

8 Quantum sensing: It’s not just a phase

8.1 Phase estimation: leveraging useful properties of qubits for measurement

8.2 Part and Partial Application

8.2.1 Steps for Dagonet and Lancelot’s game

8.3 User-Defined Types

8.3.1 Reasons you might define UDTs in Q#:

8.4 Run, snake, run: Running Q# from Python

8.5 Eigenstates and Local Phases

8.6 Controlled application: Turning global phases into local phases

8.7 Controlling any operation

8.8 Implementing Lancelot’s best strategy for the phase estimation game

8.8.1 Steps for Dagonet and Lancelot’s game

8.9 Summary

Part 3: Applied Quantum Computing

9 Solving Chemistry Problems with Quantum Computers

9.1 Real chemistry applications for quantum computing

9.1.1 Steps to simulate another quantum system, Marie’s H₂ molecule, with your quantum computer:

9.2 Many paths lead to Quantum Mechanics

9.3 Hamiltonians describe how quantum systems evolve in time.

9.4 Rotating around arbitrary axes with Pauli operations

9.5 Making the change you want to see in the system

9.6 Going through (very small) changes

9.7 Putting it all together

9.7.1 Steps to find the ground state energy of H₂.

9.8 Summary

10 Searching with Quantum Computers

10.1 Searching Unstructured Data

10.2 Reflecting about States

10.3 Reflection about the all-ones state

10.4 Reflection about an arbitrary state

10.6 Resource Estimation

10.7 Summary

11 Arithmetic With Quantum Computers

11.1 Factoring in quantum computing to security

11.2 Connecting modular math to factoring

11.3 Example of Factoring with Shor’s Algorithm

11.3.1 Working through the steps of to factor 21.

11.4 Classical algebra and factoring

11.5 Quantum arithmetic

11.6 Adding with qubits

11.7 Multiplying with qubits in superposition

11.8 Modular multiplication in Shor’s algorithm

11.9 Putting it all together

11.10 Wrapping Up

11.11 Summary:

Appendixes

Appendix A: Installing Required Software

A.1 Installing a Python Environment

A.1.1 Using Binder

A.1.2 Using Visual Studio Online

A.2 Installing a python environment

A.3 Installing anaconda

A.4 Installing python packages with anaconda

A.5 Installing the quantum development kit

A.6 Installing the .NET core SDK

A.7 Installing the project templates

A.8 Installing the visual studio code extension

A.9 Installing iq# for Jupyter notebook

Appendix B: Linear algebra refresher

B.1 Approaching vectors

B.1.1 Examples of vectors

B.2 Seeing the matrix for ourselves

B.2.1 Examples of linear functions

B2.2 Steps to compute f(np.array([[2], [3]]))

B.3 Party with inner products

What's inside

  • The underlying mechanics of how quantum computers work
  • How to simulate qubits in Python
  • Q# and the Microsoft Quantum Developer Kit
  • How to apply quantum algorithms to real-world examples

About the reader

No academic experience of quantum computing is required. A reader will need basic programming skills and some experience of linear algebra, calculus and complex numbers.

About the authors

Christopher Granade completed his PhD in physics (quantum information) at the University of Waterloo’s Institute for Quantum Computing, and now works in the Quantum Architectures and Computation (QuArC) group at Microsoft. He works in developing the standard libraries for Q# and is an expert in the statistical characterization of quantum devices from classical data. Previously, Christopher helped Scott Aaronson prepare lectures into his recent book, Quantum Computing Since Democritus.

Sarah Kaiser completed her PhD in physics (quantum information) at the University of Waterloo’s Institute for Quantum Computing. She has spent much of her career developing new quantum hardware in the lab, from satellites to hacking quantum cryptography hardware. Communicating what is so exciting about quantum is her passion, and she loves finding new demos and tools to help enable the quantum community to grow. When not at the keyboard, she loves kayaking and writing books about engineering for kids.


placing your order...

Don't refresh or navigate away from the page.
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
print book $39.99 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
Learn Quantum Computing with Python and Q# (print book) added to cart
continue shopping
go to cart

eBook $31.99 $39.99 3 formats + liveBook
Learn Quantum Computing with Python and Q# (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks