Introduction

A quantum computer is a physical machine based on quantum physics. Since the Shor’s algorithm was known to be a method for factoring a very large number with exponential speed-up on a quantum computer1, various quantum algorithms have been theoretically introduced under the assumption of noiseless quantum computers. However, the performance of quantum algorithms in practice suffers from physical errors in noisy quantum devices under technical limitations (e.g., decoherence). Thus, it is of great importance to find more efficient and error-robust methods for existing quantum algorithms within physical error thresholds for near-term future applications.

The Harrow-Hassidim-Lloyd (HHL) algorithm2 is a well-known quantum algorithm for finding the solution \(\overrightarrow{x}\) of a given system of linear equations represented by an input matrix \(\hat{A}\) and a vector \(\overrightarrow{b}\). Intuitively, the HHL algorithm performs the inverse of the matrix \(\hat{A}\) on the vector \(\overrightarrow{b}\) in a heralded way and is more efficiently operated with sparse matrix \(\hat{A}\). Because the HHL algorithm demonstrates how to use quantum computers for mathematical problems, it provides important impact on other quantum applications such as the quantum machine learning algorithm3 and the high-order quantum algorithm4 for solving differential equations.

The purpose of this paper is to provide a modified version of the original HHL algorithm2 to be efficiently operated on both classical and quantum computers in sequential steps. The main idea of our hybrid algorithm is to remove an unnecessary quantum part of the original HHL algorithm with prior classical information, so we call it the hybrid HHL algorithm. This makes the shortened circuit depth of the original algorithm without losing quantum advantages dependent to the original algorithm. We also demonstrate the hybrid HHL algorithm compared with the original one with different eigenvalues of \(\hat{A}\) in the IBM Quantum eXperience (IBMQX) setups, and show that our hybrid algorithm has more enhanced performance than the other.

Preliminaries

Definitions

A general form of linear systems of equations is given in

$$\hat{A}\overrightarrow{x}=\overrightarrow{b},$$
(1)

where \(\hat{A}\) is an N × N matrix and \(\overrightarrow{b}\) is a vector. Throughout this paper, it is assumed that the matrix \(\hat{A}\) is Hermitian and the vector \(\overrightarrow{b}\) is unit. Then the matrix \(\hat{A}\) has a spectral decomposition5

$$\hat{A}=\sum _{j=1}^{l}\,{\lambda }_{j}|{u}_{j}\rangle \langle {u}_{j}|,$$
(2)

where λj is an eigenvalue of \(\hat{A}\) corresponding to the eigenstate |uj〉. From this decomposition, a unitary operator \({U}_{\hat{A}}\) is defined as follows:

$${U}_{\hat{A}}={e}^{2\pi i\hat{A}}=\sum _{j\mathrm{=1}}^{l}\,{e}^{2\pi i{\lambda }_{j}}|{u}_{j}\rangle \langle {u}_{j}|.$$
(3)

It is easy to see that for any non-zero eigenvalue λj of \(\hat{A}\) there exists λj (0, 1) such that \({e}^{2\pi i{\lambda ^{\prime} }_{j}}={e}^{2\pi i{\lambda }_{j}}\). Thus, for convenience, we may assume that the eigenvalues of \(\hat{A}\) are in (0, 1).

We then introduce three definitions to explain the main idea of this work.

Definition 1.

Let λ be a positive real number with the range of (0, 1), then its binary representation is given by

$$\lambda =0.{b}_{1}{b}_{2}{b}_{3}\cdots \,,$$

where bk {0, 1} is a k-th bit of the binary representation. For \(n\in {\mathbb{N}}\), the n-binary estimation of λ, say λ(n), is given by

$$\lambda (n)\,:\,={b}_{1}{b}_{2}{b}_{3}\,\cdots \,{b}_{n}\approx {2}^{n}\lambda .$$

Definition 2.

Let \({\{{\lambda }_{j}\}}_{j\mathrm{=1}}^{l}\) be the set of all non-zero eigenvalues of a Hermitian matrix \(\hat{A}\). For \(k\in {\mathbb{N}}\), define a constant \({\bar{m}}_{k}\) as

$${\bar{m}}_{k}\,:\,=\frac{1}{l}(\sum _{j\mathrm{=1}}^{l}{b}_{k}^{j}),$$

where \({b}_{k}^{j}\) is the k-th bit of the binary representation of λj. We call \({\bar{m}}_{k}\) the k-th eigenmean of \(\hat{A}\). Moreover, if \({\bar{m}}_{k}\mathrm{=0}\) or 1, \({\bar{m}}_{k}\) is called fixed.

In Definition 2, we remark that if the k-th eigenmean of \(\hat{A}\) is fixed then every k-th bits of the binary representations of \({\{{\lambda }_{j}\}}_{j\mathrm{=1}}^{l}\) is equal, that is, if \({\bar{m}}_{k}\) is fixed then \({b}_{k}^{{j}_{1}}={b}_{k}^{{j}_{2}}\) for any 1 ≤ j1, j2 ≤ l.

Definition 3

Let λ be an eigenvalue of a Hermitian matrix \(\hat{A}\) and let \(n\in {\mathbb{N}}\).

  1. (i)

    λ is called perfectly n-estimated, if λ satisfies 2nλ = λ(n), where λ(n) is the n-binary estimation of λ in Definition 1.

  2. (ii)

    The matrix \(\hat{A}\) is called perfectly n-estimated, if all the eigenvalues of \(\hat{A}\) are perfectly n-estimated.

HHL algorithm

For a given \(\hat{A}\overrightarrow{x}=\overrightarrow{b}\), the HHL algorithm2 was devised to figure out the approximation of the expectation value \({\overrightarrow{x}}^{\dagger }M\overrightarrow{x}\) for some operator M. In the algorithm, \(\overrightarrow{b}\) is represented as a quantum state \({|b\rangle }_{V}={\sum }_{j=1}^{l}\,{\alpha }_{j}{|{u}_{j}\rangle }_{V}\), where |ujV is an eigenstate of \(\hat{A}\) and \({\alpha }_{j}\in {\mathbb{C}}\) such that \({\sum }_{j=1}^{l}\,|{\alpha }_{j}{|}^{2}=1\), and the solution is given as a quantum state

$${|x\rangle }_{V}=\frac{{\hat{A}}^{-1}{|b\rangle }_{V}}{\Vert {\hat{A}}^{-1}{|b\rangle }_{V}\Vert },$$

where \({\hat{A}}^{-1}\) is the inverse matrix of \(\hat{A}\). As shown in Fig. 1, the HHL algorithm with n-qubit register consists of three main parts: the quantum phase estimation (QPE) algorithm6,7,8,9 without the final measurement part (we call it as QPE part), the ancilla quantum encoding (AQE) part, in which the ancillary qubit A conditionally operates on the state of the register qubits, and the inverse QPE part.

Figure 1
figure 1

The circuit diagram for the HHL algorithm2: the circuit consists of the QPE part, the AQE part and the inverse QPE part. The unitary gate \({U}_{\hat{A}}={e}^{2\pi i\hat{A}}\) is used for controlled-unitary gates between the register R and the input qubit V while the controlled AQE indicates a set of controlled gates between the register R and the ancillary qubit A.

We first describe the QPE part of the HHL algorithm and assume that the initial state is prepared in \({|0\rangle }_{A}\otimes {|0\rangle }_{R}^{\otimes n}\otimes {|b\rangle }_{V}\) with a n-qubit register. After finishing the QPE part, the state at step (a) in Fig. 1 is written by the superposition of the state (see details in Eq. (16)) with index j and the ancillary qubit |0〉A such that

$${|0\rangle }_{A}\otimes \sum _{j=1}^{l}\,\sum _{x=0}^{{2}^{n}-1}\,{\alpha }_{j}{\beta }_{x|j}{|x\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V},$$
(4)

where \({\beta }_{x|j}=\frac{1}{{2}^{n}}{\sum }_{y=0}^{{2}^{n}-1}\,{e}^{2\pi iy({\lambda }_{j}-x{\mathrm{/2}}^{n})}\). Then the estimated value x in Eq. (4) can be relabeled with λx = x/2n such as

$${|0\rangle }_{A}\otimes \sum _{j\mathrm{=1}}^{l}\sum _{x\mathrm{=0}}^{{2}^{n}-1}{\alpha }_{j}{\beta }_{x|j}{|{\lambda }_{x}\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$

In the AQE part, a quantum encoding operation about the ancillary qubit A is performed, and the the controlled AQE in Fig. 1 is given by

$${|0\rangle }_{A}\otimes {|{\lambda }_{x}\rangle }_{R}\mapsto (\sqrt{1-\frac{{c}^{2}}{{{\lambda }_{x}}^{2}}}{|0\rangle }_{A}+\frac{c}{{\lambda }_{x}}{|1\rangle }_{A})\otimes {|{\lambda }_{x}\rangle }_{R},$$
(5)

where \(c=\mathrm{1/}\Vert {\hat{A}}^{-1}|b\rangle \Vert \). In practice, the value c in Eq. (5) has to be chosen with O(1/κ) as in the original result2, where κ is called the condition number of \(\hat{A}\). Then the state at step (b) in Fig. 1 is equal to

$$\sum _{j\mathrm{=1}}^{l}\,\sum _{x\mathrm{=0}}^{{2}^{n}-1}(\sqrt{1-\frac{{c}^{2}}{{{\lambda }_{x}}^{2}}}{|0\rangle }_{A}+\frac{c}{{\lambda }_{x}}{|1\rangle }_{A})\otimes {\alpha }_{j}{\beta }_{x|j}{|{\lambda }_{x}\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$
(6)

If all the eigenvalues λj are perfectly n-estimated then \({\beta }_{x|j}={\delta }_{x{\mathrm{,2}}^{n}{\lambda }_{j}}\), and the state in Eq. (6) becomes

$$\sum _{j=1}^{l}\,(\sqrt{1-\frac{{c}^{2}}{{{\lambda }_{j}}^{2}}}{|0\rangle }_{A}+\frac{c}{{\lambda }_{j}}{|1\rangle }_{A})\otimes {\alpha }_{j}{|{\lambda }_{j}\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$

Then after performing the inverse QPE part, the state at step (c) in Fig. 1 is represented as

$$\sum _{j=1}^{l}\,(\sqrt{1-\frac{{c}^{2}}{{{\lambda }_{j}}^{2}}}{|0\rangle }_{A}+\frac{c}{{\lambda }_{j}}{|1\rangle }_{A})\otimes {|0\rangle }_{R}^{\otimes n}\otimes {\alpha }_{j}{|{u}_{j}\rangle }_{V},$$
(7)

in which all the register qubits are reseted in \({|0\rangle }_{R}^{\otimes n}\). The normalized solution of the linear equation appears when the measurement of the ancillary qubit A is performed in Z-axis. In other words, if the outcome state of A is |1〉A, the state describing the qubit system V successfully represents the solution of the linear equation as follows:

$$\frac{1}{\Vert {\hat{A}}^{-1}|b\rangle \Vert }\sum _{j=1}^{l}\,\frac{{\alpha }_{j}}{{\lambda }_{j}}{|{u}_{j}\rangle }_{V},$$
(8)

where \({\Vert {\hat{A}}^{-1}|b\rangle \Vert }^{2}={\sum }_{j=1}^{l}\,|{\alpha }_{j}{|}^{2}/{\lambda }_{j}^{2}\). Note that the pure state in Eq. (8) is obtained only when \(\hat{A}\) is perfectly n-estimated as we mentioned earlier. If there exists an eigenvalue of \(\hat{A}\) which is not perfectly n-estimated, then the total state of Eq. (7) becomes a pure entangled state so that the state in Eq. (8) turns into a mixed state.

We note that the running time of the HHL algorithm is a polynomial of logN and κ, and the HHL algorithm runs exponentially faster than any classical algorithm2. In this paper, we consider only one-qubit state preparation with respect to the initial state of the algorithm. However, it would be more difficult to prepare an arbitrary n-qubit state in general. In fact, loading the initial data has been considered as one of the main caveats of quantum algorithms10,11, and hence several methods12,13 to handle this caveat have been proposed.

Results

Hybrid HHL algorithm

Motivation: specific linear equations

For 0 < λ < 1, let us now consider the following linear system of equations

$${\hat{A}}_{\lambda }\overrightarrow{x}=\overrightarrow{b},$$
(9)

where

$${\hat{A}}_{\lambda }=(\begin{array}{cc}\frac{1}{2} & \lambda -\frac{1}{2}\\ \lambda -\frac{1}{2} & \frac{1}{2}\end{array}),\,\overrightarrow{b}=(\begin{array}{c}1\\ 0\end{array})=|0\rangle .$$
(10)

Then one can readily check that \({\hat{A}}_{\lambda }\) is positive, and can obtain the solution of the equation \({\hat{A}}_{\lambda }\overrightarrow{x}=\overrightarrow{b}\) which is given by

$$\overrightarrow{x}=\frac{1}{\sqrt{2}\lambda }|\,+\,\rangle +\frac{1}{\sqrt{2}\mathrm{(1}-\lambda )}|\,-\,\rangle ,$$
(11)

where \(|\,\pm \,\rangle =(|0\rangle \pm |1\rangle )/\sqrt{2}\).

From the original HHL algorithm with \({\hat{A}}_{\lambda }\) and \(\overrightarrow{b}\) in Eq. (10), we can obtain the fidelity5 between the results of the algorithm with a k-qubit register (k = 1, 2, 3) and analytical results given by

$${F}_{k}(\lambda )\equiv F({\rho }_{k,\lambda },{\psi }_{\lambda }),$$

where F(,) indicates the quantum fidelity, the final state ρk,λ is the approximated solution state describing the qubit system V obtained at the end of algorithm performance, and ψλ is the normalized solution of \(\overrightarrow{x}\) in Eq. (11). In Fig. 2(a), the fidelities Fk(λ) are presented with k = 1, 2, 3 (details in Section Methods). It indicates that more register qubits make a better and larger window for higher fidelity between outcome states and the analytical solutions. From the curves, we gain two features on the performance of the original HHL algorithm which have not appeared in any previous literature. One is that we can find an exact solution of the linear system of equations only when the matrix \({\hat{A}}_{\lambda }\) is perfectly n-estimated. In particular, note that the fidelities reach to 1 with both 2- and 3-qubit registers for λ = 1/4, 1/2, 3/4. In other words, additional register qubits can increase the fidelity if \({\hat{A}}_{\lambda }\) is not perfectly n-estimated. For the other one, let us observe that F3 < F2 < F1 for λ = 0.475 in Fig. 2(a). These inequalities can be interpreted as the statement that the use of a smaller size of register provides more precise solutions at neighborhoods of the perfectly n-estimated eigenvalues, although it is not rigorously proved in this paper. We conjecture that the statement is true for the general case including n-qubit register with n > 3 and larger systems of linear equations.

Figure 2
figure 2

(a) Fidelities between solutions of the linear systems of equations in Eq. (10) and output states obtained from the HHL algorithm with k-qubit register for k = 1, 2, 3. (b) The probability distribution for measurement outcomes: The QPEA with 2-qubit register is performed on \({\hat{A}}_{\lambda }\) and \(\overrightarrow{b}\) in Eq. (10). Since the QPEA makes use of 2 qubits as register, its measurement outcomes are two-bit strings b1b2 with b1, b2 {0, 1}, and Pr(b1b2) denotes the probability that the outcome is b1b2. Details of the probabilities are presented in Eqs (12) and (13).

From the fact that F2(0.5) = F3(0.5) = 1, one may think that, for some restriction of λ, circuit implementations for the HHL algorithm with 3-qubit register can be simplified by using 2 qubits as register of the algorithm. For example, the algorithm may be implemented by using a smaller number of gates, and could have more efficient performance with the reduced amount of errors. The idea motivates us to devise a quantum linear equation algorithm whose circuit implementation is more simplified than that of the original HHL algorithm.

Description of hybrid HHL algorithm

We here present the hybrid HHL algorithm, which mainly consists of the blocks of the quantum phase estimation algorithm (QPEA), classical computing, and a reduced HHL algorithm to test the original and hybrid HHL algorithms with a two-qubit register as described in Fig. 3. In particular, the third part of the hybrid algorithm is called the reduced HHL part because the part is not an independent quantum algorithm.

  • QPEA: Repeatedly perform the QPEA to obtain k-bit classical information of eigenvalues with \({\hat{A}}_{\lambda }\) and |b〉.

  • Classical Computing: Analyze measurement outcomes from the first step by means of classical computers. Based on the analyzed data, such as an estimation of the probability distribution in Fig. 2(b), one determines which simpler circuit implementation of the original AQE part, called the reduced AQE part, is applicable. The circuit of the reduced AQE part is implemented by the classical analysis.

  • Reduced HHL: Perform the HHL algorithm with the reduced AQE part instead of the original AQE part.

Figure 3
figure 3

The circuit diagrams of the original and hybrid HHL algorithms for \({\hat{A}}_{\lambda }\) and \(\overrightarrow{b}\) in Eq. (10). (a) The controlled \({U}_{\lambda }^{m}\) gate, where \({U}_{{\hat{A}}_{\lambda }}^{m}={({e}^{2\pi i{\hat{A}}_{\lambda }})}^{m}\) for \(m\in {\mathbb{Z}}\). (b) The inverse quantum Fourier transform for two qubits. (c) Additional measurement devices to check outputs of the algorithms. In the hybrid HHL algorithm, AQE′ indicates a reduced AQE part (aqua color). The detailed circuit implementations of (a,b), and AQE′ are given in Fig. 4.

Importantly, if the reduced AQE part is not applicable from the second step of the hybrid algorithm due to the lack of capability to distinguish different eigenvalues, the user of the algorithm should restart the first step with more register qubits to perform the reduced HHL part.

How does hybrid HHL algorithm work?

Let us consider that our hybrid HHL algorithm is applied to the linear equation \({\hat{A}}_{\lambda }\overrightarrow{x}=\overrightarrow{b}\) in Eq. (9) when λ = 1/4, 2/4, 3/4, and that we use only 2 qubits as register of the hybrid HHL algorithm. Assume that λ = 1/4, 2/4, 3/4 is unknown.

In the first step of the hybrid HHL algorithm, the QPEA with 2-qubit register is repeatedly performed on the matrix \({\hat{A}}_{\lambda }\) and the state \(\overrightarrow{b}\). Then as depicted in Fig. 2(b), we may obtain a probability distribution for the measurement outcomes of the QPEA given by

$$Pr(j\mathrm{0)}=\frac{1}{16}{e}^{-6\pi i\lambda }{\mathrm{(1}+{e}^{4\pi i\lambda })}^{2}{({(-\mathrm{1)}}^{j}+{e}^{2\pi i\lambda })}^{2},$$
(12)
$${\rm{\Pr }}\mathrm{(01)}={\rm{\Pr }}\mathrm{(11)}=-\,\frac{1}{8}{e}^{-4\pi i\lambda }{(-1+{e}^{4\pi i\lambda })}^{2},$$
(13)

where j = 0, 1.

In the second step of the algorithm, we can know what the eigenvalues of \({\hat{A}}_{\lambda }\) are from the probability distribution in Fig. 2(b). In addition, we can also know that \({\hat{A}}_{\lambda }\) is perfectly 2-estimated, \({\bar{m}}_{2}\) \(\mathrm{(=1)}\) is a fixed eigenmean for the matrices \({\hat{A}}_{\mathrm{1/4}}\) and \({\hat{A}}_{\mathrm{3/4}}\), and the matrix \({\hat{A}}_{\mathrm{2/4}}\) has fixed eigenmeans \({\bar{m}}_{1}\) (=1) and \({\bar{m}}_{2}\) (=0). From the classical information, the AQE part of the HHL algorithm can be simply implemented. In detail, the AQE parts for the matrices \({\hat{A}}_{\mathrm{1/4}}\) and \({\hat{A}}_{\mathrm{3/4}}\) are given by a controlled-unitary operation

$$\begin{array}{lll}{|0\rangle }_{A}{|0\rangle }_{{r}_{1}} & \mapsto & (\sqrt{1-{c}^{2}}{|0\rangle }_{A}+c{|1\rangle }_{A}){|0\rangle }_{{r}_{1}}\\ {|0\rangle }_{A}{|1\rangle }_{{r}_{1}} & \mapsto & (\sqrt{1-{(\frac{c}{3})}^{2}}{|0\rangle }_{A}+\frac{c}{3}{|1\rangle }_{A}){|1\rangle }_{{r}_{1}},\end{array}$$
(14)

and the AQE for the matrix \({\hat{A}}_{\mathrm{2/4}}\) is given by a single-qubit unitary operation

$${|0\rangle }_{A}\mapsto \sqrt{1-{(\frac{c}{2})}^{2}}{|0\rangle }_{A}+\frac{c}{2}{|1\rangle }_{A}.$$
(15)

One of the practical drawbacks in the HHL algorithm is that we anyway need to know some partial information of the matrix \(\hat{A}\) to setup the value c in Eq. (5) in the physical circuit of the AQE. Our main purpose is to extract this information with QPEA, and then the approximated value c is now known for AQE and reduced AQE. The rotation gate RB(θ) is defined as follows:

$${R}_{B}(\theta )=\,\cos (\frac{\theta }{2}I)-i\,\sin (\frac{\theta }{2}B),$$

where I is the identity operator and B can be one of Pauli operators X, Y, and Z. To implement the original and reduced AQE parts, we employ a specific conditional phase gate RY(θn), where \({\theta }_{n}\,:\,=2\,\arccos (\sqrt{1-{{c}_{\lambda }}^{2}/{n}^{2}})\) with \({c}_{\lambda }={\Vert {{\hat{A}}_{\lambda }}^{-1}|b\rangle \Vert }^{-1}\) for n≥1.

In the third step, by performing the reduced HHL part on the linear equation \({\hat{A}}_{\lambda }\overrightarrow{x}=\overrightarrow{b}\), whose reduced AQE part is reconstructed based on Eqs (14) and (15), we can obtain the normalized solution of the linear equation in the qubit system V.

In these examples, our hybrid algorithm solves the linear equation under the condition that the matrix \({\hat{A}}_{\lambda }\) is perfectly 2-estimated and it has fixed eigenmeans. In fact, this condition is indispensable for reducing the AQE part of the original HHL algorithm. More generally, the following theorem shows that if a matrix \({\hat{A}}_{\lambda }\) in Eq. (1) is perfectly n-estimated, and it has fixed eigenmeans, then we can implement the AQE part by using smaller size of register when the eigenvalues are known as follows.

Theorem 4.

Let \(n,\,k\in {\mathbb{N}}\) with k ≤ n. If a matrix \(\hat{A}\) is perfectly n-estimated, and the matrix \(\hat{A}\) has k fixed eigenmeans, then the AQE part can be implemented by (nk)-qubit register.

Remark that Theorem 4 is useful for our hybrid algorithm as follows. First of all, the eigenvalues of \(\hat{A}\) can be perfectly n-estimated when a sufficiently large number of qubits are used as register of the HHL algorithm. Secondly, since the HHL algorithm deals with positive semidefinite matrices whose eigenvalues are between 0 and 1 in our case, the matrix \(\hat{A}\) can have at least a fixed eigenmean. Thus, by Theorem 4, the AQE part can be implemented with the reduced number of qubit register, depending on the number of fixed eigenmeans. In our hybrid algorithm, if \(\hat{A}\) is perfectly n-estimated, and it has k fixed eigenmeans, then the number k can be estimated by repeatedly performing the QPEA, and hence we can implement the reduced AQE part.

Circuit implementation and experiment

IBM Quantum Experience

The IBMQX is the name of online facilities for general public who can test their own experimental protocols in five (or sixteen) superconducting qubits. Although its physical setup consists of a complex architecture built by superconducting qubits and readout resonators in a single chip, the user interface is designed with simple diagrams, which represent single- and two-qubit gates, and is easy to understand and to write the programs without much prior knowledge of quantum information theory and experimental setups.

We in particular use four qubits in the five-qubit systems (called IBMQX2 and IBMQX4) and they have a different topology of connectivity for two-qubit gates. For example, they provide a controlled-NOT (CNOT) gate at the end-user level but the physical two-qubit gate is actually performed by a cross-resonance gate14,15, which implies that additional single-qubit gates are required to match the desired CNOT gate. Fortunately, single-qubit gates in their transmon qubits are very accurate and the fidelity of gate operations mostly depends on that of the cross-resonance gate and the readout errors after the total quantum operation. For example, we utilize single-qubit RZ gates for the algorithms as much as we can because this can be realized without applying any microwave but with only shifting the phase of the next applied microwave16.

Because the IBMQX setup shows the daily small fluctuation of parameters, they provide average device calibrations, which might be useful for understanding the imperfection of the experimental data. For example, the transmons energy frequency (between 0 and 1) is roughly about 5 GHz, which is fit to the microwave frequency with 6 cm wavelength. Importantly, one of the important measures for coherence time is T1 ≈ 50 μ s, and it approximately limits the total operation time t in performance of quantum processing such as \(|1\rangle \langle 1|\to {e}^{-t/{T}_{1}}|1\rangle \langle 1|\) for a single-qubit decay rate. For example, the CNOT gate (consisting of a cross-resonance gate and a few single-qubit gates) takes around 200 ns, and it roughly indicates that 50 times of CNOT gates might not exceed the fidelity 0.82 because e−1/5 ≈ 0.82 at the current IBMQX setup. Therefore, the hybrid quantum algorithm might be beneficial for experimental demonstrations under practical circumstances because it has simpler quantum gates with the support of classical information processing.

Setups for circuit implementations on IBMQX

We now describe experimental setups of the hybird HHL algorithm compared with the original HHL algorithm with two qubit register to solve the linear equation given by the parameterized matrix \({\hat{A}}_{\lambda }\) in Eq. (10). In addition, we only deal with the matrices \({\hat{A}}_{\mathrm{1/4}}\) and \({\hat{A}}_{\mathrm{2/4}}\), since \({\hat{A}}_{\mathrm{1/4}}\) and \({\hat{A}}_{\mathrm{3/4}}\) have the same eigenvalues. In the IBMQX setups, it is also possible to test the algorithms by using a three-qubit register. However, the complex circuit implementations dramatically decrease the fidelities of the solutions beyond the analysis scope. More importantly, because the original and hybrid HHL algorithms exactly find the same solution of \({\hat{A}}_{\lambda }\overrightarrow{x}=\overrightarrow{b}\) for the ideal (no-error) cases that λ = 1/4, 2/4, it is crucial to compare the performance of the original and hybrid HHL algorithms under the IBMQX setups under error-propagating circumstances. Note that a similar experimental investigation has been recently shown with fixed matrix \(\hat{A}\), which cannot cover the class of our parameterized matrix in Eq. (10)17.

As explained in Section Preliminaries: HHL algorithm and Fig. 3, the original HHL algorithm consists of the QPE, the AQE, and the inverse QPE with a qubit measurement on the ancillary qubit, as shown in the top of Fig. 3. The QPE part is mainly decomposed by the parts (a) and (b) in Fig. 3 or Fig. 4. The first part (a) consists of two controlled unitary gates whose circuit implementations18 are found in Fig. 4(a). The second part (b) is the inverse of the two-qubit QFT, which is a combination of a SWAP gate, two CNOT gates, and some single-qubit gates shown in Fig. 4(b). After the inverse QPE part, if the ancillary qubit is measured in |1〉A, the register qubits always become \({|00\rangle }_{{r}_{1}{r}_{2}}\) in principle. However, the propagated errors during the whole operation time might cause the other outcomes (\(\ne {|00\rangle }_{{r}_{1}{r}_{2}}\)) in real experiments. This can be verified by setting the measurements of register qubits in Fig. 3(c) to post-select successful outcomes.

Figure 4
figure 4

The circuit implementations on IBMQX setups: (a) the controlled \({U}_{\lambda }^{m}\) gate where \({U}_{{\hat{A}}_{\lambda }}^{m}={({e}^{2\pi i{\hat{A}}_{\lambda }})}^{m}\) for \(m\in {\mathbb{Z}}\), (b) the inverse quantum Fourier transform for two qubits, (c) the original AQE part, and (d) the reduced AQE part for the reduced HHL part when λ = 1/4, 2/4. Here, θ3: = θ3−(θ1 + θ2).

For the hybrid HHL algorithm in Fig. 3, classical computing is sandwiched between two quantum computing parts. The first part of the quantum algorithm is called QPEA similar to the QPE part in the original HHL. After the measurement of the two-qubit register (step 1), the analysis from classical computing decides the operation angles (θj) in the reduced AQE circuit (AQE′) with respect to the measured first two digits in r1 and r2 (step 2). Finally, the chosen angles from the classical information are applied in the lightened circuit of AQE′ (step 3). The original and reduced AQE circuits are shown in Fig. 4(c,d), respectively.

Therefore, we will show the experimental results of QPEA and the reduced HHL parts with λ = 1/4, 1/2 compared with the original HHL algorithm in the next subsection. If we consider a general case that λ ≠ k/4 with k = 1, 2, 3, we cannot exactly estimate the eigenvalues of \({\hat{A}}_{\lambda }\) from the probability distribution given in Fig. 2(b) and request more register qubits for the algorithm, however, it also indicates that a small variance of eigenvalues (|λ − k/4| = δ with small δ) would give us a high fidelity of the solution state (even better than using a three-qubit register in principle) as shown in Fig. 2(a).

Experimental results for QPEA and Reduced HHL parts

We here examine the original and hybrid HHL algorithms at the setups of IBMQX4. The experiments of QPEA are performed by using six CNOTs, and the original HHL algorithm requires 28 CNOT gates while the reduced HHL algorithm now has 14 CNOT gates. Thus, this indicates the reduction of 14 CNOT gates from the original HHL algorithm. Note that ten sets of experimental data are used for each λ with 1024 single-shot readouts per set for individual algorithms.

The QPE in the original HHL and QPEA in the hybrid HHL commonly have (a) a set of controlled unitary operations with \({U}_{\lambda }^{m}={({e}^{2\pi {\hat{A}}_{\lambda }})}^{m}\) and (b) the inverse QFT for two qubits shown in Fig. 4. The only difference between them is the measurement part in QPEA. The hybrid scheme first accepts the results of QPEA to estimate partial information of eigenvalues in two bits used for building the QAE circuit as shown in Fig. 4(d). From the results depicted in Fig. 5(a), we can verify that the performance of the QPEA on IBMQX is quite useful to confirm the first two bits of the eigenvalues of \({\hat{A}}_{\lambda }\) even with some unavoidable errors in the IBMQX circuit.

Figure 5
figure 5

Experimental results on IBMQX4: (a) the QPEA with 2-qubit register. (b) the original HHL algorithm and reduced HHL part.

In Fig. 5(b), the probabilities of theoretical and two experimental cases are depicted for both the original and reduced HHL algorithms. The solution state |xV is measured in observable X in the basis set of {|+〉, |−〉} to verify the experimental solution state for both algorithms. We also perform ten sets of data with 1024 single shots per set. Since |xV is represented by c+ |+〉 + c|−〉, where \({c}_{\pm }\in {\mathbb{C}}\) such that |c+|2 + |c|2 = 1, probabilities |c+|2 and |c|2 tell us how close xV is to the theoretical solution. As mentioned earlier, the solution of the linear equation is obtained when the ancillary qubit is 1 after measured by Z. Theoretically, this probability of the post-measurement state 1 is quit small in the case of the linear equation in Eq. (9). This means that only the minority data contribute to plot the probabilities |c+|2 and |c|2.

From Fig. 5, we can know that the solution of the reduced HHL part is more accurate than that of the original HHL algorithm. The figure shows that, if we accept to use the first two bits of QPEA for the reduced AQE circuit, we can conclude that the results of the hybrid algorithm are closer to the theoretical results than that of the original HHL algorithm in the IBMQX setups.

Discussion

We have described the HHL algorithm which solves a quantized version of given linear equations. We have especially analyzed the QPE part of the HHL algorithm, and have devised the hybrid version of the HHL algorithm. Under the IBMQX setups, we have shown that the hybrid algorithm can reduce the number of two-qubit gates, and thus has more enhanced performance than that of the HHL algorithm for some specific linear equations.

The hybrid HHL algorithm stems from the fact that the QPE part of the HHL algorithm is identical to the QPEA without measurement. It follows that the AQE part of the original HHL algorithm can be reconstructed if we are able to obtain classical information from measurement outcomes of the prior QPEA to solve a linear equation. We remark that an iterative QPEA19 can be used as the first step of our hybrid algorithm. Since the iterative QPEA does not need the quantum Fourier transform for its implementation, the small number of qubits is required. So the use of the iterative QPEA would improve the resource efficiency of the hybrid algorithm. In addition, there have been some results in literature20,21 which generalize or improve the QPEA, and we expect that combining these results with the hybrid algorithm leads to other new hybrid quantum linear equation algorithms. Finally, there have been developed some quantum algorithms, such as the quantum counting algorithm22, the quantum machine learning algorithm3, and the high-order quantum algorithm4, which have relevance to the QPEA or the HHL algorithm. Hence, it would be interesting to find out hybrid versions for these algorithms.

Regarding quantum supremacy23, IBM has currently announced a new term, quantum volume24, which measures the useful amount of quantum computing done by a quantum device with specific number of qubits and error rate. In addition, error mitigation approaches25,26,27 have shown a new direction of managing the error accuracy for specific cases. In order to apply this extrapolation scheme, the amount of errors should be sufficiently small to claim that the error-propagation curve is linear. As mentioned earlier, the reduced HHL part of our hybrid algorithm can be implemented by a smaller number of quantum gates, which reduces the total error rate from the gates. Hence, we expect that the technique in the hybrid algorithm can be adopted in quantum algorithms to show quantum supremacy.

Methods

Quantum phase estimation algorithm

Suppose that a matrix \(\hat{A}\) is Hermitian with an eigenvalue λ in (0, 1) with respect to the corresponding eigenstate |u〉. For the unitary operation \({U}_{\hat{A}}\) defined as in Eq. (3), we obtain

$${U}_{\hat{A}}|u\rangle ={e}^{2\pi i\hat{A}}|u\rangle ={e}^{2\pi i\lambda }|u\rangle .$$

The aim of the QPEA is to find out an estimated value of λ, which is given by a binary string. The QPEA is performed with the input eigenstate |u〉 and n-qubit register. Then the estimated value of λ is obtained by measuring this n-qubit register as describedin Fig. 6.

Figure 6
figure 6

The circuit diagram of the QPEA with n-qubit register: H and \(F{T}^{\dagger }\) are the Hadamard gate and the inverse quantum Fourier transform. At the end, every register qubit is measured in observable Z.

Specifically, let us explain a process of the QPEA on \(\hat{A}\) in Eq. (1) and its eigenstate |uj in Eq. (2). The total input state of the QPEA is initialized in a quantum state \({|0\rangle }_{R}^{\otimes n}\otimes {|{u}_{j}\rangle }_{V}\) and Hadamard operations are firstly performed in n-qubit register, as shown in Fig. 6. After n controlled unitary gates, controlled-\({U}_{\hat{A}}^{{2}^{n-1}}\), the state (a) in Fig. 6 is given in

$$\frac{1}{\sqrt{{2}^{n}}}\sum _{y=0}^{{2}^{n}-1}\,{e}^{2\pi i{\lambda }_{j}y}{|y\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$

Then, the inverse of quantum Fourier transform is applied in the register qubits, and the state (b) in Fig. 6 can be written in

$$\frac{1}{{2}^{n}}\sum _{x,y=0}^{{2}^{n}-1}\,{e}^{2\pi iy({\lambda }_{j}-\frac{x}{{2}^{n}})}{|x\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$
(16)

Finally, each qubit in the register system R is measured with observable Z. For large n, if the measured outcome x in register qubits is close to λj(n), we find that Pr(x) is also close to one. Otherwise, if x is close to another n-bit string which is not λj(n), Pr(x) is close to zero. Therefore for sufficiently large n, we are able to obtain the n-binary estimation λj(n) of λj from the probability distribution of the measurement outcomes.

Fidelities in Figure 2(a)

We here present explicit expressions of the fidelities in Fig. 2(a). For i = 1, 2, 3 and λ (0, 1), denote Fi(λ) as the fidelity between an exact normalized solution and the solution obtained from the HHL algorithm with i-qubit register. Let tλ = e2iπλ, and \({t}_{\lambda }^{\ast }\) be the complex conjugate of tλ. Then

$${F}_{1}(\lambda )=\frac{1}{2}(1+({t}_{\lambda }+{t}_{\lambda }^{\ast })\frac{(-\,1+\lambda )\lambda }{1-2\lambda +2{\lambda }^{2}}).$$

Let Xλ = (40 + 32i) − (129 + 64i)λ + 129λ2 and Yλ = (9 + 32i) − (146 + 64i)λ + 146λ2. Then

$$\begin{array}{rcl}{F}_{2}(\lambda ) & = & {({t}_{\lambda }^{\ast })}^{3}\mathrm{[(25}+80{t}_{\lambda }+171{t}_{\lambda }^{2}+171{t}_{\lambda }^{8}+80{t}_{\lambda }^{9}+25{t}_{\lambda }^{10})(\,-\,1+\lambda )\lambda \\ & & +\,4{t}_{\lambda }^{4}{X}_{\lambda }+4{t}_{\lambda }^{6}{X}_{\lambda }^{\ast }+2{t}_{\lambda }^{3}{Y}_{\lambda }+2{t}_{\lambda }^{7}{Y}_{\lambda }^{\ast }+\,4{t}_{\lambda }^{5}(89-170\lambda +170{\lambda }^{2})]\\ & & \,\mathrm{/[4(9}+80{t}_{\lambda }+178{t}_{\lambda }^{2}+80{t}_{\lambda }^{3}+9{t}_{\lambda }^{4}\mathrm{)(1}-2\lambda +2{\lambda }^{2}\mathrm{)]}.\end{array}$$

Let A = 140 + 105i, \(B=\mathrm{(208}+128i)\sqrt{2}\), \(C=\mathrm{8(35}+52\sqrt{2})\), \(D=\mathrm{8(}\,-\,35+52\sqrt{2})\), \(E=\mathrm{2(105}+128\sqrt{2})\), \(F=-\,210+256\sqrt{2}\), \(G=11025+76672\sqrt{2}\), and \(H=-\,11025+76672\sqrt{2}\), and let \({\alpha }_{\lambda }=-\,{({t}_{\lambda }^{\ast })}^{14}\mathrm{/(128}\)\(\mathrm{(1}-2\lambda +2{\lambda }^{2}))\), \({\beta }_{\lambda }={\alpha }_{\lambda }{(-1+{t}_{\lambda }^{8})}^{2}\), γλ = 350 + 608i−700λ, \({\varphi }_{\lambda }=315+420i+\mathrm{(384}-624i)\sqrt{2}-3E\lambda \), ξλ = −304 + 175i + 608λ. Then we have the fidelity

$${F}_{3}(\lambda )=\frac{\sum _{j\mathrm{=1}}^{8}\,{N}_{j}(\lambda )}{D(\lambda )},$$

where

$$\begin{array}{rcl}{N}_{1}(\lambda ) & = & {\alpha }_{\lambda }[{A}^{\ast }+B-1276i{t}_{\lambda }^{3}+8712i{t}_{\lambda }^{7}-1276i{t}_{\lambda }^{11}-C\lambda +\mathrm{(6}{t}_{\lambda }^{5}+2{t}_{\lambda }^{13}){\xi }_{\lambda }^{\ast }\\ & & -\mathrm{(2}t+6{t}_{\lambda }^{9}){\xi }_{\lambda }+\mathrm{(5}{t}_{\lambda }^{4}+3{t}_{\lambda }^{12})({A}^{\ast }-B+D\lambda )-\mathrm{(3}{t}_{\lambda }^{2}+5{t}_{\lambda }^{10})(A-{B}^{\ast }+D\lambda )\\ & & -\,7{t}_{\lambda }^{8}(\,-\,{A}^{\ast }-B+C\lambda )+\mathrm{(7}{t}_{\lambda }^{6}+{t}_{\lambda }^{14})(\,-\,A-{B}^{\ast }+C\lambda {)]}^{2},\\ {N}_{2}(\lambda ) & = & {\beta }_{\lambda }[{A}^{\ast }i+Bi+F\lambda +{t}_{\lambda }^{5}{\gamma }_{\lambda }^{\ast }+t{\gamma }_{\lambda }-1276{t}_{\lambda }^{3}(\,-\,1+2\lambda )\\ & & +{t}_{\lambda }^{4}{\varphi }_{\lambda }+{t}_{\lambda }^{2}{{\varphi }_{\lambda }}^{\ast }+{t}_{\lambda }^{6}(\,-\,Ai-{B}^{\ast }i+F\lambda {)]}^{2},\\ {N}_{3}(\lambda ) & = & {\beta }_{\lambda }[{A}^{\ast }i+Bi+F\lambda +{t}_{\lambda }^{5}{\gamma }_{\lambda }^{\ast }+{t}_{\lambda }{\gamma }_{\lambda }+{t}_{\lambda }^{4}({A}^{\ast }i-Bi-E\lambda )\\ & & +\,{t}_{\lambda }^{2}(\,-\,Ai+{B}^{\ast }i-E\lambda )+{t}_{\lambda }^{6}(\,-\,Ai-{B}^{\ast }i+F\lambda {)]}^{2},\\ {N}_{4}(\lambda ) & = & {\beta }_{\lambda }[-\,{A}^{\ast }-B+C\lambda +2{t}_{\lambda }^{5}{\xi }_{\lambda }^{\ast }+2{t}_{\lambda }{\xi }_{\lambda }+{t}_{\lambda }^{4}({A}^{\ast }-B+D\lambda )\\ & & +\,{t}_{\lambda }^{2}(A-{B}^{\ast }+D\lambda )+{t}_{\lambda }^{6}(\,-\,A-{B}^{\ast }+C\lambda {)]}^{2},\\ {N}_{5}(\lambda ) & = & {\beta }_{\lambda }[{A}^{\ast }i+Bi+F\lambda +{t}_{\lambda }^{4}({A}^{\ast }i-Bi-E\lambda )\\ & & +\,{t}_{\lambda }^{2}(\,-\,Ai+{B}^{\ast }i-E\lambda )+{t}_{\lambda }^{6}(\,-\,Ai-{B}^{\ast }i+F\lambda {)]}^{2},\\ {N}_{6}(\lambda ) & = & {\beta }_{\lambda }[\,-\,{A}^{\ast }-B+C\lambda +{t}_{\lambda }^{4}({A}^{\ast }-B+D\lambda )+{t}_{\lambda }^{2}(A-{B}^{\ast }+D\lambda )\\ & & +\,{t}_{\lambda }^{6}(\,-\,A-{B}^{\ast }+C\lambda {)]}^{2},\\ {N}_{7}(\lambda ) & = & {\beta }_{\lambda }[\,-\,{A}^{\ast }-B+C\lambda +{t}_{\lambda }^{4}(\,-\,{A}^{\ast }+B-D\lambda )-{t}_{\lambda }^{2}(A-{B}^{\ast }+D\lambda )\\ & & +{t}_{\lambda }^{6}(\,-\,A-{B}^{\ast }+C\lambda {)]}^{2},\\ {N}_{8}(\lambda ) & = & {\beta }_{\lambda }[{A}^{\ast }i+Bi+F\lambda +{t}_{\lambda }^{6}(\,-\,Ai-{B}^{\ast }i+F\lambda )+{t}_{\lambda }^{2}({A}^{\ast }i-{B}^{\ast }i+2E\lambda ),\\ & & +\,{t}_{\lambda }^{4}(\,-\,{A}^{\ast }i+Bi+2E\lambda {)]}^{2}\\ D(\lambda ) & = & {({t}_{\lambda }^{\ast })}^{7}[H-75950{t}_{\lambda }-3G{t}_{\lambda }^{2}-586524{t}_{\lambda }^{3}-5G{t}_{\lambda }^{4}-227850{t}_{\lambda }^{5}+7H{t}_{\lambda }^{6}\\ & & +\,2133448{t}_{\lambda }^{7}+7H{t}_{\lambda }^{8}-227850{t}_{\lambda }^{9}-5G{t}_{\lambda }^{10}-586524{t}_{\lambda }^{11}\\ & & -\,3G{t}_{\lambda }^{12}-75950{t}_{\lambda }^{13}+H{t}_{\lambda }^{14}\mathrm{]}.\end{array}$$

Proof of Theorem 4 Since each eigenvalue λj of \(\hat{A}\) is perfectly n-estimated, its binary representation can be expressed as

$${\lambda }_{j}=0.{b}_{1}^{j}{b}_{2}^{j}\cdots {b}_{n}^{j}$$

for some \({b}_{i}^{j}\in \mathrm{\{0,}\,\mathrm{1\}}\). Then since βx|j in Eq. (6) becomes

$${\beta }_{x|j}=\frac{1}{{2}^{n}}\sum _{y\mathrm{=0}}^{{2}^{n}-1}\,{e}^{2\pi iy({2}^{n}{\lambda }_{j}-x){\mathrm{/2}}^{n}}=1$$

if x = 2nλj, and βx|j = 0 otherwise, the state in Eq. (4) must be

$${|0\rangle }_{A}\otimes \sum _{j=1}^{l}\,{\alpha }_{j}{|{b}_{1}^{j}{b}_{2}^{j}\cdots {b}_{n}^{j}\rangle }_{R}\otimes {|{u}_{j}\rangle }_{V}.$$
(17)

Since the positions of the fixed eigenmeans of \(\hat{A}\) do not affect this process, without loss of generality, we may assume that the k fixed eigenmeans of the matrix \(\hat{A}\) are \({\bar{m}}_{1},\,\cdots ,\,{\bar{m}}_{k}\). Then the state in Eq. (17) becomes

$${|0\rangle }_{A}\otimes {|{\bar{m}}_{1}\cdots \bar{m}\rangle }_{{k}_{{r}_{1}\cdots {r}_{k}}}\otimes \sum _{j=1}^{l}{\alpha }_{j}{|{b}_{k+1}^{j}\cdots {b}_{n}^{j}\rangle }_{{r}_{k+1}\cdots {r}_{n}}\otimes {|{u}_{j}\rangle }_{V},$$

since \({\bar{m}}_{i}={b}_{i}^{j}\) holds for all j and 1 ≤ i ≤ k. Thus the AQE part can be implemented by using (nk)-qubit register as follows:

$${|0\rangle }_{A}{|y\rangle }_{{r}_{k+1}\cdots {r}_{n}}\mapsto (\sqrt{1-\frac{{c}^{2}}{{(y^{\prime} +y)}^{2}}}{|0\rangle }_{A}+\frac{c}{y^{\prime} +y}{|1\rangle }_{A}){|y\rangle }_{{r}_{k+1}\cdots {r}_{n}},$$

where 0 ≤ y ≤ 2nk−1 and \(y^{\prime} ={\sum }_{i=1}^{k}\,{2}^{(n-i)}{\bar{m}}_{i}\) □.