EUROPEAN JOURNAL OF PURE AND APPLIED MATHEMATICS 2025, Vol. 18, Issue 2, Article Number 5895 ISSN 1307-5543 – ejpam.com Published by New York Business Global A Comparative Study of Finite Difference and Galerkin Finite Element Methods for Solving Boundary Value Problems Shahad Saleh Ayad Almutairi1, Abdulkafi Mohammed Saeed1,∗ 1 Department of Mathematics, College of Science, Qassim University, Buraydah, Kingdom of Saudi Arabia Abstract. Many applications in engineering cannot be solved analytically, major difficulty in the study of partial differential equations is that it is often impossible to obtain analytical solutions. Therefore, various numerical methods for solving partial differential equations have been proposed by related researchers, such as the finite difference method (FDM), finite element method (FEM), finite volume method (FVM), etc. The earliest is the FDM,which approximates the differential equations by using a local Taylor expansion. The finite element method (FEM) is a numerical technique for solving problems which are described by partial differential equations or can be formulated as functional minimization. A domain of interest is represented as an assembly of finite elements.This paper presents a qualitative comparative study of FDM and Galerkin finite element method (GFEM) to show the advantages and disadvantages of these methods in solving boundary value problems. Several numerical experiments conducted for comparisons purpose. The results reveal that the GFEM is an alternative method for solving several types of boundary value problems. 2020 Mathematics Subject Classifications: 76S05, 76D10, 80A32, 35Q79 Key Words and Phrases: Boundary value problem, Finite difference method, Galerkin Finite element method, Poisson’s equation 1. Introduction There are several applications of Poisson’s equation in both engineering and physics. It is employed to resolve issues in fluid dynamics, quantum mechanics, electrostatics, and magnetostatics. Poisson’s equation connects the electric potential to the charge distribu- tion in electrostatics. It connects the magnetic potential to the current distribution in magnetostatics. For scientists and engineers investigating the behavior of physical sys- tems, the equation is a crucial tool [1–3]. ∗Corresponding author. DOI: https://doi.org/10.29020/nybg.ejpam.v18i2.5895 Email address: 441212396@qu.edu.sa (S. S. Almutairi), abdulkafi.ahmed@qu.edu.sa (A. M. Saeed) https://www.ejpam.com 1 Copyright: © 2025 The Author(s). (CC BY-NC 4.0) S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 2 of 10 The complexity of many differential equations that arise in applications makes it occasion- ally impracticable to have solution formulae; if one is available, it may include integrals that can only be computed via a numerical quadrature formula. Numerical techniques offer a potent substitute tool for resolving differential equations under the specified ini- tial condition or conditions in either scenario. The finite difference method (FDM), finite element method (FEM), and finite volume method (FVM) are the three traditional op- tions for numerically solving PDEs. The earliest is the FDM, which approximates the differential equations by using a local Taylor expansion [1, 2]. The discretization of the PDE is constructed by the FDM using a topologically square network of lines. This might be a method’s bottleneck when working with intricate geometries in several dimensions . This difficulty encouraged the adoption of an integral form of the PDEs, followed by the development of the finite element and finite volume approaches [3–5]. discretization to approximate differential equation solutions. This method converts con- tinuous functions into discrete ones, simplifying calculation and analysis. It is commonly used in domains with differential equations, including physics, engineering, and finance. There are three forms of finite difference approximations: forward difference, backward difference, and central difference. The forward difference method estimates the derivative by comparing the value of the function at one point to the next. The backward difference compares the values at the present and prior points. The central difference is a more accurate estimate since it averages the forward and backward differences. Among the nu- merical techniques developed over many decades is the FDM. The technique can be used to solve partial differential equations by approximating them with the Taylor series [6, 7]. On the other hand, the FEM is a numerical technique typically employed to resolve differ- ential equations containing boundary conditions. Using a sufficient set of basis functions, the FEM approximates the solution of the differential equation on the domain by dividing it into a finite number of smaller areas known as elements. Nowadays, a lot of problems in multiphysics, fluids, and structures are solved numerically using FEMs. Because scien- tists and engineers can model and solve extremely complicated problems numerically and mathematically, the approach is widely used [8–10]. Engineering analyses are used to eval- uate designs, while scientific analyses are conducted primarily to gain an understanding of and, ideally, forecast natural events. It is very valuable to forecast how a design will work and whether and how a natural occurrence will occur. By doing so, designs can be made safer and more economical, and knowledge of the ability to predict nature can assist, for instance, in preventing tragedies. Therefore, using the FEM significantly improves our quality of life [11–13]. The Galerkin Finite Element Method (GFEM) divides the domain into finite elements in order to produce a numerical solution to a differential equation. Piecewise trial functions over each of these elements are used to approximate the function . The GFEM for the solution of a differential equation consists of the following steps [14, 15]: 1 multiply the differential equation by a weight function ω(x) and form the integral over the whole domain. S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 3 of 10 2 if necessary, integrate by parts to reduce the order of the highest order term. 3 choose the order of interpolation (e.g. linear, quadratic, etc.) and corresponding shape functions Ni, i = 1...m, with trial function p = p̃(x) = m∑ i=1 Ni(x)pi. 4 evaluate all integrals over each element, either exactly or numerically, to set up a system of equations in the unknown pi′s. 5 solve the system of equations for the pi′s. This work will be focus on the applications of GFEM and compare it with the FDM to check more superiority method. This paper organized 5 sections. Section 2, introduced a brief description of the FDM. Section 3, presented the formulations of the GFEM for solving PDEs of elliptic type. Section 4 includes the numerical experiments and the comparison between these two method. The paper ends with conclusion and final remarks. 2. Finite difference Method The Poisson’s equation in two-dimension can be written as [16–18]. ∂2u ∂x2 + ∂2u ∂y2 = g(x, y) (1) along the boundary C with the boundary condition u = f(x, y) . Here, we also made the assumption that the mesh points are uniform in both the x and y dimensions. With this presumption, the equation (1) central difference approximation can be simplified to ui,j = 1 4 (ui+1,j + ui−1,j + ui,j+1 + ui,j−1 − h2gi,j) where gi,j = g(xi, yi). This formula is known as standard five-point formula. Let u = 0 along the boundary C and i, j = 0, 1, 2, 3, 4. Then u0,j = 0, u4,j = 0, for j = 0, 1, 2, 3, 4.and ui,0 = 0, ui,4 = 0 for i = 0, 1, 2, 3, 4. The boundary values (filled circles) are shown in Figure 1. S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 4 of 10 Figure 1: Mesh points of FDM. For a particular case, i.e. for i, j = 0, 1, 2, 3. the equation (1) becomes a system of nine equations with nine unknowns. These equations are written in matrix notation as 4 −1 0 −1 0 0 0 0 0 −1 4 −1 0 −1 0 0 0 0 0 −1 4 0 0 −1 0 0 0 −1 0 0 4 −1 0 −1 0 0 0 −1 0 −1 4 −1 0 −1 0 0 0 −1 0 −1 4 0 0 −1 0 0 0 −1 0 0 4 −1 0 0 0 0 0 −1 0 −1 4 −1 0 0 0 0 0 −1 0 −1 4   u1,1 u1,2 u1,3 u2,1 u2,2 u2,3 u3,1 u3,2 u3,3  =  −h2g1,1 −h2g1,2 −h2g1,3 −h2g2,1 −h2g2,2 −h2g2,3 −h2g3,1 −h2g3,2 −h2g3,3  As a result, equation (1) formed a system of N equations, where n is the number of subintervals along the x and y axes. The coefficient matrix is symmetric, sparse (many elements are 0), and positive definite. The preceding system of equations should be solved iteratively rather than directly because the coefficient matrix is sparse. . Constructing exact and numerical solutions of partial differential equations (PDEs) has become an active area in recent years. Several applications of PDEs have been devel- oped over the years, such as in the theory of heat-magneto-photothermal and magnetic fields. There are many complex problems in mathematics and physics that involve the use of PDEs. These problems can be quite challenging to solve due to their intricate nature. Traditional methods might not always be sufficient, so alternative methods are often employed to find solutions. [19–21] 3. Galerkin Finite element Method Let us considered the model problem: Poisson equation with homogenous Dirichlet boundary conditions [22, 23] −∆u = f in Ω (2) u = 0 on ∂Ω S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 5 of 10 Multiply a test function v, integrate over Ω, and use integration by parts to obtain the corresponding variational formulation: Find u ∈ V = H1 0 (Ω) := {v ∈ L2(Ω)|∇v ∈ L2(Ω), v|Γ = 0} such that a(u, v) = (f, v), for all v ∈ V, (3) Where a(u, v) = ∫ Ω ∇u∇v dx, (f, v) = ∫ Ω fv dx for all f ∈ L2(Ω) (4) Clearly, in such case a(·, ·) is bilinear and symmetric, and a(u, u) = |u|21,Ω := ||u||2 Fur- thermore a(u, u) = 0 implies ∇u = 0 and consequently u is constant. As u|Γ = 0, this constant should be zero. Therefore a(·, ·) defines an inner product on V , and thus the problem (2) has a unique solution by the Riesz representation theorem. We now consider a class of methods, known as Galerkin methods which are used to approximate the solution to (2). Consider a finite dimensional subspace Vh ⊂ V . Restrict the variational form in the subspace Vh , i.e., find uh ∈ V s.t. a(uh, vh) = (f, vh), for all vh ∈ V (5) Let Vh = span{φ1, φ2, ..., φN} For any function v ∈ Vh , there is a unique representation: v = ∑N i=1 viφi We thus can define an isomorphism Vh ∼= RN by v = N∑ i=1 viφi ←→ v = (v1, ..., vN )T , and call v the coordinate vector of v relative to the basis {φ}Ni=1 Following the terminology in elasticity, we introduce the stiffness matrix A = (aij)N X N with aij = a(∅j , ∅i) and the load vector f = {⟨f, φ⟩}Nk=1 ∈ RN Then the variational problem (5) on Vh can be formulated as the following linear algebraic system Au = f By definition, for two functions, vu ∈ Vh , their a(·, ·) -inner product is realized by the matrix product a(uh, vh) = a( ∑ i uiφi, ∑ vjφj) = ∑ i,j a(φi, φj)uivj = vtAu Therefore for any vector u ∈ RN , uTAu = a(u, u) ≥ 0 and equals 0 if and only if u is zero. Namely A is a symmetric positive definite (SPD) matrix and thus the solution u = A−1f exists and unique. After we get the coefficient vector u , uh can be obtained by linear combination of basis functions. The finite element method, a prominent and widely-used S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 6 of 10 example of Galerkin methods, constructs a finite-dimensional subspace Vh based on trian- gulations τh of the domain. The name comes from the fact that the domain is decomposed into finite number of elements. Usually piecewise polynomials are used to define a finite dimensional space. 4. Numerical experiments Consider Poisson equation ∂2u ∂x2 + ∂2u ∂y2 = xy (6) Subject to the boundary conditions u(x, 0) = 0, u(x, 2) = 0, u(0, y) = 0, u(2, y) = 0. The analytical solution of the PDE is u = ∑ m≥1 ∑ n≥1 −16 π2 (−1)n+m nmλnm sin( nπx 2 ) sin( mπy 2 ) (7) Table 1 shows the approximations solutions of GFEM and FDM with the analytical so- lution of the proposed problem. The results reveal that GFEM works will better than FDM because the approximation solutions resulted from GFEM close to the analytical solutions. Table 1: Comparison results of the approximation solutions from FDM, GFEM and the analytical solution of the proposed problem. NODES FDM GFEM Analytical Solution 1 0 0 0 2 −0.119349193976091 −0.122668821548822 −0.1226832533 3 −0.11477288471148 −0.117143703703704 −0.1176222268 4 −0.119349193976091 −0.122668821548822 −0.1226832533 5 −0.216687033077673 −0.221429225589226 −0.222990496 6 −0.213255170322128 −0.216574276094276 −0.2194532299 7 −0.262825492159407 −0.267567407407407 −0.2707333253 Table 2: Absolute errors of the FDM for solving the proposed problem. NODES FDM Analytical Solution Absolute error 1 0 0 0 2 −0.119349193976091 −0.1226832533 0.003334059324 3 −0.11477288471148 −0.1176222268 0.002849342089 4 −0.119349193976091 −0.1226832533 0.003334059324 5 −0.216687033077673 -0.222990496 0.006303462922 6 −0.213255170322128 −0.2194532299 0.006198059578 7 −0.262825492159407 −0.2707333253 0.007907833141 S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 7 of 10 Table 3: Absolute errors of the GFEM for solving the proposed problem. NODES GFEM Analytical Solution Absolute error 1 0 0 0 2 −0.122668821548822 −0.1226832533 −0.00001443175118 3 −0.117143703703704 −0.1176222268 −0.0004785230963 4 −0.122668821548822 −0.1226832533 −0.00001443175118 5 −0.221429225589226 −0.222990496 −0.001561270411 6 −0.216574276094276 −0.2194532299 −0.002878953806 7 −0.267567407407407 −0.2707333253 −0.003165917893 Tables 2 and 3 show the absolute error in the case of FDM and GFEM. We can observe that the absolute errors of GFEM smaller than FDM which implies that the GFEM has more accuracy than FDM. Figure 2: Comparison between the approximation solution by FDM and analytical solution. Figure 3: Comparison between the approximation solution by GFEM and analytical solution. From figures 2 and 3 we can observe that the error associated with the FDM is higher compared to that of the GFEM. Figures 4,5 and 6 show clearly the absolute errors of FDM and GFEM with the analyti- cal solution and it is noticeable that the GFEM works better than FDM and approximation S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 8 of 10 solution from GFEM is very close to the analytical solution which support our result. Figure 4: Graph of the numerical solution of Poisson equation Using FDM. Figure 5: Graph of the numerical solution of Poisson equation Using GFEM. S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 9 of 10 Figure 6: Graph of the analytical solution. 5. Conclusion In this paper, we have applied Galerkin finite element method for solving Poisson equation, the numerical experiments conducted on both GFEM and FDM for comparison purpose. The results reveal that the GFEM is more superior than FDM depends on its accuracy. We conclude that GFEM is a good alternative method for solving PDEs of elliptic types and we can extend this work for solving several types of equations which applied for many fields of engineering, fluid dynamics. . . etc. Acknowledgements The Researchers would like to thank the Deanship of Graduate Studies and Scientific Research at Qassim University for financial support (QU-APC-2025). References [1] A Quarteroni. Numerical approximation of partial differential equations. Berlin ; New York : Springer-Verlag, 1994. [2] G Smith. Numerical Solution of Partial Differential Equations: Finite Difference Methods. Clarendon Press, 1985. [3] B Szabo and I babuska. Finite Element Analysis: Method, Verification and Valida- tion. Wiley, 2021. [4] E cheney and D Kincaid. Numerical Mathematics and Computing. Pacific Grove, CA : Brooks/Cole Pub. Co, 1999. S. S. Almutairi, A. M. Saeed / Eur. J. Pure Appl. Math, 18 (2) (2025), 5895 10 of 10 [5] K Bathe. Finite element procedures. Klaus-Jurgen Bathe, 2006. [6] P Causon and P Mingham. Introductory Finite Difference Methods for PDEs. Book- boon, 2010. [7] U Yashkun and M Chandio. Finite difference method with dirichlet problems of 2d laplace’s equation in elliptic domain. Pakistan Journal of Engineering Technology and Science (PJETS), 6(2):136–144, 2016. [8] T Hughes. The finite element method : linear static and dynamic finite element analysis. Mineola, NY : Dover Publications, 2000. [9] O Zienkiewicz, R Taylor, and J Zhu. The Finite Element Method: Its Basis and Fundamentals. Elsevier Science, 2005. [10] S Brenner and R Scott. The Mathematical Theory of Finite Element Methods. Springer New York, 2007. [11] R Haberman. Elementary Applied Partial Differential Equations: With Fourier Series and Boundary Value Problems. Prentice Hall, 1998. [12] O Zienkiewicz. The finite element method. Singapore : McGraw-Hill, 1989. [13] K Bathe. Computational Fluid and Solid Mechanics 2003. Elsevier Science, 2003. [14] H Grosshans, S Gopireddy, R Humza, and E Gutheil. Modeling and simulation of single particle and spray drying of pvp- and mannitol-water in hot air. Springer, 2016. [15] A Azadi, A Irani, M Azarafza, and M Bonab. Coupled numerical and analytical sta- bility analysis charts for an earth-fill dam under rapid drawdown conditions. Applied Sciences, 12(9):19, 2022. [16] S Abdulkafi. Improved rotated finite difference method for solving fractional elliptic partial differential equations. American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS), 26(1):261–270, 2016. [17] S Abdulkafi. Solving poisson’s equation using preconditioned nine-point group sor iterative method. International Journal of Mathematics and Statistics Invention (IJMSI), 4:8, 2016. [18] P Zhou. Finite Difference Method, pages 63–94. Springer Berlin Heidelberg, Berlin, Heidelberg, 1993. [19] Kh Lotfy, AA El-Bary, and RS Tantawi. Effects of variable thermal conductivity of a small semiconductor cavity through the fractional order heat-magneto-photothermal theory. The European Physical Journal Plus, 134(6):280, 2019. [20] Kh Lotfy, AA El-Bary, W Hassan, and MH Ahmed. Hall current influence of microtemperature magneto-elastic semiconductor material. Superlattices and Mi- crostructures, 139:106428, 2020. [21] Kh Lotfy and RS Tantawi. Photo-thermal-elastic interaction in a functionally graded material (fgm) and magnetic field. Silicon, 12(2):295–303, 2020. [22] P Ciarlet. The Finite Element Method for Elliptic Problems. Elsevier Science, 1978. [23] J Guermond and A Ern. Finite Elements II: Galerkin Approximation, Elliptic and Mixed PDEs. Springer International,, 2022.