Available via license: CC BY 4.0
Content may be subject to copyright.
Measurement on quantum devices with applications to time-dependent density
functional theory
Jun Yang, James Brown, James Daniel Whitfield
Dartmouth College, Department of Physics and Astronomy, Hanover NH, 03755
(Dated: September 10, 2019)
Quantum algorithms are touted as a way around some classically intractable problems such as the
simulation of quantum mechanics. At the end of all quantum algorithms is a quantum measurement
whereby classical data is extracted and utilized. In fact, many of the modern hybrid-classical ap-
proaches are essentially quantum measurements of states with short quantum circuit descriptions.
Here, we compare and examine three methods of extracting the time-dependent one-particle prob-
ability density from a quantum simulation: direct Z-measurement, Bayesian phase estimation and
harmonic inversion. We have tested these methods in the context of the potential inversion problem
of time-dependent density functional theory. Our test results suggest that direct measurement is
the preferable method. We also highlight areas where the other two methods may be useful and
report on tests using Rigetti’s quantum device. This study provides a starting point for imminent
applications of quantum computing.
Simulating quantum systems on a classical computer
is a difficult problem even for a supercomputer due to
the fact that the Hilbert space grows exponentially with
the system size [1]. A universal quantum computer is
believed to be the solution of the difficulty, where it is
known that a wide class of physical systems can be sim-
ulated efficiently on a quantum computer [1–3].
Density functional theory (DFT) is a powerful tool in
simulating condensed matter systems [4]. DFT converts
the problem of solving a many-particle system to the
problem of solving a non-interacting system with a new
scalar potential. The additional potential term in the
non-interacting system is known as the Kohn-Sham po-
tential. In the Kohn-Sham (K-S) system, the calculation
of an exchange-correlation term is required, which can
only be obtained by approximation methods given the
computational complexity of its computation [5]. In the
article [6], a method of combining simulations on a quan-
tum computer and classical DFT calculation is proposed,
the exchange-correlation term can be obtained from a
quantum computer to enhance the accuracy of DFT cal-
culation.
As an extension of DFT, time-dependent density func-
tional theory (TDDFT) [7] is widely used in finding the
dynamics of the system when time-dependent potentials
are present. Similar to DFT, TDDFT uses the time de-
pendent K-S system where again the key hurdle is con-
structing the required K-S potentials. We call the task
of constructing such K-S potentials when given the time-
evolution of the on-site probability density, the K-S po-
tential inversion problem. In article [8], a scheme of solv-
ing the K-S potential inversion problem utilizing a quan-
tum computer was proposed. We have recently returned
to this proposal with improved numerical methods for in-
verting the potential [9]. To obtain the K-S potential, we
need to get the density of the time evolved many-particle
system using a quantum computer. In this paper, we will
present three different methods of measuring the density
operator on a quantum computer and compare the per-
formance of the methods.
An outline for the remainder of the article is as follows:
Next, we discuss the phase estimation approach to mea-
surement. Then we describe the circuit implementation
for measuring the on-site fermionic density. Qubit de-
scriptions for the fermionic operator are explained before
turning to the illustration of a two-electron test. The
three schemes for extracting the density are tested nu-
merically and compared. We have also performed pre-
liminary tests of these techniques on Rigetti’s quantum
computer and report briefly on our results. Finally, we
draw conclusions to close the manuscript.
Phase estimation.— The clearest understanding of the
quantum simulation paradigm is given by the view that
spectra are Fourier transforms of auto-correlation func-
tions e.g. f(t) = hψ|ψ(t)i. In a time-dependent approach
to quantum mechanics [10, 11], the spectrum is given by
ε(ω)∝Zdt f(t)eiωt =Zdt hψ|U(t)|ψieiωt
∝X|cj|2Zdt ei(ω−Ej)t∝X|cj|2δ(ω−Ej) (1)
Here U(t) is a unitary operator given by U(t) = e−iHt =
Pe−iEkt|ki hk|and ψ=ψ(0) = Pck|ki.
We can apply this same view to phase estimation.
The first Hadamard followed the controlled unitary gate
is used to impart a relative phase such that the ini-
tial state |0i |ψiwhich then evolves into 1
2|0i[|ψi+
|ψ(t)i] + 1
2[|1i |ψi − |ψ(t)i]. Before measurement, the fi-
nal Hadamard transform creates a state proportional to
|0i[|ψi+|ψ(ti] + |1i[|ψi−|ψ(t)i]. The bracketed terms
are the k= 0 and k= 1 points of the two-bit discrete
Fourier transform respectively. Measurement probabili-
ties are then given by
P(0|t) = 1
2+1
2[hψ(t)|ψi+hψ|ψ(t)i] (2)
arXiv:1909.03078v1 [quant-ph] 6 Sep 2019
2
|0iH•H
|ψiU(t)U2(τ)|ψ0i
Figure 1. The circuit for measuring the density matrix. The
half before the dashed line is used for evolving the state, the
half after is used for doing the density measurement.
To implement the measurement of an arbitrary observ-
able, we will consider the circuit as shown in Fig. 1. The
circuit has two parts, the half before the dashed line is for
evolving the initial state for time tunder a fixed fermionic
Hamiltonian given in second quantization as
H=X
pq
hpqa†
paq+1
2X
pqrs
hpqrs a†
pa†
qaras(3)
where operators {aj}follow a†
qap+apa†
q=δpq and apaq=
−aqap. The circuit in Fig. 1 does not explicitly include
the state preparation but can be included as part of U(t)
if required. The latter half is a phase estimation circuit
[12] where U2(τ) = e−iH2twhere H2is the observable to
be measured.
For a general state, the phase estimation algorithm
yields the eigenvalues Ej’s with probability |cj|2. To be
precise, for a general state |ψi=Pkck|ki, where |ki’s
are the eigenvectors of the Hamiltonian H, the probabil-
ity of measuring zero on the top register
P(0|τ, t) = X
k
|ck(t)|2cos2Ekτ
2
=1
2+1
4X
k
|ck(t)|2eiEkτ+e−iEkτ(4)
In this article, we only consider H2=nj=a†
jajin
order to measure the local on-site density at site j. The
eigenvalues of nj=a†
jajare λ= 0,1 so that the wave
function after evolution under U(t) is given by ψ(t) =
c0(t)|ψnj=0i+c1(t)|ψnj=1 i. The expectation value of
the density is given by
hnj(t)i=hψ(t)|a†
jaj|ψ(t)i=|c1(t)|2(5)
Qubit Encoding.— To implement the evolution and
phase estimation algorithm on a quantum computer, we
need to encode the Hamiltonians into qubits. Jordan-
Wigner (JW) transformation is a standard way to encode
a fermionic system of Morbitals into Mqubits using a
tensor product of Pauli operators
ap=1
2(Xp+iYp)Z1Z2. . . Zp−1(6)
a†
p=1
2(Xp−iYp)Z1Z2. . . Zp−1(7)
With these transformations, the fermionic Hamiltonian
can be encoded into qubit representations. Thus, the
Hamiltonian can be written as H=Pihi, where all the
hi’s are in terms of qubit operators.
There is not an easy way to construct arbitrary unitary
operators on a quantum computer. In order to simulate
the propagator U(t), we applied Trotter decomposition.
U(t) = e−iHt ≈e−ih1t/N e−ih2t/N . . . e−ihnt/N N(8)
Each term in the decomposition above is straight-forward
to simulate on a quantum computer [13].
Two-electron test system.— The two-electron system
that we tested on is the four spin-orbital HeH+model
with parameters matching the example found in Ref. [14].
The basis functions are orthogonalized and then trans-
formed such that the one-body Coulomb matrix is di-
agonal. This transformation was chosen so that a cor-
responding scalar time-dependent Kohn-Sham potential
could be calculated using for this system using the
method of Reference 9. The initial state at t= 0 places
two electrons in the first two modes of opposite spin.
This state is obtained by employing two X-gates to pre-
pare ψ(0) = |1100i.
Using Rigetti’s quantum virtual machine [15], we then
evolve the system under its Hamiltonian for times less
than three atomic units. The propagation is implemented
via first-order Trotterization with three time steps. To re-
duce the Trotter error in evolution, either a shorter Trot-
ter step or a higher order Trotter approximation must be
used [16]. This means more quantum gates are needed,
making it hard to be implemented on a near term device.
Additional sources of error are associated with finite sam-
pling from the binomial distribution and the error asso-
ciated with the inference steps. To make the virtual ma-
chine slightly closer to a real quantum computer, in all
methods below, measurement noise was added into the
system, giving 1% probability of flipping the qubit. It
should be noted that the quantum noise found on the
actual device was much higher.
In Figs. 2 and 5, we used 3000 quantum measurement
samples per time-point. For the plot of harmonic in-
version depicted in Fig. 4, a total of 120,000 quantum
measurements occur for the density at each time point.
This is because there were 40 equally spaced τ-points and
3000 quantum measurements were used per fixed τ. In all
three of these plots, the density according to the Trotter-
ize evolution is plotted in pink with a fading color region
representing the decay of the binomial distribution with
parameters p=n(t), ntrials = 3000.
Method 1: Z-basis Measurement.— In the first of the
three methods investigated, we rely on the fact that the
Jordan-Wigner transformation of the on-site density op-
erator has a simple form a†
pap= (1−Zp)/2. Thus, we can
directly measure the local density operator by measuring
3
Zpwithout appealing to the phase estimation circuit af-
ter the dotted line in Fig. 1.
For an arbitrary wave function |ψ(t)i=c0(t)|ψnp=0i+
c1(t)|ψnp=1i, where ψnpdenotes the state projected into
the subspace where the p-th qubit is in state np. Both
amplitudes can be obtained from the measurement giving
hZp(t)i=|c0(t)|2− |c1(t)|2.
By repeating the measurement many times at each
value of 0 ≤t≤3, we obtain the expectation value
of the density. The results based on 15 equally spaced
time-points with 3000 measurements at each fixed time
are shown in Fig. 2. The exact time evolution of the
density is also shown in the figure for comparison along
with error bars of 2σreflective of the N= 3000 sample
variance of the binomial distribution.
The simplicity of this measurement approach reduces
the classical runtime to the lowest of the three methods
compared, and the convergence of the error bars is faster
than the Bayesian measurement discussed later.
Figure 2. The expectation values of a†
1a1measured via Z-
basis measurement versus exact Trotter solution. Error bars
are twice that of the standard errors.
Method 2: Harmonic Inversion.— Harmonic inversion
is a technique of extracting the amplitudes Aj, frequen-
cies fj, phases φjand exponential decay constants αjout
of a signal,
f(τ) = X
j
Aje−i(2πfjτ−φj)−αjτ(9)
which is evenly sampled [17, 18]. The signal recon-
structed from harmonic inversion has the same form as
the probability P(0|τ) except for the decaying term which
is negligible in real implementation. The decay of the sig-
nal could be used to represent the decaying fidelity of the
Trotter approximation with the target evolution opera-
tor but this decay is a priori unknown. By comparing
the form of the reconstructed signal with the probability,
we can obtain the density from the reconstructed signal.
The results of density measurement through harmonic
inversion are shown in Fig. 3. Each point in Fig. 3 was
Figure 3. The expectation values of a†
1a1measured via har-
monic inversion versus exact Trotter solution. No error bars
for this plot because the error comes from two sources, one is
from the sampling error at different time τ, the other is from
the reconstructing the density from harmonic inversion.
computed through harmonic inversion using the HarmInv
package [19]. Because the local density operator a†
pap
only has eigenvalues zero and one, the measurement out-
come has a simple form
P(0|τ, t) = A0(t) + A1(t)e−i2πfτ +ei2π fτ (10)
where A0(t) = 1
2(2 − |c1(t)|2), A1(t) = |c1(t)|2/4, and
f= 1/2π. One example of the reconstruction is shown
in Fig. 4.
Figure 4. Black dots are the original data obtained from
Rigetti’s quantum virtual machine They were sampled at 40
equidistant τ-points between 0 and τmax with 3000 samples
per τ-point. Blue line is the reconstructed function at t= 2.8
a.u. through harmonic inversion. Note that this reconstruc-
tion occurs at every each fixed value of t.
Method 3: Bayesian inference.— Bayesian inference
can be used to estimate the density as well. As a pow-
erful tool of making inferences, Bayesian inference has
4
wide applications. We applied Bayesian inference to in-
fer the unknown parameters in a quantum system which,
in our case, is the on-site density. The density estimation
was implemented via sequential Monte Carlo (SMC) [20].
This method requires the most communication between
the classical and quantum processors since the SMC sug-
gests each τ-point based on the previous outcomes. The
Bayesian experimental design is based on the implemen-
tation found in the QInfer package [21]. Bayesian in-
ference gives the probability distribution of a parameter
over the parameter space. The final decision is made
according to the posterior probability P(θ|d1, d2. . . dN),
where θis the parameter we want to estimate, di’s are the
outcome of each measurement. In the present application
θ≡ hnj(t)i.
Recall the Bayesian rule, the posterior probability is
updated by carrying out experiments sequentially,
P(θ|d1, d2,...dN)∝
N
Y
i=1
P(di|θ)P(θ) (11)
where P(θ) is the prior probability, P(di|θ) is the likeli-
hood function.
The likelihood function is the information we know
about the parameter before conducting any experiments.
Because we know nothing before the experiment, we can
initialize the prior with a uniform distribution over the
parameter space. For the phase estimation circuit of
Fig. 1, the likelihood function is given by
P(d| hnj(t)i;τ) = 1
2+(−1)d
4hψ(t)|{U2(τ) + U†
2(τ)}|ψ(t)i
(12)
where U2(τ) = exp(−iτa†
jaj) and d= 0 or 1. Note, when
d= 0 we recover Eq. (2). With this we can rewrite the
likelihood function as
P(d| hnj(t)i;τ) = δd,0+(−1)d
2(cos τ−1) hnj(t)i(13)
This can be compared with Eq. (4) in the case that d= 0.
The results of Bayesian inference are shown in Fig. 5.
Bayesian inference has good performance within a wide
range of the time domain except at the boundary of the
estimate domain e.g. when the density is one or zero.
This is based on numerical evidence since the majority
of the points at or near the boundary of the estimation
domain needed to be discarded when cleaning the data
as discussed below.
Unlike harmonic inversion, τin the phase estimation
circuit is not required to be evenly spaced. Another ad-
vantage of Bayesian inference is that we do not need to
know the exact form of the function to be estimated a pri-
ori. Bayesian inference could also be applied to estimate
more general parameters.
Comparison
Figure 5. The expectation values of a†
1a1measured via
Bayesian inference versus exact Trotter solution. The first
point shows a large deviation from the Trotter solution typi-
cal of behavior whenever the exact density’s value is close to
one. Error bars are twice that of the standard errors.
To quantify the accuracy of these density extraction
methods, we employ the L1norm to measure the devia-
tion from the Trotter solution. For discrete data points,
the deviation is given by the loss function on the density
at the first site: L=PN
k|˜n1(tk)−n1(tk))|/N.
Figure 6. Loss function versus number of measurements of the
quantum computer (trials). Red diamonds, black triangles
and blue circles are drawn from harmonic inversion, Bayesian
inference and Z-basis measurement respectively. The slope of
the fitting lines are -0.4865, -0.3747 and -0.3980 respectively.
Points 5σaway from the exact density under the Trotter ap-
proximation are not used for calculating the loss function.
This resulted in 73.87%, 87.26% and 90.07% of points used in
the plotted data respectively. Harmonic inversion measures
40 times more than the other two methods, so the actual data
and fitting line should be shifted to the right by 40 times the
number of measurements showing in the figure.
Fig. 6 shows how the loss function scales with the num-
ber of trials for each of the three approaches. The con-
5
vergence rate for determining the bias of a coin would
be 0.5 but here additional measurement error has been
introduced into the model which prevents L= 0 situa-
tion even with an infinite number of samples. Further,
the Bayesian and harmonic inversion techniques some-
times reported anomalously poor estimates of the density
at a given time. A single fluctuation of this type along
the time trace of the density entirely dominates the loss
function. For the sake of comparison, we have cleaned
the data by removing anomalous density values that are
too far from the exact solution. Although this is an ad
hoc procedure that requires knowing the exact answer,
we have tested our data at various levels of cutoff finding
that at any fixed cutoff harmonic inversion had the most
points discarded and consistently displayed marginally
faster convergence rates.
Regardless of the possible improvement in convergence,
it should be reminded that the harmonic inversion tech-
nique uses many quantum computer queries to estimate
P(0|τ, t) at variable τbefore inferring the density at a
fixed time t. In comparing the three methods, all require
time evolution of the system wave function to time t.
In the harmonic inversion and Bayesian estimation tech-
niques, additional gates are needed for the τpropagation
under the observable for density. The difference between
queries in harmonic inversion and Bayesian inference is
the selection of the τparameter in U2(τ).
While the convergence rates are all approximately the
same, it is clear that the Z-basis measurement has the
best performance in terms of the number of queries of
the quantum computer. In the case considered here, the
direct Zmeasurements are convenient for the Jordan-
Wigner encoding. In other circumstances with different
fermion-to-spin transforms, the direct measurement tech-
nique may not be as fruitful. For existing and near-term
quantum devices, the constraints of low circuit depth sug-
gests direct measurement of the Zoperators as the best
path forward when using Jordan-Winger transformed
qubit Hamiltonians.
The runtime of these three methods also varies. Since
direct Z-measurements are the simplest from an infer-
ence point of view, the classical computation time is also
the least. Bayesian inference requires many steps for the
sequential Monte Carlo to converge [20]. Consequently,
this method used the longest amount of classical com-
putational time. Although harmonic inversion uses 40
times more measurement per time-point, it is interest-
ing to note that it only took an intermediate amount of
classical processing time.
Conclusions.— We have tested three different methods
of measuring the on-site density operator for a toy model
inspired by TDDFT. We were able to conclude that direct
Zmeasurements obtains the best estimates of the on-site
density for a given number of quantum computer queries.
This is based on the use of the Jordan-Wigner transform
and simulated measurement noise. Of course, we could
have considered other fermion-to-spin transforms which
lead to different encodings of the a†
iai.
For improving our noise models, we can do no better
than testing our circuits on current and future quantum
devices. We tested our circuits on Rigetti’s quantum de-
vice but found that the loss function depends heavily
on which qubits are used as well as the permutation of
qubit labels within the circuit. Time evolution under
the full Hamiltonian did not return any signal even when
using only one first-order Trotter step. We therefore re-
sorted to using a truncated Hamiltonian which included
the one-body Hamiltonian and only the Coulomb-like
(hijji) terms of the two-body Hamiltonian. After en-
coding and exponentiation, this Hamiltonian results in
66 universal gates and compiled non-deterministically to
approximately 200 allowable gates on the Rigetti device.
Due to decoherence, only a weak signal was present where
amplitudes recovered were between three and twenty per-
cent of the exact solution. The recovered amplitude de-
pended mostly on qubit selection but also changed run-
to-run. The frequency and sinusoidal shape of the signal
was recovered more reliably. In our present study, the
eigenenergies were not interesting but we suspect that
problems that depend on the frequencies may be more
successfully calculated on the current Rigetti device.
We plan to continue our inquiry into the TDDFT po-
tential inversion problem using existing and forthcoming
quantum technology. Tasks that avoid QMA-hard state
preparation problems will continue to be of interest to
those looking for new applied areas of quantum compu-
tation.
Acknowledgements.— JY, JB and JDW were sup-
ported by the U.S. Department of Energy, Office of Sci-
ence, Office of Advanced Scientific Computing Research,
under the Quantum Computing Application Teams pro-
gram (Award 1979657). JDW was also supported by the
NSF (Grant 1820747) and additional funding from the
DOE (Award A053685). Calculations were performed
using Dartmouth’s Discovery Linux HPC Cluster.
[1] I. M. Georgescu, S. Ashhab, and F. Nori, Rev. Mod.
Phys. 86, 153 (2014).
[2] S. Lloyd, Science 273, 1073 (1996).
[3] Y. Cao, J. Romero, J. P. Olson, M. Degroote, P. D.
Johnson, M. Kieferov´a, I. D. Kivlichan, T. Menke,
B. Peropadre, N. P. D. Sawaya, S. Sim, L. Veis,
and A. Aspuru-Guzik, arXiv e-prints , arXiv:1812.09976
(2018), arXiv:1812.09976 [quant-ph].
[4] P. Hohenberg and W. Kohn, Phys. Rev. 136, B864
(1964).
[5] N. Schuch and F. Verstraete, Nature Physics 5, 732
(2009).
[6] R. Hatcher, J. A. Kittl, and C. Bowen, arXiv e-prints ,
arXiv:1903.05550 (2019), arXiv:1903.05550 [quant-ph].
[7] E. Runge and E. K. U. Gross, Phys. Rev. Lett. 52, 997
6
(1984).
[8] J. D. Whitfield, M.-H. Yung, D. G. Tempel, S. Boixo,
and A. Aspuru-Guzik, New J. Phys. 16, 083035 (2014).
[9] J. Brown, J. Yang, and J. D. Whitfield, arXiv preprint
arXiv:1904.10958 (2019).
[10] E. Heller, Acc. Chem. Res. 14, 368 (1981).
[11] D. J. Tannor, Introduction to Quantum Mechanics: A
Time-Dependent Perspective (University Science Books,
2006).
[12] A. Yu. Kitaev, quant-ph/9511026 (1995).
[13] J. D. Whitfield, J. Biamonte, and A. Aspuru-Guzik,
Molecular Physics 109, 735–750 (2011).
[14] A. Szabo and N. Ostlund, Modern Quantum Chemistry:
Introduction to Advanced Electronic Structure Theory,
Dover Books on Chemistry (Dover Publications, 2012).
[15] R. S. Smith, M. J. Curtis, and W. J. Zeng, arXiv preprint
arXiv:1608.03355 (2016).
[16] N. Hatano and M. Suzuki, “Finding exponential prod-
uct formulas of higher orders,” in Quantum Annealing
and Other Optimization Methods, edited by A. Das and
B. K. Chakrabarti (Springer Berlin Heidelberg, Berlin,
Heidelberg, 2005) pp. 37–68.
[17] V. A. Mandelshtam and H. S. Taylor, J. Chem. Phys.
107, 6756 (1997).
[18] V. Mandelshtam, Prog. Nucl. Mag. Res. Sp. 38, 159
(2001).
[19] S. G. Johnson, “Harmonic inversion of time signals
by the filter diagonalization method,” https://github.
com/NanoComp/harminv (2005).
[20] C. E. Granade, C. Ferrie, N. Wiebe, and D. G. Cory,
New J. Phys. 14, 103013 (2012).
[21] C. Granade, C. Ferrie, I. Hincks, S. Casagrande,
T. Alexander, J. Gross, M. Kononenko, and Y. Sanders,
Quantum 1, 5 (2017).