1 Introduction

Fractional differential equations have proved to be valuable tools in the modeling of many different processes and systems. Some applications of these equations in various fields of science and engineering can be found in [1, 3, 16, 18, 19, 21, 3133, 35, 39, 43, 46, 49]. Fractional convection-subdiffusion equations describe a special type of anomalous diffusion process, and have been considered by a number of researches (see [13, 14, 20, 34, 36]).

Although analytic solutions of fractional differential equations can be found in some special cases (see [39]), in general it is difficult to obtain them for most of the equations. In general cases, numerical methods have become important in obtaining the approximate solutions of fractional differential equations. The finite difference method is one of the most popular numerical methods used for solving time and/or space fractional differential equations (see [57, 11, 15, 22, 26, 50, 51, 54, 56, 57]). There are also a few other interesting studies by the finite element method [4, 23, 55], the spectral method [2, 24, 25], the implicit meshless method [17] and the radial basis function approximation method [29].

In recent years, a great deal of work has been devoted to numerical methods for fractional convection-subdiffusion equations. We mention only a few works here. Liu et al. [27] and Shen et al. [44] proposed some implicit and explicit difference methods for space-time fractional convection-subdiffusion equations. The authors of [8] and [58] developed some numerical methods for a variable-order convection-subdiffusion equation with a nonlinear source term. A radial basis function approximation method was implemented in [47] for a time fractional convection-subdiffusion equation on a bounded domain. A finite element method for a space fractional convection-subdiffusion equation with non-homogeneous initial-boundary conditions was given in [58]. Saadatmandi et al. [41] constructed a Sinc–Legendre collocation method for a class of fractional convection-subdiffusion equations. A numerical technique for a two-dimensional fractional convection-subdiffusion equation on a finite domain was proposed in [9]. More recently, Liu’s group discussed the radial basis function approximation methods for a fractional mobile/immobile convection-subdiffusion equation [30] and analyzed the finite difference methods for a time variable fractional order mobile/immobile convection-subdiffusion equation [52] and a class of fractional convection-diffusion equations that include four different fractional convection-subdiffusion equations [28].

In all above works, the proposed methods are convergent only with second-order spatial accuracy. To improve the spatial accuracy, Cui [12] and Mohebbi et al. [37] proposed, respectively, a compact exponential method and a compact finite difference method for a time fractional convection-subdiffusion equation so that the spatial accuracy is improved to the fourth-order. However, their methods and analyses are only for the equations with constant coefficients. In particular, the discussions in [37] are limited to a special time fractional convection-subdiffusion equation where the diffusion and convection coefficients are assumed to be one. In the real world, the coefficients in the equations are usually spatially and/or temporally variable. This motivated us to look for high-order numerical methods that can be efficiently used to solve time fractional convection-subdiffusion equations with variable coefficients. This paper is to report our finding in this effort. Specifically, we will propose and analyze a high-order compact finite difference method for a class of time fractional convection-subdiffusion equations with variable convection coefficients. The class of equations under consideration is given by

$$\begin{aligned}&\beta _{2}\frac{\partial ^{\alpha } v}{\partial t^{\alpha }}(x,t)+\beta _{1} \frac{\partial v}{\partial t}(x,t)=d \displaystyle \frac{\partial ^{2} v}{\partial x^{2}}(x,t) -p(x) \frac{\partial v}{\partial x}(x,t) \nonumber \\&\quad +f(x,t),\quad (x,t)\in (0,L)\times (0,T) \end{aligned}$$
(1.1)

with the boundary conditions

$$\begin{aligned} v(0,t)=\phi _{0}(t),\quad v(L,t)=\phi _{L}(t),\qquad t\in (0,T], \end{aligned}$$
(1.2)

and the initial condition

$$\begin{aligned} v(x,0)=\varphi (x),\qquad x\in [0,L], \end{aligned}$$
(1.3)

where \(\beta _{1}\), \(\beta _{2}\) and \(d\) are known parameters with \(\beta _{1}\ge 0\), \(\beta _{2}>0\) and \(d>0\), and the fractional derivative \(\frac{\partial ^{\alpha } v}{\partial t^{\alpha }}\) is given in the Caputo’s sense:

$$\begin{aligned} \frac{\partial ^{\alpha } v}{\partial t^{\alpha }}(x,t)=\frac{1}{\Gamma (1-\alpha )} \int _{0}^{t} \frac{\partial v}{\partial s}(x,s) (t-s)^{-\alpha }\mathrm{d}s, \qquad 0<\alpha <1. \end{aligned}$$
(1.4)

In terms of convection-diffusion problems, the first two terms on the right-hand side of (1.1) describe “diffusion” and “convection”, respectively. In particular, \(d\) is called the diffusivity or diffusion coefficient and \(p(x)\) is referred to as the average convective velocity or convection coefficient. If \(\beta _{1}=0\), Eq. (1.1) is just the commonly discussed time fractional convection-subdiffusion equations (see [12, 28, 37, 53] and the references therein). If \(\beta _{1}\not =0\), Eq. (1.1) governs a fractal mobile/immobile transport process and is called the time fractional mobile/immobile subdiffusion equation (\(p(x)\equiv 0\)) (see [30]) or the fractional mobile/immobile convection-subdiffusion equation (\(p(x)\not \equiv 0\)) (see [28, 52, 53] and the references therein).

When the coefficient \(p(x)\) is independent of the variable \(x\), i.e., \(p(x)\equiv p\) is a constant, some numerical treatments to Eq. (1.1) with the boundary and initial conditions (1.2) and (1.3) were given in [28]. The main purpose there is to present a stable implicit numerical method by the basic finite difference discretization. The accuracy of the method proposed in that paper is only of order \(\mathcal{O}(\beta _{2}\tau ^{2-\alpha }+\beta _{1}\tau +h)\), where \(\tau \) is the time step and \(h\) is the spatial step. In [10], a finite difference method was developed to solve a fractional Fokker–Planck equation which is formally a convection-subdiffusion equation with a spatially variable convection coefficient. That method can be directly applied to the Eq. (1.1) when \(\beta _{1}=0\), but its accuracy is only of order \(\mathcal{O}(\tau ^{2-\alpha }+h^{2})\). As mentioned before, the compact finite difference methods given by Cui [12] and Mohebbi et al. [37] improve the spatial accuracy to the fourth-order. However, their methods and analyses are only for time fractional convection-subdiffusion equations with constant coefficients and cannot be generalized to the present equation (1.1). In this paper, we propose a high-order compact finite difference method for the problem (1.1)–(1.3), where the coefficient \(p(x)\) may be spatially variable. In our method, we use a fourth-order compact finite difference approximation for the spatial discretization and apply the \(L_{1}\) approximation [10, 38, 45] coupled with the Crank–Nicolson technique for the temporal discretization. The resulting difference scheme from this new method has the local truncation error \(\mathcal{O}(\tau ^{2-\alpha }+h^{4})\). Moreover, it is stable and convergent with the same order as the truncation error, and thus improves the known methods.

Unlike the constant coefficient case, a direct compact difference discretization of Eq. (1.1) in the same manner as in [12, 37] is much more complicated. One inconvenience is that it is often not clear how to analyze theoretically the resulting schemes due to the dependence on the spatial variable \(x\) of \(p(x)\). In order to overcome this difficulty, we here use an indirect approach by transforming (1.1) into a special and equivalent form. This approach makes it possible to apply the idea and technique for time fractional subdiffusion equations to the present time fractional convection-subdiffusion equation. The main advantage behind this approach is that it yields a very simple and effective high-order scheme for the variable convection coefficient problems, especially when the equation is not convection dominated. More importantly, it is very convenient for us to use the discrete energy method to carry out the stability and convergence analyses of the derived scheme for the present variable coefficient problem.

The outline of the paper is as follows. In Sect. 2, we transform Eq. (1.1) into a special and equivalent form, and then discretize the equivalent form into a finite difference system. The local truncation error and the solvability of the resulting finite difference scheme are discussed in Sect. 3. In Sects. 4 and 5, we use the discrete energy method to prove the stability and convergence of the proposed method, and provide the optimal error estimates (i.e., the error estimate with the same order as the truncation error) of the numerical solution in the discrete \(H^{1}\), \(L^{2}\) and \(L^{\infty }\) norms. In Sect. 6, we give some applications to several model problems, and use some numerical results to confirm the theoretical analysis and to illustrate the effectiveness of this new method. The final section contains some concluding remarks.

2 Compact finite difference method

Assume that the coefficient \(p(x)\) is integrable in \(x\in [0,L]\). Let

$$\begin{aligned} v(x,t)=\exp \left( \frac{1}{2d}\int _{0}^{x}p(s)\mathrm{d}s \right) u(x,t). \end{aligned}$$

We transform the problem (1.1)–(1.3) into

$$\begin{aligned} \left\{ \begin{array}{l} \displaystyle \beta _{2}\frac{\partial ^{\alpha } u}{\partial t^{\alpha }}(x,t)+\beta _{1} \frac{\partial u}{\partial t}(x,t)=d \displaystyle \frac{\partial ^{2} u}{\partial x^{2}}(x,t)+q(x) u(x,t)+g(x,t),\quad (x,t)\in (0,L)\times (0,T),\\ u(0,t)=\phi _{0}^{*}(t),\quad u(L,t)=\phi _{L}^{*}(t),\qquad t\in (0,T],\\ u(x,0)=\varphi ^{*}(x), \qquad x\in [0,L], \end{array} \right. \end{aligned}$$
(2.1)

where

$$\begin{aligned} \begin{aligned} q(x)&=\frac{1}{2}\left( \frac{\mathrm{d} p}{\mathrm{d} x}(x)-\frac{p^{2}(x)}{2d}\right) , \\ g(x,t)&=\exp \left( -\frac{1}{2d} \int _{0}^{x} p(s) \mathrm{d}s \right) f(x,t), \quad \phi _{0}^{*}(t)=\phi _{0}(t), \\ \phi _{L}^{*}(t)&=\exp \left( -\frac{1}{2d} \int _{0}^{L}p(s) \mathrm{d}s \right) \phi _{L}(t),\qquad \\ \varphi ^{*}(x)&=\exp \left( -\frac{1}{2d} \int _{0}^{x} p(s) \mathrm{d}s \right) \varphi (x). \end{aligned} \end{aligned}$$
(2.2)

It is clear that \(v(x,t)\) is a solution of (1.1)–(1.3) if and only if \(u(x,t)=\exp \left( -\frac{1}{2d} \int _{0}^{x} p(s) \mathrm{d}s \right) v(x,t)\) is a solution of (2.1).

Our compact finite difference method for the problem (1.1)–(1.3) is based on the above equivalent form (2.1). For a positive integer \(N\), we let \(\tau =T/N\) be the time step. Denote \(t_{n}=n\tau \) \((0\le n\le N)\) and \(t_{n-\frac{1}{2}}=(n-\frac{1}{2})\tau \) \((1\le n\le N)\). Given a grid function \(w=\{w^{n}~|~0\le n\le N\}\), we define

$$\begin{aligned} w^{n-\frac{1}{2}}=\frac{1}{2}\left( w^{n}+w^{n-1}\right) ,\qquad \delta _{t}w^{n-\frac{1}{2}}=\frac{1}{\tau }\left( w^{n}-w^{n-1}\right) . \end{aligned}$$

Let \(h=L/M\) be the spatial step, where \(M\) is a positive integer. We partition \([0,L]\) into a mesh by the mesh points \(x_{i}=ih\) \((0\le i\le M)\). Denote \(x_{i-\frac{1}{2}}=(i-\frac{1}{2})h\) \((1\le i\le M)\). For any grid function \(w=\{w_{i}~|~0\le i\le M\}\), we define spatial finite difference operators

$$\begin{aligned}&\delta _{x}w_{i-\frac{1}{2}}=\frac{1}{h}\left( w_{i}-w_{i-1} \right) ,\quad \delta _{x}^{2}w_{i}=\frac{1}{h^{2}} \left( w_{i+1}-2w_{i}+w_{i-1}\right) ,\\&\quad \mathcal{H}_{x}w_{i}=\left( I+\frac{h^{2}}{12}\delta _{x}^{2}\right) w_{i}, \end{aligned}$$

where \(I\) denotes the identical operator. Let \(u(x,t)\) be the solution of (2.1), and define the grid functions

$$\begin{aligned} \begin{array}{llll} U_{i}^{n}=u(x_{i},t_{n}),\quad &{} W_{i}^{n}=\displaystyle \frac{\partial u}{\partial t}(x_{i},t_{n}), \quad &{} Z_{i}^{n}=\displaystyle \frac{\partial ^{2} u}{\partial x^{2}}(x_{i},t_{n}), \quad &{} q_{i}=q(x_{i}),\\ g_{i}^{n}=g({x}_{i},t_{n}),\quad &{} \phi _{0}^{*,n}=\phi _{0}^{*}(t_{n}),&{} \phi _{L}^{*,n}=\phi _{L}^{*}(t_{n}),&{} \varphi _{i}^{*}=\varphi ^{*}(x_{i}). \end{array} \end{aligned}$$

We now discretize (2.1) into a finite difference system. Let \(\mu =\tau ^{\alpha } \Gamma (2-\alpha )\) and let

$$\begin{aligned} a_{k}=(1-\alpha ) \int _{k}^{k+1} t^{-\alpha } \mathrm{d}t =(k+1)^{1-\alpha }-k^{1-\alpha }, \qquad k=0,1,\ldots . \end{aligned}$$

Using the \(L_{1}\) approximation of \(\frac{\partial ^{\alpha } u}{\partial t^{\alpha }}(x,t)\) at \((x_{i},t_{n})\) (see [10, 38, 45]), we have

$$\begin{aligned} \displaystyle \frac{\partial ^{\alpha } u}{\partial t^{\alpha }}(x_{i},t_{n})= \frac{1}{\mu }\left( U_{i}^{n}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k}-a_{n-1}U_{i}^{0}\right) -(R_{t}^{\alpha })_{i}^{n}, \end{aligned}$$
(2.3)

where the truncation error \((R_{t}^{\alpha })_{i}^{n}\) satisfies

$$\begin{aligned} \left| (R_{t}^{\alpha })_{i}^{n}\right| \le \frac{1}{\Gamma (2-\alpha )}\left( \frac{1-\alpha }{12}+\frac{2^{2-\alpha }}{2-\alpha }-1-2^{-\alpha }\right) \max _{0\le t\le t_{n}}\left| \frac{\partial ^{2}u}{\partial t^{2}}(x_{i},t)\right| \tau ^{2-\alpha }. \qquad \end{aligned}$$
(2.4)

Substituting (2.3) into the first equation of (2.1), we obtain

$$\begin{aligned}&\frac{\beta _{2}}{\mu }\left( U_{i}^{n}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k}-a_{n-1}U_{i}^{0}\right) +\beta _{1} W_{i}^{n}\nonumber \\&\quad =d \displaystyle Z_{i}^{n}+q_{i}U_{i}^{n}+g_{i}^{n}+\beta _{2} (R_{t}^{\alpha })_{i}^{n},\qquad 1\le i\le M-1, ~~1\le n\le N. \end{aligned}$$
(2.5)

For the second-order spatial derivative \(Z_{i}^{n}\), we adopt the following fourth-order compact approximation (see, e.g., [54]):

$$\begin{aligned} \mathcal{H}_{x}Z_{i}^{n}=\delta _{x}^{2}U_{i}^{n}+(R_{x})_{i}^{n}, \end{aligned}$$
(2.6)

where

$$\begin{aligned} (R_{x})_{i}^{n}=\frac{h^{4}}{360}\int _{0}^{1}\left( \frac{\partial ^{6}u}{\partial x^{6}}({x}_{i}-sh,t_{n})+\frac{\partial ^{6}u}{\partial x^{6}}({x}_{i}+sh,t_{n})\right) \zeta (s) \mathrm{d}s \end{aligned}$$
(2.7)

with \(\zeta (s)=5(1-s)^{3}-3(1-s)^{5}\). Multiplying (2.5) by \(\mu \) and then applying \(\mathcal{H}_{x}\) to both sides yields

$$\begin{aligned}&\beta _{2} \mathcal{H}_{x}\left( U_{i}^{n}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k}-a_{n-1}U_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}W_{i}^{n} \nonumber \\&\quad =\mu \left( d \displaystyle \delta _{x}^{2}U_{i}^{n}+\mathcal{H}_{x}\left( q_{i}U_{i}^{n}\right) +\mathcal{H}_{x}g_{i}^{n}+(R_{xt}^{(1)})_{i}^{n} \right) , \quad 1\le i\le M-1, 1\le n\le N,\nonumber \\ \end{aligned}$$
(2.8)

where

$$\begin{aligned} (R_{xt}^{(1)})_{i}^{n}=\beta _{2}\mathcal{H}_{x}(R_{t}^{\alpha })_{i}^{n}+d(R_{x})_{i}^{n}. \end{aligned}$$
(2.9)

Case 1. \(\beta _{1}\not =0\). In this case, it is necessary to discretize \(W_{i}^{n}\). On the time level \(n-1\), we have

$$\begin{aligned}&\beta _{2} \mathcal{H}_{x}\left( U_{i}^{n-1}-\sum \limits ^{n-2}_{k=1}(a_{n-k-2}-a_{n-k-1})U_{i}^{k}-a_{n-2}U_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}W_{i}^{n-1} \nonumber \\&\quad =\mu \left( d \displaystyle \delta _{x}^{2}U_{i}^{n-1}+\mathcal{H}_{x}\left( q_{i}U_{i}^{n-1}\right) +\mathcal{H}_{x}g_{i}^{n-1}+(R_{xt}^{(1)})_{i}^{n-1} \right) , \nonumber \\&\qquad 1\le i\le M-1, ~2\le n\le N. \end{aligned}$$
(2.10)

Since

$$\begin{aligned} -\sum \limits ^{n-2}_{k=1}(a_{n-k-2}-a_{n-k-1})U_{i}^{k}-a_{n-2}U_{i}^{0}=-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k-1}-a_{n-1}U_{i}^{0}, \end{aligned}$$

Eq. (2.10) can be reformulated as

$$\begin{aligned}&\beta _{2} \mathcal{H}_{x}\left( U_{i}^{n-1}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k-1}-a_{n-1}U_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}W_{i}^{n-1} \nonumber \\&\quad =\mu \left( d \displaystyle \delta _{x}^{2}U_{i}^{n-1}+\mathcal{H}_{x}\left( q_{i}U_{i}^{n-1}\right) +\mathcal{H}_{x}g_{i}^{n-1}+(R_{xt}^{(1)})_{i}^{n-1} \right) , \nonumber \\&\qquad 1\le i\le M-1, 2\le n\le N. \end{aligned}$$
(2.11)

Letting \(t=0\) in (2.1), it holds that \(\beta _{1}W_{i}^{0}=d Z_{i}^{0}+q_{i}U_{i}^{0}+g_{i}^{0}\) which implies that (2.11) holds true also for \(n=1\) with \((R_{xt}^{(1)})_{i}^{0}=d (R_{x})_{i}^{0}\). Taking the arithmetic mean of (2.8) and (2.11), we conclude that

$$\begin{aligned}&\beta _{2} \mathcal{H}_{x}\left( U_{i}^{n-\frac{1}{2}}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k-\frac{1}{2}}-a_{n-1}U_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}W_{i}^{n-\frac{1}{2}} \nonumber \\&\quad =\mu \left( d \displaystyle \delta _{x}^{2}U_{i}^{n-\frac{1}{2}}+\mathcal{H}_{x}\left( q_{i}U_{i}^{n-\frac{1}{2}}\right) +\mathcal{H}_{x}g_{i}^{n-\frac{1}{2}}+(R_{xt}^{(1)})_{i}^{n-\frac{1}{2}} \right) ,\nonumber \\&\qquad 1\le i\le M-1, ~~1\le n\le N. \end{aligned}$$
(2.12)

An application of the Crank–Nicolson technique (see, e.g., [54]) gives

$$\begin{aligned} W_{i}^{n-\frac{1}{2}}=\delta _{t}U_{i}^{n-\frac{1}{2}}+(R_{t}^{c})_{i}^{n-\frac{1}{2}}, \qquad 1\le i\le M-1, ~~1\le n\le N, \end{aligned}$$
(2.13)

where

$$\begin{aligned} (R_{t}^{c})_{i}^{n-\frac{1}{2}}=\frac{\tau ^{2}}{16}\int _{0}^{1}\left( \frac{\partial ^{3}u}{\partial t^{3}}\left( {x}_{i},t_{n-\frac{1}{2}}+\frac{s\tau }{2}\right) +\frac{\partial ^{3}u}{\partial t^{3}}\left( {x}_{i},t_{n-\frac{1}{2}}-\frac{s\tau }{2}\right) \right) (1-s^{2})\mathrm{d}s. \nonumber \\ \end{aligned}$$
(2.14)

This implies that

$$\begin{aligned}&\beta _{2} \mathcal{H}_{x}\left( U_{i}^{n-\frac{1}{2}}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})U_{i}^{k-\frac{1}{2}}-a_{n-1}U_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}\delta _{t}U_{i}^{n-\frac{1}{2}} \nonumber \\&\quad =\mu \left( d \displaystyle \delta _{x}^{2}U_{i}^{n-\frac{1}{2}}+\mathcal{H}_{x}\left( q_{i}U_{i}^{n-\frac{1}{2}}\right) +\mathcal{H}_{x}g_{i}^{n-\frac{1}{2}}+(R_{xt}^{(2)})_{i}^{n-\frac{1}{2}} \right) ,\nonumber \\&\quad \quad 1\le i\le M-1, 1\le n\le N, \end{aligned}$$
(2.15)

where

$$\begin{aligned} (R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}=(R_{xt}^{(1)})_{i}^{n-\frac{1}{2}}-\beta _{1}\mathcal{H}_{x}(R_{t}^{c})_{i}^{n-\frac{1}{2}}. \end{aligned}$$
(2.16)

Omitting the small term \(\mu (R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}\) in (2.15), we obtain the following compact finite difference scheme for \(\beta _{1}\not = 0\):

$$\begin{aligned}&\left\{ \begin{array}{l} \beta _{2} \mathcal{H}_{x}\left( u_{i}^{n-\frac{1}{2}}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})u_{i}^{k-\frac{1}{2}}-a_{n-1}u_{i}^{0}\right) +\mu \beta _{1} \mathcal{H}_{x}\delta _{t}u_{i}^{n-\frac{1}{2}} \\ \quad =\!\mu \! \left( d \displaystyle \delta _{x}^{2}u_{i}^{n\!-\!\frac{1}{2}}\!+\!\mathcal{H}_{x}\left( q_{i}u_{i}^{n-\frac{1}{2}}\right) \!+\!\mathcal{H}_{x}g_{i}^{n-\frac{1}{2}}\right) ,\qquad 1\!\le \! i\!\le \! M-1, ~~1\!\le \! n\le N,\quad \\ u_{0}^{n}=\phi _{0}^{*,n},\quad u_{M}^{n}=\phi _{L}^{*,n}, \qquad 1\le n\le N, \\ u_{i}^{0}=\varphi _{i}^{*}, \qquad 0\le i\le M, \end{array}\right. \quad \quad \end{aligned}$$
(2.17)

where \(u_{i}^{n}\) denotes the finite difference approximation to \(U_{i}^{n}\).

Case 2. \(\beta _{1}= 0\). For this case, we omit the small term \(\mu (R_{xt}^{(1)})_{i}^{n}\) in (2.8) to obtain the following compact finite difference scheme:

$$\begin{aligned} \left\{ \begin{array}{l} \beta _{2} \mathcal{H}_{x}\left( u_{i}^{n}\!-\!\sum \limits ^{n-1}_{k=1}(a_{n-k-1}\!-\!a_{n-k})u_{i}^{k}-a_{n-1}u_{i}^{0}\right) \!=\!\mu \left( d \delta _{x}^{2}u_{i}^{n}+\mathcal{H}_{x}\left( q_{i}u_{i}^{n}\right) +\mathcal{H}_{x}g_{i}^{n}\right) ,\\ \quad 1\le i\le M-1, ~~1\le n\le N, \\ u_{0}^{n}=\phi _{0}^{*,n},\quad u_{M}^{n}=\phi _{L}^{*,n}, \qquad 1\le n\le N, \\ u_{i}^{0}=\varphi _{i}^{*}, \qquad 0\le i\le M. \end{array}\right. \end{aligned}$$
(2.18)

3 Truncation error and solvability

We now estimate the truncation errors \((R_{xt}^{(1)})_{i}^{n}\) and \((R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}\). Assume that the solution \(u(x,t)\) of the problem (2.1) is in \(\mathcal{C}^{(6,2)}((0,L)\times [0,T])\). It follows from (2.7) and (2.4) that

$$\begin{aligned}&\left| (R_{x})_{i}^{n}\right| \le \frac{h^{4}}{240} \max _{x\in [0,L]} \left| \frac{\partial ^{6}u}{\partial x^{6}}(x,t_{n}) \right| , \displaystyle \left| (R_{t}^{\alpha })_{i}^{n}\right| \le \frac{C_{\alpha }}{\Gamma (2-\alpha )} \max _{t\in [0,T]} \left| \frac{\partial ^{2}u}{\partial t^{2}} ({x}_{i},t) \right| \tau ^{2-\alpha }, \nonumber \\&\quad 1\le i\le M-1,~~1\le n\le N, \end{aligned}$$
(3.1)

where \(C_{\alpha }=\frac{1-\alpha }{12}+\frac{2^{2-\alpha }}{2-\alpha }-1-2^{-\alpha }\). If the solution \(u(x,t)\) is thrice continuously differentiable in \(t\), we have from (2.14) that

$$\begin{aligned} \displaystyle \left| (R_{t}^{c})_{i}^{n-\frac{1}{2}}\right| \le \frac{\tau ^{2}}{12} \max _{t\in [0,T]} \left| \frac{\partial ^{3}u}{\partial t^{3}} ({x}_{i},t) \right| , \qquad 1\le i\le M-1,~~1\le n\le N. \end{aligned}$$
(3.2)

Since \(\mathcal{H}_{x}w_{i}=\frac{1}{12}(w_{i-1}+10w_{i}+w_{i+1})\), we apply the estimates (3.1) and (3.2) in (2.16), and the estimate (3.1) in (2.9) to get following results immediately.

Theorem 3.1

Assume that the solution \(u(x,t)\) of problem (2.1) \((\beta _{1}\not = 0)\) is in \(\mathcal{C}^{(6,3)}((0,L)\times [0,T])\). Then the truncation error \((R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}\) of the scheme (2.17) satisfies

$$\begin{aligned} \displaystyle \left| (R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}\right| \le C_{2}^{*} \left( \tau ^{2-\alpha }+h^{4}\right) , \qquad 1\le i\le M-1,~~1\le n\le N, \end{aligned}$$
(3.3)

where \(C_{2}^{*}\) is a positive constant independent of the step sizes \(\tau \) and \(h\) and the time level \(n\).

Theorem 3.2

Assume that the solution \(u(x,t)\) of problem (2.1) \((\beta _{1}= 0)\) is in \(\mathcal{C}^{(6,2)}((0,L)\times [0,T])\). Then the truncation error \((R_{xt}^{(1)})_{i}^{n}\) of the scheme (2.18) satisfies

$$\begin{aligned} \displaystyle \left| (R_{xt}^{(1)})_{i}^{n}\right| \le C_{1}^{*} \left( \tau ^{2-\alpha }+h^{4}\right) , \qquad 1\le i\le M-1,~~1\le n\le N, \end{aligned}$$
(3.4)

where \(C_{1}^{*}\) is a positive constant independent of the step sizes \(\tau \) and \(h\) and the time level \(n\).

For implementing the schemes (2.17) and (2.18), it is more convenient to consider their matrix forms. To do this, we define the following column vectors:

$$\begin{aligned}&\mathbf{u}^{n}=\left( u_{1}^{n}, u_{2}^{n}, \dots , u_{M-1}^{n}\right) ^{T}, \qquad \mathbf{g}^{n}=\left( g_{1}^{n}, g_{2}^{n}, \dots , g_{M-1}^{n}\right) ^{T}, \\&\mathbf{u}^{n-1,*}=\left( {u}_{1}^{n-1,*}, {u}_{2}^{n-1,*}, \dots , {u}_{M-1}^{n-1,*}\right) ^{T}, \end{aligned}$$

where

$$\begin{aligned} {u}_{i}^{n-1,*}= \left\{ \begin{array}{ll} \sum ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})u_{i}^{k-\frac{1}{2}}+a_{n-1}u_{i}^{0},\quad &{}\mathrm{for}~(2.17), \\ \sum ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})u_{i}^{k}+a_{n-1}u_{i}^{0}, &{} \mathrm{for}~(2.18), \end{array}\right. \quad 1\le i\le M-1. \nonumber \\ \end{aligned}$$
(3.5)

We also define the following \((M-1)\)-order tridiagonal or diagonal matrices:

$$\begin{aligned} A=\mathrm{tridiag}(-1,2,-1), \ B=\mathrm{tridiag}\left( \frac{1}{12}, \frac{5}{6}, \frac{1}{12}\right) , \ Q=\mathrm{diag}\left( q_{1}, q_{2}, \dots , q_{M-1}\right) . \end{aligned}$$

A simple process shows that the scheme (2.17) can be expressed in the matrix form as

$$\begin{aligned}&\displaystyle \left( \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) B+\frac{d}{2}\frac{\mu \tau }{h^{2}} A-\frac{\mu \tau }{2} B Q \right) \mathbf{u}^{n}\nonumber \\&\quad =\displaystyle \left( \left( \mu \beta _{1}\!-\!\frac{\tau }{2}\beta _{2}\right) B\!-\!\frac{d}{2} \frac{\mu \tau }{h^{2}} A\!+\!\frac{\mu \tau }{2} B Q \right) \mathbf{u}^{n-1}\!+\!\tau B \left( \beta _{2} \mathbf{u}^{n-1,*}\!+\!\mu \mathbf{g}^{n-\frac{1}{2}} \right) +\mathbf{r}^{n},\nonumber \\ \end{aligned}$$
(3.6)

where \(\mathbf{r}^{n}\) absorbs the boundary values of the solution vector and the source terms.

Theorem 3.3

The compact finite difference scheme (2.17) is uniquely solvable if and only if the matrix

$$\begin{aligned} Q^{*}\equiv \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) B+\frac{d}{2}\frac{\mu \tau }{h^{2}} A-\frac{\mu \tau }{2} B Q \end{aligned}$$
(3.7)

is nonsingular.

Define

$$\begin{aligned} \overline{q}=\max _{x\in [0,L]} q(x), \qquad \underline{q}=\min _{x\in [0,L]} q(x). \end{aligned}$$
(3.8)

A sufficient condition for the matrix \(Q^{*}\) to be nonsingular is given by

$$\begin{aligned} \mu \tau \max \left\{ \frac{\overline{q}}{2}, \frac{5\overline{q}-\underline{q}}{8}\right\} \le \frac{\tau }{2}\beta _{2}+\mu \beta _{1}. \end{aligned}$$
(3.9)

Corollary 3.1

The compact finite difference scheme (2.17) is uniquely solvable if the condition (3.9) holds true.

Proof

In fact, \(Q^{*}=\mathrm{tridiag}(p_{i-1}^{*}, q_{i}^{*}, p_{i+1}^{*})\) with \(p_{0}^{*}=p_{M}^{*}=0\) and

$$\begin{aligned} p_{i}^{*}&= \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) -\frac{d}{2} \frac{\mu \tau }{h^{2}}- \frac{q_{i}}{24}\mu \tau , \\ q_{i}^{*}&= \frac{5}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}- \frac{5q_{i}}{12}\mu \tau (1\le i\le M-1). \end{aligned}$$

The condition (3.9) implies that \(q_{i}^{*}>0\) for each \(1\le i\le M-1\).

Case 1. Assume that \(p_{i}^{*}\not =0\) for all \(1\le i\le M-1\). In this case, the matrix \(Q^{*}\) is irreducible. By the condition (3.9), we have that for \(2\le i\le M-2\),

$$\begin{aligned} \begin{array}{ll} |p_{i-1}^{*}|+|p_{i+1}^{*}|&{}\displaystyle \le \frac{1}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}-\frac{q_{i-1}+q_{i+1}}{24}\mu \tau \\ &{}\displaystyle \le \frac{1}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}-\frac{\mu \tau }{12}\underline{q} \\ &{}\displaystyle \le \frac{5}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}- \frac{5q_{i}}{12}\mu \tau =|q_{i}^{*}|. \end{array} \end{aligned}$$

Similarly,

$$\begin{aligned} |p_{2}^{*}|&\le \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +\frac{d}{2} \frac{\mu \tau }{h^{2}}- \frac{q_{2}}{24}\mu \tau \\&\le \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +\frac{d}{2} \frac{\mu \tau }{h^{2}}-\frac{\mu \tau }{24}\underline{q}\le \frac{q_{1}^{*}}{2}<|q_{1}^{*}|,\\ |p_{M-2}^{*}|&\le \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +\frac{d}{2} \frac{\mu \tau }{h^{2}}- \frac{q_{M-2}}{24}\mu \tau \le \frac{q_{M-1}^{*}}{2}< |q_{M-1}^{*}|. \end{aligned}$$

This proves that \(Q^{*}\) is irreducibly diagonally dominant and thus nonsingular (see [48]).

Case 2. Assume that \(p_{i_{0}}^{*}= 0\) for some \(1\le i_{0}\le M-1\). In this case, we complete the proof by partitioning \(Q^{*}\) and considering the submatrices of \(Q^{*}\). \(\square \)

Corollary 3.2

The compact finite difference scheme (2.17) is uniquely solvable if the function \(q(x)\) is nonpositive and convex in \([0,L]\).

Proof

We write \(Q^{*}=\mathrm{tridiag}(p_{i-1}^{*}, q_{i}^{*}, p_{i+1}^{*})\) as in Corollary 3.1. Since the function \(q(x)\) is nonpositive and convex, we have that for \(2\le i\le M-2\),

$$\begin{aligned} |p_{i-1}^{*}|+|p_{i+1}^{*}|&\le \displaystyle \frac{1}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}-\frac{q_{i-1}+q_{i+1}}{24}\mu \tau \\&< \displaystyle \frac{5}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}-\frac{5q_{i}}{12}\mu \tau =|q_{i}^{*}|, \end{aligned}$$

and

$$\begin{aligned} \displaystyle |p_{2}^{*}|&\le \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +\frac{d}{2} \frac{\mu \tau }{h^{2}}- \frac{q_{2}}{24}\mu \tau \\&< \frac{5}{6} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +d \frac{\mu \tau }{h^{2}}- \frac{5q_{1}}{12}\mu \tau =|q_{1}^{*}|,\\ \displaystyle |p_{M-2}^{*}|&\le \frac{1}{12} \left( \frac{\tau }{2}\beta _{2}+\mu \beta _{1}\right) +\frac{d}{2} \frac{\mu \tau }{h^{2}}- \frac{q_{M-2}}{24}\mu \tau < |q_{M-1}^{*}|. \end{aligned}$$

This shows that the matrix \(Q^{*}\) is strictly diagonally dominant and thus nonsingular (see [48]). \(\square \)

The matrix form of the scheme (2.18) is written as

$$\begin{aligned} \left( \beta _{2}B+\frac{\mu d}{h^{2}} A-\mu BQ\right) \mathbf{u}^{n}=B \left( \beta _{2}\mathbf{u}^{n-1,*}+\mu \mathbf{g}^{n} \right) +\mathbf{r}^{n}, \end{aligned}$$
(3.10)

where \(\mathbf{r}^{n}\) absorbs the boundary values of the solution vector and the source terms. Using the same argument as that for Theorem 3.1 and Corollaries 3.1 and 3.2, we have the following results for the solvability of the scheme (2.18).

Theorem 3.4

The compact finite difference scheme (2.18) is uniquely solvable if and only if the matrix \(\beta _{2}B+\frac{\mu d}{h^{2}} A-\mu BQ\) is nonsingular.

Corollary 3.3

The compact finite difference scheme (2.18) is uniquely solvable if the condition (3.9) holds true with \(\beta _{1}=0\) or the function \(q(x)\) is nonpositive and convex in \([0,L]\).

Remark 3.1

When \(q(x)\equiv q\) is independent of \(x\) and \(q\le 0\), the conditions in Corollaries 3.13.3 are trivially satisfied. We notice that if the convection coefficients \(p(x)\) in the original equation (1.1) is independent of \(x\), i.e., \(p(x)\equiv p\), we must have \(q(x)\equiv -\frac{p^{2}}{4d}\le 0\). Therefore, for the fractional convection-subdiffusion equation (1.1) with constant coefficients, the corresponding compact finite difference scheme (2.17) or (2.18) is always uniquely solvable without any additional constraints.

4 Stability and convergence of the scheme (2.17)

We now carry out the stability and convergence analysis of the compact difference scheme (2.17) using the discrete energy method. Let \(\mathcal{S}_{h}=\{u~|~ u=(u_{0}, u_{1}, \dots , u_{M}), u_{0}=u_{M}=0\}\) be the space of the grid functions defined in the spatial mesh and vanishing on two boundary points. For any grid functions \(v,w\in \mathcal{S}_{h}\), we define the inner product \((v,w)\), \(L^{2}\) norm \(\Vert v \Vert \) and \(L^{\infty }\) norm \(\Vert v \Vert _{\infty }\) by

$$\begin{aligned} (v,w)=h\sum \limits _{i=1}^{M-1} v_{i}w_{i}, \qquad \Vert v\Vert =(v,v)^{\frac{1}{2}}, \qquad \Vert v\Vert _{\infty }=\max _{0\le i\le M} |v_{i}|. \end{aligned}$$

We also define

$$\begin{aligned} (\delta _{x}v,\delta _{x}w]=h\sum \limits _{i=1}^{M} \delta _{x}v_{i-\frac{1}{2}}\delta _{x}w_{i-\frac{1}{2}}, \qquad |v|_{1}=(\delta _{x}v,\delta _{x}v]^{\frac{1}{2}}. \end{aligned}$$

For any \(v\in \mathcal{S}_{h}\), its \(H^{1}\) norm is defined by \(\Vert v\Vert _{1}= (\Vert v\Vert ^{2} +|v|_{1}^{2})^{\frac{1}{2}}\). Some simple calculations show that for any grid functions \(v,w\in \mathcal{S}_{h}\),

$$\begin{aligned} (\delta _{x}^{2}v, w)=-(\delta _{x}v, \delta _{x}w],\qquad h\Vert \delta _{x}^{2}v\Vert \le 2|v|_{1}, \qquad h|v|_{1}\le 2\Vert v\Vert . \end{aligned}$$
(4.1)

The inverse estimate \(h\Vert \delta _{x}^{2}v\Vert \le 2|v|_{1}\) in (4.1) shows that \(|v|_{1}^{2}-\frac{h^{2}}{12} \Vert \delta _{x}^{2} v\Vert ^{2}\ge \frac{2}{3} |v|_{1}^{2}\). For convenience, we introduce the following notation:

$$\begin{aligned} \Vert v\Vert _{*}=\left( |v|_{1}^{2}-\frac{h^{2}}{12} \Vert \delta _{x}^{2} v\Vert ^{2}\right) ^{\frac{1}{2}}. \end{aligned}$$

Then we have

$$\begin{aligned} \frac{2}{3} |v|_{1}^{2}\le \Vert v\Vert _{*}^{2}\le |v|_{1}^{2}. \end{aligned}$$
(4.2)

This means that \(\Vert v\Vert _{*}\) is an equivalent norm to \(|v|_{1}\).

Lemma 4.1

For any grid functions \(v, w\in \mathcal{S}_{h}\),

$$\begin{aligned} (\mathcal{H}_{x}v, -\delta _{x}^{2}v)=\Vert v\Vert _{*}^{2},\qquad \left| (\mathcal{H}_{x}v, -\delta _{x}^{2}w)\right| \le \Vert v\Vert _{*} \Vert w\Vert _{*}. \end{aligned}$$
(4.3)

Proof

The first relation follows from \((v, \delta _{x}^{2}v)=-|v|_{1}^{2}\) and the definition of \(\mathcal{H}_{x}\). To prove the second one, we observe that \( (\mathcal{H}_{x}v, -\delta _{x}^{2}w)=(\mathcal{H}_{x}w, -\delta _{x}^{2}v)\). This implies that for arbitrary real number \(\lambda \),

$$\begin{aligned}&\Vert v+\lambda w\Vert _{*}^{2}=\left( \mathcal{H}_{x}(v+\lambda w), -\delta _{x}^{2}(v+\lambda w) \right) =\Vert v\Vert _{*}^{2}\\&\quad +2 \lambda (\mathcal{H}_{x}v, -\delta _{x}^{2}w)+\lambda ^{2}\Vert w\Vert _{*}^{2}\ge 0. \end{aligned}$$

This is equivalent to the second relation in (4.3). \(\square \)

Lemma 4.2

For any grid function \(v\in \mathcal{S}_{h}\),

$$\begin{aligned} \Vert v \Vert ^{2}\le \frac{3L^{2}}{16} \Vert v\Vert _{*}^{2}, \quad \Vert v\Vert _{\infty }^{2}\le \frac{3L}{8} \Vert v\Vert _{*}^{2},\quad \Vert v\Vert _{1}^{2}\le \frac{3(8+L^{2})}{16} \Vert v\Vert _{*}^{2}. \end{aligned}$$

Proof

It is known that \(\Vert v\Vert ^{2}\le \frac{L^{2}}{8} |v|_{1}^{2}\) and \(\Vert v\Vert _{\infty }^{2}\le \frac{L}{4} |v|_{1}^{2}\) (see [42], pp. 111 and 112). Thus, the desired inequalities follow from \(|v|_{1}^{2}\le \frac{3}{2}\Vert v\Vert _{*}^{2}\) in (4.2) immediately. \(\square \)

Lemma 4.3

Let \(\gamma (x)\) be a continuous function in \([0,L]\). For any grid function \(v\in \mathcal{S}_{h}\), we have \(\Vert \mathcal{H}_{x}(\gamma v) \Vert \le \Vert \gamma \Vert _{\infty } \Vert v\Vert \).

Proof

We have from (4.1) that

$$\begin{aligned} \Vert \mathcal{H}_{x}(\gamma v) \Vert ^{2}\!=\!\Vert \gamma v\Vert ^{2}\!-\!\frac{h^{2}}{6}|\gamma v|_{1}^{2}\!+\!\frac{h^{4}}{144} \Vert \delta _{x}^{2}(\gamma v) \Vert ^{2}\!\le \! \Vert \gamma v\Vert ^{2}\!-\!\frac{5h^{2}}{36}|\gamma v|_{1}^{2}\le \Vert \gamma v\Vert ^{2}. \nonumber \\ \end{aligned}$$
(4.4)

It is clear that \(\Vert \gamma v \Vert ^{2}\le \Vert \gamma \Vert _{\infty }^{2}\Vert v \Vert ^{2}\). This completes the proof. \(\square \)

Lemma 4.4

(Discrete Gronwall lemma [40]) Assume that \(\{k_{n}\}\) and \(\{s_{n}\}\) are nonnegative sequences, and that the sequence \(\{\phi _{n}\}\) satisfies

$$\begin{aligned} \phi _{0}\le g_{0},\quad \phi _{n}\le g_{0}+\sum \limits ^{n-1}_{l=0}s_{l}+\sum \limits _{l=0}^{n-1}k_{l}\phi _{l},\qquad n\ge 1, \end{aligned}$$

where \(g_{0}\ge 0\). Then the sequence \(\{\phi _{n}\}\) satisfies

$$\begin{aligned} \phi _{n}\le \left( g_{0}+\sum \limits _{l=0}^{n-1}s_{l}\right) \exp \left( \sum \limits _{l=0}^{n-1}k_{l}\right) ,\qquad n\ge 1. \end{aligned}$$

Based on the above lemmas, we now discuss the stability of the compact difference scheme (2.17) with respect to the initial value \(\varphi ^{*}\) and the forcing term \(g\).

Theorem 4.1

Let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.17) with \(u_{0}^{n}=u_{M}^{n}=0\). Then when \(\tau \Vert q\Vert _{\infty }^{2} \le \frac{16d\beta _{1}}{3L^{2}}\), it holds that

$$\begin{aligned} \left\| u^{n} \right\| _{*}^{2} \le \displaystyle \left( G^{0} +\frac{2\tau }{d\beta _{1}}\sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}\right) \exp \left( \frac{3T\Vert q\Vert _{\infty }^{2}L^{2}}{8d\beta _{1}}\right) , \qquad 1\le n\le N, \nonumber \\ \end{aligned}$$
(4.5)

where

$$\begin{aligned} G^{0}=\displaystyle \frac{2}{\beta _{1}} \left( \beta _{1} + \frac{\beta _{2} T^{1-\alpha }}{\Gamma (2-\alpha )} \right) \left\| \varphi ^{*}\right\| _{*}^{2} +\frac{\tau }{d\beta _{1}} \Vert q\Vert _{\infty }^{2} \left\| \varphi ^{*} \right\| ^{2}. \end{aligned}$$
(4.6)

Proof

Let \(b_{n,k}=a_{n-k-1}-a_{n-k}\). It is clear that \(b_{n,k}\ge 0\). Taking the inner product of (2.17) with \(-\delta _{x}^{2}u^{n-\frac{1}{2}}\) gives

$$\begin{aligned}&\beta _{2}\left( \mathcal{H}_{x}u^{n-\frac{1}{2}}, -\delta _{x}^{2}u^{n-\frac{1}{2}} \right) -\mu \beta _{1}\left( \mathcal{H}_{x}\delta _{t}u^{n-\frac{1}{2}}, \delta _{x}^{2}u^{n-\frac{1}{2}}\right) \nonumber \\&\quad =\beta _{2}\displaystyle \sum _{k=1}^{n-1} b_{n,k} \left( \mathcal{H}_{x}u^{k-\frac{1}{2}}, -\delta _{x}^{2}u^{n-\frac{1}{2}}\right) +\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \nonumber \\&\qquad -\mu d \left\| \delta _{x}^{2}u^{n-\frac{1}{2}}\right\| ^{2}-\mu \left( \mathcal{H}_{x}(q u^{n-\frac{1}{2}}),\delta _{x}^{2}u^{n-\frac{1}{2}}\right) -\mu \left( \mathcal{H}_{x}g^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) .\nonumber \\ \end{aligned}$$
(4.7)

By Lemma 4.1, the relation \((\delta _{x}^{2}v, w)=-(\delta _{x}v, \delta _{x}w]\) in (4.1) and the Cauchy–Schwarz inequality,

$$\begin{aligned}&\beta _{2}\left( \mathcal{H}_{x}u^{n-\frac{1}{2}}, -\delta _{x}^{2}u^{n-\frac{1}{2}} \right) =\beta _{2} \left\| u^{n-\frac{1}{2}}\right\| _{*}^{2},\nonumber \\&\quad \displaystyle \beta _{2}\sum _{k=1}^{n-1} b_{n,k} \left( \mathcal{H}_{x}u^{k-\frac{1}{2}}, -\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \quad \le \displaystyle \frac{\beta _{2}}{2}\sum _{k=1}^{n-1} b_{n,k} \left( \left\| u^{k-\frac{1}{2}}\right\| ^{2}_{*}+\left\| u^{n-\frac{1}{2}}\right\| _{*}^{2} \right) \nonumber \\&\quad \quad =\displaystyle \frac{\beta _{2}}{2} \left( \sum _{k=1}^{n-1} a_{n-k-1}\left\| u^{k-\frac{1}{2}}\right\| _{*}^{2}-\displaystyle \sum _{k=1}^{n-1}a_{n-k} \left\| u^{k-\frac{1}{2}}\right\| _{*}^{2}+(1-a_{n-1})\left\| u^{n-\frac{1}{2}}\right\| _{*}^{2} \right) ,\nonumber \\&-\mu \beta _{1} \left( \mathcal{H}_{x}\delta _{t}u^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \nonumber \\&\quad =-\mu \beta _{1} \left( \delta _{t}u^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) -\mu \beta _{1} \left( \displaystyle \frac{h^{2}}{12}\delta _{x}^{2} \delta _{t}u^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \nonumber \\&\quad =\mu \beta _{1} \left( \delta _{t}\delta _{x}u^{n-\frac{1}{2}}, \delta _{x}u^{n-\frac{1}{2}}\right] -\displaystyle \frac{\mu \beta _{1} h^{2}}{12}\left( \delta _{t}\delta _{x}^{2} u^{n-\frac{1}{2}}, \delta _{x}^{2}u^{n-\frac{1}{2}}\right) \nonumber \\&\quad =\displaystyle \frac{\mu \beta _{1}}{2\tau } \left( \left| u^{n}\right| _{1}^{2}- \left| u^{n-1}\right| _{1}^{2}\right) - \displaystyle \frac{\mu \beta _{1} h^{2}}{24\tau }\left( \left\| \delta _{x}^{2}u^{n}\right\| ^{2}- \left\| \delta _{x}^{2}u^{n-1}\right\| ^{2}\right) \nonumber \\&\quad = \displaystyle \frac{\mu \beta _{1}}{2\tau } \left( \left\| u^{n}\right\| _{*}^{2} -\left\| u^{n-1}\right\| _{*}^{2}\right) \end{aligned}$$
(4.8)

and

$$\begin{aligned}&\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \le \displaystyle \frac{\beta _{2}a_{n-1}}{2} \left( \Vert u^{0}\Vert _{*}^{2}+\left\| u^{n-\frac{1}{2}} \right\| _{*}^{2}\right) ,\nonumber \\&\quad -\mu \left( \mathcal{H}_{x}g^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \le \displaystyle \frac{\mu }{2d} \left\| \mathcal{H}_{x}g^{n-\frac{1}{2}}\right\| ^{2}+ \frac{\mu d}{2} \left\| \delta _{x}^{2}u^{n-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.9)

We have from Lemma 4.3 that

$$\begin{aligned} -\mu \left( \mathcal{H}_{x}(q u^{n-\frac{1}{2}}),\delta _{x}^{2}u^{n-\frac{1}{2}}\right)&\le \displaystyle \frac{\mu }{2d} \left\| \mathcal{H}_{x}(q u^{n-\frac{1}{2}}) \right\| ^{2}+\frac{\mu d}{2} \left\| \delta _{x}^{2}u^{n-\frac{1}{2}}\right\| ^{2} \nonumber \\&\le \displaystyle \frac{\mu \Vert q\Vert _{\infty }^{2}}{2d} \left\| u^{n-\frac{1}{2}} \right\| ^{2} + \frac{\mu d}{2} \left\| \delta _{x}^{2}u^{n-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.10)

Let

$$\begin{aligned} F^{0}=\displaystyle \mu \beta _{1} \left\| u^{0}\right\| _{*}^{2},\qquad F^{n}=\displaystyle \beta _{2}\tau \sum _{k=1}^{n}a_{n-k} \left\| u^{k-\frac{1}{2}}\right\| _{*}^{2}+\mu \beta _{1} \left\| u^{n}\right\| _{*}^{2}~(1\le n\le N). \end{aligned}$$

Substituting the inequalities (4.8)–(4.10) into (4.7), we obtain

$$\begin{aligned} F^{n}\le F^{n-1}+\displaystyle \frac{\tau \mu }{d} \left( \Vert q\Vert _{\infty }^{2}\left\| u^{n-\frac{1}{2}} \right\| ^{2}+ \left\| \mathcal{H}_{x}g^{n-\frac{1}{2}}\right\| ^{2}\right) + \tau \beta _{2}a_{n-1} \Vert u^{0}\Vert _{*}^{2} \end{aligned}$$

or equivalently,

$$\begin{aligned} F^{n}\le F^{0}+\displaystyle \frac{\tau \mu }{d} \sum _{k=1}^{n} \left( \Vert q\Vert _{\infty }^{2} \left\| u^{k-\frac{1}{2}} \right\| ^{2} +\left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}\right) +\tau \beta _{2}n^{1-\alpha }\Vert u^{0}\Vert _{*}^{2}. \end{aligned}$$

Furthermore, by the relation \(\Vert u^{k-\frac{1}{2}}\Vert ^{2}\le \frac{1}{2} ( \Vert u^{k} \Vert ^{2}+\Vert u^{k-1} \Vert ^{2})\), we have

$$\begin{aligned}&F^{n}\le F^{0}+\displaystyle \frac{\tau \mu }{2d} \Vert q\Vert _{\infty }^{2} \left( \left\| u^{0} \right\| ^{2}+2 \sum _{k=1}^{n-1} \left\| u^{k} \right\| ^{2} + \left\| u^{n} \right\| ^{2}\right) \nonumber \\&\quad \quad \quad +\frac{\tau \mu }{d} \sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}+\frac{\mu \beta _{2} T^{1-\alpha }}{\Gamma (2-\alpha )}\Vert u^{0}\Vert _{*}^{2}. \end{aligned}$$
(4.11)

In view of the definitions of \(F^{n}\) and \(F^{0}\), it follows that

$$\begin{aligned}&\displaystyle 2d\beta _{1} \left\| u^{n}\right\| _{*}^{2}-\tau \Vert q\Vert _{\infty }^{2} \left\| u^{n} \right\| ^{2} \le \displaystyle 2d \left( \beta _{1} + \frac{\beta _{2} T^{1-\alpha }}{\Gamma (2-\alpha )} \right) \left\| u^{0}\right\| _{*}^{2}+\tau \Vert q\Vert _{\infty }^{2} \left\| u^{0} \right\| ^{2} \nonumber \\&\quad +\displaystyle 2\tau \Vert q\Vert _{\infty }^{2} \sum _{k=1}^{n-1} \left\| u^{k} \right\| ^{2}\displaystyle +2\tau \sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.12)

An application of Lemma 4.2 gives

$$\begin{aligned}&\displaystyle \left( 2d\beta _{1} -\frac{3\tau \Vert q\Vert _{\infty }^{2}L^{2}}{16} \right) \left\| u^{n} \right\| _{*}^{2} \le \displaystyle 2d \left( \beta _{1} + \frac{\beta _{2} T^{1-\alpha }}{\Gamma (2-\alpha )} \right) \left\| u^{0}\right\| _{*}^{2}+\tau \Vert q\Vert _{\infty }^{2} \left\| u^{0} \right\| ^{2} \nonumber \\&\quad +\displaystyle \frac{3\tau \Vert q\Vert _{\infty }^{2}L^{2}}{8} \sum _{k=1}^{n-1} \left\| u^{k} \right\| _{*}^{2}\displaystyle +2\tau \sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.13)

When \(\tau \Vert q\Vert _{\infty }^{2} \le \frac{16d\beta _{1}}{3L^{2}}\), we have

$$\begin{aligned} \left\| u^{n} \right\| _{*}^{2} \le G^{0}+\displaystyle \frac{3\tau \Vert q\Vert _{\infty }^{2}L^{2}}{8 d\beta _{1}} \sum _{k=1}^{n-1} \left\| u^{k} \right\| _{*}^{2}\displaystyle +\frac{2\tau }{d\beta _{1}}\sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.14)

The estimate (4.5) follows from Lemma 4.4 (Discrete Gronwall lemma) immediately. \(\square \)

Theorem 4.1 shows that the compact difference scheme (2.17) is almost unconditionally stable to the initial value \(\varphi ^{*}\) and the forcing term \(g\), or more precisely, it is stable under the mild condition \(\tau \Vert q\Vert _{\infty }^{2} \le \frac{16d\beta _{1}}{3L^{2}}\) for the general \(q(x)\). For the special case when \(q(x)\equiv q\) is independent of \(x\) and \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\), this mild condition is no longer required to obtain the unconditional stability of the compact difference scheme (2.17). Specifically, we have the following result.

Theorem 4.2

Let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.17) with \(u_{0}^{n}=u_{M}^{n}=0\). Assume that \(q(x)\equiv q\) is independent of \(x\) and that \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Then it holds that

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2} \le \displaystyle \left( 1+ \frac{2\varepsilon \beta _{2}T^{1-\alpha }}{\beta _{1}\Gamma (2-\alpha )}\right) \left\| \varphi ^{*}\right\| _{*}^{2}+ \frac{\tau }{2d\beta _{1}} \sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.15)

Proof

The proof follows from the similar argument as that in the proof of Theorem 4.1. When \(q(x)\equiv q\) is independent of \(x\) and \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\), we have from Lemma 4.1 and \(\mu \le T^{\alpha }\Gamma (1-\alpha )a_{n-1}\) that

$$\begin{aligned} -\!\mu \left( \mathcal{H}_{x}(q u^{n-\frac{1}{2}}),\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \! =\!\mu q \left\| u^{n-\frac{1}{2}} \right\| _{*}^{2}\!\le \! \left( \frac{1}{2}\!-\!\frac{1}{4\varepsilon }\right) \beta _{2}a_{n-1}\left\| u^{n\!-\!\frac{1}{2}} \right\| _{*}^{2}. \quad \quad \quad \quad \end{aligned}$$
(4.16)

By Lemma 4.1 and the Cauchy–Schwarz inequality

$$\begin{aligned}&\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \le \displaystyle \beta _{2}a_{n-1} \left( \varepsilon \Vert u^{0}\Vert _{*}^{2}+\frac{1}{4\varepsilon } \left\| u^{n-\frac{1}{2}} \right\| _{*}^{2} \right) ,\nonumber \\&\quad -\mu \left( \mathcal{H}_{x}g^{n-\frac{1}{2}},\delta _{x}^{2}u^{n-\frac{1}{2}}\right) \le \displaystyle \frac{\mu }{4d} \left\| \mathcal{H}_{x}g^{n-\frac{1}{2}}\right\| ^{2}+ \mu d\left\| \delta _{x}^{2}u^{n-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.17)

Using (4.7) (with \(q(x)\equiv q\)), (4.8), (4.16) and (4.17), we obtain

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2} \le \left( 1+ \frac{2\varepsilon \beta _{2}\tau }{\mu \beta _{1}} \sum _{k=1}^{n} a_{k-1} \right) \left\| u^{0}\right\| _{*}^{2}+\frac{\tau }{2d\beta _{1}} \sum _{k=1}^{n} \left\| \mathcal{H}_{x}g^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$
(4.18)

The estimate (4.15) follows from

$$\begin{aligned} \tau \sum _{k=1}^{n} a_{k-1}=\tau n^{1-\alpha }\le \frac{\mu T^{1-\alpha }}{\Gamma (2-\alpha )}. \end{aligned}$$

The proof is completed. \(\square \)

Remark 4.1

The condition \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\) is automatically satisfied if \(q\le 0\). The latter is certainly satisfied if the convection coefficient \(p(x)\) in the original equation (1.1) is independent of \(x\), i.e., \(p(x)\equiv p\). This implies that for the fractional convection-subdiffusion equation (1.1) with constant coefficients, the corresponding compact difference scheme (2.17) is unconditionally stable.

We now consider the convergence of the compact difference scheme (2.17). Let \(e_{i}^{n}=U_{i}^{n}-u_{i}^{n}\). From (2.15) and (2.17), we get the following error equation:

$$\begin{aligned} \left\{ \begin{array}{l} \displaystyle \beta _{2} \mathcal{H}_{x}\left( e_{i}^{n-\frac{1}{2}}-\sum \limits ^{n-1}_{k=1}(a_{n-k-1}-a_{n-k})e_{i}^{k-\frac{1}{2}}\right) +\mu \beta _{1} \mathcal{H}_{x}\delta _{t}e_{i}^{n-\frac{1}{2}}\\ \quad =\mu \left( d \displaystyle \delta _{x}^{2}e_{i}^{n-\frac{1}{2}}\!+\!\mathcal{H}_{x}\left( q_{i}e_{i}^{n-\frac{1}{2}}\right) \!+\!(R_{xt}^{(2)})_{i}^{n-\frac{1}{2}}\right) ,\quad 1\!\le \! i\!\le \! M-1, ~~1\le n\!\le N,\\ e_{0}^{n}=e_{M}^{n}=0, \quad 1\le n\le N,\\ e_{i}^{0}=0, \quad 0\le i\le M. \end{array} \right. \nonumber \\ \end{aligned}$$
(4.19)

Let \(C_{2}^{*}\) be the constant as that in (3.3), and define

$$\begin{aligned} C_{1}=\left( \frac{2TL{C_{2}^{*}}^{2}}{d\beta _{1}} \exp \left( \frac{3T\Vert q\Vert _{\infty }^{2}L^{2}}{8d\beta _{1}}\right) \right) ^{\frac{1}{2}}, \qquad C_{2}=\left( \frac{TL{C_{2}^{*}}^{2}}{2d\beta _{1}}\right) ^{\frac{1}{2}}. \end{aligned}$$
(4.20)

Based on the error equation (4.19), we have the following convergence results.

Theorem 4.3

Let \(U_{i}^{n}\) denote the value of the solution \(u(x,t)\) of (2.1) \((\beta _{1}\not = 0)\) at the mesh point \((x_{i},t_{n})\) and let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.17). Assume that the condition in Theorem 3.1 is satisfied. Then when \(\tau \Vert q\Vert _{\infty }^{2}\le \frac{16d\beta _{1}}{3L^{2}}\), we have

$$\begin{aligned} \left\| U^{n}-u^{n} \right\| _{*} \le \displaystyle C_{1} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N. \end{aligned}$$
(4.21)

Proof

It follows from (4.19) and Theorem 4.1 that

$$\begin{aligned} \left\| e^{n} \right\| _{*}^{2} \le \displaystyle \frac{2\tau }{d\beta _{1}} \exp \left( \frac{3T\Vert q\Vert _{\infty }^{2}L^{2}}{8d\beta _{1}}\right) \sum _{k=1}^{n} \left\| (R_{xt}^{(2)})^{k-\frac{1}{2}}\right\| ^{2}. \end{aligned}$$

Applying Theorem 3.1, we get

$$\begin{aligned} \left\| e^{n} \right\| _{*}^{2} \le \displaystyle C_{1}^{2} \left( \tau ^{2-\alpha }+h^{4}\right) ^{2}. \end{aligned}$$

The estimate (4.21) is proved. \(\square \)

Theorem 4.4

Let \(U_{i}^{n}\) denote the value of the solution \(u(x,t)\) of (2.1) \((\beta _{1}\not = 0)\) at the mesh point \((x_{i},t_{n})\) and let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.17). Assume that \(q(x)\equiv q\) is independent of \(x\) and that \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Also assume that the condition in Theorem 3.1 is satisfied. Then we have

$$\begin{aligned} \left\| U^{n}-u^{n}\right\| _{*} \le \displaystyle C_{2} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N. \end{aligned}$$
(4.22)

Proof

The proof follows from (4.19) and Theorems 3.1 and 4.2. \(\square \)

Combining Lemma 4.2 with Theorems 4.3 and 4.4, we get immediately the following two theorems concerning with the error estimates in the discrete \(L^{2}\), \(H^{1}\) and \(L^{\infty }\) norms.

Theorem 4.5

Assume that the condition in Theorem 4.3 is satisfied. Then

$$\begin{aligned}&\left\| U^{n}-u^{n} \right\| \le \displaystyle \frac{C_{1}L\sqrt{3}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N,\nonumber \\&\left\| U^{n}-u^{n} \right\| _{1} \le \displaystyle \frac{C_{1}\sqrt{3(8+L^{2})}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N, \\&\left\| U^{n}-u^{n} \right\| _{\infty } \le \displaystyle \frac{C_{1}\sqrt{6L}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N.\nonumber \end{aligned}$$
(4.23)

Theorem 4.6

Assume that the condition in Theorem 4.4 is satisfied. Then

$$\begin{aligned}&\left\| U^{n}-u^{n} \right\| \le \displaystyle \frac{C_{2}L\sqrt{3}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N,\nonumber \\&\left\| U^{n}-u^{n} \right\| _{1} \le \displaystyle \frac{C_{2}\sqrt{3(8+L^{2})}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N, \\&\left\| U^{n}-u^{n} \right\| _{\infty } \le \displaystyle \frac{C_{2}\sqrt{6L}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N.\nonumber \end{aligned}$$
(4.24)

Remark 4.2

In Theorem 4.5, the optimal error estimates (i.e., the error estimate with the same order as the truncation error) of the compact difference scheme (2.17) in the discrete \(L^{2}\), \(H^{1}\) and \(L^{\infty }\) norms are obtained under the mild condition \(\tau \Vert q\Vert _{\infty }^{2}\le \frac{16d\beta _{1}}{3L^{2}}\) for the general \(q(x)\). Theorem 4.6 shows that this mild condition is no longer required to obtain the same optimal error estimate if \(q(x)\equiv q\) is independent of \(x\) and that \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). In particular, this is the case for the fractional convection-subdiffusion equation (1.1) with constant coefficients.

5 Stability and convergence of the scheme (2.18)

Similar technique for the analysis of the compact difference scheme (2.17) can be used to analyze the scheme (2.18).

Theorem 5.1

Let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.18) with \(u_{0}^{n}=u_{M}^{n}=0\). Assume that \(\Vert q\Vert _{\infty }^{2}\le \frac{4 (4\varepsilon -1)(2\varepsilon -1)d\beta _{2}}{3 \varepsilon ^{2}L^{2}T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Then it holds that

$$\begin{aligned} \left\| u^{n}\right\| _{*}^{2}\le \displaystyle 2\varepsilon \left( \Vert \varphi ^{*}\Vert _{*}^{2}+\frac{ T^{\alpha }\Gamma (1-\alpha )}{d\beta _2} \max _{1\le n\le N} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2} \right) , \qquad 1\le n\le N. \end{aligned}$$
(5.1)

Proof

Let \(b_{n,k}=a_{n-k-1}-a_{n-k}\) as before. Taking the inner product of (2.18) with \(-\delta _{x}^{2}u^{n}\) gives

$$\begin{aligned} \beta _{2} \left( \mathcal{H}_{x}u^{n}, -\delta _{x}^{2}u^{n} \right)&= \beta _{2}\displaystyle \sum _{k=1}^{n-1} b_{n,k} \left( \mathcal{H}_{x}u^{k}, -\delta _{x}^{2}u^{n}\right) +\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n}\right) \nonumber \\&-\mu d \left\| \delta _{x}^{2}u^{n}\right\| ^{2}-\mu \left( \mathcal{H}_{x}(q u^{n}),\delta _{x}^{2}u^{n}\right) -\mu \left( \mathcal{H}_{x}g^{n},\delta _{x}^{2}u^{n}\right) .\nonumber \\ \end{aligned}$$
(5.2)

By Lemma 4.1, the relation \((\delta _{x}^{2}v, w)=-(\delta _{x}v, \delta _{x}w]\) in (4.1) and the Cauchy–Schwarz inequality,

$$\begin{aligned}&\beta _{2}\left( \mathcal{H}_{x}u^{n}, -\delta _{x}^{2}u^{n} \right) =\beta _{2} \left\| u^{n}\right\| _{*}^{2}, \nonumber \\&\quad \displaystyle \beta _{2}\sum _{k=1}^{n-1} b_{n,k} \left( \mathcal{H}_{x}u^{k}, -\delta _{x}^{2}u^{n}\right) \le \displaystyle \frac{\beta _{2}}{2}\sum _{k=1}^{n-1} b_{n,k} \left( \left\| u^{k}\right\| ^{2}_{*}+\left\| u^{n}\right\| _{*}^{2} \right) \nonumber \\&\quad \quad =\displaystyle \frac{\beta _{2}}{2} \left( \sum _{k=1}^{n-1} \left( a_{n-k-1}-a_{n-k}\right) \left\| u^{k}\right\| ^{2}_{*}+(1-a_{n-1})\left\| u^{n}\right\| _{*}^{2} \right) \end{aligned}$$
(5.3)

and

$$\begin{aligned}&\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n}\right) \le \displaystyle \beta _{2}a_{n-1} \left( \varepsilon \Vert u^{0}\Vert _{*}^{2}+\frac{1}{4 \varepsilon }\left\| u^{n} \right\| _{*}^{2}\right) , \nonumber \\&\quad -\mu \left( \mathcal{H}_{x}g^{n},\delta _{x}^{2}u^{n}\right) \le \displaystyle \frac{\varepsilon \mu }{d} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2}+ \frac{\mu d}{4\varepsilon } \left\| \delta _{x}^{2}u^{n}\right\| ^{2}, \end{aligned}$$
(5.4)

where \(\varepsilon \ge \frac{1}{2}\) is the constant such that \(\Vert q\Vert _{\infty }^{2}\le \frac{4 (4\varepsilon -1)(2\varepsilon -1)d\beta _{2}}{3 \varepsilon ^{2}L^{2}T^{\alpha }\Gamma (1-\alpha )}\). We have from Lemmas 4.2 and 4.3 and the Cauchy–Schwarz inequality that

$$\begin{aligned} -\mu \left( \mathcal{H}_{x}(q u^{n}),\delta _{x}^{2}u^{n}\right)&\le \displaystyle \frac{\varepsilon \mu }{(4\varepsilon -1)d} \left\| \mathcal{H}_{x}(q u^{n}) \right\| ^{2}+\frac{(4\varepsilon -1)\mu d}{4\varepsilon } \left\| \delta _{x}^{2}u^{n}\right\| ^{2}\\&\le \displaystyle \frac{3\varepsilon \mu L^{2}\Vert q\Vert _{\infty }^{2}}{16(4\varepsilon -1)d} \left\| u^{n} \right\| _{*}^{2} +\frac{(4\varepsilon -1)\mu d}{4\varepsilon } \left\| \delta _{x}^{2}u^{n}\right\| ^{2}. \end{aligned}$$

Since \(\mu \le T^{\alpha } \Gamma (1-\alpha ) a_{n-1}\) and \(\Vert q\Vert _{\infty }^{2}\le \frac{4 (4\varepsilon -1)(2\varepsilon -1)d\beta _{2}}{3 \varepsilon ^{2}L^{2}T^{\alpha }\Gamma (1-\alpha )}\), the above inequality implies that

$$\begin{aligned} -\mu \left( \mathcal{H}_{x}(q u^{n}),\delta _{x}^{2}u^{n}\right) \le \displaystyle \left( \frac{1}{2}-\frac{1}{4\varepsilon } \right) \beta _{2}a_{n-1} \left\| u^{n} \right\| _{*}^{2} +\left( 1-\frac{1}{4\varepsilon }\right) \mu d \left\| \delta _{x}^{2}u^{n}\right\| ^{2}. \nonumber \\ \end{aligned}$$
(5.5)

Substituting the inequalities (5.3), (5.4) and (5.5) into (5.2) and then multiplying the resulting inequality by \(\frac{2}{\beta _{2}}\) yield

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2}\le \displaystyle \sum _{k=1}^{n-1}\left( a_{n-k-1}-a_{n-k} \right) \left\| u^{k}\right\| _{*}^{2}+\displaystyle 2 \varepsilon a_{n-1} \Vert u^{0}\Vert _{*}^{2}+\frac{2\varepsilon \mu }{d\beta _{2}} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2}. \end{aligned}$$

A simple induction using \(a_{k}>a_{k+1}\) for each \(k\ge 0\) and \(\sum \limits _{k=1}^{n-1}\left( a_{n-k-1}-a_{n-k} \right) =1-a_{n-1}\) shows that

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2}\le \displaystyle 2\varepsilon \Vert u^{0}\Vert _{*}^{2}+\frac{2\varepsilon \mu }{d\beta _2 a_{n-1}} \max _{1\le n\le N} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2}, \qquad 1\le n\le N. \end{aligned}$$
(5.6)

The proof is completed since \(\mu \le T^{\alpha } \Gamma (1-\alpha ) a_{n-1}\). \(\square \)

Theorem 5.2

Let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.18) with \(u_{0}^{n}=u_{M}^{n}=0\). Assume that \(q(x)\equiv q\) is independent of \(x\) and that \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha } \Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Then it holds that

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2}\le \displaystyle 2\varepsilon \Vert \varphi ^{*}\Vert _{*}^{2}+\frac{T^{\alpha }\Gamma (1-\alpha )}{2d\beta _2 } \max _{1\le n\le N}\left\| \mathcal{H}_{x}g^{n}\right\| ^{2}, \qquad 1\le n\le N. \end{aligned}$$
(5.7)

Proof

When \(q(x)\equiv q\) is independent of \(x\) and \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha } \Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\), we have from Lemma 4.1 and \(\mu \le T^{\alpha }\Gamma (1-\alpha )a_{n-1}\) that

$$\begin{aligned} -\mu \left( \mathcal{H}_{x} (qu^{n}), \delta _{x}^{2}u^{n} \right) =\mu q \left\| u^{n}\right\| _{*}^{2}\le \left( \frac{1}{2}-\frac{1}{4\varepsilon }\right) \beta _{2}a_{n-1}\left\| u^{n}\right\| _{*}^{2}. \end{aligned}$$
(5.8)

By Lemma 4.1 and the Cauchy–Schwarz inequality,

$$\begin{aligned}&\beta _{2}a_{n-1}\left( \mathcal{H}_{x}u^{0},-\delta _{x}^{2}u^{n}\right) \le \displaystyle \beta _{2}a_{n-1} \left( \varepsilon \Vert u^{0}\Vert _{*}^{2}+\frac{1}{4 \varepsilon }\left\| u^{n} \right\| _{*}^{2}\right) ,\nonumber \\&\quad -\mu \left( \mathcal{H}_{x}g^{n},\delta _{x}^{2}u^{n}\right) \le \displaystyle \frac{\mu }{4d} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2}+ \mu d \left\| \delta _{x}^{2}u^{n}\right\| ^{2}. \end{aligned}$$
(5.9)

We thus have from (5.2), (5.3), (5.8) and (5.9) that

$$\begin{aligned} \displaystyle \left\| u^{n}\right\| _{*}^{2}\le \displaystyle \sum _{k=1}^{n-1}\left( a_{n-k-1} -a_{n-k}\right) \left\| u^{k}\right\| _{*}^{2}+\displaystyle 2\varepsilon a_{n-1} \Vert u^{0}\Vert _{*}^{2}+\frac{\mu }{2d\beta _2} \left\| \mathcal{H}_{x}g^{n}\right\| ^{2}, \ 1\!\le \!n\!\le \!N. \end{aligned}$$

The remaining proof is the same as that of Theorem 5.1. \(\square \)

Remark 5.1

The condition \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha } \Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\) is certainly satisfied if the convection coefficient \(p(x)\) in the original equation (1.1) is independent of \(x\). Therefore, the compact difference scheme (2.18) is unconditionally stable for the fractional convection-subdiffusion equation (1.1) with constant coefficients.

Let \(C_{1}^{*}\) be the constant as that in (3.4), and define

$$\begin{aligned} C_{3}=\left( \frac{T^{\alpha }L\Gamma (1-\alpha ){C_{1}^{*}}^{2}}{d\beta _2}\right) ^{\frac{1}{2}}. \end{aligned}$$

Applying Theorem 3.2, Theorem 5.1 and Lemma 4.2, we obtain the following convergence results of the compact difference scheme (2.18).

Theorem 5.3

Let \(U_{i}^{n}\) denote the value of the solution \(u(x,t)\) of (2.1) \((\beta _{1}= 0)\) at the mesh point \((x_{i},t_{n})\) and let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.18). Assume that the condition in Theorem 3.2 is satisfied and \(\Vert q\Vert _{\infty }^{2}\le \frac{4 (4\varepsilon -1)(2\varepsilon -1)d\beta _{2}}{3 \varepsilon ^{2}L^{2}T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Then we have

$$\begin{aligned}&\left\| U^{n}-u^{n} \right\| _{2} \le \displaystyle \frac{C_{3}L\sqrt{6\varepsilon }}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N,\nonumber \\&\left\| U^{n}-u^{n} \right\| _{1} \le \displaystyle \frac{C_{3}\sqrt{6(8+L^{2})\varepsilon }}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N, \\&\left\| U^{n}-u^{n} \right\| _{\infty }\le \displaystyle \frac{C_{3}\sqrt{3L\varepsilon }}{2} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N.\nonumber \end{aligned}$$
(5.10)

Theorem 5.4

Let \(U_{i}^{n}\) denote the value of the solution \(u(x,t)\) of (2.1) \((\beta _{1}= 0)\) at the mesh point \((x_{i},t_{n})\) and let \(u^{n}=(u_{0}^{n}, u_{1}^{n}, \dots , u_{M}^{n})\) be the solution of the compact difference scheme (2.18). Assume that the condition in Theorem 3.2 is satisfied. Also assume that \(q(x)\equiv q\) is independent of \(x\) and \(q\le \frac{(2\varepsilon -1)\beta _{2}}{4\varepsilon T^{\alpha } \Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\). Then we have

$$\begin{aligned}&\left\| U^{n}-u^{n} \right\| \le \displaystyle \frac{C_{3}L\sqrt{6}}{8} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N,\nonumber \\&\left\| U^{n}-u^{n} \right\| _{1} \le \displaystyle \frac{C_{3}\sqrt{6(8+L^{2})}}{8} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N, \\&\left\| U^{n}-u^{n} \right\| _{\infty } \le \displaystyle \frac{C_{3}\sqrt{3L}}{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N. \nonumber \end{aligned}$$
(5.11)

Remark 5.2

The constraint condition \(\Vert q\Vert _{\infty }^{2}\le \frac{4 (4\varepsilon -1)(2\varepsilon -1)d\beta _{2}}{3 \varepsilon ^{2}L^{2}T^{\alpha }\Gamma (1-\alpha )}\) for some positive constant \(\varepsilon \ge \frac{1}{2}\) in Theorems 5.1 and 5.3 is only for the analyses of the stability and convergence of the scheme (2.18) with the general \(q(x)\). This condition is easily verifiable for practical problems. One of the numerical experiments in the next section shows that it is only a sufficient condition. Improvement of this condition can be interesting both theoretically and computationally. It will be a subject of our future investigations. The same remark holds for Theorems 5.2, 5.4, 4.2 and 4.4.

6 Applications and numerical results

In this section, we give some applications of the proposed compact finite difference method for several model problems. The exact analytical solution \(v(x,t)\) of each problem is explicitly known and is mainly used to compare with the computed solution \(v_{i}^{n}=\exp \left( \frac{1}{2d} \int _{0}^{x_{i}}p(s)\mathrm{d}s \right) u_{i}^{n}\) to check the accuracy of the compact finite difference method, where \(u_{i}^{n}\) is the solution of the compact difference scheme (2.17) or (2.18). In order to demonstrate the high efficiency of the compact difference scheme (2.17) or (2.18), we also make some numerical comparisons of it with the difference scheme given in [28].

Let \(V_{i}^{n}=v(x_{i},t_{n})\) be the value of the solution \(v(x,t)\) of the original problem (1.1)–(1.3) at the mesh point \((x_{i},t_{n})\). Since \(V_{i}^{n}=\exp ( {\frac{1}{2d}\int _{0}^{x_{i}}p(s)\mathrm{d}s})U_{i}^{n}\), we have from (4.23), (4.24), (5.10) or (5.11) that

$$\begin{aligned} \Vert V^{n}- v^{n} \Vert _{\nu } \le C_{4} \left( \tau ^{2-\alpha }+h^{4}\right) ,\qquad 1\le n\le N, \end{aligned}$$
(6.1)

where the norm \(\Vert \cdot \Vert _{\nu }\) stands for \(\Vert \cdot \Vert \), \(\Vert \cdot \Vert _{1}\) or \(\Vert \cdot \Vert _{\infty }\), and \(C_{4}\) is a positive constant independent of the step sizes \(\tau \) and \(h\) and the time level \(n\). To check this accuracy, we compute \(L^{2}\), \(H^{1}\) and \(L^{\infty }\) norm errors:

$$\begin{aligned} \mathrm{e}_{2}(\tau ,h)=\displaystyle \max _{0\le n\le N}\Vert V^{n}-v^{n}\Vert ,\quad \mathrm{e}_{\nu }(\tau ,h)=\displaystyle \max _{0\le n\le N}\Vert V^{n}-v^{n}\Vert _{\nu } (\nu =1,\infty ).\qquad \end{aligned}$$
(6.2)

The temporal and spatial convergence orders are computed, respectively, by

$$\begin{aligned} \displaystyle \mathrm{order}_{\nu }^\mathrm{t}(\tau ,h)\!=\!\log _{2}\left( \frac{\mathrm{e}_{\nu }(2\tau ,h)}{\mathrm{e}_{\nu }(\tau ,h)}\right) ,\quad \displaystyle \mathrm{order}_{\nu }^\mathrm{s}(\tau ,h)\!=\!\log _{2}\left( \frac{\mathrm{e}_{\nu }(\tau ,2h)}{\mathrm{e}_{\nu }(\tau ,h)}\right) (\nu \!=\!1,2,\infty ).\nonumber \\ \end{aligned}$$
(6.3)

Example 6.1

We first consider a time fractional mobile/immobile convection-subdiffusion problem with a variable convection coefficient. This problem is governed by Eq. (1.1) in the domain \([0,\pi ]\times [0,1]\) with \(\beta _{2}=\beta _{1}=d=1\) and

$$\begin{aligned} p(x)=-\sin x, \qquad f(x,t)=t^{2}\left( 3+t+\frac{6t^{1-\alpha }}{\Gamma (4-\alpha )} \right) \cos x+t^{3} \sin ^{2} x. \end{aligned}$$
(6.4)

The boundary and initial conditions are given by (1.2) and (1.3) with

$$\begin{aligned} \phi _{0}(t)=t^{3}, \qquad \phi _{L}(t)=-t^{3}, \qquad \varphi (x)\equiv 0. \end{aligned}$$
(6.5)

It is easy to check that \(v(x,t)=t^{3}\cos x\) is the solution of this problem.

We first test the temporal error and the temporal convergence order of the compact difference scheme (2.17) for different \(\alpha \). In this test, we let the spatial step \(h\approx \tau ^{\frac{2-\alpha }{4}}\) (\(M=\lceil \pi \tau ^{-\frac{2-\alpha }{4}}\rceil \)). Table 1 gives the errors \(\mathrm{e}_{\nu }(\tau ,h)\) \((\nu =1,2,\infty )\) and the temporal convergence orders \(\mathrm{order}_{\nu }^\mathrm{t}(\tau ,h)\) \((\nu =1,2,\infty )\) of the computed solution \(v_{i}^{n}\) for \(\alpha =1/4, 1/2, 3/4\) and different time step \(\tau \). As expected from our theoretical analysis, the computed solution \(v_{i}^{n}\) has the temporal accuracy of order \((2-\alpha )\).

We next compute the spatial error and the spatial convergence order. Table 2 presents the errors \(\mathrm{e}_{\nu }(\tau ,h)\) \((\nu =1,2,\infty )\) and the spatial convergence orders \(\mathrm{order}_{\nu }^\mathrm{s}(\tau ,h)\) \((\nu =1,2,\infty )\) of the computed solution \(v_{i}^{n}\) for \(\alpha =1/4, 1/2, 3/4\) and different spatial step \(h\), where the time step \(\tau \approx h^{\frac{4}{2-\alpha }}\) (\(N=\lceil h^{-\frac{4}{2-\alpha }}\rceil \)). The data in this table demonstrate that the compact difference scheme (2.17) generates the fourth-order spatial accuracy. This coincides well with the analysis.

Table 1 The temporal errors and convergence orders of the compact difference scheme (2.17) for Example 6.1 \((h\approx \tau ^{\frac{2-\alpha }{4}})\)
Table 2 The spatial errors and convergence orders of the compact difference scheme (2.17) for Example 6.1 \((\tau \approx h^{\frac{4}{2-\alpha }})\)

Example 6.2

The work in [28] develops a finite difference scheme (i.e., the difference scheme (24) in [28]) for solving time fractional mobile/immobile convection-subdiffusion problems with constant coefficients. To compare it with the compact difference scheme (2.17) given here, we consider Eq. (1.1) and the boundary and initial conditions (1.2) and (1.3) in the domain \([0,1]\times [0,1]\) with \(\beta _{2}=\beta _{1}=d=1\) and

$$\begin{aligned}&p(x)=1, \quad f(x,t)=3 t^{2}\left( 1+\frac{2t^{1-\alpha }}{\Gamma (4-\alpha )} \right) \mathrm{e}^{x},\quad \phi _{0}(t)=t^{3}, \quad \phi _{L}(t)=t^{3}\mathrm{e},\nonumber \\&\quad \varphi (x)\equiv 0. \end{aligned}$$
(6.6)

The exact analytical solution to this problem is given by \(v(x,t)=t^{3}\mathrm{e}^{x}\).

We now use the compact difference scheme (2.17) in this paper and the difference scheme (24) in [28] to solve the above problem numerically. Tables 3 and 4 list the error \(\mathrm{e}_{\infty }(\tau ,h)\), the temporal convergence order \(\mathrm{order}_{\infty }^\mathrm{t}(\tau ,h)\) and the spatial convergence order \(\mathrm{order}_{\infty }^\mathrm{s}(\tau ,h)\) of these two schemes for \(\alpha =1/4, 1/2, 3/4\). It is seen that the compact difference scheme (2.17) is more accurate than the difference scheme (24) in [28]. Specifically, the compact difference scheme (2.17) possesses the fourth-order spatial accuracy and the \((2-\alpha )\)-order temporal accuracy, while the difference scheme (24) in [28] has only the first-order spatial and temporal accuracy.

Table 3 Comparisons of the temporal accuracy between the scheme (2.17) and the scheme \((24)\) in [28] for Example 6.2
Table 4 Comparisons of the spatial accuracy between the scheme (2.17) and the scheme \((24)\) in [28] for Example 6.2

Example 6.3

In this example, we test the error and the convergence order of the compact difference scheme (2.18). Consider the following problem

$$\begin{aligned} \left\{ \begin{array}{l} \displaystyle \frac{\partial ^{\alpha } v}{\partial t^{\alpha }}(x,t)=\frac{\partial ^{2} v}{\partial x^{2}}(x,t)-\frac{1}{1+x}\frac{\partial v}{\partial x}(x,t)+\frac{1}{2}(1+x)^{2}t^{2}\Gamma (3+\alpha ), \quad (x,t)\in (0,1)\times (0,1), \\ v(0,t)=1+t^{2+\alpha }, \quad v(1,t)=4\left( 1+t^{2+\alpha }\right) , \qquad t\in (0,1],\\ v(x,0)=(1+x)^{2}, \qquad x\in [0,1]. \end{array} \right. \end{aligned}$$
(6.7)

Its exact analytical solution is given by \(v(x,t)=(1+t^{2+\alpha })(1+x)^{2}\).

We use the compact difference scheme (2.18) to solve the above problem numerically. In Table 5, we give the errors \(\mathrm{e}_{\nu }(\tau ,h)\) \((\nu =1,2,\infty )\) and the temporal convergence orders \(\mathrm{order}_{\nu }^\mathrm{t}(\tau ,h)\) \((\nu =1,2,\infty )\) of the computed solution \(v_{i}^{n}\) for \(\alpha =1/4, 1/2, 3/4,19/20\) and different time step \(\tau \), where the spatial step \(h\approx \tau ^{\frac{2-\alpha }{4}}\) (\(M=\lceil \tau ^{-\frac{2-\alpha }{4}}\rceil \)). It is seen that the computed solution \(v_{i}^{n}\) has the temporal accuracy of order \((2-\alpha )\). The numerical results in Table 6 give the errors \(\mathrm{e}_{\nu }(\tau ,h)\) \((\nu =1,2,\infty )\) and the spatial convergence orders \(\mathrm{order}_{\nu }^\mathrm{s}(\tau ,h)\) \((\nu =1,2,\infty )\) of the computed solution \(v_{i}^{n}\) for \(\alpha =1/4, 1/2, 3/4,19/20\) and different spatial step \(h\), where the time step \(\tau \approx h^{\frac{4}{2-\alpha }}\) (\(N=\lceil h^{-\frac{4}{2-\alpha }}\rceil \)). These results show that the compact difference scheme (2.18) generates the fourth-order spatial accuracy.

We notice that when \(\alpha =19/20\), the constraint condition on \(\Vert q\Vert _{\infty }^{2}\) in Theorems 5.1 and 5.3 does not hold for the present problem since \(\Vert q\Vert _{\infty }^{2}=\frac{9}{16}>\frac{32}{3\Gamma (0.05)}\). However, the corresponding numerical results in Tables 5 and 6 show that compact difference scheme (2.18) is still stable and convergent. This implies that the constraint condition on \(\Vert q\Vert _{\infty }^{2}\) in Theorems 5.1 and 5.3 is only a sufficient condition for the stability and convergence of the compact difference scheme (2.18) with the general \(q(x)\).

For comparison, we also use the difference scheme (24) in [28] to solve the above problem numerically. Table 7 lists the errors \(\mathrm{e}_{\nu }(\tau ,h)\) \((\nu =1,2,\infty )\) and the spatial convergence orders \(\mathrm{order}_{\nu }^\mathrm{s}(\tau ,h)\) \((\nu =1,2,\infty )\) of this scheme for \(\alpha =1/4, 1/2, 3/4\) and different spatial step \(\tau \), where the time step \(\tau \approx h^{\frac{1}{2-\alpha }}\) (\(N=\lceil h^{-\frac{1}{2-\alpha }}\rceil \)). It is seen that the scheme has only the first-order spatial accuracy.

Table 5 The temporal errors and convergence orders of the compact difference scheme (2.18) for Example 6.3 \((h\approx \tau ^{\frac{2-\alpha }{4}})\)
Table 6 The spatial errors and convergence orders of the compact difference scheme (2.18) for Example 6.3 \((\tau \approx h^{\frac{4}{2-\alpha }})\)
Table 7 The spatial errors and convergence orders of the difference scheme \((24)\) in [28] for Example 6.3 \((\tau \approx h^{\frac{1}{2-\alpha }})\)

7 Concluding remarks

We have presented and analyzed a high-order compact finite difference method for a class of time fractional convection-subdiffusion equations. The convection coefficients may be spatially variable, and the time fractional derivative is in the Caputo’s sense with the order \(\alpha \) (\(0<\alpha <1\)). The class of the equations under consideration includes time fractional mobile/immobile subdiffusion or convection-subdiffusion equations with spatially variable convection coefficients. We have proved that the proposed compact finite difference method is uniquely solvable, stable and convergent, and provided the optimal error estimates in the discrete \(H^{1}\), \(L^{2}\) and \(L^{\infty }\) norms. The error estimate shows that the method has the fourth-order spatial accuracy and the \((2-\alpha )\)-order temporal accuracy. Numerical results confirm our analysis and show the efficiency of the method.

In this paper, we use an indirect approach so that the scheme derived in this way has a very simple and practical form for the variable convection coefficient problems. The related theoretical analysis is also quite transparent. The proposed method may be extended to the multi-dimensional problems. It is also straightforward to apply our method to Eq. (1.1) with a linear zero-order damping term \(p_{1}(x)v(x,t)\) being added. However, since our method requires an exponential transformation to eliminate the convection term, the method for the present form may not be suitable for the convection dominated problems, namely the problems of \(|p(x)|\gg d\). Whether it can be extended to solve the convection dominated problems efficiently will be an interesting subject.