# Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

#### 2.1. Difference Scheme of the Poisson Equation

^{2}u/∂x

^{2}+ ∂

^{2}u/∂y

^{2}= −f(x,y)

#### 2.2. Discretization of the Equation

- Representation of the input vector b:|x〉|0〉 → |x〉|b〉
- Conversion of the matrix A into a quantum operation:|x〉|y〉|0〉 → |x〉|y〉|A(x,y)〉
- Calculation of the solution vector x:|x〉|y〉|A(x,y)〉|b〉 → |x〉|y〉|A(x,y)〉|b〉 − A(x,y)|x〉
- Measurement of the states of the qubits representing the solution vector x:|x〉|y〉|A(x,y)〉|b〉 → |x〉|y〉|A(x,y)〉|b〉 − A(x,y)|x〉

#### 2.3. HHL Algorithm

#### 2.4. Using the HHL Algorithm on the Poisson Equation

- The right-hand-side vector b is represented as a superposition of two states |0〉 and |1〉 proportional to it, i.e., |b〉 = sqrt(p
_{0})|0〉 + sqrt(p_{1})|1〉; - An operator is applied that effectively implements the action of the matrix A on the state |1〉, i.e., |1〉 → |A〉|1〉, where |A〉 is some state that encodes the matrix A;
- The quantum Fourier transform (QFT) is performed on the qubits corresponding to the right-hand-side vector and matrix A;
- The qubit corresponding to the right-side vector is measured. In this case, it is the probability of getting 0 or 1;
- Inverse QFT (IQFT) is applied on all qubits to obtain the inverse Fourier transform for the state |y〉;
- The first N qubits are measured on the standard basis and the output results are obtained. Then, using the results of measurements and the IQFT, an estimate of the solution x is obtained;
- To estimate the accuracy of the solution, the vector $\stackrel{~}{b}=A\times \stackrel{~}{x}$ is calculated, where $\stackrel{~}{x}$ is the estimate of the solution x;
- The norm $\Vert b-\stackrel{~}{b}\Vert $ is evaluated to obtain an estimate of the error of the solution.

^{2}qubits, where N represents the number of points on the grid in each dimension. The stages of solving and creating a quantum circuit are shown in Figure 4.

_{0})|0〉 + sqrt(p

_{1})|1〉. This step is to represent the vector on the right side of the equation as a superposition of two quantum states. To do this, the principle of superposition is used, according to which each possible state of a quantum system can be expressed as a linear combination of two basic states, for example, |0〉 and |1〉. In this case, the right vector b is represented as a superposition of states |0〉 and |1〉 proportional to it with weights sqrt(p

_{0}) and sqrt(p

_{1}), respectively. That is, the vector b is represented as a combination of two states, each state corresponds to one of the possible values of the elements of the vector b (0 or 1), and the weight of this state is determined by the probability of the occurrence of this value of the element of the vector b in solving the equation.

^{n−1}. Mathematically, this can be expressed as follows:

## 3. Results

#### 3.1. Quantum Scheme and Probabilities for States

- A quantum circuit is created with N × N qubits and one classical bit.
- The gates associated with matrix A are applied. Each non-zero element of matrix A leads to the application of the corresponding gates. If the element is on the main diagonal (i = j), the rz gate is used. Otherwise, when the element is off the main diagonal (i! = j), the CRZ gate is used.
- The Hadamard h gate is applied to all qubits.
- QFT quantum Fourier transform is applied on all qubits.
- cswap gate is applied between certain qubits.
- gates rz and rx with defined angles are applied on each qubit.
- The last rz valve with an angle of 0 can be omitted because it is equivalent to the identity valve.
- The last qubit is measured, and the result is stored in the classic bit.

#### 3.2. Error Calculations in Different Quantum Simulators and in Different Qubits

^{−3}s. This value emerged when the matrix was of a small size. If it is possible to increase the size of the matrix, then quantum simulators freeze and cannot cope with this load.

- Problem size: The table shows that the HHL algorithm uses only 5 qubits on real quantum computers and 63 qubits on a quantum simulator. If the problem scales with increasing numbers of qubits, real quantum computers may begin to show their advantages.
- Noise and decoherence: Real quantum computers are subject to noise and decoherence, which can slow down the execution of algorithms. Simulators can bypass this limitation because they do not encounter the real physics and noise associated with real quantum systems. If the matrix size is increased, the number of qubits may not be sufficient to run it on real quantum computers. Therefore, the results of work in quantum simulators are obtained faster than on real quantum computers.

## 4. Discussion

## 5. Conclusions

^{−3}s. These execution times were observed when working with a small matrix size. To achieve favorable outcomes, it is essential to have the capability to utilize quantum computers and conduct tests on them.

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Cao, Y.; Papageorgiou, A.; Petras, I.; Traub, J.; Kais, S. Quantum algorithm and circuit design solving the Poisson equation. New J. Phys.
**2013**, 15, 013021. [Google Scholar] [CrossRef] - Dervovic, D.; Herbster, M.; Mountney, P.; Severini, S.; Usher, N.; Wossnig, L. Quantum linear systems algorithms: A primer (Version 1). arXiv
**2018**, arXiv:1802.0822. [Google Scholar] [CrossRef] - Morrell, H.J.; Wong, H.Y. Study of using Quantum Computer to Solve Poisson Equation in Gate Insulators. In Proceedings of the International Conference on Simulation of Semiconductor Processes and Devices (SISPAD), Dallas, TX, USA, 27–29 September 2021. [Google Scholar]
- Childs, A.M.; Liu, J.-P.; Ostrander, A. High-precision quantum algorithms for partial differential equations. Quantum
**2020**, 5, 574. [Google Scholar] [CrossRef] - Liu, H.-L.; Wu, Y.-S.; Wan, L.-C.; Pan, S.-J.; Qin, S.-J.; Gao, F.; Wen, Q.-Y. Variational quantum algorithm for the Poisson equation. Phys. Rev. A
**2021**, 104, 022418. [Google Scholar] [CrossRef] - Costa, P.C.S.; Jordan, S.; Ostrander, A. Quantum algorithm for simulating the wave equation. Phys. Rev. A
**2019**, 99, 012323. [Google Scholar] [CrossRef] - Lloyd, S.; De Palma, G.; Gokler, C.; Kiani, B.; Liu, Z.-W.; Marvian, M.; Tennie, F.; Palmer, T. Quantum algorithm for nonlinear differential equations (Version 2). arXiv
**2020**, arXiv:2011.06571. [Google Scholar] [CrossRef] - Matsuo, S.; Souma, S. A proposal of quantum computing algorithm to solve Poisson equation for nanoscale devices under Neumann boundary condition. In Solid-State Electronics; Elsevier: Amsterdam, The Netherlands, 2023; Volume 200, p. 108547. [Google Scholar] [CrossRef]
- Pesah, A. Quantum Algorithms for Solving Partial Differential Equations; University College London: London, UK, 2020. [Google Scholar]
- Engel, A.; Smith, G.; Parker, S.E. Quantum algorithm for the Vlasov equation. Phys. Rev. A
**2019**, 100, 062315. [Google Scholar] [CrossRef] - Linden, N.; Montanaro, A.; Shao, C. Quantum vs. Classical Algorithms for Solving the Heat Equation. arXiv
**2020**, arXiv:2004.06516. [Google Scholar] [CrossRef] - Berry, D.W.; Childs, A.M.; Ostrander, A.; Wang, G. Quantum algorithm for linear differential equations with exponentially improved dependence on precision. Commun. Math. Phys.
**2017**, 356, 1057–1081. [Google Scholar] [CrossRef] - Childs, A.M.; Liu, J.-P. Quantum Spectral Methods for Differential Equations. Commun. Math. Phys.
**2020**, 375, 1427–1457. [Google Scholar] [CrossRef] - Montanaro, A.; Pallister, S. Quantum algorithms and the finite element method. Phys. Rev. A
**2016**, 93, 032324. [Google Scholar] [CrossRef] - Gaitan, F. Finding flows of a Navier–Stokes fluid through quantum computing. Npj Quantum Inf.
**2020**, 6, 61. [Google Scholar] [CrossRef] - Mebrate, B.; Koya, P.R. Numerical Solution of a Two Dimensional Poisson Equation with Dirichlet Boundary Conditions. Am. J. Appl. Math.
**2015**, 3, 297. [Google Scholar] [CrossRef] - Duan, B.; Yuan, J.; Yu, C.-H.; Huang, J.; Hsieh, C.-Y. A survey on HHL algorithm: From theory to application in quantum machine learning. Phys. Lett. A
**2020**, 384, 126595. [Google Scholar] [CrossRef] - Liu, X.; Xie, H.; Liu, Z.; Zhao, C. Survey on the Improvement and Application of HHL Algorithm. J. Phys. Conf. Ser.
**2022**, 2333, 012023. [Google Scholar] [CrossRef] - Camps, D.; Van Beeumen, R.; Yang, C. Quantum Fourier transform revisited. Numer. Linear Algebra Appl.
**2020**, 28, e2331. [Google Scholar] [CrossRef] - IBM Quantum Lab. Available online: https://lab.quantum-computing.ibm.com/ (accessed on 1 May 2023).
- Shepherd, D. On the Role of Hadamard Gates in Quantum Circuits (Version 2). arXiv
**2005**, arXiv:quant-ph/0508153. [Google Scholar] [CrossRef] - de Bruijn, N. Remarks on Hermitian Matrices. Linear Algebra Appl.
**1980**, 32, 201–208. [Google Scholar] [CrossRef] - Zhang, M.; Dong, L.; Zeng, Y.; Cao, N. Improved circuit implementation of the HHL algorithm and its simulations on QISKIT. Sci. Rep.
**2022**, 12, 13287. [Google Scholar] [CrossRef] [PubMed]

**Figure 1.**A 5 × 5 rectangular grid (black dots represent internal nodes of the grid; white dots represent border nodes).

Quantum Simulators | Type | Time (s) |
---|---|---|

qasm_simulator | General | 51.353 |

ibmq_qasm_simulator | General, context aware | 24.219 |

statevector_simulator | Schrödinger wavefunction | 5.745 |

matrix_product_state | Extended Clifford | 0.6654 |

Quantum Resources | Number of Qubits | Time (s) |
---|---|---|

simulator_extended_stabilizer | 63 | 0.7246 |

ibmq_quito | 5 | 4.7431 |

ibmq_belem | 5 | 5.0169 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Daribayev, B.; Mukhanbet, A.; Imankulov, T.
Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators. *Appl. Sci.* **2023**, *13*, 11491.
https://doi.org/10.3390/app132011491

**AMA Style**

Daribayev B, Mukhanbet A, Imankulov T.
Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators. *Applied Sciences*. 2023; 13(20):11491.
https://doi.org/10.3390/app132011491

**Chicago/Turabian Style**

Daribayev, Beimbet, Aksultan Mukhanbet, and Timur Imankulov.
2023. "Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators" *Applied Sciences* 13, no. 20: 11491.
https://doi.org/10.3390/app132011491