Programming with Quantum Mechanics
Evandro C. R. da Rosa
Quantuloop
Claudio Lima
Quantuloop
Abstract—Quantum computing is an emerging paradigm that
opens a new era for exponential computational speedup. Still,
quantum computers have yet to be ready for commercial use.
However, it is essential to train and qualify today the workforce
that will develop quantum acceleration solutions to get the
quantum advantage in the future. This tutorial gives a broad view
of quantum computing, abstracting most of the mathematical
formalism and proposing a hands-on with the quantum pro-
gramming language Ket. The target audience is undergraduate
and graduate students starting in quantum computing – no
prerequisites for following this tutorial.
Index Terms—quantum computation, quantum programming,
quantum simulation
CONTENTS
I Introduction 1
II Setup 2
III Quantum Bits 2
III-A Bloch Sphere . . . . . . . . . . . . . . 2
III-B Qubits in Ket . . . . . . . . . . . . . . 3
IV Quantum Gates 3
IV-A Pauli Gates . . . . . . . . . . . . . . . . 4
IV-B Rotation Gates . . . . . . . . . . . . . . 4
IV-C Hadamard Gate . . . . . . . . . . . . . 4
IV-D Phase Gate . . . . . . . . . . . . . . . . 4
IV-E Entanglement and Controlled Gates . . 4
IV-F Inverse Quantum Gate . . . . . . . . . . 5
V Quantum Measurement 6
V-A Ket Runtime Architecture . . . . . . . . 6
V-B Measuring Entangled Qubits . . . . . . 7
VI Quantum Computer vs. Simulator 7
VII Final Considerations 8
References 8
I. INTRODUCTION
Quantum computing opens up new ways for processing
information, solving in a few minutes problems that would
take decades for a classical computer to find the solution. This
claim was known in theory for a long time. Now we begin to
see the first quantum computers that outperform classical ones.
This tutorial walks through some quantum mechanics concepts
with the eyes of quantum computing, demonstrating how to
use them to program a quantum application.
The idea of quantum computers dates back to the 80s when
Richard Feynman proposed a quantum computer as a universal
quantum simulator. His motivation was the difficulty of simu-
lating quantum systems in classical computers, a problem with
a time complexity that grows exponentially with the number of
variables. The proof that quantum computers can significantly
increase processing power came in the late 90s with the work
of Peter Shor. His integer factorization algorithm, known as
Shor’s algorithm, reveals how to solve a problem that tokens
exponential time in a classical computer in polynomial time
with the help of a quantum computer.
Shor’s algorithm boosted the development of quantum com-
puters and uplifted the creation of post-quantum cryptography.
A research field to find quantum-resistant alternatives for
today’s standard public-key cryptography algorithms since
Shor’s algorithm breaks all of them. While this may sound
alarming, the industry still lacks powerful quantum computers
to break a standard cryptography scheme. Moreover, NIST
is working to standardize new quantum-resistant asymmetric
encryption algorithms.
Quantum computers can speed up several processes, in-
cluding but not limited to optimization, logistics, machine
learning, and quantum chemistry simulation. However, we
are in the Noisy Intermediate-Scale Quantum (NISQ) era,
with quantum computers featuring few qubits very susceptible
to noise that limits the complexity of quantum executions.
Although, we went further than was expected 20 years ago,
even reaching the quantum advantage milestone with quantum
computers outperforming classical ones for some tasks. The
task, in this case, is not solving any real-world problem. It
is just a trial projected specifically for the quantum advantage
demonstration. However, we are not far from large-scale fault-
tolerant quantum computers, being on the roadmap of many
companies to deliver them by the end of the decade (until
2030).
Quantum engineers are a highly in-demand workforce today,
even though we have not yet unlocked the full potential of
quantum computing. We expect this demand to grow in the
foreseeable future. A new domain that comes with the growth
of quantum technologies is the quantum developer, profes-
sionals who adapt solutions to take advantage of quantum
computers and programming quantum applications.
Adapting and developing quantum algorithms is not a
straightforward process. Although, quantum programming is
not as hard as one may think. It is much like classical pro-
gramming. This tutorial will discuss the main characteristics
of quantum computing, demonstrating how to express it in the
arXiv:2210.15506v1 [quant-ph] 27 Oct 2022