forked from ellisonbg/sympy-qcpaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qcpaper.tex
532 lines (409 loc) · 19.8 KB
/
qcpaper.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
%% ****** Start of file apstemplate.tex ****** %
%%
%%
%% This file is part of the APS files in the REVTeX 4 distribution.
%% Version 4.1r of REVTeX, August 2010
%%
%%
%% Copyright (c) 2001, 2009, 2010 The American Physical Society.
%%
%% See the REVTeX 4 README file for restrictions and more information.
%%
%
% This is a template for producing manuscripts for use with REVTEX 4.0
% Copy this file to another name and then work on that file.
% That way, you always have this original template file to use.
%
% Group addresses by affiliation; use superscriptaddress for long
% author lists, or if there are many overlapping affiliations.
% For Phys. Rev. appearance, change preprint to twocolumn.
% Choose pra, prb, prc, prd, pre, prl, prstab, prstper, or rmp for journal
% Add 'draft' option to mark overfull boxes with black boxes
% Add 'showpacs' option to make PACS codes appear
% Add 'showkeys' option to make keywords appear
\documentclass[aps,pra,groupedaddress,amsmath,reprint]{revtex4-1}
%\documentclass[aps,prl,preprint,superscriptaddress]{revtex4-1}
%\documentclass[aps,prl,reprint,groupedaddress]{revtex4-1}
% You should use BibTeX and apsrev.bst for references
% Choosing a journal automatically selects the correct APS
% BibTeX style file (bst file), so only uncomment the line
% below if necessary.
%\bibliographystyle{apsrev4-1}
\usepackage{verbatim}
\usepackage[utf8]{inputenc}
\begin{document}
% Use the \preprint command to place your local institutional report
% number in the upper righthand corner of the title page in preprint mode.
% Multiple \preprint commands are allowed.
% Use the 'preprintnumbers' class option to override journal defaults
% to display numbers if necessary
%\preprint{}
%Title of paper
\title{The symbolic simulation and manipulation of quantum circuits}
% repeat the \author .. \affiliation etc. as needed
% \email, \thanks, \homepage, \altaffiliation all apply to the current
% author. Explanatory text should go in the []'s, actual e-mail
% address or url should go in the {}'s for \email and \homepage.
% Please use the appropriate macro foreach each type of information
% \affiliation command applies to all authors since the last
% \affiliation command. The \affiliation command should follow the
% other information
% \affiliation can be followed by \email, \homepage, \thanks as well.
\author{Addison Cugini}
\affiliation{Apple Computer, Cupertino, CA}
\author{Matt Curry}
\affiliation{Department of Physics, University of New Mexico, Albuquerque, NM 87131, USA}
\author{Raymond Wong}
\affiliation{Department of Computer Science, California Polytechnic State University, San Luis Obispo, CA 93407, USA}
\author{Austen Greene}
\affiliation{Department of Physics, California Polytechnic State University, San Luis Obispo, CA
93407, USA}
\author{Brian E. Granger}
\email[]{[email protected]}
\affiliation{Department of Physics, California Polytechnic State University, San Luis Obispo, CA 93407, USA}
%Collaboration name if desired (requires use of superscriptaddress
%option in \documentclass). \noaffiliation is required (may also be
%used with the \author command).
%\collaboration can be followed by \email, \homepage, \thanks as well.
%\collaboration{}
%\noaffiliation
\date{\today}
\begin{abstract}
The simulation of quantum computers and quantum information systems on
classical computers is an important part of quantum information science. With
such simulations, algorithms can be developed and tested, experiments can be
validated and insight can be gained about the foundations of quantum
information. We have developed an open source software package for simulating
quantum computers symbolically using a computer algebra system, SymPy. The
symbolic manipulation of gates and circuits has many advantages over the
traditional numerical approach where gates and qubits are represented as large
matrices and vectors. In this work, we introduce the software, describe its
features through examples and outline the advantages of this approach.
\end{abstract}
% insert suggested PACS numbers in braces on next line
\pacs{}
% insert suggested keywords - APS authors don't need to do this
%\keywords{}
%\maketitle must follow title, authors, abstract, \pacs, and \keywords
\maketitle
% body of paper here - Use proper section commands
% References should be done using the \cite, \ref, and \label commands
\section{Introduction}
% Put \label in argument of \section for cross-referencing
%\section{\label{}}
\section{Foundations}
\subsection{SymPy}
SymPy \cite{sympy} is a Python library for symbolic mathematics. It aims to
become a full-featured computer algebra system (CAS) while keeping the code as
simple as possible in order to be comprehensible and easily extensible. SymPy
is written entirely in Python and does not require any external libraries.
SymPy was started in 2005 by Ondřej Čertík and it now has an active community
of over 100 developers contributing to it. SymPy is BSD licensed and anyone
can easily contribute new features and algorithms by submitting a GitHub pull
request. SymPy has been periodically participating in the Google Summer of
Code (25 students in 5 years) and the quantum computing module has started as
one such project as well.
In this paragraph we will give an overview of SymPy's capabilities, probably
in the form of a bulleted list.
In this paragraph we will describe the latex printing support in SymPy and how
that can be used in conjunction with SymPy Live or IPython to get nicely
formatted output. We should emphasize the fact that all latex formulas in this
paper were autogenerated by SymPy.
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
We now show a few examples of SymPy's capabilities to show its usefulness as a
general computer algebra system.
In SymPy symbols have to be created explicitely. Here we create the symbols
($x$, $y$, $z$):
\begin{verbatim}
x, y, z = symbols("x y z")
\end{verbatim}
Once these symbols have been created, symbolic expressions can be created and
manipulated. Here is an example involving a rational number, $\pi$, $i$, $e$ and
basic arithmetic operations:
\begin{verbatim}
Rational(3,2)*pi+exp(I*x) / (x**2+y)
\end{verbatim}
$$\frac{3}{2} \pi + \frac{e^{\mathbf{\imath} x}}{x^{2} + y}$$
Expressions can be evaluated numerically using SymPy's arbitrary precision
arithmetic algorithms:
\begin{verbatim}
exp(pi*sqrt(163)).evalf(35)
\end{verbatim}
$$262537412640768743.99999999999925007$$
Here is an example of expanding and refactoring a polynomial:
\begin{verbatim}
((x+y)**2*(x+1)).expand()
\end{verbatim}
$$x^{3} + 2 x^{2} y + x^{2} + x y^{2} + 2 x y + y^{2}$$
\begin{verbatim}
factor(_)
\end{verbatim}
$$\left(x + 1\right) \left(x + y\right)^{2}$$
Derivatives can be taken of expressions:
\begin{verbatim}
diff(cos(x**2)**2/(1+x), x)
\end{verbatim}
$$- 4 \frac{x \operatorname{sin}\left(x^{2}\right) \operatorname{cos}\left(x^{2}\right)}{x + 1} - \frac{\operatorname{cos}^{2}\left(x^{2}\right)}{\left(x + 1\right)^{2}}$$
We emphasize that these examples are merely representative of its vast
capabilities. We encourage the reader to consult the SymPy documentation for a
more complete set of examples.
Python is an object oriented language and SymPy leverages that to build reusable
objects for symbolic mathematics. Internally, SymPy creates instances of these
objects and stores them in an expression tree. In this example, we construct a
simple expression and then display its expression tree and SymPy objects using
the \verb:srepr: function:
\begin{verbatim}
e = x + 2*y
srepr(e)
\end{verbatim}
\begin{verbatim}
Add(Symbol('x'), Mul(Integer(2), Symbol('y')))
\end{verbatim}
This combination of object orientation and expression trees makes SymPy easily
extensible; once new objects are created they can immediately be used in
arbitrary expressions.
%#############################################################################
\subsection{Symbolic Dirac notation}
Dirac's bra-ket notation has become the standard way of expressing the
mathematics of quantum mechanics. This notation is concise, powerful and
flexible. We have implemented this notation in SymPy in its most general form.
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
\subsubsection{Bras and kets}
Symbolic kets can be created using the \verb:Ket: class as seen here:
\begin{verbatim}
phi, psi = Ket('phi'), Ket('psi')
\end{verbatim}
These ket instances are fully symbolic and behave exactly like the corresponding
mathematical entities. For example, one can form a linear combination using
addition and scalar multiplication:
\begin{verbatim}
alpha = Symbol('alpha', complex=True)
beta = Symbol('beta', complex=True)
state = alpha*psi + beta*phi; state
\end{verbatim}
$$\alpha {\left|\psi\right\rangle } + \beta {\left|\phi\right\rangle }$$
Bras can be created using the \verb:Bra: class directly or by using the
\verb:Dagger: class on an expression involving kets:
\begin{verbatim}
ip = Dagger(state)*state; ip
\end{verbatim}
$$\left(\overline{\alpha} {\left\langle \psi\right|} + \overline{\beta} {\left\langle \phi\right|}\right) \left(\alpha {\left|\psi\right\rangle } + \beta {\left|\phi\right\rangle }\right)$$
Because this is a standard SymPy expression, we can use standard SymPy functions
and methods for manipulating expression. Here we use expand to multiply this
expression out, followed by \verb:qapply: which identifies inner and outer
products in an expression.
\begin{verbatim}
qapply(expand(ip))
\end{verbatim}
$$\alpha \overline{\alpha} \left\langle \psi \right. {\left|\psi\right\rangle } + \alpha \overline{\beta} \left\langle \phi \right. {\left|\psi\right\rangle } + \beta \overline{\alpha} \left\langle \psi \right. {\left|\phi\right\rangle } + \beta \overline{\beta} \left\langle \phi \right. {\left|\phi\right\rangle }$$
\subsubsection{Operators}
SymPy also has a full set of classes for handling symbolic operators. Here we
create three operators, one of which is hermitian:
\begin{verbatim}
A = Operator('A')
B = Operator('B')
C = HermitianOperator('C')
\end{verbatim}
When used in arithmetic expressions SymPy knows that operators do not commute
under multiplication/composition as is seen by expanding a polynomial of
operators:
\begin{verbatim}
expand((A+B)**2)
\end{verbatim}
$$A B + \left(A\right)^{2} + B A + \left(B\right)^{2}$$
Commutators of operators can also be created:
\begin{verbatim}
comm = Commutator(A*B,B+C); comm
\end{verbatim}
$$\left[A B,C + B\right]$$
The \verb:expand: function has custom logic for expanding commutators using
standard commutator relations:
\begin{verbatim}
comm.expand(commutator=True)
\end{verbatim}
$$- \left[C,A\right] B + \left[A,B\right] B - A \left[C,B\right]$$
Any commutator can be performed ($[A,B]\rightarrow AB-BA$) using the \verb:doit:
method:
\begin{verbatim}
_.doit().expand()
\end{verbatim}
$$- C A B + A B C + A \left(B\right)^{2} - B A B$$
The \verb:Dagger: class also works with operators and is aware of the properties
of unitary and hermitian operators:
\begin{verbatim}
Dagger(_)
\end{verbatim}
$$- B^{\dagger} A^{\dagger} B^{\dagger} - B^{\dagger} A^{\dagger} C + \left(B^{\dagger}\right)^{2} A^{\dagger} + C B^{\dagger} A^{\dagger}$$
\subsubsection{Tensor products}
Symbolic tensor products of operators and states can also be created and
manipulated:
\begin{verbatim}
op = TensorProduct(A,B+C)
state = TensorProduct(psi,phi)
op*state
\end{verbatim}
$${A}\otimes \left({C + B}\right) {{\left|\psi\right\rangle }}\otimes {{\left|\phi\right\rangle }}$$
Once a tensor product has been created, it can be simplified,
\begin{verbatim}
tensor_product_simp(_)
\end{verbatim}
$$\left({A {\left|\psi\right\rangle }}\right)\otimes \left({\left(C + B\right) {\left|\phi\right\rangle }}\right)$$
and expanded:
\begin{verbatim}
expand(_)
\end{verbatim}
$$\left({A {\left|\psi\right\rangle }}\right)\otimes \left({C {\left|\phi\right\rangle } + B {\left|\phi\right\rangle }}\right)$$
%#############################################################################
As we have developed the Dirac notation in SymPy, we have tried to balance
mathematical formality with ease of use. For example, all bras, kets and
operators internally track what Hilbert space they are associated with,
but we do not require users to deal with this layer unless they need to.
An important aspect of quantum mechanics is the representation of operators
and states in different bases. We have developed a framework that allows any
operator or state to declare its representation in any number of different
bases. This logic is handled through a single \verb:represent: function that
handles both discrete and continuous Hilbert spaces. Its usage will be
illustrated below for qubits and gates.
We have also implemented completely general logic for declaring how operators
act on states, which is handled through the \verb:qapply: function ("quantum
apply"). We emphasize that the application of operators to states is fully
symbolic and does not in any way depend on representing those operators or
states in a particular basis. In the context of quantum computing, this means
that we can apply gates to qubits without representing them as large matrices.
The symbolic Dirac notation built into SymPy provides a solid foundation, upon
which a wide range of quantum mechanical systems can be implemented. In
addition to the quantum computing capabilities described below, we have also
implemented quantum angular momentum and the second quantized approach to many
body quantum theory using it. We now turn to describe the details of
how we have used it to build a general tool for simulating quantum computers.
\section{Symbolic computing computing}
\subsection{Qubits}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Gates}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Density matrix}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\section{Algorithms and examples}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Quantum Fourier transform}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Grover's Algorithm}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Teleportation}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Dense coding}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Heisenberg limited measurement}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
\subsection{Quantum error correction}
%#############################################################################
% Autogenerated content, please edit the notebooks, export to .tex and paste
%#############################################################################
%#############################################################################
% If in two-column mode, this environment will change to single-column
% format so that long equations can be displayed. Use
% sparingly.
%\begin{widetext}
% put long equation here
%\end{widetext}
% figures should be put into the text as floats.
% Use the graphics or graphicx packages (distributed with LaTeX2e)
% and the \includegraphics macro defined in those packages.
% See the LaTeX Graphics Companion by Michel Goosens, Sebastian Rahtz,
% and Frank Mittelbach for instance.
%
% Here is an example of the general form of a figure:
% Fill in the caption in the braces of the \caption{} command. Put the label
% that you will use with \ref{} command in the braces of the \label{} command.
% Use the figure* environment if the figure should span across the
% entire page. There is no need to do explicit centering.
% \begin{figure}
% \includegraphics{}%
% \caption{\label{}}
% \end{figure}
% Surround figure environment with turnpage environment for landscape
% figure
% \begin{turnpage}
% \begin{figure}
% \includegraphics{}%
% \caption{\label{}}
% \end{figure}
% \end{turnpage}
% tables should appear as floats within the text
%
% Here is an example of the general form of a table:
% Fill in the caption in the braces of the \caption{} command. Put the label
% that you will use with \ref{} command in the braces of the \label{} command.
% Insert the column specifiers (l, r, c, d, etc.) in the empty braces of the
% \begin{tabular}{} command.
% The ruledtabular enviroment adds doubled rules to table and sets a
% reasonable default table settings.
% Use the table* environment to get a full-width table in two-column
% Add \usepackage{longtable} and the longtable (or longtable*}
% environment for nicely formatted long tables. Or use the the [H]
% placement option to break a long table (with less control than
% in longtable).
% \begin{table}%[H] add [H] placement to break table across pages
% \caption{\label{}}
% \begin{ruledtabular}
% \begin{tabular}{}
% Lines of table here ending with \\
% \end{tabular}
% \end{ruledtabular}
% \end{table}
% Surround table environment with turnpage environment for landscape
% table
% \begin{turnpage}
% \begin{table}
% \caption{\label{}}
% \begin{ruledtabular}
% \begin{tabular}{}
% \end{tabular}
% \end{ruledtabular}
% \end{table}
% \end{turnpage}
% Specify following sections are appendices. Use \appendix* if there
% only one appendix.
%\appendix
%\section{}
% If you have acknowledgments, this puts in the proper section head.
%\begin{acknowledgments}
% put your acknowledgments here.
%\end{acknowledgments}
% Create the reference section using BibTeX:
\nocite{*}
\bibliography{qcrefs}
\end{document}
%
% ****** End of file apstemplate.tex ******