How To Code For Quantum Computers
()
About this ebook
Related to How To Code For Quantum Computers
Related ebooks
Quantum Algorithms in Action: A Practical Guide to Implementation with Qiskit Rating: 0 out of 5 stars0 ratingsQuantum Computing Neuroscience Rating: 0 out of 5 stars0 ratingsQuantum Computing and Communications: An Engineering Approach Rating: 0 out of 5 stars0 ratingsWhat's This Thing Called A Quantum Computer? Rating: 0 out of 5 stars0 ratingsWhat’s This Thing Called A Quantum Computer? Rating: 0 out of 5 stars0 ratingsQuantum Internet: A Simple Guide to Big Ideas Rating: 0 out of 5 stars0 ratingsQuantum Computing: Computer Science, Physics, And Mathematics Rating: 0 out of 5 stars0 ratingsQuantum Bits (Qubits) Rating: 0 out of 5 stars0 ratingsMastering Quantum Programming with Qiskit: A Practical Guide Rating: 0 out of 5 stars0 ratingsQuantum Magic - 101 Rating: 0 out of 5 stars0 ratingsFrom Bits to Qubits: A Computer Engineer's Journey Rating: 0 out of 5 stars0 ratingsQuantum Horizon Rating: 0 out of 5 stars0 ratingsQuantum Mechanics 5: Entanglement, EPR, Teleportation, & Advanced Topics Rating: 4 out of 5 stars4/5Quantumania is Real: Here is What You Need to Know Rating: 0 out of 5 stars0 ratingsHawking Radiation 3 Rating: 0 out of 5 stars0 ratingsCritical Thinking² - A Force Multiplier Rating: 0 out of 5 stars0 ratingsQuantum Computing for Beginners: Unlocking the Next Tech Frontier Rating: 0 out of 5 stars0 ratingsQuantum Computer Vs Traditional Computer Rating: 0 out of 5 stars0 ratingsQuantum Computing: Fundamental Principles of Quantum Computing Systems Rating: 0 out of 5 stars0 ratingsQuantum Physics For Dummies Rating: 0 out of 5 stars0 ratingsIntroduction to Quantum Computing & Machine Learning Technologies: 1, #1 Rating: 0 out of 5 stars0 ratingsOops we Broke Reality - A Guide to Quantum Computing Rating: 0 out of 5 stars0 ratingsQuantum Computing Rating: 0 out of 5 stars0 ratingsLearning Quantum Computing Rating: 4 out of 5 stars4/5The Quantum Revolution - Exploring the World of Quantum Computing Rating: 0 out of 5 stars0 ratingsSoft Computing: Fundamentals and Applications Rating: 0 out of 5 stars0 ratingsHadamard Transform: Unveiling the Power of Hadamard Transform in Computer Vision Rating: 0 out of 5 stars0 ratingsQuantum Physics for Beginners: An Easy Guide for Discovering the Hidden Side of Reality one Speck at a Time Rating: 0 out of 5 stars0 ratingsQuantum Mechanics 4: Spin, Lasers, Pauli Exclusion & Barrier Penetration Rating: 3 out of 5 stars3/5Beyond Weird: Why Everything You Thought You Knew about Quantum Physics Is Different Rating: 4 out of 5 stars4/5
Computers For You
The Self-Taught Computer Scientist: The Beginner's Guide to Data Structures & Algorithms Rating: 0 out of 5 stars0 ratingsElon Musk Rating: 4 out of 5 stars4/5Storytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsThe Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution Rating: 4 out of 5 stars4/5Fundamentals of Programming: Using Python Rating: 5 out of 5 stars5/5Computer Science I Essentials Rating: 5 out of 5 stars5/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Mindhacker: 60 Tips, Tricks, and Games to Take Your Mind to the Next Level Rating: 4 out of 5 stars4/5Technical Writing For Dummies Rating: 0 out of 5 stars0 ratingsUX/UI Design Playbook Rating: 4 out of 5 stars4/5Becoming a Data Head: How to Think, Speak, and Understand Data Science, Statistics, and Machine Learning Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsCompTia Security 701: Fundamentals of Security Rating: 0 out of 5 stars0 ratingsThe Musician's Ai Handbook: Enhance And Promote Your Music With Artificial Intelligence Rating: 5 out of 5 stars5/5ITIL Foundation Essentials ITIL 4 Edition - The ultimate revision guide Rating: 5 out of 5 stars5/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Quantum Computing For Dummies Rating: 3 out of 5 stars3/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5
Related categories
Reviews for How To Code For Quantum Computers
0 ratings0 reviews
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.
ImagemI 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