The Numerical Solution of Poisson Equation with Dirichlet Boundary Conditions

Abstract

This work mainly focuses on the numerical solution of the Poisson equation with the Dirichlet boundary conditions. Compared to the traditional 5-point finite difference method, the Chebyshev spectral method is applied. The numerical results show the Chebyshev spectral method has high accuracy and fast convergence; the more Chebyshev points are selected, the better the accuracy is. Finally, the error of two numerical results also verifies that the algorithm has high precision.

Share and Cite:

Guo, P. (2021) The Numerical Solution of Poisson Equation with Dirichlet Boundary Conditions. Journal of Applied Mathematics and Physics, 9, 3007-3018. doi: 10.4236/jamp.2021.912194.

1. Introduction

The Laplace equation u = 0 can be dated back to 1782 when the French mathematician P.S. Laplace discussed the problem of the gravitational field [1] [2]. About thirty years later, S.D. Poisson pointed out that if the density of gravitational field is considered, the Laplace equation should have a new form i.e. u = f , which we called Poisson equation. Now Poisson equation has been applied to modelling the temperature distribution of stable temperature field with a stable heat source or without internal heat source, the stable non-rotating flow of incompressible fluid in hydrodynamics, etc. In recent several years, some researchers find that the 2-dimensional Poisson equation with Dirichlet boundary condition is a good tool to cope with seamless image composite problems [3] [4] [5] [6] [7].

In the following part, we will focus on Poisson equation with the Dirichlet boundary condition [8].

{ u = f ( x , y ) ( x , y ) Ω u ( x , y ) = g ( x , y ) ( x , y ) Ω (1)

The above Equation (1) is the 2-dimensional Poisson equation, where u = 2 u x 2 + 2 u y 2 , g ( x , y ) is the boundary condition.

In general, the Poisson equation is hard to get the analytical solution, only a few can find the exact solution. Therefore, the numerical algorithm is a good way to deal with this problem. For the second-order parabolic type differential equation, the finite difference method is a popular discretization method. The precision of the traditional 5-point difference method is not good enough. In order to improve the accuracy, some scholars proposed a new method based on 5-point difference scheme, such as 9-point difference scheme. The error of the 9-point difference scheme is fourth-order. But if we want to continue to improve the accuracy of the algorithm based on the 9-point difference method, it will be very difficult. Compared to the finite difference method the spectral method has high accuracy and less computation. Especially for multidimensional problems, such as 2-dimensional or 3-dimensional Poisson equation if we use the finite difference method, we need to calculate so many nodes the amount of calculation is very large. In addition to the finite difference method and spectral method, the finite element method is also an effective method to deal with differential equations. For the in-depth discussion of these methods, we can refer to [8] - [23].

The spectral method is a well-developed algorithm, which has infinite order accuracy and exponential order convergence speed in theory [17] [18] [19]. In this work, we will use Chebyshev spectral method to find the numerical solution of 2-dimensional Poisson equation.

2. Preliminaries

Some basic contents including Chebyshev polynomials and Chebyshev points will be introduced in this part. The Chebyshev points will be used to construct the differentiation matrices, which is the key point to obtain high-precision solutions.

Definition 1. In the interval [ 1,1 ] , with the weight ω ( x ) = 1 1 x 2 , the polynomials with the following relations are called Chebyshev polynomials [20].

{ T 0 ( x ) = 1 , T 1 ( x ) = x , T n + 1 ( x ) = 2 x T n ( x ) T n 1 ( x ) , n 1. (2)

where T n ( x ) , n 0 are the Chebyshev polynomials.

A big difference between Chebyshev polynomials and other polynomials is that Chebyshev polynomials have an explicit relation, i.e. T n ( x ) = cos ( n arccos ( x ) ) . The zeros of Chebyshev polynomials x k = cos k π n , n = 0 , 1 , , n are called Chebyshev points. These Chebyshev points are highly clustered on both sides of the interval. This feature of the Chebyshev points can help one overcome Runge phenomenon in interpolation. The Chebyshev polynomials satisfy the following orthogonal properties with weight 1 1 x 2

Property 1

1 1 1 1 x 2 T m ( x ) T n ( x ) d x = { 0 , m n , π 2 , m = n = 0 , π , m = n 0. (3)

First-order derivative of Chebyshev polynomials T n ( x ) and the original Chebyshev polynomials T n ( x ) satisfy the following relations.

Property 2

{ T 0 ( x ) = T 1 ( x ) , T 1 ( x ) = 1 4 T 2 ( x ) , T n ( x ) = 1 2 ( n + 1 ) T n + 1 ( x ) 1 2 ( n 1 ) T n 1 ( x ) , n 2. (4)

There are some other polynomials such as Legendre polynomials, Jacobi polynomials, etc. For a more detailed discussion about the properties of Chebyshev and other polynomials, one can refer to [17] [19].

3. Numerical Algorithms for 2-Dimensional Poisson Equation

In this part, we will show two different schemes to solve the 2-dimensional Poisson equation. The finite difference method with five points will be applied first, then the Chebyshev spectral method will be considered. The 2-dimensional Poisson equation we will discuss is as follows,

{ ( 2 u x 2 + 2 u y 2 ) = f ( x , y ) , ( x , y ) [ a , b ] × [ c , d ] u ( a , y ) = g 1 ( y ) , u ( b , y ) = g 2 ( y ) , u ( x , c ) = g 3 ( x ) , u ( x , d ) = g 4 ( x ) . (5)

1) 5-point finite difference method

First, we will give a discretization in x and y directions. In x direction we choose N 1 + 1 points and give an equidistant discretization, that is h 1 = b a N 1 . Then the points in the interval [ a , b ] can be expressed as x i = a + i h 1 , where i = 0 , 1 , 2 , , N 1 . Similarly, in y direction, the points in [ c , d ] can be expressed as y j = a + j h 2 , j = 0 , 1 , 2 , , N 2 , where h 2 = d c N 2 .

Both in x and y directions we use the central difference method respectively, as shown in Figure 1, we have

Figure 1. 5-point finite difference method.

( 2 u x 2 ) ( x i , y j ) = u i + 1 , j + u i 1 , j 2 u i , j h 1 2 + O ( h 1 2 ) , (6)

( 2 u y 2 ) ( x i , y j ) = u i , j + 1 + u i , j 1 2 u i , j h 2 2 + O ( h 2 2 ) . (7)

If we choose the same step size, i.e. h 1 = h 2 = h , then for the problem we have the following algorithm,

u i + 1 , j + u i 1 , j + u i , j + 1 + u i , j 1 4 u i , j h 2 = f i , j , (8)

where the corresponding truncation error is O ( h 1 2 + h 2 2 ) , if h 1 = h 2 = h , the truncation error can be written as O ( h 2 ) .

The size of the nodes on grids is ( N 1 + 1 ) × ( N 2 + 1 ) . Considering that the boundary values are known, we arrange the remaining nodes in columns to form a new column vector. Let’s U = ( u 1 , 1 , u 2 , 1 , , u N 1 1 , 1 , , u N 1 1 , N 2 1 ) T , the 2-dimensional Poisson equation can be written in a matrix form A U = F , where A N 1 1, N 2 1 is the coefficient matrix, F is a matrix on the right-hand side of the relation (8). The detailed expression of the coefficient matrix A is as follows,

A = h 2 ( B I I B I I B I I B ) , (9)

where B N 1 1, N 1 1 has the following expression,

B = ( 4 1 1 4 1 1 4 1 1 4 ) . (10)

2) Chebyshev spectral method

The Chebyshev points are x k = cos k π n , n = 0 , 1 , , n . Obviously, all the Chebyshev points are in the interval [ 1,1 ] . Before we use the Chebyshev spectral method, we should map the interval [ 1,1 ] into the interval [ a , b ] with the following transformation,

x = b + a 2 + b a 2 x k . (11)

Similarly, for y [ c , d ] , if we use the transformation

y = d + c 2 + d c 2 x k , (12)

the interval [ 1,1 ] can also be mapped into [ c , d ] . The differentiation matrices D 1 for the interval [ 1,1 ] can be derived directly from the explicit expression of Chebyshev polynomials. But the expression of the first-order differentiation matrices is slightly different, i.e. D [ a , b ] 1 = b a 2 D 1 , D [ c , d ] 1 = d c 2 D 1 . For more detailed proofs or properties, one can refer to [17].

{ D 0 , 0 1 = D N , N 1 = 2 N 2 + 1 6 , D i , i 1 = x i 2 ( 1 x i 2 ) , i = 1 , 2 , , N 1 , D i , j 1 = c i ( 1 ) i + j c j ( x i x j ) , i j , i , j = 0 , 1 , , N , (13)

where

c i = { 2 , i = 0 , i = N 1 , otherwise . (14)

The second-order derivative can be computed easily by D 2 = ( D 1 ) 2 . If we arrange the matrixu in a column vector, 2 u x 2 can be writen in the matrix form ( D 2 I ) u , and 2 u y 2 can be written in the matrix form ( I D 2 ) u . Let’s L denote ( D 2 I + I D 2 ) , where is the Kronecker product. Then for the 2-dimensional Poisson equation, the Chebyshev spectral algorithm can be given as follows,

L U = F . (15)

where U and F are similar as given in 5-point difference method. The numerical results can be computed directly. Jie et al. have proved the error estimate for the Chebyshev spectral method with Dirichlet boundary conditions [17].

4. Numerical Examples

In this part, the proposed algorithm will be employed to solve 2-dimensional Poisson equation with Dirichlet boundary conditions.

Example 1. Consider the following 2-dimensional Poisson equation

{ ( 2 u x 2 + 2 u y 2 ) = e x y ( x 2 + y 2 ) , ( x , y ) [ 0 , 1 ] × [ 0 , 1 ] , u ( x , 0 ) = 1 , 0 x 1 u ( x , 1 ) = e x , 0 x 1 u ( 0 , y ) = 1 , 0 y 1 u ( 1 , y ) = e y , 0 y 1 (16)

where the exact solution is u ( x , y ) = e x y .

Figure 2 shows the numerical solution of Example 1 with five points finite difference method. Figure 3 shows the absolute error at different points in the interval [ 0,1 ] × [ 0,1 ] . The biggest error is about 8.5 × 10−6. Table 1 is the detailed error when x and y take different values.

Table 2 shows the absolute error when x and y take different values. The biggest absolute error is 3.7 × 10−8. From the absolute error tables obtained by the two methods, we find that the accuracy of the spectral method is better than that of the finite difference method. The more the Chebyshev points we use, the higher accuracy of the numerical results we get. Theoretically, if we use enough Chebyshev points, we can obtain the numerical solutions with arbitrary accuracy.

Figure 4 is the numerical solution that we get with the Chebyshev spectral method. Figure 4 is very similar to Figure 2, but from the above two error tables, we find that the solution obtained by the spectral method is more consistent with the exact solution.

Figure 2. The numerical solution with finite difference method.

Figure 3. The absolute error with finite difference method.

Table 1. The errors of Example 1 with finite difference method.

Table 2. The errors of Example 1 with spectral method.

Figure 4. The numerical solution with Chebyshev spectral method.

Figure 5 is the error of the solution obtained by the Chebyshev spectral method. From this figure, we can see that the overall error of the solution obtained by the Chebyshev spectrum method is relatively small compared with the difference method.

Example 2. Consider the following 2-dimensional Laplace equation,

{ 2 u x 2 + 2 u y 2 = 0 , ( x , y ) [ 0 , 1 ] × [ 0 , 1 ] , u ( x , 0 ) = sin π x , 0 x 1 u ( x , 1 ) = e x sin π x , 0 x 1 u ( 0 , y ) = 0 , 0 y 1 u ( 1 , y ) = 0 , 0 y 1 (17)

where the exact solution is u ( x , y ) = e π y sin π x .

Figure 6 and Figure 7 show the absolute error of example 2 with finite difference method and Chebyshev spectral method respectively. When we choose the nodes n x = n y = 51 in x and y directions, for the finite difference method the maximum error is 1.16 × 10−4 as shown in Figure 6. For the same example, if we use spectral method with 51 × 51 Chebyshev points in the interval [ 0,1 ] × [ 0,1 ] , the maximum error is 2.33 × 10−7 as shown in Figure 7. From the absolute error of example 2, we find that the accuracy of spectral method is much higher than that of finite difference method.

Figure 5. The absolute error of Chebyshev spectral method.

Figure 6. The absolute error with finite difference method.

The second example is the Laplace equation which is a special case of Poisson equation. Table 3 shows the absolute error of example with finite difference method and Chebyshev spectral method. E r r o r f represents the maximum absolute error with finite difference method and E r r o r s represents the maximum absolute error with Chebyshev spectral method. We select the same number of nodes, i.e. n x = n y = 10 , 30 , 50 , 70 , 90 , and then compare the absolute errors

Figure 7. The absolute error with Chebyshev spectral method.

Table 3. The errors of Example 2.

of the two methods. From Table 3, we can clearly find that the accuracy of spectral method is better than that of finite difference method.

5. Conclusion

In this work, we study the 2-dimensional Poisson equation with Dirichlet boundary conditions. We use the five-point difference method and Chebyshev spectral method to solve the corresponding two-dimensional Poisson equation. For each method, we give the corresponding numerical algorithm. Finally, we give the numerical solution of the corresponding algorithm through a numerical case. We also obtain the absolute error respectively. The absolute error of two methods reveals that the accuracy of the spectral method is better than that of the difference method.

Acknowledgements

This research was funded by the Humanity and Social Science Youth Foundation of Ministry of Education (No. 18YJC630120), the Applied Mathematics of Shanghai DianJi University (No. 16JCXK02) and the Key Projects of Shanghai Soft Science Research Program (No. 18692106600).

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Abramowitz, M. and Stegun, I.A. (1972) Handbook of Mathematical Functions. Dover, New York.
[2] Wang, Z.X. and Guo, D.R. (1982) Special Functions. World Scientific Press, Singapore.
[3] Hao, W. and Dan, X. (2009) Improved Poisson Image Editing and Its Implementation on GPU. 2009 IEEE 10th International Conference on Computer-Aided Industrial Design & Conceptual Design, Wenzhou, 26-29 November 2009, 1044-1048.
https://doi.org/10.1109/CAIDCD.2009.5375343
[4] Morel, J.M., Petro, A.B. and Sbert, C. (2012) Fourier Implementation of Poisson Image Editing. Pattern Recognition Letters, 33, 342-348.
https://doi.org/10.1016/j.patrec.2011.10.010
[5] Martino, J.M.D., Facciolo, G. and Meinhardt-Llopis, E. (2016) Poisson Image Editing. Image Processing On Line, 5, 300-325.
https://doi.org/10.5201/ipol.2016.163
[6] Tian, C., Li, H. and Gao, X. (2018) Photo-Realistic 2D Expression Transfer Based on FFT and Modified Poisson Image Editing. Neurocomputing, 309, 1-10.
https://doi.org/10.1016/j.neucom.2018.03.045
[7] Kruse, A.W., Alenin, A.S. and Tyo, S. (2020) Contrast-Based Phase Angle of Polarization Image Construction Using Poisson Image Editing. Conference: Computational Optical Sensing and Imaging, Washington DC, 22-26 June 2020, CTh4C.5.
https://doi.org/10.1364/COSI.2020.CTh4C.5
[8] Sauer, T. (2012) Numerical Analysis. 2nd Edition, Addison Wesley Longman, Boston.
[9] Dou, M.Y., Li, H.Y. and Liu, X.W. (2017) An Inertial Proximal Peaceman-Rachford Splitting Method. Scientia Sinica: Mathematica, 47, 333-348.
https://doi.org/10.1360/N012016-00134
[10] Sweilam, N.H., Moharram, H.M. and Ahmed, S. (2012) On the Parallel Iterative Finite Difference Algorithm for 2-D Poisson equation with MPI Cluster. International Conference on Informatics & Systems IEEE, Giza, 14-16 May 2012, MM-78-MM-85.
[11] Yang, F. and Fu, C.L. (2010) The Inverse Problem of the Identification of the Heat Source for the Poisson equation. Acta Mathematica Scientia, 30, 1080-1087.
[12] Barnett, A., Wu, B. and Veerapaneni, S. (2015) Spectrally Accurate Quadratures for Evaluation of Layer Potentials Close to the Boundary for the 2D Stokes and Laplace Equations. SIAM Journal on Scientific Computing, 37, 519-542.
https://doi.org/10.1137/140990826
[13] Heinrich, B. (1996) The Fourier-Finite-Element Method for Poisson equation in Axisymmetric Domains with Edges. SIAM Journal on Numerical Analysis, 33, 1885-1911.
https://doi.org/10.1137/S0036142994266108
[14] Nkemzi, B. and Jung, M. (2020) The Fourier-Finite-Element Method for Poisson equation in Three-Dimensional Axisymmetric Domains with Edges: Computing the Edge Flux Intensity Functions. Journal of Numerical Mathematics, 28, 75-98.
https://doi.org/10.1515/jnma-2019-0002
[15] Febrianto, E., Ortiz, M. and Cirak, F. (2021) Mollified Finite Element Approximants of Arbitrary Order and Smoothness. Computer Methods in Applied Mechanics and Engineering, 373, Article ID: 113513.
https://doi.org/10.1016/j.cma.2020.113513
[16] Et., A. (2021) A New Finite Element Method Using Matlab for Poisson Equation in Axisymmetric Domain. Turkish Journal of Computer and Mathematics Education, 12, 671-678.
https://doi.org/10.17762/turcomat.v12i1S.1963
[17] Jie, S. and Tao, T. (2006) Spectral and High-Order Methods with Applications. Science Press, Beijing.
[18] Jie, S., Tao, T. and Wang, L.L. (2011) Spectral Methods: Algorithms, Analysis and Applications. Springer-Verlag, Berlin.
[19] Boyd, J.P. (2001) Chebyshev and Fourier Spectral Methods. Dover, New York.
[20] Trefethen, L.N. (2000) Spectral Methods in MATLAB. SIAM, Philadelphia.
https://doi.org/10.1137/1.9780898719598
[21] Kosloff, D. (2012) Solution of the Equations of Dynamic Elasticity by a Chebychev Spectral Method. Geophysics, 55, Article No. 734.
https://doi.org/10.1190/1.1442885
[22] Long, Y. and Zeng, B. (2021) Sign-Changing Solutions for Discrete Dirichlet Boundary Value Problem. Journal of Applied Mathematics and Physics, 5, 2228-2243.
https://doi.org/10.4236/jamp.2017.511182
[23] Mangoubi, J., Moukoko, D., Moukamba, F., et al. (2016) Existence and Uniqueness of Solution for Cahn-Hilliard Hyperbolic Phase-Field System with Dirichlet Boundary Condition and Regular Potentials. Applied Mathematics, 7, 1919-1926.
https://doi.org/10.4236/am.2016.716157

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.