Quantum Computing with Silq Programming - Srinjoy Ganguly - E-Book

Quantum Computing with Silq Programming E-Book

Srinjoy Ganguly

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Quantum computing is a growing field, with many research projects focusing on programming quantum computers in the most efficient way possible. One of the biggest challenges faced with existing languages is that they work on low-level circuit model details and are not able to represent quantum programs accurately. Developed by researchers at ETH Zurich after analyzing languages including Q# and Qiskit, Silq is a high-level programming language that can be viewed as the C++ of quantum computers! Quantum Computing with Silq Programming helps you explore Silq and its intuitive and simple syntax to enable you to describe complex tasks with less code.
This book will help you get to grips with the constructs of the Silq and show you how to write quantum programs with it. You’ll learn how to use Silq to program quantum algorithms to solve existing and complex tasks. Using quantum algorithms, you’ll also gain practical experience in useful applications such as quantum error correction, cryptography, and quantum machine learning. Finally, you’ll discover how to optimize the programming of quantum computers with the simple Silq.
By the end of this Silq book, you’ll have mastered the features of Silq and be able to build efficient quantum applications independently.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 371

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Quantum Computing with Silq Programming

Get up and running with quantum computing with the simplicity of this new high-level programming language

Srinjoy Ganguly

Thomas Cambier

BIRMINGHAM—MUMBAI

Quantum Computing with Silq Programming

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Aaron Lazar

Publishing Product Manager: Shweta Bairoliya

Senior Editor: Storm Mann

Content Development Editor: Nithya Sadanandan

Technical Editor: Gaurav Gala

Copy Editor: Safis Editing

Project Coordinator: Deeksha Thakkar

Proofreader: Safis Editing

Indexer: Rekha Nair

Production Designer: Vijay Kamble

First published: April 2021

Production reference: 3090921

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

978-1-80056-966-9

www.packt.com

I dedicate this book to God, my Guru, to my family, my teachers and tutors, and to my amazing friends for their consistent support and encouragement throughout the writing process.

– Srinjoy Ganguly

I would like to thank Prof. Dr. Martin Vechev for giving me the opportunity to write my Master's thesis at the SRI lab at ETH Zurich, and Benjamin Bichsel for his help on implementing quantum algorithms with Silq.

– Thomas Cambier

Contributors

About the authors

Srinjoy Ganguly is the founder and CEO of AdroitERA, an EdTech firm, and possesses a Master's in quantum computing technology from the Technical University of Madrid, and a Master's in artificial intelligence from the University of Southampton. He has over 4 years' experience in quantum computing and 5 years' experience in machine learning and deep learning. He currently leads the Quantum Machine Learning (QML) study space at QWorld. He has given an expert talk on QML at IEEE SPS. His research interests include QML, Quantum Image Processing, Quantum Natural Language Processing (QNLP), machine learning, and deep learning.

Thomas Cambier is a French programmer and software developer. After studying top-level mathematics, physics, and computer science at Ecole Polytechnique, France's leading engineering school, he obtained a Master's degree in computer science at ETH Zürich on a broad range of subjects going from algorithmics and cryptography to object-oriented programming. Deeply interested in the promising possibilities resulting from quantum computing, he wrote his Master's thesis on the design of quantum algorithms with Silq, a brand-new high-level quantum language created by a research group at ETH Zürich.

About the reviewer

Alberto Maldonado is doing his Ph.D. on QML in computer science at the Center for Computing Research, IPN, Mexico. At his institute, he has collaborated with the Fermilab and CERN research centers for the GeantV project. Alberto has participated in different events, such as Xanadu's Qhack, and was a mentee of QOSF's mentor program. He is passionate about using new technologies and paradigms, such as quantum computing, and is self-taught and diligent.

Table of Contents

Preface

Section 1: Essential Background and Introduction to Quantum Computing

Chapter 1: Essential Mathematics and Algorithmic Thinking

Introducing linear algebra for quantum computing

Vectors and vector spaces

Inner products and norms

Matrices and their operations

The eigenvalues and eigenvectors of an operator

Tensor products

Coordinate systems, complex numbers, and probability

Introducing coordinate systems

Complex numbers and the complex plane

Probability

Defining computational thinking

Decomposition

Pattern recognition

Data representation and abstraction

Introducing computer algorithms

Defining an algorithm

The linear search algorithm

The calculation of the time and space complexity of algorithms

Time and space complexity

Notation for time and space complexity

Calculation and analysis of the complexity of algorithms

Summary

Further reading

Chapter 2: Quantum Bits, Quantum Measurements, and Quantum Logic Gates

Introducing single quantum bits – qubits and superposition of qubits

Learning about the Bra-Ket notation for qubits

Superposition of qubits

Illustrating qubits in different bases

Bloch sphere representation of qubits

The Z basis states — |0> and |1>

The X basis states — and

The Y basis states – and

Introducing quantum measurements

Mathematics of projective measurements

Quantum logic gates

Pauli gates

The Hadamard gate – the quantum H gate

The S gate

The S (S dagger) gate

The T gate – gate

The T (T dagger) gate

The gate

The gate

The gate

Summary

Further reading

Chapter 3: Multiple Quantum Bits, Entanglement, and Quantum Circuits

Introducing multiple quantum bits

The wonder of quantum entanglement

Exploring the Bell states system

Verifying entanglement of quantum states

Exploring multi-qubit quantum logic gates

The quantum CX or CNOT gate

The quantum CZ or CPHASE gate

The quantum SWAP gate

The quantum CCX or CCNOT gate – Toffoli gate

The quantum CSWAP gate – Fredkin gate

Quantum teleportation

Quantum superdense coding

Summary

Chapter 4: Physical Realization of a Quantum Computer

Criteria for quantum computation existence

Depicting quantum information

Unitary transformation capability

Reference initial quantum states preparation

Output measurement capability

Superconducting qubit-based quantum computers

Superconducting qubits

NISQ era

Quantum annealing-based quantum computers

Ion-trap quantum computers

Nuclear magnetic resonance

Optical photonics-based quantum computers

Summary

Further reading

Section 2: Challenges in Quantum Programming and Silq Programming

Chapter 5: Challenges in Quantum Computer Programming

A brief history of classical computers

The challenges of today's classical computers

Understanding the assembly language

HLLs for classical computers

Low-level circuit programming of quantum computers

Introducing quantum programming languages

The IBM Qiskit quantum programming language

The Microsoft Q# quantum programming language

The Google Cirq quantum programming language

The challenges of quantum programming

Summary

Further reading

Chapter 6: Silq Programming Basics and Features

Technical requirements

Introducing Silq and its special features

Introducing Silq

Installing Silq

Installing Microsoft Visual Studio Code

Installing the Silq plugin

Introducing Silq data types

Defining variables in Silq

Control flow in Silq

Functions and iterations in Silq

Introducing Silq annotations

Introducing classical type annotations – !

The qfree annotation

The mfree annotation

The const annotation

The lifted annotation

Simple example programs using Silq

Summary

Further reading

Chapter 7: Programming Multiple-Qubit Quantum Circuits with Silq

Technical requirements

Exploring multi-qubit quantum logic gates in Silq

The quantum CX or CNOT gate

The quantum CZ or CPHASE gate

The quantum SWAP gate

The quantum CCX or CCNOT gate – the Toffoli gate

The quantum CSWAP gate – the Fredkin gate

Constructing quantum circuits with quantum logic gates using Silq

Implementing Bell states in Silq

Decomposing the CX gate

Implementing the GHZ state using Silq

Implementing a classical half adder circuit in Silq

Quantum teleportation

Quantum superdense coding

Summary

Section 3: Quantum Algorithms Using Silq Programming

Chapter 8: Quantum Algorithms I – Deutsch-Jozsa and Bernstein-Vazirani

Technical requirements

Introducing quantum parallelism and interference

Quantum parallelism

Quantum interference

Implementing the Deutsch-Jozsa algorithm

Problem statement

Classical solution

Quantum solution

Silq implementation

Designing a more concise version of the algorithm

Implementing the Bernstein-Vazirani algorithm

Problem statement

Classical solution

Quantum solution

Silq implementation

Summary

Chapter 9: Quantum Algorithms II – Grover's Search Algorithm and Simon's Algorithm

Technical requirements

Introducing search algorithms

Getting started with Grover's search algorithm

Grover's search for one solution using Silq programming

Grover's search for multiple solutions using Silq programming

Mathematical treatment of Grover's search for multiple solutions

Silq implementation of Grover's search for multiple solutions

Grover's search for an unknown number of solutions using Silq programming

Silq implementation of Grover's search for an unknown number of solutions

Introducing Simon's algorithm

The Silq implementation of Simon's algorithm

Summary

Further reading

Chapter 10: Quantum Algorithms III – Quantum Fourier Transform and Phase Estimation

Technical requirements

Introducing the classical Discrete Fourier Transform (DFT)

Exploring the QFT

Implementing the QFT using Silq

Getting started with the phase estimation algorithm

Implementing phase estimation using Silq

Summary

Further reading

Section 4: Applications of Quantum Computing

Chapter 11: Quantum Error Correction

Technical requirements

Introducing classical error correction technique

Redundancy and majority vote

Linear codes

Understanding quantum error correction

Working with bit-flip code

Working with phase-flip code

Working with Shor code

Summary

Chapter 12: Quantum Cryptography – Quantum Key Distribution

Technical requirements

Introducing classical cryptography techniques

The basics of cryptography

Overviewing the main types of encryption algorithms

Understanding quantum key distribution

Describing the quantum key distribution protocol

Implementing the quantum key distribution in Silq

Summary

Chapter 13: Quantum Machine Learning

Introducing classical machine learning

Types of learning

The K-means clustering algorithm

Artificial neural networks

Kernel support vector machines (SVMs)

Getting started with quantum machine learning

Encoding classical data into a quantum state

Kernel-based quantum machine learning models

Learning about the quantum K-means algorithm

Exploring variational circuits

Variational quantum classifier (VQC)

Variational quantum eigensolver (VQE)

Quantum approximate optimization algorithm (QAOA)

The latest developments in the field of quantum machine learning and quantum computing

Summary

Further reading

Why subscribe?

Other Books You May Enjoy

Preface

Quantum computing is an emerging cutting-edge technology that has already started having an impact on various industries, along with academia. Quantum computers have proved that significant speed-ups are possible in different kinds of algorithms over the present classical algorithms. As Moore's law comes to an end, the importance of quantum computers is increasing for various applications, including finance, chemistry, optimization, and many more. One of the major challenges that people in the quantum computing space face is related to low-level circuit programming, which restricts industry and academia from developing quantum applications for deployment.

This book will introduce you to a high-level quantum programming language – Silq. We will utilize Silq to construct quantum circuits on our own, understand and develop important quantum algorithms, and learn about some significant applications of quantum computing, such as quantum error correction, quantum cryptography, and quantum machine learning. You will be learning hands-on Silq programming to understand its unique features, such as more intuitive syntax and automatic uncomputation compared to other quantum programming languages, such as Microsoft Q#.

Who this book is for

This Silq quantum computing book is for students, researchers, and scientists looking to learn quantum computing techniques and high-level quantum programming development. Quantum computing enthusiasts who want to explore this futuristic technology will also find this book useful. Beginner-level knowledge of any programming language, as well as mathematical topics such as linear algebra, probability, complex numbers, and statistics, is required.

What this book covers

Chapter 1, Essential Mathematics and Algorithmic Thinking, provides you with a basic foundational knowledge of mathematics and algorithms.

Chapter 2, Quantum Bits, Quantum Measurements, and Quantum Logic Gates, introduces the basics of quantum bits, measurements, and single-qubit quantum logic gates.

In Chapter 3, Multiple Quantum Bits, Entanglement, and Quantum Circuits, you will explore multiple qubits and their various quantum circuits using single- and multi-qubit quantum gates.

Chapter 4, Physical Realization of a Quantum Computer, takes you through various technologies that will enable you to build a real physical quantum computer.

Chapter 5, Challenges in Quantum Computer Programming, will introduce you to the various challenges faced in quantum programming.

In Chapter 6, Silq Programming Basics and Features, we will introduce Silq and help you to start programming with this high-level quantum programming language.

In Chapter 7, Programming Multiple Qubit Quantum Circuits with Silq, you will learn to tackle multiple qubits in Silq and construct various interesting quantum circuits using Silq.

In Chapter 8, Quantum Algorithms I – Deutsch-Jozsa and Bernstein-Vazirani, you will start coding your very first quantum algorithms using Silq – Deutsch-Jozsa, which identifies whether a function is constant or balanced, and Bernstein-Vazirani, which finds a secret string encoded in a function.

In Chapter 9, Quantum Algorithms II – Grover's Search Algorithm and Simon's Algorithm, you will see how to use Grover's search algorithm for unstructured database search, and Simon's algorithm for finding a hidden string.

In Chapter 10, Quantum Algorithms III – Quantum Fourier Transform and Phase Estimation, you will learn two of the most important algorithms – first, the Quantum Fourier Transform (QFT), which is a technique for linear transformations on qubits. Then you will use the QFT to learn about the quantum phase estimation algorithm.

Chapter 11, Quantum Error Correction, offers an introduction to classical error-correction techniques, and you will learn to implement different quantum error-correcting codes to prevent a potential bit-flip or phase-flip from occurring on a qubit.

In Chapter 12, Quantum Cryptography – Quantum Key Distribution, you will see an overview of classical cryptographical methods and learn to implement in Silq a quantum protocol useful to safely exchange keys: quantum key distribution.

In Chapter 13, Quantum Machine Learning, you will explore some important concepts regarding quantum machine learning and recent developments happening in the field of quantum computing.

To get the most out of this book

You will need the latest version of Microsoft Visual Studio Code installed on your Windows computer.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

After you finish with the book, we recommend you try to solve the challenges hosted by Microsoft Q# using Silq language for more programming practice!

You can find those challenges in the following links:

Microsoft coding contest 2018: https://codeforces.com/contest/1002/Microsoft coding contest 2019: https://codeforces.com/contest/1116/Some of the challenges, solved using Silq, have been given in the Silq documentation: https://silq.ethz.ch/examples

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Quantum-Computing-with-Silq-Programming. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781800569669_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "In the second line, the coerce keyword forces the secret string to be a classical unsigned integer on four qubits."

A block of code is set as follows:

def scal[n:!ℕ](const x:uint[n], const y:uint[n])qfree:uint[n] {

  count := 0:uint[n];

  for k in [0..n) {

    count += x[k] && y[k];

  }

  return count;

}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

def scal[n:!ℕ](const x:uint[n], const y:uint[n])qfree:uint[n] {

  count := 0:uint[n];

  for k in [0..n) {

    count += x[k] && y[k];

  }

  return count;

}

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "In the world of quantum computing we use the term qubit or quantum bit to represent the bits."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

Section 1: Essential Background and Introduction to Quantum Computing

This part deals with the mathematical prerequisites that are essential for understanding quantum computing and the challenges faced by users who perform quantum programming in their daily lives. The construction of a real quantum computer will also be touched upon briefly. After completing this part, you will feel confident in your mathematical abilities and understand the challenges faced by the quantum computing community.

This section comprises the following chapters:

Chapter 1, Essential Mathematics and Algorithmic ThinkingChapter 2, Quantum Bits, Quantum Measurements, and Quantum Logic GatesChapter 3, Multiple Quantum Bits, Entanglement, and Quantum CircuitsChapter 4, Physical Realization of a Quantum Computer