<<

Quantum analog-digital conversion

Kosuke Mitarai,1, ∗ Masahiro Kitagawa,1, 2 and Keisuke Fujii3, 4, † 1Graduate School of Engineering Science, Osaka University, 1-3 Machikaneyama, Toyonaka, Osaka 560-8531, Japan. 2Quantum Information and Quantum Biology Division, Institute for Open and Transdisciplinary Research Initiatives, Osaka University, 1-3 Machikaneyama, Toyonaka, Osaka 560-8531, Japan. 3Graduate School of Science, Kyoto University, Yoshida-Ushinomiya-cho, Sakyo-ku, Kyoto 606-8302, Japan. 4JST, PRESTO, 4-1-8 Honcho, Kawaguchi, Saitama 332-0012, Japan. (Dated: January 10, 2019) Many quantum algorithms, such as Harrow-Hassidim-Lloyd (HHL) algorithm, depend on oracles that efficiently encode classical data into a quantum state. The encoding of the data can be cat- egorized into two types; analog-encoding where the data are stored as amplitudes of a state, and digital-encoding where they are stored as -strings. The former has been utilized to process classical data in an exponentially large space of a quantum system, whereas the latter is required to perform arithmetics on a quantum computer. Quantum algorithms like HHL achieve quantum speedups with a sophisticated use of these two encodings. In this work, we present algorithms that converts these two encodings to one another. While quantum digital-to-analog conversions have implicitly been used in existing quantum algorithms, we reformulate it and give a generalized protocol that works probabilistically. On the other hand, we propose a deterministic algorithm that performs a quantum analog-to-digital conversion. These algorithms can be utilized to realize high-level quantum algorithms such as a nonlinear transformation of amplitudes of a quantum state. As an example, we construct a “quantum amplitude perceptron”, a quantum version of the neural network, and hence has a possible application in the area of learning.

I. INTRODUCTION since data are encoded into analog quantities, that is, complex amplitudes of a quantum state. Here we define A wide variety of quantum algorithms that potentially an analog-encoding unitary transformation UA({cj}) by: give quantum speedups over classical computers has been X proposed. The problems that are efficiently solved by ex- UA({cj}) |0i = cj |ji . (2) isting quantum algorithms can be divided into two types: j ones where input data of a problem is relatively small in Another approach is to encode m-bits of binary data size but the problem itself is hard classically, and ones into qubit-strings. Let N and d = {d(k)}m (d(k) = where the input of a problem is exponentially large, mak- j j k=1 j 0, 1, j = 1, ··· ,N) be the number of binary data pro- ing it hard to handle on classical computers. The formers vided and the data bitstrings. In this approach, data are are solved by algorithms such as Shor’s factoring [1], or encoded as follows: quantum chemistry calculations [2]. On the other hand, there are algorithms that solve problems categorized as N N 1 X 1 X (m) (1) the latter. They achieve quantum speedups only if an or- √ |ji |dji = √ |ji |d ··· d i . (3) N N j j acle that encodes N classical data in O(poly(log N)) time j=1 j=1 exists [3]. A famous example is Harrow-Hassidim-Lloyd We will call this state as a “digital-encoded” state. For (HHL) algorithm [4], which is an algorithm to apply a in- example, quantum algorithms for solving semidefinite verse A−1 of a matrix A to a N = 2n-dimensional vector N programs (SDPs) [11, 12] depends on this encoding. Sim- {cj} . It requires us to construct a quantum state: arXiv:1805.11250v2 [quant-ph] 9 Jan 2019 j=1 ilarly to an analog-encoding unitary transformation, we

N define a digital-encoding unitary transformation by X c |ji , (1) j UD({dj }) |ji |0i = |ji |dji . (4) j=1 UD is often called quantum random access memory N PN 2 where {cj} normalized to satisfy |cj| = 1. (QRAM). Refs. [13, 14] have provided a protocol which j=1 j=1 2 Data encoding in the format of Eq. (1) is crucial for all employs to speedup a memory call to O(log N) HHL-based algorithms [5–8], and others [9, 10]. We will two-body interaction gates. Their method is promising call the state of Eq. (1) as an “analog-encoded” state, compared to a conventional method that requires O(N) operations. It might be worth noting that in the context of QRAM, it is usually assumed that we already have “memory cells” which stores data in the form accessible ∗ [email protected] from a quantum computer. The O(log2 N) operations do † [email protected] not include the construction of them. 2

Many quantum algorithms sophisticatedly use these (a) Analog-encoding two types of encodings. For example, in HHL algorithm � [4], an analog-encoded state Eq. (1) is put through quan- �� � tum phase estimation algorithm that digitally encode �=1 eigenvalues {λ } of a matrix A, and then the inverse Classical data j Encode QADC QDAC of them are multiplied to the amplitudes by controlled rotations (Fig. 1 (b)); in quantum metropolis sampling �� , �� Digital-encoding [15], energy eigenvalue {Ej} of a Hamiltonian is first dig- itally encoded by the phase estimation, and then the en- � coded energies are transferred to amplitudes in the form 1 � −β(E −E ) � |� ⟩ of e j k , again using controlled rotations. (b) HHL algorithm � �=1 In this paper, we investigate the relation between these two different encoding methods. Specifically, we con- Vector Eigenvalue of matrix centrate on conversions between these two encodings; �� �Phase� estimation� can you go from “digital-encoding” to “analog-encoding” Analog-/ digital- Analog-encoding Analog-encoding (quantum digital-to-analog conversion, QDAC), or the encoding QDAC other way around (quantum analog-to-digital conversion, � � � −1 QADC)? DAC and ADC play important roles in classi- � � � � � � � � � � �=1 � � |� ⟩ �=1 cal information processing, since digitally-stored data are �=1 easier to handle than analog data which physical systems generate and are driven by. QDAC and QADC can be re- FIG. 1. (a) Schematic sketch of analog-encoding and digital- encoding. QDAC and QADC mediates these two encod- garded as quantum analogs of them, and therefore there ings. (b) A brief flowchart of HHL algorithm [4]. {|aj i} de- is a possibility that they stimulate the construction of note eigenvectors of a Hermitian matrix A, each correspond- more sophisticated quantum algorithms. ing to eigenvalues {λj }. χj are complex numbers such that First, we formulate these problems. It is shown that PN PN xj |ji = χj |aj i. QDAC can be implemented probabilistically, and QADC j=1 j=1 deterministically. A special case of QDAC, in fact, has implicitly been employed in existing algorithms such as can be constructed in time O(N log2 N) on a classical HHL and quantum metropolis samplings. We unify those computer. With this structure, there exists a quantum techniques and give a generalized procedure. QDAC and algorithm that constructs an analog-encoding unitary QADC algorithms provide an insight into what should be N UA({xj}j=1) with O(log Npoly(log log N)) single- and done in digital- or analog-encodings. Also, as an applica- two-qubit gates. tion, we show that a QADC-QDAC combined method can be utilized to perform almost arbitrary nonlinear We use the phase estimation algorithm stated below transformations of amplitudes of a quantum state. This as a key ingredient of our QADC algorithm. result can be utilized, for example, for a purpose of con- structing algorithms. Fact 2 (phase estimation [18]) Let U be a unitary This paper is organized as follows. First in Sec. II, operator acting on M-qubit Hilbert space with eigenstates we summarize the algorithms we use as subroutines and M M {|ψ i}2 and corresponding eigenvalues {e2πiφj }2 define QADC and QDAC problem. In Sec.III, we re- j j=1 j=1 where φ ∈ [0, 1). Let  = 2−m for some positive view QDAC procedures that have implicitly been utilized j integer m. There exists a , which in existing algorithms. We also present the generalized consists of O(1/) controlled-U calls and O(log2(1/)) QDAC procedure. Then in Sec.IV, we present an algo- single- and two-qubit gates, that performs transforma- rithm to perform QADC. In Sec. V, we provide appli- P2M ⊗m P2M ˜ cations of QADC, and show that QADC combined with tion j=1 aj |ψji |0i → |ψPEi = j=1 aj |ψji |φji QDAC provides us a way to perform a nonlinear trans- ˜ ˜ (1) ˜ (2) ˜ (m) where φj denotes a bitstring φj φj ··· φj such that formation of amplitudes of a quantum state. Pm ˜(k) −k | k=1 φj 2 − φj| ≤  for all j with state fidelity at least 1 − poly(). II. PRELIMINARY We say that |ψ˜i has fidelity 1−δ with |ψi when | hψ˜|ψi | = 1−δ. The phase estimation algorithm can also be viewed Here we summarize some useful results from existing as a digital-encoding unitary transformation, where the works along with definitions of terms. Throughout this address is replaced by eigenstates of U. paper N = 2n denotes the number of data. Next we state a version of the amplitude amplification technique. Fact 1 (analog encoding unitary [16, 17]) N N For given classical data {xj}j=1 ∈ R such that Fact 3 (amplitude amplification [19]) Suppose we PN 2 j=1 xj = 1, a binary-tree like classical data structure have a unitary operator U that acts on M-qubit Hilbert 3 space as U |0i⊗M = α |ψi |0i + β |Gi |1i where |ψi , |Gi A similar title is found on Ref. [21]. However, their are arbitrary M − 1-qubit states. Then probability of purpose was to map a continuous-space wave function getting |ψi |0i can be made close to unity by O(1/|α|) |ψi = R dxψ(x) |xi to a discrete-space wave function P application of U. |ψdi = j ψ(j/N) |ji. In the context of this paper, it can be viewed as analog-to-analog conversion. We define QDAC as follows.

N Definition 1 (QDAC) Let {dj} be a set of real j=1 III. QDAC numbers in [0, 1), each of which is represented by dj = Pm (k) −k (k) k=1 dj 2 with binary variables dj ∈ {0, 1}. Let dj (1) (m) It is actually straightforward to create an analog- denote the m-bit string dj ··· dj . An m-bit QDAC op- encoded state from a digital-encoded state just by adding N eration transforms digital-encoded state √1 P |ji |d i an ancilla qubit and performing a controlled rotation N j=1 j PN ⊗m with the data register. In fact, this QDAC procedure has to C j=1 dj |ji |0i where C is a normalization con- stant. implicitly used in existing works. For example, HHL [4] has utilized the above protocol to multiply the inverse N As for QADC, the amplitudes {cj}j=1 of a quantum of eigenvalues of a Hermitian matrix A to an analog- state are, in general, complex numbers. Therefore we encoded state vector. We state this QDAC operation define three versions of QADC, each corresponding to formally as a theorem below. the analog-to-digital conversion of the absolute value, the Theorem 1 (QDAC with ancilla) There exists a real part, and the imaginary part of {cj}. quantum algorithm that performs m-bit QDAC using Definition 2 (abs-QADC) Let r˜j denote the m- O(poly(log(1/))) single- and two-qubit gates and one (1) (m) U † , where  = 2−m, with probability PN d2/N. bit string r˜j ··· r˜j that best approximates |cj| D j=1 j Pm (k) −k Proof - The procedure of the algorithm is as follows. As- by k=1 r˜j 2 . An m-bit abs-QADC operation PN ⊗m sume that we are provided with a digital-encoded state transforms analog-encoded state j=1 cj |ji |0i to N Eq. (3). √1 P |ji |r˜ i. N j=1 j 2 −1 1. Compute ϕj = π cos dj by quantum arithmetics. Definition 3 (real-QADC) Let x˜j denote the m-bit N N (1) (m) 1 X ⊗m 1 X string x˜j ··· x˜j that best approximates the real part √ |ji |dji |0i → √ |ji |dji |ϕji , (5) Pm (k) −k N j=1 N j=1 of cj by k=1 x˜j 2 . An m-bit real-QADC opera- PN ⊗m tion transforms analog-encoded state cj |ji |0i to (1) (m) j=1 where ϕj denotes m-bit strings ϕj ··· ϕj such N √1 P m (k) j=1 |ji |x˜ji. P −k N that ϕj = k=1 ϕj 2 . Definition 4 (imag-QADC) Let y˜ denote the m-bit j 2. Adding an ancilla qubit |0ia, perform a controlled (1) (m) iπϕj Y/2 string y˜j ··· y˜j that best approximates the imaginary rotation Ry(πϕj) = e , on the ancilla. Pm (k) −k part of cj by y˜ 2 . An m-bit imag-QADC oper- N k=1 j 1 X PN ⊗m √ |ji |d i |ϕ i |0i ation transforms analog-encoded state j=1 cj |ji |0i j j a N N j=1 √1 P to j=1 |ji |y˜ji. N N 1 X  q 2  We use quantum arithmetics as a subroutine, which is → √ |ji |dji |ϕji dj |0i + 1 − d |1i . (6) N a j a stated as the following theorem. j=1 Fact 4 (quantum arithmetics [20]) Let a, b be m-bit 3. Measure the ancilla in computational basis. With strings. There exists a quantum algorithm that performs PN 2 probability dj /N, we obtain transformation |ai |bi → |ai |a + bi or |ai |bi → |ai |abi j=1 N with O(poly(m)) single- and two-qubit gates. X C dj |ji |dji |ϕji |0i , (7) Note that for accuracy defined as  = 2−m, quantum a j=1 arithmetics scales as O(poly(log(1/))). Furthermore, we q assume the following statement as a fact. PN 2 where C = 1/( j=1 dj ). Fact 5 Some basic functions such as inverse, trigono- † metric functions, square root, and inverse trigonometric 4. Uncompute ϕj (step 1) and apply UD. We now functions can be calculated to accuracy , that is, we can have an analog-encoded state ˜ perform a transformation |ai |0i → |ai |f(a)i such that N ˜ X |f(a) − f(a)| ≤  where f(a) is the objective function, C dj |ji . (8) using O(poly(log(1/))) quantum arithmetics. j=1 4

−1 Now we analyze the complexity. On step 1, cos dj can be calculated with quantum arithmetics using 푛 O(poly(log(1/))) gates by Fact 5. Step 2 uses m = |휉⟩ log(1/) controlled rotations. Therefore, overall complex- 푛 † |휓⟩ ity for steps 1, 2 and 4 is O(poly(log(1/))) and one UD. H H The success probability of step 3 is PN d2/N. 2 j=1 j  푝0 = + 휉 휓 Success probability of above procedure can be rewrit- FIG.|⟩ 2. of the [23]. ten in terms of the mean µ and the variance v of the 1 PN 2 2 data, since N j=1 dj = v + µ . Note that, when v +µ2  1 and the success probability is relatively small, 2. Perform controlled-NOT from the address the amplitude amplification technique can be utilized to to initialized ancilla qubits, which will be referred N shorten the expected running time quadratically from as qubits A, to get √1 P |ki |ki .   N k=1 ad A O(1/(v + µ2)) to O 1/p(v + µ2) . 3. Prepare the analog-encoded state in data qubits, When one modifies Step 1 to give ϕ = cos−1(f(d )), P j j cj |ji . we readily obtain the following. j data Corollary 1.1 (generalized QDAC) There exists a 4. Using another ancilla qubit (We will call it qubit quantum algorithm that performs the transformation B), perform a swap test [23] without measurement N N between data-qubit and qubits A (Fig. 3). We have: √1 P |ji |d i → C0 P f˜(d ) |ji |0i such that N j=1 j j=1 j |f˜(d ) − f(d )| ≤ , where f : [0, 1) → [0, 1) is a func-   j j |ki tion satisfying Fact 5, using O(poly(log(1/))) single- X ad X X √  cj |jidata |kiA + |kidata cj |jiA |0iB + PN ˜ 2 2 N and two-qubit gates, with probability j=1 f(dj) /N = k j j (NC0)−1.    X X If we choose f(x) = tanh(x), Collorary 1.1 provides an  cj |jidata |kiA − |kidata cj |jiA |1iB (9) alternative way to implement a sigmoid function other j j than the one proposed in Ref. [22]. 1 X ≡ √ |kiad |Ψkidata,A,B . (10) N k

IV. QADC Fig. 3 shows the quantum circuit from step 1 to step 4. We define V to be the combined unitary First, we propose an abs-QADC algorithm. Note that transformation of step 3 and 4. This step extracts the abs-QADC may easily be constructed with the real- an absolute value rk of amplitude ck each corre- QADC and the imag-QADC presented as Theorem 3 and sponding to an address |kiad. The similar idea is 4. However, we expect that the abs-QADC algorithm also used in Ref. [24]. that we present here would bring you some intuitions in the construction of the algorithm. We use the swap 5. Construct a gate test [23], which is a special case of the Hadamard test, to † extract the absolute value of amplitudes. The usual swap G = V (CNOT)ad→AS0(CNOT)ad→AV ZB, (11) test, as described in Fig. 2, measures an absolute value of an inner product of arbitrary two states |ψi and |ξi as where S0 is a conditional phase shift gate; S0 = I − 2 (|0i h0|) and Z is a Pauli Z gate only p0, the probability of getting |0i from an ancilla qubit. If data,A,B B we input |ki, which is a computational basis state, and acting on the qubit B (Fig. 4). The act of G can an analog-encoded state to the swap test, we can extract be written as a data x . The amplitude estimation [19] of p can be k 0 1 X utilized to encode the data digitally. An important trick G√ |kiad |Ψkidata,A,B = used in the algorithm presented below is that this process N k can be parallelized. 1 X   √ |kiad Gk |Ψkidata,A,B , (12) Theorem 2 (abs-QADC) There exists an m-bit abs- N k QADC algorithm that runs using O(1/) controlled-UA gates and O((log2 N)/) single- and two-qubit gates with where −m output state fidelity 1 − O(poly()), where  = 2 . † Gk = VSkV ZB, (13) Proof - First we provide the algorithm. (See Fig. 3 for steps 1-4.) and

N 1. Prepare address qubits. √1 P |ki N k=1 ad Sk = I − 2 (|0i h0|)data,B ⊗ (|ki hk|)A. (14) 5

͢ Each |Ψkidata,A,B is decomposed into two of eigen- address: R˿ H states |Ψk+idata,A,B and |Ψk−idata,A,B of Gk, each ͢ respectively corresponding to eigenvalue λk± = data: R˿ ͏̻ ͥ  q  ∑ ͟ ΏΒ >& ΒΏ΢Ώ ͵ Ͷ ±i2πθk 1 2 ͢  & Q Q e where sin(πθk) = 2 (1 + rk) and θk ∈ A: R˿ [1/4, 1/2). The decomposition is: |Ψkidata,A,B = √−i (eiπθk |Ψ i −e−iπθk |Ψ i ). See B: R˿ H H 2 k+ data,A,B k− data,A,B Appendix for detailed description. ͐

6. Introducing the register qubits, run the phase esti- FIG. 3. Quantum circuit through steps 1 to 4 of abs-QADC mation of G as depicted in Fig.5. Then we have: in the main text.

1 X  address √ |kiad |θkireg0 |Ψk+idata,A,B 2N k data  A + |1 − θ i 0 |Ψ i B k reg k− data,A,B † 퐺 푉 푆0 푉 1 X 푍 ≡ √ |kiad |Ψk,AEireg0,data,A,B (15) FIG. 4. Definition of gate G in abs-QADC. N k

where |θkireg0 and |1 − θkireg0 are m-bit strings Proof - We provide the algorithm. (See Fig. 3 for steps that store θk and 1 − θk as binary data, and 1-3.) The algorithm presented here is slightly modified one from the previous algorithm for QADC. |Ψk,AEi 0 = N reg ,data,A,B 1. Prepare address qubits. √1 P |ki 1   N k=1 ad √ |θ i |Ψ i + |1 − θ i |Ψ i k reg0 k+ data,A,B k reg0 k− data,A,B 2. Prepare the analog-encoded state in data qubits, 2 P (16) j xj |jidata 3. Using another ancilla qubit (We will call it qubit 7. On another register, using digital quantum arith- B), perform an Hadamard test as described in p 2 metics, calculate rk = 2 sin πθk − 1. Note that Fig. 6. We have: sin πθk = sin π(1−θk), and rk is uniquely recovered   since rk ∈ [0, 1]. Then finally we get: X |kiad X √  xj |jidata + |ki |0iB + N k 2 N j 1 X √ |kiad |r˜kireg |Ψk,AEireg0,data,A,B . (17)    N k=0 X  xj |jidata − |ki |1iB (19) j 8. Uncompute the data, A, B, reg’ qubits. We obtain: 1 X ≡ √ |ki |Ψ i . (20) N ad k data,B 1 X N k √ |kiad |r˜kireg |0ireg0,data,A,B , (18) N k=0 This step extracts the real part xk of a complex am- plitude ck each corresponding to an address |kiad. which is a digital-encoded state. Fig. 6 shows the quantum circuit from step 1 to 3. We define W to be the combined unitary transfor- Here we analyze the complexity of the above algo- mation of step 2 and 3. rithm. For steps 1 to 4, we used O(log N) single- and two-qubit gate. On step 5, the phase estimation, we need 4. Construct a gate to use O(1/) of controlled-U and O(log2 N/) of single- A G0 = WS0 W †Z , (21) and two-qubit gate. Step 6, quantum arithmetics takes 0 B 0 0 O(poly(log(1/))) by Fact 5. Therefore, overall complex- where S0 is a conditional phase shift gate; S0 = 2 ity is O(1/) of controlled-UA and O(log N/) of single- I − 2 (|0i h0|)data,B and ZB is a Pauli Z gate only and two-qubit gate. The fidelity of the output state is acting on the qubit B (Fig. 4). The act of G0 can 1 − O(poly()) by Fact 2.  be written as Next we show the real-QADC. 0 1 X G √ |kiad |Ψkidata,B = Theorem 3 (real-QADC) There exists an m-bit real- N k QADC algorithm that runs using O(1/) controlled-UA   2 1 X 0 gates and O((log N)/) single- and two-qubit gates with √ |ki G |Ψki , (22) N ad k data,B output state fidelity 1 − O(poly()), where  = 2−m. k 6

bit register: H

푚 0 퐼푄푇

address: H data: A: |0⟩ 푚−1 푚 B: |0⟩ 2 2 2 |0⟩ 푉 FIG. 5. Step 6 of the abs-QADC|0⟩ algorithm. The phase estimationa is performed to encode the analog-encoded value xj into qubit bitstrings. IQFT is inverse quantum Fourier transformation [25].

where address: H 0 푛 Gk = (1 − 2 |Ψkidata,B hΨk|data,B)ZB. (23) data: |0⟩ 1 푛 † 푘 ad 푘 data,B Each |Ψki is decomposed into two of eigen- 퐴 퐴 푁 σ 푘 Ψ data,B B: |0⟩ 푈 H 푈 H states |Ψk+idata,B and |Ψk−idata,B of Gk, each respectively corresponding to eigenvalue λk± = |0⟩ ±i2πθ q 1 e k where sin(πθk) = (1 + xk) and θk ∈ 2 FIG. 6. A quantum circuit through steps푊 1 to 3 of real-QADC [1/4, 1/2). The decomposition is: |Ψkidata,B = in the main text. √−i (eiπθk |Ψ i −e−iπθk |Ψ i ). The de- 2 k+ data,B k− data,B tail of this transformation is similar to the one de- scribed in Appendix and thus omitted. address: 푛 5. Introducing the register qubits, run the phase esti- data: |0⟩ 0 1 mation of G . Then we have: 푛 † 푘 ad 푘 data,B B: |0⟩ 푈퐴 푈퐴 푁 σ 푘 Ψ 1 X  H S H √ |kiad |θkireg0 |Ψk+idata,B 2N k |0⟩  + |1 − θ i |Ψ i k reg0 k− data,B FIG. 7. A quantum circuit element푊 for imag-QADC. The imag-QADC can be performed by replacing W in the real- 1 X QADC by this circuit. ≡ √ |kiad |Ψk,AEireg0,data,B (24) N k

where |θkireg0 and |1 − θkireg0 are m-bit strings that store θk and 1 − θk as binary data, and which is a digital-encoded state.

|Ψk,AEireg0,data,B = 1   The runtime of this algorithm is as same as the abs- √ |θki 0 |Ψk+i + |1 − θki 0 |Ψk−i 2 reg data,B reg data,B QADC.  (25) The imag-QADC can be constructed in the same man- 6. On another register, using digital quantum arith- 2 ner as the real-QADC. In this case, we replace the gate metics, calculate xk = 2 sin πθk − 1. Note that W to the one described in Fig. 7. Therefore we have the sin πθk = sin π(1 − θk). Then finally we get: following. N 1 X √ |ki |x˜ki |Ψk,AEi 0 . (26) N ad reg reg ,data,B k=0 Theorem 4 (imag-QADC) There exists an m-bit imag-QADC algorithm that runs using O(1/) controlled- 7. Uncompute the data, A, B, reg’ qubits. We obtain: 2 UA gates and O((log N)/) single- and two-qubit gates N with output state fidelity 1 − O(poly()), where  = 2−m. 1 X √ |kiad |x˜kireg |0ireg0,data,B , (27) N k=0 7

V. APPLICATIONS The most useful application of this would be to deal with a “quantum big-data”. For example, using UA on A. Classical data loading two registers, we can prepare X U |0i ⊗ U |0i = c c |ii |ji . (28) As stated in the introduction, there are some algo- A A i j rithms, such as quantum SDP solvers [11, 12], that re- i,j quire an oracle which encodes N classical data into a UA is not restricted to the loading of classical data {cj}, quantum state Eq. (3) in time O(poly(log N)). but can also be a time evolution operator e−iHt, where H QADC can be utilized for this purpose. Assume that is some Hamiltonian which can efficiently be simulated a binary-tree structure required in Fact 1 is already on a quantum computer. Notice that the tensor prod- constructed on the classical side. Combined with the uct structure of quantum mechanics has calculated the analog-encoding unitary U of Fact 1, the m-bit digital- 2 A product ci, cj and the combined system has N of ampli- N encoded state √1 P |ji |d i can be prepared with N j=1 j tudes. This nonlinearity is employed in quantum circuit O(log2 Npoly(log log N)/) quantum gates. learning [27] for machine learning application. The di- 2 Recently another method for digital encoding has been rect digital encoding of these N dimensional data on proposed [26]. They proposed a protocol that directly a quantum state might be impractical, since the calcu- N 2 encodes binary classical data into qubits. lation of the product {cicj}i,j=1 takes O(N ) time and space classically. In comparison, the construction of the quantum state Eq. (28) requires only O(N log N) clas- sical and O(log Npoly(log log N)) quantum operations. B. Nonlinear transformation of amplitude Tensor product structure is useful to introduce nonlin- earity to the data in the form of Eq. (28), however, it The transformation performed on the probability am- cannot be used to introduce general and more complex PN plitudes cj of a quantum state j=1 cj |ji, without mea- transformation stated in above theorem. surements, is always linear owing to the unitarity of Applying QADC on this combined state yields a state, the quantum dynamics. Even with (projective) mea- X surement, the transformation is restricted to the form |ii |ji |cicji . (29) of cj/C, where C is some constant that is determined i,j by the normalization condition. Therefore, a transfor- mation of the form f(cj) with an arbitrary function f Note that this transformation can also be performed cannot be done, without encoding them in digital form in time O(poly(log N)). Then applying the nonlinear using QADC. We state the fact that this form of nonlin- QDAC procedure and the inverse of QADC, one gets, ear transformation of amplitude can be performed using X QADC and QDAC as the following theorem. f(cicj) |ii |ji |0i , (30) i,j Theorem 5 Let data {c }N , analog-encoding unitary j j=1 which has nonlinearly transformed probability ampli- N PN UA({cj}j=1) and analog-encoded state j=1 cj |ji be tudes. A further extension is discussed in the next sub- given. For any function f : C → [−1, 1] that sat- section. isfies Fact 5, there exists a probabilistic quantum al- PN gorithm that performs transformation j=1 cj |ji → 0 PN ˜ ˜ C. Quantum amplitude perceptron C j=1 f(cj) |ji, such that |f(cj) − f(cj)| ≤ , 2 with O(1/) controlled-UA gates and O((log N)/) single- and two-qubit gates. Probability of success is When one chooses f(x) = tanh(x) or the ReLU func- PN f˜(c )2/N and the output state fidelity is 1 − tion which are frequently used in neural networks, it can j=1 j readily mimic the perceptron, which is a building block O(poly()) of neural networks. We denote such an activation func- tion by σ(x) In neural network, a transformation of the Proof - By running the QADC algorithm from The- form σ(w · x), where w and x are a weight vector and orem 3 and Theorem 4 in parallel, we get a N a data vector, is utilized to learn some task. The train- state √1 P |ji |x˜ i |y˜ i using O(1/) controlled- N j=1 j j ing of the network is done by tuning the weight w to 2 UA gates and O((log N)/) single- and two-qubit give some specific output. To mimic this, first we ap- gates with state fidelity 1 − O(poly()). Then per- ply a parametrized unitary transformation U(θ), which forming the modified QDAC from Corollary 1.1, we corresponds to the weight w, on an analog-encoded state get C0 PN f˜(x , y ) |ji |x i |y i with O(poly(log(1/))) PN PN PN j=1 j j j j i=1 ci |ii, yielding a state i=1 j=1 ujk(θ)cj |ii. Note single- and two-qubit gates and with probability that the amplitude xi can be a resultant amplitude after PN ˜ 2 j=1 f(cj) /N. Finally, application of inverse QADC the tensor product multiplication described in the previ- leaves us the desired state.  ous section. Then use the procedure of Theorem 5 with 8 the activation function σ, which produces, state   |Ψkidata,A,B = V |0idata |kiA |0iB = 0 X X C σ  uij(θ)xj |ii . (31)   1 X X i j c |ji |ki + |ki c |ji |0i + 2  j data A data j A B j j The full tomography of this state would require us an    exponential time, but if one is interested in the constant X X number of perceptron outputs, performing a swap test  cj |jidata |kiA − |kidata cj |jiA |1iB . [23] with chosen basis {|ki} is enough to extract them. j j The state Eq. (31) can be further transformed by some (A.1) unitary gates to determine the readout weight of the out- put. First, we define two normalized states For machine learning, it is necessary to optimize the   parameter θ. Although the gradient of the output with 1 X X |Ψk0i =  cj |ji |ki + |ki cj |ji  |0i , respect to θ cannot be extracted due to the complex form 2α data A data A B k j j of Eq. (31), gradient-free methods can be utilized, just (A.2) as same as mentioned in Ref. [22].   Finally, we note here, if one can determine the value of 2 1 X X   2 |Ψk1i =  cj |jidata |kiA − |kidata cj |jiA |1iB , P P 2βk i σ j uij(θ)xj somehow, amplitude ampli- j j fication technique can be employed to make QDAC pro- (A.3) cedure deterministic. This would enable us to implement where a multilayer neural network on a quantum computer de- terministically. r1 α = (1 + r2), (A.4) k 2 k r1 VI. CONCLUSION β = (1 − r2). (A.5) k 2 k

We have formulated QDAC and QADC, and described We define θk ∈ [1/4, 1/2) by algorithms to implement them on quantum computers. Although QDAC protocols have implicitly been utilized sin πθk = αk. (A.6) in existing algorithms, we have generalized it to facil- Then |Ψ i can be rewritten as itate complex nonlinear functions. We have also pre- k data,A,B sented an algorithm that performs QADC. It was shown |Ψ i = α |Ψ i + β |Ψ i . (A.7) that a combination of QADC and QDAC enables us al- k data,A,B k k0 k k1 most arbitrary nonlinear transformations of amplitudes We denote Z , VS V † and G acting on the subspace of a quantum state. The possible application of this non- B k k † linear transformation is to make a quantum amplitude spanned by {|Ψk0i , |Ψk1i} as ZfB, VS^kV and Gfk respec- perceptron, which can be employed to construct more tively. The first two can be written as sophisticated quantum machine learning algorithms. ZfB = |Ψk0i hΨk0| − |Ψk1i hΨk1| , (A.8)

† 2 VS^kV = (1 − 2αk) |Ψk0i hΨk0| ACKNOWLEDGMENTS 2 + (1 − 2βk) |Ψk1i hΨk1| − 2α β (|Ψ i hΨ | + |Ψ i hΨ |). (A.9) KM would like to thank Makoto Negoro for fruit- k k k1 k0 k0 k1 ful discussions. KF is supported by KAKENHI No. Therefore G is 16H02211, JST PRESTO JPMJPR1668, JST ERATO fk JPMJER1601, and JST CREST JPMJCR1673. KM and ^† MK are supported by CREST by JST grant number JP- Gfk = VSkV ZfB 2 MJCR1672. = (1 − 2αk) |Ψk0i hΨk0| 2 − (1 − 2βk) |Ψk1i hΨk1| − 2αkβk(|Ψk1i hΨk0| − |Ψk0i hΨk1|). (A.10) Appendix: Eigenvalues and eigenstates of Gk

Two eigenvalues of Gfk are Here we calculate the eigenvalues and eigenstates of ±i2πθk Gk defined in Eq. (22). We consider Gk acting on the λk± = e , (A.11) 9 and eigenvectors |Ψk±i each corresponding to λk± are 1 |Ψk±i = √ (|Ψk0i ± i |Ψk1i) . (A.12) 2

|Ψki can be decomposed into |Ψk±i as −i iπθk −iπθk  |Ψki = √ e |Ψk+i − e |Ψk−i . (A.13) 2

[1] P. W. Shor, SIAM J. Comput. 26, 1484 (1997). [14] V. Giovannetti, S. Lloyd, and L. Maccone, Phys. Rev. [2] I. Kassal, J. D. Whitfield, A. Perdomo-Ortiz, M.-H. Lett. 100, 160501 (2008). Yung, and A. Aspuru-Guzik, Annu. Rev. Phys. Chem. [15] K. Temme, T. J. Osborne, K. G. Vollbrecht, D. Poulin, 62, 185 (2011). and F. Verstraete, Nature 471, 87 (2011). [3] S. Aaronson, Nature Physics 11, 291 (2015). [16] I. Kerenidis and A. Prakash, (2016), arXiv:1603.08675. [4] A. W. Harrow, A. Hassidim, and S. Lloyd, Phys. Rev. [17] I. Kerenidis and A. Prakash, (2017), arXiv:1704.04992. Lett. 103, 150502 (2009). [18] R. Cleve, A. Ekert, C. Macchiavello, and M. Mosca, [5] M. Schuld, I. Sinayskiy, and F. Petruccione, Phys. Rev. Proceedings of the Royal Society A 454, 339 (1998). A 94, 022342 (2016). [19] G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, [6] C.-H. Yu, F. Gao, and Q.-Y. Wen, (2017), arXiv:0005055 [quant-ph]. arXiv:1707.09524. [20] L. Ruiz-Perez and J. C. Garcia-Escartin, Quantum In- [7] P. Rebentrost, M. Mohseni, and S. Lloyd, Phys. Rev. formation Processing 16, 152 (2017). Lett. 113, 130503 (2014). [21] F. Schm¨userand D. Janzing, Phys. Rev. A 72, 042324 [8] N. Wiebe, D. Braun, and S. Lloyd, Phys. Rev. Lett. 109, (2005). 050505 (2012). [22] Y. Cao, G. G. Guerreschi, and A. Aspuru-Guzik, [9] N. Wiebe, A. Kapoor, and K. M. Svore, Quantum Info. arXiv:1711.11240. Comput. 15, 316 (2015). [23] H. Buhrman, R. Cleve, J. Watrous, and R. de Wolf, [10] S. Lloyd, M. Mohseni, and P. Rebentrost, (2013), Phys. Rev. Lett. 87, 167902 (2001). arXiv:1307.0411. [24] S. S. Zhou, T. Loke, J. A. Izaac, and J. B. Wang, Quan- [11] F. G. Brandao and K. M. Svore, in 2017 IEEE 58th An- tum Inf. Process. 16, 82 (2017). nual Symposium on Foundations of Computer Science [25] M. A. Nielsen and I. L. Chuang, Quantum Computation (FOCS) (IEEE, 2017) pp. 415–426. and (Cambridge University Press, [12] F. G. S. L. Brand˜ao,A. Kalev, T. Li, C. Y.-Y. Lin, K. M. Cambridge, 2010). Svore, and X. Wu, (2017), arXiv: 1710.02581. [26] J. A. Cortese and T. M. Braje, (2018), arXiv:1803.01958. [13] V. Giovannetti, S. Lloyd, and L. Maccone, Phys. Rev. [27] K. Mitarai, M. Negoro, M. Kitagawa, and K. Fujii, A 78, 052310 (2008). arXiv:1803.00745.