# Solving Multidimensional Partial Differential Equations Using Efficient Quantum Circuits
## 4 Materials and Methods
### Multidimensional Poisson Equation
#### 4.2.4 4D Poisson Equation  
A 4D Poisson equation can be written as shown in (24). The four dimensions considered in (24) are spatial dimensions \(x\), \(y\), and \(z\), along with the temporal dimension \(t\). \[\frac{\partial^{2}u(x,y,z,t)}{\partial x^{2}}+\frac{\partial^{2}u (x,y,z,t)}{\partial y^{2}}+\frac{\partial^{2}u(x,y,z,t)}{\partial z^{2}}+ \tag{24}\] \[\frac{\partial^{2}u(x,y,z,t)}{\partial t^{2}}=f(x,y,z,t)\]  
The step size along \(x\)-dimension, \(y\)-dimension, and \(z\)-dimension are shown in (25). \[\Delta_{x} =\frac{X_{max}-X_{min}}{N_{x}-1}=\frac{X_{diff}}{N_{x}-1}, \tag{25}\] \[\Delta_{y} =\frac{Y_{max}-Y_{min}}{N_{y}-1}=\frac{Y_{diff}}{N_{y}-1},\] \[\Delta_{z} =\frac{Z_{max}-Z_{min}}{N_{z}-1}=\frac{Z_{diff}}{N_{z}-1},\] \[\Delta_{t} =\frac{t_{max}-t_{min}}{N_{t}-1}=\frac{t_{diff}}{N_{t}-1}\]  
After applying second-order finite approximation and considering \(\Delta=min(\Delta_{x},\Delta_{y},\Delta_{z},\Delta_{t})\), (24) can be discretized into (26). By rearranging the terms in (26), it can be further reduced to (27). The expression in (27) can be converted into the matrix  
Figure 7: FDM grid discretization for the 3D Poisson equation. form \(A\vec{u}=\vec{b}\), using the grid point indices \(x_{i}\), \(y_{i}\), \(z_{i}\), and \(t_{i}\), where \(0\leq x_{i}<N_{x}\), \(0\leq y_{i}<N_{y}\), \(0\leq z_{i}<N_{z}\), and \(0\leq t_{i}<N_{t}\). \[\left(\frac{u_{t_{i},z_{i}y_{i},x_{i}+1}-2u_{t_{i},z_{i}y_{i},x_{i} }+u_{t_{i},z_{i}y_{i},x_{i}+1}}{\Delta_{x}^{2}}\right)+\left(\frac{u_{t_{i},z_{ i},y_{i}+1,x_{i}}-2u_{t_{i},z_{i},y_{i},x_{i}}+u_{t_{i},z_{i},y_{i}+1,x_{i}}}{ \Delta_{y}^{2}}\right)+ \tag{26}\] \[\left(\frac{u_{t_{i},z_{i}+1,y_{i},x_{i}}-2u_{t_{i},z_{i},y_{i},x_ {i}}+u_{t_{i},z_{i}+1,y_{i},x_{i}}}{\Delta_{z}^{2}}\right)+\left(\frac{u_{t_{i} +1,z_{i}y_{i},x_{i}}-2u_{t_{i},z_{i}y_{i},x_{i}}+u_{t_{i}+1,z_{i}y_{i},x_{i}} }{\Delta_{t}^{2}}\right)=f_{t_{i},z_{i},y_{i},x_{i}}\] \[-8u_{t_{i},z_{i}y_{i},x_{i}}+u_{t_{i},z_{i},y_{i},x_{i}+1}+u_{t_{ i},z_{i},y_{i},x_{i}-1}+\] \[\frac{\partial^{2}u(x,y,z,t)}{\partial t^{2}}=f(x,y,z,t)\]0 (27) \[\frac{\partial^{2}u(x,y,z,t)}{\partial t^{2}}=f(x,y,z,t)\]1  
The matrix \(A\) and the vector \(\vec{b}\) can be determined for any number of dimensions up to four using the Algorithm 1. ```
1:Input:
2:\(X_{diff},Y_{diff},Z_{diff},t_{diff}\)\(\triangleright\) Domain lengths in each dimension
3:\(N_{x}^{{}^{\prime}},N_{y}^{{}^{\prime}},N_{z}^{{}^{\prime}},N_{t}^{{}^{ \prime}}\)\(\triangleright\) Initial number of points in each dimension
4:
5:Qubits used for each dimension
6:\(n_{x\_qubits}\leftarrow\lceil\log_{2}N_{x}^{{}^{\prime}}\rceil\)
7:\(n_{y\_qubits}\leftarrow\lceil\log_{2}N_{y}^{{}^{\prime}}\rceil\)
8:\(n_{z\_qubits}\leftarrow\lceil\log_{2}N_{z}^{{}^{\prime}}\rceil\)
9:\(n_{t\_qubits}\leftarrow\lceil\log_{2}N_{t}^{{}^{\prime}}\rceil\)
10:
11:Adjust grid sizes for quantum-based approach (if needed). 12:\(N_{x}\gets 2^{n_{x\_qubits}}\)
13:\(N_{y}\gets 2^{n_{x\_qubits}}\)
14:\(N_{z}\gets 2^{n_{z\_qubits}}\)
15:\(N_{t}\gets 2^{n_{t\_qubits}}\)
16:\(n_{total\_qubits}\leftarrow\sum\Bigl{(}n_{x\_qubits},n_{y\_qubits},n_{z\_qubits},n_{t\_ qubits}\Bigr{)}\)
17:\(u_{x\_-,1},u_{y\_-,1},u_{t_{i}-1}\)\(\triangleright\) Boundary values (lower ends)
18:\(u_{N_{x}},u_{N_{y}},u_{N_{z}},u_{N_{t}}\)\(\triangleright\) Boundary values (upper ends)
19:Define coefficients\(\lambda_{x},\lambda_{y},\lambda_{z},\lambda_{t}\)
20:\(\lambda_{x}\leftarrow \begin{cases}1&\text{if }N_{x}>1\\ 0&\text{otherwise}\end{cases} \)
21:\(\lambda_{y}\leftarrow \begin{cases}1&\text{if }N_{y}>1\\ 0&\text{otherwise}\end{cases} \)
22:\(\lambda_{z}\leftarrow \begin{cases}1&\text{if }N_{z}>1\\ 0&\text{otherwise}\end{cases} \)
23:\(\lambda_{t}\leftarrow \begin{cases}1&\text{if }N_{t}>1\\ 0&\text{otherwise}\end{cases}