# Implementation of the HHL Algorithm for Solving the Poisson Equation on Quantum Simulators
## 2 Materials and Methods
### HHL Algorithm  
First, let us consider the solution of a system of linear equations using the HHL algorithm for a 2 \(\times\) 2 matrix. The system of linear equations is given as \(Ax=b\), which defines the matrix \(A\) and the vector b for the approximate linear system of equations. The HHL algorithm requires the calculation of alpha, beta, and theta parameters using matrix \(A\) and vector \(b\). These parameters are then used to construct a quantum circuit that prepares the \(\ket{\text{psi}}\) state, which approximates the solution of Equation (5). Then, a quantum circuit is built. The circuit uses three qubits and one classical bit. The initial state is a superposition of \(\ket{0}\) and \(\ket{1}\) on the first qubit, generated using the Hadamard gate [21]. The circuit then applies a sequence of quantum gates to generate the state \(\ket{\text{psi}}\). The QFT algorithm is now used to solve this system of linear equations. A quantum circuit is created with the number of qubits corresponding to the number of unknowns in the system of equations. Each qubit corresponds to one unknown. Then, the universal gates and cswap operations that make up the QFT algorithm are applied and the last qubit is measured to obtain the result as a classical bit. The quantum circuit can be seen in Figure 2.  
Then, the probabilistic amplitudes are calculated for all states resulting from the execution of the quantum circuit. The circuit is executed on a quantum simulator with a step count of 1024. A three-qubit QASM quantum simulator was used for these calculations of quantum measurement numbers. In Figure 3, the number of measurements where the quantum computer returned 0 and 1 is calculated. The number of measurements contains information about how many times each bit was measured in the 0 and 1 states, assuming that in some cases the measurements are not deterministic, and the results are not accurate. The state of the quantum system that corresponds most closely (with the greatest amplitude) to the solution of the equation \(Ax=b\) is computed. Figure 2: \(Ax=b\) quantum circuit using the HHL algorithm. The general idea of the algorithm is as follows, and each part will be analyzed separately. First, the right-hand-side vector b is represented as a superposition of two states \(\left|0\right\rangle\) and \(\left|11\right\rangle\) proportional to it, i.e., \(\left|b\right\rangle=sqrt(p_{0})\left|0\right\rangle+sqrt(p_{1})\left|11\right\rangle\). 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, \(\left|0\right\rangle\) and \(\left|11\right\rangle\). In this case, the right vector \(b\) is represented as a superposition of states \(\left|0\right\rangle\) and \(\left|11\right\rangle\) 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. Then, an operator is applied that effectively implements the action of the matrix \(A\) on the state \(\left|1\right\rangle\), i.e., \(\left|1\right\rangle\rightarrow\left|A\right\rangle\left|1\right\rangle\), where \(\left|A\right\rangle\) is some state that encodes the matrix \(A\). In linear quantum algebra, there is the concept of a quantum state, which can be represented as a vector in Hilbert space. In this case, the state \(\left|1\right\rangle\) denotes a qubit that is in the unit state. Matrix \(A\) is a matrix that describes the linear transformation of the system that relates the input vector to the output.