arxiv: v2 [quant-ph] 2 Aug 2012

Similar documents
arxiv: v1 [quant-ph] 3 Feb 2015

Transformation of quantum states using uniformly controlled rotations

Computer arithmetic. Intensive Computation. Annalisa Massini 2017/2018

Numerical Linear Algebra

Fault Tolerant Quantum Computing Robert Rogers, Thomas Sylwester, Abe Pauls

1-way quantum finite automata: strengths, weaknesses and generalizations

MODELING THE RELIABILITY OF C4ISR SYSTEMS HARDWARE/SOFTWARE COMPONENTS USING AN IMPROVED MARKOV MODEL

arxiv:quant-ph/ v1 14 Apr 2005

Solved Problems. (a) (b) (c) Figure P4.1 Simple Classification Problems First we draw a line between each set of dark and light data points.

arxiv: v2 [quant-ph] 5 Dec 2013

CMSC 425: Lecture 4 Geometry and Geometric Programming

Proof Nets and Boolean Circuits

An Investigation on the Numerical Ill-conditioning of Hybrid State Estimators

A MIXED CONTROL CHART ADAPTED TO THE TRUNCATED LIFE TEST BASED ON THE WEIBULL DISTRIBUTION

RANDOM WALKS AND PERCOLATION: AN ANALYSIS OF CURRENT RESEARCH ON MODELING NATURAL PROCESSES

State Estimation with ARMarkov Models

Fourier Series Tutorial

Evaluating Circuit Reliability Under Probabilistic Gate-Level Fault Models

Finding Shortest Hamiltonian Path is in P. Abstract

CSE 599d - Quantum Computing When Quantum Computers Fall Apart

ALTERNATIVE SOLUTION TO THE QUARTIC EQUATION by Farid A. Chouery 1, P.E. 2006, All rights reserved

A Recursive Block Incomplete Factorization. Preconditioner for Adaptive Filtering Problem

Efficient algorithms for the smallest enclosing ball problem

Deriving Indicator Direct and Cross Variograms from a Normal Scores Variogram Model (bigaus-full) David F. Machuca Mory and Clayton V.

Linear diophantine equations for discrete tomography

1. INTRODUCTION. Fn 2 = F j F j+1 (1.1)

PHYS 301 HOMEWORK #9-- SOLUTIONS

Uncorrelated Multilinear Principal Component Analysis for Unsupervised Multilinear Subspace Learning

Pretest (Optional) Use as an additional pacing tool to guide instruction. August 21

Pell's Equation and Fundamental Units Pell's equation was first introduced to me in the number theory class at Caltech that I never comleted. It was r

Realization of Two-Qutrit Quantum Gates with Control Pulses

Additive results for the generalized Drazin inverse in a Banach algebra

Model checking, verification of CTL. One must verify or expel... doubts, and convert them into the certainty of YES [Thomas Carlyle]

José Alberto Mauricio. Instituto Complutense de Análisis Económico. Universidad Complutense de Madrid. Campus de Somosaguas Madrid - SPAIN

Towards understanding the Lorenz curve using the Uniform distribution. Chris J. Stephens. Newcastle City Council, Newcastle upon Tyne, UK

A New Method of DDB Logical Structure Synthesis Using Distributed Tabu Search

MATH 2710: NOTES FOR ANALYSIS

LIMITATIONS OF RECEPTRON. XOR Problem The failure of the perceptron to successfully simple problem such as XOR (Minsky and Papert).

Beginnings of the Helicity Basis in the (S, 0) (0, S) Representations of the Lorentz Group

Lilian Markenzon 1, Nair Maria Maia de Abreu 2* and Luciana Lee 3

ON THE DEVELOPMENT OF PARAMETER-ROBUST PRECONDITIONERS AND COMMUTATOR ARGUMENTS FOR SOLVING STOKES CONTROL PROBLEMS

A SIMPLE PLASTICITY MODEL FOR PREDICTING TRANSVERSE COMPOSITE RESPONSE AND FAILURE

A Qualitative Event-based Approach to Multiple Fault Diagnosis in Continuous Systems using Structural Model Decomposition

Solving Cyclotomic Polynomials by Radical Expressions Andreas Weber and Michael Keckeisen

Scaling Multiple Point Statistics for Non-Stationary Geostatistical Modeling

Metrics Performance Evaluation: Application to Face Recognition

An Overview of Witt Vectors

Title. Author(s)Okamoto, Ryo; Hofmann, Holger F.; Takeuchi, Shigeki; CitationPhysical Review Letters, 95: Issue Date

Relaxed p-adic Hensel lifting for algebraic systems

Uncorrelated Multilinear Discriminant Analysis with Regularization and Aggregation for Tensor Object Recognition

Impossibility of a Quantum Speed-up with a Faulty Oracle

PROFIT MAXIMIZATION. π = p y Σ n i=1 w i x i (2)

Universal Finite Memory Coding of Binary Sequences

1 More General von Neumann Measurements [10 Points]

SAT based Abstraction-Refinement using ILP and Machine Learning Techniques

Positive decomposition of transfer functions with multiple poles

Various Proofs for the Decrease Monotonicity of the Schatten s Power Norm, Various Families of R n Norms and Some Open Problems

An Inverse Problem for Two Spectra of Complex Finite Jacobi Matrices

On Line Parameter Estimation of Electric Systems using the Bacterial Foraging Algorithm

Any AND-OR formula of size N can be evaluated in time N 1/2+o(1) on a quantum computer

System Reliability Estimation and Confidence Regions from Subsystem and Full System Tests

Quantitative estimates of propagation of chaos for stochastic systems with W 1, kernels

A Parallel Algorithm for Minimization of Finite Automata

q-ary Symmetric Channel for Large q

arxiv: v2 [quant-ph] 17 Nov 2011

Automatic Generation and Integration of Equations of Motion for Linked Mechanical Systems

The Noise Power Ratio - Theory and ADC Testing

TRACES OF SCHUR AND KRONECKER PRODUCTS FOR BLOCK MATRICES

16.2. Infinite Series. Introduction. Prerequisites. Learning Outcomes

Estimation of the large covariance matrix with two-step monotone missing data

The Arm Prime Factors Decomposition

1 Properties of Spherical Harmonics

A generalization of Amdahl's law and relative conditions of parallelism

Principles of Computed Tomography (CT)

Blame, coercion, and threesomes: Together again for the first time

Lecture 1.2 Pose in 2D and 3D. Thomas Opsahl

Combining Logistic Regression with Kriging for Mapping the Risk of Occurrence of Unexploded Ordnance (UXO)

Information collection on a graph

On the Toppling of a Sand Pile

GOOD MODELS FOR CUBIC SURFACES. 1. Introduction

D.1 Deutsch-Jozsa algorithm

Constructive quantum scaling of unitary matrices

STABILITY ANALYSIS TOOL FOR TUNING UNCONSTRAINED DECENTRALIZED MODEL PREDICTIVE CONTROLLERS

Hotelling s Two- Sample T 2

The Graph Accessibility Problem and the Universality of the Collision CRCW Conflict Resolution Rule

Design of NARMA L-2 Control of Nonlinear Inverted Pendulum

Topic: Lower Bounds on Randomized Algorithms Date: September 22, 2004 Scribe: Srinath Sridhar

Principal Components Analysis and Unsupervised Hebbian Learning

On Wald-Type Optimal Stopping for Brownian Motion

arxiv: v4 [quant-ph] 8 Mar 2013

arxiv: v1 [quant-ph] 20 Jun 2017

Quantum Game Beats Classical Odds Thermodynamics Implications

arxiv: v1 [quant-ph] 22 Apr 2017

Implementation and Validation of Finite Volume C++ Codes for Plane Stress Analysis

Algorithms for Air Traffic Flow Management under Stochastic Environments

Specialized and hybrid Newton schemes for the matrix pth root

Computations in Quantum Tensor Networks

Observer/Kalman Filter Time Varying System Identification

The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION COURSE III. Wednesday, August 16, :30 to 11:30 a.m.

Generalized Coiflets: A New Family of Orthonormal Wavelets

Transcription:

Qcomiler: quantum comilation with CSD method Y. G. Chen a, J. B. Wang a, a School of Physics, The University of Western Australia, Crawley WA 6009 arxiv:208.094v2 [quant-h] 2 Aug 202 Abstract In this aer, we resent a general quantum comutation comiler, which mas any given quantum algorithm to a quantum circuit consisting a sequential set of elementary quantum logic gates based on recursive cosinesine decomosition. The resulting quantum circuit diagram is rovided by directly linking the ackage outut written in LaTex to Qcircuit.tex <htt://www.cquic.org/qcircuit>. We illustrate the use of the Qcomiler ackage through various examles with full details of the derived quantum circuits. Besides its generality and simlicity, Qcomiler roduces quantum circuits which reflect the symmetry of the systems under study. Corresonding author Email address: jingbo.wang@uwa.edu.au (J. B. Wang) Prerint submitted to August 3, 202

Program summary Program Title: Qcomiler Journal Reference: Catalogue identifier: Licensing rovisions: none Programming language: Fortran Comuter: any comuter with a Fortran comiler Oerating system: Linux, Mac OS X 0.5 (and later) RAM: deend on the size of the unitary matrix to be decomosed Keywords: Quantum comiler, quantum circuit, unitary matrix, quantum gate, quantum algorithm Classification: External routines/libraries: Laack Nature of roblem: Decomose any given unitary oeration into a quantum circuit with only elementary quantum logic gates. Solution method: This ackage decomoses an arbitrary unitary matrix, by alying the CSD algorithm recursively, into a series of block-diagonal matrices, which can then be readily associated with elementary quantum gates to form a quantum circuit. Restrictions: The only limitation is imosed by the available memory on the user s comuter. Comments: This ackage is alicable for any arbitrary unitary matrices, both real and comlex. If the unitary matrix is real, its corresonding quantum circuit is much simler with only half number of quantum gates in comarison with comlex matrices of the same size. Running time: Memory and CPU time requirements deend critically on the size of the unitary matrix to be decomosed. Most examles resented in this aer require a few minutes of CPU time on Intel Pentium Dual Core 2 Duo E2200 @ 2.2GHz. 2

. Introduction Quantum comuting exloits the nature of the quantum world in a way that romises to solve roblems which are intractable using conventional comuters [ 3]. At the heart of a quantum comuter lies a set of qubits whose states are maniulated by a series of elementary quantum logic gates, namely a quantum circuit, to rovide the ultimate comutational results. In our earlier work [4], we develoed a highly efficient quantum comutation simulator to assist on the analysis of comlicated quantum circuits comrised of qubit and qudit quantum gates. In this aer, we resent a quantum comutation comiler which mas any given quantum algorithm to a quantum circuit consisting a set of elementary quantum logic gates. In the seminal aers by Barenco et al and Deutsch et al [5, 6], it was roven that any arbitrarily comlex unitary oeration can be imlemented by a quantum circuit involving only one- or two-qubit elementary quantum logic gates. Earlier studies alied the standard triangularization or QR-factorization scheme with Givens rotations and Gray codes to ma a quantum algorithm to a series of elementary gate oerations[3, 5 7]. Subsequently, a more efficient and versatile scheme based on the cosine-sine decomosition was roosed and utilized [8 3]. More recently, De Vos et al [4, 5] examined another decomosition scheme, namely the Birkhoff decomosition, which was found to rovide simler quantum circuits for certain tyes of unitary matrices than the cosine-sine decomosition. However, the Birkhoff decomosition does not work for general unitary matrices. In this work we develo a general quantum comiler, named the Qcomiler, based on the cosine-sine decomosition scheme, because it works for arbitrary unitary matrices, it is extremely adatable, and the core CSD code is now available as art of the LAPACK ackage. Furthermore, we have managed to half the number of quantum gates in the circuit, if the quantum algorithm involves only real unitary matrices. For the Qcomiler, the inut file contains a user secified unitary matrix U. Qcomiler alies the cosine-sine decomosition (CSD) recursively and comiles U into a quantum circuit with a sequence of controlled/uncontrolled rotation and hase gates. Its outut contains the comlete information on these elementary quantum gates, including a searate LaTex document which can be directly linked to Qcircuit.tex <htt://www.cquic.org/qcircuit> to roduce the resulting quantum circuit diagram. This aer is structured as follows. Section 2 describes the recursive cosine-sine decomosition scheme, which mas an arbitrary unitary matrix U into a quantum circuit with only one- and two-qubit logic gates. In Section 3, we rovide a more cost-efficient method for real unitary matrices, which significantly reduces the number of quantum gates in the final circuit. In Section 4, we discuss the general structure as well as the usage of the Qcomiler ackage. In Section 5, we resent various examles with full details and discussions 3

of the resulting quantum circuits. Section 6 concludes the aer. 2. The recursive CSD scheme: General Unitary Matrices The Cosine Sine Decomosition (CSD) algorithm as described in [6, 7] decomoses an arbitrary 2 n 2 n unitary matrix U as the following u C S x U = v S C y, () where cos θ cos θ 2 C = diag (cos θ l ) = l=,...,2 n... cos θ 2 n and sin θ sin θ 2 S = diag (sin θ l ) = l=,...,2 n... sin θ 2 n are 2 n 2 n diagonal matrices, while u, v, x and y are 2 n 2 n unitary matrices which can be further decomosed by the CSD algorithm recursively into a string of block diagonal unitary matrices [9]. To show the general structure of the decomosition, we denote all sub-matrices as u i dim ignoring their exlicitly different numerical values, where i indicates the level of recursion and dim the matrix dimension. At the first level, we have U = u 2 n 2 n u 2 n 2 n u 2 n 2 n u 2 n 2 n =U A U. 4 C 2 n 2 n S 2 n 2 n S 2 n 2 n C 2 n 2 n (2)

At the second level, u = 2 n 2 u 2 2 n 2 2 n 2 n u 2 2 n 2 2 n 2 C 2 2 n 2 2 n 2 S 2 2 n 2 2 n 2 S 2 2 n 2 2 n 2 C 2 2 n 2 2 n 2 u 2 2 n 2 2 n 2 u 2, 2 n 2 2 n 2 U = u 2 n 2 n u 2 n 2 n = u 2 2 n 2 2 n 2 u 2 2 n 2 2 n 2 u 2 C 2 2 n 2 2 n 2 S 2 2 n 2 2 n 2 S 2 2 n 2 2 n 2 C 2 2 n 2 2 n 2 C 2 2 n 2 2 n 2 u 2 2 n 2 2 n 2 (3) 2 n 2 2 n 2 S 2 2 n 2 2 n 2 S 2 2 n 2 2 n 2 C 2 2 n 2 2 n 2 u 2 2 n 2 2 n 2 u 2 2 n 2 2 n 2 u 2 =U 2 A 2 U 2, 2 n 2 2 n 2 u 2 2 n 2 2 n 2 and U = U A U = U 2 A 2 U 2 A U 2 A 2 U 2. (4) At the ith level of recursion, the matrix U i is decomosed as the following: U i = U i A i U i (5) 5

where u i 2 n i 2 n i U i = u i 2 n i 2 n i... (6) u i 2 n i 2 n i and C i 2 n i 2 n i S i 2 n i 2 n i A i = S i 2 n i 2 n i C i 2 n i 2 n i.... (7) C i 2 n i 2 n i S i 2 n i 2 n i S i 2 n i 2 n i C i 2 n i 2 n i At the end of the recursive rocess, i.e. the nth level, we obtain U =U A U =U 2 A 2 U 2 A U 2 A 2 U 2 =U 3 A 3 U 3 A 2 U 3 A 3 U 3 A U 3 A 3 U 3 A 2 U 3 A 3 U 3 = 2 n = U n A i() Un 2 n, = (8) where marks the osition of the matrix sequence, i is imlicitly determined by, A is given by Eq. (7), and U n = diag k=,...,2 n (u n,k ) = diag k=,...,2 n (ex(iϕ,k )). (9) The above described recursive CSD scheme works for 2 n 2 n unitary matrices. For an arbitrary N N unitary matrix U, where 2 n < N 2 n, we add an identity matrix to U to form a new unitary matrix W 2 n 2 n = U N N I (2n N) (2n N), (0) and then aly the recursive CSD decomosition to W as described above. The decomosed matrices given by Eq. (8) can be directly related to elementary quantum gates, in articular, the hase gate Φ and the controlled rotation gate [3, 9], where the rotation oeration is defined as 6

If the rotation axis is y or z, we have R a (ρ) = ex(ia σ ρ 2 ) = I cos ρ 2 + ia σ sin ρ 2. () (ρ) = (2θ) = ex(iσ y θ) = I cos θ + iσ y sin θ cos θ sin θ = sin θ cos θ (2) and (ρ) = (2φ) = ex(iσ z φ) = I cos φ + iσ z sin φ ex(iφ) 0 (3) = 0 ex( iφ), resectively. P i() To establish a maing to elementary quantum gates, Möttönen et al [9] inserted identity matrices I = (P i() ) after each A i() in Eq. (8) with which P i() commutes, and thus U n A i() = U n A i() P i() (P i() ) = U n P i() A i() (P i() ). (4) The final decomosition becomes 2 n U = = B i() A i() Ũn 2 n, (5) where Ũ n = (P i( ) ) U n, excet Ũ n = Un, and Bi() = Ũ n P i() is a 2 n 2 n diagonal unitary matrix. With a set of P i() gate secified by solving a set of linear equations, B i() will have the required symmetry to be equivalent to C n (i;,..., i, i +,..., n), (6) where i denotes the target qubit with n control qubits. Similarly, A i can be maed to gate C n (i;,..., i, i +,..., n), (7) 7

and Ũ n 2 n is equivalent to a series of gates Φ(; ) I 2 n 2 n, (; ) I 2 n 2 n, C (2; ) I 2 n 2 2 n 2,... (8) C n 2 (n ;,..., n 2) I 2 2, C n (n;,..., n ). As an examle, we decomose a 2 3 2 3 unitary matrix by alying the CSD scheme recursively, i.e. U = B 3 A3 B2 2 A2 2 B3 3 A3 3 B 4 A 4 B3 5 A3 5 B2 6 A2 6 B3 7 A3 7Ũ3 8, (9) where A ( = 4) C 2 (; 2, 3), A 2 ( = 2, 6) C 2 (2;, 3), A 3 ( =, 3, 5, 7) C 2 (), B ( = 4) C 2 (; 2, 3), (20) B 2 ( = 2, 6) C 2 (2;, 3), B 3 ( =, 3, 5, 7) C 2 (), and U 3 8 Φ(; ), (; ), C (2; ), C 2 (). For simlicity, the identity matrices are omitted in the above exressions. The equivalent quantum circuit for U given by Eq. 9 is shown in Fig.. For a 2 4 2 4 unitary matrix, we have U =B 4 A4 B3 2 A3 2 B4 3 A4 3 B2 4 A2 4 B4 5 A4 5 B3 6 A3 6 B4 7 A4 7 B 8 A 8 B 4 9 A4 9 B3 0 A3 0 B4 A4 B2 2 A2 2 B4 3 A4 3 B3 4 A3 4 B4 5 A4 5Ũ4 6. (2) The corresonding quantum circuit is shown in Fig. 2. 8

U = Ũ 3 8 Ũ 3 8 A 3 7 B 3 7 A 2 6 B 2 6 A 3 5 B 3 5 A 4 B 4 A 3 3 B 3 3 A 2 2 B 2 2 A 3 B 3 Φ Ũ 3 8 = Figure : Quantum circuit for an 8-by-8 comlex unitary matrix. = U Ũ 4 6 Ũ 4 6 A 4 5 B 4 5 A 3 4 B 3 4 A 4 3 B 4 3 A 2 2 B 2 2 A 4 B 4 A 3 0 B3 0 A 4 9 B 4 9 A 8 B 8 A 4 7 B 4 7 A 3 6 B 3 6 A 4 5 B 4 5 A 2 4 B 2 4 A 4 3 B 4 3 A 3 2 B 3 2 A 4 B 4 Φ = Ũ 4 6 Figure 2: Quantum circuit for a 6-by-6 comlex unitary matrix. 3. The recursive CSD scheme: Real Unitary Matrices If the 2 n 2 n unitary matrix U is real, we have u n,k = ex(iϕ,k) = or from Eq. 9 and U n becomes a diagonal matrix consisting of only or. In this case, we can insert the identity matrix I = Ũ n (Ũ n ) = Ũ n Ũn after each A i() in Eq. 8, i.e. U n A i() = U n A i() Ũ n Ũn (22) 9

where Ũ n = Uq. n The decomosition for a real unitary U then becomes where à i() q= 2 n U = à i() = Ũn 2 n (23) = Ũ n A i() Ũ n. Note for general unitary matrices, it requires the solution of a set of linear equations to determine each inserted P i() in Eq. 4 [9]. Here, for real unitary matrices, we only need to calculate the roduct of U n, Un 2,..., Un to obtain the inserted Ũ n. Furthermore, we end u with only half number of decomosed matrices in comarison with Eq. 5. Since Ũ n is a diagonal matrix with only two ossible values, or, à i() A i() can be readily maed to the gate C n (i;,..., i, i +,..., n). The gates for à i() are almost the same excet for the signs of some rotation angles. and The last matrix Ũ n 2 n can be written as Ũ n 2 n = n diag (D m,k ) I 2 m 2m (24) k=,...,2 n m m= where D m,k are either ( ) ( 0 0 or 0 ) 0, with the former being an identity gate and the later a Π gate. Therefore, U n 2 n is equivalent to a subset of the following quantum gates: Π(; ) I 2 n 2 n C Π(2; ) I 2 n 2 2 n 2... C n 2 Π(n ;,..., n 2) I 2 2 C n Π(n;,..., n ). As an examle we decomose a 6-by-6 real unitary matrix U and get U = à 4 Ã3 2Ã4 3Ã2 4Ã4 5Ã3 6Ã4 7à 8Ã4 9Ã3 0Ã4 Ã2 2Ã4 3Ã3 4Ã4 5Ũ4 6 (25) Its corresonding circuit is, as shown in Fig. 3, much simler than that for a 6-by-6 comlex unitary matrix. The number of gates is reduced to half. 0

= U Ũ 4 6 Ũ 4 6 Ã 4 5 Ã 3 4 Ã 4 3 Ã 2 2 Ã 4 Ã 3 0 Ã 4 9 Ã 8 Ã 4 7 Ã 3 6 Ã 4 5 Ã 2 4 Ã 4 3 Ã 3 2 Ã 4 Ũ 4 6 = the subset of Figure 3: The circuit of a 6-by-6 real U. 4. Overview of the Software The Qcomiler ackage, written in Fortran, consists of main rogram and 2 subroutines. ackage utilizes recursively Sutton s CSD subroutines [7], which is now art of Laack available at htt://www.netlib.org/laack under a ermissive free software license. As described in Section 3, the Qcomiler ackage decomoses U as U = ( 2 n ( = 2 n = ) Ã i() Ũ n 2 n B i() A i() ) Ũ n 2 n if U is real, if U is comlex. It then generates an outut file containing a comlete descrition of each quantum gate in the circuit. The rincial flow chart of Qcomiler is shown in Fig. 4 with all subroutines calls summarized in Fig. 5. This (26)

Start Main Program CYG_CSD Real Case Main Program CYGR_CSD Read in the real unitary matrix CYGR_READF Create a useful table called index CYG_INDEXTABLE Choose the matrix style Comlex Case Main Program CYGC_CSD Read in the comlex unitary matrix CYGC_READF Create a useful table called index CYG_INDEXTABLE CSD for one ste LAPACK: DORCSD CSD recursively CYGR_BLKCSD CSD recursively CYGC_BLKCSD CSD for one ste LAPACK: ZUNCSD Process the CSD result in the real case to match each decomosed matrix with a quantum gate CYGR_CUTGATE Create the outut file (details of each gate in the circuit) CYGR_BLKCSD Process the CSD result in the comlex case to match each decomosed matrix with a quantum gate CYGC_CSDPHASE Create the outut file (details of each gate in the circuit) CYGC_BLKCSD End Figure 4: Flow chart for the Qcomiler ackage. CYGR_READF CYGR_CSD CYGR_BLKCSD CYGR_CUTGATE CYGR_WRITEF LAPACK: DORCSD CYG_CSD CYG_INDEXTABLE CYGC_CSD CYGC_READF CYGC_BLKCSD CYGC_CSDGATEU CYGC_CSDPHASE CYGC_WRITEF LAPACK: ZUNCSD CYGC_COEFF Figure 5: Flow chart for all subroutine calls. 2

5. Examle 5.. Comlex unitary matrix An 8-by-8 comlex unitary matrix U is generated randomly as the following: U = 0.650 0.3423i 0.0792 0.32i 0.4 0.0356i 0.727+0.594i 0.2945 0.2656i 0.3970+0.0475i 0.703 0.0385i 0.0757+0.065i 0.2339 0.3i 0.5429+0.0637i 0.055 0.0559i 0.0454 0.349i 0.022+0.0956i 0.494 0.0384i 0.5056 0.86i 0.5333 0.0362i 0.885 0.242i 0.468 0.234i 0.608 0.24i 0.5436 0.29i 0.374+0.0600i 0.848 0.079i 0.0026+0.374i 0.06 0.3250i 0.2882+0.223i 0.2745+0.75i 0.0532 0.2853i 0.27 0.483i 0.5067 0.4492i 0.0320 0.000i 0.0223+0.0879i 0.29+0.6i 0.080 0.293i 0.4807+0.042i 0.372+0.0264i 0.2358 0.3746i 0.4089+0.0434i 0.480+0.93i 0.2750+0.932i 0.832 0.296i 0.002+0.02i 0.428 0.4283i 0.2636+0.747i 0.363+0.2767i 0.3588 0.0596i 0.520 0.2426i 0.0680 0.248i 0.792 0.224i 0.2579 0.785i 0.0825 0.2606i 0.2869+0.52i 0.06 0.2008i 0.490+0.0484i 0.3993 0.07i 0.5480 0.3288i 0.874+0.76i 0.322+0.22i 0.0733+0.0072i 0.4026+0.079i 0.00+0.256i 0.0048 0.62i 0.4437 0.859i 0.984+0.2056i 0.493 0.397i Recursive CSD decomosition gives U = B 3 A3 B2 2 A2 2 B3 3 A3 3 B 4 A 4 B3 5 A3 5 B2 6 A2 6 B3 7 A3 7Ũ3 8. Their corresonding quantum gates are detailed in the outut file roduced by Qcomiler, as exlained below.. (27) Outut of the ackage Matrix Gate GATEPHASE ; 0.586 Φ(; ) Φ = 2 0.586 Φ GATEZ ; -0.9734 Ũ 3 8 (; ) 2φ = 2 ( 0.9734) GATEZ 2; -0.0856 0.4745 C (2; ) 2φ = 2 ( 0.0856) 2φ 2 = 2 0.4745 = R z R 2 z GATEZ 0.0975-0.0388-0.4445 0.046 C 2 () 2φ = 2 0.0975 2φ 2 = 2 ( 0.0388) 2φ 3 = 2 ( 0.4445) 2φ 4 = 2 0.046 = R z R 2 z R 3 z R 4 z 3

Outut of the ackage Matrix Gate 0.0758 0.238 0.4094 0.287 A 3 7 C 2 () 2θ = 2 0.0758 2θ 2 = 2 0.238 2θ 3 = 2 0.4094 2θ 4 = 2 0.287 = R y R 2 y R 3 y R 4 y GATEZ -0.5384 0.700-0.6665-0.209 B 3 7 C 2 () 2φ = 2 ( 0.5384) 2φ 2 = 2 0.700 2φ 3 = 2 ( 0.6665) 2φ 4 = 2 ( 0.209) = R z R 2 z R 3 z R 4 z 2;, 3 0.573 0.3405 0.09 0.483 A 2 6 C 2 (2;, 3) 2θ = 2 0.573 2θ 2 = 2 0.3405 2θ 3 = 2 0.09 2θ 4 = 2 0.483 = R y R 2 y R 3 y R 4 y GATEZ 2;, 3-0.0876-0.227 0.2202 0.235 B 2 6 C 2 (2;, 3) 2φ = 2 ( 0.0876) 2φ 2 = 2 ( 0.227) 2φ 3 = 2 0.2202 2φ 4 = 2 0.235 = R z R 2 z R 3 z R 4 z 0.23 0.3567 0.2444 0.2683 A 3 5 C 2 () 2θ = 2 0.23 2θ 2 = 2 0.3567 2θ 3 = 2 0.2444 2θ 4 = 2 0.2683 = R y R 2 y R 3 y R 4 y 4

Outut of the ackage Matrix Gate GATEZ -0.346 0.4879-0.530-0.047 B 3 5 C 2 () 2φ = 2 ( 0.346) 2φ 2 = 2 0.4879 2φ 3 = 2 ( 0.530) 2φ 4 = 2 ( 0.047) = R z R 2 z R 3 z R 4 z ; 2, 3 0.090 0.279 0.2752 0.3789 A 4 C 2 (; 2, 3) 2θ = 2 0.090 2θ 2 = 2 0.279 2θ 3 = 2 0.2752 2θ 4 = 2 0.3789 R y R 2 y R 3 y R 4 y = GATEZ ; 2, 3 0.529 0.509 0.264-0.0838 B 4 C 2 (; 2, 3) 2φ = 2 0.529 2φ 2 = 2 0.509 2φ 3 = 2 0.264 2φ 4 = 2 ( 0.0838) R z R 2 z R 3 z R 4 z = 0.36 0.2352 0.2069 0.3275 A 3 3 C 2 () 2θ = 2 0.36 2θ 2 = 2 0.2352 2θ 3 = 2 0.2069 2θ 4 = 2 0.3275 = R y R 2 y R 3 y R 4 y GATEZ -0.5367-0.300-0.0056 0.5324 B 3 3 C 2 () 2φ = 2 ( 0.5367) 2φ 2 = 2 ( 0.300) 2φ 3 = 2 ( 0.0056) 2φ 4 = 2 0.5324 = R z R 2 z R 3 z R 4 z 5

Outut of the ackage Matrix Gate 2;, 3 0.898 0.403 0.2375 0.3869 A 2 2 C 2 (2;, 3) 2θ = 2 0.898 2θ 2 = 2 0.403 2θ 3 = 2 0.2375 2θ 4 = 2 0.3869 = R y R 2 y R 3 y R 4 y GATEZ 2;, 3-0.607-0.5540 0.0320 0.8280 B 2 2 C 2 (2;, 3) 2φ = 2 ( 0.607) 2φ 2 = 2 ( 0.5540) 2φ 3 = 2 0.0320 2φ 4 = 2 0.8280 = R z R 2 z R 3 z R 4 z 0.077 0.426 0.3956 0.2628 A 3 C 2 () 2θ = 2 0.077 2θ 2 = 2 0.426 2θ 3 = 2 0.3956 2θ 4 = 2 0.2628 = R y R 2 y R 3 y R 4 y GATEZ -0.0073-0.6907-0.305-0.447 B 3 C 2 () 2φ = 2 ( 0.0073) 2φ 2 = 2 ( 0.6907) 2φ 3 = 2 ( 0.305) 2φ 4 = 2 ( 0.447) = R z R 2 z R 3 z R 4 z The final quantum circuit of the comlex unitary matrix U given by Eq. 27 is shown in Fig. 6. Φ U = Ũ 3 8 A 3 7 B 3 7 A 2 6 B 2 6 A 3 5 B 3 5 A 4 B 4 A 3 3 B 3 3 A 2 2 B 2 2 A 3 B 3 Figure 6: The circuit of U, the random 8-by-8 comlex unitary matrix. 6

It requires 8 gates for Ũ 3 8, 4 7 gates for A i, and 4 7 gates for B i, thus 64 gates in total to build the equivalent quantum circuit. 5.2. Real unitary matrix An 8-by-8 real unitary matrix U is generated randomly as the following: U = 0.299 0.387 0.5667 0.0990 0.5322 0.225 0.4933 0.37 0.3284 0.443 0.045 0.607 0.4763 0.054 0.3696 0.559 0.3766 0.704 0.56 0.42 0.2958 0.0275 0.3785 0.3094 0.383 0.523 0.7265 0.032 0.5063 0.030 0.0024 0.2826 0.345 0.0206 0.0599 0.9064 0.500 0.088 0.48 0.0394 0.457 0.4240 0.2668 0.2504 0.87 0.2838 0.5707 0.2689 0.3908 0.596 0.230 0.0746 0.2757 0.4422 0.3534 0.6057 0.3427 0.2257 0.094 0.2255 0.24 0.8337 0.0655 0.2456. (28) Recursive CSD decomosition gives U = Ã 3 Ã2Ã3Ã4Ã3 5Ã26Ã3 7Ũ3 8. Their corresonding quantum gates are detailed in the outut file roduced by Qcomiler, as exlained below. Outut of the ackage Matrix Gate GATEPI ; Y Π(; ) GATEPI 2; Y N Ũ 3 8 C Π(2; 0 ) GATEPI Y Y N Y C 2 Π(3; (, 2) 00 ) C 2 Π(3; (, 2) 0 ) C 2 Π(3; (, 2) ) Note: This art secifies the subset of gates: -0.388 0.450-0.4725 0.2393 Ã 3 7 C 2 () 2θ = 2 ( 0.388) 2θ 2 = 2 0.450 2θ 3 = 2 ( 0.4725) 2θ 4 = 2 0.2393 = R y R 2 y R 3 y R 4 y 7

Outut of the ackage Matrix Gate 2;, 3 0.0624 0.4624 0.028 0.4629 Ã 2 6 C 2 (2;, 3) 2θ = 2 0.0624 2θ 2 = 2 0.4624 2θ 3 = 2 0.028 2θ 4 = 2 0.4629 = R y R 2 y R 3 y R 4 y -0.026 0.4866-0.0855-0.2735 Ã 3 5 C 2 () 2θ = 2 ( 0.026) 2θ 2 = 2 0.4866 2θ 3 = 2 ( 0.0855) 2θ 4 = 2 ( 0.2735) = R y R 2 y R 3 y R 4 y ; 2, 3-0.052 0.25-0.3422-0.4830 Ã 4 C 2 (; 2, 3) 2θ = 2 ( 0.052) 2θ 2 = 2 0.25 2θ 3 = 2 ( 0.3422) 2θ 4 = 2 ( 0.4830) R y R 2 y R 3 y R 4 y = 0.3353-0.357-0.277 0.060 Ã 3 3 C 2 () 2θ = 2 0.3353 2θ 2 = 2 ( 0.357) 2θ 3 = 2 ( 0.277) 2θ 4 = 2 0.060 = R y R 2 y R 3 y R 4 y 2;, 3 0.2953 0.366 0.2673 0.456 Ã 2 2 C 2 (2;, 3) 2θ = 2 0.2953 2θ 2 = 2 0.366 2θ 3 = 2 0.2673 2θ 4 = 2 0.456 = R y R 2 y R 3 y R 4 y 8

Outut of the ackage Matrix Gate 0.2999-0.267-0.4684-0.28 à 3 C 2 () 2θ = 2 0.2999 2θ 2 = 2 ( 0.267) 2θ 3 = 2 ( 0.4684) 2θ 4 = 2 ( 0.28) = R y R 2 y R 3 y R 4 y The final quantum circuit of the real unitary matrix U given by Eq. 28 is shown in Fig. 7, which is significantly simler than that shown in Fig. 6 for a comlex unitary matrix of the same size. U = Ũ 3 8 à 3 7 à 2 6 à 3 5 à 4 à 3 3 à 2 2 à 3 Figure 7: The circuit of U, the random 8-by-8 real unitary matrix. It requires 5 Π gates for Ũ 3 8, and 4 7 gates for à i, thus 33 gates in total to build the equivalent quantum circuit, significantly simler than its comlex counterart. 5.3. Random walk on a square grah Quantum walks have recently been exlored for their non-intuitive dynamics, which may hold the key to radically new quantum algorithms [8 20]. Douglas and Wang [2] recently resented efficient quantum circuits for several families of highly symmetrical grahs. Here we use Qcomiler to build quantum circuits for quantum walk on general grahs. The walker s quantum state is given : ψ = N A i, j i, j, (29) i= j S where N is the number of nodes of the given grah, i reresents the ith node state, j the coin state which connects the ith and jth node, and S is determined by the grah adjacent matrix. 9

To realize one ste quantum walk, we first aly a coin oerator Ĉ = diag (Ĉ i ) on the walker, where i=,...,n Ĉ i = j S k S c i j,k i, k i, j. (30) In this work, we choose the Grover Coin [22] so that the quantum walk can be reresented by a real matrix. We then aly the translation oerator ˆT = N j, i i, j. (3) i= j S The unitary matrix for the comlete ste is Û = ˆTĈ. For a simle square grah, shown in Fig. 8, the quantum walk oerator is Û = ˆTĈ = 0 0 0 0 0 0 0 0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 3 Figure 8: The square grah The outut file of Qcomiler is given as the following with its quantum circuit shown in Fig. 9. Outut of the ackage Matrix Gate GATEPI ; Y Π(; ) GATEPI 2; Y N Ũ 3 8 C Π(2; 0 ) 20

Outut of the ackage Matrix Gate GATEPI N Y Y N C 2 Π(3; (, 2) 0 ) C 2 Π(3; (, 2) 0 ) Note: This art secifies the subset of gates: 0.5000 0.0000 0.0000-0.5000 Ã 3 7 C 2 () 2θ = 2 0.5 = 2θ 4 = 2 ( 0.5) = R y R 4 y 2;, 3 0.0000 0.5000 0.0000 0.5000 Ã 2 6 C 2 (2;, 3) 2θ 2 = 2 0.5 = 2θ 4 = 2 0.5 = R 2 y R 4 y -0.5000-0.5000 0.0000 0.0000 Ã 3 5 C 2 () 2θ = 2 ( 0.5) = 2θ 2 = 2 ( 0.5) = R y R 2 y ; 2, 3 0.0000 0.0000-0.5000 0.5000 Ã 4 C 2 (; 2, 3) 2θ 3 = 2 ( 0.5) = 2θ 4 = 2 0.5 = R 3 y R 4 y 0.0000 0.5000 0.5000 0.0000 Ã 3 3 C 2 () 2θ 2 = 2 0.5 = 2θ 3 = 2 0.5 = R 2 y R 3 y 2

Outut of the ackage Matrix Gate 2;, 3 0.0000-0.5000 0.0000 0.5000 Ã 2 2 C 2 (2;, 3) 2θ 2 = 2 ( 0.5) = 2θ 4 = 2 0.5 = R 2 y R 4 y 0.0000-0.5000-0.5000 0.0000 Ã 3 C 2 () 2θ 2 = 2 ( 0.5) = 2θ 3 = 2 ( 0.5) = R 2 y R 3 y R 3 y R 4 y U = R 2 y R 4 y R 2 y R 4 y R y R 4 y R y R 2 y R 2 y R 3 y R 2 y R 3 y Ũ 3 8 Ã 3 7 Ã 2 6 Ã 3 5 Ã 4 Ã 3 3 Ã 2 2 Ã 3 Figure 9: The circuit of U, the random walk evolution on the square grah (Fig. 8). Comare to the random 8-by-8 real matrix given by Eq. 28, which requires 33 gates, the circuit of the square grah consists of only 8 gates, reflecting the simle symmetry of this grah. 5.4. Random walk on the 8-star grah Fig. 0 shows another simle grah, namely the 8-star grah 22

8 2 3 9 4 5 7 6 Figure 0: The 8-star grah For this grah, the quantum walk oerator is Û = ˆTĈ = 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.75, which is a 6 6 unitary matrix. The comlete result is dislayed below. Note that since all of the rotation angles of à 4, Ã3 2, Ã4 3, Ã2 4, Ã4 5, Ã3 6, Ã4 7 are zeros, these gates vanish and are omitted here. Outut of the ackage Matrix Gate GATEPI ; N GATEPI 2; N N GATEPI N N N N GATEPI 4;, 2, 3 N N N N N N N Y Ũ 4 6 C 3 Π(4; (, 2, 3) ) 23

Outut of the ackage Matrix Gate Note: This art secifies the subset of gates: 4;, 2, 3 0.0000 0.0000 0.0000 0.0000-0.53 0.573-0.3073-0.0372 Ã 4 5 C 3 (4;, 2, 3) 2θ 5 = 2 ( 0.53) 2θ 6 = 2 0.573 2θ 7 = 2 ( 0.3073) 2θ 8 = 2 ( 0.0372) R 5 y R 6 y R 7 y R 8 y, 4 0.0000 0.0000 0.0000 0.0000-0.289-0.4029 0.074 0.320 Ã 3 4 C 3 (, 4) 2θ 5 = 2 ( 0.289) 2θ 6 = 2 ( 0.4029) 2θ 7 = 2 0.074 2θ 8 = 2 0.320 R 5 y R 6 y R 7 y R 8 y 4;, 2, 3 0.0000 0.0000 0.0000 0.0000 0.0392-0.2637-0.4685 0.927 Ã 4 3 C 3 (4;, 2, 3) 2θ 5 = 2 0.0392 2θ 6 = 2 ( 0.2637) 2θ 7 = 2 ( 0.4685) 2θ 8 = 2 0.927 R 5 y R 6 y R 7 y R 8 y 2;, 3, 4 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.5000 Ã 2 2 C 3 (2;, 3, 4) 2θ 8 = 2 0.5 = R 8 y 24

Outut of the ackage Matrix Gate 4;, 2, 3 0.0000 0.0000 0.0000 0.0000-0.0392 0.2637 0.4685 0.927 Ã 4 C 3 (4;, 2, 3) 2θ 5 = 2 ( 0.0392) 2θ 6 = 2 0.2637 2θ 7 = 2 0.4685 2θ 8 = 2 0.927 R 5 y R 6 y R 7 y R 8 y, 4 0.0000 0.0000 0.0000 0.0000 0.289 0.4029-0.074 0.320 Ã 3 0 C 3 (, 4) 2θ 5 = 2 0.289 2θ 6 = 2 0.4029 2θ 7 = 2 ( 0.074) 2θ 8 = 2 0.320 R 5 y R 6 y R 7 y R 8 y 4;, 2, 3 0.0000 0.0000 0.0000 0.0000 0.53-0.573 0.3073-0.0372 Ã 4 9 C 3 (4;, 2, 3) 2θ 5 = 2 0.53 2θ 6 = 2 ( 0.573) 2θ 7 = 2 0.3073 2θ 8 = 2 ( 0.0372) R 5 y R 6 y R 7 y R 8 y ; 2, 3, 4-0.5000-0.5000-0.5000-0.5000-0.5000-0.5000-0.5000-0.5000 Ã 8 C 3 (; 2, 3, 4) 2θ = 2θ 2 = 2θ 3 = 2θ 4 = 2θ 5 = 2θ 6 = 2θ 7 = 2θ 8 = 2 ( 0.5) = R y R 2 y R 8 y =... Putting these gates together, we obtain its quantum circuit as shown in Fig.. It requires only 34 quantum gates to imlement the 6 6 unitary matrix. As a comarison, for a random 6 6 real matrix, it needs around 8 5 + 5 = 35 gates, while for a random 6 6 comlex matrix, it 25

U = Ũ 4 6 Ã 4 5 Ã 3 4 Ã 4 3 Ã 2 2 Ã 4 Ã 3 0 Ã 4 9 Ã 8 Figure : The circuit of U, the random walk evolution on the star grah (Fig. 0). needs 8 5+8 5+6 = 256 gates. The last 7 gate combinations (56 subgates) comletely disaear. This is another examle demonstrating the efficiency of Qcomiler. 5.5. Random walk on a comlicated grah Qcomiler also works for very comlicated grahs. Fig. 2 is an adjacent matrix of a 00-node grah with white dots standing for and black dots for 0. Figure 2: The adjacent matrix of a comlicated grah. The quantum walk oerator for this grah is a 40 40 unitary matrix U. We first exand the size of 26

the unitary matrix with an identity matrix, i.e. U W = I (32) where U is the 40 40 unitary matrix, I is a 85 85 identity matrix, and W is a 2 2 2 2 unitary matrix. The resulting quantum circuit contains 2 qubits. 6. Conclusions We have develoed an efficient and versatile ackage, Qcomiler, which mas any unitary matrix U of arbitrary size into a quantum circuit with only one- and two-qubit logic gates by alying cosine-sine decomosition recursively. For real unitary matrices, Qcomiler rovides a much simler quantum circuit with only half number of elementary gates in comarison with earlier work by Mottonen et al [9] which deals with general unitary matrices. The quantum circuits roduced by Qcomiler also reflects the symmetry of the systems under study. In articular, we examined the resulting quantum circuits corresonding to quantum walks on grahs with certain degree of symmetry [9]. In this case, many gates in such a circuit turned out to be an identity gate or a simle gate, which can be easily eliminated or combined with other gates to further reduce the comlexity of the final quantum circuit. For unitary matrices of certain structure or symmetry, it may be ossible to include qutris and qudits to roduce simler and more efficient quantum circuits. This will be an interesting subject for further study. Acknowledgements The authors would like to thank Sergey Koulikov, Blake Segler, and Gary Allwood for their earlier involvement in this roject. Thanks are also due to Kia Manouchehri, Brendan Douglas and Thomas Loke for several valuable discussions. References [] Deutsch, D., Proceedings of the Royal Society of London Series A - Mathematical Physical and Engineering Sciences 425 (989) 73. [2] Shor, P. W., SIAM Journal on Comuting 26 (997) 484. [3] Nielsen, M. and Chuang, I., Quantum comutation and quantum information, Cambridge, Cambridge, 2000. 27

[4] Loke, T. and Wang, J. B., Comuter Physics Communications 82 (20) 22852294. [5] Barenco, A. et al., Physical Review A 52 (995) 3457. [6] Deutsch, D., Barenco, A., and Ekert, A., Proceedings of the Royal Society of London Series a-mathematical Physical and Engineering Sciences 449 (995) 669. [7] Cybenko, G., Comuting in Science and Engineering 3 (200) 27. [8] Tucci, R. R., quant-h/9902062 (999), quant-h/04027 (2004), quant-h/040725 (2004). [9] Mottonen, M., Vartiainen, J. J., Bergholm, V., and Salomaa, M. M., Physical Review Letters 93 (2004) 30502. [0] Bergholm, V., Vartiainen, J. J., Mottonen, M., and Salomaa, M. M., Physical Review A 7 (2005) 052330. [] Shende, V. V. and Markov, I. L., Quantum Information & Comutation 5 (2005) 49. [2] Khan, F. S. and Perkowski, M., Theoretical Comuter Science 367 (2006) 336. [3] Manouchehri, K. and Wang, J. B., Physical Review A 80 (2009) 060304. [4] De Vos, A. and Van Rentergem, Y., Journal of Multile-Valued Logic and Soft Comuting 5 (2009) 489. [5] De Vos, A., Boes, M., and De Baerdemacker, S., Journal of Multile-Valued Logic and Soft Comuting 8 (20) 67. [6] Paige, C. C. and Wei, M., Linear Algebra and Its Alications 209 (994) 303. [7] Sutton, B., Numerical Algorithms 50 (2009) 33. [8] Keme, J., Contemorary Physics 44 (2003) 307. [9] Douglas, B. L. and Wang, J. B., J. Phys. A: Math. Theor 4 (2008) 075303. [20] Berry, S. D. and Wang, J. B., Physical Review A 83 (20) 04237. [2] Douglas, B. L. and Wang, J. B., Physical Review A 79 (2009) 052335. [22] Shenvi, N., Keme, J., and Whaley, K. B., Physical Review A 67 (2003) 052307. 28