1. Introduction
Fractional differential equations (FDEs), as the evolution of integral differential equations, can more precisely describe phenomena with sophisticated dynamics [
1,
2,
3,
4]. In the past few decades, FDEs have been investigated by a number of scholars because they have practical applications in various fields, such as relativistic quantum mechanics [
5], hydromechanics [
6], neuroscience [
7], and materials science [
8]. Due to it being virtually impossible to obtain an analytic solution to an FDE in most cases, many numerical methods for solving FDEs have been developed rapidly. In particular, finite difference methods (FDMs) [
9,
10], finite element methods (FEMs) [
11,
12,
13], spectral methods [
14,
15,
16], and spectral element methods [
17,
18] have been extensively utilized.
In this article, we concentrate on the following FKGE:
When
, (
1) is a classical integer-order Klein–Gordon equation.
is a fractional derivative with respect to
t in the Caputo sense, which is defined as
If we set
, then an FKGE can be obtained, and a fractional dissipative Klein–Gordon equation can be obtained for
[
19].
The application of FDEs has been extended to quantum mechanics, which has given rise to fractional quantum mechanics [
20,
21]. Klein–Gordon equations, which are some of the most fundamental equations in relativistic quantum mechanics, have been generalized to FKGEs [
19,
22]. As a matter of fact, quite a few scholars have investigated FKGEs. Vong et al. proposed a high-order finite difference scheme for a nonlinear FKGE, and the convergence order of the proposed scheme was
[
23], where
h and
are the spatial and temporal step sizes, respectively. Hashemizadeh et al. proposed an approach that relied on the sparse operational matrix of the derivative to solve an FKGE, leading to more efficient operation [
19]. By combining the properties of Chebyshev approximations with the FDM, Khadera et al. developed a method that reduced an FKGE to a system of ODEs and then solved it using the FDM [
24]. Recently, Saffarian et al. utilized the ADI spectral element method to solve a nonlinear FKGE with a convergent order of
) [
25], where
N is the polynomial degree and m represents the regularity of the solution. As far as the authors’ knowledge is concerned, there have been few reports on numerical methods utilizing fast algorithms for an FKGE. Motivated by the above considerations, our main aim was developing a stable and fast numerical method for FKGEs.
The structure of this paper is as follows: In
Section 2, some crucial preliminaries are provided for the subsequent analysis. In
Section 3, to obtain the fully discrete scheme, we introduce the
scheme and the Legendre spectral method in the temporal and spatial directions, respectively. Meanwhile, correction terms are considered to improve the weak regularity of the solution. In
Section 4, we attach importance to the stability analysis and the convergence analysis. To save on computational expenses for the fractional operators, a fast algorithm is implemented in
Section 5. In
Section 6, several numerical experiments are conducted to validate our theoretical analysis. In the final section, we present our conclusions.
2. Preliminaries
In this section, some lemmas and definitions that were necessary for the following analysis are presented.
The space corresponds to the set of polynomials defined in the domain , encompassing polynomials with a degree lower than N. Moreover, within , we have the subspace that fulfills the boundary condition for
Let us denote
as the orthogonal projection operator from the Hilbert space
to the subspace
. For any
and any
, the orthogonal projection operator
exhibits the following property:
Here, we make a crucial assumption that the solution to Equation (
1) conforms to the following form [
11,
17]:
where
;
;
and
is a function that is sufficiently smooth with respect to both variables
x and
t. There exists
for
We define
as:
which describes the regularity of (
2).
Lemma 1 ([
14,
16]).
Suppose ; then, we have Lemma 2 ([
11,
19]).
Let be a continuous function with a fractional derivative of order α; then, we have Lemma 3 ([
11]).
Suppose for . Let with and . Then, we have Integrating both sides of (
1) with the operator
and combining Lemmas 2 and 3, we obtain
where
Under the assumption of (
2),
.
3. Fully Discrete Scheme
Let
be a temporal step size and
For the discretization of fractional operators (
) and the first-order derivative, we utilize the
schemes as follows [
11,
12]:
where
,
. The following expression captures the relationship between the generating function
and its expansion coefficients
:
where
, and the choice of
does not affect the convergence rate. When
, it simplifies to a fractional Crank–Nicolson scheme [
26]. We apply the following formula to determine expansion coefficients
:
where
The semi-discrete scheme of (
7) is obtained in the temporal direction utilizing (
8) as follows:
where
, and
is
The Legendre spectral method is applied for the discretization in the spatial direction and used to find
for
, such that
We see from the truncation errors in (
8) that if
, then the convergence order in the temporal direction is lower than
. Generally, the solutions of FKGEs have weak regularity. To improve the convergence rate, correction terms are added to the approximation formulas as follows [
17,
27,
28]:
where
,
, and
are starting weights, and they can be derived by solving a linear system of equations. Take an example for calculating
in (
13).
is exact for
. Then, it can be solved through the following linear system:
5. Fast Algorithm
The expansion coefficients
in (
9) can be represented as integrals by [
11,
29,
30]
where
If we define
then
where
. From (
51), we can derive
and so we can rewrite
as
where
, and
The key to the fast algorithm is that we divide the time domain into a series of fast growing intervals,
where
B is a basis chosen satisfying
, and
is overlapping.
In Equation (
49), we select a Talbot contour
as our chosen path of integration [
31]. Then, we can obtain
where
and
are
To demonstrate the effectiveness of the approximation, we subtract (
57) from (
9) and obtain the absolute value, which represents the absolute approximation error. Setting
,
and
and 30, we plot the absolute approximation error in
Figure 1.
Figure 1 shows that the approximate effect of the first few weights is poor, so in the calculation process, we calculate the first few weights by (
9) and find that the approximate effect of
is generally better than that of
, which will be verified in Example 4. Referring to [
32], we determine
L and obtain
.
We define
as
Then, utilizing (
57), (
60), and the definitions for
, we obtain (for
)
where
is as follows
We notice that
has a recursive structure, which can be utilized to enhance the computation speed:
The first few weights are not described well by (
57) (refer to
Figure 1). Thus, for
, we calculate the weights according to (
9), and for
, we calculate the weights according to (
57). Combining (
59)–(
61), we can obtain
Below are listed the steps for implementing the fast algorithm:
- 1.
Input parameters , , , , .
- 2.
Compute and obtain .
- 3.
For
, compute the weights using (
9), and calculate the weights using (
57) for
.
- 4.
From step 3, compute (
64).
6. Numerical Examples
In this section, we provide four examples of solving an FKGE utilizing our proposed scheme, and the results verify our theoretical analysis and the effectiveness of our method. The basis function was chosen as for , where is the frequency coefficient. The codes were developed in MATLAB 2022a and executed on a Windows 10 operating system. The computer used for running these codes had a processor speed of 2.60 GHz and 8 GB of RAM.
Example 1. Let in (1). We considered the following fractional dissipative Klein–Gordon equation with homogeneous initial condition : Assuming that the exact solution of Equation (65) is , the corresponding forcing term is given by For
, the results are presented in
Table 1,
Table 2 and
Table 3. It can be observed that our numerical scheme exhibited second-order convergence accuracy in the temporal direction, which aligned with the theoretical expectations.
To analyze the spatial accuracy, we set
to eliminate temporal direction errors. In
Figure 2, it can be observed that when
and
the error exhibited an exponential decrease. This behavior confirmed the spectral accuracy of the method, which in turn confirmed the validity of our theoretical analysis.
Example 2. Let in (1). We investigated the fractional linear Klein–Gordon equation with the non-homogeneous initial conditions Assuming that the exact solution of Equation (66) is , the corresponding forcing term is For
, the results are illustrated in
Table 4,
Table 5 and
Table 6. Notably, even when considering non-homogeneous initial conditions, it was evident that our numerical scheme remained applicable. The results indicated the adaptability and flexibility of our method.
Example 3. Let in (1). The non-smooth solution was considered, with the corresponding forcing term Assuming
, it is worth mentioning that due to the weak regularity of the solution, it was not possible to achieve the optimal convergence rate of
. Referring to
Table 7, we can observe that the inclusion of correction terms led to an improved convergence rate. This result serves as evidence for the efficiency of our method.
Example 4. Let in (1). We utilized the fast algorithm to solve the Equation (66). Assuming that the exact solution of Equation (66) is , the corresponding forcing term is We set
and
To simplify the notation, we denoted the approximation of Equation (
57) with
points as Fast
. We had two sets of solutions:
, which were obtained using the direct method, and
, which was obtained using the fast algorithm. We set
and defined the pointwise error as
According to
Table 8, it is evident that the fast algorithm significantly accelerated the computation process. Moreover, our approach not only attained exceptional precision, but also effectively reduced the computational cost. For example, for
the pointwise error was around
, which was close to the machine accuracy.
Figure 3a displays the exact solutions for
Figure 3b shows the numerical solutions for the given parameters:
,
= 1.8, and
. Furthermore, in order to obtain the error contour plot shown in
Figure 4a, we subtracted the corresponding solutions from
Figure 3a,b. In
Figure 4b, it is evident that the computational complexity of the fast algorithm was
, while the direct method had a computational complexity of
. This result in
Figure 4 aligned with the theoretical expectations and confirmed that the algorithms’ performances matched the expected efficiencies.