Bayesian phase difference estimation: a general quantum algorithm for the direct calculation of energy gaps

Quantum computers can perform full configuration interaction (full-CI) calculations by utilising the quantum phase estimation (QPE) algorithms including Bayesian phase estimation (BPE) and iterative quantum phase estimation (IQPE). In these quantum algorithms, the time evolution of wave functions for atoms and molecules is simulated conditionally with an ancillary qubit as the control, which make implementation to real quantum devices difficult. Also, most of the problems in chemistry discuss energy differences between two electronic states rather than total energies themselves, and thus direct calculations of energy gaps are promising for future applications of quantum computers to real chemistry problems. In the race of finding efficient quantum algorithms to solve quantum chemistry problems, we test a Bayesian phase difference estimation (BPDE) algorithm, which is a general algorithm to calculate the difference of two eigenphases of unitary operators in the several cases of the direct calculations of energy gaps between two electronic states on quantum computers, including vertical ionisation energies, singlet–triplet energy gaps, and vertical excitation energies. In the BPDE algorithm, state preparation is carried out conditionally on the ancillary qubit, and the time evolution of the wave functions in superposition of two electronic states are executed unconditionally. Based on our test, we conclude that BPDE is capable of computing the energy gap with an accuracy similar to BPE without controlled-time evolution simulations and with the smaller number of iterations in Bayesian optimisations.


Introduction
Quantum computers are believed to have the potential to revolutionise our lives in many ways. Anticipated applications of quantum computers range from secure communications, 1 financial problems, 2 machine learning, 3 combinatorial optimisations, 4 and material and drug designs. 5 Among the diverse topics in quantum computing and quantum information processing, sophisticated quantum chemical calculations of atoms and molecules are one of the most intensively studied realms as the near future applications of quantum computers. In 1929, Dirac pointed out that ''The underlying physical laws necessary for the mathematical theory of a large part of physics and the whole of chemistry are thus completely known, and the difficulty is only that the exact application of these laws leads to equations much too complicated to be soluble''. 6 The computational cost for full configuration interaction (full-CI) calculations that can give variationally best possible wave functions within the space spanned by the basis set being used increases exponentially against the system size. However, as Feynman pointed out, quantum mechanical systems can be efficiently simulated by using a computer built of quantum mechanical elements which obey quantum mechanical laws, namely a quantum computer. 7 We note that if quantum computers are capable of performing sophisticated quantum chemical calculations of large and complex systems such as the Mn 4 CaO 5 cluster of photosystem II 8 and FeMo cofactor of nitrogenase, 9 it will help us deeply understand chemical processes in nature a Department of Chemistry and Molecular Materials Science, Graduate School of and design novel compounds and materials with valuable functionalities. In fact, quantum computers allow us to calculate full-CI energy in polynomial time, by utilising a quantum phase estimation (QPE) algorithm. 10 The first theoretical study of the QPE-based full-CI was reported in 2005, 11 and proof-of-principle experiments of the full-CI/STO-3G calculations of H 2 molecules were reported by using photonic and NMR quantum computers in 2010. 12,13 Since then, many theoretical studies including quantum gate complexity improvement, [14][15][16][17][18][19] spatial and spin symmetry adaptation, [20][21][22][23][24][25] qubits and quantum gate resource estimations 17,26,27 as well as experimental demonstrations of quantum chemical calculations 28,29 have been reported. QPE needs N qubits to readout the eigenphase in N-digits in binary, while iterative QPE (IQPE) 30,31 and Bayesian phase estimation (BPE), 32,33 which are the family of QPE algorithms, use only one ancillary qubit. In 2014, a quantum-classical hybrid algorithm known as a variational quantum eigensolver (VQE) was proposed, 34,35 which is capable of computing the energy expectation values of approximated wave functions using currently available noisy intermediate-scale quantum (NISQ) devices. 36 Recent reviews in this field can be found elsewhere. [37][38][39][40][41] Although it has been thought that advent of fault-tolerant quantum computers (FTQC) which have an ability to perform massive computations with quantum computational advantages is in the distant future, remarkable progress in quantum hardware is constantly being made. For example, two-dimensional quantum walks on a 62-qubit system have been reported recently, 42 and Google Inc. announced that they aim for commercial-grade quantum computers by 2029. 43 In this context, development of efficient quantum algorithms targeted at utilising FTQC is an important issue.
Importantly, the computational cost of quantum chemical calculations on quantum computers increases when we evaluate the energy in finer digits. This is because QPE calculates the energy range where the full-CI solution locates, rather than the full-CI energy itself. Length of the time evolution should be doubled to half the energy range. Thus, the computational cost is inversely proportional to the energy precision. In VQE, the energy expectation value is computed in a statistical manner by iteratively executing the state preparation and measurements, and therefore the statistical error is unavoidable. To half the statistical error of the energy expectation value, one should quadruple the number of measurements. 35,40 From these reasons, it is quite difficult to precisely calculate the total energy of large molecules and molecules containing heavy atoms. Noticeably, we need several theoretical breakthroughs to open the door to solve real-world chemistry problems, as well as developments of quantum computing hardware. From the viewpoint of computational chemistry, almost all the problems in chemistry focus on the energy differences between two electronic states or structures of the molecular systems under study, rather than the total energies themselves relevant to the systems. Furthermore, the magnitude of the energy gap to be discussed is not greatly dependent on the molecular size. We have to discuss the similar magnitude of energy differences regardless of the size of molecules. The direct calculation of energy gaps between two electronic states on quantum computers is one of the plausible and promising solutions. [44][45][46][47] Note that several approaches to calculate excitation energies have been proposed in VQE, such as subspace expansion, 48 subspace search VQE, 49 using orthogonality of wave functions, 50 and so on. In these methods energy gaps are calculated by the subtraction of total energies of individual electronic states.
Recently, we proposed a quantum algorithm ''Bayesian exchange coupling parameter calculator with broken-symmetry wave functions (BxB)'', 45 that is capable of directly computing the energy difference between two electronic states belonging to different spin quantum numbers. From the numerical quantum circuit simulations, we demonstrated that the BxB quantum algorithm is able to predict the exchange coupling parameter J, which is half of the singlet-triplet energy gap, of small molecules within 1 kcal mol À1 of precision, with much lower computational costs than the conventional QPE-based approach. 45 We also carried out numerical simulations for the direct calculations of vertical ionisation energies using the BxB algorithm, achieving 0.1 eV of energy precision. 46 The BxB algorithm is powerful and applicable to larger systems, and exponential speedup against classical counterpart is guaranteed. Unfortunately, as discussed in detail in the next section, the BxB algorithm has drawbacks. It needs more ancillary qubits to execute quantum computation, compared with IQPE and BPE, and it cannot generally be applicable to calculations for any energy gaps. For example, singlet-singlet excitation energies, which are important in chemistry, cannot be calculated using the BxB algorithm.
In this work, we propose a new quantum algorithm, ''Bayesian phase difference estimation (BPDE)'', whose capability is general in calculating the difference of two eigenphases of unitary operators, and apply the BPDE algorithm to direct calculations of various energy gaps. We emphasise that the number of qubits needed for implementing the BPDE equals that of IQPE and BPE, and unlike IQPE and BPE, the BPDE algorithm does not require any controlled-time evolution operation that is one of the most difficult parts of quantum algorithms to be implemented to real devices. Numerical quantum circuit simulations for the direct calculations of vertical ionisation energies of He, Li, Be, B, C, N, HF, BF, CF, CO, O 2 , NO, CN, F 2 , H 2 O, NH 3 , CH 4 , HCN, and HNC, singlet-triplet energy gaps of H 2 , C, O, NH, OH + , NF, NCN, and CNN, and vertical excitation energies of dihalocarbenes (CX 2 , X = F, Cl, and Br), dihalosilylenes (SiX 2 , X = F and Cl), and formaldehyde (HCHO) are given.

A Bayesian phase estimation (BPE) algorithm for full-CI calculations on quantum computers
Here we briefly review the theory of quantum chemical calculations on quantum computers and full-CI calculations using the BPE algorithm. 32 The QPE algorithms including IQPE and BPE are based on the quantum simulation of the time evolution of wave functions conditionally on the ancillary qubit and following measurement of the ancillary qubit to project the wave function to the eigenfunction of Hamiltonian. The quantum circuit for BPE is illustrated in Fig. 1. Here, horizontal lines specify a qubit or N SO of qubits, and squares, circles, and vertical lines represent relevant quantum gates. N SO is the number of spin orbitals in the active space. Definitions of the quantum gates and quantum circuits are given in the ESI. † T z is the phase shift gate defined in eqn (1).
In the BPE, an approximate wave function |Ci having sufficiently large overlap with the full-CI wave function of the target electronic state is needed as the input. The Hartree-Fock wave function |C HF i is often used as |Ci for the ground state calculations of closed shell singlet molecules. By using a Jordan-Wigner transformation discussed below, |C HF i can be generated by N elec of Pauli-X (NOT) gates from the qubits initialised to the |00Á Á  Fig. 1 (eqn (2)). The next step is for the controlled-time evolution of |Ci. The time evolution operator exp(ÀiHt) is applied to |Ci if and only if the ancillary qubit is in the |1i state (eqn (3)). After that the T z gate is applied to the ancillary qubit to cause the phase shift to the |1i state (eqn (4)). The following Hadamard gate on the ancillary qubit generates the quantum state in eqn (5).
The probability to obtain the |0i state in the measurement of the ancillary qubit, P(0), is calculated as in eqn (6).
From eqn (6), the measurement of the ancillary qubit always gives the |0i state if E = e. In BPE, the rotational angle y = et of the T z (y) gate is optimised using Bayesian inference to maximise P(0). The BPE returns a posterior distribution over the phase, rather than a point estimate. BPE is robust against experimental imperfections and noises, and it outperforms IQPE. 32 To adopt BPE for full-CI calculations of atoms and molecules, the wave functions should be mapped onto qubits. Several wave function mapping techniques were proposed, 52-54 and here we use the mapping based on the Jordan-Wigner transformation (JWT). 11,52 In the JWT, each qubit stores the occupancy of a particular spin orbital: the qubit is in the |1i state if the spin orbital is occupied by an electron, otherwise |0i. A Hamiltonian for the systems under study is written in the second quantised formula as in eqn (7), where a † p and a p are creation and annihilation operators, respectively, acting on the p-th spin orbital. h pq and h pqrs are one-and two-electron integrals and they are computed on classical computers prior to quantum simulations. In the JWT, a † p and a p are transformed to the products of Pauli operators (Pauli strings) using eqn (8) and (9), respectively. As a result, the molecular Hamiltonian in eqn (7) is transformed to the qubit Hamiltonian consisting of a linear combination of Pauli strings, as in eqn (10) and (11).
The quantum circuit that corresponds to the exponential of a Pauli string appearing in the time evolution operator can be constructed by following the literature. 57 The quantum circuit for exp(ÀiwX 1 Z 2 Y 3 t) is illustrated in Fig. 2 as an example, where X p , Y p , and Z p denote Pauli operators acting on the p-th qubit. Note that in BPE the time evolution operation is executed conditional on the ancillary qubit. The controlledexp(ÀiwX 1 Z 2 Y 3 t) is realised by substituting the R z (2wt) gate in Fig. 1 A quantum circuit for the BPE algorithm. N SO is the number of spin orbitals in the active space. Fig. 2 to the controlled-R z (2wt) gate, where the control qubit is the ancillary qubit.

A BxB quantum algorithm for the direct calculation of spin state energy gaps
Because quantum computers can utilise quantum superposition states as their computational resources, it is possible to calculate the energy difference between two electronic states directly on quantum computers, by using the wave function approximated by a superposition of the two electronic states. The BxB quantum algorithm uses a broken-symmetry wave function |C BS i that is a mixture of wave functions belonging to different spin quantum numbers and is used for the calculations of an exchange coupling parameter J in terms of DFT 58-60 as the input. For the two-spin systems |C BS i is described as in eqn (13).
In the BxB algorithm, the calculation of the spin state energy gap is achieved by finding the j parameter in the shifted Hamiltonian defined in eqn (14), for which |C BS i given in eqn (15) becomes an eigenfunction of the shifted Hamiltonian H 0 .
Here, S 2 is the spin squared operator giving an eigenvalue S(S + 1), where S denotes a spin quantum number. The eigenvalues of |C S=S a i and |C S=S b i under the shifted Hamiltonian H 0 are given in eqn (16) and (17), respectively.
By writing the j parameter giving E S=S a 0 = E S=S b 0 as j opt , the spin state energy gap DE is calculated as follows.
The quantum circuit for the BxB algorithm is given in Fig. 3. In the BxB algorithm, the deviation of |C BS i from the eigenfunction of H 0 is evaluated by the quantum simulation of the time evolution of |C BS i under the shifted Hamiltonian H 0 and following a SWAP test. 61 The SWAP test consists of the controlled-SWAP operation that interchanges two quantum states |fi and |ji if the ancillary qubit is in the |1i state, flanked by two Hadamard gates on the ancillary qubit, and ancillary qubit measurement. The probability of obtaining the |0i state in the measurement is given in eqn (19), and therefore the square overlap |hf|ji| 2 can be efficiently evaluated by the SWAP test.
In the BxB quantum algorithm, |fi is exp(ÀiHt)|C BS i and |ji is exp{Ài(ÀjS 2 )t}|C BS i. The probability P(0) becomes a cosine function whose period is given by DE 0 t, where DE 0 is the energy gap between the two spin states under the shifted Hamiltonian H 0 . By adopting the Bayesian inference to optimise the j parameter giving a maximum P(0), we can calculate the spin state energy gap directly, without inspecting the total energies of individual spin states.
As demonstrated in the preceding papers, the BxB algorithm can calculate the exchange coupling parameter J defined in Heisenberg spin Hamiltonian H = À2J ij S i ÁS j within 1 kcal mol À1 of errors, 45 and vertical ionisation energies within 0.1 eV of precision. 46 Also, the BxB algorithm can be extended to other problems, by replacing the penalty term introduced to the shifted Hamiltonian from jS 2 to other operators such as a number operator of electrons jN elec ¼ j P p a y p a p . However, any operators cannot be used as the penalty term in the BxB algorithm. It should commute with the original Hamiltonian H, otherwise the introduction of the penalty term changes the shape of eigenfunctions. Also, the eigenvalues of the penalty operator must be known. The two electronic states to calculate the energy gap should have different eigenvalues of the penalty operator. Operators satisfying these conditions are very rare, and thus the application of the BxB algorithm is limited. For example, the BxB algorithm can calculate the singlet-triplet energy gaps but it cannot compute singlet-singlet excitation energies. Furthermore, because the BxB algorithm uses the SWAP test, the number of qubits required for implementation is approximately doubled from the conventional QPE-based full-CI. It is highly desirable to overcome these shortcomings and to develop a new quantum algorithm enabling us to generally calculate any energy gaps. In the next section, we will introduce a new quantum algorithm, Bayesian phase difference estimation (BPDE), as a general algorithm capable of computing the differences of two eigenphases of unitary operators.

A Bayesian phase difference estimation (BPDE) algorithm
Let us rethink the reason why QPE algorithms including IQPE and BPE are difficult to implement on real quantum devices. Obviously, the biggest reason is that the quantum circuit for the time evolution is so deep that quantum error corrections are  necessary to obtain meaningful computational results. Another reason is that QPE needs the controlled-time evolution operation. As discussed above, the controlled-time evolution requires many controlled-R z gates with the same control qubit but different target qubits. Some quantum devices like those based on superconducting circuits can execute two qubit gates between physically connected qubits only. In order to implement the controlled-R z gate to two qubits which are not physically connected, one has to construct a SWAP network to exchange the quantum states of the neighbouring qubits, so that the two qubits that the controlled-R z gate acts on are placed next to each other. The SWAP network requires O(N SO ) of additional gates, where we used a big-Oh notation to represent quantum gate complexity. Even if all qubits are fully connected, one has to minimise the crosstalk errors of the controlled-R z gates. It is useful if QPE can be implemented without controlled-time evolution operations. Again, let us rethink the mechanism of QPE algorithms. It calculates the phase shift caused by the time evolution of wave functions and readout the eigenphase by means of inverse quantum Fourier transformation (QPE) or Bayesian inference (BPE). The controlled-time evolution is introduced to calculate the phase difference of wave functions before and after the time evolution. However, it is possible to calculate the energy difference of two electronic states by simulating the time evolution of the wave function in the quantum superposition of the two electronic states without controlled operations, if we can prepare the quantum superposition of the two electronic states conditional to the quantum state of the ancillary qubit. This is the key idea in the quantum algorithms for direct calculations of energy gaps. [44][45][46][47] The quantum circuit for the BPDE algorithm is given in Fig. 4. The quantum circuit consists of one ancillary qubit and N SO of qubits storing the wave function. Here, |C 0 i can be any (approximated) eigenfunction of Hamiltonian H. Unless otherwise specified, we assume that |C 0 i is the approximated wave function of the electronic ground state. The quantum circuit starts with an Hadamard gate on the ancillary qubit to generate the superposition of the |0i and |1i states. The following controlled-Excit gate (denoted by c-Excit in eqn (20)) applies an excitation operator to the wave function |C 0 i if and only if the ancillary qubit is in the |1i state. This operation generates the superposition of the ground and excited states as given in the right hand side of eqn (20), and subsequent time evolution operation and inverse-controlled-Excit operation transform the quantum state as in eqn (21) and (22), respectively. The next step is application of the phase shift gate T z to the ancillary qubit, giving the quantum state in eqn (23). By applying another Hadamard gate on the ancillary qubit, the quantum state before the measurement in Fig. 4 is given as eqn (24).
The probability to obtain the |0i state in the measurement of the ancillary qubit can be calculated as in eqn (25).
From eqn (25), it is clear that the measurement of the ancillary qubit always gives the |0i state if E 1 À E 0 = De. Thus, the energy gap between the two electronic states can be calculated by optimising the phase shift angle Det by means of Bayesian inference. The BPDE algorithm does not need a penalty operator and is capable of computing the difference of two eigenphases of unitary operators, if one can conditionally generate the superposition of two eigenfunctions. It should be emphasised that application of the BPDE algorithm is not limited to quantum chemical calculations, but to a wide variety of eigenvalue problems. Another merit of the BPDE algorithm against BxB is that the P(0) given in eqn (25) varies between 0 and 1, although P(0) in the BxB algorithm is given as P(0) = [3 + cos{(E 1 À E 0 À De)t}]/4, 45 and thus it takes a value between 0.5 and 1. Thus, the range of the possible value for P(0) is wider in BPDE than in BxB, and the variation of P(0) by changing De becomes more apparent.
Note that the BPDE algorithm needs only one ancillary qubit, which is the same in IQPE and BPE. Importantly, both IQPE and BPE require controlled-time evolution operations but BPDE is free from them. In BPDE, the controlled operations appear in the state preparation (controlled-Excit) and inverse state preparation (controlled-Excit † ). The controlled-Excit generates the excited state wave function conditionally, and therefore the quantum circuit for the controlled-Excit has the depth similar to that used for the state preparation in conventional QPE-based approaches. Importantly, we do not have to prepare the exact eigenfunction of a target electronic state in QPE, and preparation of the approximate wave function having sufficiently large overlap with the target electronic state is enough. The situation is the same in the BPDE algorithm, and we can calculate the energy gap correctly if the controlled-Excit can conditionally generate the wave function having large overlap with the target excited state. Thus, the quantum circuit for the controlled-Excit is usually very shallow and implementation of BPDE is much easier than IQPE and BPE those need controlledtime evolution operations. It should be also noted that the phase difference estimation algorithm described here can be easily extended to the IQPE scheme.

Results and discussion
To demonstrate the usefulness of the BPDE algorithm, we developed numerical quantum circuit simulation programs using Python with OpenFermion 62 and Cirq 63 libraries, and carried out numerical simulations for the direct calculations of vertical ionisation energies, singlet-triplet energy gaps, and vertical excitation energies. We also calculated the energy gaps using a naïve approach to compute total energies of individual electronic states by two separate BPE simulations and subtract them. The simulations were performed five times for each system. Details of computational procedures and conditions for the numerical simulations of BPDE and BPE are given in the ESI. †

Vertical ionisation energies
Accurate calculations of ionisation energies are important to understand electron transfer and oxidation processes in chemical reactions and nature of chemical bonding. As we demonstrated in the preceding paper, direct calculations of vertical ionisation energies are possible by using the BxB algorithm. 45 Here, we adopt the BPDE algorithm to calculate the vertical ionisation energies of CH 4 , HCN, and HNC molecules as well as 16 chemical species (He, Li, Be, B, C, N, HF, BF, CF, CO, O 2 , NO, CN, F 2 , H 2 O, and NH 3 ) studied previously by using the BxB algorithm. 46 In order to calculate the vertical ionisation energies with the BPDE algorithm, we set the starting wave function |C 0 i to be RHF/6-311G(d,p) or the ROHF/6-311G(d,p) wave function for closed shell and open shell species, respectively, of the neutral state. The largest systems under study are HCN and HNC with (10e, 9o) active spaces, those corresponding to 19 qubit quantum circuit simulations (18 qubits for the wave function storage and one ancillary qubit). Under the JWT, the controlled-Excit gate is realised by a CNOT gate with the ancillary qubit as the control and the qubit storing the occupation number of spin orbitals of which electron ionisation occurs as the target. We used the ionisation energy at the DSCF level, IE(DSCF) = E HF (cation) À E HF (neutral), as the initial estimate of the vertical ionisation energies.
The difference of the vertical ionisation energies from the quantum circuit simulations and that from the CAS-CI calculations are plotted in Fig. 5, and the values of the BPDE, BPE, and CAS-CI ionisation energies in conjunction with experimental ones are summarised in Table S2 in the ESI. † For all chemical species under study, both the BPDE and BPE algorithms reproduced the CAS-CI ionisation energy within 0.1 eV of errors. The ionisation energies computed by using BPDE and BPE are very close to each other, revealing that the accuracy of the vertical ionisation energy is almost the same between the direct calculation and naïve approach. In the HF molecule, both BPE and BPDE exhibit large deviations from the CAS-CI values. The deviation can be rationally explained by the errors arising from Trotter decomposition. In fact, the deviation from the CAS-CI value systematically improves by increasing the number of Trotter slices, and it becomes 0.004 eV if we use five times larger the number of Trotter slices in the calculation of HF molecule (see the ESI † for details).
The BPDE simulation converges after eight optimisation cycles in all atoms and molecules under study, and thus the number of iterations does not depend on the system size. This is because BPDE optimises the energy difference directly. By contrast, in BPE the number of Bayesian optimisation cycles increases as the system size. For example, BPE optimisation of the neutral and cationic states of F 2 takes 11 iterations. System size independence in the Bayesian optimisation in the BPDE algorithm cannot be overemphasised. This feature becomes more important in the calculations of larger molecules and molecules containing heavier atoms, as discussed in the excitation energy calculations of CBr 2 (see Section 3.3).

Singlet-triplet energy gaps
Next we applied the BPDE algorithm to the direct calculations of singlet-triplet energy gap DE S-T . The singlet-triplet energy gap is the most important physical quantity in biradicals. The DE S-T of biradicals are usually in the order of a few kcal mol À1 or less, and accurate calculations of DE S-T using quantum computers are very cost demanding. In this study, we focused on the covalent bond dissociation of the H 2 molecule at the full-CI/STO-3G level, and atoms and small molecules including C, O, NH, OH + , NF, NCN, and CNN at the CAS-CI/6-311G(d,p) level. CAS-CI active spaces are summarised in the ESI. † For the calculation of the singlet-triplet energy gap, we used the |C CSF i of the M S = 0 of the spin-triplet state given in eqn (26) as |C 0 i, and the spin-singlet state given in eqn (27) is assigned to the excited state |C 1 i. In this formulation, DE S-T becomes negative if the spin-singlet state has lower energy than the spintriplet state. (27) By setting |C 0 i and |C 1 i as described above, the controlled-Excit operation becomes a controlled-Z gate with the ancillary qubit as the control and one of the qubits storing the occupation number of singly occupied molecular orbitals (SOMOs) as the target. See the ESI † for details of the state preparations.
The results of the numerical quantum circuit simulations and the CAS-CI calculations are summarised in Fig. 6, and the DE S-T values calculated at the BPDE, BPE, and CAS-CI methods are given in Tables S4 and S6 in the ESI. † From Fig. 6, both the BPE and BPDE succeed in predicting DE S-T within 2 kcal mol À1 of errors in all systems under study. This corresponds to 1 kcal mol À1 of energy precision in the exchange coupling parameter J used in our preceding paper. 45 Departures of the DE S-T (BPE) and DE S-T (BPDE) from the CAS-CI value are large for the H 2 molecule with the interatomic distance R(HÁ Á ÁH) r 1.5 Å, but again this large deviation is mainly caused by the Trotter decomposition (see the ESI †). Another reason is that the spin-singlet wave function is not well approximated by |C 1 i. For shorter HÁ Á ÁH distances contribution of the closed shell singlet electronic configuration to the full-CI wave function becomes significant, and therefore contributions from other electronic states to |C 1 i are not negligible. As a result, the likelihood function becomes a linear combination of many cosine functions and P(0) becomes flattened. Adopting multiconfigurational wave functions constructed by using diradical character y for |C 1 i using the quantum circuit proposed by us 51 is a promising approach to improve the DE S-T values, which is out of focus of this paper.

Vertical excitation energies
Finally, we applied the BPDE algorithm to calculations of vertical excitation energies. These calculations were impossible by using the BxB algorithm, although it is essential to theoretically assign electronic transitions of the UV-vis spectra. In this study, we calculated the S 0 -S 1 and S 0 -T 1 excitation energies of dihalocarbenes (CX 2 , X = F, Cl, and Br) and dihalosilylenes (SiX 2 , X = F and Cl), and vertical excitation energies of the valence excited states of formaldehyde (HCHO). Active spaces for the CAS-CI calculations of dihalocarbenes and dihalosilylenes are provided as Fig. S9-S13 in the ESI, † and that of formaldehyde is given in Fig. 7.
To calculate the excitation energies from the closed shell singlet ground state, we have to apply the symmetry-adapted excitation operators as the controlled-Excit gate. Spin-singlet and triplet states can be obtained by using the excitation operators T ja given in eqn (28) and (29), respectively, where j and a represent occupied and unoccupied molecular orbitals in the ground state, respectively.
T ja ðsingletÞ ¼ 1 ffiffi ffi 2 p a y aa a ja þ a y ab a jb (28) T ja ðtripletÞ ¼ 1 ffiffi ffi 2 p a y aa a ja À a y ab a jb (29) The quantum circuits for the controlled-Excit gates are illustrated in Fig. S16 in the ESI. † The calculated vertical excitation energies are summarised in Table 1. In Table 1, the BPE and BPDE excitation energies are given as the average of five numerical simulations. The 1 1 B 1 and 1 3 B 1 excited states of dihalocarbenes and dihalosilylenes are attributed to spin-allowed and spin-forbidden (spin-flip) HOMO -LUMO one electron transitions, respectively. In formaldehyde, the 1 1 A 2 , 1 1 B 1 , and 2 1 A 1 excited states are described mainly by the (2b 2 -2b 1 ), (5a 1 -2b 1 ), and (1b 1 -2b 1 ) electron excitations, respectively. The calculated excitation energies are overestimated from the experimental values due to lack of dynamical electron correlation effects. The excitation energies obtained from the BPE and BPDE quantum circuit simulations agree to the CAS-CI value within ca. 0.1 eV of  errors, exemplifying the accuracy of the BPE and BPDE algorithms.
As discussed above, the number of the iterations in the Bayesian optimisation does not depend on the system size in BPDE, although it strongly depends on the magnitude of total energy in BPE. This behaviour can be clearly seen in the calculation of CBr 2 . The CAS-CI(10e,6o)/6-31G* energy of the electronic ground state of CBr 2 is À5181.9601544990 Hartree. BPE gives the ground state energy to be À5181.9600265599 Hartree (the average value of five runs). Error of the total energy is about 0.0035 eV and thus very small, but BPE simulations need 16 iterations to achieve the convergence. Note that in this study we used the 0.05 of Hartree-Fock energy as the initial variance of the Gaussian function (a prior distribution). Using tighter initial variance can accelerate the Bayesian optimisation. By contrast, the BPDE simulation converges after 8 iterations. Direct calculations of the energy gap are beneficial to reduce the computational costs related to Bayesian optimisations.

Conclusions
In this work, we examined the Bayesian phase difference estimation (BPDE) algorithm, which is a general quantum algorithm capable of computing the difference of two eigenphases of unitary operators, in several cases of direct calculations of energy gaps including vertical ionisation energies, singlettriplet energy gaps, and vertical excitation energies. The BPDE algorithm is free from the controlled-time evolution operation that is necessary for putative QPE algorithms, and the number of qubits required for the implementation equals those in the IQPE and BPE algorithms. The BPDE algorithm is easier to be implemented on quantum devices than the BPE, and the accuracy of the energy gaps is comparable to the naïve approach based on two separate BPE quantum simulations. One of the most important features of the BPDE algorithm against the conventional BPE is that the number of iterations in the Bayesian optimisation to achieve the convergence does not depend on the system size, although it increases in BPE when the magnitude of the total energy becomes large. Direct calculations of energy gaps are also promising in terms of reducing the computational cost of Bayesian optimisation.
We emphasise that the usage of the BPDE algorithm is not limited to quantum chemical calculations. It is applicable to other unitary operators and therefore various applications can be anticipated. Even if we restrict ourselves to the topics of quantum chemical calculations, we can expect a variety of possible applications such as core ionisations, core excitations, Rydberg excitations, and charge-transfer excitations. Connection of the BPDE algorithm to the sophisticated methods for the wave function preparation such as multiconfigurational wave function preparations using diradical characters 51 and adiabatic state preparation 68,69 is another important extension of the algorithm.
These applications potentially open the door to apply quantum computers to real-world chemistry problems.

Author contributions
K. Sugisaki, K. Sato, and T. Takui planned and conducted the project. K. Sugisaki proposed the theory. K. Sugisaki and C. Sakai performed quantum chemical calculations and numerical simulations. All the other authors discussed the results. K. Sugisaki and T. Takui wrote the paper.

Conflicts of interest
There are no conflicts to declare.