# Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators
## 2 Materials and Methods
### HHL Algorithm
If a measurement result of 0 is obtained, this means that the state vector of the quantum system is closer to \(\ket{0}\), and if a measurement result of 1 is obtained, this means that the state vector of the quantum system is closer by \(\ket{1}\). Thus, the probability of obtaining a result of 0 or 1 when measuring the first qubit depends on how close the right side of the equation is to \(\ket{10}\) or \(\ket{1}\). The closer the right side is to \(\ket{10}\), the higher the probability is of obtaining the result 0, and the closer the right side is to \(\ket{11}\), the higher the probability is of obtaining the result 1. The implementation of the quantum circuit was performed using Qiskit ([[https://qiskit.org/](https://qiskit.org/)]([https://qiskit.org/](https://qiskit.org/)), accessed on 12 September 2023). Since it was not possible to obtain access to a real quantum computer for testing and running the circuit, quantum simulators were utilized instead. To obtain the result, one needs to apply the inverse QFT (IQFT) to all qubits of the quantum circuit in order to obtain the quantum Fourier transform for the state \(\ket{y}\). In the algorithm for solving the Poisson equation using the QFT, it is necessary to apply the IQFT to the quantum state obtained as a result of the Fourier transform in the previous step. The Fourier transform and its inverse are used to change the representation of numbers from one base to another. In the context of quantum computing, the QFT is defined by  
\[F(\ket{x})=(N-1){\sum}_{y=0}^{N-1}e^{\frac{2\pi iy}{N}}\mid y\rangle \tag{11}\]  
where \(\mid x\rangle\) is the quantum state to be transformed, \(\mid y\rangle\) is the quantum state in the new basis, and \(N\) is the number of qubits in the register. The IQFT is defined as  
\[F-1(\mid y\rangle)=(N-1){\sum}_{y=0}^{N-1}e^{(-\frac{2\pi iy}{N})}\mid x\rangle \tag{12}\]  
The IQFT is applied to the quantum state that results from the Fourier transform in the previous step to return that state to its original representation. When using QFT to solve the Poisson equation on a quantum computer, the IQFT is used to measure the computation's result in a new basis, where the solution to the Poisson equation is represented by the most probable state. After these steps, the quantum circuit is as follows (Figure 6). Figure 6: Quantum circuit after application of QFT and IQFT. After applying the IQFT to the measurement results, the state of the qubits is obtained, which depends on the value of solution x. This state can be expressed as a sum of basis vectors, where the weight of each vector is determined by the corresponding Fourier coefficient. Then, this state is measured on a standard basis to obtain one of the possible vectors. The result is an estimate of the solution x, which is a linear combination of basis vectors whose weights are determined by the Fourier coefficients. This score can be used to evaluate the accuracy of the solution. Then, it is necessary to evaluate the accuracy of the algorithm. To estimate the accuracy of the solution, vector \(b=A\ \times x\) will be calculated, where \(x\) is the estimate of the solution \(x\). However, in practice, the matrix \(A\) may be poorly conditioned, and significant changes in the vector may lead to large changes in the solution of \(x\). In this case, the resulting solution may be inaccurate or unstable. To evaluate the accuracy of the resulting solution, the vector \(\overset{\sim}{b}\) is calculated by multiplying the matrix \(A\) by the vector \(\overset{\sim}{x}\), which is our estimate of the solution \(x\). If the vectors \(b\) and \(\overset{\sim}{b}\) are close, then our estimate of the solution is accurate. If the vectors are very different, our estimate may not be accurate, and additional iterations of the algorithm must be performed to improve the accuracy of the solution. To calculate the vector \(\overset{\sim}{b}\), another quantum register is created and operators corresponding to the matrix \(A\) are applied to it.