# Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators
## 2 Materials and Methods  
### Difference Scheme of the Poisson Equation  
In the 2D case, the Poisson equation is written as  
\[\partial^{2}u/\partial x^{2}+\partial^{2}u/\partial y^{2}=-f(x,y) \tag{1}\]where \(u\) is an unknown function that determines the distribution of the potential in the 2D region given by variables \(x\) and \(y\)[16]. The function \(f(x,y)\) represents sources in this area. This equation can be used to model electrostatic fields, fluid flows, temperature distribution in areas with variable thermal conductivity, etc. The problem is to find a function \(f(x,y)\) that satisfies Equation (1) and boundary conditions. Boundary conditions can be specified on the region's boundary to indicate the value of the function \(f(x,y)\) on that boundary. To solve the problem, it is necessary to choose an appropriate method and apply it to calculate the function \(f(x,y)\) in a given area with given boundary conditions. The approximation of differential Equation (1), using the formulas for finding the second-order individual derivatives at the internal nodes of the grid, is constructed as follows:  
\[ \begin{array}{c}\frac{\partial^{2}u}{\partial x^{2}}\approx u_{\mathbf{\mathrm{ x}}x_{ij}}=\frac{u_{i-1j-2u_{j}+u_{i+1j}}}{h^{2}},\\ \frac{\partial^{2}u}{\partial y^{2}}\approx u_{\mathbf{\mathrm{y}}y_{ij}}=\frac{u_ {i-1}-2u_{ij}+u_{i+1}}{h^{2}}\end{array}  \tag{2}\]  
Let us write the system of linear algebraic equations obtained from the finite difference form of the 2D Poisson equation in matrix form. First, equations are written for each grid point according to Equation (2). Figure 1 shows the mesh of [PERSON]'s equation in the case of \(n=5\). Apart from the boundary values, nine equations were written for the \(3\times 3\) interior points:  
\[ \begin{array}{c}-4\mathbf{u}_{11}+\mathbf{u}_{01}+\mathbf{u}_{21}+\mathbf{u}_{10}+\mathbf{u}_{12 }=h^{2}\mathbf{f}_{11}\\ -4\mathbf{u}_{12}+\mathbf{u}_{02}+\mathbf{u}_{22}+\mathbf{u}_{11}+\mathbf{u}_{13}=h^{2}\mathbf{f}_{12} \\ -4\mathbf{u}_{13}+\mathbf{u}_{03}+\mathbf{u}_{23}+\mathbf{u}_{12}+\mathbf{u}_{14}=h^{2}\mathbf{f}_{13} \\ \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad \qquad\cdots\\ -4\mathbf{u}_{33}+\mathbf{u}_{23}+\mathbf{u}_{43}+\mathbf{u}_{32}+\mathbf{u}_{34}=h^{2}\mathbf{f}_{33} \end{array}  \tag{3}\]  
If the \(x_{(i-1)*(n-2)+(j-1)}=u_{ij},\ i=1,\ldots,n-2,\ j=1,\ldots,n-2\) is added for unknown and known boundaries, moving values to the right side of the equation, then they can be expressed in the following SLAE (system of linear algebraic equations) form:  
\[ \begin{array}{c}-4\mathbf{x}_{0}+\mathbf{x}_{1}+\mathbf{x}_{3}=h^{2}\mathbf{f}_{11}-\mathbf{u}_ {01}-\mathbf{u}_{10}\\ -4\mathbf{x}_{1}+\mathbf{x}_{0}+\mathbf{x}_{2}+\mathbf{x}_{4}=h^{2}\mathbf{f}_{12}-\mathbf{u}_{02}\\ -4\mathbf{x}_{2}+\mathbf{x}_{1}+\mathbf{x}_{5}=h^{2}\mathbf{f}_{13}-\mathbf{u}_{03}-\mathbf{u}_{14}\\ \qquad\qquad\qquad\qquad\qquad\qquad\qquad\cdots\\ -4\mathbf{x}_{8}+\mathbf{x}_{5}+\mathbf{x}_{7}=h^{2}\mathbf{f}_{33}-\mathbf{u}_{34}-\mathbf{u}_{43} \end{array}  \tag{4}\]  
Figure 1: A \(5\times 5\) rectangular grid (black dots represent internal nodes of the grid; white dots represent border nodes). The given SLAE can be expressed in the form of this formula. Now, let us try to solve this equation using quantum algorithms. \[Ax=b \tag{5}\]  
An example of a quantum algorithm that can be applied to solve the Poisson equation is the HHL algorithm [17]. HHL can be used to find an approximate solution to the Poisson equation with a given accuracy. The quantum algorithm can be used to solve the Poisson equation on a 2D grid with Dirichlet boundary conditions. In this article, a modified version of the HHL algorithm is used, which utilizes CRZ rotations instead of matrix elements. This modification significantly reduces the number of qubits and gates in the circuit. The traditional implementation of the HHL algorithm requires matrix elements for the operator, which incurs a significant cost in memory and computing resources.