Open-access A DIMENSION-INDEPENDENT FINITE DIFFERENCE METHOD FOR THE POISSON EQUATION USING AN INDEX MAPPING FUNCTION

ABSTRACT

The numerical solution to the Poisson Problem is widely known and studied in various fields of science for its vast applications. However, most applications consider the case in two dimensions, with fewer studies addressing the problem in dimension three or higher. Most literature texts present a twodimensional case implementation using an approach that makes it difficult to extend to higher dimensions. Our work aims to propose a generalization of the numerical solution to the Poisson problem that can be implemented for any dimension. The strategy used considers an index function that enumerates the mesh points so that, using this index, the implementation is easily extended to any dimension. In addition to the numerical solution extension, we developed the mathematical foundation for the consistency and stability of the solution in arbitrary dimension. The preliminary results consider the implementation in Python and experiments that demonstrate the feasibility of the proposed methodology.

Keywords:
Poisson’s equation; Dirichlet boundary condition; numerical solution

1 INTRODUCTION

It is a known fact that many models exist in the literature for the Poisson Problem in one and two dimensions, both demonstrated with the necessary mathematical rigor and implemented in some programming language. However, there is a smaller amount of work on mathematical modeling for the three-dimensional case of the Poisson Problem. There is also a difficulty when trying to expand the modeling to a new dimension, requiring a new implementation, with non-trivial changes, for each desired dimension. In the present work, we note that the creation of an index function to enumerate the mesh points corresponding to unknown values, not only facilitates the implementation for the two-dimensional and three-dimensional case, but also creates a generalization that facilitates the implementation in any dimension. This approach, using the index function, was not found in any other work during our literature review. This function plays a very important role in the implementation because, by enumerating sampled elements of the domain, it simplifies the construction of the coefficient matrix of the sparse linear system that arises in the modeling of the solution. The index function allows this to be done systematically and efficiently and, moreover, it can be rewritten very easily so that the path to access the elements is not unique and depends on the enumeration one chooses, without this choice interfering with the solution.

In this work, therefore, we generalize the numerical solution to the Poisson problem using the finite difference method in the n dimension, with n ≥ 1. Consider the second-order elliptical problem, in the dimension n, given by

- Δ u ( x ) = f ( x ) , x ∈ Ω , (1.1)

with the Dirichlet boundary condition

u x = g x , x ∈ ∂ Ω ,

where Ω = (r 1 , s 1)×... × (r n , s n ), r j < s j , for j = 1, . . . , n, ∂ Ω is the boundary of Ω and ∆ denotes the Laplacian operator, given by

Δ u x = ∑ j = 1 n ∂ 2 u ∂ x j 2 ( x ) .

There are different approaches to solving these problems, depending on the geometry of the domain. Some recent studies, including the one, two and three dimensional Poisson equation, present numerical solutions using increasingly accurate and efficient methods 19), (18. There is a large amount of literature about the numerical solution of a Poisson equation, and a good review of results on this important subject can be found in 4), (12), (8), (7), (17), (21), (22), (27.

In this paper, motivated by the two-dimensional case 6), (15 and 24, the finite difference method is preferred due to the ease of implementation and computational efficiency for linear problems in rectangular regions of ℝ2. In practice, problems may be nonlinear, have nonrectangular domains, and be defined in ℝn with n > 2. Therefore, extending the method to handle these cases is of great importance for solving real-world problems.

In recent decades, numerous applications and extensions of the finite difference method for nonlinear Poisson-type differential equations have emerged. Owing to the nonlinear behavior of the partial differentiable equation under consideration, the theoretical analysis has been proved to be considerably difficult, especially for problems with irregular geometries and non-uniform boundary conditions. To study the nonlinearity in complex solution domain, it is a long history in resorting to numerical solutions. So far, different numerical techniques, including finite difference method 1), (5), (16, exponential finite difference method 20, quasilinear boundary element method 14, hybrid fundamental solution-based finite element method 26, the method of fundamental solution 2), (3, among others, have been developed to solve nonlinear Poissontype problems. More discussions on this topic, using other numerical techniques, can be found in the literature 28), (9.

There are several studies in the literature in which the finite difference method is applied to solve elliptic equations in the irregular domain 11), (13. In principle, its application is restricted to a domain with a boundary that has a relatively simple geometry 10, but for a domain with a more general boundary, certain special steps must be taken, with an exploratory approach to overcome this fact, as reported in the literature 23.

Although the finite difference formulation in ℝn follows classical generalizations, our focus is on an efficient computational abstraction via an index function that is rarely addressed explicitly in the literature. In most cases, the solution goes through the construction of a system of linear equations AU = B, where A is a sparse matrix in which the location of non-zero elements is not trivial, especially as the dimension n of the domain increases. Once the problem is formulated as a linear system, a wide range of existing numerical solvers and optimization techniques can be employed to improve CPU efficiency, particularly given that the resulting system matrix is highly sparse. This opens up opportunities for further performance improvements through the use of specialized sparse matrix libraries and parallel computing techniques.

The main contributions of this paper are the generalization of the numerical solution of the Poisson equation, with Dirichlet boundary conditions, in the dimension n, for all n ≥ 1, and the introduction of an index function I that facilitates the numerical modeling of the solution, and its computational implementation, using the sparse system of linear equations AU = B that results from the numerical problem studied, as seen in Section 2. The index function I, while enumerating the unknown elements of the discrete sample of the domain, facilitates the determination of the numerical solution of the Poisson Problem in any dimension of the Euclidean space and, using it, it is possible to know, for example, in which line and in which column each non-null element of the matrix A of the above system is located.

The rest of the article is organized as follows: In Section 2, we formulate the finite difference method of 2n + 1 points, with n ≥ 1, to obtain a numerical solution of the Poisson equation, with Dirichlet boundary conditions. In Section 3, we demonstrate the convergence of the method. For this, its consistency and stability is ensured. The computational implementation of the method is discussed in Section 4. In Section 5, we present experimental results to validate the proposed method in the solution of some elliptic problems and, finally, in Section 6, we present the conclusions and future directions of the study.

2 THE FINITE DIFFERENCE METHOD IN DIMENSION N

First, consider u a real function of n real variables sufficiently differentiable, x = (x 1 , . . . , x n ) in ℝn and h j > 0, with j = 1, . . . , n. Using Taylor’s formula, we get the central difference formula

∂ 2 u ∂ x j 2 x = u x + h j e j - 2 u x + u x - h j e j h j 2 - h j 2 12 ∂ 4 u ∂ x j 4 x + ( ϱ j - x j ) e j , (2.1)

where ρ j ∈ (x j −h j , x j + h j ) and e j = (0,..., 0, 1, 0, ..., 0) is a vector of the canonical basis of ℝn , with the jth coordinate equal to one and the others null, for j = 1, . . . , n.

To approximate second-order partial derivatives ∂2u∂xj2, j = 1, . . . , n , by finite differences, we cover the region Ω ∪ ∂Ω with a mesh. The points of this mesh are denoted by xi1,…,in=(x1i1,…,xnin), where xjij=rj+ij.hj,hj=sj-rjMj with i j = 0, 1, . . . , M j and j = 1, . . . , n.

We denote by Ωδ the set of mesh points that are interior to Ω and by ∂ Ωδ the set of mesh points that are on the border of Ω. Then, using the equations (1.1) and (2.1), we get the finite difference method of 2n + 1 points,

Δ δ U i 1 , … , i n = - f ( x i 1 , … , i n ) in Ω δ (2.2)

and

U i 1 , … , i n = g ( x i 1 , … , i n ) on ∂ Ω δ , (2.3)

where Ui1,…,in is the numerical solution and ∆δ is the discrete Laplacian operator given by

Δ δ U i 1 , … , i n = ∑ j = 1 n U i 1 , … , i j + 1 , … , i n - 2 U i 1 , … , i n + U i 1 , … , i j - 1 , … , i n h j 2 .

By substituting into the equation (2.2) each of the (M 1 − 1) · (M 2 − 1) · . . . · (M n − 1) points from Ωδ and using the equation (2.3), we get the linear system AU = B, with (M 1 − 1) · (M 2 − 1) · . . . · (M n − 1) equations and the same number of unknowns, where U is the column vector given by

U = ( U 1 , 1 , … , 1 , … , U M 1 - 1 , 1 , … , 1 , … , U 1 , M 2 - 1 , … , M n - 1 , … , U M 1 - 1 , M 2 - 1 , … , M n - 1 ) T ,

A = a b 1 b n b 1 a b 1 ⋱ 0 ⋱ ⋱ ⋱ 0 ⋱ b n ⋱ ⋱ ⋱ b n ⋱ 0 ⋱ ⋱ ⋱ 0 ⋱ b 1 a b 1 b n b 1 a

and

B = ( B 1 , 1 , … , 1 , … , B M 1 - 1 , 1 , … , 1 , … , B 1 , M 2 - 1 , … , M n - 1 , … , B M 1 - 1 , M 2 - 1 , … , M n - 1 ) T ,

where

B 1 , 1 , … , 1 = - f ( x 1 , 1 , … , 1 ) - g ( x 0 , 1 , … , 1 ) ( h 1 ) 2 - g ( x 1 , 0 , … , 1 ) ( h 2 ) 2 - … - g ( x 1 , 1 , … , 0 ) ( h n ) 2 , B M 1 - 1 , 1 , … , 1 = - f ( x M 1 - 1 , 1 , … , 1 ) - g ( x M 1 , 1 , … , 1 ) ( h 1 ) 2 - g ( x M 1 - 1 , 0 , … , 1 ) ( h 2 ) 2 - … - g ( x M 1 - 1 , 1 , … , 0 ) ( h n ) 2 , B 1 , M 2 - 1 , … , M n - 1 = - f ( x 1 , M 2 - 1 , … , M n - 1 ) - g ( x 0 , M 2 - 1 , … , M n - 1 ) ( h 1 ) 2 - … - g ( x 1 , M 2 - 1 , … , M n ) ( h n ) 2

and

B M 1 - 1 , M 2 - 1 , … , M n - 1 = - f ( x M 1 - 1 , M 2 - 1 , … , M n - 1 ) - g ( x M 1 , M 2 - 1 , … , M n - 1 ) ( h 1 ) 2 - … - g ( x M 1 - 1 , M 2 - 1 , … , M n ) ( h n ) 2 .

The notation X T represents the transpose of the X matrix. The matrix A is a sparse matrix, with non-zero elements at 2n + 1 diagonals. The values a, b 1, . . . , b n that appear on the diagonals are the coefficients of the discretization of 2n + 1 point, with n ≥ 1, and are given by

a = - 2 ∑ j = 1 n 1 h j 2 a n d b j = 1 h j 2 ,

for j = 1, . . . , n. Each number b j vanishes to zero in some positions of the matrix A. These positions, which depend on the dimension of Euclidean space and the value of each M j , with j = 1, . . . , n, obey a specific rule and will be seen in Section 4, where an index function enumerates the unknowns of the problem and determines the position of each non-zero element in matrix A.

In the next Section, the convergence of the method will be verified.

3 METHOD CONVERGENCE

To show that the method is convergent, consistency and stability will be analyzed. Thus, for the following definitions and results, given a discrete function V: Ωδ ∪ ∂Ωδ → ℝ, consider the operator ∆δ V: Ωδ ∪∂Ωδ → ℝ given by

Δ δ V ( x ) = ∑ j = 1 n V ( x + h j e j ) - 2 V ( x ) + V ( x - h j e j ) ( h j ) 2 ,

for all x ∈ Ωδ ∪ ∂Ωδ.

Definition 3.1. The local truncation error, denoted by τ i 1 , … , i n , is defined as

τ i 1 , … , i n = Δ δ u ( x i 1 , … , i n ) + f ( x i 1 , … , i n ) . (3.1)

The next lemma shows that the local truncation error decreases as we refine the mesh and gives us the convergence rate of this error.

Lemma 3.1.If the solution u of the equation (1.1) is differentiable up to order four in Ω, with limited fourth-order partial derivatives, then the local truncation error satisfies the inequality

| τ i 1 , … , i n | ≤ C ∑ j = 1 n h j 2 ,

where C is a positive constant independent of hj, with j = 1, . . . , n.

Proof. Applying 2n times the Taylor’s formula, we get the following developments around the point xi1,…,in:

u ( x i 1 , … , i n + h j e j ) = u ( x i 1 , … , i n ) + h j ∂ u ∂ x j ( x i 1 , … , i n ) + ( h j ) 2 2 ! ∂ 2 u ∂ x j 2 ( x i 1 , … , i n ) + ( h j ) 3 3 ! ∂ 3 u ∂ x j 3 ( x i 1 , … , i n ) + ( h j ) 4 4 ! ∂ 4 u ∂ x j 4 ( x i 1 , … , i n + ( ϱ j 1 - x j i j ) e j )

and

u ( x i 1 , … , i n - h j e j ) = u ( x i 1 , … , i n ) - h j ∂ u ∂ x j ( x i 1 , … , i n ) + ( h j ) 2 2 ! ∂ 2 u ∂ x j 2 ( x i 1 , … , i n ) - ( h j ) 3 3 ! ∂ 3 u ∂ x j 3 ( x i 1 , … , i n ) + ( h j ) 4 4 ! ∂ 4 u ∂ x j 4 ( x i 1 , … , i n + ( ϱ j 2 - x j i j ) e j ) ,

where ρj1∈xjij,xjij+hj and ρj2∈xjij-hj,xjij, with j = 1, . . . , n.

By replacing these expansions into (3.1), simplifying the similar terms and using the fact that the function u satisfies the equation (1.1) at the point xi1,…,in, we get

τ i 1 , … , i n = 1 4 ! ∑ j = 1 n ( h j ) 2 ∂ 4 u ∂ x j 4 ( x i 1 , … , i n + ( ϱ j 1 - x j i j ) e j ) + 1 4 ! ∑ j = 1 n ( h j ) 2 ∂ 4 u ∂ x j 4 ( x i 1 , … , i n + ( ϱ j 2 - x j i j ) e j ) . (3.2)

Since the fourth-order partial derivatives are limited, it follows from (3.2) that

| τ i 1 , … , i n | ≤ C ∑ j = 1 n h j 2 ,

for some positive constant C, independent of h j , with j = 1, . . . , n.

Thus, we conclude that the method is of second order. This completes the proof. □

Definition 3.2. The global error, denoted by ei1,…,in, is defined as

e i 1 , … , i n = u ( x i 1 , … , i n ) - U i 1 , … , i n , (3.3)

where Ui1,…,in denotes the numerical solution of the Poisson problem calculated at the point xi1,…,in.

In the following theorem, we demonstrate that the numerical method is stable. For this, we use the Discrete Maximum Principle 25.

Theorem 3.1. (Discrete Maximum Principle) Consider V: Ωδ ∪ ∂Ωδ → ℝ a discrete function.

(i) If ∆δ V (x) ≥ 0, for all x ∈ Ωδ , then

max x ∈ Ω δ V ( x ) ≤ max x ∈ ∂ Ω δ V ( x ) .

(ii) If ∆δ V (x) ≤ 0, for all x ∈ Ωδ , then

min x ∈ Ω δ V ( x ) ≥ min x ∈ ∂ Ω δ V ( x ) .

Proof.

(i) Suppose the maximum of V does not occur on the boundary of Ωδ . This implies that there is P 0 ∈ Ωδ so that V (P 0) = M 0, with V (P) ≤ M 0, for all P ∈ Ωδ , and V (P) < M 0, for any P ∈ ∂ Ωδ . Now consider the points given by

P j 1 = P 0 + h j e j and P j 2 = P 0 - h j e j ,

where j = 1, . . . , n. Hence,

Δ δ V ( P 0 ) = ∑ j = 1 n ( h j ) - 2 [ V ( P j 1 ) + V ( P j 2 ) ] - 2 V ( P 0 ) ∑ j = 1 n ( h j ) - 2 .

As ∆δ V (P 0) ≥ 0, we conclude that

2 V ( P 0 ) ∑ j = 1 n ( h j ) - 2 ≤ ∑ j = 1 n ( h j ) - 2 [ V ( P j 1 ) + V ( P j 2 ) ] .

Consequently,

M 0 ≤ ∑ j = 1 n ( h j ) - 2 - 1 ∑ j = 1 n ( h j ) - 2 V ( P j 1 ) + V ( P j 2 ) 2 .

Since V(Q) ≤ M 0, for all Q ∈ Ωδ ∪ ∂Ωδ , we conclude that V(Pj1)=M0 and V(Pj2)=M0, for all j = 1, . . . , n. In fact, suppose V(Pj1)<M0 or V(Pj2)<M0, for some j = 1, . . . , n. It follows from (3.4) that

M 0 < ∑ j = 1 n ( h j ) - 2 - 1 ∑ j = 1 n ( h j ) - 2 M 0 + M 0 2 = M 0 .

Which is absurd. Therefore, V(Pj1)=M0 and V(Pj2)=M0, for all j = 1, . . . , n.

This argument is repeated for each of the interior points Pj1 and Pj2 instead of P 0. By repetition, each point of Ωδ ∪ ∂Ωδ appears as one of Pj1 and Pj2, for some corresponding P 0.

Thus, we conclude that

V ( P ) = M 0 , for all P ∈ Ω δ ∪ ∂ Ω δ .

But this contradicts the fact that V(P) < M 0, for all P ∈ ∂ Ωδ . Thus, the item (i) is established.

(ii) Firstly, note that

m a x - V ( x ) = - m i n V ( x ) and Δ δ - V = - Δ δ V .

Suppose ∆δ V(x) ≤ 0, for all x ∈ Ωδ . So,

Δ δ ( - V ( x ) ) ≥ 0 ,

for all x ∈ Ωδ . By the item (i),

max x ∈ Ω δ - V ( x ) ≤ max x ∈ ∂ Ω δ - V ( x )

and consequently,

min x ∈ Ω δ V ( x ) ≥ min x ∈ ∂ Ω δ V ( x ) .

Which completes the proof. □

The next theorem gives us a bound for the solution of the equation (2.2).

Theorem 3.2. (A Priori estimate)Consider V: Ωδ ∪ ∂Ωδ → ℝ a discrete function. Then,

max x ∈ Ω δ | V ( x ) | ≤ max x ∈ ∂ Ω δ | V ( x ) | + r 1 2 + s 1 2 2 max x ∈ Ω δ | Δ δ V ( x ) | . (3.5)

Proof. Consider ψ : Ωδ ∪ ∂Ωδ → ℝ a discrete function defined by ψ(x)=12x12, for all x = (x 1, . . . , x n ) ∈ Ωδ ∪ ∂Ωδ. Note that, for all x ∈ Ωδ ∪ ∂Ωδ,

0 ≤ ψ ( x ) ≤ r 1 2 + s 1 2 2 a n d Δ δ ψ ( x ) = 1 .

Consider V+: Ωδ ∪ ∂Ωδ → ℝ and V−: Ωδ ∪ ∂Ωδ → ℝ two discrete functions defined by

V + ( x ) = V ( x ) + N 0 ψ ( x ) a n d V - ( x ) = - V ( x ) + N 0 ψ ( x ) ,

where

N 0 = max x ∈ Ω δ | Δ δ V ( x ) | .

So, for every x ∈ Ωδ, we have that ∆δ V +(x) = ∆δ V(x) + N 0 ≥ 0 and ∆δ V −(x) = −∆δ V(x) + N 0 ≥ 0.

By applying the item (i) of the Theorem 3.1 to V +, we get

V ( x ) ≤ max x ∈ Ω δ V + ( x ) ≤ max x ∈ ∂ Ω δ [ V ( x ) + N 0 ψ ( x ) ] ≤ max x ∈ ∂ Ω δ V ( x ) + N 0 r 1 2 + s 1 2 2 ≤ max x ∈ ∂ Ω δ | V ( x ) | + r 1 2 + s 1 2 2 max x ∈ Ω δ | Δ δ V ( x ) | , (3.6)

for all x ∈ Ωδ.

Using the Theorem 3.1, item (i), again, we deduce that

- V ( x ) ≤ max x ∈ ∂ Ω δ | V ( x ) | + r 1 2 + s 1 2 2 max x ∈ Ω δ | Δ δ V ( x ) | , (3.7)

for all x ∈ Ωδ. As a consequence of (3.6) and (3.7), we get (3.5). □

Note 3.1. In the proof of Theorem 3.2, we can replace r12+s122 in (3.5) for rj2+sj22 with j = 2, . . . , n, as long as we use one of the discrete functions ψj , defined by ψj(x)=xj22, for x = (x 1, . . . , x n ), in place of ψ.

Now, let’s get an estimate for the global error. Then, consider the discrete function ei1,…,in defined in (3.3). By the Theorem 3.2 , we deduce that

| e i 1 , … , i n | ≤ max ∂ Ω δ | e i 1 , … , i n | + r 1 2 + s 1 2 2 max Ω δ | Δ δ e i 1 , … , i n | .

Once we have, by the equation (2.3),

e i 1 , … , i n = u ( x i 1 , … , i n ) - g ( x i 1 , … , i n ) = 0

over the boundary of Ωδ, we get

| e i 1 , … , i n | ≤ r 1 2 + s 1 2 2 max Ω δ | Δ δ e i 1 , … , i n | . (3.8)

From (2.2) and (3.1), we conclude that

Δ δ e i 1 , … , i n = Δ δ u ( x i 1 , … , i n ) - Δ δ U i 1 , … , i n = Δ δ u ( x i 1 , … , i n ) + f ( x i 1 , … , i n ) = τ i 1 , … , i n .

Using this, (3.8) and the Lemma 3.1, we have that

| e i 1 , … , i n | ≤ C ∑ j = 1 n h j 2 , (3.9)

for some positive constant C, independent of h j , with j = 1, . . . , n.

Note 3.2. We conclude, from Lemma 3.1 and from (3.9), that the numerical method is convergent.

The next result establishes the uniqueness of the solution of the system AU = B and is a consequence of the Discrete Maximum Principle.

Corollary 3.1. The resulting system of linear equations AU = B has a unique solution.

Proof. It is sufficient to show that the only solution of the homogeneous linear system AU = 0 is the trivial solution. For this, consider the homogeneous problem

- Δ u = 0 , in Ω , u = 0 , on ∂ Ω . (3.10)

The function u = 0 is the only solution to the above problem. Discretizing the problem (3.10), we obtain a homogeneous linear system for the unknowns Ui1,…,in. Since Ui1,…,in is a solution of the difference equation (2.2), with f = 0, we conclude that

Δ δ U i 1 , … , i n = 0 in Ω δ and U i 1 , … , i n = 0 on ∂ Ω δ .

By theorem 3.1, item (i), we have

max Ω δ U i 1 , … , i n ≤ max ∂ Ω δ U i 1 , … , i n = 0 .

Applying again the Theorem 3.1, item (ii), we obtain

min Ω δ U i 1 , … , i n ≥ min ∂ Ω δ U i 1 , … , i n = 0 .

Thus, Ui1,…,in=0 in Ωδ. Therefore, U = 0 is the only solution for the linear system AU = 0 and the proof of the corollary is complete. □

In the next section the numerical method, given by the equations (2.2) and (2.3), will be implemented computationally.

4 COMPUTER IMPLEMENTATION

We consider the function u with domain [r 1 , s 1] × · · · × [r n , s n ] ⊂ ℝn and the discrete sample of (M 1 + 1) · (M 2 + 1) · . . . · (M n + 1) domain points. Along each axis x j , for j = 1, . . . , n, uniform sampling of points defines segments of length

d x j = s j - r j M j .

Initially, we build a multidimensional matrix G with the dimension (M 1 + 1)· (M 2 + 1)·...· (M n + 1), whose elements must be images from the function u, known on the domain boundary, that is,

G [ i 1 , i 2 , … , i n ] = u ( r 1 + i 1 d x 1 , r 2 + i 2 d x 2 , … , r n + i n d x n ) .

Note that only the values of u on the domain boundary are known, that is, we know G[i 1 , i 2 , . . . , i n ] only when i j = 0 or i j = M j , for some j ∈ {1, 2, . . . , n}. Within the domain, when 0 < i j < M j for all j, the values G[i 1 , i 2 , . . . , i n ] are unknown.

The next step is the construction of a multidimensional matrix F with dimension (M 1 + 1)· (M 2 + 1) · . . . · (M n + 1), whose elements must be values of the Laplacian ∆u, that is,

F [ i 1 , i 2 , … , i n ] = Δ u ( r 1 + i 1 d x 1 , r 2 + i 2 d x 2 , … , r n + i n d x n ) .

In this case, only the values of ∆u in the domain interior are known, that is, we know F[i 1 , i 2 , . . . , i n ] only when 0 < i j < M j , for all j ∈ {1, 2, . . . , n}.

Finally, each known element of matrix F is related to unknown elements of matrix G by the equation,

F [ i 1 , . . . , i n ] = ∑ j = 1 n b j G [ i 1 , . . . , i j - 1 , . . . , i n ] + b j G [ i 1 , . . . , i j + 1 , . . . , i n ] + a G [ i 1 , i 2 , . . . , i n ] , (4.1)

where a=-2∑j=1n1dxj2 and bj=1dxj2, for j = 1, ..., n.

The same equation (4.1) can be rewritten considering all the elements of the matrix G, in order to obtain an equation with (M 1 − 1)...(M n − 1) unknowns, given by

F [ i 1 , . . . , i n ] = ∑ l 1 = 1 M 1 - 1 . . . ∑ l n = 1 M n - 1 α ( l 1 , . . . , l n ) G [ l 1 , . . . , l n ] , (4.2)

with i j = 1, . . . , M j − 1 and j = 1, . . . , n, where the coefficients α(l 1 , ..., l n ) are null, except for the following cases:

α ( i 1 , i 2 , . . . , i n ) = a ; α ( i 1 , . . . , i j - 1 , . . . , i n ) = b j ; α ( i 1 , . . . , i j + 1 , . . . , i n ) = b j . (4.3)

To construct a system of linear equations, the unknowns G[i 1 , i 2 , . . . , i n ] are enumerated by an index function

I : { 1 , … , M 1 - 1 } × { 1 , … , M 2 - 1 } × . . . × { 1 , … , M n - 1 } → ℕ

defined by

I ( i 1 , … , i n ) = ( i 1 - 1 ) + ( M 1 - 1 ) ( i 2 - 1 ) + ( M 1 - 1 ) ( M 2 - 1 ) ( i 3 - 1 ) + … + ( M 1 - 1 ) ( M 2 - 1 ) … ( M n - 1 - 1 ) ( i n - 1 ) . (4.4)

Thus, we have (M 1 − 1) . . . (M n − 1) equations, with the same number of unknowns, determining a linear system AU = B, whose solution vector U provides the searched unknowns, that is,

G [ i 1 , i 2 , . . . , i n ] = U [ I ( i 1 , i 2 , . . . , i n ) ] . (4.5)

The matrix A is a sparse matrix with null elements, except for:

A [ I ( i 1 , i 2 , . . . , i n ) , I ( i 1 , i 2 , . . . , i n ) ] = a ; A [ I ( i 1 , i 2 , . . . , i n ) , I ( i 1 , . . . , i j - 1 , . . . , i n ) ] = b j if i j > 1 and A [ I ( i 1 , i 2 , . . . , i n ) , I ( i 1 , . . . , i j + 1 , . . . , i n ) ] = b j if i j < M j - 1 , for j = 1 , . . . , n . (4.6)

Note that the index I(i 1 , . . . , i n ) indicates that the coefficient α(i 1 , i 2 , ..., i n ) = a of the equation (4.2) associated with the unknown G[i 1 , . . . , i n ] will appear in the line I(i 1 , . . . , i n ) and column I(i 1 , . . . , i n ) of the matrix A. The indices I(i 1 , . . . , i j − 1, . . . , i n ) and I(i 1 , . . . , i j + 1, . . . , i n ) indicate that the coefficients α(i 1 , . . . , i j −1,..., i n ) = b j and α(i 1 , . . . , i j +1,..., i n ) = b j , j = 1, . . . , n, will appear in the line I(i 1 , . . . , i n ) and columns I(i 1 , . . . , i j − 1, . . . , i n ) and I(i 1 , . . . , i j + 1, . . . , i n ) of the matrix A, respectively. In the other positions of the line I(i 1 , . . . , i n ) the coefficients α(l 1 , ..., l n ) of the equation (4.2) are all null. Figure 1 illustrates the final position of each element in matrix A, for the case n = 3.

Figure 1:
Illustration of the coefficient matrix of the system AU = B with indication of the diagonals corresponding to the coefficients a, b 1 , b 2 , b 3.

Now, notice that the vector B, which has (M 1 − 1) . . . (M n − 1) independent terms, is not given just by values of the Laplacian F[i 1 , i 2 , . . . , i n ], but known boundary values G[i 1 , i 2 , . . . , i n ], for i j = 0 or i j = M j , are incorporated into the independent terms as follows:

B [ I ( i 1 , i 2 , … , i n ) ] = F [ i 1 , i 2 , … , i n ] - ∑ j = 1 n s j G [ i 1 , … , i j - 1 , … , i n ] - ∑ j = 1 n t j G [ i 1 , … , i j + 1 , … , i n ] ,

where the coefficients s j and t j , for j = 1, . . . , n, are all null, except in the cases:

s j = b j if i j = 1 ; t j = b j if i j = M j - 1 .

Using the implementation details above, below is a code example, in Python, for solving the following Problem in ℝ3:

Δ u = 12 x 2 + 12 y 2 + 12 z 2 , in Ω , u = x 4 + y 4 + z 4 , on ∂ Ω ,

where Ω = (−1,1)×(−1,1)×(−1,1).

5 EXPERIMENTS

In this section, we present numerical experiments to evaluate the effectiveness of the proposed method. To illustrate the implementation and computational performance, we consider a set of test cases. In each case, the integration domain is a rectangular block discretized using a uniform mesh. The tables below display the average error, (e), calculated according to the following formula:

e = ∑ i 1 = 0 M 1 ∑ i 2 = 0 M 2 … ∑ i n = 0 M n G ( i 1 , … , i n ) - u ( r 1 + i 1 d x 1 , … , r n + i n d x n ) M 1 + 1 . M 2 + 1 … M n + 1 , (5.1)

where G is the approximate solution by the method and u is the exact solution.

We also show the evolution of the error in the numerical solution, for each problem, as the resolution of the considered mesh increases. The solution for the linear system AU = B was obtained using spsolve package for sparse matrix in Python. The numerical solution for the examples 1 and 2, considered next, is obtained using the procedure in the section 4.

Example 1. Consider the following problem in ℝ2

Δ u = - s i n ( x ) - s i n ( y ) , in Ω , u = s i n ( x ) + s i n ( y ) , on ∂ Ω ,

where Ω = (−π, π) × (−π, π). The exact solution to this problem is given by u(x, y) = sin(x) + sin(y).

In Table 1 we present values of the average error, given by the formula (5.1), for some resolutions M × M of the mesh, with M = 4, 8, 16, 32, 64, 128, 256, 512, 1024. In this table one can observe the convergence of the error. The curve fitting for this data indicates that the convergence is approximately of order O(1.978), which is close to quadratic, as expected.

Table 1:
Error in the solution of the problem Example 1, for some resolutions.

Example 2. Consider the following problem in ℝ3

Δ u = 12 x 2 + 12 y 2 + 12 z 2 , in Ω , u = x 4 + y 4 + z 4 , on ∂ Ω ,

where Ω = (−1, 1) × (−1, 1) × (−1, 1).

In this case, with the domain in ℝ3, the resolution M ×M ×M leads to the sampling of M 3 points from the domain. Due to the limitation of memory allocation capacity, we only considered up to resolution 50 × 50 × 50, but it is already possible to notice the convergence (Table 2). For this data, the convergence order is approximately O(1.915), which is also close to quadratic, as expected. Note that in this case the matrix A, from the system AU = B, has 493 = 117, 649 rows and columns.

Table 2:
Error in the solution of the problem Example 2, for some resolutions.

Figure 1 illustrates the matrix A of the system AU = B for the mesh with resolution 5 × 5 × 5. In this case A has 43 = 64 rows and columns. The diagonals corresponding to the coefficients a, b 1 , b 2 , b 3 are indicated in the figure, as automatically defined in Equation 4.6.

Numerical experiments confirm the consistency and stability of the method, ie, the convergence of the numerical solution to the exact solution of the problem while the mesh is refined as demonstrated in the section 3. The code in Python presented in the section 4 uses the index function to solve the problem of Example 2, in the dimension n = 3, and can be modified to consider larger dimensions, as detailed in the same Section.

6 CONCLUSIONS

This article presents the numerical solution for the n-dimensional Poisson problem, for all n ≥ 1. We propose a new approach based on an index function that plays a central role in obtaining the numerical solution, as it facilitates generalization and supports computational implementation in any dimension. The index function simplifies the construction of both the coefficient matrix and the right-hand side vector of the sparse linear system that arises in the modeling process. Moreover, this function can be easily adapted, since the access path to array elements is not unique and depends on the chosen enumeration, without affecting the final solution. This concept can be extended to obtain numerical solutions for other elliptic problems.

As future work, we intend to investigate how the use of the index function can be adapted and extended to more complex scenarios, including problems with irregular boundaries and nonlinear Poisson-type equations.

Acknowledgments

The authors are grateful to the support of Unimontes and IFNMG.

REFERENCES

  • 1 B.M. Averick & J.M. Ortega. Fast solution of nonlinear Poisson-type equations. SIAM Journal on Scientific Computing, 14(1) (1993), 44-48.
  • 2 K. Balakrishnan & P.A. Ramachandran. A particular solution Trefftz method for non-linear Poisson problems in heat and mass transfer. Journal of Computational Physics, 150(1) (1999), 239-267.
  • 3 K. Balakrishnan & P.A. Ramachandran. Osculatory interpolation in the method of fundamental solution for nonlinear Poisson problems. Journal of Computational Physics , 172(1) (2001), 1-18.
  • 4 R.F. Boisvert. Families of high order accurate discretizations of some elliptic problems. SIAM Journal on Scientific and Statistical Computing, 2(3) (1981), 268-284.
  • 5 W.R. Bowen & P.M. Williams. Finite difference solution of the 2-dimensional Poisson-Boltzmann equation for spheres in confined geometries. Colloids and Surfaces A: Physicochemical and Engineering Aspects, 204(1-3) (2002), 103-115.
  • 6 J.A. Cuminato & M.M. Junior. “Discretização de equações diferenciais parciais: técnicas de diferenças finitas”. SBM, Rio de Janeiro, 1 ed. (2013).
  • 7 L.P. da Silva, M.A.V. Pinto & L.K. Araki. Higher-order methods for the Poisson equation obtained with geometric multigrid and completed Richardson extrapolation. Computational and Applied Mathematics, 43(7) (2024), 395.
  • 8 L.P. da Silva, B.B. Rutyna, A.R. Santos Righi & M.A. Villela Pinto. High order of accuracy for Poisson equation obtained by grouping of repeated Richardson extrapolation with fourth order schemes. Computer Modeling in Engineering & Sciences, 128(2) (2021), 699-715.
  • 9 G.E. Fasshauer. Newton iteration with multiquadrics for the solution of nonlinear PDEs. Computers & Mathematics with Applications, 43(3-5) (2002), 423-438.
  • 10 J.H. Ferziger & M. Perić. “Computational methods for fluid dynamics”. Springer (2002).
  • 11 M.M. Gupta, R.P. Manohar & J.W. Stephenson. A single cell high order scheme for the convectiondiffusion equation with variable coefficients. International Journal for Numerical Methods in Fluids, 4(7) (1984), 641-651.
  • 12 G.M.A.M.L. Guta. Solution of Two Dimensional Poisson Equation Using Finite Difference Method with Uniform and Non-uniform Mesh Size. (2019).
  • 13 H. Johansen & P. Colella. A Cartesian grid embedded boundary method for Poisson’s equation on irregular domains. Journal of Computational Physics , 147(1) (1998), 60-85.
  • 14 J.J. Kasab, S.R. Karur & P. Ramachandran. Quasilinear boundary element method for nonlinear Poisson type problems. Engineering Analysis with Boundary Elements, 15(3) (1995), 277-282.
  • 15 L. Lapidus & G.F. Pinder. “Numerical solution of partial differential equations in science and engineering”. John Wiley & Sons (2011).
  • 16 Z. Li, C. Pao & Z. Qiao. A finite difference method and analysis for 2D nonlinear Poisson-Boltzmann equations. Journal of Scientific Computing, 30 (2007), 61-81.
  • 17 B. Mebrate, P.R. Koya et al. Numerical solution of a two dimensional poisson equation with dirichlet boundary conditions. American Journal of Applied Mathematics, 3(6) (2015), 297-304.
  • 18 H. Moghaderi, M. Dehghan & M. Hajarian. A fast and efficient two-grid method for solving d-dimensional poisson equations. Numerical Algorithms, 72 (2016), 483-537.
  • 19 F.M. Okoro & A.E. Owoloko. Compact finite difference schemes for Poisson equation using direct solver. Journal of Mathematics and Technology, ISSN, (2010), 2078-0257.
  • 20 P. Pandey. A higher accuracy exponential finite difference method for the numerical solution of second order elliptic partial differential equations. J. Math. Comput. Sci., 3(5) (2013), 1325-1334.
  • 21 J.B. Rosser. Nine-point difference solutions for Poisson’s equation. Computers & Mathematics with Applications , 1(3-4) (1975), 351-360.
  • 22 J.B. Rosser. Finite-difference solution of Poisson’s equation in rectangles of arbitrary proportions. Zeitschrift für angewandte Mathematik und Physik ZAMP, 28 (1977), 185-196.
  • 23 G.H. Shortley & R. Weller. The numerical solution of Laplace’s equation. Journal of Applied Physics, 9(5) (1938), 334-348.
  • 24 G.D. Smith. “Numerical solution of partial differential equations: finite difference methods”. Oxford university press (1985).
  • 25 J.C. Strikwerda. “Finite difference schemes and partial differential equations”. SIAM (2004).
  • 26 H. Wang, Q.H. Qin & X.P. Liang. Solving the nonlinear Poisson-type problems with F-Trefftz hybrid finite element model. Engineering Analysis with Boundary Elements , 36(1) (2012), 39-46.
  • 27 Y. Wang & J. Zhang. Sixth order compact scheme combined with multigrid method and extrapolation technique for 2D Poisson equation. Journal of Computational Physics , 228(1) (2009), 137-146.
  • 28 T. Zhu, J. Zhang & S.N. Atluri. A meshless local boundary integral equation (LBIE) method for solving nonlinear problems. Computational mechanics, 22(2) (1998), 174-186.

Data availability

Do not apply.

*

Corresponding author: Antonio Wilson Vieira - E-mail: antonio.vieira@unimontes.br

Associate editor:

Pedro Lima

Publication Dates

  • Publication in this collection
    28 July 2025
  • Date of issue
    2025

History

  • Received
    12 Apr 2022
  • Accepted
    05 June 2025
location_on
Sociedade Brasileira de Matemática Aplicada e Computacional - SBMAC Rua Maestro João Seppe, nº. 900, 16º. andar - Sala 163, Cep: 13561-120 - SP / São Carlos - Brasil, +55 (16) 3412-9752 - São Carlos - SP - Brazil
E-mail: sbmac@sbmac.org.br
rss_feed Acompanhe os números deste periódico no seu leitor de RSS
Ir para o topo Reportar erro