Introduction

Quantum simulation and quantum computing have been attracting tremendous attention in recent years. Among the rapidly advancing quantum hardwares1, cold atoms provide a quantum simulation platform with excellent controllability and scalability2,3,4,5. In the last two decades, cold atom based quantum simulations have achieved fantastic progress not only along the line of conceptually exotic physics such as artificial gauge fields6,7,8, and topological matters9, but also along the line of simulating computationally difficult problems such as BEC-BCS crossover10, High-Tc physics11,12,13,14,15, and non-equilibrium dynamics16, where its exceptional quantum advantage has been demonstrated.

In quantum simulations aiming for demonstration of fundamental physical concepts, it is not crucial to precisely calibrate the system. However, in order to use quantum simulations to solve computationally difficult problems, it is required to make the simulation precise—for example in the study of quantum criticality and in solving spin-glass problems, the physical properties of interest are sensitive to Hamiltonian parameters. And in quantum simulations of many-body localization using an incommensurate optical lattice, it has been found that calibration problems cause qualitative disagreement17,18,19,20 with the targeting Aubry–Andre (AA) model21,22. This issue also arises generically in using speckle-pattern induced disorder optical potentials to simulate localization physics23,24,25,26,27,28,29,30,31,32,33,34, as the onsite energies and tunnelings are not programmable, let alone the simulation precision.

Here, we consider integration of the recently developed DMD techniques in controlling optical potentials13,35,36,37,38 to optical lattices, and calibrate the platform towards precise programmable quantum simulations. We develop an efficient algorithm, which can systematically construct an inhomogeneous optical potential to precisely simulate a given tight binding lattice model, i.e., both the onsite energies and the tunnelings are made precisely programmable. Its efficiency relies on the physical locality. For benchmarking, we provide detailed numerical results for AA and Anderson localization (AL) models, where we show our approach has adequate programmability and systematically eliminates calibration errors. We show that our approach can also be used to implement atom-based quantum sampling algorithms such as boson sampling39,40 and determinantal point process41,42, having promising applications to quantum machine learning. Our protocol provides precise programmability to the quantum platform of optical lattice, which is intrinsically demanded for quantum simulations aiming for computationally difficult problems.

Results

Theory setup

For atoms confined in an optical potential, the Hamiltonian description is

$$H=-\frac{{\hslash }^{2}}{2m}\frac{{{\mathrm{d}}}^{2}}{{\mathrm{d}}{x}^{2}}+{V}_{{\rm{p}}}(x)+{V}_{{\rm{D}}}(x).$$
(1)

Here we have separated the optical potential into a primary part \({V}_{{\rm{p}}}(x)=\frac{{V}_{{\rm{p}}}}{2}\cos (2kx)\) created by standard counter propagating laser beams and an additional potential VD(x) created by DMD13,35,36,37,38 or sub-wavelength potential43,44 techniques. The primary part has lattice translation symmetry with the lattice spacing determined by the forming laser wavelength. Hereafter, we use the lattice constant a = π/k as the length unit and the photon recoil energy of the lattice ER = 2k2/2m as the energy unit. The added potential VD(x) in general has no homogeneity, and with the present technology it is typically much weaker than the primary lattice. A targeting tight-binding Hamiltonian matrix for the continuous system to simulate is referred to as \({{\mathcal{H}}}^{\star }\), which contains onsite energies ϵi and tunnelings \({J}_{\langle ii^{\prime} \rangle }\), with \(i,i^{\prime}\) labeling lattice sites determined by the primary optical potential. In the following, we describe our numerical method to reverse engineer VD(x) and Vp(x) that makes the precise tight-binding model description of H in Eq. (1) our target, \({{\mathcal{H}}}^{\star }\).

Firstly, we describe our method for efficient extraction of a tight-binding model of the continuous Hamiltonian H to obtain a single band effective Hamiltonian. Without the inhomogeneous potential VD(x), the precise tight binding model of the system can be efficiently constructed by introducing Bloch modes, because different modes with different lattice momenta are decoupled due to lattice translation symmetry. We denote the Hamiltonian matrix in the Wannier function basis {wm(x − xi)} as \({{\mathcal{H}}}_{mi;m^{\prime} i^{\prime} }\), with \(m,m^{\prime}\) labeling different bands running from zero (lowest band) to a high-band cutoff Mc, and \(i,i^{\prime}\) the Wannier function localized centers (or equivalently the lattice sites of the primary lattice). This Hamiltonian matrix takes a block diagonalized form with the decoupled blocks corresponding to different bands45,46. However, in the presence of an inhomogeneous potential VD(x), the generated matrix elements \(\int\ {\mathrm{d}}x\ {w}_{m}(x-{x}_{i}){V}_{{\rm{D}}}(x){w}_{m^{\prime} }(x-{x}_{i^{\prime} })\) induce inter-band couplings. We propose to use Wegner flow47,48 to decouple different bands, which then produces a precise tight-binding model. The band decoupling procedure follows a flow equation,

$$\frac{{\mathrm{d}}{\mathcal{H}}(l)}{{\mathrm{d}}l}=[\eta (l),{\mathcal{H}}(l)],$$
(2)

that generates a continuous unitary transformation \({\mathcal{H}}(l)=U(l){\mathcal{H}}(0){U}^{\dagger }(l)\). Here, the anti-Hermitean generator \(\eta (l)=\frac{{\mathrm{d}}U(l)}{{\mathrm{d}}l}{U}^{\dagger }(l)\), which we choose to be \(\eta (l)=[G,{\mathcal{H}}(l)]\), with \({G}_{mi;m^{\prime} i^{\prime} }={\delta }_{ii^{\prime} }\left[2{\delta }_{mm^{\prime} }-{\delta }_{m,0}{\delta }_{m^{\prime} ,0}\right]\). Following the flow from l = 0 to +, \({\mathcal{H}}(l)\) converges to a matrix that commutes with G because

$$\begin{array}{l}{\rm{Tr}}{[{\mathcal{H}}(l)-G]}^{2}\ge 0,\\ \frac{{\mathrm{d}}}{{\mathrm{d}}l}{\rm{Tr}}{[{\mathcal{H}}(l)-G]}^{2}=-2{\rm{Tr}}[{\eta }^{\dagger }(l)\eta (l)]\le 0.\end{array}$$
(3)

This means the coupling between the m = 0 block of the matrix \({\mathcal{H}}\) and other blocks monotonically converges to 0. A more thorough analysis shows an exponential convergence with a convergence speed inversely proportional to the band gap (see “Methods” section). We remark that although there are different ways of choosing the generator η, other generators may not produce a Wegner flow with strict exponential convergence, which we prove for the particular generator used here. This means our approach is applicable as long as the inhomogeneous potential VD(x) is not too strong to close the band gap. The finite-depth flow equation generates a local unitary that defines a precise tight-binding model as the converged m = 0 Hamiltonian block, which is denoted as the single band effective Hamiltonian \({{\mathcal{H}}}_{{\rm{eff}}}\).

Secondly, we develop a numerical optimization method to adjust the potential VD(x) to minimize the difference between \({{\mathcal{H}}}_{{\rm{eff}}}\) and \({{\mathcal{H}}}^{\star }\). We choose a Frobenius-norm based cost function f = f0 + λ1f1, where f0 and f1 are Frobenius norms for the difference in the onsite energies and tunnelings, respectively, and a hyper-parameter λ1 is introduced to afford extra weight to the tunneling for better optimization-performance. In our numerics, we parameterize

$${V}_{{\rm{D}}}(x)=\mathop{\sum }\limits_{n = 0}^{2L-1}\frac{{\widetilde{V}}_{n}}{2}\cos \left(2\frac{n}{L}kx+{\widetilde{\phi }}_{n}\right),$$
(4)

where L is the number of periods of the primary lattice, and \({\widetilde{V}}_{n}\), \({\widetilde{\phi }}_{n}\) are variational parameters. The maximal spatial frequency of the DMD potential is about twice over the frequency of the primary lattice. Regarding the phase stabilization, it is required to stabilize the phase between the DMD and the primary lattice potential, which has been achieved in recent experiments49. We start from a random initialization, obtain \({{\mathcal{H}}}_{{\rm{eff}}}\) through Wegner flow, and then update the optical potential through a gradient descent method. This procedure is iterated until the cost function is below a threshold of our request.

Furthermore, our method is highly efficient by making use of locality. Considering a system with large system size, instead of performing the Wegner-flow for the full problem which then has a computation complexity of O(L3), we split the system into small pieces, with an individual length Lp. The adjacent pieces have about one third of their length overlapped with each other. We optimize the optical potential to reproduce the precise tight-binding model piece-by-piece, and then glue them together. This is sensible because of the locality in the problem—the onsite energy at one site and the tunnelings between two sites are both determined by their neighboring potential, following the finite-depth Wegner flow. Note that one problem arises that the potential may not be smooth in the overlapping regions, as the obtained potential could be inconsistent in optimizing the two adjacent pieces. To solve this problem, we add λ2f2 to the cost function, where f2 is the Frobenius norm of the difference of the potential in the overlapping region obtained in the optimization of its belonging two pieces (see “Methods” section). The piece-by-piece procedure is swept back-and-forth for convergence, analogous to the optimization in the standard density-matrix-renormalization group calculation50. In the sweeping process, we find a monotonic decrease in the difference between \({{\mathcal{H}}}_{{\rm{eff}}}\) and \({{\mathcal{H}}}^{\star }\) in the whole system, and that the converged optical potential is smooth. The computation complexity scaling is thus reduced to O(L).

Although this work focuses on one-dimensional lattices, the developed approach is adaptable to high-dimensional lattices as well (see Supplementary Note 1 and Supplementary Fig. 1). The sweeping process in the piece-by-piece optimization has more choices for higher-dimensional systems. How to perform the sweeping in an optimal way is worth future study.

Application to quantum simulation of AA model

In the study of quantum localization physics, AA model has been investigated extensively in both theory and experiment17,18,19,20,28,49,51,52,53,54,55,56. Its Hamiltonian reads as

$$\begin{array}{l}{{\rm{H}}}_{{\rm{AA}}}^{\star }=-{{\rm{J}}}_{{\rm{AA}}}{\sum \limits_{i}}\left({b}_{i+1}^{\dagger }{b}_{i}+h.c.\right)\\ +\frac{{\epsilon }_{{\rm{AA}}}}{2}{\sum \limits_{i}}\cos (2\pi \alpha i+\phi ){b}_{i}^{\dagger }{b}_{i},\end{array}$$
(5)

where \({b}_{i}^{\dagger }\) (bi) denotes the creation (annihilation) operator on a lattice site i, α is an irrational number, JAA is the site-independent tunneling, ϵAA describes the strength of the onsite energies, and ϕ is an arbitrary phase. Here, we choose α as the golden ratio \((\sqrt{5}-1)/2\), which is approximated by the Fibonacci sequence (Fn) as Fn/Fn+1 in a finite-size calculation. Because of its energy independent duality defined by a Fourier transform, the model exhibits a phase transition from all wave-function localized to all extended, which makes it natural place to examine one-dimensional localization criticality.

In the optical lattice experiment17, the AA model Hamiltonian is achieved by using an incommensurate bichromatic potential, a primary lattice perturbed by a second weak incommensurate lattice with \({V}_{{\rm{D}},{\rm{rough}}}(x)={V}_{1}\cos (2\alpha kx)/2\) following our notation in Eq. (1). However, its corresponding tight-binding model is not a precise AA model—there are corrections making tunnelings inhomogeneous and generating higher-order harmonics, which generically breaks the central ingredient of duality of the AA model57. The effects of such corrections have been established both in theory18 and experiment19,20. This problem can be solved by using our precise quantum simulation method.

Taking the general form of VD(x) in Eq. (4), we find the variational minimization for the precise quantum simulation of the AA model automatically reduces to a more specific form

$${V}_{{\rm{D}},{\rm{precise}}}(x)=\frac{{\widetilde{V}}_{1}}{2}\cos \left(2\frac{{F}_{n}}{{F}_{n+1}}kx\right)+\frac{{\widetilde{V}}_{2}}{2}\cos \left(2\frac{{F}_{n-1}}{{F}_{n+1}}kx\right),$$
(6)

since all other parameters except \({\widetilde{V}}_{1,2}\) in Eq. (4) are found to vanish. As an example, we consider a specific model \({H}_{{\rm{AA}}}^{\star }\) with parameters JAA = −0.0308ER, ϵAA = 0.0841ER, α ≈ Fn/Fn+1 (Fn = 34 and Fn+1 = 55), and ϕ = −πα. This target model is reached by choosing Vp = 8ER, V1 = 0.1ER, \({\widetilde{V}}_{1}=0.0341{E}_{{\rm{R}}}\), and \({\widetilde{V}}_{2}=-0.0592{E}_{{\rm{R}}}\). In Fig. 1a, we show the optical potentials corresponding to VD,rough and VD,precise for comparison. We find that the resultant onsite energies are approximately the same (Fig. 1b), yet with the potential VD,precise giving a more precise solution. More drastically, the tunnelings out of our potential with VD,precise(x) are precisely homogeneous, with a relative inhomogeneity below 10−4 (Fig. 1c). This cannot be achieved with the potential of VD,rough(x).

Fig. 1: Precise quantum simulation of AA model.
figure 1

a The optical potential VD,precise (red solid line) and VD,rough (blue dash-dotted line). Here, we have \({V}_{{\rm{D}},{\rm{rough}}}={V}_{1}\cos (2\alpha kx)/2\), and VD,precise given in Eq. (6). The potential VD,precise possesses a vanishing derivative at the individual sites (black dots), whereas VD,rough does not. b The onsite energies produced by VD,precise (red circles) and VD,rough (blue crosses). The dashed line is the desired sinusoidal form of the site-dependent onsite energies in \({H}_{{\rm{AA}}}^{\star }\). c The tunnelings produced by VD,precise (red circles) and VD,rough (blue crosses). The dashed line marks the desired site-independent tunnelings in \({H}_{{\rm{AA}}}^{\star }\). Here, we choose the hyper-parameter λ1 = 1, the system size L = 55, and periodic boundary condition. In our numerical calculation, we choose high-band cutoff Mc = 2, and confirm that the including higher bands do not affect the presented results.

We also emphasize here that our constructed potential VD,precise(x) possesses a vanishing derivative at the individual sites, as exhibited in Fig. 1a. This is crucial to experiments as a potential with finite derivative at the position of atoms would make the system more susceptible to shaking-induced heating processes49.

Anderson localization with programmable disorder potential

To further demonstrate the precise programmability enabled by our method, we also carry out an application to quantum simulation of Anderson localization models whose previous experimental realization by speckle pattern lacks programmability23,24,25,26,27,28,29,30,31,32,33,34. The Hamiltonians of 1D AL models are given as

$${H}_{{\rm{AL}}}^{\star }={\sum \limits_{i}}{h}_{i}{b}_{i}^{\dagger }{b}_{i}+{\sum \limits_{i}}\left({t}_{i}{b}_{i+1}^{\dagger }{b}_{i}+h.c.\right).$$
(7)

We consider three different cases: (a) random onsite model with \({h}_{i}\in [-{\widetilde{\epsilon }}_{{\rm{AL}}}/2,{\widetilde{\epsilon }}_{{\rm{AL}}}/2]\) and ti = JAL being homogeneous, (b) random hopping model with hi = ϵAL homogenous and \({t}_{i}\in [{J}_{{\rm{AL}}}-{\widetilde{J}}_{{\rm{AL}}}/2,{J}_{{\rm{AL}}}+{\widetilde{J}}_{{\rm{AL}}}/2]\), and (c) both onsite energies and tunnelings being random with \({h}_{i}\in [-{\widetilde{\epsilon }}_{{\rm{AL}}}/2,{\widetilde{\epsilon }}_{{\rm{AL}}}/2]\) and \({t}_{i}\in [{J}_{{\rm{AL}}}-{\widetilde{J}}_{{\rm{AL}}}/2,{J}_{{\rm{AL}}}+{\widetilde{J}}_{{\rm{AL}}}/2]\). The random onsite energies and tunnelings are drawn according to a uniform distribution. In Fig. 2, we show all the three different cases of AL model can be precisely achieved with our optimization method. The absolute errors in the tight-binding model compared to the target one is made smaller than 10−5 in units of recoil energy, which demonstrates the precise programmability of our scheme.

Fig. 2: Precise quantum simulation of three cases of AL models.
figure 2

a The random onsite model with hi [−0.05ER, 0.05ER] and ti = −0.0308ER being homogeneous. b The random hopping model with hi = 0 homogenous, ti [JAL − JAL/2, JAL + JAL/2], and JAL = −0.0308ER. c Both onsite energy and tunneling being random with hi [−0.05ER, 0.05ER], ti [JAL − JAL/2, JAL + JAL/2], and JAL = −0.0308ER. The first row shows the reverse-engineered optical potentials VD(x). The middle row shows the onsite energies (circles) and the tunnelings (crosses) of the targeting tight binding model. The “dashed” and “dash-dotted” lines mark the averaged value of on-site energies and tunnelings, respectively. And the last row shows the absolute errors in the tight-binding models extracted from the continuous Hamiltonian in Eq. (1) compared to the target one. Here, we choose the hyper-parameter λ1 = 100, the system size L = 10, the depth of the primary lattice Vp = 8ER, and periodic boundary condition. In our numerical calculation, we choose high-band cutoff Mc = 2, and confirm that the including higher bands do not affect the presented results.

Regarding the efficiency of the optimization method, we find the cost function is typically evaluated for 104 times before reaching convergence. For the actual CPU time cost, the results in Fig. 2a are obtained in 30 s with MATLAB implementation on an Intel processor of 8-core Xeon E5-2640 v4 CPU at 2.40 GHz, similarly for Fig. 2b,c. The method is thus confirmed to be highly efficient.

One immediate application of the programmable quantum simulation of Anderson localization is to study the anomalous localization in the random hopping model. Unlike the random onsite model, where all states are localized in one dimension, the random hopping model has delocalized states at band center58,59. But it is extremely difficult to perform quantum simulation of this pure random hopping model with the speckle-pattern approach lacking programmability, since the unavoidable inhomogeneity in the onsite energy will make all states localized. We randomly generate 2000 disorder samples for the hopping, and compute the corresponding potential VD(x) using our optimization method. The averaged inverse participation ratio (IPR) which diagnoses localization to delocalization transition60 is calculated, with the results shown in Fig. 3. We find quantitative agreement of results obtained for the continuous potential with the targeting tight-binding model. The discrepancy can be further improved by increasing the lattice depth or allocating more numerical resources.

Fig. 3: Averaged IPR for the random hopping model by sampling 2000 disorder configurations.
figure 3

Here, we set JAL = −0.0308ER and \({\widetilde{J}}_{{\rm{AL}}}=2| {J}_{{\rm{AL}}}| /3\), the system size L = 100. The blue solid, and red dash-dotted lines, correspond to the results obtained from diagonalizing the continuous Hamiltonian in Eq. (1) and the tight binding random-hopping model, respectively. Here, we choose the hyper-parameter λ1 = 100, λ2 = 0.5, the system size L = 100, the depth of the primary lattice Vp = 8ER, and periodic boundary condition. The whole system is split into a number of pieces with Lp = 10, and the adjacent pieces overlap with each other over 4 sites. In our numerical calculation, we choose high-band cutoff Mc = 2, and confirm that the including higher bands do not affect the presented results.

Implementation of boson sampling and determinantal point process

Boson sampling is a promising candidate to demonstrate quantum computational advantage for its established exponential complexity on a classical computer39,40,61. Its experimental implementation has been achieved in linear photonic62, trapped ion63, and quantum-dot devices64. Here we show that boson sampling could also be implemented with bosonic atoms confined in an optical lattice using our developed precise programmability. One advantage of atomic realization is that one can replace bosonic atoms by their fermionic isotopes, which then performs quantum sampling for determinantal point process41. This then provides one way to verify the quantum advantageous boson sampling because the simulation of determinantal point process is efficient on a classical computer41,42.

Here, we consider a standard boson sampling problem with m input modes and n identical bosons, where the n bosons are one-to-one injected into the first n modes as the input state, and then let evolve under an m × m Haar-random unitary U. In the dilute limit (nm), where each output mode contains at most one particle, the probability of a specific output Fock-state configuration S is p(S) = per(US)2, with per meaning the permanent, and US a submatrix of U selected according to the input and output configurations39.

To experimentally realize the Haar-random unitary U with an optical lattice, we adapt the decomposition in ref. 65, where the random unitary is constructed by multiplication of a series of building blocks of two-mode unitary operations. For the optical lattice implementation, we develop a different construction from photonic realization66 (see “Methods” section). We choose the two-mode building blocks as

$${T}^{(p,q)}=\exp \left({\rm{i}}{h}_{z}^{(p,q)}{\sigma }_{z}^{(p,q)}\right)\exp \left({\rm{i}}{h}_{x}^{(p,q)}{\sigma }_{x}^{(p,q)}\right).$$
(8)

Here we have the Pauli matrices \({\sigma }_{x}^{(p,q)}=\left|q\right\rangle \left\langle p\right|+\left|p\right\rangle \left\langle q\right|\) and \({\sigma }_{z}^{(p,q)}=\left|q\right\rangle \left\langle q\right|-\left|p\right\rangle \left\langle p\right|\), p, q {1, 2, …, m}, the quantum states \(\left|p\right\rangle\) and \(\left|q\right\rangle\) represent the Wannier functions in the optical lattice, and \({h}_{x,z}^{(p,q)}\) are parameters determined by U. With our optimization method, we can obtain the Hamiltonians \({H}_{z}^{(q+1,q)}={\epsilon }_{z}{\sigma }_{z}^{(q+1,q)}\) and \({H}_{x}^{(q+1,q)}={J}_{x}{\sigma }_{x}^{(q+1,q)}\), and hence the unitary \({\left({T}^{(q+1,q)}\right)}^{\dagger }\) can be achieved through the time evolution operator \(\exp (-{\rm{i}}{\tau }_{x}^{(q+1,q)}{H}_{x}^{(q+1,q)})\exp (-{\rm{i}}{\tau }_{z}^{(q+1,q)}{H}_{z}^{(q+1,q)})\), with the evolution time \({\tau }_{x}^{(q+1,q)}={h}_{x}^{(q+1,q)}\!/{J}_{x}\) and \({\tau }_{z}^{(q+1,q)}={h}_{z}^{(q+1,q)}/{\epsilon }_{z}\), which are positive with proper construction (see “Methods” section). For p − q > 1, a more involved construction is required, which is provided in “Methods” section. The building blocks of T(p, q) ultimately realize any random unitary, and the total evolution time is just the summation of all the evolution time of the building blocks.

For experimental implementation, we consider Li atoms67,68 confined in a lattice formed by a laser with wavelength 1064 nm, the recoil energy is ER = 2π × 25.12 kHz with 7Li. For a mode number m = 10 and number of atoms n = 3, we find that the average total evolution time is estimated to be 0.1 second taking Jx = −0.01ER and ϵz = 0.2ER. We emphasize here that the current lifetime of cold atoms is about one second, which permits quantum sampling with the mode number as large as m = 30. We also confirm that the overall harmonic potential confinement in standard cold atom experiments can be corrected by our precise quantum simulation scheme (see Supplementary Note 2 and Supplementary Fig. 2), which is required in performing programmable quantum sampling. Denoting the probabilities corresponding to the theory and the simulated DMD-based experimental realization as p1(S) and p2(S), respectively, the sampling precision is characterized by a measure of similarity \(G={\sum }_{S}\sqrt{{p}_{1}(S){p}_{2}(S)}\), and a measure of distance D = (1/2) \(\sum_s\)p1(S) − p2(S). The numerical results are shown in Fig. 4a. We find quantitative agreement between the simulated experimental realization and the theory prediction, which implies the precision achieved with our scheme is adequate to perform boson sampling experiments.

Fig. 4: Comparison between theory and simulated experimental realization for atom-based samplings.
figure 4

a boson sampling, b determinantal point process, and c determinantal point process with an error. Here, we choose mode number m = 10 and particle number n = 3. The solid bars indicate the results of the simulated experimental realization based on DMD enabled programmability. Empty bars indicate the results from the precise targeting theory model. In c, we deliberately introduce an error in the Hamiltonian \({H}_{x}^{(9,8)}\) (see main text), whose amplitude is set to be 70% of the correct value. The similarities (distances) between them are a G = 0.997 (D = 0.0525), b G = 0.998 (D = 0.0412), and c G = 0.884 (D = 0.327). The error in the quantum simulation is thus detectable from the results of determinantal point process, which can be simulated efficiently on a classical computer. Here, we only show no-collision output combinations in the bosonic case, and we set Jx = − 0.01ER, ϵz= 0.2ER.

We also study the case with fermionic atoms, which then realize the determinantal point process41. The results are shown in Fig. 4b, where we also find the quantitative agreement between the simulated experimental realization and the theory prediction. It is worth noting here that even when the classical simulation of boson sampling is unavailable for a large particle number, the experiment with fermions allows one way to detect errors when the device is erroneous, since the determinantal point process can be efficiently simulated on both classical computers41,42 and quantum devices. In Fig. 4c, we set an error in the Hamiltonian \({H}_{x}^{(9,8)}\), whose amplitude is deliberately set to be 70% of the correct value in order to check whether the error can be detected. We find that the error is indeed detectable by comparing the quantum sampling with the exact results.

Discussion

We have proposed a scheme for precisely simulating lattice models with optical lattices, whose potentials can be manipulated through the high-resolution DMD techniques. We have developed a Wegner-flow method to extract the precise tight-binding model of a continuous potential, and a scalable optimization method for the reverse engineering of the optical potential whose tight binding model precisely matches a targeting model. The performance is demonstrated with concrete examples of AA and Anderson models, and quantum sampling problems. Our approach implies optical lattices can be upgraded towards high-precision programmable quantum simulations by integrating with DMD techniques.

The precise programmable quantum simulation enabled by our scheme make the optical lattice rather flexible. For disorder physics, having programmable disorder allows for more systematic study of the localization transition, especially for cases where the rare disorder Griffith effects are important for example in understanding disordered Weyl semimetals69, and many-body localization mobility edge70,71.

Our proposing setup also paves a way to building a programmable quantum annealer with optical lattices. Considering spinor atoms in a deep lattice with strong interaction, programmable tunnelings imply programmable spin-exchange. For interacting systems, our approach is directly adaptable in the limit of interaction much weaker than the band gap, because the Wannier functions are easily accessible in the Wegner flow (see Supplementary Note 3 and Supplementary Fig. 3). We expect the approach can be further generalized for generic interacting systems, which is worth future investigation.

Methods

Exponential convergence of Wegner flow

As the efficiency of our method relies on the convergence behavior of Wegner flow, in this section we prove that the convergence is exponential, and that the convergence speed is inversely proportional to the band gap—it has a lower bound inversely proportional to the band gap to be more precise.

Note that we use Wegner flow to decouple the lowest band from the rest. The flow converges when the coupling between the lowest and excited bands vanish. To analyze such couplings, we rewrite the Hamiltonian matrix in terms of the lowest and excited band blocks and their couplings as

$$\begin{array}{l}{{\mathcal{H}}}_{mi;m^{\prime} i^{\prime} }={{\mathcal{D}}}_{ii^{\prime} }^{(0)}{\delta }_{m0}{\delta }_{m^{\prime} 0}+{{\mathcal{D}}}_{mi;m^{\prime} i^{\prime} }^{(1)}(1-{\delta }_{m0})(1-{\delta }_{m^{\prime} 0})\\ +\,{\delta }_{m0}{{\mathcal{C}}}_{i;m^{\prime} i^{\prime} }(1-{\delta }_{m^{\prime} 0})+(1-{\delta }_{m0}){{\mathcal{C}}}_{i^{\prime} ;mi}^{* }{\delta }_{m^{\prime} 0}.\end{array}$$
(9)

Following our constructed Wegner flow, we have the flow equation for the coupling matrix \({\mathcal{C}}\) as

$$\frac{{\mathrm{d}}{\mathcal{C}}}{{\mathrm{d}}l}={{\mathcal{D}}}^{(0)}{\mathcal{C}}-{\mathcal{C}}{{\mathcal{D}}}^{(1)}.$$
(10)

The overall strength of these couplings in \({\mathcal{C}}\) are quantified by the trace \({\rm{Tr}}[{{\mathcal{C}}}^{\dagger }{\mathcal{C}}]\), whose l-dependence obeys

$$\begin{array}{rcl}\frac{{\mathrm{d}}}{{\mathrm{d}}l}{\rm{Tr}}[{{\mathcal{C}}}^{\dagger }{\mathcal{C}}]&=&2{\rm{Tr}}[{\mathcal{C}}{{\mathcal{C}}}^{\dagger }{{\mathcal{D}}}^{(0)}-{{\mathcal{C}}}^{\dagger }{\mathcal{C}}{{\mathcal{D}}}^{(1)}]\\ &<&-2\left[{{\mathrm{d}}}_{\min }^{(1)}-{{\mathrm{d}}}_{\max }^{(0)}\right]{\rm{Tr}}[{{\mathcal{C}}}^{\dagger }{\mathcal{C}}],\end{array}$$
(11)

with \({{\mathrm{d}}}_{\min }^{(1)}\) the minimal eigenvalue of the Hermitian matrix \({{\mathcal{D}}}^{(1)}\) and \({{\mathrm{d}}}_{\max }^{(0)}\) the maximal eigenvalue of \({{\mathcal{D}}}^{(0)}\). We then obtain a bound on the trace as

$${\rm{Tr}}{[{{\mathcal{C}}}^{\dagger }{\mathcal{C}}]}_{{l}_{0}+\Delta l}\,< \, {\rm{Tr}}{[{{\mathcal{C}}}^{\dagger }{\mathcal{C}}]}_{{l}_{0}}{{\rm{e}}}^{-2[{{\mathrm{d}}}_{\min }^{(1)}-{{\mathrm{d}}}_{\max }^{(0)}]\Delta l}.$$
(12)

Having a finite gap between the lowest and the first excited bands, we have \({{\mathrm{d}}}_{\min }^{(1)}-{{\mathrm{d}}}_{\max }^{(0)}\, > \, 0\). The exponential convergence of the couplings between the lowest and excited bands is then assured. The convergence speed is larger than a value inversely proportional to the band gap. In practical calculations, the Frobenius norm of the Wegner flow generator η flows to 10−6 after 300 calculations of commutators of sparse matrices for the results presented in the paper.

The piece-by-piece optimization method

In this section, we provide the details of the piece-by-piece optimization method. Taking a system having L number of periods—the period is defined according to the primary lattice, the starting points of the periods are labeled as (X0, X1, X2, …, XL−1). We split the system into smaller pieces with a piece-size Lp. Two adjacent pieces have a finite overlap region with size Mp. The i-th piece contains the periods from \({X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})}\) to \({X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})+{L}_{{\rm{p}}}}\). Its overlap with the lefthand [righthand] side (i − 1)-th [(i + 1)-th] piece is from \({X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})}\) to \({X}_{(i-1)({L}_{{\rm{p}}}-{M}_{{\rm{p}}})+{L}_{{\rm{p}}}}\) [from \({X}_{(i+1)({L}_{{\rm{p}}}-{M}_{{\rm{p}}})}\) to \({X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})+{L}_{{\rm{p}}}}\)]. In optimizing the optical potential at i-th piece for the targeting tight-binding model in that local region, we introduce an additional cost function λ2f2, with λ2 a hyper-parameter, and

$$\begin{array}{l}{f}_{2}=\sqrt{\displaystyle{\int\nolimits_{{X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})}}^{{X}_{(i-1)({L}_{{\rm{p}}}-{M}_{{\rm{p}}})+{L}_{{\rm{p}}}}}}{d}{\mathrm{x}}{\left[{V}_{{\rm{D}},i}(x)-{V}_{{\rm{D}},i-1}(x)\right]}^{2}}\\ +\sqrt{\displaystyle{\int\nolimits_{{X}_{(i+1)({L}_{{\rm{p}}}-{M}_{{\rm{p}}})}}^{{X}_{i({L}_{{\rm{p}}}-{M}_{{\rm{p}}})+{L}_{{\rm{p}}}}}}{d}{\mathrm{x}}{\left[{V}_{{\rm{D}},i}(x)-{V}_{{\rm{D}},i+1}(x)\right]}^{2}},\end{array}$$
(13)

where VD,i(x) is the variational potential in optimizing the i-th piece. The f2 cost function is introduced to minimize the inconsistency of the potential in the overlap region with the neighboring (i − 1)-th and (i + 1)-th pieces. Since the constraint on the consistency is not implemented strict, there will still be leftover inconsistency between VD,i(x) and VD,i ± 1(x) in a single run. To solve this problem, we perform a back-and-forth sweeping process—we first carry out optimization in a forward direction from the leftmost piece to the rightmost, and then in a backward direction from the rightmost to leftmost. This sweeping process is iterated for potential convergence. In our numerics, we find convergence with three to four times of sweeping. We then glue all the pieces together and construct the global optical potential. It is confirmed that this procedure gives the correct potential whose tight binding model is the targeting model.

Decomposition of a Haar-random unitary with optical lattice accessible operations

Here we describe how to adapt the decomposition of the Haar-random unitary in ref. 65 to optical lattice implementation. An m × m Haar-random unitary U(m) is decomposed into

$$U(m)={U}_{{\rm{diag}}}\times {\left[\left(\mathop{\prod }\limits_{p = m}^{2}\mathop{\prod }\limits_{q = p-1}^{1}{T}^{(p,q)}\right)\right]}^{\dagger }.$$
(14)

The order of matrix multiplication using ∏ is defined to be from left to right, for example \(\mathop{\prod }\nolimits_{i = 3}^{1}{A}_{i}\) means A3A2A1 and \(\mathop{\prod }\nolimits_{i = 1}^{3}{A}_{i}\) means A1A2A3. In the above equation, we have

$${T}^{(p,q)}=\exp \left({\rm{i}}{h}_{z}^{(p,q)}{\sigma }_{z}^{(p,q)}\right)\exp \left({\rm{i}}{h}_{x}^{(p,q)}{\sigma }_{x}^{(p,q)}\right),$$
(15)

where the Pauli operations are defined according to the Wannier basis quantum states \(\left|q\right\rangle\) with q the lattice site index—\({\sigma }_{z}^{(p,q)}=\left|q\right\rangle \left\langle q\right|-\left|p\right\rangle \left\langle p\right|\), \({\sigma }_{x}^{(p,q)}=\left|q\right\rangle \left\langle p\right|+\left|p\right\rangle \left\langle q\right|\). To specify the matrix T(p, q), we introduce a matrix \({\widetilde{U}}^{(p,q)}\), whose elements \({\widetilde{U}}_{p,q}^{(p,q)}\) and \({\widetilde{U}}_{p,p}^{(p,q)}\) determine the parameters \({h}_{x,z}^{(p,q)}\) as

$$\begin{array}{rcl}{h}_{x}^{(p,q)}&=&-\arctan \left(\left|\frac{{\widetilde{U}}_{p,q}^{(p,q)}}{{\widetilde{U}}_{p,p}^{(p,q)}}\right|\right)\le 0,\\ &&{h}_{z}^{(p,q)}=\frac{1}{2}\left[\pi -\arg \left(\frac{{\rm{i}}{\widetilde{U}}_{p,q}^{(p,q)}}{{\widetilde{U}}_{p,p}^{(p,q)}}\right)\right]\ge 0.\end{array}$$
(16)

Here, T(p,q) and \({\widetilde{U}}^{(p,q)}\) are constructed in a sequential manner as (p, q) goes through the sequence {(m, m − 1), (m, m − 2), …, (m, 1), (m − 1, m − 2), (m − 1, m − 3), …, (2, 1)}. From \({\widetilde{U}}^{(m,m-1)}=U(m)\), we obtain T(m,m−1) through Eq. (16) and Eq. (15), and then we have \({\widetilde{U}}^{(m,m-2)}={\widetilde{U}}^{(m,m-1)}{T}^{(m,m-1)}\). In general once \({\widetilde{U}}^{({p}_{1},{q}_{1})}\) and \({T}^{({p}_{1},{q}_{1})}\) are obtained, we have \({\widetilde{U}}^{({p}_{2},{q}_{2})}={\widetilde{U}}^{({p}_{1},{q}_{1})}{T}^{({p}_{1},{q}_{1})}\) for (p2, q2) next to (p1, q1) in that sequence. Following this sequence, all matrices are constructed. The additional matrix Udiag in Eq. (14) is diagonal with the elements \({({U}_{{\rm{diag}}})}_{n,n}={[{\widetilde{U}}^{(2,1)}{T}^{(2,1)}]}_{n,n}\), n = 1, 2, …, m.

From Eq. (14), we see that to realize the Haar-random unitary U(m), the building block is the unitary \({({T}^{(p,q)})}^{\dagger }\), which can be achieved through time evolution of the corresponding Hamiltonian, as specified latter. To engineer the non-local gate operation \({({T}^{(p,q)})}^{\dagger }\) we perform the following transformation,

$${{\boldsymbol{\sigma }}}_{x,z}^{(p,q)}={\left({U}^{(p,q)}\right)}^{\dagger }{\sigma }_{x,z}^{(q+1,q)}{U}^{(p,q)},$$

where,

$${U}^{(p,q)}=\left\{\begin{array}{ll}\,{\text{Identity}}\, {\text{matrix}}\,,&p=q+1,\\ \mathop{\prod }\nolimits_{n = q+1}^{p-1}{U}^{(n+1,n)}, & p \, > \, q+1, \end{array}\right.$$

with

$$\begin{array}{rcl}{U}^{(n+1,n)}&=&\left|n\right\rangle \left\langle n+1\right|-\left|n+1\right\rangle \left\langle n\right|\\ \,&&+\mathop {\sum}\limits_{k\in \{1,\,\ldots ,\,m\}\backslash \{n,n+1\}}\left|k\right\rangle \left\langle k\right|.\end{array}$$

Hence, we have

$$\displaystyle{T}^{(p,q)}={\left({U}^{(p,q)}\right)}^{\dagger }{\widetilde{T}}^{(p,q)}{U}^{(p,q)},$$

with

$$\displaystyle{\widetilde{T}}^{(p,q)}={{\rm{e}}}^{{\rm{i}}{\tau }_{z}^{(p,q)}{H}_{z}^{(q+1,q)}}{{\rm{e}}}^{{\rm{i}}{\tau }_{x}^{(p,q)}{H}_{x}^{(q+1,q)}},$$

which corresponds to time evolution with tight binding Hamiltonians

$$\displaystyle{H}_{z}^{(q+1,q)}={\epsilon }_{z}{\sigma }_{z}^{(q+1,q)},\,{H}_{x}^{(q+1,q)}={J}_{x}{\sigma }_{x}^{(q+1,q)}.$$

Here ϵz > 0 and Jx < 0 are constants, and the evolution time is \({\tau }_{z}^{(p,q)}={h}_{z}^{(p,q)}/{\epsilon }_{z}\), \({\tau }_{x}^{(p,q)}={h}_{x}^{(p,q)}/{J}_{x}\). That is to say, \({\left({\widetilde{T}}^{(p,q)}\right)}^{\dagger }\) can be achieved through the time evolution operator

$$\displaystyle{{\rm{e}}}^{-{\rm{i}}{\tau }_{x}^{(p,q)}{H}_{x}^{(q+1,q)}}{{\rm{e}}}^{-{\rm{i}}{\tau }_{z}^{(p,q)}{H}_{z}^{(q+1,q)}}.$$

It is straightforward to show that U(n + 1,n) and its hermitian conjugate can also be obtained through time evolution operators, i.e.,

$$\begin{array}{rcl}\displaystyle{U}^{(n+1,n)}&=&{{\rm{e}}}^{-{\rm{i}}{\tau }_{z}^{u}{H}_{z}^{(n+1,n)}}{{\rm{e}}}^{-{\rm{i}}{\tau }_{x}^{u}{H}_{x}^{(n+1,n)}},\\ \displaystyle{\left({U}^{(n+1,n)}\right)}^{\dagger }&=&{{\rm{e}}}^{-{\rm{i}}{\tau }_{x}^{u}{H}_{x}^{(n+1,n)}}{{\rm{e}}}^{-{\rm{i}}{\tau }_{z}^{u}{H}_{z}^{(n+1,n)}},\end{array}$$

with the evolution time \({\tau }_{z}^{u}=\pi /(2{\epsilon }^{z})\) and \({\tau }_{x}^{u}=-\pi /(2{J}^{x})\). Therefore, we finally have

$$\begin{array}{r}U(m)={U}_{{\rm{diag}}}\times {\left({\widetilde{T}}^{(2,1)}\right)}^{\dagger }\mathop{\prod }\limits_{p = 3}^{m}\left[\left(\mathop{\prod }\limits_{q = p-1}^{2}{\left({U}^{(q+1,q)}\right)}^{\dagger }\right)\right.\\ \left.\times \left(\mathop{\prod }\limits_{q = 1}^{p-2}{\left({\widetilde{T}}^{(p,q)}\right)}^{\dagger }{U}^{(q+2,q+1)}\right){\left({\widetilde{T}}^{(p,p-1)}\right)}^{\dagger }\right].\end{array}$$
(17)

We see that in order to build a general m × m Haar-random unitary U(m), both the number of Hx and Hz gates we need are (m − 1)(3m − 4)/2. And also a gate Udiag is needed, which can be achieved through evolving the Hamiltonian \({H}_{{\rm{d}}}=\frac{{\rm{i}}}{8\pi }\mathrm{log}\,({U}_{{\rm{diag}}})\) with the time τd = 8π/ER. In Fig. 5, we show all the Hamiltonians of typical quantum gates can be precisely achieved with our optimization method, and the absolute errors in the tight-binding model compared to the target one is made smaller than 10−5 in units of recoil energy.

Fig. 5: Precise quantum simulation of the Hamiltonians corresponding to different quantum gates.
figure 5

a \({H}_{x}^{(5,4)}={J}_{x}{\sigma }_{x}^{(5,4)}\) with Jx = −0.01ER. b \({H}_{z}^{(5,4)}={\epsilon }_{z}{\sigma }_{z}^{(5,4)}\) with ϵz = 0.2ER. c \({H}_{{\rm{d}}}=\frac{{\rm{i}}}{8\pi }\mathrm{log}\,({U}_{{\rm{diag}}})\), with Udiag defined in Eq. (14), corresponding to the decomposition of the Haar-random unitary in Fig. 4 (see the notation in “Methods” section). The first row shows the reverse-engineered optical potentials VD(x). The middle row shows the onsite energies (circles) and the tunnelings (crosses) of the targeting tight binding model. The ‘dashed’ and ‘dash-dotted’ lines mark the zero value of on-site energies and tunnelings, respectively. And the last row shows the absolute errors in the tight-binding models extracted from the continuous Hamiltonian in Eq. (1) compared to the target one. Here, we choose the hyper-parameter λ1 = 20 and the depth of the primary lattice Vp = 20ER. In our numerical calculation, we choose high-band cutoff Mc = 2, and confirm that the including higher bands do not affect the presented results.