- Research
- Open access
- Published:

# Legendre spectral element method for solving sine-Gordon equation

*Advances in Difference Equations*
**volumeÂ 2019**, ArticleÂ number:Â 113 (2019)

## Abstract

In this paper, we study the Legendre spectral element method for solving the sine-Gordon equation in one dimension. Firstly, we discretize the equation by Legendre spectral element in space and then discretize the time by the second-order leap-frog method. We study the stability and convergence of the method and show the convergence of our method. Finally, we show the results with numerical examples.

## 1 Introduction

A spectral element method combines the high accuracy of spectral methods and flexibility of finite element method, and the approximate result of this method provides high accuracy and spectral convergence. In this method the solution is approximated on each element using spectral methods. One of the advantages of this method is the high accuracy and stable solving algorithm with a small number of elements under a wide range of conditions [1].

Finite element method was proposed for the first time in 1943 by Courant [2]. He solved the Poisson equation based on minimizing piecewise linear approximations on finite subdomains.

The spectral method is a conventional method for solving partial differential equations, which was first introduced by Navier for elastic sheet problems in 1825. In spectral method the solution is approximated on one general domain.

In 1984, Patera applied a spectral method to a greater number of subdomains by a division of domains. He proposed the spectral element method by combining the spectral method and the finite element method [3]. In his innovative method, Patera uses the Chebyshev polynomials as the interpolation basis functions. Legendreâ€™s spectral element was developed by Maday and Patera [4]. The use of the Lagrangian interpolation conjugate with the Gaussâ€“Legendreâ€“Lobatto quadrature leads to a matrix of mass with diameter structure [5]. The diagonal mass matrix is a very important property of the Legendre spectral element method and is different from the Chebyshev spectral element method [6].

The Legendre spectral element method is widely used in solving partial differential equations. Chen et al. [7] used the Legendre spectral element method to solve a constrained optimal control problem. An alternating direction implicit (ADI) Legendre spectral element method for the two-dimensional Schrodinger equation is developed in [8], and the optimal \(H^{1}\) error estimate for the linear case is given. The aim of [9] is the Lagrangeâ€“Galerkin spectral element method for solving two-dimensional shallow water equations. The authors of [10] considered the numerical approximation of the acoustic wave equation by the spectral element method based on the Gaussâ€“Lobattoâ€“Legendre quadrature formulas and finite difference Newmarkâ€™s explicit time advancing schemes. A modified set of basis functions for use with spectral element methods is presented in [11] for solving a mixed elliptic boundary value problem. These basis functions are constructed so that the axial conditions along a plane or axis of symmetry are satisfied identically. A numerical spectral element method for the computation of fluid flows governed by the incompressible Euler equations in a complex geometry is presented in [12]. Zhuang and Chen [13] used this method to solve biharmonic equations. In [14], the authors used the spectral element method with least-square formulation for parabolic interface problems. Ai et al. [15] used fully diagonalized Legendre spectral element methods using Sobolev orthogonal/biorthogonal basis functions for solving second-order elliptic boundary value problems. A Legendre spectral element formulation of an improved time-splitting method is developed for the natural convection heat transfer problem in a square cavity by Wang and Qin [16].

The sine-Gordon equation is one of the most important partial differential equations, which applies to many scientific fields such as the motion of a rigid pendula attached to a stretched wire [17], solid state physics, nonlinear optics, and the stability of fluid motions.

We consider the one-dimension sine-Gordon equation

where *u* is a function of *x* and *t*, and \({u _{0}} ( x )\) and \({u _{1}} ( x )\) are known analytic functions.

Different numerical methods are presented for Eq. (1). Dehghan and Shokri [18] solved a one-dimensional sine-Gordon equation using collocation points and approximating the solution using thin plate splines radial basis function. Dehghan and Mirzaei [19] used a numerical method of the boundary integral equation to approximate the solution of one-dimensional equation (1). Mohebbi and Dehghan [20] have also used the finite difference method for numerical solution of equation (1).

In [21] the authors present an analysis of the stability spectrum for all stationary periodic solutions to the sine-Gordon equation. Yousif an Mahmood [22] used the variational homotopy perturbation method for solving the Kleinâ€“Gordon and sine-Gordon equations. In [23] a new scheme, which has energy-preserving property, is proposed for solving the sine-Gordon equation with periodic boundary conditions. This method is obtained by the Fourier pseudo-spectral method and the fourth-order average vector field method. Baccouch [24] presented superconvergence results for the local discontinuous Galerkin method for the sine-Gordon nonlinear hyperbolic equation in one space dimension.

Other numerical methods have also been used to solve the sine-Gordon equation such as Chebyshev tau meshless method [25], meshless method of lines [26], high-accuracy multiquadric quasi-interpolation [27], reduced differential transform method [28], pseudo-spectral method [29], modified cubic B-spline differential quadrature method [30], modified cubic B-spline collocation method [31], etc.

In this paper, we study the Legendre spectral element method for solving Eq. (1). First, using the Legendre spectral element method, we obtain a semi-discrete spatial form of Eq. (1), and then, using the leap-frog method, we obtain a complete discrete form of Eq. (1). We bring theorems on stability and convergence, and, finally, we show the results by a numerical example.

This paper is organized as follows: In Sect. 2, we perform a spatial discretization of Eq. (1) using the Legendre spectral element method. In Sect. 3, we perform a time discretization of Eq. (1) using the second-order leap-frog method. In Sect. 4, we present stability and convergence theorems. Finally, in Sect. 5, we present a numerical example to validate the stability and convergence of the numerical scheme with respect to the discretization parameters.

## 2 Space discretization

In this section, we explain the Legendre spectral element method and spatial discretization of Eq. (1).

### 2.1 Legendre spectral element method

In the Legendre spectral element method, we first divide the domain *Î©* into \(N_{e}\) nonoverlapping subdomains \(\varOmega _{e}\):

We define the approximation space

where \({P_{N}}\) is a polynomial space of dimension less than or equal to *N*. Basis functions are considered as the Lagrangian interpolation polynomials defined at Gaussâ€“Lobatto integration points on each element. If \(N_{e} = 1\), then we obtain the spectral Galerkin method of order \(N-1\). If \(N = 1\) or \(N = 2\), then we obtain a standard Galerkin finite element method based on linear and quadratic elements, respectively.

Now on each element \(\varOmega _{e}\), we define the approximate solution of order *N* as

where \({\varphi _{j}}\) is the *j*th Lagrange polynomial of order *N* on the Gaussâ€“Legendreâ€“Lobatto points \(\{ {{\xi _{i}}} \} _{i = 0}^{N}\) [32]:

and \(L_{N}\) is the Legendre polynomial of order *N*.

To convert the \([-1,1 ]\) to the *e*th element and its inverse, we use the mapping functions

where \(x_{e}\) and \(x_{e-1}\) are the endpoints of the *e*th element. The stiffness [33] and mass matrices [34] on each element are calculated as follows:

where

Using the Gauss quadrature, we obtain [35]

where

and

### 2.2 Space discretization of the sine-Gordon equation

We obtain the weak form of Eq. (1) as follows. For each element \(\varOmega _{e}\), we find \({u^{e}} \in {U^{h}}\) such that

The second integral on the left-hand side is obtained by integration by parts. Now, taking the *k*th Lagrange function of order *N* as the test function *v* and using Eq. (2), we have

We obtain the right-hand side of Eq. (3) using the following equation [36]:

The matrix form of the semidiscrete form of Eq. (3) is

where the vector \(U^{e}\) contains an approximation solution of order *N* on the element \(\varOmega _{e}\) at time *t*, \(M^{e}\) is a local diagonal mass matrix, and \(S^{e}\) is a local stiffness matrix on the element \(\varOmega _{e}\).

To obtain a semidiscrete form on the general domain, we must assemble the local matrices \(M^{e}\) and \(S^{e}\) and obtain the general matrices *M* and *S* [35]. So Eq. (4) becomes

where *U* is the vector of the approximate solution on the general domain *Î©* at time *t*.

## 3 Time discretization

For full discretization of Eq. (5), we first divide the interval \((0,T )\) into subintervals \([t_{n},t_{n+1} ]\), where \({t_{0}} = 0\) and \(t_{n+1}=t_{n}+k\) for \(n=0,\ldots,N_{t}-1\). Now, using the leap-frog method, we obtain the full discrete form of Eq. (1):

where \(U_{n}\) is the vector of approximation solution at time \(t_{n}\). After simplifying, Eq. (6) becomes

For \(n=0\), we have

For calculation of \(U_{-1}\), we have

and thus

So, for \(n=0\), we have

For \(n>0\), we also have

Because the mass matrix *M* is diagonal, solving Eqs. (8) and (9) is easier than by similar methods.

## 4 Stability and convergence analysis

In this section, we analyze the stability of leap-frog method and the convergence of the spectral element method presented in the previous sections.

### 4.1 Stability of leap-frog method

Equation (9) can be written as

where

and

Since \(F_{n,n - 1}\) is a known vector at each step and does not play any role in the stability analysis, we need to consider the equation

### Theorem 4.1

*Equation* (10) *is stable under the following condition*:

### Proof

We must show that

If \(\mu _{i}\) are the eigenvalues of the diagonal matrix *M* and \(\lambda _{i}\) are the eigenvalues of the matrix *S*, then \({\frac{ {{\lambda _{i}}}}{{{\mu _{i}}}}}\) are the eigenvalues of the matrix *A*. We must show that

From this inequality we obtain

According to [37], we have that

and, consequently,

According to Eq. (11),

â€ƒâ–¡

### 4.2 Convergence of spectral element method

In [38] the convergence theorem is presented for the spectral element method for acoustic waves.

### Theorem 4.2

([38])

*Suppose that*
\(u \in {C^{2}} ( {0,T;{H^{s}} ( \varOmega )} ) \cap {C^{4}} ( {0,T;{L^{2}} ( \varOmega )} )\)
*is the exact solution of*

*and*
*U*
*is the approximation result of the spectral element method under stability conditions on*
*k*. *Then*, *for all*
\(t_{n} > 0\), *we have*

## 5 Numerical results

In this section, we consider a numerical example to validate the proposed scheme. The accuracy of the scheme is verified in the \(L_{2}\) and \(L_{\infty }\) norms and root mean square errors.

We set

where \(N_{e,N}\) are all nodes of the domain, and \(U_{n}\) is the vector of nodal values of the numerical solution corresponding to the discretization parameters *N*, \(N_{e}\), and *k* at time \(t_{n}\), and for each continuous function *f*,

### Example 5.1

We consider the equation

and the exact solution is given by

We solve this problem with the Legendre spectral element method presented in this paper with several values of *N*, *k*, and \(N_{e}\) at final time \(T = 1\). Table 1 shows the errors of Legendre spectral element method with several values of *N* at final time \(T = 1\) with \(k=0.1, 0.01\) and \({N_{e}}=20\).

Table 2 shows the maximum pointwise error \(\vert {u_{ \mathrm{exact}}-u_{\mathrm{LSEM}}} \vert \) at several times \(T=1,2, \ldots,10\) with \(N =4\), \(N{_{e}}=20\), and \(k=0.01\).

Figures 1 and 2 show graphs of approximate solution and absolute error and Fig. 3 shows graph of approximate and exact solution at \(T = 1\), using present method with \(N = 4\), \({N_{e}} =20\) and \(k = 0.1\).

In the following figures (4, 5, and 6) we have used a logarithmic scale for both axes. In Fig. 4, we show the *RMS*err as a function of the degree of the polynomials *N* for two fixed values of *k* (\(k = 0.1,0.01\)) and \(N_{e} = 20\).

In Fig. 5, we report the quantity *RMS*err for *k* ranging from 0.001 to 0.1 and fixed \(N = 7\) and \(N_{e} = 20\).

Figure 6 shows the *RMS*err as a function of \(N_{e}\) for two fixed values of *k* (\(k= 0.1, 0.01\)) and \(N = 4\).

### Example 5.2

In this example, we obtain the numerical solutions of Eq. (1) the computational domain \(\varOmega = [-1,1 ]\) with the initial conditions

The analytical solution is given in [39] as

The boundary conditions are obtained from the exact solution. We compute the numerical solution in the domain \(\varOmega = [-1,1 ]\) with several values of *N*, *k*, \(N_{e}\), and time *t*. The obtained results are compared with the results in [18, 30, 31]. Table 3 shows the results at the different time levels. It can be seen from Table 3 that the present results are in good agreement with those in the literature. A graph comparing the exact and numerical solutions at \(T = 1\) with \(N=4\), \(k=0.01\), and \(N_{e}=20\) is depicted in Fig. 7. We also draw the space-time graph of approximate solution for \(t\le 2\) in Fig. 8 with \(N = 2\), \(N_{e} = 10\), and \(k = 0.01\).

### Example 5.3

Consider the sine-Gordon equation (1) in the range \(\varOmega = [-10,10 ]\) with the initial conditions

where \(c=0.5\) is the velocity of solitary wave, and \(\gamma = \frac{1}{ {\sqrt{1 + {c^{2}}} }}\). The exact solution [31] is given as

The boundary conditions can be obtained from the exact solution. The numerical solution for Example 5.3 is computed in the domain \([-10, 10 ]\) using the parameter values \(N = 7\), \(N_{e}=30\), and \(k=0.001\). Computed results are compared with the results obtained in [30, 31, 40]. Table 4 shows \(L_{2}\operatorname{err}\) and \(L_{\infty }\operatorname{err}\) at different time levels. From Table 4 we can see that the present results are in good agreement with those of [31, 40], but it has more errors than [30]. Figure 9 shows the comparison between the numerical and exact solutions at \(t = 1\) with \(N=3\), \(N_{e}=30\), and \(k=0.01\). In Fig. 10, we show the space-time graph of approximate solution for \(t\le 10\) using the present method with \(N = 3\), \(N_{e} = 30\), and \(k = 0.1\).

## 6 Conclusion and discussion

The spectral polynomials are useful tools for solving ordinary and partial differential equations. Also, the incorporation of the finite element method with spectral polynomials, that is, the use of spectral polynomials as new shape functions in the finite element method is very efficient for obtaining a numerical algorithm with high accuracy. In this paper, we constructed a Legendre spectral element method for the solution of the one-dimensional sine-Gordon equation. We used the Legendre spectral element method for discretizing the spatial space. Also, we used a leap-frog scheme for discretizing the temporal space with the stability condition \({C^{*}}{N^{ - 1}} \le {k^{2}} \le \tilde{C}{N^{ - 3}}{h^{2}}\). We presented theorems on the stability and convergence. Finally, using one test problem, we demonstrated that the algorithm is efficient for obtaining approximation solutions of the sine-Gordon equation.

## References

Vosse, F.N., Minev, P.D.: Spectral Element Methods: Theory and Applications. Eindhoven University of Technology, EUT Report 96-w-001 (1996)

Courant, R.: Variational method for the solution of problems of equilibrium and vibration. Bull. Am. Math. Soc.

**49**, 1â€“23 (1943)Patera, A.T.: A spectral element method for fluid dynamics: laminar flow in a channel expansion. J.Â Comput. Phys.

**54**, 468â€“488 (1984)Maday, Y., Patera, A.T.: Spectral Element Methods for the Incompressible Navierâ€“Stokes Equations, Surveys on Computational Mechanics. ASME, New York (1989)

Bathe, K.J.: Finite Element Procedures, 2nd edn. Prentice Hall International, Englewood Cliffs (1995)

Priolo, E., Seriani, G.A.: A numerical investigation of Chebyshev spectral element method for acoustic wave propagation. In: Proceedings of the 13th IMACS Conference Comparat, vol. 54, pp. 154â€“172 (1991)

Chen, Y., Yi, N., Liu, W.: A Legendreâ€“Galerkin spectral method for optimal control problems governed by elliptic equations. SIAM J. Numer. Anal.

**46**, 2254â€“2275 (2008)Zeng, F., Ma, H., Zhao, T.: Alternating direction implicit Legendre spectral element method for SchrÃ¶dinger equations. J.Â Shanghai Univ. Nat. Sci. Ed.

**17**(6), 724â€“727 (2011)Giraldo, F.X.: Strong and weak Lagrangeâ€“Galerkin spectral element methods for the shallow water equations. Comput. Math. Appl.

**45**, 97â€“121 (2003)Zampieri, E., Pavarino, L.F.: Approximation of acoustic waves by explicit Newmarkâ€™s schemes and spectral element methods. J.Â Comput. Appl. Math.

**185**, 308â€“325 (2006)VanOs, R.G., Phillips, T.N.: The choice of spectral element basis functions in domains with an axis of symmetry. J.Â Comput. Appl. Math.

**201**, 217â€“229 (2007)Xu, C., Maday, Y.: A spectral element method for the time-dependent two-dimensional Euler equations: applications to flow simulations. J.Â Comput. Appl. Math.

**91**, 63â€“85 (1998)Zhuang, Q., Chen, L.: Legendreâ€“Galerkin spectral-element method for the biharmonic equations and its applications (in press)

Khan, A., Upadhyay, C.S., Gerritsma, M.: Spectral element method for parabolic interface problems. Comput. Methods Appl. Mech. Eng. (2018). https://doi.org/10.1016/j.cma.2018.03.011

Ai, Q., Li, H.Y., Wang, Z.Q.: Diagonalized Legendre spectral methods using Sobolev orthogonal polynomials for elliptic boundary value problems. Appl. Numer. Math. (2018). https://doi.org/10.1016/j.apnum.2018.01.003

Wang, Y., Qin, G., Wang, Z.Q.: An improved time-splitting method for simulating natural convection heat transfer in a square cavity by Legendre spectral element approximation. Comput. Fluids (2018). https://doi.org/10.1016/j.compfluid.2018.07.013

Wazwaz, A.M.: A variable separated ODE method for solving the triple sine-Gordon and the triple sinh-Gordon equations. Chaos Solitons Fractals

**33**, 703â€“710 (2007)Dehghan, M., Shokri, A.: A numerical method for one-dimensional nonlinear sine-Gordon equation using collocation and radial basis functions. Numer. Methods Partial Differ. Equ.

**24**, 687â€“698 (2008)Dehghan, M., Mirzaei, D.: The boundary integral equation approach for numerical solution of the one-dimensional sine-Gordon equation. Numer. Methods Partial Differ. Equ.

**24**, 1405â€“1415 (2008)Mohebbi, A., Dehghan, M.: High order solution of one-dimensional sine-Gordon equation using compact finite difference and DIRKN methods. Math. Comput. Model.

**51**, 537â€“549 (2010)Deconinck, B., McGil, P., Sega, B.L.: The stability spectrum for elliptic solutions to the sine-Gordon equation. Physica D

**360**, 17â€“35 (2017)Yousif, M.A., Mahmood, B.A.: Approximate solutions for solving the Kleinâ€“Gordon and sine-Gordon equations. J.Â Assoc. Arab Univ. Basic Appl. Sci.

**22**, 83â€“90 (2017)Jiang, C., Sun, J., Li, H., Wang, Y.: A fourth-order AVF method for the numerical integration of sine-Gordon equation. Appl. Math. Comput.

**313**, 144â€“158 (2017)Baccouch, M.: Superconvergence of the local discontinuous Galerkin method for the sine-Gordon equation in one space dimension. J. Comput. Appl. Math.

**333**, 292â€“313 (2018)Shao, W., Wu, X.: The numerical solution of the nonlinear Kleinâ€“Gordon and sine-Gordon equations using the Chebyshev tau meshless method. Comput. Phys. Commun.

**185**, 1399â€“1409 (2014)Hussain, A., Haq, S., Uddin, M.: Numerical solution of Kleinâ€“Gordon and sine-Gordon equations by meshless method of lines. Eng. Anal. Bound. Elem.

**37**, 1355â€“1366 (2013)Jiang, Z.W., Wang, R.H.: Numerical solution of one-dimensional sine-Gordon equation using high accuracy multiquadric quasi-interpolation. Appl. Math. Comput.

**218**, 7711â€“7716 (2012)Keskin, Y., Aglar, I., Ko, A.: Numerical solution of sine-Gordon equation by reduced differential transform method, vol.Â 1 (2011)

Taleei, A., Dehghan, M.: A pseudo-spectral method that uses an overlapping multidomain technique for the numerical solution of sine-Gordon equation in one and two spatial dimensions. Math. Methods Appl. Sci.

**37**, 1909â€“1923 (2014)Shukla, H.S., Tamsir, M.: Numerical solution of nonlinear sine-Gordon equation by using the modified cubic B-spline differential quadrature method. Beni-Suef Univ. J. Basic Appl. Sci.

**7**(4), 359â€“366 (2018)Mittal, R.C., Bhatia, R.: Numerical solution of nonlinear sine-Gordon equation by modified cubic B-spline collocation method. Int. J. Partial Differ. Equ. (2014). https://doi.org/10.1155/2014/343497

Hesthaven, J.S., Gottlieb, S., Gottlieb, D.: Spectral Method for Time-Dependent Problems. Cambridge University Press, Cambridge (2007)

Ern, A., Guermond, J.L.: Theory and Practice of Finite Elements. Springer, New York (2004)

Hand, L.N., Finch, J.D.: Analytical Mechanics. Cambridge University Press, Cambridge (2008)

Pozrikidis, C.: Introduction to Finite and Spectral Element Methods Using Matlab. Chapman & Hall, London (2005)

Argyris, J., Haase, M., Heinrich, J.C.: Finite element approximation to two dimensional sine-Gordon solitons. Comput. Methods Appl. Mech. Eng.

**86**, 1â€“26 (1991)Bernardi, C., Maday, Y.: Approximations Spectrales de ProblÃ¨mes aux Limites Elliptiques. Springer, Berlin (1992)

Zampieri, E., Pavarino, L.F.: An explicit second order spectral element method for acoustic waves. Adv. Comput. Math.

**25**, 381â€“401 (2006)Wei, G.W.: Discrete singular convolution for the sine-Gordon equation. Physica D

**137**, 247â€“259 (2000)Bratsos, A.G.: A fourth order numerical scheme for the one dimensional sine-Gordon equation. Int. J. Comput. Math.

**85**, 1083â€“1095 (2008)

### Acknowledgements

The authors are thankful to the honorable reviewers and editors for their valuable suggestions and comments, which improved the paper.

### Availability of data and materials

The results and numerical data obtained in this paper have been fully tested. These results are obtained using MATLAB R2017a(win64) software and Windows 8 operating system on a intel(R) Core(TM) i7 CPU, 1.73 GHz processor with 4 GB RAM. The authors declare that all data and material in the paper are available and veritable.

## Funding

Not applicable.

## Author information

### Authors and Affiliations

### Contributions

Both authors contributed equally and significantly in writing this article. Both authors wrote, read, and approved the final manuscript.

### Corresponding author

## Ethics declarations

### Competing interests

The authors declare that they have no competing interests.

## Additional information

### Publisherâ€™s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

**Open Access** This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

## About this article

### Cite this article

Lotfi, M., Alipanah, A. Legendre spectral element method for solving sine-Gordon equation.
*Adv Differ Equ* **2019**, 113 (2019). https://doi.org/10.1186/s13662-019-2059-7

Received:

Accepted:

Published:

DOI: https://doi.org/10.1186/s13662-019-2059-7