Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

How To Code For Quantum Computers
How To Code For Quantum Computers
How To Code For Quantum Computers
Ebook287 pages1 hour

How To Code For Quantum Computers

Rating: 0 out of 5 stars

()

Read preview

About this ebook

As quantum computing rapidly evolves, professionals and tech enthusiasts are seeking ways to stay ahead of the curve. Traditional programming knowledge isn’t enough, and understanding quantum computing concepts is becoming essential for future tech leaders. However, many find learning quantum computing intimidating due to its complexity, lack of clear resources, and steep learning curve. Existing materials are either too theoretical or overly technical, making it difficult to get started. Without the right guide, aspiring developers risk falling behind in a field that will soon revolutionize industries. Missing out on understanding quantum programming could mean losing competitive advantage in tech-driven careers. How to code for Quantum Computers offers a clear, step-by-step approach, breaking down complex concepts into manageable, practical examples. With Cirq code examples and hands-on projects, this book empowers readers to master quantum programming, opening doors to cutting-edge opportunities and career advancements, it do this using three classic algorithms, Deutsch–Jozsa, Grover, and Shor as a foundation for study, along with the famous quantum teleportation protocol, taking care of starting from basic concepts such as qubits and gates and circuit. The complete source codes for sample programs using Cirq from Google Research and Python on Jupyter Notebook are available in a public Bitbucket repository.
LanguageEnglish
PublisherClube de Autores
Release dateOct 20, 2024
How To Code For Quantum Computers

Related to How To Code For Quantum Computers

Related ebooks

Computers For You

View More

Related categories

Reviews for How To Code For Quantum Computers

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    How To Code For Quantum Computers - Nivio Dos Santos

    How to code for Quantum Computers

    First Edition

    By: Nívio dos Santos

    Copyright © 2024 Nívio dos Santos

    ISBN nº 978-65-01-17239-2

    My dearest Fátima, your unwavering support and belief in me have been the driving force behind this book. Thank you for encouraging me to pursue my dreams and for always being there to celebrate my victories, no matter how small. Your love and encouragement have made all the difference.

    Quantum mechanics is what you would inevitably come up with if you started from probability theory, and then said, let's try to generalize it so that the numbers we used to call probabilities can be negative numbers. As such, the theory could have been invented by mathematicians in the 19th century without any input from experiment. It wasn't, but it could have been.

    by Scott Aaronson

    Table of Contents

    Chapter 1

    Introduction to Quantum Computing

    Required background

    Code examples

    Cirq

    Conventional Bit vs Qubit

    Double-slit experiment

    Bra Ket Notation

    Probabilities

    What Are Complex Numbers?

    Why are amplitudes complex Numbers?

    Quick view in a Qubit

    What more?

    Real-Valued vs. Complex-Valued Quantum Theories

    Quantum Entanglement

    Entanglement Exchange Experiment

    Navascués' Proposal

    Conclusion about Complex Numbers

    Unitary matrix

    Chapter 2

    Visual representation

    Bloch Sphere

    Where does this equation come from?

    Circle Notation

    Circle Notation for multi-Qubit scenarios

    Choosing the Right Tool

    Chapter 3

    Qubits and Quantum Gates

    Basic Gates with a single Qubit

    The Identity Gate

    Pauli Gates - Pauli X

    Pauli Gates - Pauli Y

    Pauli Gates - Pauli Z

    Hadamard Gate

    Phase Gate

    RXGate

    RYGate

    Read/Measurement

    Get down to business:

    Notation used with Google Cirq

    Code example to achieve a specific state |Ψ>

    Gates for Multiple Qubits

    CNOT Gate

    Bell States

    Investigating |Θ+> Bell state

    Toffoli - CCNOT

    CPhase and CZ

    Phase KickBack

    SWAP

    Combining Gates

    Chapter 4

    Quantum Teleportation

    Short fictional story

    The Teleportation Process

    The Math Behind this Quantum Teleportation

    Sending/modulating

    Receiving/demodulating

    Conclusion

    Chapter 5

    Deutsch–Jozsa algorithm

    Steps of the algorithm

    Algorithm examples

    Balanced function with 3 Qubits (n=3)

    Constant function with 3 Qubits (n=3)

    The Math Behind Deutsch–Jozsa algorithm

    Scenario when f(x) is a constant function.

    Scenario when f(x) is a balanced function.

    Conclusion

    Chapter 6

    Grover algorithm

    Algorithm Summary

    Understanding the algorithm

    Let's start with the problem definition

    Additional Definitions

    Starting algorithm analysis

    Initializing

    Oracle phase flip

    Grover Diffusion Operator

    Conclusion

    Chapter 7

    Shor Algorithm I

    Fundamental mathematics

    The structure of our algorithm

    The quantum portion of our algorithm

    Chapter 8

    Quantum Fourier Transform

    Discrete Fourier Transform (DFT)

    Quantum Fourier Transform (QFT)

    Quantum Fourier Transform Circuit

    Exemplifying QFT with 1 Qubit

    Exemplifying QFT with 2 Qubits

    Exemplifying QFT with 4 Qubits

    Conclusion

    Chapter 9

    Quantum Phase Estimation

    Concept

    Phase Representation

    Quantum phase estimation

    The quantum phase estimation circuit example

    Conclusion

    Chapter 10

    Shor Algorithm II

    From QPE to Order Finding

    QPE

    Order-finding

    Explaining the operator Ux = |gx mod N>

    Using the operator Ux = |gx mod N>

    Example of Shor's Algorithm: N = 15, g = 7

    Building Ux = |7x mod 15>

    Analyzing Order Finding for N=15 and g = 7

    Applying the invQFT operation

    For those curious, where is e²π i j/² ?

    Conclusion

    Chapter 11

    Concluding thoughts

    We're off and running, now what?

    My Inspiration

    It's time to say see you later

    Appendix

    XOR - ⊕

    The notation X ∈ {0,1}n

    HAD|X>´s alternative mathematical expression

    Sum of the bitwise product

    Grover’s Oracle Flip Phase

    Number of Grover’s Iterations

    GCD Euclidean algorithm

    Unitarity of the QFT

    References

    Chapter 1


    Introduction to Quantum Computing

    This introduction is inspired by the article written by Scott Aaronson, so I will not write about the history of computers, from the abacus to current computers, but instead starts directly from the core, going to the central point from probabilities (only positive number) to amplitudes (that can be positive, negative until complex number) since quantum mechanics is a highly accurate mathematical model with concepts such as probability and superposition that emerges from observations and experiments of the strange world of atoms and subatomic particles.

    Required background

    This material assumes familiarity with some foundational mathematical concepts:

    Mathematical functions: Understanding how functions operate on inputs to produce outputs.

    Trigonometry: Knowledge of sine, cosine, tangent, and their applications in angles and relationships;

    Matrices: The ability to work with matrices, including operations like addition, multiplication, and transposition;

    Number systems: Comfort with converting between binary, decimal, and hexadecimal representations of numbers;

    Complex numbers: An understanding of numbers with both real and imaginary components. Having a grasp of these concepts will be beneficial in following the discussions and code examples presented.

    Code examples

    The complete source codes for the sample programs can be found in a public Bitbucket repository. While I won't be including the code directly in this book, there are a few reasons for this decision.

    Length: The code spans multiple pages, which can disrupt the flow of reading and make it difficult to follow the concepts being explained;

    Formatting: Code displays differently in print than in its original programming environment, which can affect readability.

    I believe it's more beneficial to focus on the key concepts and functionalities of the programs rather than getting bogged down in the specifics of the code.

    However, if you'd like to explore the code in more detail, you can access it through the following location:

    Bitbucket Repository: https://bitbucket.org

    Source Path:/Nivio/htcfqc/src/main/

    These sample programs are implemented in Python, utilizing the Cirq framework within a Jupyter Notebook environment. A basic understanding of Python and Jupyter Notebook will be helpful in following the code.

    Cirq

    Cirq is an open-source quantum computing framework developed by Google, designed to help developers create, simulate, and run quantum circuits on near-term quantum computers. It provides tools to build and manipulate quantum circuits, optimize them, and simulate their execution on classical computers.

    Imagem

    I have chosen it because, as one of the leading frameworks, it aligns perfectly with my other passion, machine learning. My decision was largely influenced by the fact that Google developed TensorFlow Quantum (TFQ), a library that bridges the gap between quantum computing and classical machine learning by integrating TensorFlow's deep learning strengths with Cirq's quantum circuit design and simulation capabilities. Attention, while quantum machine learning isn't one subject of this book, using a framework like Cirq can

    Enjoying the preview?
    Page 1 of 1