Programming with Quantum Mechanics Evandro C. R. da Rosa QuantuloopClaudio Lima

2025-05-02 0 0 692.71KB 8 页 10玖币
侵权投诉
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
quantum programming language Ket. We will present a broad
view of the topic, which may help one take the first steps in
quantum development.
Ket is an embedded programming language that introduces
the ease of Python to quantum programming, letting anyone
quickly prototype and test quantum applications. We expect
the reader following this tutorial to be familiar with Python
programming and Jupyter notebook. We will introduce quan-
tum programming focusing on digital qubit-based quantum
computing, a general-purpose quantum computation model
used by several companies, including IBM, Google, and
Microsoft.
II. SETUP
We will present some examples that one can try on their
computer. There are several ways one can execute a Ket
program. Regardless, using Google Colab is the most straight-
forward approach, allowing one to create and run Ket applica-
tions on any computer quickly. However, feel free to use any
method. Get started by going to the Colab website, creating a
new notebook, and running the command presented in Listing
1. See Ket’s project website1for more ways to get Ket. Try
running the example from Listing 2 to test if it works. It should
output similarly as Fig. 1.
!pip install ket-lang qutip -q
from ket import *
Listing 1: Installing and importing Ket on a Jupyter notebook.
Figure 1: Running Ket on Google Colab.
Listing 2 allocates two qubits, uses a Hadamard gate to
create superposition, a controlled gate to entangle both qubits,
and prints the quantum state on the screen. Do not worry if
some of those terms seem unfamiliar; this tutorial will explain
all those concepts, presenting how to use them in quantum
programming.
1https://quantumket.org
1>>> from ket import *
2>>> a,b=quant(2)
3>>> H(a)
4>>> cnot(a, b)
5>>> print(dump(a+b).show())
6|00(50.00%)
70.707107
=1/2
8|11(50.00%)
90.707107
=1/2
Listing 2: Preparing and printing a Bell state.
III. QUANTUM BITS
Quantum computers store information in quantum bits,
aka qubits, the quantum analog for the classical bit. As its
classical counterpart, a qubit has two possible values, 0 and
1, or using the Dirac notation, |0iand |1i, known as the
computational basis. A qubit can store classical or quantum
information since it can simultaneously be in one or both
states, a phenomenon known as quantum superposition. As
for classical bits, the number of states in a set of bits grows
exponentially with the number of bits, e.g., with 32-bits, one
can express a single unsigned integer between 0 and 232 1,
which is also true for qubits. However, with 32-qubits, one
can simultaneously represent all unsigned integers between 0
and 232 1. The amount of memory a quantum computer
have grows exponentially with the number of qubits, which
is equivalent to saying that the number of bits needed to
represent a qubit set grows exponentially with the set length.
Fig. 2 geometrically illustrate this exponential memory growth,
displaying how much data the same number of qubits and bits
can store.
One can represent a qubit in superposition as a linear combi-
nation of the computational basis states, with an arbitrary qubit
|ψidefined as α|0i+β|1i. The numbers αand β, known as
the probability amplitude, weigh the probability of measuring a
basis state. We will talk more about measurement later. Those
are complex numbers with the restriction of |α|2+|β|2= 1.
Generalizing for more qubits, one can represent n-qubits as
Pkαk|ki, where Pk|α|2= 1.
Quantum mechanics limits how one can modify the state
of qubits. For instance, every quantum operation must be
reversible except for measurement, meaning there is no loss
of information during quantum computation. Reversibility is
not necessary for classical computers. We will discuss this in
the next section.
Another limitation of quantum computers is the impos-
sibility of copying a quantum state. Nonetheless, quantum
information explores this characteristic to offer communication
protocols physically secured against eavesdropping.
A. Bloch Sphere
We can picture every possible single-qubit state in the
Bloch sphere. This geometric representation helps visualize
the quantum superposition and single-qubit operation. In the
摘要:

ProgrammingwithQuantumMechanicsEvandroC.R.daRosaQuantuloopClaudioLimaQuantuloopAbstract—Quantumcomputingisanemergingparadigmthatopensaneweraforexponentialcomputationalspeedup.Still,quantumcomputershaveyettobereadyforcommercialuse.However,itisessentialtotrainandqualifytodaytheworkforcethatwilldevelop...

展开>> 收起<<
Programming with Quantum Mechanics Evandro C. R. da Rosa QuantuloopClaudio Lima.pdf

共8页,预览2页

还剩页未读, 继续阅读

声明:本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。玖贝云文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知玖贝云文库,我们立即给予删除!
分类:图书资源 价格:10玖币 属性:8 页 大小:692.71KB 格式:PDF 时间:2025-05-02

开通VIP享超值会员特权

  • 多端同步记录
  • 高速下载文档
  • 免费文档工具
  • 分享文档赚钱
  • 每日登录抽奖
  • 优质衍生服务
/ 8
客服
关注