1 Introduction

Fractional differential equations (FDEs) have a long history of applications in physics, chemistry, biology, engineering, economics, and many other scientific and engineering fields [1,2,3,4,5,6,7,8,9,10,11]. In most cases, analytical methods do not work well on most of FDEs, and even if they can be solved, the expressions of solution often contain infinite series or special functions, which are complicated or difficult to calculate [12, 13], so it is natural to resort to numerical approaches. Up to now, there are several numerical techniques to solve FDEs, such as the finite difference method (FDM) [14,15,16,17], the finite element method (FEM) [18,19,20], the discontinuous Galerkin method [21, 22], the spectral method [23,24,25,26,27,28], and so on.

In this paper, we consider the following variable-coefficient fractional diffusion-wave equation:

$$ {}^{C}_{0}{D}_{t}^{\gamma }u(x,t)= \mathcal{L}u(x,t)+g(x,t),\quad -1< x< 1, 0< t\leqslant T, $$
(1)

subject to the initial and boundary conditions

figure a

where \({}^{C}_{0}{D}_{t}^{\gamma }u\) (\(\gamma \in (1,2)\)) is the Caputo fractional derivative with respect to t of order γ,

$$ {}^{C}_{0}{D}_{t}^{\gamma }u(x,t)= \frac{1}{\varGamma (2-\gamma )} \int _{0}^{t}(t-s)^{1-\gamma }\frac{ \partial ^{2} u(x,s)}{\partial s^{2}}{ \,\mathrm{d}}s, $$

\(\varGamma (\cdot )\) is the gamma function,

$$\begin{aligned} \mathcal{L}u=\frac{\partial }{\partial x} \biggl(p(x)\frac{\partial u}{ \partial x} \biggr)-q(x)u, \end{aligned}$$

and the functions \(p(x)\geqslant c_{0}>0\), \(q(x)\geqslant 0\), and g are sufficiently smooth.

The fractional diffusion-wave equation is a mathematical model of some important physical phenomena [29]. When \(g\equiv 0\), Schneider and Wyss [30] obtained the solution of the equation with constant coefficients in the whole space and half-space by Green functions. Agrawal [31] obtained a general solution in terms of Mittag-Leffler functions in a bounded domain. Pskhu [32] constructed a fundamental solution for a fractional diffusion-wave equation with Dzhrbashyan–Nersesyan fractional differential operator with respect to t, with Riemann–Liouville and Caputo derivatives as its particular cases. Chen et al. [33] considered a fractional diffusion-wave equation with damping; by using the method of separation of variables the analytical solution is derived, an implicit difference scheme is constructed, and the stability and convergence of the scheme are proved by the energy method. For numerical approximation of problem (1)–(3) with constant coefficients, Sun and Wu [34] proposed a fully discrete difference scheme and analyzed the solvability, stability, and \(L^{\infty }\) convergence of the scheme by the energy method; its convergence rate is \(\mathrm{O}(\tau ^{3-\gamma }+h^{2})\), where τ and h are the time- and space-step sizes, respectively. Huang et al. [35] proposed two finite difference schemes with convergence rates \(\mathrm{O}(\tau +h^{2})\). Wang and Vong [36] proposed a compact difference scheme with convergence rate \(\mathrm{O}(\tau ^{2}+h^{4})\). For variable-coefficient case, Wang [37] developed a compact difference scheme for a class of variable-coefficient time fractional convection–diffusion-wave equations with convergence rate \(\mathrm{O}( \tau ^{3-\gamma }+h^{4})\).

In this paper, we aim to solve problem (1)–(3) by using two fully discrete spectral schemes, one based on the approximation of the Caputo fractional derivative, and the other based on the approximation of the Riemann–Liouville fractional integral operator. We give a detailed analysis of the stability and convergence of these two schemes. The first scheme is unconditionally stable, and its convergence rate in the \(H^{1}\) norm is \(\mathrm{O}(\tau ^{3-\gamma }+N^{1-m})\). By a delicate analysis the second scheme is conditionally stable, and its convergence rate in the \(L^{2}\) norm is \(\mathrm{O}(\tau ^{2}+N^{1-m})\).

The rest of the paper is organized as follows. We commence by reviewing some preliminaries and notations in the next section. In Sects. 3 and 4, we present formulations of two fully discrete spectral schemes and vigorously analyze their stability and convergence. Numerical experiments are presented in Sect. 5. We conclude by summary and discussion in the last section.

2 Preliminaries

In this section, we introduce some notations and lemmas, which will be used in the following sections.

Definition 1

([38, 39])

Let \(\alpha >0\). The left-side Riemann–Liouville fractional integral \({}_{0}{I}_{t}^{\alpha }f(t)\) of order α of a given function \(f(t)\) is defined by

$$ {}_{0}{I}_{t}^{\alpha }f(t)=\frac{1}{\varGamma (\alpha )} \int _{0}^{t} (t-s)^{\alpha -1}f(s)\,\mathrm{d}s,\quad t>0. $$

Definition 2

([38, 39])

Let \(n-1\leqslant \alpha < n\). The left-side Caputo fractional derivative \({}^{C}_{0}{D}_{t}^{\alpha }f(t)\) of order α of \(f(t)\) is defined by

$$ {}^{C}_{0}{D}_{t}^{\alpha }f(t)={}_{0}{I}_{t}^{n- \alpha }f^{(n)}(t)= \frac{1}{\varGamma (n-\alpha )} \int _{0}^{t}(t-s)^{n- \alpha -1}f^{(n)}(s) \,\mathrm{d}s,\quad t>0. $$

We have the following result by Theorem 3.8 in [38] (p. 54) for the Caputo fractional derivative

$$ {}_{0}{I}_{t}^{\alpha }{}^{C}_{0}{D}_{t}^{\alpha }f(t)=f(t)- \sum_{k=0}^{n-1}\frac{f^{(k)}(0)}{k!}t^{k}. $$
(4)

Let \(\varLambda =(-1,1)\), amd let N be a positive integer. By \(L_{w}^{2}(\varLambda )\) we denote the weighted \(L^{2}\)-space with weight function \(w(x)\) and inner product and norm defined as

$$ (u,v)_{w}= \int _{\varLambda }uv w\,\mathrm{d}x,\qquad \Vert v \Vert _{w}= \biggl( \int _{ \varLambda }v^{2} w\,\mathrm{d}x \biggr)^{\frac{1}{2}}. $$

Denote the norms of the Sobolev spaces \(W^{r,p}(\varLambda )\) by \(\Vert \cdot \Vert _{r,p}\), with the particular case \(H^{r}(\varLambda )\triangleq W^{r,2}(\varLambda )\) with seminorm \(|\cdot |_{r}\) and norm \(\Vert \cdot \Vert _{r}\), and

$$ H_{0}^{1}(\varLambda )= \bigl\{ v\in H^{1}(\varLambda ),v(\pm 1)=0 \bigr\} . $$

By \(\mathbb{P}_{N}(\varLambda )\) we denote the space of all polynomials on Λ of degree less than or equal to N. We also denote \(\mathbb{P}_{N}^{0}(\varLambda ):= \mathbb{P}_{N}(\varLambda )\cap H_{0} ^{1}(\varLambda )\).

For space-time functional spaces, we denote by \(L^{\infty }(0,T;H^{m}( \varLambda ))\) the space of measurable functions \(v:(0,T)\rightarrow H ^{m}(\varLambda )\) such that

$$ \Vert v \Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))} = \operatorname*{ess\,sup}_{t\in [0,T]} \bigl\Vert v(x,t) \bigr\Vert _{m}< \infty $$

and by \(C^{k} ([0,T];H^{m}(\varLambda ) )\) (\(0\leqslant k<\infty \)) be the space of k-times continuous differentiable functions \(v:[0,T]\rightarrow H^{m}(\varLambda )\) such that

$$ \Vert v \Vert _{C^{k}([0,T];H^{m}(\varLambda ))}=\sum_{i=0}^{k} \max_{t\in [0,T]} \bigl\Vert \partial _{t}^{i}v(x,t) \bigr\Vert _{m}< \infty . $$

For simplicity, we denote \(\partial _{s}^{k}=\frac{\partial ^{k}}{ \partial s^{k}}\). Throughout the paper, c denotes a generic positive constant.

Now we introduce some projection approximation results.

Let \(\pi _{N}^{1,0}\) be the \(H_{0}^{1}\)-orthogonal projection operator from \(H_{0}^{1}(\varLambda )\) onto \(\mathbb{P}_{N}^{0}\) such that for all \(u \in H_{0}^{1}(\varLambda )\),

$$ \bigl(\partial _{x}\pi _{N}^{1,0}u-\partial _{x}u,\partial _{x}v_{N} \bigr)=0,\quad \forall v_{N}\in \mathbb{P}_{N}^{0}. $$

For the projection operator \(\pi _{N}^{1,0}\), we have the following estimate.

Lemma 1

([40], p. 288)

Let \(k=0,1\) and \(m\geqslant k\). For all \(u \in H^{m}(\varLambda )\cap H_{0}^{1}(\varLambda )\), there exists a positive constant C, depending only on m, such that

$$ \bigl\Vert u-\pi _{N}^{1,0}u \bigr\Vert _{k} \leqslant CN^{k-m} \Vert u \Vert _{m}, $$

where C is a positive constant independent of N.

Define the modified projector \(\varPi _{N}^{1,0}: H_{0}^{1}(\varLambda ) \rightarrow \mathbb{P}_{N}^{0}\) such that

$$ \bigl(p(x)\partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr),\partial _{x}v_{N} \bigr)+ \bigl(q(x) \bigl(u- \varPi _{N}^{1,0}u\bigr),v_{N} \bigr)=0,\quad \forall v_{N}\in \mathbb{P}_{N} ^{0}. $$

We have the following lemma.

Lemma 2

For all \(u \in H_{0}^{1}(\varLambda )\), we have

$$ \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u-\varPi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \leqslant CN^{2-2m} \Vert u \Vert _{m}^{2},\quad m \geqslant 1, $$

where C is a positive constant independent of N.

Proof

By the definition of the operator \(\varPi _{N}^{1,0}\) and the Hölder inequality we deduce that

$$\begin{aligned} & \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u-\varPi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \\ &\quad = \bigl(p(x)\partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr),\partial _{x}\bigl(u-\pi _{N}^{1,0}u\bigr) \bigr)+ \bigl(q(x) \bigl(u-\varPi _{N}^{1,0}u\bigr),u-\pi _{N}^{1,0}u \bigr) \\ &\quad \leqslant \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u\bigr) \bigr\Vert _{p(x)} \bigl\Vert \partial _{x}\bigl(u- \pi _{N}^{1,0}u\bigr) \bigr\Vert _{p(x)}+ \bigl\Vert u-\varPi _{N}^{1,0}u \bigr\Vert _{q(x)} \bigl\Vert u-\pi _{N}^{1,0}u \bigr\Vert _{q(x)} \\ &\quad \leqslant \bigl( \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u\bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u- \varPi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \bigr)^{\frac{1}{2}} \bigl( \bigl\Vert \partial _{x}\bigl(u- \pi _{N}^{1,0}u\bigr) \bigr\Vert _{p(x)}^{2} + \bigl\Vert u-\pi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \bigr)^{ \frac{1}{2}} . \end{aligned}$$

Thus we obtain

$$ \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u-\varPi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \leqslant \bigl\Vert \partial _{x}\bigl(u-\pi _{N}^{1,0}u \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u- \pi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2}. $$

Therefore by the boundedness of \(p(x)\), \(q(x)\) and Lemma 1 we have

$$ \bigl\Vert \partial _{x}\bigl(u-\varPi _{N}^{1,0}u \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u-\varPi _{N}^{1,0}u \bigr\Vert _{q(x)}^{2} \leqslant CN^{2-2m} \Vert u \Vert _{m}^{2}, \quad m \geqslant 1, $$

The lemma is proved. □

The Poincaré inequality is a useful tool in the following analysis.

Lemma 3

For \(u(x)\in C^{1}[-1,1]\) with \(u(\pm 1)=0\), we have

$$ \Vert u \Vert \leqslant \frac{1}{\sqrt{2}} \Vert \partial _{x} u \Vert . $$

Proof

Since \(u(\pm 1)=0\), we can see that for all \(x\in (-1,1)\),

$$ u(x)= \int ^{x}_{-1}\partial _{s}u(s) \,\mathrm{d}s= \int ^{x}_{1}\partial _{s}u(s) \,\mathrm{d}s=- \int ^{1}_{x}\partial _{s}u(s) \,\mathrm{d}s. $$

Thus by Hölder’s inequality we get

$$\begin{aligned} \int _{-1}^{0} \bigl\vert u(x) \bigr\vert ^{2}{\,\mathrm{d}}x &\leqslant \int _{-1}^{0} \biggl( \int _{-1}^{x}{\,\mathrm{d}}s \int _{-1}^{x} \bigl\vert \partial _{s}u(s) \bigr\vert ^{2} {\,\mathrm{d}}s \biggr)\,\mathrm{d}x \\ &\leqslant \int _{-1}^{0} \bigl\vert \partial _{s}u(s) \bigr\vert ^{2}{\,\mathrm{d}}s \int ^{0}_{-1}(x+1)\,\mathrm{d}x \\ &=\frac{1}{2} \int ^{0}_{-1} \bigl\vert \partial _{s}u(s) \bigr\vert ^{2}{\,\mathrm{d}}s. \end{aligned}$$

Analogously, we have

$$ \int ^{1}_{0} \bigl\vert u(x) \bigr\vert ^{2}{\,\mathrm{d}}x \leqslant \int ^{1}_{0} \bigl\vert \partial _{s}u(s) \bigr\vert ^{2}{\,\mathrm{d}}s \int ^{1}_{0}(1-x)\,\mathrm{d}x= \frac{1}{2} \int ^{1}_{0} \bigl\vert \partial _{s}u(s) \bigr\vert ^{2}{\,\mathrm{d}}s. $$

Therefore by the above two inequalities we obtain

$$ \Vert u \Vert ^{2}= \int ^{0}_{-1} \bigl\vert u(x) \bigr\vert ^{2}{\,\mathrm{d}}x+ \int ^{1}_{0} \bigl\vert u(x) \bigr\vert ^{2} {\,\mathrm{d}}x\leqslant \frac{1}{2} \Vert \partial _{x}u \Vert ^{2}. $$

The proof is completed. □

3 The fully discrete Scheme I

In this section, we consider the formulation of the first fully discrete spectral scheme for (1)–(3), which is based on the approximation of the Caputo fractional derivative directly, and present the stability and convergence analysis of the scheme.

Let τ be the time-step size, let M be a positive integer, \(\tau =T/M\), and \(t_{k}=k\tau \), \(k=0,1,\ldots ,M\). For a given function w, we denote

$$\begin{aligned} &w^{k}=w(\cdot ,t_{k}),\qquad w^{k+\frac{1}{2}}= \frac{1}{2} \bigl(w^{k+1}+w^{k} \bigr), \\ &\delta _{t}w^{k+\frac{1}{2}}=\frac{1}{\tau } \bigl(w^{k+1}-w^{k} \bigr),\quad 0\leqslant k\leqslant M-1. \end{aligned}$$

3.1 Formulation of Scheme I

The first fully discrete scheme is based on the approximation of the Caputo fractional derivative of order \(\gamma \in (1,2)\). We use the \(L_{1}\) approximation coupled with the Crank–Nicolson technique as in [34, 37].

Denote \(\gamma _{0}=\tau ^{\gamma -1}\varGamma (3-\gamma )\) and \(b_{j}=(j+1)^{2- \gamma }-j^{2-\gamma }\), \(j\geqslant 0\), and for a differentiable function \(v(t)\), let

$$ L_{t}^{\gamma }v^{k+\frac{1}{2}}=\frac{1}{\gamma _{0}} \Biggl(\delta _{t}v ^{k+\frac{1}{2}}-\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \delta _{t}v^{k-j- \frac{1}{2}}-b_{k}v'(t_{0}) \Biggr) $$

for \(k=1,2,\ldots , M-1\).

We have the following lemma for the approximation of Caputo fractional derivative of order \(\gamma \in (1,2)\).

Lemma 4

([41], p. 122)

Let \(\gamma \in (1,2)\). Suppose that \(v(t)\in C^{3}[0,t_{k+1}]\) (\(0\leqslant k \leqslant M-1\)). Then

$$\begin{aligned} & \biggl\vert \frac{1}{2} \bigl({}^{C}_{0}{D}_{t}^{\gamma }v(t_{k+1}) +{}^{C}_{0}{D}_{t}^{\gamma }v(t_{k}) \bigr) -L_{t}^{\gamma }v ^{k+\frac{1}{2}} \biggr\vert \\ &\quad \leqslant \frac{1}{\varGamma (3-\gamma )} \biggl(\frac{2-\gamma }{12}+\frac{2^{3- \gamma }}{3-\gamma }- \bigl(1+2^{1-\gamma }\bigr)+\frac{1}{12} \biggr) \max_{t \in [0,t_{k+1}]} \bigl\vert v'''(t) \bigr\vert \tau ^{3-\gamma }. \end{aligned}$$

Next, we discretize the spatial component by the Legendre spectral method. Let \(u_{N}^{j}\in \mathbb{P}_{N}^{0}\) be the approximation of \(u(x,t)\) at \(t=t_{j}\), \(j=0,1,\ldots , M\). The first fully discrete spectral scheme (Scheme I) is: find \(u_{N}^{k+1}\in \mathbb{P}_{N} ^{0}\) such that

$$\begin{aligned} &\bigl(\delta _{t} u_{N}^{k+\frac{1}{2}},v_{N} \bigr)+\gamma _{0}\bigl(p(x)\partial _{x} u_{N}^{k+\frac{1}{2}},\partial _{x} v_{N}\bigr)+ \gamma _{0}\bigl(q(x)u_{N}^{k+ \frac{1}{2}},v_{N} \bigr) \\ &\quad =\gamma _{0}\bigl(g^{k+\frac{1}{2}},v_{N}\bigr)+\sum _{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl( \delta _{t}u_{N}^{k-1-j+\frac{1}{2}},v_{N} \bigr)+b_{k}(\psi ,v_{N}), \quad \forall v_{N}\in \mathbb{P}_{N}^{0}, \end{aligned}$$
(5)

for \(k=1,2,\ldots ,M-1\).

For given \(\{u_{N}^{j}\}_{j=0}^{k}\), the well-posedness of problem (5) is guaranteed by the Lax–Milgram lemma.

3.2 Stability and convergence analysis

In this subsection, we analyze the stability and convergence of Scheme I.

It is easy to verify that

$$ \textstyle\begin{cases} b_{i}>0, \quad i=0,1,\ldots ,k; \\ b_{k}< b_{k-1}< \cdots < b_{1}< b_{0}=1; \\ \sum_{i=0}^{k-1}(b_{i}-b_{i+1})+b_{k}=1. \end{cases} $$
(6)

Furthermore we have

$$ b_{j} =(j+1)^{2-\gamma }-j^{2-\gamma } =(2-\gamma ) \int _{j}^{j+1}s ^{1-\gamma }{\,\mathrm{d}}s \geqslant (2-\gamma ) (j+1)^{1-\gamma }. $$

For the stability of the fully discrete scheme (5), we have the following result.

Theorem 1

The fully discrete scheme (5) is unconditionally stable, that is, for all \(\tau >0\),

$$\begin{aligned} & \bigl\Vert \partial _{x} u_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u_{N}^{k+1} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant \bigl\Vert \partial _{x} u_{N}^{0} \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u_{N}^{0} \bigr\Vert _{q(x)} ^{2}+2\varGamma (2-\gamma )T^{\gamma -1} \tau \sum_{j=0}^{k} \bigl\Vert g^{j+ \frac{1}{2}} \bigr\Vert ^{2} +\frac{2T^{2-\gamma }}{\varGamma (3-\gamma )} \Vert \psi \Vert ^{2}. \end{aligned}$$

Proof

Taking \(v_{N}=\delta _{t}u_{N}^{k+\frac{1}{2}}\) in (5) yields

$$\begin{aligned} & \bigl\Vert \delta _{t} u_{N}^{k+\frac{1}{2}} \bigr\Vert ^{2}+\gamma _{0}\bigl(p(x)\partial _{x} u_{N}^{k+\frac{1}{2}},\partial _{x} \delta _{t}u_{N}^{k+\frac{1}{2}}\bigr)+ \gamma _{0} \bigl(q(x)u_{N}^{k+\frac{1}{2}},\delta _{t}u_{N}^{k+\frac{1}{2}} \bigr) \\ &\quad =\gamma _{0}\bigl(g^{k+\frac{1}{2}},\delta _{t}u_{N}^{k+\frac{1}{2}} \bigr)+ \sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(\delta _{t}u_{N}^{k-1-j+\frac{1}{2}}, \delta _{t}u_{N}^{k+\frac{1}{2}}\bigr) +b_{k}\bigl(\psi , \delta _{t}u_{N}^{k+ \frac{1}{2}}\bigr). \end{aligned}$$
(7)

For the last two terms on the left-hand side of (7), we have

$$\begin{aligned} \gamma _{0} \bigl(p(x)\partial _{x} u_{N}^{k+\frac{1}{2}},\partial _{x} \delta _{t}u_{N}^{k+\frac{1}{2}} \bigr) &=\frac{\gamma _{0}}{2\tau } \bigl(p(x),\bigl(\partial _{x} u_{N}^{k+1} \bigr)^{2}-\bigl(\partial _{x} u_{N}^{k} \bigr)^{2} \bigr) \\ &=\frac{\gamma _{0}}{2\tau } \bigl( \bigl\Vert \partial _{x} u_{N}^{k+1} \bigr\Vert _{p(x)} ^{2}- \bigl\Vert \partial _{x} u_{N}^{k} \bigr\Vert _{p(x)}^{2} \bigr) \end{aligned}$$
(8)

and

$$\begin{aligned} \gamma _{0} \bigl(q(x) u_{N}^{k+\frac{1}{2}}, \delta _{t}u_{N}^{k+ \frac{1}{2}} \bigr) &=\frac{\gamma _{0}}{2\tau } \bigl(q(x),\bigl( u_{N}^{k+1}\bigr)^{2}-\bigl( u_{N}^{k}\bigr)^{2} \bigr) \\ &\quad =\frac{\gamma _{0}}{2\tau } \bigl( \bigl\Vert u_{N}^{k+1} \bigr\Vert _{q(x)}^{2}- \bigl\Vert u_{N} ^{k} \bigr\Vert _{q(x)}^{2} \bigr), \end{aligned}$$
(9)

respectively.

For the terms on the right-hand side of (7), by Hölder’s and Young’s inequalities, we get

$$\begin{aligned} &\gamma _{0}\bigl(g^{k+\frac{1}{2}},\delta _{t}u_{N}^{k+\frac{1}{2}}\bigr) \leqslant \frac{\gamma _{0}^{2}}{b_{k}} \bigl\Vert g^{k+\frac{1}{2}} \bigr\Vert ^{2}+\frac{1}{4}b _{k} \bigl\Vert \delta _{t}u_{N}^{k+\frac{1}{2}} \bigr\Vert ^{2}, \end{aligned}$$
(10)
$$\begin{aligned} &\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(\delta _{t}u_{N}^{k-1-j+\frac{1}{2}}, \delta _{t}u_{N}^{k+\frac{1}{2}}\bigr) \\ &\quad \leqslant \frac{1}{2}\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl( \bigl\Vert \delta _{t}u_{N}^{k-1-j+\frac{1}{2}} \bigr\Vert ^{2}+ \bigl\Vert \delta _{t}u_{N}^{k+\frac{1}{2}} \bigr\Vert ^{2} \bigr) \\ &\quad = \frac{1}{2}\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl\Vert \delta _{t}u_{N}^{k-1-j+ \frac{1}{2}} \bigr\Vert ^{2}+\frac{1}{2}(1-b_{k}) \bigl\Vert \delta _{t}u_{N}^{k+ \frac{1}{2}} \bigr\Vert ^{2}, \end{aligned}$$
(11)

and

$$ b_{k}\bigl(\psi ,\delta _{t}u_{N}^{k+\frac{1}{2}} \bigr)\leqslant b_{k} \biggl( \Vert \psi \Vert ^{2}+ \frac{1}{4} \bigl\Vert \delta _{t}u_{N}^{k+\frac{1}{2}} \bigr\Vert ^{2} \biggr), $$
(12)

respectively.

Substituting (8)–(12) into (7), we obtain

$$\begin{aligned} &\tau \sum_{j=0}^{k}b_{j} \bigl\Vert \delta _{t}u_{N}^{k-j+\frac{1}{2}} \bigr\Vert ^{2}+ \gamma _{0} \bigl\Vert \partial _{x} u_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+\gamma _{0} \bigl\Vert u_{N} ^{k+1} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant \tau \sum_{j=0}^{k-1}b_{j} \bigl\Vert \delta _{t}u_{N}^{k-1-j+ \frac{1}{2}} \bigr\Vert ^{2}+\gamma _{0} \bigl\Vert \partial _{x} u_{N}^{k} \bigr\Vert _{p(x)}^{2}+ \gamma _{0} \bigl\Vert u_{N}^{k} \bigr\Vert _{q(x)}^{2}+2\tau b_{k} \Vert \psi \Vert ^{2} \\ &\qquad {} +\frac{2\tau \gamma _{0}^{2}}{b_{k}} \bigl\Vert g^{k+\frac{1}{2}} \bigr\Vert ^{2}. \end{aligned}$$
(13)

Let

$$ F^{0}=\gamma _{0} \bigl\Vert \partial _{x} u_{N}^{0} \bigr\Vert _{p(x)}^{2}+\gamma _{0} \bigl\Vert u _{N}^{0} \bigr\Vert _{q(x)}^{2} $$

and

$$ F^{k+1}=\tau \sum_{j=0}^{k}b_{j} \bigl\Vert \delta _{t}u_{N}^{k-j+\frac{1}{2}} \bigr\Vert ^{2}+\gamma _{0} \bigl\Vert \partial _{x} u_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+\gamma _{0} \bigl\Vert u _{N}^{k+1} \bigr\Vert _{q(x)}^{2}, $$

\(0\leqslant k\leqslant M-1\).

By (13) we have

$$ F^{k+1}\leqslant F^{k}+2\tau b_{k} \Vert \psi \Vert ^{2}+\frac{2\tau \gamma _{0}^{2}}{b_{k}} \bigl\Vert g^{k+\frac{1}{2}} \bigr\Vert ^{2}, $$

viz.,

$$ F^{k+1}\leqslant F^{0}+\tau \sum _{j=0}^{k}\frac{2\gamma _{0}^{2}}{b _{j}} \bigl\Vert g^{j+\frac{1}{2}} \bigr\Vert ^{2}+2\tau (k+1)^{2-\gamma } \Vert \psi \Vert ^{2}. $$
(14)

Since \(b_{j}\geqslant (2-\gamma )(j+1)^{1-\gamma }\), \(\varGamma (s+1)=s \varGamma (s)\), and \(\gamma _{0}=\varGamma (3-\gamma )\tau ^{\gamma -1}\), we obtain

$$ b_{j}^{-1}\leqslant \varGamma (2-\gamma ) \frac{T^{\gamma -1}}{\gamma _{0}}, \tau (k+1)^{2-\gamma }\leqslant \frac{\gamma _{0}T^{2-\gamma }}{\varGamma (3-\gamma )}. $$
(15)

Substituting (15) into (14) yields

$$ F^{k+1}\leqslant F^{0}+2\varGamma (2-\gamma )T^{\gamma -1} \gamma _{0} \tau \sum_{j=0}^{k} \bigl\Vert g^{j+\frac{1}{2}} \bigr\Vert ^{2}+\frac{2\gamma _{0}T^{2- \gamma }}{\varGamma (3-\gamma )} \Vert \psi \Vert ^{2}. $$

Then we deduce that

$$\begin{aligned} & \bigl\Vert \partial _{x} u_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u_{N}^{k+1} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant \bigl\Vert \partial _{x} u_{N}^{0} \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u_{N}^{0} \bigr\Vert _{q(x)} ^{2}+2\varGamma (2-\gamma )T^{\gamma -1} \tau \sum_{j=0}^{k} \bigl\Vert g^{j+ \frac{1}{2}} \bigr\Vert ^{2} +\frac{2T^{2-\gamma }}{\varGamma (3-\gamma )} \Vert \psi \Vert ^{2}. \end{aligned}$$

The proof is completed. □

Now we analyze the convergence of the fully discrete scheme (5).

Theorem 2

Let u be the solution of (1)(3), and let \(u_{N}^{k}\) (\(0 \leqslant k \leqslant M\)) be the solutions of (5) with the initial condition \(u_{N}^{0}=\varPi _{N}^{1,0}u_{0}\). Suppose that \(u\in C^{3} ([0,T];H^{1}(\varLambda ) )\cap L^{\infty } (0,T;H ^{m}(\varLambda ) )\), \({}^{C}_{0}{D}_{t}^{\gamma }u\in L^{ \infty } (0,T;H^{m}(\varLambda ) )\), \(\psi \in H^{m}(\varLambda )\), \(m\geqslant 1\). Then for \(1\leqslant k\leqslant M\), we have

$$\begin{aligned} & \bigl\Vert \partial _{x} \bigl(u(t_{k})-u_{N}^{k} \bigr) \bigr\Vert _{p(x)}^{2}+ \bigl\Vert u(t _{k})-u_{N}^{k} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant c\varGamma (2-\gamma )T^{\gamma } \bigl(N^{2-2m} \bigl\Vert {}^{C}_{0}{D}_{t}^{\gamma }u \bigr\Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2} +\tau ^{6-2\gamma } \Vert u \Vert _{C^{3}([0,T];H^{1}(\varLambda ))}^{2} \bigr) \\ &\qquad {}+\frac{\mathit{cT}^{2-\gamma }}{\varGamma (3-\gamma )}N^{2-2m} \Vert \psi \Vert _{m}^{2}+cN^{2-2m} \Vert u \Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2}, \end{aligned}$$

where c is a positive constant independent of N and γ.

Proof

Let \(e_{N}^{j}=u(t_{j})-u_{N}^{j}=\widetilde{e}_{N}^{j}+\widehat{e} _{N}^{j}\), \(\widetilde{e}_{N}^{j}=\varPi _{N}^{1,0}u(t_{j})-u_{N}^{j}\), \(\widehat{e}_{N}^{j}=u(t_{j})-\varPi _{N}^{1,0}u(t_{j})\). Obviously, \(\widetilde{e}_{N}^{0}=0\), \(e_{N}^{0}=u_{0}-\varPi _{N}^{1,0}u_{0}= \widehat{e}_{N}^{0}\). By the original equation (1) and the fully discrete scheme (5) we get the error equation

$$\begin{aligned} &\bigl(\delta _{t} e_{N}^{k+\frac{1}{2}},v_{N} \bigr)+\gamma _{0}\bigl(p(x)\partial _{x} e_{N}^{k+\frac{1}{2}},\partial _{x} v_{N}\bigr)+ \gamma _{0}\bigl(q(x)e_{N}^{k+ \frac{1}{2}},v_{N} \bigr) \\ &\quad =\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(\delta _{t}e_{N}^{k-1-j+\frac{1}{2}},v _{N} \bigr)+\gamma _{0}\bigl(R_{t}\bigl(u^{k+\frac{1}{2}} \bigr),v_{N}\bigr),\quad \forall v_{N} \in \mathbb{P}_{N}^{0}, \end{aligned}$$

where \(R_{t}(u^{k+\frac{1}{2}})=L_{t}^{\gamma }u^{k+\frac{1}{2}}- \frac{1}{2} ({}^{C}_{0}{D}_{t}^{\gamma }u(t_{k+1})+ {}^{C}_{0}{D}_{t}^{\gamma }u(t_{k}) )\).

By the definition of the projection operator \(\varPi _{N}^{1,0}\) we have

$$\begin{aligned} &\bigl(\delta _{t} \widetilde{e}_{N}^{k+\frac{1}{2}},v_{N} \bigr)+\gamma _{0}\bigl(p(x) \partial _{x} \widetilde{e}_{N}^{k+\frac{1}{2}},\partial _{x} v_{N}\bigr)+ \gamma _{0}\bigl(q(x)\widetilde{e}_{N}^{k+\frac{1}{2}},v_{N} \bigr) \\ &\quad =\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(\delta _{t}\widetilde{e}_{N}^{k-1-j+ \frac{1}{2}},v_{N} \bigr)+\gamma _{0}\bigl(R_{t}\bigl(u^{k+\frac{1}{2}} \bigr),v_{N}\bigr)+\sum_{i=1}^{2}R_{i}^{k+1}, \quad \forall v_{N}\in \mathbb{P}_{N}^{0}, \end{aligned}$$
(16)

where

$$\begin{aligned} &R_{1}^{k+1}=- \Biggl(\delta _{t} \widehat{e}_{N}^{k+\frac{1}{2}}-\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \delta _{t}\widehat{e}_{N}^{k-1-j+ \frac{1}{2}}-b_{k} \bigl(\psi -\varPi _{N}^{1,0}\psi \bigr), v_{N} \Biggr), \\ &R_{2}^{k+1}=-b_{k}\bigl(\psi -\varPi _{N}^{1,0}\psi ,v_{N}\bigr). \end{aligned}$$

Since

$$\begin{aligned} &\delta _{t}\widehat{e}_{N}^{k+\frac{1}{2}}-\sum _{j=0}^{k-1}(b_{j}-b _{j+1})\delta _{t}\widehat{e}_{N}^{k-1-j+\frac{1}{2}}-b_{k}\bigl( \psi -\varPi _{N}^{1,0}\psi \bigr) \\ &\quad =\gamma _{0} L_{t}^{\gamma }\widehat{e}_{N}^{k+\frac{1}{2}} \\ &\quad =\frac{\gamma _{0}}{2} \bigl({}^{C}_{0}{D}_{t}^{\gamma } \widehat{e}_{N}(t_{k+1})+{}^{C}_{0}{D}_{t}^{\gamma } \widehat{e}_{N}(t_{k}) \bigr)+\gamma _{0} R_{t}\bigl(\widehat{e}_{N}^{k+ \frac{1}{2}}\bigr), \end{aligned}$$

by Lemmas 2, 3, and 4 we obtain

$$\begin{aligned}& \begin{aligned}[b] \bigl\vert R_{1}^{k+1} \bigr\vert &\leqslant \frac{c\gamma _{0}^{2}}{b_{k}} \bigl(N^{2-2m} \bigl\Vert {}^{C}_{0}{D}_{t}^{\gamma }u \bigr\Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2} +\tau ^{6-2\gamma } \Vert u \Vert _{C^{3}([0,T];H^{1}(\varLambda ))}^{2} \bigr) \\ &\quad {}+\frac{1}{6}b_{k} \Vert v_{N} \Vert ^{2}, \end{aligned} \end{aligned}$$
(17)
$$\begin{aligned}& \bigl\vert R_{2}^{k+1} \bigr\vert \leqslant \mathit{cb}_{k}N^{2-2m} \Vert \psi \Vert _{m}^{2}+ \frac{1}{6}b_{k} \Vert v_{N} \Vert ^{2}, \end{aligned}$$
(18)

and

$$ \gamma _{0}\bigl(R_{t}\bigl(u^{k+\frac{1}{2}} \bigr),v_{N}\bigr) \leqslant \frac{c\gamma _{0}^{2}}{b_{k}}\tau ^{6-2\gamma } \Vert u \Vert _{C^{3}([0,T];L^{2}(\varLambda ))} ^{2}+\frac{1}{6}b_{k} \Vert v_{N} \Vert ^{2}, $$
(19)

respectively.

Using inequality (6), Hölder’s inequality, and Young’s inequality, we get

$$\begin{aligned} &\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(\delta _{t}\widetilde{e}_{N}^{k-1-j+ \frac{1}{2}},v_{N} \bigr) \\ &\quad \leqslant \frac{1}{2}\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl( \bigl\Vert \delta _{t} \widetilde{e}_{N}^{k-1-j+\frac{1}{2}} \bigr\Vert ^{2}+ \Vert v_{N} \Vert ^{2} \bigr) \\ &\quad =\frac{1}{2}\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl\Vert \delta _{t} \widetilde{e}_{N}^{k-1-j+\frac{1}{2}} \bigr\Vert ^{2}+\frac{1}{2}(1-b_{k}) \Vert v _{N} \Vert ^{2}. \end{aligned}$$
(20)

Substituting inequalities (17)–(20) into (16) and taking \(v_{N}=\delta _{t}\widetilde{e}_{N}^{k+ \frac{1}{2}}\), we deduce that

$$\begin{aligned} &\tau \sum_{j=0}^{k}b_{j} \bigl\Vert \delta _{t}\widetilde{e}_{N}^{k-j+ \frac{1}{2}} \bigr\Vert ^{2}+\gamma _{0} \bigl\Vert \partial _{x} \widetilde{e}_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+\gamma _{0} \bigl\Vert \widetilde{e}_{N}^{k+1} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant \tau \sum_{j=0}^{k-1}b_{j} \bigl\Vert \delta _{t}\widetilde{e}_{N} ^{k-1-j+\frac{1}{2}} \bigr\Vert ^{2}+\gamma _{0} \bigl\Vert \partial _{x} \widetilde{e}_{N} ^{k} \bigr\Vert _{p(x)}^{2}+\gamma _{0} \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert _{q(x)}^{2}+2 \tau b_{k}cN^{2-2m} \Vert \psi \Vert _{m}^{2} \\ &\qquad {}+\frac{2\tau \gamma _{0}^{2}}{b_{k}}c \bigl(N^{2-2m} \bigl\Vert {}^{C}_{0}{D}_{t}^{\gamma }u \bigr\Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2}+\tau ^{6-2\gamma } \Vert u \Vert _{C^{3}([0,T],H^{1}(\varLambda ))}^{2} \bigr). \end{aligned}$$

Analogously to the proof of Theorem 1, we obtain

$$\begin{aligned} & \bigl\Vert \partial _{x} \widetilde{e}_{N}^{k+1} \bigr\Vert _{p(x)}^{2}+ \bigl\Vert \widetilde{e} _{N}^{k+1} \bigr\Vert _{q(x)}^{2} \\ &\quad \leqslant c\varGamma (2-\gamma )T^{\gamma } \bigl(N^{2-2m} \bigl\Vert {}^{C}_{0}{D}_{t}^{\gamma }u \bigr\Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2}+\tau ^{6-2\gamma } \Vert u \Vert _{C^{3}([0,T];H^{1}(\varLambda ))}^{2} \bigr) \\ &\qquad {}+\frac{\mathit{cT}^{2-\gamma }}{\varGamma (3-\gamma )}N^{2-2m} \Vert \psi \Vert _{m}^{2}. \end{aligned}$$

Finally, applying the triangular inequality \(\|e_{N}^{k+1}\|\leqslant \|\widetilde{e}_{N}^{k+1}\|+\|\widehat{e}_{N}^{k+1}\|\) and Lemmas 2 and 3, we complete the proof. □

4 The second fully discrete spectral scheme

From Lemma 4 we can see that the temporal accuracy of the scheme (5) is of order \(3-\gamma \). In this section, we present the other fully discrete scheme based on the approximation of the Riemann–Liouville integral operator, which has second-order temporal accuracy. We also derive the stability and convergence of the scheme.

4.1 Scheme II

The second fully discrete spectral scheme is based on the fractional integro-differential equation, an equivalent form of the original equation.

By Definition 2 we can see that

$$ {}^{C}_{0}{D}_{t}^{\gamma }u(x,t) = \frac{1}{\varGamma (1-( \gamma -1))} \int _{0}^{t}(t-s)^{1-\gamma } \partial _{s} (\partial _{s} u )\,\mathrm{d}s ={}^{C}_{0}{D}_{t}^{\gamma -1} \bigl(\partial _{t} u(x,t) \bigr), $$

and by (4) we obtain

$$ {}_{0}{I}_{t}^{\gamma -1}{}^{C}_{0}{D}_{t}^{\gamma }u(x,t)= \partial _{t} u(x,t)-\psi (x). $$

Therefore an equivalent form of the original equation (1) is

$$ \partial _{t} u(x,t)={}_{0}{I}_{t}^{\alpha } \mathcal{L}u(x,t)+f(x,t)+ \psi (x), $$

where \(\alpha =\gamma -1\) and \(f(x,t)={}_{0}{I}_{t}^{\alpha }g(x,t)\).

There is no loss of generality in assuming that \(u(x,0)=\varphi (x) \equiv 0\). If \(u(x,0)=\varphi (x)\neq 0\), we can consider the equation for \(v(x,t)=u(x,t)-\varphi (x)\). For the discretization of the fractional integral operator \({}_{0}{I}_{t}^{\alpha }\), we can continuously extend the solution \(u(x,t)\) to be zero for \(t<0\). We use the weighted and shifted difference operator as in [36] (p. 9), viz.,

$$ {}_{0}{I}_{t}^{\alpha }u(\cdot ,t_{k+1})=\tau ^{\alpha }\sum_{j=0}^{k+1} \lambda _{j}^{(\alpha )}u(\cdot ,t_{k+1-j})+\mathrm{O}\bigl( \tau ^{2}\bigr), $$
(21)

where

$$ \lambda _{0}^{(\alpha )}= \biggl(1- \frac{\alpha }{2} \biggr)\omega _{0} ^{(\alpha )}, \qquad \lambda _{j}^{(\alpha )}= \biggl(1-\frac{\alpha }{2} \biggr) \omega _{j}^{(\alpha )}+\frac{\alpha }{2}\omega _{j-1}^{(\alpha )},\quad j\geqslant 1, $$
(22)

and \(\omega _{j}^{(\alpha )}=(-1)^{j}\binom{-\alpha }{j}\) for \(j\geqslant 0\).

Remark 1

We refer to [42] (p. 3) for the details of the second-order weighted and shifted Grünwald difference (WSGD) operator, and (21) is derived analogously.

For simplicity, we denote

$$ \mathrm{I}_{\tau }^{\alpha }u^{k+1}=\tau ^{\alpha } \sum_{j=0}^{k+1} \lambda _{j}^{(\alpha )}u^{k+1-j}, $$

based on the Crank–Nicolson-type discretization. The second fully discrete spectral scheme (Scheme II) is: find \(u_{N}^{k+1}\in \mathbb{P}_{N}^{0}\), \(k=0,1,\ldots ,M-1\), such that

$$\begin{aligned} \bigl(\delta _{t} u_{N}^{k+\frac{1}{2}},v_{N} \bigr) &=-\frac{1}{2} \bigl(p(x) \mathrm{I}_{\tau }^{\alpha } \partial _{x}\bigl(u_{N}^{k+1}+u_{N}^{k} \bigr), \partial _{x} v_{N} \bigr)-\frac{1}{2} \bigl(q(x)\mathrm{I}_{\tau }^{ \alpha }\bigl(u_{N}^{k+1}+u_{N}^{k} \bigr),v_{N} \bigr) \\ &\quad {}+\bigl(f^{k+\frac{1}{2}},v_{N}\bigr)+(\psi ,v_{N}),\quad \forall v_{N}\in \mathbb{P}_{N}^{0}. \end{aligned}$$
(23)

For given \(u_{N}^{j}\), \(j=0,1,\ldots ,k\), the Lax–Milgram lemma guarantees the well-posedness of problem (23).

4.2 Stability and convergence of scheme (23)

To analyze the stability and convergence of the fully discrete scheme (23), we recall and introduce some useful tools.

Lemma 5

(Discrete Grönwall’s inequality [43] (p. 369))

Let ν, B, and \(a_{\mu }\), \(b_{\mu }\), \(c_{\mu }\), \(\gamma _{ \mu }\) for integers \(\mu \geqslant 0\) be nonnegative numbers such that

$$ a_{n}+\nu \sum_{\mu =0}^{n} b_{\mu }\leqslant \nu \sum_{\mu =0}^{n} \gamma _{\mu }a_{\mu }+\nu \sum_{\mu =0} ^{n} c_{\mu }+B, \quad n\geqslant 0. $$

Suppose that \(\nu \gamma _{\mu }<1\) for all μ, and set \(\sigma _{\mu }\equiv (1-\nu \gamma _{\mu })^{-1}\). Then

$$ a_{n}+\nu \sum_{\mu =0}^{n} b_{\mu }\leqslant \exp \Biggl( \nu \sum_{\mu =0}^{n} \sigma _{\mu }\gamma _{\mu } \Biggr) \Biggl\{ \nu \sum _{\mu =0}^{n} c_{\mu }+B \Biggr\} ,\quad n\geqslant 0. $$

For the coefficients of \(\{\lambda _{n}^{(\alpha )}\}_{n=0}^{\infty }\), we have the following result.

Lemma 6

([36] (p. 9))

Let \(\{\lambda _{n}^{(\alpha )}\}_{n=0}^{\infty }\) be the series defined in (22). For any positive integer l and real vector \(( v_{1},v_{2},\ldots, v_{l})\in \mathbb{R}^{l}\), we have that

$$ \sum_{i=0}^{l-1} \Biggl(\sum _{j=0}^{i} \lambda _{j}^{(\alpha )}v_{i+1-j} \Biggr)v_{i+1}\geqslant 0. $$

We immediately get the following analogous result via the lemma.

Lemma 7

([44] (p. 386))

Let \(r(x)\) be a nonnegative continuous function. Then for any positive integer l and real continuous functions \(v_{1}(x)\), \(v_{2}(x)\), ..., \(v _{l}(x)\), we have

$$ \sum_{i=0}^{l-1} \Biggl(r(x)\sum_{j=0}^{i} \lambda _{j}^{( \alpha )}v_{i+1-j}(x),v_{i+1}(x) \Biggr)\geqslant 0, $$

where \((\cdot ,\cdot )\) denotes the inner product on Λ.

We have the following result for the stability of the fully discrete scheme (23).

Theorem 3

Suppose that \(\tau <1/2\). The fully discrete scheme (23) is stable, viz., for \(1\leqslant n\leqslant M\),

$$ \bigl\Vert u_{N}^{n} \bigr\Vert ^{2} \leqslant \exp \biggl({\frac{2T}{1-2\tau }} \biggr) \Biggl( \tau \sum _{k=0}^{n-1} \bigl\Vert f^{k+\frac{1}{2}} \bigr\Vert ^{2}+\tau \sum_{k=0}^{n-1} \Vert \psi \Vert ^{2} \Biggr). $$

Proof

Taking \(v_{N}=u_{N}^{k+1}+u_{N}^{k}\) in (23) yields

$$\begin{aligned} &\frac{1}{\tau } \bigl( \bigl\Vert u_{N}^{k+1} \bigr\Vert ^{2}- \bigl\Vert u_{N}^{k} \bigr\Vert ^{2} \bigr) \\ &\quad =-\frac{\tau ^{\alpha }}{2} \Biggl(p(x)\sum_{j=0}^{k} \lambda _{j}^{( \alpha )}\partial _{x} \bigl(u_{N}^{k+1-j}+u_{N}^{k-j} \bigr), \partial _{x} \bigl(u_{N}^{k+1}+u_{N}^{k} \bigr) \Biggr) \\ &\qquad {}-\frac{\tau ^{\alpha }}{2} \Biggl(q(x)\sum_{j=0}^{k} \lambda _{j}^{( \alpha )} \bigl(u_{N}^{k+1-j}+ u_{N}^{k-j} \bigr),u_{N}^{k+1}+u_{N} ^{k} \Biggr) \\ &\qquad {}+\bigl(f^{k+\frac{1}{2}},u_{N}^{k+1}+u_{N}^{k} \bigr)+\bigl(\psi ,u_{N}^{k+1}+u_{N} ^{k}\bigr). \end{aligned}$$
(24)

For the last two terms on the right-hand side of (24), using Hölder’s and Young’s inequalities, we have

$$ \bigl(f^{k+\frac{1}{2}},u_{N}^{k+1}+u_{N}^{k} \bigr) \leqslant \bigl\Vert f^{k+ \frac{1}{2}} \bigr\Vert ^{2}+ \frac{1}{2} \bigl\Vert u_{N}^{k+1} \bigr\Vert ^{2}+\frac{1}{2} \bigl\Vert u_{N} ^{k} \bigr\Vert ^{2} $$
(25)

and

$$ \bigl(\psi ,u_{N}^{k+1}+u_{N}^{k} \bigr) \leqslant \Vert \psi \Vert ^{2}+\frac{1}{2} \bigl\Vert u _{N}^{k+1} \bigr\Vert ^{2}+ \frac{1}{2} \bigl\Vert u_{N}^{k} \bigr\Vert ^{2}, $$
(26)

respectively.

Substituting (25) and (26) into (24), summing for k from 0 to \(n-1\), and using Lemma 7, we deduce that

$$\begin{aligned} \bigl\Vert u_{N}^{n} \bigr\Vert ^{2} & \leqslant -\frac{\tau ^{\alpha +1}}{2}\sum_{k=0} ^{n-1} \Biggl(p(x)\sum_{j=0}^{k}\lambda _{j}^{(\alpha )}\partial _{x} \bigl(u_{N}^{k+1-j}+u_{N}^{k-j} \bigr),\partial _{x} \bigl(u_{N} ^{k+1}+u_{N}^{k} \bigr) \Biggr) \\ &\quad {} -\frac{\tau ^{\alpha +1}}{2}\sum_{k=0}^{n-1} \Biggl(q(x)\sum_{j=0} ^{k}\lambda _{j}^{(\alpha )} \bigl( u_{N}^{k+1-j}+ u_{N}^{k-j} \bigr), u_{N}^{k+1}+u_{N}^{k} \Biggr) \\ &\quad {} +\tau \sum_{k=0}^{n-1} \bigl\Vert u_{N}^{k+1} \bigr\Vert ^{2}+\tau \sum _{k=0}^{n-1} \bigl\Vert u_{N}^{k} \bigr\Vert ^{2}+\tau \sum_{k=0}^{n-1} \bigl\Vert f^{k+\frac{1}{2}} \bigr\Vert ^{2}+ \tau \sum _{k=0}^{n-1} \Vert \psi \Vert ^{2} \\ &\leqslant 2\tau \sum_{k=0}^{n} \bigl\Vert u_{N}^{k} \bigr\Vert ^{2}+\tau \sum _{k=0}^{n-1} \bigl\Vert f^{k+\frac{1}{2}} \bigr\Vert ^{2}+\tau \sum_{k=0}^{n-1} \Vert \psi \Vert ^{2}. \end{aligned}$$

Thus by Lemma 5 we get

$$ \bigl\Vert u_{N}^{n} \bigr\Vert ^{2} \leqslant \exp \biggl({\frac{2T}{1-2\tau }} \biggr) \Biggl(\tau \sum _{k=0}^{n-1} \bigl\Vert f^{k+\frac{1}{2}} \bigr\Vert ^{2}+\tau \sum_{k=0} ^{n-1} \Vert \psi \Vert ^{2} \Biggr). $$

The proof of the theorem is completed. □

Remark 2

The restriction \(\tau <1/2\) can be removed by using a delicate analysis as in [34].

Now we consider the error estimate of the fully discrete scheme (23).

Theorem 4

Let u be the solution of (1)(3), let \(\{u_{N}^{k}\} _{k=0}^{M}\) be the solutions of problem (23) with the initial condition \(u_{N}^{0}=\varPi _{N}^{1,0} u_{0}(x)\). Assume that \(u \in L^{\infty } (0,T;H^{m}(\varLambda ) )\), \(\frac{\partial u}{ \partial t}\in L^{2} (0,T;H^{m}(\varLambda ) )\), \(m\geqslant 1\), and \(\tau <1/2\). Then we have

$$\begin{aligned} \bigl\Vert u(t_{k})-u_{N}^{k} \bigr\Vert &\leqslant \exp \biggl({\frac{2T}{1-2\tau }} \biggr) \bigl(c_{u}\tau ^{4}+cN^{2-2m} \Vert \partial _{t}u \Vert _{L^{2}(0,T;H^{m}(\varLambda ))}^{2} \bigr) \\ &\quad {}+cN^{2-2m} \Vert u \Vert _{L^{\infty }(0,T;H^{m}(\varLambda ))}^{2},\quad 1 \leqslant k\leqslant M, \end{aligned}$$

where c is a positive constant independent of N and τ, and \(c_{u}\) is a positive constant depending only on u.

Proof

Setting \(e_{N}^{j}=u^{j}-u_{N}^{j}=\widetilde{e}_{N}^{j}+\widehat{e} _{N}^{j}\), \(\widetilde{e}_{N}^{j}=\varPi _{N}^{1,0}u^{j}-u_{N}^{j}\), \(\widehat{e}_{N}^{j}=u^{j}-\varPi _{N}^{1,0}u^{j}\), particularly, \(\widetilde{e}_{N}^{0}=0\) and \(e_{N}^{0}=u^{0}-\varPi _{N}^{1,0}u^{0}= \widehat{e}_{N}^{0}\), by (1) and (23) we get

$$\begin{aligned} \bigl(\delta _{t} \widetilde{e}_{N}^{k+\frac{1}{2}},v_{N} \bigr) = &-\frac{ \tau ^{\alpha }}{2} \Biggl(p(x)\sum_{j=0}^{k} \lambda _{j}^{(\alpha )} \partial _{x} \bigl(e_{N}^{k+1-j}+e_{N}^{k-j} \bigr), \partial _{x} v_{N} \Biggr) \\ &-\frac{\tau ^{\alpha }}{2} \Biggl(q(x)\sum_{j=0}^{k} \lambda _{j}^{( \alpha )} \bigl( e_{N}^{k+1-j}+ e_{N}^{k-j} \bigr),v_{N} \Biggr) \\ & -\bigl(\delta _{t} \widehat{e}_{N}^{k+\frac{1}{2}},v_{N} \bigr)+\bigl(R_{N}^{k+1},v _{N}\bigr),\quad \forall v_{N}\in \mathbb{P}_{N}^{0}, \end{aligned}$$
(27)

where

$$\begin{aligned} R_{N}^{k+1}= &\delta _{t}u^{k+\frac{1}{2}}-\partial _{t}u^{k+\frac{1}{2}} +{}_{0}{I}_{t}^{\alpha } \mathcal{L}u^{k+\frac{1}{2}} - \frac{1}{2}\partial _{x} \bigl(p(x)\mathrm{I}_{\tau }^{\alpha }\partial _{x} \bigl(u^{k+1}+u^{k}\bigr) \bigr) \\ &+\frac{1}{2}q(x)\mathrm{I}_{\tau }^{\alpha } \bigl(u^{k+1}+u^{k}\bigr). \end{aligned}$$

By the Taylor formula and (21) we have \(|R_{N}^{k+1}|\leqslant c_{u}\tau ^{2}\).

Taking \(v_{N}=\widetilde{e}_{N}^{k+1}+\widetilde{e}_{N}^{k}\) in (27) yields

$$\begin{aligned} &\frac{1}{\tau } \bigl( \bigl\Vert \widetilde{e}_{N}^{k+1} \bigr\Vert ^{2}- \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert ^{2} \bigr) \\ &\quad =-\frac{\tau ^{\alpha }}{2} \Biggl(p(x)\sum_{j=0}^{k} \lambda _{j}^{( \alpha )}\partial _{x} \bigl(e_{N}^{k+1-j}+e_{N}^{k-j} \bigr), \partial _{x} \bigl(\widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \bigr) \Biggr) \\ &\qquad {}-\frac{\tau ^{\alpha }}{2} \Biggl(q(x)\sum_{j=0}^{k} \lambda _{j}^{( \alpha )} \bigl(e_{N}^{k+1-j}+ e_{N}^{k-j} \bigr),\widetilde{e}_{N} ^{k+1}+\widetilde{e}_{N}^{k} \Biggr) \\ &\qquad {}-\bigl(\delta _{t} \widehat{e}_{N}^{k+\frac{1}{2}}, \widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \bigr)+\bigl(R_{\tau }^{k+1},\widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k}\bigr). \end{aligned}$$
(28)

For the last two terms of the right-hand side of (28), by Hölder’s and Young’s inequalities we have

$$\begin{aligned} &{-}\bigl(\delta _{t}\widehat{e}_{N}^{k+\frac{1}{2}}, \widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \bigr) \\ &\quad =- \biggl(\frac{1}{\tau } \int _{t_{k}}^{t_{k+1}}\partial _{t}\widehat{e} _{N}{\,\mathrm{d}}t,\widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \biggr) \\ &\quad \leqslant \frac{1}{\tau } \int _{t_{k}}^{t_{k+1}} \Vert \partial _{t} \widehat{e}_{N} \Vert ^{2}{\,\mathrm{d}}t+\frac{1}{2} \bigl\Vert \widetilde{e}_{N}^{k+1} \bigr\Vert ^{2} +\frac{1}{2} \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert ^{2} \end{aligned}$$
(29)

and

$$ \bigl(R_{\tau }^{k+1},\widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k}\bigr) \leqslant \bigl\Vert R_{\tau }^{k+1} \bigr\Vert ^{2}+\frac{1}{2} \bigl\Vert \widetilde{e}_{N}^{k+1} \bigr\Vert ^{2}+\frac{1}{2} \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert ^{2}, $$
(30)

respectively.

Substituting (29) and (30) into (28), summing for k from 0 to \(n-1\), and using Lemmas 2 and 7, we have

$$\begin{aligned} \bigl\Vert \widetilde{e}_{N}^{n} \bigr\Vert ^{2} &\leqslant -\frac{\tau ^{\alpha +1}}{2} \sum_{k=0}^{n-1} \Biggl(p(x)\sum_{j=0}^{k}\lambda _{j}^{(\alpha )} \partial _{x} \bigl( \widetilde{e}_{N}^{k+1-j} +\widetilde{e}_{N}^{k-j} \bigr), \partial _{x} \bigl(\widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \bigr) \Biggr) \\ &\quad {}-\frac{\tau ^{\alpha +1}}{2}\sum_{k=0}^{n-1} \Biggl(q(x)\sum_{j=0}^{k} \lambda _{j}^{(\alpha )} \bigl(\widetilde{e}_{N}^{k+1-j}+ \widetilde{e}_{N}^{k-j} \bigr), \widetilde{e}_{N}^{k+1}+ \widetilde{e}_{N}^{k} \Biggr) \\ &\quad {}+ \int _{0}^{t_{n}} \Vert \partial _{t} \widehat{e}_{N} \Vert ^{2}{\,\mathrm{d}}t+ \tau \sum _{k=0}^{n-1} \bigl\Vert \widetilde{e}_{N}^{k+1} \bigr\Vert ^{2}+\tau \sum_{k=0} ^{n-1} \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert ^{2}+\tau \sum_{k=0}^{n-1} \bigl\Vert R_{\tau } ^{k+1} \bigr\Vert ^{2} \\ &\leqslant 2\tau \sum_{k=0}^{n} \bigl\Vert \widetilde{e}_{N}^{k} \bigr\Vert ^{2}+cN^{2-2m} \int _{0}^{T} \Vert \partial _{t} u \Vert _{m}^{2}{\,\mathrm{d}}t+c_{u}\tau ^{4}. \end{aligned}$$

By Lemma 5 we obtain

$$ \bigl\Vert \widetilde{e}_{N}^{n} \bigr\Vert ^{2} \leqslant \exp \biggl({\frac{2T}{1-2 \tau }} \biggr) \bigl(c_{u}\tau ^{4}+cN^{2-2m} \Vert \partial _{t}u \Vert _{L^{2}(0,T;H ^{m}(\varLambda ))}^{2} \bigr). $$

Finally, using the triangular inequality \(\|e_{N}^{n}\|\leqslant \| \widetilde{e}_{N}^{n}\|+\|\widehat{e}_{N}^{n}\|\) and Lemmas 2 and 3, we get the error estimate.

The proof is completed. □

5 Numerical experiments

In this section, we present numerical experiments to verify the theoretical results of two schemes.

5.1 Implementation

For the sake of implementation of two fully discrete schemes, all the integrals in (5) and (23) are evaluated by numerical quadratures from the practical and operational points of view as in [45]. Since the integrands in these integrals are polynomials with respect to x, we use the Legendre–Gauss–Lobatto quadrature to calculate these integrals.

Let \(L_{N}(x)\) be the Legendre polynomials of degree N, and let \(\{x_{j}\}_{j=0}^{N}\) be the zeros of \((1-x^{2})L_{N}^{\prime }(x)\). Then \(\{x_{j},\omega _{j}\}_{j=0}^{N}\) are referred to as the Legendre–Gauss–Lobatto quadrature nodes and weights, and the weights are

$$ \omega _{j}=\frac{2}{N(N+1)}\frac{1}{[L_{N}(x_{j})]^{2}},\quad 0\leqslant j \leqslant N. $$

We have the following quadrature:

$$ \int _{-1}^{1}\varphi (x)\,\mathrm{d}x=\sum _{j=0}^{N} \varphi (x_{j}) \omega _{j}, \quad \forall \varphi \in \mathbb{P}_{2N-1}(\varLambda ). $$

Define the discrete inner product

$$ (\phi ,\psi )_{N}=\sum_{j=0}^{N} \phi (x_{j})\psi (x_{j})\omega _{j}, \quad \forall \phi , \psi \in C^{0}(\overline{\varLambda }), $$

and the discrete norm \(\|\phi \|_{N}:=(\phi ,\phi )_{N}^{1/2}\).

The function \(u_{N}^{k}\) is expressed in terms of the Lagrangian interpolants \(h_{j}(x)\) based on the Legendre–Gauss–Lobatto points \(x_{j}\), \(j=0,1,\ldots ,N\),

$$ u_{N}^{k}(x)=\sum_{j=0}^{N} \widetilde{u}_{j}^{k}h_{j}(x), $$

where

$$ \widetilde{u}_{j}^{k}:=u_{N}^{k}(x_{j}), \qquad h_{j}(x_{i})=\delta _{ij}, \quad i,j=0,1, \ldots ,N, $$

and \(\delta _{\mathit{ij}}\) is the Kronecker delta symbol.

Letting \(\alpha =(\tau \gamma _{0})/2\), we can reform the first scheme (5) as

$$ \bigl(u_{N}^{k+1},v_{N} \bigr)_{N}+\alpha \bigl(p(x)\partial _{x}u_{N}^{k+1}, \partial _{x}v_{N} \bigr)_{N}+\alpha \bigl(q(x)u_{N}^{k+1},v_{N} \bigr) _{N}=F_{N}(v_{N}), $$
(31)

where

$$\begin{aligned} &F_{N}(v_{N}) \\ &\quad =\bigl(u_{N}^{k},v_{N}\bigr)_{N}+b_{k} \tau (\psi ,v_{N})_{N}-\alpha \bigl(p(x) \partial _{x} u_{N}^{k},\partial _{x}v_{N} \bigr)_{N}-\alpha \bigl(q(x) u_{N}^{k},v_{N} \bigr)_{N} \\ &\qquad {}+\sum_{j=0}^{k-1}(b_{j}-b_{j+1}) \bigl(u_{N}^{k-j}-u_{N}^{k-j-1},v_{N} \bigr)_{N}+2 \alpha \bigl(g^{k+\frac{1}{2}},v_{N} \bigr)_{N}. \end{aligned}$$

Since \(u_{N}^{k+1}(\pm 1)=0\), by choosing \(v_{N}\) to be \(h_{i}(x)\), \(i=1,2, \ldots ,N-1\), we have

$$ \sum_{j=1}^{N-1} \bigl( ( h_{j},h_{i} )_{N}+\alpha (p\partial _{x} h_{j},\partial _{x}h_{i} )_{N}+\alpha (q h_{j},h_{i} )_{N} \bigr)\widetilde{u}_{j}^{k+1} =F_{N}(h_{i}). $$

Let

$$\begin{aligned} &\mathbf{U}^{k+1}=\bigl(\widetilde{u}_{1}^{k+1}, \widetilde{u}_{2}^{k+1}, \ldots ,\widetilde{u}_{N-1}^{k+1} \bigr)^{\mathrm{T}}, \\ &\mathbf{F}^{k+1}=\bigl(F_{N}^{k+1}(h_{1}),F_{N}^{k+1}(h_{2}), \ldots ,F _{N}^{k+1}(h_{N-1})\bigr)^{\mathrm{T}}. \end{aligned}$$

Introduce the matrices

$$\begin{aligned} & \mathbf{A}=(A_{ij})= \bigl((h_{i},h_{j})_{N} \bigr)_{i,j=1}^{N-1},\qquad \mathbf{B}=(B_{ij})= \bigl( (p \partial _{x} h_{i},\partial _{x}h _{j} )_{N} \bigr)_{i,j=1}^{N-1}, \\ & \mathbf{C}=(C_{ij})= \bigl( (q h_{i},h_{j} )_{N} \bigr)_{i,j=1} ^{N-1}. \end{aligned}$$

Then the matrix form of problem (31) is

$$ (\mathbf{A}+\alpha \mathbf{B}+\alpha \mathbf{C} )\mathbf{U} ^{k+1}= \mathbf{F}^{k+1}. $$

By the definition of the discrete inner product we can get the elements of the matrices as

$$\begin{aligned} &A_{ij}=(h_{i},h_{j})_{N}=\omega _{i}\delta _{ij},\qquad B_{ij}=\sum _{l=0}^{N}p(x_{l})\partial _{x} h_{i}(x_{l})\partial _{x} h _{j}(x_{l})\omega _{l}, \\ &C_{ij}=q(x_{i})\omega _{i}\delta _{ij}. \end{aligned}$$

The implementation of the second scheme (23) is similar.

5.2 Numerical results

We carry out some numerical examples in this subsection to illustrate the theoretical statements.

Example 1

We consider equations (1)–(3) with \(p(x)=3-\sin x\), \(q(x)=1-\cos x\), and the source term

$$\begin{aligned} g(x,t)&= \frac{24}{\varGamma (5-\gamma )}t^{4-\gamma }\sin (\pi x)+t^{4} \sin ( \pi x) \bigl(1-\cos x+\pi ^{2}(3-\sin x) \bigr) \\ &\quad {}+\pi t^{4}\cos x\cos (\pi x), \quad x\in \varLambda . \end{aligned}$$

The exact solution is

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

Let \(N=25\), \(\tau =0.05\), and \(\gamma =1.1\). The exact solution of Example 1 is shown in Fig. 1, and numerical solutions by two schemes are shown in Figs. 2 and 3.

Figure 1
figure 1

The exact solution of Example 1

Figure 2
figure 2

The numerical solutions of Example 1 by Scheme I with \(N=25\), \(\tau =0.05\), \(\gamma =1.1\)

Figure 3
figure 3

The numerical solutions of Example 1 by Scheme II with \(N=25\), \(\tau =0.05\), \(\gamma =1.1\)

For \(T=1\), the exact solution and the numerical solutions of Example 1 are depicted in Fig. 4. From Figs. 14 we can seen that the numerical solutions of two schemes are very similar to the exact solution.

Figure 4
figure 4

The exact and numerical solution of Example 1 with \(N=25\), \(\tau =0.05\), \(\gamma =1.1\) at \(T=1\)

To confirm the temporal accuracy, we choose N large enough such that the space discretization error is negligible compared with the temporal error. Here we take \(N=25\) and \(T=1\). Table 1 lists the errors \(\|u(T)-u_{N}^{M}\|_{1}\) and temporal convergence orders of Scheme I, and Table 2 shows the errors \(\|u(T)-u_{N}^{M} \|\) and temporal convergence orders of Scheme II, which are consistent with our theoretical analysis. The convergence order is given by the formula

$$ \text{Order}= \frac{\log e_{1}-\log e_{2}}{\log \tau _{1}-\log \tau _{2}}, $$

where \(e_{i}\) is the error corresponding to \(\tau _{i}\), \(i=1,2\).

Table 1 \(H^{1}\) errors and temporal convergence orders of Scheme I for Example 1
Table 2 \(L^{2}\) errors and temporal convergence rates of Scheme II for Example 1

Next, we verify the spatial accuracy with respect to the polynomial degree N. By fixing the time step small enough to reduce the contamination of the temporal error, we illustrate the case of \(\tau =0.001\) and \(\gamma =1.5\). As we can see from Fig. 5, the errors of the numerical solutions decay exponentially in approximate lines as the polynomial degree N is increased. This is the so-called spectral accuracy.

Figure 5
figure 5

\(\gamma =1.5\), \(\tau =0.001\), errors of Example 1 versus the polynomial degree N

Example 2

(Finite regular solution)

We consider problem (1)–(3) with \(p(x)=2-\sin x\), \(q(x)=1+\cos x\), and the source term

$$\begin{aligned} &g(x,t) \\ &\quad =\frac{6}{\varGamma (4-\gamma )}t^{3-\gamma }(1-x) (1+x)^{2}x^{ \frac{16}{3}}+t^{3}(1+ \cos x) (1-x) (1+x)^{2}x^{\frac{16}{3}} \\ &\qquad {}-\frac{2}{9}t^{3}(2-\sin x) \bigl(104+152x-209x^{2}-275x^{3} \bigr)x^{ \frac{10}{3}} \\ &\qquad {}+ \frac{t^{3}}{3}\cos x \bigl(16+19x-22x^{2}-25x^{3} \bigr)x^{\frac{13}{3}}, \quad x\in \varLambda . \end{aligned}$$

The exact solution is

$$ u(x,t)=t^{3}(1-x) (1+x)^{2}x^{\frac{16}{3}}, $$

which has finite regularity (we can readily to verify that \(u\in H ^{5}(\varLambda )\) but \(u\notin H^{6}(\varLambda )\)).

For comparison, we depict the exact and numerical solutions at different times T in Fig. 6. Here we choose \(N=50\), \(\tau =0.05\), and \(\gamma =1.1\). The black curve denotes the exact solution, blue “O” represents the numerical solution of Scheme I and red “+” denotes the numerical solution of Scheme II. Different curves with symbols “O” and “+” represent the true solution and numerical solutions at different time T, respectively. The exact solution and numerical solutions match well at different times T as shown in Fig. 6, which illustrates that two numerical schemes effectively approximate the exact solution.

Figure 6
figure 6

The exact and numerical solutions of Example 2 with \(N=50\), \(\tau =0.05\), \(\gamma =1.1\)

We take \(N=100\), which is large enough such that the space discretization error is negligible compared with the temporal error. Table 3 lists the errors \(\|u(T)-u_{N}^{M}\|_{1}\) and temporal convergence orders of Scheme I, and Table 4 shows the errors \(\|u(T)-u_{N}^{M}\|\) and temporal convergence orders of Scheme II for Example 2, which are consistent with our theoretical analysis. Here we choose \(T=1\).

Table 3 \(H^{1}\) errors and temporal convergence orders of Scheme I for Example 2
Table 4 \(L^{2}\) errors and temporal convergence orders of Scheme II for Example 2

Now we investigate the spatial accuracy with respect to the polynomial degree N. We fix the time step \(\tau =0.001\) to avoid the contamination of the temporal error and illustrate the case \(\gamma =1.5\).

In Fig. 7, we present the errors with respect to the polynomial degree N in a log-log scale for Example 2. Since its exact solution belongs to \(H^{5}(\varLambda )\), but not to \(H^{6}(\varLambda )\), we can see from Fig. 7 that the convergence rate is between \(N^{-4}\) and \(N^{-5}\), which conforms with our theoretical analysis.

Figure 7
figure 7

\(\gamma =1.5\), \(\tau =0.001\), errors of Example 2 versus the polynomial degree N

6 Conclusions

In this paper, we presented and analyzed two fully discrete spectral schemes for the fractional diffusion-wave equation with variable coefficients in a bounded domain, one based on its original form and the other based on its equivalent fractional integro-differential form. The stability and convergence of two schemes were rigorously established. We carried out some numerical experiments to support the theoretical results. From numerical examples we can seen that two numerical schemes work well on time-fractional diffusion-wave equations, no matter the solution is sufficiently smooth or of finite regularity. The schemes presented in the paper can also be extended to solve two- or three-dimensional time fractional diffusion-wave equations on rectangular or cubical domains.