Quantum Algorithm For Nonhomogeneous Linear Partial Differential Equations
Quantum Algorithm For Nonhomogeneous Linear Partial Differential Equations
Juan Miguel Arrazola,1,* Timjan Kalajdzievski,1 Christian Weedbrook,1 and Seth Lloyd2
1
Xanadu, 372 Richmond Street W, Toronto, Ontario, Canada M5V 1X6
2
Massachusetts Institute of Technology, Department of Mechanical Engineering, 77 Massachusetts Avenue,
Cambridge, Massachusetts 02139, USA
(Received 21 September 2018; revised manuscript received 22 February 2019; published 4 September 2019)
We describe a quantum algorithm for preparing states that encode solutions of nonhomogeneous linear partial
differential equations. The algorithm is a continuous-variable version of matrix inversion: it efficiently inverts
differential operators that are polynomials in the variables and their partial derivatives. The output is a quantum
state whose wave function is proportional to a specific solution of the nonhomogeneous differential equation,
which can be measured to reveal features of the solution. The algorithm consists of three stages: preparing fixed
resource states in ancillary systems, performing Hamiltonian simulation, and measuring the ancilla systems.
The algorithm can be carried out using standard methods for gate decompositions, but we improve this in two
ways. First, we show that for a wide class of differential operators, it is possible to derive exact decompositions
for the gates employed in Hamiltonian simulation. This avoids the need for costly commutator approximations,
reducing gate counts by orders of magnitude. Additionally, we employ methods from machine learning to find
explicit circuits that prepare the required resource states. We conclude by studying two example applications of
the algorithm: solving Poisson’s equation in electrostatics and performing one-dimensional integration.
DOI: 10.1103/PhysRevA.100.032306
in which case  can be viewed as a Hamiltonian for the Performing a momentum homodyne measurement on both
N-mode system. resource modes and postselecting on observing the outcome
We follow the Fourier decomposition technique of p = 0 on both modes, i.e., projecting onto the state |0 px |0 py ,
Ref. [25], but note that the methods proposed in Ref. [32] for yields
solving linear systems of equations using continuous-variable
1 ⊗0 px 0 py ⊗ 0 px 0 py |
quantum computers could also potentially be adapted to solv-
∞
ing partialdifferential equations. Let g(x) be an ∞odd function i
∞
satisfying 0 g(x)dx = 1. It holds that a−1 = 0 g(ax)dx for = √ dx dy (x) y e −y2 /2 −iÂxy
e | f 0 px 0 py
2π −∞
a = 0. Choosing g(x) = x e−x /2 and
2
−1
∞ writing−yg(x)
2
in terms of
/2 ixy = Â | f 0 p 0 p , (5)
its Fourier transform g(x) = √2π i
−∞ dy y e e we have x y
the resource states of Eq. (3). A global unitary e−iÂX̂ Ŷ is = − |a. (8)
a a
subsequently applied to all systems, where X̂ and Ŷ are
respectively the position operators of the two resource modes. The effect of a truncated step function is an exponentially
This transformation is equivalent to performing evolution small correction from the ideal result a−1 |a. The correction is
under a Hamiltonian Ĥ = ÂX̂ Ŷ for unit time. The result is only significant for small eigenvalues such that a 1/L, i.e.,
032306-2
QUANTUM ALGORITHM FOR NONHOMOGENEOUS LINEAR … PHYSICAL REVIEW A 100, 032306 (2019)
the value of L determines the smallest eigenvalue a for which Up to normalization, this state is equal to the desired state
the approximation is adequate. This result can then be used to a−1 |a except for a correction O(3 /a3 ) that is only relevant
analyze the effect of the approximation on an arbitrary state when a .
| f whenever
it is possible to express it in the eigenbasis of Â: Comparing to Eq. (8), the dominant error for small values
| f = da φ(a)|a. of a arises from the finite width of the step function state,
Even a step function of finite width is an idealization since whose effect is exponential in a for a 1/L.
it is not continuous at either x = 0 or x = L: any physical By expressing the state | f in terms of the eigenbasis {|a}
wave function will exhibit a smooth transition around these of Â, we note that the action of Â−1 approx on | f introduces an
√
points. The effect of this finite rise time can be modeled by overall constant factor 2 π and therefore the probability of
approximating the ideal step function in terms of a continuous successfully projecting onto the desired output state satisfies
function. Here we consider the error function 21 (1 + erf[kx]) Pr(success) = Â−1 approx | f = O( ). In the Appendixes, we
2 2
as an approximate step function, where the approximation discuss how coarse-graining measurement outputs can also be
improves with larger k > 0. We then have used to increase the probability of success at the cost of an
∞ ∞ increase in the approximation error.
i
Â−1 dy y e−y /2 e−iÂxy |a
2
approx |a = √ dx(1+erf[kx]) Combining the effects of a finite-width step function and a
8π 0 −∞ finite-precision measurement leads to an approximation
⎛ √ ⎞
4 L ∞
1 2 ⎠ 1 a2 a i
= ⎝ |a = 1 − 2 + O 4 |a. Â−1
approx |a = √ dx dy y e−y /2 e−iÂxy g(x, y, )|a
2
a a2
2+ k 2 a 2k k 2π 0 −∞
√
2a π (1 − eL (a + + )/2(1+ ) )
2 2 2 4 2
(9)
= √ |a
This induces another correction from the ideal scenario, but in 1 + 2 (a2 + 2 + 4 )
√
this case the effect is significant only for large eigenvalues a = 2 π F (a)|a, (13)
such that a k. Thus approximations to an ideal step function
state lead to deviations that are relevant only for very small or where
very large eigenvalues.
a(1 − e−L (a + + )/2(1+ ) )
2 2 2 4 2
Finally, physical homodyne measurements have finite pre- F (a) := √ |a, (14)
cision, whose effect on the resulting output state must be 1 + 2 (a2 + 2 + 4 )
taken into account. We model the finite-precision homodyne
measurement as a projection onto finitely squeezed states, which is an approximation to a−1 .
as opposed to momentum eigenstates which are infinitely The imprecision of the algorithm arises due to the differ-
squeezed. This is the same strategy employed, for example, ence between the ideal inverse operator Â−1 and the resulting
in classical simulators [33]. The state corresponding to the approximation Â−1 . We can express  in its eigenbasis
m(a)approx
p = 0 outcome of measurement with precision as  = a k=1 a|a, ka, k|, where Â|a, k = a|a, k and
a homodyne
is | = π 1/41√ d p e−p /2 |p. The resulting output state is
2 2
m(a) is the multiplicity of eigenvalue a. We then have
given by
m(a)
1
Â−1 = |a, ka, k|, (15)
(1 ⊗|| ⊗ ||)| a
∞ ∞ ak=1
=√
i
dx dy y e−y /2 e−iÂxy g(x, y, )| f ||
2
m(a)
2π 0 −∞
Â−1
approx = F (a)|a, ka, k|. (16)
a k=1
−1
= Âapprox | f ||, (10)
The relationship between F (a) and a−1 is illustrated in Fig. 2
where for L = 7 and = 0.1.
∞ Finally, the error in the approximation can be quantified in
1
d p dq e−p /2 −ipx −q2 /22 −iqy
2 2
g(x, y, ) = √ e terms of the distance between the resulting output states. More
π −∞ precisely, let
= e−(x +y2 )2 /2
2
. (11)
m(a)
1
|ψ = Â−1 | f = ca,k |a, k, (17)
As before, the approximation of the inverse operator is best a
a
k=1
expressed in terms of its action on the eigenstate |a:
∞ ∞
m(a)
i |ψ̃ = Â−1
approx | f = F (a)ca,k |a, k (18)
Â−1 dy y e−y /2 e−iÂxy g(x, y, )|a
2
approx |a = √ dx a k=1
2π 0 −∞
√ be unnormalized output states. Defining the error as ε :=
2a π
=√ |a |ψ − |ψ̃ 1 we obtain
1 + (a2 + 2 + 4 )
2
√
3
2 π
m(a)
1
= +O 3 |a. (12) ε= |ca,k | − F (a). (19)
a a a
a
k=1
032306-3
JUAN MIGUEL ARRAZOLA et al. PHYSICAL REVIEW A 100, 032306 (2019)
N
 = λ 1 + a j X̂ j + b j P̂j + α j X̂ j2 + β j P̂j2 , (22)
j=1
III. HAMILTONIAN SIMULATION the universal set, but exact decompositions can also be derived
The goal of Hamiltonian simulation is to find a quantum for them (see the Appendixes for details). The resulting exact
2
circuit that performs the transformation eiĤt for some Hamil- decomposition for the gate eit X̂ j X̂k X̂l contains 281 gates from
tonian Ĥ and time t > 0. The circuit is specified in terms of a the universal set. It is important to contrast this with the
universal gate set, which in this work we take to be the set commutator approximation method [38], which requires 28
gates to decompose eit X̂ j X̂k X̂l , but for a precision of 10−3 , it
2
π
+P̂2 )
, eit1 X̂ , eit2 X̂ , eit3 X̂ , eiτ X̂1 ⊗X̂2 },
2 2 3
{ei 2 (X̂ (21) needs about 10 repetitions for a total of roughly 107 gates.
6
where t1 , t2 , t3 , and τ are adjustable real parameters. The For any sparse Hamiltonian that is a polynomial of con-
π
Fourier transform gate F̂ := ei 2 (X̂ +P̂ ) has the effect of map-
2 2 stant degree over the quadrature operators, universal simu-
ping between the quadrature operators: F̂ † X̂ F̂ = −P̂ and lation theorems [27,28] state that poly(N ) time is required
F̂ † P̂F̂ = X̂ . The standard approach for performing Hamilto- to perform Hamiltonian simulation and therefore to run our
nian simulation is to employ a Trotter-Suzuki decomposition quantum algorithm for partial differential equations. This is
M an exponential improvement over classical algorithms for
[34–37] to express the transformation eit Ĥ = eit j=1 Ĥ j in solving PDEs, which scale exponentially with dimension
t K
terms of the product eit Ĥ = Mj=1 (ei K Ĥ j ) + O(t 2 /K ). Fol- [40–42]. The runtime of Hamiltonian simulation also scales
lowing this, a sequence of commutator approximations are polynomially on the operator norm  ∞ [3], so care must be
t
typically employed to decompose each term ei K Ĥ j into ele- taken to ensure that this norm is well behaved over the support
ments from the universal set [38]. We focus on the case where of the input state | f .
032306-4
QUANTUM ALGORITHM FOR NONHOMOGENEOUS LINEAR … PHYSICAL REVIEW A 100, 032306 (2019)
032306-5
JUAN MIGUEL ARRAZOLA et al. PHYSICAL REVIEW A 100, 032306 (2019)
VI. CONCLUSION
We have presented a quantum algorithm for preparing
quantum states that encode the solution to nonhomoge-
neous linear partial differential equations. The algorithm is
a continuous-variable version of the quantum algorithm for
linear systems of equations. For differential operators of fixed
degree, the runtime is polynomial in the dimension N: an
exponential improvement compared to classical algorithms
x2 y2
FIG. 5. (Top) Charge distribution ρ(x, y) = xy e− 2 e− 2 . The that compute the full solution of partial differential equa-
top-right and bottom-left quadrants are regions of positive charge, tions. However, there are important differences between this
while the remaining quadrants are negatively charged. (Bottom) quantum algorithm and classical approaches: the quantum
Electric-field lines reconstructed from the output state of the quantum algorithm assumes that the input state | f encoding the non-
algorithm. There are regions of zero electric field in each quadrant homogeneous term of the equation can be efficiently prepared
that arise from interfering contributions of the charge clouds sur- and the output is not an explicit specification of the solu-
rounding these points. The electric field is also zero at the origin, tion, but instead a state whose wave function is proportional
as expected from the symmetry of the charge distribution. to the solution. It is crucial to identify applications where
input states can be efficiently prepared and where sampling
from the output state—for example to compute expectation
B. One-dimensional integration
values—is enough for the task at hand. Note also that recent
The simplest nonhomogeneous differential equation is the breakthroughs in classical algorithms for linear systems of
one-dimensional equation Aψ (x) := dψdt(x) = f (x). A solution equations [44,45] apply only to low-rank operators, which do
to the equation is not appear in practice in solving partial differential equations.
Finally, the quantum algorithm provides a specific solu-
−1 tion to the nonhomogeneous equation, but to solve general
A f (x) = dx f (x), (27) boundary problems it is necessary to also incorporate solu-
tions to the homogeneous equation. The solution ψ (x) of
i.e., the solution is the indefinite integral of f (x). To apply the a nonhomogeneous partial differential equation can always
quantum algorithm to this problem we set  = P̂, in which be written as ψ (x) = ψH (x) + ψNH (x), where ψH (x) is a
case the output of the algorithm is the state |ψ = P̂−1 | f general solution to the homogeneous equation and ψNH (x) is
whose wave function is proportional to a specific solution to the nonhomogeneous equation. The cor-
responding boundary problem can be solved by first finding an
arbitrary solution ψNH (x) to the nonhomogeneous differential
ψ (x) = 2i dx f (x). (28) equation, then finding a solution to the homogeneous problem
032306-6
QUANTUM ALGORITHM FOR NONHOMOGENEOUS LINEAR … PHYSICAL REVIEW A 100, 032306 (2019)
−iδ 3 −iδ 3
e−i2P̂l X̂ j ei2P̂j X̂k e e−i2P̂j X̂k e 3 X̂ j
iδ 3
× ei2P̂l X̂ j e 3 X̂l 3 X̂ j
iδ 3 iδ 3
× e 3 X̂k e 3 X̂l . (A1)
This equation can be best understood by looking at the right
hand and building each term in sequence. To begin, note
that the first four cubic operators in the decomposition are
surrounded by operators of the form ei2P̂j X̂k which can be
expanded with unitary conjugation:
3
ei2P̂j X̂k eiδX̂ j e−i2P̂j X̂k = eiδ (X̂ j +X̂k ) .
3
(A2)
The first one in mode j is translated by the k and l modes,
3
leading to an exponent (X̂ j + X̂k + X̂l ) . Similarly, the other
3 3
three cubic gates lead to the exponents (X̂k + X̂l ) , (X̂l + X̂ j ) ,
3
and (X̂ j + X̂k ) . Expanding these polynomials gives a series of
operators which can be simplified to give the cubic gate on the
left-hand side.
The second decomposition we use is
= e2iαX̂ j X̂k X̂l e−iαX̂ j P̂k e−2iαX̂ j X̂k X̂l eiαX̂ j P̂k e−2iα
2
X̂ j2 P̂k P̂l 2 2 2 2 3
X̂ j2 P̂l
e2iα .
(A3)
iα X̂ j2 P̂k2
For this decomposition we use operations e and
e−2iα X̂ j P̂l , which are not in the universal set. For these, we
3 2
= ei2αX̂ j X̂k eik P̂k e−iαX̂ j X̂k e−ik P̂k e−i2αX̂ j X̂k
2
k P̂k X̂ j2 3 3
ei3α
FIG. 6. (Top) Function f (x) = sin(ωx)e−x /(2σ ) (solid green)
2 2
with ω = 5 and σ = 1.8. The wave function of the output state of × eik P̂k eiαX̂ j X̂k e−ik P̂k eiα k 34 X̂ j3
3 3 3
(A4)
the algorithm is also shown (dashed red). (Bottom) Function f (x) =
sin(ωx)e−x /(2σ ) with ω = 5 (solid green) and its integral (dashed
2 2
and
red), which can be computed analytically. The wave function of the α α α α
eiαX̂ j X̂k = ei2P̂j X̂k ei 12 X̂ j e−i4P̂j X̂k ei 12 X̂ j ei2P̂j X̂k e−i 6 X̂ j e−i 6 X̂k ,
2 2 4 4 4 4
032306-7
JUAN MIGUEL ARRAZOLA et al. PHYSICAL REVIEW A 100, 032306 (2019)
∞
i −y2 /2 −iÂxy
= √ dx dy (x) y e e g(x, y)| f |p1 |p2
2π −∞
= Â−1
approx | f |p1 |p2 , (B1)
where
√ √ √
2a e(p1 −iap2 ) /2a2
− ip1 π − p1 π Erfi p1√−iap
2
2
2a
F (p1 , p2 , a) = e−p1 (p1 −2iap2 )/2a
2
√ , (B4)
2a2
where Erfi(·) is the imaginary error function. Outputs can error δ(a) for the worst case values of p1 and p2 , which
be coarse grained by selecting a parameter p that when occur when p1 = −p2 = p. Figure 7 shows the relative
p1 and p2 are both in the interval [−p, p] the algorithm error δ(a)/(1/a) = aδ(a) as a function of a for fixed p. As
has succeeded. Let δ(a) = | a1 − F (p1 , p2 , a)|. We study the before, the error is largest for small a.
[1] P. W. Shor, in Foundations of Computer Science, 1994 Pro- [12] J. Biamonte, P. Wittek, N. Pancotti, P. Rebentrost, N. Wiebe,
ceedings, 35th Annual Symposium (IEEE, New York, 1994), pp. and S. Lloyd, Nature (London) 549, 195 (2017).
124–134. [13] D. W. Berry, G. Ahokas, R. Cleve, and B. C. Sanders, Commun.
[2] L. K. Grover, in Proceedings of the Twenty-eighth Annual ACM Math. Phys. 270, 359 (2007).
Symposium on Theory of Computing (ACM, Providence, RI, [14] D. W. Berry, A. M. Childs, and R. Kothari, in Foundations of
1996), pp. 212–219. Computer Science (FOCS), 2015 IEEE 56th Annual Symposium
[3] S. Lloyd, Science 273, 1073 (1996). (IEEE, New York, 2015), pp. 792–809.
[4] S. Hallgren, J. ACM (JACM) 54, 4 (2007). [15] D. W. Berry, A. M. Childs, R. Cleve, R. Kothari, and R. D.
[5] M. H. Freedman, A. Kitaev, and Z. Wang, Commun. Math. Somma, in Forum of Mathematics, Sigma (Cambridge Univer-
Phys. 227, 587 (2002). sity Press, Cambridge, UK, 2017), Vol. 5.
[6] D. Aharonov, V. Jones, and Z. Landau, Algorithmica 55, 395 [16] D. W. Berry, J. Phys. A: Math. Theor. 47, 105301 (2014).
(2009). [17] D. W. Berry, A. M. Childs, A. Ostrander, and G. Wang,
[7] A. M. Childs and W. van Dam, Rev. Mod. Phys. 82, 1 Commun. Math. Phys. 356, 1057 (2017).
(2010). [18] T. Xin, S. Wei, J. Cui, J. Xiao, I. Arrazola, L. Lamata, X. Kong,
[8] F. G. Brandao and K. M. Svore, in Foundations of Computer D. Lu, E. Solano, and G. Long, arXiv:1807.04553.
Science (FOCS), 2017 IEEE 58th Annual Symposium (IEEE, [19] S. K. Leyton and T. J. Osborne, arXiv:0812.4423.
New York, 2017), pp. 415–426. [20] Y. Cao, A. Papageorgiou, I. Petras, J. Traub, and S. Kais, New
[9] Fernando G. S. L. Brandão, A. Kalev, T. Li, C. Y.-Y. Lin, K. J. Phys. 15, 013021 (2013).
M. Svore, X. Wu et al., Leibniz Int. Proc. Info. (2019), https: [21] A. Montanaro and S. Pallister, Phys. Rev. A 93, 032324
//par.nsf.gov/biblio/10106371. (2016).
[10] S. Lloyd, M. Mohseni, and P. Rebentrost, Nat. Phys. 10, 631 [22] A. W. Harrow, A. Hassidim, and S. Lloyd, Phys. Rev. Lett. 103,
(2014). 150502 (2009).
[11] P. Rebentrost, M. Mohseni, and S. Lloyd, Phys. Rev. Lett. 113, [23] N. Wiebe, D. Braun, and S. Lloyd, Phys. Rev. Lett. 109, 050505
130503 (2014). (2012).
032306-8
QUANTUM ALGORITHM FOR NONHOMOGENEOUS LINEAR … PHYSICAL REVIEW A 100, 032306 (2019)
[24] B. D. Clader, B. C. Jacobs, and C. R. Sprouse, Phys. Rev. Lett. [35] M. Suzuki, Proc. Jpn. Acad., Ser. B 69, 161 (1993).
110, 250504 (2013). [36] I. Dhand and B. C. Sanders, J. Phys. A 47, 265206 (2014).
[25] A. Childs, R. Kothari, and R. Somma, SIAM J. Comput. 46, [37] T. Kalajdzievski, C. Weedbrook, and P. Rebentrost, Phys. Rev.
1920 (2017). A 97, 062311 (2018).
[26] L. Wossnig, Z. Zhao, and A. Prakash, Phys. Rev. Lett. 120, [38] S. Sefi and P. van Loock, Phys. Rev. Lett. 107, 170501 (2011).
050502 (2018). [39] T. Kalajdzievski and J. M. Arrazola, Phys. Rev. A 99, 022341
[27] S. Lloyd and S. L. Braunstein, Phys. Rev. Lett. 82, 1784 (1999). (2019).
[28] S. L. Braunstein and P. van Loock, Rev. Mod. Phys. 77, 513 [40] J. W. Thomas, Numerical Partial Differential Equations: Finite
(2005). Difference Methods (Springer Science & Business Media, New
[29] N. Killoran, T. R. Bromley, J. M. Arrazola, M. Schuld, N. York, 2013), Vol. 22.
Quesada, and S. Lloyd, arXiv:1806.06871. [41] A. G. Werschulz, The Computational Complexity of Differential
[30] J. M. Arrazola, T. R. Bromley, J. Izaac, C. R. Myers, K. Brádler, and Integral Equations: An Information-based Approach (Ox-
and N. Killoran, Quantum Science and Technology 4 (2018). ford University Press, Oxford, 1991).
[31] L. O’Driscoll, R. Nichols, and P. A. Knott, Quantum Mach. [42] K. Ritter and G. W. Wasilkowski, Lect. Appl. Math. 32, 677
Intel. 1, 5 (2019). (1996).
[32] H.-K. Lau, R. Pooser, G. Siopsis, and C. Weedbrook, Phys. Rev. [43] M. Abadi, A. Agarwal, P. Barham, E. Brevdo, Z. Chen, C.
Lett. 118, 080501 (2017). Citro, G. S. Corrado, A. Davis, J. Dean, M. Devin et al.,
[33] N. Killoran, J. Izaac, N. Quesada, V. Bergholm, M. Amy, and arXiv:1603.04467.
C. Weedbrook, Quantum 3, 129 (2019). [44] A. Gilyén, S. Lloyd, and E. Tang, arXiv:1811.04909.
[34] H. F. Trotter, Proc. Am. Math. Soc. 10, 545 (1959). [45] N.-H. Chia, H.-H. Lin, and C. Wang, arXiv:1811.04852.
032306-9