1 Introduction

In recent decades, fractional partial differential equations have attracted increasing interest mainly due to their potential applications in various realms of science and engineering [13]. The fractional telegraph equation, as a typical diffusion-wave equation, is commonly used in propagation of electrical signals [4], random walk theory [5], the neutron transport in nuclear reactor [6], and so on.

The fractional telegraph equation has been considered recently by several authors. Liu et al. [7] considered the analytical solution of the time-fractional telegraph equation by the method of separating variables. Momani [8] used the Adomian decomposition method to obtain analytic and approximate solutions of the space- and time-fractional telegraph equations. Huang [9] provided the fractional Green function for the time-fractional telegraph equation by employing the Laplace and Fourier transforms. In [10], an analytical mathematical tool, the homotopy analysis method, is used to solve the time-fractional telegraph equation. Although many valuable works have been conducted on theoretical analysis, the obtained solutions of most fractional telegraph equations are not analytic. Therefore many researchers have studied numerical solution of the fractional telegraph equation. Hosseini et al. [11] implemented a hybrid of the radial basis functions and finite difference scheme to achieve a semidiscrete solution of the time-fractional telegraph equation. Liu et al. [12] present a class of unconditionally stable difference schemes of high order for solving a Riesz space-fractional telegraph equation. Hashemi et al. [13] proposed a simple and accurate numerical scheme for solving the time-fractional telegraph equation. Wang et al. [14] discussed and analyzed an \(H^{1}\)-Galerkin mixed finite element method to look for the numerical solution of time-fractional telegraph equation. Ford et al. [15] considered a finite difference method for the two-parameter fractional telegraph equation and obtained a stability condition of the numerical method. Wei [16] developed a fully discrete local discontinuous Galerkin finite element method for numerical simulation of the time-fractional telegraph equation. Although many authors have studied the numerical solution of the fractional telegraph equation, they did not strictly prove the unconditional stability and convergence in time direction.

In this paper, we study the method resulting from a generalized finite difference method for the temporal discretization and a Legendre spectral Galerkin method for the spatial discretization of the following time-fractional telegraph problem:

$$ \textstyle\begin{cases} _{0}^{C}D_{t}^{\alpha+1}u(x,t)+ {}_{0}^{C}D_{t}^{\alpha}u(x,t)+\beta u(x,t)-\lambda\frac{\partial^{2}}{\partial x^{2}}u(x,t)=f(x,t),\\ \quad (x,t)\in\Omega\times[0,T], \\ u(x,0)=u_{0}(x),\qquad \frac{\partial u(x,t)}{\partial t} |_{t=0}=u_{1}(x),\quad x \in\Omega, \\ u(x,t)=0, \quad(x,t)\in\partial\Omega\times[0,T], \end{cases} $$
(1.1)

where \(0 < \alpha<1\) is a parameter describing the fractional derivative with respect to time, \(\Omega=[a,b]\) is a bounded closed interval in \(\mathbb{R}\), \(\beta, \lambda\) are positive constants in \(\mathbb{R}\), and \(f(x,t), u_{0}(x)\), and \(u_{1}(x)\) are given smooth functions.

The time-fractional derivative in (1.1) uses the Caputo fractional partial derivative of order α defined as follows:

$$ _{0}^{C}D_{t}^{\alpha}u(x,t)= \textstyle\begin{cases}\frac{1}{\Gamma(1-\alpha)} \int_{0}^{t} \frac{\partial u(x,s)}{\partial s}\frac{ds}{(t-s)^{\alpha}} & \text{if } 0 < \alpha< 1, \\ \frac{1}{\Gamma(2-\alpha)} \int_{0}^{t} \frac{\partial^{2} u(x,s)}{\partial s^{2}}\frac{ds}{(t-s)^{\alpha-1}} & \text{if } 1< \alpha< 2, \end{cases} $$
(1.2)

where Γ is the gamma function. Obviously, if \(0<\alpha<1\), then \(1<\alpha+1<2\), so

$$\begin{aligned} _{0}^{C}D_{t}^{\alpha+1}u(x,t)&= \frac{1}{\Gamma(2-(\alpha+1))} \int _{0}^{t} \frac{\partial^{2} u(x,s)}{\partial s^{2}}\frac {ds}{(t-s)^{(\alpha+1)-1}} \\ &=\frac{1}{\Gamma(1-\alpha)} \int_{0}^{t} \frac{\partial^{2} u(x,s)}{\partial s^{2}}\frac{ds}{(t-s)^{\alpha}}. \end{aligned}$$
(1.3)

The rest of the paper is organized as follows. In the next section, the temporal discretization scheme of the time-fractional telegraph equation and its stability and convergence are discussed. In Section 3, we derive a full discretization scheme of the time-fractional telegraph equation and obtain error estimates. Numerical experiments are carried out in Section 4, which verify the effectiveness of our method and support the theoretical analysis. The last section is the concluding remarks.

2 Discretization in time: a generalized finite difference scheme

First, we introduce a generalized finite difference approximation to discretize the time-fractional derivative. Let \(t_{k}: = k \tau, k=0,1,\ldots,K \), where \(\tau= \frac{T}{K}\) is the time step. To motivate the construction of the scheme, we define the sequence \(\{a_{j}\}|_{j=0}^{K}\) as \(a_{j}=\frac{\tau ^{1-\alpha}}{1-\alpha} ((j+1)^{1-\alpha}-j^{1-\alpha} )\) and introduce the following lemmas [17].

Lemma 2.1

Let \(g\in C^{2}[0, t_{k}]\) and \(0< \alpha< 1\). Then

$$\begin{aligned} & \Biggl\vert \int_{0}^{t_{k}}\frac{g'(t)}{(t_{k}-t)^{\alpha}}\,dt-\dfrac {1}{\tau } \Biggl[a_{0}g(t_{k})- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j})g(t_{j})-a_{k-1}g(t_{0}) \Biggr] \Biggr\vert \\ &\quad \leq \frac{1}{1-\alpha} \biggl(\frac{1-\alpha}{12}+\frac {2^{2-\alpha }}{2-\alpha}- \bigl(1+2^{-\alpha} \bigr) \biggr)\max_{0\leq t \leq t_{k}} \bigl\vert g''(t) \bigr\vert \tau ^{2-\alpha}. \end{aligned}$$

Lemma 2.2

For any \(G=\{G_{1}, G_{2}, G_{3},\dots\}\) and q, we have

$$\begin{aligned} &\sum_{n=1}^{N} \Biggl(a_{0}G_{n}- \sum_{k=1}^{n-1}(a_{n-k-1}-a_{n-k})G_{k}-a_{n-1}q \Biggr)G_{n}\\ &\quad\geq\frac {t_{N}^{-\alpha}}{2}\tau\sum _{n=1}^{N}G_{n}^{2}- \frac {t_{N}^{1-\alpha }}{2(1-\alpha)}q^{2}. \end{aligned}$$

To motivate the construction of the time-discrete scheme, we use the following functions:

$$ \textstyle\begin{cases} v(x,t)=\frac{\partial u(x,t)}{\partial t}, \\ w(x,t)=\frac{1}{\Gamma(1-\alpha)} \int_{0}^{t}\frac{\partial v(x,s)}{\partial s}\frac{ds}{(t-s)^{\alpha}}, \\ z(x,t)=\frac{1}{\Gamma(1-\alpha)} \int_{0}^{t}\frac{\partial u(x,s)}{\partial s}\frac{ds}{(t-s)^{\alpha}}. \end{cases} $$
(2.1)

Introduce the following notation:

$$u^{k-1/2}(x)=\frac{1}{2} \bigl(u^{k}(x)+u^{k-1}(x) \bigr), \qquad \delta _{t}u^{k-1/2}(x)=\frac{1}{\tau} \bigl(u^{k}(x)-u^{k-1}(x) \bigr). $$

Then we have

$$\begin{aligned} & w^{k-1/2}(x)+z^{k-1/2}(x)+\beta u^{k-1/2}(x)- \lambda\frac{\partial^{2} u^{k-1/2}(x)}{\partial x^{2}}=f^{k-1/2}(x,t), \end{aligned}$$
(2.2)
$$\begin{aligned} & v^{k-1/2}(x)=\delta_{t} u^{k-1/2}(x)+r_{1}^{k-1/2}(x), \end{aligned}$$
(2.3)

and there exists a constant \(C_{1}\) such that \(|r_{1}^{k-1/2}|\leq C_{1}\tau^{2}\) for all \(1\leq k\leq K\).

By Lemma 2.1 we have

$$\begin{aligned} &w^{k-1/2}(x) \\ &\quad=\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0}v^{k-1/2}(x)- \sum _{j=1}^{k-1}(a_{k-j-1}-a_{k-j})v^{j-1/2}(x)-a_{k-1}v^{0}(x) \Biggr)+r_{2}^{k-1/2}, \end{aligned}$$
(2.4)
$$\begin{aligned} &z^{k-1/2}(x) \\ &\quad=\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0}u^{k-1/2}(x)- \sum _{j=1}^{k-1}(a_{k-j-1}-a_{k-j})u^{j-1/2}(x)-a_{k-1}u^{0}(x) \Biggr)+r_{3}^{k-1/2}, \end{aligned}$$
(2.5)

and there exist constants \(C_{2}\) and\(C_{3}\) such that \(|r_{2}^{k-1/2}|\leq C_{2}\tau^{2-\alpha}\) and \(|r_{3}^{k-1/2}|\leq C_{3}\tau^{2-\alpha}\).

From (2.3)-(2.5) we obtain

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)}\frac{1}{\tau} \Biggl(a_{0} \bigl(\delta _{t}u^{k-1/2}(x)+u^{k-1/2}(x) \bigr)- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta _{t}u^{j-1/2}(x)+u^{j-1/2}(x) \bigr) \\ &\qquad -a_{k-1} \bigl(u_{1}(x)+u_{0}(x) \bigr) \Biggr)+ \beta u^{k-1/2}(x)-\lambda \frac{\partial^{2}u^{k-1/2}(x)}{\partial x^{2}} \\ &\quad =f^{k-1/2}+R^{k-1/2},\quad k=1,2,\ldots,K, \end{aligned}$$
(2.6)

where

$$R^{k-1/2}=- \Biggl\{ \frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0}r_{1}^{k-1/2}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j})r_{1}^{j-1/2} \Biggr)+r_{2}^{k-1/2}+r_{3}^{k-1/2} \Biggr\} $$

with

$$\begin{aligned} \bigl\vert R^{k-1/2} \bigr\vert &\leq \frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0}+ \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \Biggr)C_{1}\tau^{2}+C_{2}\tau ^{2-\alpha }+C_{3}\tau^{2-\alpha} \\ &=\frac{1}{\Gamma(1-\alpha)\tau}(2a_{0}-a_{k-1})C_{1}\tau ^{2}+C_{2}\tau ^{2-\alpha}+C_{3} \tau^{2-\alpha} \\ &\leq \biggl(\frac{2C_{1}}{\Gamma(2-\alpha)}+C_{2}+C_{3} \biggr)\tau ^{2-\alpha}. \end{aligned}$$
(2.7)

Dropping the truncation error \(R^{k-1/2}\) in (2.6), we can easily get the the variation (weak) formulation of (1.1): Find \(u^{k}(x)\in H_{0}^{1}(\Omega)\) such that, for all \(v\in H_{0}^{1}(\Omega)\),

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl( \delta _{t}u^{k-1/2}(x)+u^{k-1/2}(x),v(x) \bigr)-a_{k-1} \bigl(u_{1}(x)+u_{0}(x),v(x) \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta _{t}u^{j-1/2}(x)+u^{j-1/2}(x),v(x) \bigr) \Biggr) \\ &\qquad{}+\beta \bigl(u^{k-1/2}(x),v(x) \bigr)+\lambda \biggl(\frac{\partial u^{k-1/2}(x)}{\partial x}, \frac{\partial v(x)}{\partial x} \biggr) \\ &\quad= \bigl(f^{k-1/2}(x),v(x) \bigr). \end{aligned}$$
(2.8)

For the semidiscrete problem, we have the following result.

Theorem 2.1

The semidiscrete problem (2.8) is unconditionally stable in the sense that, for all \(\tau \geq 0\),

$$\bigl\Vert u^{n} \bigr\Vert _{1}+2\tau\sum _{k=1}^{n} \bigl\Vert u^{k-1/2} \bigr\Vert _{1}^{2}\leq C \Bigl( \Vert u_{1} \Vert ^{2}+ \Vert u_{0} \Vert ^{2}+ \max _{1\leq k\leq K} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2} \Bigr), $$

where \(n=1,2,\ldots,K\), and \(C=\frac{\max\{\beta, \gamma\}}{\min\{ \beta , \gamma\}}+\frac{2T^{1-\alpha}}{\min\{\beta, \gamma\}\Gamma (2-\alpha )}+ \frac{\Gamma(1-\alpha)T^{1+\alpha}}{\min\{\beta, \gamma\}}\) is a constant.

Proof

Taking \(v = \delta_{t} u^{k-1/2}+u^{k-1/2}\) in (2.8), we have

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl( \delta _{t}u^{k-1/2}+u^{k-1/2}, \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr)-a_{k-1} \bigl(u_{1}+u_{0},\delta _{t}u^{k-1/2}+u^{k-1/2} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta _{t}u^{j-1/2}+u^{j-1/2}, \delta_{t}u^{k-1/2}+u^{k-1/2} \bigr) \Biggr) \\ &\qquad{}+\beta \bigl(u^{k-1/2},\delta_{t}u^{k-1/2}+u^{k-1/2} \bigr)+\lambda \biggl(\frac{\partial u^{k-1/2}}{\partial x },\frac{\partial\delta _{t}u^{k-1/2}+u^{k-1/2}}{\partial x} \biggr) \\ &\quad = \bigl(f^{k-1/2},\delta_{t}u^{k-1/2}+u^{k-1/2} \bigr). \end{aligned}$$
(2.9)

We first sum both sides of (2.9) for k from 1 to n, and then, using Lemma 2.2 and the Cauchy-Schwarz inequality for the first term of the left-hand side of (2.9), we obtain

$$\begin{aligned} &\sum_{k=1}^{n} \frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert ^{2}-a_{k-1} \bigl(u_{1}+u_{0},\delta _{t}u^{k-1/2}+u^{k-1/2} \bigr) \\ &\qquad{}-\sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta _{t}u^{j-1/2}+u^{j-1/2}, \delta_{t}u^{k-1/2}+u^{k-1/2} \bigr) \Biggr) \\ &\quad \geq \frac{1}{\Gamma(1-\alpha)\tau}\sum_{k=1}^{n} \Biggl(a_{0} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert -\sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl\Vert \delta _{t}u^{j-1/2}+u^{j-1/2} \bigr\Vert \\ &\qquad{}-a_{k-1} \Vert u_{1}+u_{0} \Vert \Biggr) \bigl\Vert \delta_{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert \\ &\quad \geq\frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)}\sum_{k=1}^{n} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert ^{2}-\frac{t_{n}^{1-\alpha}}{2\tau\Gamma (2-\alpha)} \Vert u_{1}+u_{0} \Vert ^{2}. \end{aligned}$$
(2.10)

The third term can be written as

$$\begin{aligned} &\lambda\sum_{k=1}^{n} \biggl(\frac{\partial u^{k-1/2}}{\partial x}, \frac{\partial\delta_{t}u^{k-1/2}+u^{k-1/2}}{\partial x} \biggr) \\ &\quad =\frac{\lambda}{2\tau}\sum _{k=1}^{n} \bigl( \bigl\vert u^{k} \bigr\vert _{1}^{2}- \bigl\vert u^{k-1} \bigr\vert _{1}^{2} \bigr)+\lambda\sum_{k=1}^{n} \bigl\vert u^{k-1/2} \bigr\vert _{1}^{2} \\ &\quad =\frac{\lambda}{2\tau} \bigl( \bigl\vert u^{n} \bigr\vert _{1}^{2}- \Vert u_{1} \Vert ^{2} \bigr)+\lambda\sum_{k=1}^{n} \bigl\vert u^{k-1/2} \bigr\vert _{1}^{2}. \end{aligned}$$
(2.11)

Similarly, the second term can be written as

$$\begin{aligned} &\beta \bigl(u^{k-1/2}(x),\delta_{t}u^{k-1/2}+u^{k-1/2} \bigr) \\ &\quad=\frac {\beta }{2\tau} \bigl( \bigl\Vert u^{n} \bigr\Vert ^{2}- \Vert u_{0} \Vert ^{2} \bigr)+\beta \sum_{k=1}^{n} \bigl\Vert u^{k-1/2} \bigr\Vert ^{2}. \end{aligned}$$
(2.12)

Using the Young inequality for the right-hand side of (2.9), we have

$$\begin{aligned} & \sum_{k=1}^{n} \bigl(f^{k-1/2},\delta_{t}u^{k-1/2}+u^{k-1/2} \bigr) \\ &\quad\leq\sum_{k=1}^{n} \biggl( \frac{\Gamma(1-\alpha)}{2 t_{n}^{-\alpha }} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2}+ \frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha )} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert ^{2} \biggr). \end{aligned}$$
(2.13)

From (2.10)-(2.13) we get the following relation:

$$\begin{aligned} &\frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)}\sum_{k=1}^{n} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert ^{2}-\frac{t_{n}^{1-\alpha}}{2\tau\Gamma (2-\alpha)} \Vert u_{1}+u_{0} \Vert ^{2} \\ &\qquad{}+\frac{\beta}{2\tau} \bigl( \bigl\Vert u^{n} \bigr\Vert ^{2}- \Vert u_{0} \Vert ^{2} \bigr)+\beta \sum_{k=1}^{n} \bigl\Vert u^{k-1/2} \bigr\Vert ^{2}+\frac{\lambda}{2\tau } \bigl( \bigl\vert u^{n} \bigr\vert _{1}^{2}- \Vert u_{1} \Vert ^{2} \bigr)+\lambda\sum _{k=1}^{n} \bigl\vert u^{k-1/2} \bigr\vert _{1}^{2} \\ &\quad \leq\sum_{k=1}^{n} \biggl( \frac{\Gamma(1-\alpha)}{2 t_{n}^{-\alpha }} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2}+ \frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha )} \bigl\Vert \delta _{t}u^{k-1/2}+u^{k-1/2} \bigr\Vert ^{2} \biggr). \end{aligned}$$
(2.14)

Denoting \(A:=\max\{\beta, \gamma\}\) and \(B:=\min\{\beta,\gamma\} \), we have

$$\begin{aligned} &\frac{B}{2\tau} \bigl\Vert u^{n} \bigr\Vert _{1}^{2}+B\sum_{k=1}^{n} \bigl\Vert u^{k-1/2} \bigr\Vert _{1}^{2} \\ &\quad \leq\frac{A}{2\tau} \bigl( \Vert u_{1} \Vert ^{2}+ \Vert u_{0} \Vert ^{2} \bigr)+\frac {t_{n}^{1-\alpha }}{2\tau\Gamma(2-\alpha)} \Vert u_{1}+u_{0} \Vert ^{2}+\frac{\Gamma(1-\alpha)}{2 t_{n}^{-\alpha}}\sum _{k=1}^{n} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2}. \end{aligned}$$
(2.15)

Multiplying both sides of this inequality at \(\frac{2\tau}{B}\), we obtain

$$\begin{aligned} & \bigl\Vert u^{n} \bigr\Vert _{1}^{2}+2\tau\sum_{k=1}^{n} \bigl\Vert u^{k-1/2} \bigr\Vert _{1}^{2} \\ &\quad \leq \frac{t_{n}^{1-\alpha}}{B \Gamma(2-\alpha )} \Vert u_{1}+u_{0} \Vert ^{2}+\frac{A}{B} \bigl( \Vert u_{1} \Vert ^{2}+ \Vert u_{0} \Vert ^{2} \bigr)+ \frac {\tau\Gamma(1-\alpha)t_{n}^{\alpha}}{B}\sum_{k=1}^{n} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2} \\ &\quad \leq \biggl(\frac{A}{B}+\frac{2t_{n}^{1-\alpha}}{B\Gamma(2-\alpha)}+ \frac{T\Gamma(1-\alpha)t_{n}^{\alpha}}{B} \biggr) \Bigl( \Vert u_{1} \Vert ^{2}+ \Vert u_{0} \Vert ^{2}+ \max_{1\leq k\leq n} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2} \Bigr) \\ &\quad \leq \biggl(\frac{A}{B}+\frac{2T^{1-\alpha}}{B\Gamma(2-\alpha)}+ \frac {\Gamma(1-\alpha)T^{1+\alpha}}{B} \biggr) \Bigl( \Vert u_{1} \Vert ^{2}+ \Vert u_{0} \Vert ^{2}+ \max_{1\leq k\leq K} \bigl\Vert f^{k-1/2} \bigr\Vert ^{2} \Bigr). \end{aligned}$$
(2.16)

The proof is completed. □

Theorem 2.2

Let \(u(x,t)\) (\(\{u^{k}=u(t_{k})\}_{k=0}^{K}\)) be the exact solution of (1.1), and \(\{u_{\varsigma}^{k}\}_{k=0}^{K}\) be the solution of variation (weak) formulation (2.8). Then we have the following error estimate:

$$\bigl\Vert u^{n}-u_{\varsigma}^{n} \bigr\Vert _{1}^{2}+2\tau\sum_{k=1}^{n} \bigl\Vert u^{n-1/2}-u_{\varsigma}^{n-1/2} \bigr\Vert _{1}^{2}\leq C \bigl(\tau ^{2-\alpha} \bigr)^{2}. $$

Proof

Denoting \(\rho^{k}=u^{k}-u_{\varsigma}^{k}\), we obtain

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl( \delta_{t}\rho ^{k-1/2}+ \rho^{k-1/2},v \bigr)- \sum _{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta_{t}\rho^{j-1/2}+\rho^{j-1/2},v \bigr) \Biggr) \\ &\qquad{}+\beta \bigl(u^{k-1/2},v \bigr)+\lambda \biggl(\frac{\partial\rho ^{k-1/2}}{\partial x}, \frac{\partial v}{\partial x} \biggr) \\ &\quad = \bigl(R^{k-1/2},v \bigr). \end{aligned}$$
(2.17)

Taking \(v=\delta_{t}\rho^{k-1/2}+\rho^{k-1/2}\) in (2.17) yields

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl( \delta_{t}\rho ^{k-1/2}+ \rho^{k-1/2}, \delta_{t}\rho^{k-1/2}+\rho^{k-1/2} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta_{t}\rho ^{j-1/2}+\rho ^{j-1/2}, \delta_{t}\rho^{k-1/2}+\rho^{k-1/2} \bigr) \Biggr) \\ &\qquad{}+\beta \bigl(u^{k-1/2},\delta_{t}\rho^{k-1/2}+ \rho^{k-1/2} \bigr)+\lambda \biggl(\frac{\partial\rho^{k-1/2}}{\partial x},\frac{\partial\delta _{t}\rho ^{k-1/2}+\rho^{k-1/2}}{\partial x} \biggr) \\ &\quad = \bigl(R^{k-1/2},\delta_{t}\rho^{k-1/2}+ \rho^{k-1/2} \bigr). \end{aligned}$$
(2.18)

Summing up for k from 1 to n and using Lemma 2.2, we obtain

$$\begin{aligned} & \sum_{k=1}^{n} \frac{1}{\tau\Gamma(1-\alpha)} \Biggl\{ a_{0} \bigl(\delta _{t} \rho^{k-1/2}+\rho^{k-1/2},\delta_{t}\rho^{k-1/2}+ \rho ^{k-1/2} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta_{t}\rho^{j-1/2}+\rho ^{j-1/2}, \delta_{t}\rho^{k-1/2}+\rho^{k-1/2} \bigr) \Biggr\} \\ &\quad \geq \frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)}\sum_{k=1}^{n} \bigl\Vert \delta _{t}\rho^{k-1/2}+\rho^{k-1/2} \bigr\Vert ^{2}. \end{aligned}$$
(2.19)

In addition, similarly to the proof of Theorem 2.1, we can write the following relations:

$$\begin{aligned} &\sum_{k=1}^{n} \bigl( \rho^{k-1/2},\delta_{t}\rho^{k-1/2}+\rho ^{k-1/2} \bigr)=\frac {1}{2\tau} \bigl\Vert \rho^{n} \bigr\Vert ^{2}+\sum_{k=1}^{n} \bigl\Vert \rho^{k-1/2} \bigr\Vert ^{2}, \end{aligned}$$
(2.20)
$$\begin{aligned} & \sum_{k=1}^{n} \biggl( \frac{\partial\rho^{k-1/2}}{\partial x},\frac {\partial \delta_{t}\rho^{k-1/2}+\rho^{k-1/2}}{\partial x} \biggr)=\frac{1}{2\tau } \bigl\vert \rho ^{n} \bigr\vert _{1}^{2}+\sum _{k=1}^{n} \bigl\vert \rho^{k-1/2} \bigr\vert _{1}^{2} \end{aligned}$$
(2.21)

and

$$\begin{aligned} \sum_{k=1}^{n} \bigl(R^{k-1/2},\delta_{t}\rho^{k-1/2}+ \rho^{k-1/2} \bigr)\leq{} &\frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)}\sum _{k=1}^{n} \bigl\vert \delta _{t}\rho ^{k-1/2}+\rho^{k-1/2} \bigr\vert _{0}^{2} \\ &{}+\frac{t_{n}^{\alpha}\Gamma(1-\alpha)}{2}\sum_{k=1}^{n} \bigl\Vert R^{k-1/2} \bigr\Vert _{0}^{2}. \end{aligned}$$
(2.22)

From (2.19)-(2.22) we obtain the following relation:

$$\begin{aligned} &\frac{\beta}{2\tau} \bigl\Vert \rho^{n} \bigr\Vert ^{2}+\beta\sum_{k=1}^{n} \bigl\Vert \rho ^{k-1/2} \bigr\Vert ^{2}+\frac{\lambda}{2\tau} \bigl\vert \rho^{n} \bigr\vert _{1}^{2}+\lambda\sum _{k=1}^{n} \bigl\vert \rho^{k-1/2} \bigr\vert _{1}^{2} \\ &\quad\leq\frac{t_{n}^{\alpha}\Gamma (1-\alpha )}{2}\sum _{k=1}^{n} \bigl\Vert R^{k-1/2} \bigr\Vert _{0}^{2}. \end{aligned}$$
(2.23)

From (2.7) we can find a constant \(C':=\frac{2C_{1}}{\Gamma (2-\alpha)}+C_{2}+C_{3}\) such that \(\vert R^{k-1/2} \vert \leq C'\tau^{2-\alpha}\). Similarly to (2.16), we obtain

$$\begin{aligned} \bigl\Vert \rho^{n} \bigr\Vert _{1}^{2}+2\tau\sum_{k=1}^{n} \bigl\Vert \rho ^{k-1/2} \bigr\Vert _{1}^{2}&\leq \frac{t_{n}^{\alpha}\Gamma(1-\alpha)}{B}\tau\sum_{k=1}^{n} \bigl\Vert R^{k-1/2} \bigr\Vert _{0}^{2} \\ &\leq\frac{T^{1+\alpha}\Gamma(1-\alpha)}{B} \max_{1\leq k\leq n} \bigl\Vert R^{k-1/2} \bigr\Vert _{0}^{2} \\ &\leq\frac{T^{1+\alpha}\Gamma(1-\alpha)}{B}{C^{\prime}}^{2} \bigl(\tau^{2-\alpha} \bigr)^{2}. \end{aligned}$$
(2.24)

Letting \(C=\frac{T^{1+\alpha}\Gamma(1-\alpha)}{B}{C^{\prime}}^{2}\), the theorem is proved. □

3 Full discretization

To simplify the notation, let \(\Omega=(-1,1)\). The Galerkin spectral discretization proceeds by approximating the solution by polynomials of high degree. To this end, we denote by \(P_{N}(\Omega)\) the space of all polynomials of degree ≤N with respect x. Then the discrete space, denoted by \(P_{N}^{0}(\Omega)\), is defined as follows: \(P_{N}^{0}(\Omega ):=H_{0}^{1}(\Omega)\cap P_{N}(\Omega)\).

Now we consider the spectral Galerkin discretization to problem (1.1) as follows. Find \(u_{N}^{k}(x)\in P_{N}^{0}(\Omega)\) such that, for all \(v_{N}(x)\in P_{N}^{0}(\Omega)\),

$$\begin{aligned} &\frac{1}{\Gamma(1-\alpha)\tau} \Biggl(a_{0} \bigl( \delta _{t}u_{N}^{k-1/2}(x)+u_{N}^{k-1/2}(x),v_{N}(x) \bigr)-a_{k-1} \bigl(\pi _{N}^{1} \bigl(u_{1}(x)+u_{0}(x) \bigr),v_{N}(x) \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta _{t}u_{N}^{j-1/2}(x)+u_{N}^{j-1/2}(x),v_{N}(x) \bigr) \Biggr) \\ &\qquad{}+\beta \bigl(u^{k-1/2}(x),v_{N}(x) \bigr)+\lambda \biggl( \frac{\partial u_{N}^{k-1/2}(x)}{\partial x},\frac{\partial v_{N}(x)}{\partial x} \biggr) \\ &\quad = \bigl(f^{k-1/2}(x),v_{N}(x) \bigr). \end{aligned}$$
(3.1)

For all \(\{u_{N}^{k}\}|_{k=0}^{K}\), the well-posed problem (3.1) is guaranteed by the well-known Lax-Milgram lemma. In this section, we would like to derive an error estimation for the full-discrete solution \(\{u_{N}^{k}\}|_{k=0}^{K}\). Let \(\pi_{N}^{1}\) be the \(H^{1}\)-orthogonal projection operation from \(H_{0}^{1}(\Omega)\) into \(P_{N}^{0}(\Omega )\), where

$$ \bigl(\nabla\pi_{N}^{1} u, \nabla v \bigr)=( \nabla u, \nabla v),\quad \forall v\in P_{N}^{0}(\Omega). $$
(3.2)

The following projection estimation is well known:

$$ \bigl\Vert v-\pi_{N}^{1}v \bigr\Vert _{1}\leq CN^{1-\omega} \Vert v \Vert _{\omega} \quad\mbox{if } v \in H^{\omega}(\Omega) \cap H_{0}^{1}(\Omega), \omega \geq1. $$
(3.3)

Lemma 3.1

Let \(\{u_{\varsigma}^{k}\}_{k=0}^{K}\) be the solution of the semidiscrete problem (2.8). Then there exists a constant C such that

$$\bigl\vert R_{N}^{k-1/2} \bigr\vert \leq C \bigl(N^{1-\omega}+\tau^{2-\alpha} \bigr), $$

where

$$\begin{aligned} R_{N}^{k-1/2}={}& \frac{1}{\tau\Gamma(1-\alpha)} \Biggl(a_{0} \bigl(\pi _{N}^{1} \delta_{t}u_{\varsigma}^{k-1/2}+\pi_{N}^{1}u_{\varsigma }^{k-1/2}- \delta_{t}u_{\varsigma}^{k-1/2}-u_{\varsigma}^{k-1/2} \bigr) \\ &{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\pi_{N}^{1}\delta _{t}u_{\varsigma}^{j-1/2}+ \pi_{N}^{1}u_{\varsigma}^{j-1/2}-\delta _{t}u_{\varsigma}^{j-1/2}-u_{\varsigma}^{j-1/2} \bigr) \\ &{}-a_{k-1} \bigl(\pi_{N}^{1}u_{1}+ \pi_{N}^{1}u_{0}-u_{1}-u_{0} \bigr) \Biggr) \\ &{}+\beta \bigl(\pi _{N}^{1} u^{k-1/2}-u^{k-1/2} \bigr). \end{aligned}$$
(3.4)

Proof

Using the triangle inequality, Lemma 3.1, and relation (3.3), we easily obtain that \(\vert R_{N} \vert \leq C(N^{1-\omega}+\tau ^{2-\alpha})\), where C depends on the norm of \(\{u_{\varsigma}^{k}\}_{k=0}^{K}\). □

Theorem 3.1

Let \(\{u_{\varsigma}^{k}\}_{k=0}^{K}\) be the solution of the semidiscrete problem (2.8), and \(\{u_{N}^{k}\}_{k=0}^{K}\) be the solution of the full-discrete problem (3.1). Suppose that \(\{u_{\varsigma}^{k}\}_{k=0}^{K} \in H^{\omega}(\Omega)\cap H_{0}^{1}(\Omega), \omega>1\). Then there exists a constant C such that

$$\bigl\Vert u_{\varsigma}^{n}-u_{N}^{n} \bigr\Vert _{1}\leq C \bigl(\tau^{2-\alpha }+N^{1-\omega} \bigr). $$

Proof

Subtracting (3.1) from (2.8) and using (3.2) give

$$\begin{aligned} &\frac{1}{\tau\Gamma(1-\alpha)} \Biggl\{ a_{0} \bigl( \pi_{N}^{1}\delta _{t}u_{\varsigma}^{k-1/2}- \delta_{t}u_{N}^{k-1/2},v_{N} \bigr) \\ &\qquad{}- \sum _{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\pi_{N}^{1}\delta_{t}u_{\varsigma }^{j-1/2}- \delta_{t}u_{N}^{j-1/2},v_{N} \bigr) \Biggr\} \\ &\qquad{}+\frac{1}{\tau\Gamma(1-\alpha)} \Biggl\{ a_{0} \bigl(\pi _{N}^{1}u_{\varsigma }^{k-1/2}-u_{N}^{k-1/2},v_{N} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\pi _{N}^{1}u_{\varsigma}^{\varsigma}{j-1/2}-u_{N}^{j-1/2},v_{N} \bigr) \Biggr\} \\ &\qquad{}+\beta \bigl(\pi_{N}^{1}\delta_{t}u_{\varsigma}^{k-1/2}- \delta _{t}u_{N}^{k-1/2},v_{N} \bigr) \\ &\qquad{}+ \lambda \biggl(\frac{\partial \pi_{N}^{1}u_{\varsigma}^{k-1/2}-u_{N}^{k-1/2}}{\partial x},\frac {\partial v_{N}}{\partial x} \biggr) \\ &\quad= \bigl(R_{N}^{k-1/2},v_{N} \bigr). \end{aligned}$$
(3.5)

To simplify the function, we let \(\phi_{N}^{k}=\pi _{N}^{1}u_{\varsigma }^{k}-u_{N}^{k}\). Taking \(v_{N}=\delta_{t}\phi_{N}^{k-1/2}+\phi _{N}^{k-1/2}\) yields

$$\begin{aligned} &\frac{1}{\tau\Gamma(1-\alpha)} \Biggl\{ a_{0} \bigl( \delta_{t}\phi _{N}^{k-1/2}+ \phi_{N}^{k-1/2}, \delta_{t}\phi_{N}^{k-1/2}+ \phi _{N}^{k-1/2} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta_{t}\phi _{N}^{j-1/2}+\phi _{N}^{j-1/2},\delta_{t}\phi_{N}^{k-1/2}+ \phi_{N}^{k-1/2} \bigr) \Biggr\} \\ &\qquad{}+\beta \bigl(\phi_{N}^{k-1/2},\delta_{t} \phi_{N}^{k-1/2}+\phi _{N}^{k-1/2} \bigr)+ \lambda \biggl(\frac{\partial \phi_{N}^{k-1/2}}{\partial x},\frac{\partial\delta_{t}\phi _{N}^{k-1/2}+\phi_{N}^{k-1/2}}{\partial x} \biggr) \\ &\quad = \bigl(R_{N}^{k-1/2},\delta_{t} \phi_{N}^{k-1/2}+\phi_{N}^{k-1/2} \bigr). \end{aligned}$$
(3.6)

Similarly to the proof of Theorem 2.1, we can write the following relations:

$$\begin{aligned} & \sum_{k=1}^{n} \frac{1}{\tau\Gamma(1-\alpha)} \Biggl\{ a_{0} \bigl(\delta _{t} \phi_{N}^{k-1/2}+\phi_{N}^{k-1/2}, \delta_{t}\phi _{N}^{k-1/2}+\phi _{N}^{k-1/2} \bigr) \\ &\qquad{}- \sum_{j=1}^{k-1}(a_{k-j-1}-a_{k-j}) \bigl(\delta_{t}\phi _{N}^{j-1/2}+\phi _{N}^{j-1/2},\delta_{t}\phi_{N}^{k-1/2}+ \phi_{N}^{k-1/2} \bigr) \Biggr\} \\ &\quad \geq\frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)}\sum_{k=1}^{n} \bigl\Vert \delta _{t}\phi_{N}^{k-1/2}+ \phi_{N}^{k-1/2} \bigr\Vert ^{2}, \end{aligned}$$
(3.7)
$$\begin{aligned} & \sum_{k=1}^{n} \bigl(\phi_{N}^{k-1/2},\delta_{t}\phi _{N}^{k-1/2}+\phi _{N}^{k-1/2} \bigr) \\ &\quad= \frac{1}{2\tau} \bigl( \bigl\Vert \phi_{N}^{n} \bigr\Vert ^{2}- \bigl\Vert \phi _{N}^{0} \bigr\Vert ^{2} \bigr)+\sum_{k=1}^{n} \bigl\Vert \phi^{k-1/2} \bigr\Vert ^{2}, \end{aligned}$$
(3.8)
$$\begin{aligned} & \sum_{k=1}^{n} \biggl(\frac{\partial\phi_{N}^{k-1/2}}{\partial x},\frac {\partial\delta_{t}\phi_{N}^{k-1/2}+\phi_{N}^{k-1/2}}{\partial x} \biggr) \\ &\quad=\frac{1}{2\tau} \bigl( \bigl\vert \phi_{N}^{n} \bigr\vert _{1}^{2}- \bigl\vert \phi _{N}^{0} \bigr\vert _{1}^{2} \bigr)+\sum_{k=1}^{n} \bigl\vert \phi^{k-1/2} \bigr\vert _{1}^{2}, \end{aligned}$$
(3.9)
$$\begin{aligned} & \sum_{k=1}^{n} \bigl\vert \bigl(R^{k-1/2},\delta_{t}\phi_{N}^{k-1/2}+ \phi _{N}^{k-1/2} \bigr) \bigr\vert \\ &\quad \leq \frac{t_{n}^{-\alpha}}{2\Gamma(1-\alpha)} \sum_{k=1}^{n} \bigl\Vert \delta_{t}\phi_{N}^{k-1/2}+\phi_{N}^{k-1/2} \bigr\Vert ^{2} +\frac{t_{n}^{\alpha}\Gamma(1-\alpha)}{2}\sum_{k=1}^{n} \bigl\Vert R_{N}^{k-1/2} \bigr\Vert _{0}^{2}. \end{aligned}$$
(3.10)

From (3.7)-(3.10) we obtain

$$\begin{aligned} &\frac{\beta}{2\tau} \bigl\Vert \phi_{N}^{n} \bigr\Vert ^{2}+\beta\sum _{k=1}^{n} \bigl\Vert \phi _{N}^{k-1/2} \bigr\Vert ^{2}\frac{\lambda}{2\tau} \bigl\vert \phi _{N}^{n} \bigr\vert _{1}^{2}+\lambda \sum_{k=1}^{n} \bigl\vert \phi_{N}^{k-1/2} \bigr\vert _{1}^{2} \\ &\quad \leq\frac{t_{n}^{\alpha}\Gamma(1-\alpha)}{2}\sum_{k=1}^{n} \bigl\Vert R_{N}^{k-1/2} \bigr\Vert ^{2}+ \frac{\lambda}{2\tau} \bigl\vert \phi ^{0} \bigr\vert _{1}^{2}+\frac{\beta}{2\tau} \bigl\Vert \phi^{0} \bigr\Vert ^{2}. \end{aligned}$$
(3.11)

Similarly to (2.16) we obtain

$$\begin{aligned} \bigl\Vert \phi_{N}^{n} \bigr\Vert _{1}^{2}+2\tau\sum_{k=1}^{n} \bigl\Vert \phi _{N}^{k-1/2} \bigr\Vert _{1}^{2} &\leq\frac{t_{n}^{\alpha}\Gamma(1-\alpha )}{B}\tau\sum _{k=1}^{n} \bigl\Vert R_{N}^{k-1/2} \bigr\Vert _{0}^{2}+\frac{A}{B} \bigl\Vert \phi ^{0} \bigr\Vert _{1}^{2} \\ &\leq\frac{T^{1+\alpha}\Gamma(1-\alpha)}{B} \max_{1\leq k\leq n} \bigl\Vert R_{N}^{k-1/2} \bigr\Vert _{0}^{2}+ \frac{A}{B} \bigl\Vert \phi^{0} \bigr\Vert _{1}^{2} \\ &\leq C \bigl(N^{1-\omega}+\tau^{2-\alpha} \bigr)^{2}. \end{aligned}$$
(3.12)

From the triangle inequality and (3.2) we obtain

$$ \bigl\Vert u_{\varsigma}^{n}-u_{N}^{n} \bigr\Vert _{1}\leq \bigl\Vert u_{\varsigma}^{n}-\pi _{N}^{1}u_{\varsigma}^{n} \bigr\Vert _{1}+ \bigl\Vert \phi_{N}^{n} \bigr\Vert _{1}\leq C \bigl(N^{1-\omega }+\tau^{2-\alpha} \bigr). $$
(3.13)

The proof of the theorem is completed. □

Theorem 3.2

Let \(u(x,t)\) (\(\{u^{k}=u(t_{k})\}_{k=0}^{K}\)) be the exact solution of (1.1), and \(\{u_{N}^{k}\}_{k=0}^{K}\) be the solution of the full-discrete problem (3.1). Suppose that \(\{u^{k}\}_{k=0}^{K} \in H^{\omega}(\Omega)\cap H_{0}^{1}(\Omega), \omega>1\). Then there exists a constant C such that

$$\bigl\Vert u^{n}-u_{N}^{n} \bigr\Vert _{1}\leq C \bigl(N^{1-\omega}+\tau^{2-\alpha} \bigr). $$

Proof

From Theorem 2.2, Theorem 3.1, and the triangle inequality we obtain

$$\bigl\Vert u^{n}-u_{N}^{n} \bigr\Vert _{1}\leq \bigl\Vert u^{n}-u_{\varsigma }^{n} \bigr\Vert _{1}+ \bigl\Vert u_{\varsigma}^{n}-u_{N}^{n} \bigr\Vert _{1}\leq C \bigl(N^{1-\omega }+\tau ^{2-\alpha} \bigr), $$

where \(\{u_{\varsigma}^{k}\}_{k=0}^{K}\) is the solution of the semidiscrete problem (2.8). □

4 Numerical examples

4.1 Implementation

Before numerical experiments, in this subsection, we briefly introduce an implementation.

Let \(L_{i}(x)\) be the ith-degree Legendre polynomial. They are mutually orthogonal in \(L^{2}(\Omega)\), that is,

$$ \bigl(L_{i}(x),L_{j}(x) \bigr)= \int_{\Omega}L_{i}(x)L_{j}(x)\,dx= \frac{2}{2k+1}\delta_{ij}, $$
(4.1)

where \(\delta_{ij}\) is the Kronecker delta symbol.

We define (see [18])

$$ \Phi_{i}(x)=L_{i}(x)-L_{i+2}(x). $$
(4.2)

One useful property of the Legendre polynomials is

$$ (2n+1)L_{n}(x)=L_{n+1}'(x)-L_{n-1}'(x), $$
(4.3)

which gives the relation

$$ \Phi_{i}'(x)=-(2i+3)L_{i+1}(x). $$
(4.4)

It is easy to verify that, for \(N\geq2\),

$$ P_{N}^{0}(\Omega)=\operatorname{span} \bigl\{ \Phi_{0}(x),\Phi_{1}(x),\ldots,\Phi_{N-2}(x) \bigr\} . $$
(4.5)

Let us denote

$$\begin{aligned} \begin{aligned} &u_{N}^{k}(x)= \sum _{j=0}^{N-2}\hat{(}u)_{j}^{k} \Phi_{j}(x),\qquad \hat {u}^{k}= \bigl(\hat{u}_{0}^{k}, \hat{u}_{1}^{k},\ldots,\hat{u}_{N-2}^{k} \bigr)^{T}, \\ &\hat{f}_{j}^{k}= \bigl(I_{N} f^{k}(x), \Phi_{j}(x) \bigr),\qquad \hat{f}^{k}= \bigl( \hat{f}_{0}^{k}, \hat {f}_{1}^{k},\ldots, \hat{f}_{N-2}^{k} \bigr)^{T}, \\ &\hat{u}_{0,j}= \bigl(\pi_{N}^{1} u_{0}(x),\Phi_{j}(x) \bigr),\qquad \hat{u}_{0}=(\hat {u}_{0,0},\hat {u}_{0,1},\ldots,\hat{u}_{0,N-2})^{T}, \\ &\hat{u}_{1,j}= \bigl(\pi_{N}^{1} u_{1}(x),\Phi_{j}(x) \bigr),\qquad\hat{u}_{1}=(\hat {u}_{1,0},\hat {u}_{1,1},\ldots,\hat{u}_{1,N-2})^{T}, \\ &m_{ij}= \bigl(\Phi_{j}(x),\Phi_{i}(x) \bigr),\qquad M=(m_{ij})_{i,j=0,1,\ldots,N-2}, \\ &p_{ij}= \bigl(\Phi_{j}'(x), \Phi_{i}'(x) \bigr),\qquad P=(p_{ij})_{i,j=0,1,\ldots,N-2}. \end{aligned} \end{aligned}$$
(4.6)

Then, scheme (3.1) leads to the following linear system: For \(k=1,2,\ldots,K\),

$$\begin{aligned} & \bigl(a_{0}(2+\tau)+\beta \tau^{2}\Gamma(1-\alpha) \bigr)M\hat {u}^{k}+\lambda \tau^{2}\Gamma(1-\alpha)P\hat{u}^{k} \\ &\quad = \bigl(a_{0}(2-\tau)-\beta\tau^{2}\Gamma(1-\alpha) \bigr)M\hat {u}^{k-1}-\lambda\tau^{2}\Gamma(1-\alpha)P \hat{u}^{k-1} \\ &\qquad{}+\sum_{l=1}^{k-1}(a_{k-l-1}-a_{k-l})M \bigl(2 \bigl(\hat{u}^{l}-\hat {u}^{l-1} \bigr)+\tau \bigl( \hat{u}^{l}+\hat{u}^{l-1} \bigr) \bigr) \\ &\qquad{}+2\tau a_{k-1}(\hat{u}_{1}+\hat{u}_{0})+ \tau^{2}\Gamma(1-\alpha) \bigl(\hat {f}^{k}+ \hat{f}^{k+1} \bigr). \end{aligned}$$
(4.7)

Using the orthogonality of Legendre polynomials, we can easily determine that the matrix M is pentadiagonal and P is diagonal. We easily obtain:

$$\begin{aligned} &m_{ij}=m_{ji}= \textstyle\begin{cases} \frac{2}{2j+1}+\frac{2}{2j+5},& i=j, \\ -\frac{2}{2j+5},& i=j\pm2, \\ 0& \mbox{otherwise}, \end{cases}\displaystyle \end{aligned}$$
(4.8)
$$\begin{aligned} & p_{ij}=p_{ji}= \textstyle\begin{cases} 4j+6,& i=j, \\ 0& \mbox{otherwise}. \end{cases}\displaystyle \end{aligned}$$
(4.9)

Hence, at each time step, we obtain a system of linear algebraic equations with different right-hand-side vectors. The matric in the left-hand side of (4.7) is banded, and the linear system (4.7) can be easily solved.

4.2 Numerical results

In this subsection, we carry out two numerical experiments and present some results to confirm our theoretical statements. The main purpose is to check the convergence behavior of the numerical solution with respect to the time step size τ and polynomial degree N used in the calculation. Here, all the calculations are carried out in Matlab.

Example 1

Consider the time-fractional telegraph equation (1.1) in \([-1,1]\times[0,1]\) with \(\beta=\lambda=1\) and the exact solution:

$$u(x,t)=t^{2}\sin(\pi x). $$

It can be checked that the corresponding forcing term, initial condition, and boundary condition are respectively

$$\begin{aligned} &f(x,t)=\frac{2\sin(\pi x)}{\Gamma(2-\alpha)}t^{1-\alpha}+\frac {2\sin (\pi x)}{\Gamma(3-\alpha)}t^{2-\alpha}+t^{2} \sin(\pi x)+\pi ^{2}t^{2}\sin (\pi x). \\ &u(x,0)=0,\qquad \frac{\partial u(x,t)}{\partial t} \Big\vert _{t=0}=0. \\ &u(-1,t)=u(1,t)=0. \end{aligned}$$

We solve this example using the proposed method with several values of \(\tau, N\), and α.

When \(\alpha=0.6\), as an example, the graphs of the exact solution and the numerical solution with \(\tau=\frac{1}{1{,}000}\) and \(N=48\) are shown in Figure 1.

Figure 1
figure 1

Example  1 . Graphs of the exact solution (left panel) and the numerical solution (right panel).

Figure 2 (left) shows the plot of the absolute \(L_{\infty}, L_{2}, H_{1}\) errors as functions of the time step size for \(N=24\) via \(\alpha=0.3\). Figure 2 (right) shows the plot of the absolute \(L_{\infty}, L_{2}, H_{1}\) errors as functions of polynomial degree N for \(\tau=\frac{1}{20{,}000}\) via \(\alpha=0.1\).

Figure 2
figure 2

Example  1 . Graphs of error as a function of the time step size τ (left panel) and the polynomial degree N (right panel).

Table 1 lists some numerical results when \(N=24\) (the degree of Lagrange polynomial), which shows that the convergence order of presented scheme in temporal direction is \(O(\tau^{2-\alpha})\), where \(\alpha=0.1, 0.5, 0.9\). Table 2 presents the errors in \(H_{1}\)-norm and the convergence orders of presented scheme in space direction with \(\tau=\frac{1}{20{,}000}\) and \(\alpha=0.1, 0.3\), respectively.

Table 1 \(\pmb{H_{1}}\) -errors and convergence orders obtained for Example  1 with \(\pmb{N=24}\)
Table 2 \(\pmb{H_{1}}\) -errors and convergence orders obtained for Example  1 with \(\pmb{\tau=\frac{1}{20{,}000}}\)

Example 2

The proposed method also can be used to solve another kind of time-fractional telegraph equation:

$$ D_{t}^{2\alpha}u(x,t)+D_{t}^{\alpha}u(x,t)+u(x,t)- \frac{\partial ^{2}}{\partial x^{2}}u(x,t)=f(x,t) $$
(4.10)

with exact solution

$$u(x,t)=t^{3}e^{-x^{2}}. $$

It can be checked that the corresponding forcing term, initial condition, and boundary condition are respectively

$$\begin{aligned} &f(x,t)=\frac{6e^{-x^{2}}}{\Gamma(4-2\alpha)}t^{3-2\alpha}+\frac {6e^{-x^{2}}}{\Gamma(4-\alpha)}t^{3-\alpha }+t^{3}e^{-x^{2}}- \bigl(4x^{2}-2 \bigr)e^{-x^{2}}t^{3}, \\ &u(x,0)=0,\qquad \frac{\partial u(x,t)}{\partial t}\Big|_{t=0}=0, \\ &u(-1,t)=u(1,t)=\frac{t^{3}}{e}. \end{aligned}$$

Figure 3 (left) shows the plot of the absolute \(L_{\infty}, L_{2}, H_{1}\) errors as functions of the time step size for \(N=24\) via \(\alpha=0.7\). Figure 3 (right) shows the plot of the absolute \(L_{\infty}, L_{2}, H_{1}\) errors as functions of polynomial degree N for \(\tau=\frac{1}{20{,}000}\) via \(\alpha=0.6\).

Figure 3
figure 3

Example  2 . Graphs of error as functions of the time step size τ (left panel) and the polynomial degree N (right panel).

Table 3 lists some numerical results when \(N=24\) (the degree of Lagrange polynomial) and \(\alpha=0.2, 0.4, 0.6, 0.8\), respectively, which shows that the time convergence order of the case \(0< \alpha< 0.5\) is \(\mathcal{O}(\tau^{2-2\alpha})\) and the time convergence order of the case \(0.5< \alpha< 1\) is \(\mathcal{O}(\tau ^{3-2\alpha})\). Table 4 presents the errors in \(H_{1}\)-norm and the convergence order of presented scheme in space direction with \(\tau=\frac{1}{20{,}000}\) and \(\alpha=0.1, 0.2, 0.6, 0.7\), respectively.

Table 3 \(\pmb{H_{1}}\) -errors and computational orders obtained for Example  2 with \(\pmb{N=24}\)
Table 4 \(\pmb{H_{1}}\) -errors and computational orders obtained for Example  2 with \(\pmb{\tau=\frac{1}{20{,}000}}\)

5 Concluding remarks

In this paper, we have proposed a new numerical method for the time-fractional telegraph equation with convergence order \(\mathcal {O}(\tau^{2-\alpha}+N^{1-\omega})\) in \(H_{1}\)-norm by combining the generalized finite difference method and spectral Galerkin method, and we have rigorously proved the stability and convergence of this method. By Example 1 we have verified the theoretical results. It is demonstrated that this method is an effective and high-accuracy numerical scheme for solving the time-fractional telegraph equation (1.1). Example 2 shows that the proposed method also can solve the other kind of time-fractional telegraph equation with convergence order \(\mathcal{O}(\tau^{2-2\alpha}+N^{1-\omega})\) when \(0<\alpha<0.5\) and convergence order \(\mathcal{O}(\tau^{3-2\alpha}+N^{1-\omega})\) when \(0.5<\alpha<1\).