1 Introduction

Fractional calculus is an old topic in mathematical analysis, which goes back to Leibniz (1695) and Euler (1730) (see [15, 16]). In recent years, the numerical solution of fractional equations has become a popular topic in applied sciences control and engineering. Bagley–Torvik equation appears in the modeling of the motion of a rigid plate submerged in a Newtonian fluid [6]. Existence and uniqueness theorem for Bagley–Torvik equation with Dirichlet boundary condition is given in [5]. In this article, the exponential spline will be employed to obtain the approximate solution of Bagley–Torvik equation with Caputo derivative

$$ u''(x)+\overline{\eta } D^{\alpha }u(x)+\mu u(x)=f(x), \quad m-1\leq \alpha \leq m, x\in [a,b], $$
(1)

subject to boundary conditions

$$ u(a)-\omega _{1}=u(b)-\omega _{2}=0. $$
(2)

Here, \(D^{\alpha }\) is the Caputo derivative, \(f(x)\) is a continuous function, \(\omega _{i}\) (\(i=1,2\)), η̅, μ are real constants, and \(m = 1\) or 2. In general, it is difficult to solve most of the fractional differential equations analytically. Therefore, numerical methods to find an approximate solution and qualitative behaviors of the solution for fractional differential equation have been investigated by authors in [19, 11, 14, 1925, 2729], and some references therein. The reproducing kernel method is employed for the fractional order differential equations in [13]. In [21], numerical solution of boundary value problem of fractional Bagley–Torvik equation is given in the reproducing kernel space. In [14], the authors study the numerical approach based on operational matrices of fractional differential equations with a hybrid of block-pulse functions and Chebyshev polynomials. The existence of positive and negative solutions and properties of their derivatives for the generalized Bagley–Torvik fractional differential equation is given in [24]. Numerical solution of the fractional Bagley–Torvik equation arising in fluid mechanics based on Taylor matrix method is given in [11]. In [29] the numerical solutions for fractional boundary value problem have been found by cubic spline polynomials. The numerical scheme for solving two-point fractional Bagley–Torvik equation using the Chebyshev collocation method has been solved in [22]. In [23] the Bagley–Torvik equation as a prototype fractional differential equation with two derivatives is investigated by means of homotopy perturbation method. The numerical solution to the Bagley–Torvik equation by exponential integrators is discussed in [9]. Also Adomian decomposition method for solving the initial value problem of Bagley–Torvik equation is discussed in [19], fractional linear multistep method and a predictor-corrector method of Adams type based on finite difference methods for initial value problem of Bagley–Torvik equation are discussed in [8]; Legendre operational matrix method for fractional differential equation is applied in [20]; and a combination of collocation points and first-order Bessel functions, which is called Bessel-collocation method for boundary value problem of Bagley–Torvik equation, is discussed in [27]. Quadratic spline solution for boundary value problem of fractional order is applied in [28], and an exponential spline technique for solving fractional boundary value problem is employed in [4].

The first aim of the present work is to explore exponential spline interpolation with multiple parameters and to produce the error of approximate exponential spline. The second aim is to introduce a new approximate technique to find solutions of fractional boundary value problem, and we demonstrate the convergence analysis for this technique.

In [10], the authors tried to approximate the solution of nonlinear fractional differential pantograph equations by sinc interpolation. At first, they have transformed the problem into a nonlinear integral equation with some delay terms and the kernel of this integral equation is weakly singular for the case \(0<\alpha <1\), thus the solution is weakly singular and the numerical methods cannot achieve high accuracy in approximating solutions. The main advantage of our algorithm is that it can be used directly without using assumption or transformation formulae.

This paper is organized into four sections. In Sect. 2, we describe basic definitions and the nonpolynomial spline method to approximate the solutions of fractional Bagley–Torvik equation. Convergence analysis is proved in Sect. 3. In Sect. 4, the numerical examples are given to illustrate the applications of the method, and also the computed results are compared with another known method in [4, 9, 17, 21, 28, 29].

2 Basic definitions and description of the methods

In this section, we recall some definitions and properties of the fractional calculus theory, which are used in this paper. There are several definitions of a fractional derivative of order \(\alpha >0\), such as Riemann–Liouville, Grunwald–Letnikov, and Caputo. In the present work, Caputo and Grunwald–Letnikov fractional derivatives are used for the formulation of the problem.

Definition 1

Let \(u(x)\) be a function defined on \((a,b)\), then the Riemann–Liouville fractional derivative is of the following form [5]:

$$ ^{R}D^{\alpha }\bigl(u(x)\bigr)=\frac{1}{\varGamma (m-\alpha )} \,\frac{d^{m}}{dx ^{m}} \int _{a}^{x}(x-t)^{m-\alpha -1}u(t)\,dt, \quad \alpha >0, m-1< \alpha < m, $$

where Γ is the gamma function.

Definition 2

The left Riemann–Liouville fractional integral [5]

$$\begin{aligned}& D_{a+}^{-\alpha }u(x)=\frac{1}{\varGamma (\alpha )} \int _{a}^{x}(x-t)^{ \alpha -1}u(t)\,dt, \quad \alpha >0, \\& D_{b-}^{-\alpha }u(x)=\frac{1}{\varGamma (\alpha )} \int _{x}^{b}(t-x)^{ \alpha -1}u(t)\,dt, \quad \alpha >0. \end{aligned}$$

Definition 3

Let \(u(x)\) be a function defined on \((a,b)\), then the Caputo fractional derivative is of the following form [5]:

$$ D^{\alpha }\bigl(u(x)\bigr)=\frac{1}{\varGamma (m-\alpha )} \int _{a}^{x} (x-t)^{m- \alpha -1}u^{(m)}(t)\,dt, \quad \alpha >0, m-1< \alpha < m. $$
(3)

Definition 4

The Grunwald definition for the fractional derivative is defined in the following form [5]:

$$ A^{\alpha }_{h,p}\bigl(u(x)\bigr)=\lim \frac{1}{h^{\alpha }}\sum_{k=0}^{\infty }g_{\alpha ,k}u \bigl(x-(k-p)h\bigr), $$
(4)

where \(A^{\alpha }_{h,p} (u(x))=^{R}D^{\alpha }(u(x))+O(h) \) and \(g_{\alpha ,k}= \frac{\varGamma (k-\alpha )}{\varGamma (-\alpha )\varGamma (k+1)}\).

Definition 5

The weighted and shifted Grünwald difference operator is as follows [25]. Let \(u(x)\in L^{1}(R)\), \({}_{ \infty } D^{ \alpha +2}_{x} (u(x))\), and its Fourier transform belongs to \(L^{1}(R)\),

$$ \textstyle\begin{cases} {}_{a}D^{ \alpha }_{h,p,q}u(x)= \frac{\vartheta }{h^{\alpha }} \sum_{k=0}^{[\frac{x-a}{h}]+p} g_{\alpha ,k}u(x-(k-p)h) \\ \hphantom{{}_{a}D^{ \alpha }_{h,p,q}u(x)= }{}+\frac{(1-\vartheta )}{h^{\alpha }}\sum_{k=0}^{[\frac{x-a}{h}]+q} g _{\alpha ,k}u(x-(k-q)h)+O(h^{2}), \\ {}_{b}D^{ \alpha }_{h,p,q}u(x)= \frac{\vartheta }{h^{\alpha }} \sum_{k=0}^{[\frac{b-x}{h}]+p} g_{\alpha ,k}u(x+(k-p)h) \\ \hphantom{{}_{b}D^{ \alpha }_{h,p,q}u(x)=}{}+\frac{(1-\vartheta )}{h^{\alpha }}\sum_{k=0}^{[\frac{b-x}{h}]+q} g _{\alpha ,k}u(x+(k-q)h)+O(h^{2}), \end{cases} $$
(5)

where \(x\in R\), \(\vartheta \in [0,1] \), also p and q (\(p\neq q\)) are integers and symmetric.

Let us consider a mesh with nodal points \(x_{i}\) on \([a,b]\) such that

$$ \Delta :a=x_{0}< x_{1}< x_{2}< \cdots < x_{n-1}< x_{n}=b, $$

where \(h=\frac{b-a}{n}\), \(x_{i}=a+ih\) for \(i=0(1)n\).

Let \(u(x)\) be the exact solution of (1) and \(S_{i}\) be an approximation to \(u_{i} = u(x_{i})\) obtained by the exponential spline function \(Q_{i}(x) \in C^{\infty }[a,b]\) passing through the points \((x_{i}, S _{i} )\) and \((x_{i+1}, S_{i+1}) \). Then in each subinterval the parametric spline segment \(Q_{i}(x)\) has the following form (see [12, 18, 26]):

$$ Q_{i}(x)=\sum_{k=1}^{4}a_{i_{k}}e^{k\beta (x - x_{i})}, $$
(6)

where β is a free parameter of the spline functions which can be real or pure imaginary and which will be used to raise the accuracy of the method, see [26].

To derive the coefficients \(a_{i_{k}}, k=1, 2, 3, 4\), of equation (6), we first define

$$ \textstyle\begin{cases} Q_{i}(x_{i} )=u_{i} , \qquad Q_{i}^{(2)}(x_{i})=M_{i}, \\ Q_{i}(x_{i+1})=u_{i+1}, \qquad Q_{i}^{(2)}(x_{i+1})=M_{i+1}. \end{cases} $$
(7)

By algebraic manipulation we get

$$\begin{aligned}& \textstyle\begin{cases} \rho _{1}= e^{-\theta } (5 e^{3 \theta } M_{i}-7 e^{4 \theta } M_{i}-5 e^{\theta } M_{i+1}+7 M_{i+1}-80 e^{3 \theta } \tau ^{2} u_{i} \\ \hphantom{\rho _{1}=}{}+28 e^{4 \theta } \tau ^{2} u_{i}+80 e^{\theta } \tau ^{2} u_{i+1}-28 \tau ^{2} u_{i+1}), \\ \rho _{2}= -e^{-2 \theta }(8 e^{3 \theta } M_{i}-7 e^{4 \theta } M _{i}-7 e^{5 \theta } M_{i}+7 e^{\theta } M_{i+1}-8 e^{2 \theta } M _{i+1} \\ \hphantom{\rho _{2}=}{}+7 M_{i+1} -128 e^{3 \theta } \tau ^{2} u_{i} +7e^{4 \theta } \tau ^{2} u_{i}+7 e^{5 \theta } \tau ^{2} u_{i}-7 e^{\theta } \tau ^{2} u _{i+1} \\ \hphantom{\rho _{2}=}{}+128 e^{2 \theta } \tau ^{2} u_{i+1}-7 \tau ^{2} u_{i+1}), \\ \rho _{3}= e^{-2 \theta }(e^{2 \theta } M_{i}+e^{3 \theta } M_{i}-4 e ^{4 \theta } M_{i}-e^{\theta } M_{i+1}-e^{2 \theta } M_{i+1} \\ \hphantom{\rho _{3}=}{}+4 M_{i+1}-16 e^{2 \theta } \tau ^{2} u_{i}-16 e^{3 \theta } \tau ^{2} u_{i}+4 e^{4 \theta } \tau ^{2} u_{i} \\ \hphantom{\rho _{3}=}{}+16 e^{\theta } \tau ^{2} u_{i+1}+16 e^{2 \theta } \tau ^{2} u_{i+1}-4 \tau ^{2} u_{i+1}), \\ \rho _{4}=-e^{-2 \theta }(3 e^{2 \theta } M_{i}-5 e^{3 \theta } M_{i}-3 e^{\theta } M_{i+1}+5 M_{i+1}-27 e^{2 \theta } \tau ^{2} u_{i} \\ \hphantom{\rho _{4}=}{}+5 e^{3 \theta } \tau ^{2} u_{i}+ 27 e^{\theta } \tau ^{2} u_{i+1}-5 \tau ^{2} u_{i+1}), \\ \rho _{5}=3 (e^{\theta }-1 )(-18 e^{\theta }+7 e^{2 \theta }+7)\tau ^{2}, \end{cases}\displaystyle \\& a_{i_{1}}=\frac{\rho _{1}}{\rho _{5}}, \qquad a_{i_{2}}=\frac{\rho _{2}}{\rho _{5}}, \qquad a_{i_{3}}= \frac{\rho _{3}}{\rho _{5}}, \qquad a_{i_{4}}=\frac{\rho _{4}}{\rho _{5}}, \end{aligned}$$
(8)

where \(\theta =h\beta \). Applying the continuity of the first derivative of \(Q'_{i}(x )=Q'_{i-1}(x )\) at \(x=x_{i}\) for \(i=1,\ldots,n-1\), we get the following consistency relation:

$$ h^{2}(\alpha _{1} M_{i-1}+ \alpha _{2} M_{i}+ \alpha _{3} M_{i+1})=\alpha _{4}u_{i+1}+\alpha _{5} u_{i}+\alpha _{6}u_{i-1}, $$
(9)

where

$$\begin{aligned}& \alpha _{1}=\frac{2 e^{-2 \theta } (e^{\theta }-1 )^{2}}{3 \theta ^{2}}, \qquad \alpha _{2}= \frac{4 (e^{\theta }+1 ) (e ^{\theta }-1 )^{2}}{3 \theta ^{2}}, \\& \alpha _{3}=\frac{2 e^{3 \theta } (e^{\theta }-1 )^{2}}{3 \theta ^{2}}, \qquad \alpha _{4}= \frac{2}{3} e^{-2 \theta } \bigl(-11 e^{ \theta }+16 e^{2 \theta }+1 \bigr), \\& \alpha _{5}=\frac{2}{3} \bigl(e^{\theta }+1 \bigr) \bigl(-28 e^{ \theta }+11 e^{2 \theta }+11 \bigr), \qquad \alpha _{6}=\frac{2}{3} e^{3 \theta } \bigl(-11 e^{\theta }+e^{2 \theta }+16 \bigr). \end{aligned}$$

For the development of consistency relations between the exponential spline approximation and its derivatives at the nodal points, we consider the following four relations:

$$ \textstyle\begin{cases} Q_{i}(x_{i} )=u_{i} , \qquad Q'_{i}(x_{i})=m_{i}, \\ Q_{i}(x_{i+1})=u_{i+1}, \qquad Q'_{i}(x_{i+1})=m_{i+1}. \end{cases} $$
(10)

After a simple calculation, we obtain the values of coefficients, and using the second-order derivative continuity at the knots \(x_{i}\), for \(i=1,\ldots,n-1\), we get

$$ h (\beta _{1} m_{i-1}+\beta _{2} m_{i}+\beta _{3} m_{i+1} )= (\beta _{4} u_{i-1}+\beta _{5} u_{i}+\beta _{6} u_{i+1} ), $$
(11)

where

$$\begin{aligned}& \beta _{1}=-2 e^{-2 \theta }, \qquad \beta _{2}=-4 \bigl(e^{\theta }+1 \bigr), \\& \beta _{3}=-2 e^{3 \theta }, \qquad \beta _{4}= \frac{2 e^{-2 \theta } (4 e^{\theta }-1 ) \theta }{e^{\theta }-1}, \\& \beta _{5}=10 \bigl(e^{\theta }+1 \bigr) \theta , \qquad \beta _{6}=\frac{2 e^{3 \theta } (e^{\theta }-4 ) \theta }{e^{\theta }-1}. \end{aligned}$$

In the limiting case, when \(\theta \to 0\), relations (9) and (11) reduce into the ordinary cubic spline relation:

$$ \textstyle\begin{cases} \frac{h^{2}}{6}[M_{i-1}+4M_{i}+M_{i+1}]=u_{i+1}-2u_{i}+u_{i-1}, & i=1,\ldots,n-1, \quad \textbf{(I)} \\ -2h ( m_{i-1}+4 m_{i}+ m_{i+1} )= (6 u_{i-1}-6 u _{i+1} ), &i=1,\ldots,n-1. \quad \textbf{(II)} \end{cases} $$
(12)

The proposed differential Eq. (1) in the mesh point \((x_{i})\) may be discretized by

$$ M_{i}=f_{i}-\overline{\eta } D^{\alpha }_{t} u_{i}-\mu u_{i}, \quad i=1,\ldots,n-1. $$
(13)

Lemma 1

The local truncation error\(x_{i}\)associated with equations (9) and (11) for\(i=1,\ldots,n-1\)in the limiting case when\(\theta \to 0\)is given by

$$\begin{aligned}& \bigl\vert u''_{i}-Q''_{i} \bigr\vert =\frac{h^{2}}{12}Q^{(4)}_{i}+O \bigl(h^{4}\bigr), \end{aligned}$$
(14)
$$\begin{aligned}& \bigl\vert Q''_{i}-u''_{i} \bigr\vert = \frac{h^{2}}{12}u^{(4)}_{i}+O \bigl(h^{4}\bigr), \end{aligned}$$
(15)
$$\begin{aligned}& \bigl\vert u'_{i}-Q'_{i} \bigr\vert = \frac{h^{4}}{180}Q^{(5)}_{i}+O \bigl(h^{5}\bigr), \end{aligned}$$
(16)
$$\begin{aligned}& \bigl\vert Q'_{i}-u'_{i} \bigr\vert =\frac{h^{4}}{180}u^{(5)}_{i} +O \bigl(h^{5}\bigr). \end{aligned}$$
(17)

Proof

The above expressions can be obtained by expanding the terms \(M_{i+1}\), \(M_{i-1}\), \(m_{i+1}\), \(m_{i-1}\), \(u_{i+1}\), and \(u_{i-1}\) about the points \(x_{i}\) in relations (12) using Taylor series respectively. Moreover,

$$ \textstyle\begin{cases} u''_{i}=Q''_{i}+\frac{h^{2}}{12}Q^{(4)}_{i}+\frac{h^{4}}{240}Q^{(6)} _{i}-\frac{h^{6}}{6048}Q^{(8)}_{i}+O(h^{7}), & i=1,\ldots,n-1, \quad \textbf{(I)} \\ Q''_{i}=u''_{i}-\frac{h^{2}}{12}u^{(4)}_{i}+\frac{h^{4}}{360}u^{(6)} _{i}+\frac{17h^{6}}{60480}u^{(8)}_{i}+O(h^{7}),&i=1,\ldots,n-1. \quad \textbf{(II)} \end{cases} $$
(18)

In a similar manner, we get

$$ \textstyle\begin{cases} u'_{i}=Q'_{i}+\frac{h^{4}}{180}Q^{(5)}_{i}+\frac{h^{6}}{1512}Q^{(7)} _{i}-\frac{h^{8}}{14\text{,}400}Q^{(9)}_{i}+O(h^{9}), & i=1,\ldots,n-1, \quad \textbf{(III)} \\ Q'_{i}=u'_{i}-\frac{h^{4}}{180}u^{(5)}_{i}+\frac{h^{6}}{1512}u^{(7)} _{i}+\frac{h^{8}}{25\text{,}920}u^{(8)}_{i}+O(h^{9}),&i=1,\ldots,n-1. \quad \textbf{(IV)} \end{cases} $$
(19)

 □

2.1 Cubic and exponential splines method for approximate fractional Bagley–Torvik equation

In this section, we give some methods to approximate \(D^{\alpha }(u(x))|_{x=x _{i}}\) by using spline function.

Method I. The discrete approximation of the Caputo fractional derivative \(D^{\alpha }(u(x))\) can be obtained by a cubic spline (in the limiting case when \(\theta \to 0\), the relations of exponential spline reduce into ordinary cubic spline relation) formula as follows (see [12] and [13]):

$$ M_{i}+\overline{\eta } D^{\alpha }\bigl(u(x) \bigr)|_{x=x_{i}}+\mu u_{i}= f_{i}, \quad i=1,2,3,\ldots,n-1. $$
(20)

Using the Caputo fractional derivative for \(1< \alpha <2\), we get

$$\begin{aligned} D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} =& \frac{1}{\varGamma (2-\alpha )} \int _{0} ^{x_{i}}(x_{i}-\eta )^{1-\alpha }u''(\eta )\,d\eta . \end{aligned}$$
(21)

Using a piecewise technique, the following equation is obtained using equation (21) and Lemma 1:

$$\begin{aligned} D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} =& \frac{1}{\varGamma (2-\alpha )}\sum_{j=1} ^{i} \int _{(j-1)h}^{jh}\bigl(Q''( \eta )+O\bigl(h^{2}\bigr)\bigr) (x_{i}-\eta )^{1-\alpha }\,d\eta . \end{aligned}$$
(22)

Since \((x_{i}-\eta )^{1-\alpha }\) does not change sign on \([(j-1)h, jh]\), by the weighted mean value theorem for integrals and by applying to each integration of the last summation, we get

$$ \int _{(j-1)h}^{jh}\bigl(Q''( \eta )+O\bigl(h^{2}\bigr)\bigr) (x_{i}-\eta )^{1-\alpha }\,d\eta =\bigl(Q''(\overline{\eta })+O\bigl(h^{2}\bigr)\bigr) \int _{(j-1)h}^{jh}(x_{i}-\eta )^{1- \alpha }\,d\eta , $$

where \(\overline{\eta }\in [(j-1)h, jh]\). After simple calculations, equations (6), (10), and (22) become

$$\begin{aligned}& D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} \\& \quad =\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \biggl(-\frac{6 (\eta _{j}-x _{i} ) (-h m_{j}-h m_{j+1}-2 u_{j}+2 u_{j+1} )}{h ^{3}} \\& \qquad {}-\frac{2 (2 h m_{j}+h m_{j+1}+3 u_{j}-3 u_{j+1} )}{h^{2}}O\bigl(h ^{2}\bigr)\biggr) \bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \\& \quad =\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{2-\alpha }-(x _{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{6(x_{i}-jh)}{h^{2}}-\frac{4}{h}\biggr)m_{j} \\& \qquad {}+\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{2-\alpha }-(x _{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{6(x_{i}-jh)}{h^{2}}-\frac{2}{h}\biggr)m_{j+1} \\& \qquad {}+\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{2-\alpha }-(x _{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{12(x_{i}-jh)}{h^{3}}-\frac{6}{h}\biggr)u_{j} \\& \qquad {}+\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{2-\alpha }-(x _{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{-12(x_{i}-jh)}{h^{3}}-\frac{6}{h^{2}}\biggr)u _{j+1} \\& \qquad {}+\frac{1}{\varGamma (m-\alpha +1)}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \bigl(O\bigl(h^{2}\bigr)\bigr). \end{aligned}$$
(23)

Using [12] and [13], we have \(\|Q''-u'' \| _{\infty }=O(h^{2})\). Also we obtain the following relation for \(i = 1, 2, \ldots , n-1\):

$$\begin{aligned}& M_{i} + \frac{\overline{\eta }}{\varGamma (3-\alpha )}\sum _{j=1}^{i}\overline{a _{ij}}m_{j}+ \frac{\overline{\eta }}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \overline{b _{ij}}m_{j+1} \\& \qquad {}+\frac{\overline{\eta }}{\varGamma (3-\alpha )}\sum_{j=1}^{i} \overline{c _{ij}}u_{j}+\frac{\overline{\eta }}{\varGamma (3-\alpha )}\sum _{j=1}^{i}\overline{d _{ij}}u_{j+1}+\mu u_{i} \\& \quad = f_{i}, \quad i=1, 2, 3, \ldots,n-1. \\& \overline{a}_{ij}=\bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{6(x _{i}-jh)}{h^{2}}-\frac{4}{h}\biggr), \\& \overline{b}_{ij+1}=\bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{6(x _{i}-jh)}{h^{2}}-\frac{2}{h}\biggr), \\& \overline{c}_{ij}=\bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{12(x _{i}-jh)}{h^{3}}-\frac{6}{h}\biggr), \\& \overline{d}_{ij+1}=\bigl((x_{i}-jh+h)^{2-\alpha }-(x_{i}-jh)^{2-\alpha } \bigr) \biggl(\frac{-12(x _{i}-jh)}{h^{3}}-\frac{6}{h^{2}}\biggr), \end{aligned}$$
(24)

where \(\overline{a}_{in}=\overline{c}_{in}=\overline{b}_{i1}= \overline{d}_{i1}=0\) for \(i=1, 2, \ldots,n\). Also we approximate \(u_{i}\) by \(\hat{u_{i}}\) and \(m_{i}\) by \(\hat{m_{i}}\) such that \(\hat{u_{i}}\) and \(\hat{m_{i}}\) for \(i = 1, 2, \ldots,n\) satisfy system (11). We get

$$\begin{aligned}& \hat{ M_{i}}+\frac{\overline{\eta }}{\varGamma (m-\alpha +1)} \Biggl(\sum _{j=1} ^{i}\overline{a}_{ij} \hat{m_{j}}+\sum_{j=1}^{i} \overline{b}_{ij} \hat{m_{j+1}}+\sum _{j=1}^{i}\overline{c}_{ij} \hat{u_{j}}+\sum_{j=1} ^{i} \overline{d}_{ij}\hat{u_{j+1}}\Biggr) \\& \quad {}+\mu \hat{u_{i}}= f_{i}, \quad i=1,2,3,\ldots,n. \end{aligned}$$
(25)

Finally, we approximate the exact solution \(u_{i}\) by the natural cubic spline function \(\widehat{Q_{i}}(x) \) for \(i = 1, 2, \ldots,n\). In the matrix notation, we get

$$ \hat{M}+\frac{\overline{\eta }}{\varGamma (m-\alpha +1)}(\overline{A} \hat{m}+\overline{B} \hat{m}+\overline{C}\hat{U}+\overline{D}\hat{U})+ \mu \hat{U}= F, $$
(26)

where \(\overline{A}=(\overline{a}_{ij})\), \(\overline{B}=(\overline{b}_{ij})\), \(\overline{C}=(\overline{c}_{ij})\), and \(\overline{D}=(\overline{d} _{ij})\). Now, the values \(\hat{ M_{i}}\) and \(\hat{ m_{i}} \) are determined as the solutions of linear systems (12)(I) and (12)(II). We approximate \(\hat{m_{0}}=\frac{-3\hat{u}_{0}+4 \hat{u}_{1}-\hat{u}_{2}}{2h}\), \(\hat{m_{n}}=\frac{3\hat{u}_{n-2}-4\hat{u}_{n-1}-\hat{u}_{n}}{2h}\), and also, by using boundary conditions, we approximate \(\hat{ M_{i}}\) for \(i=0, n\). We need the following lemma.

Lemma 2

The matricesWandZare obtained with the help of systems (9) and (11) invertible.

Proof

The values \(\hat{M}_{i}\) are determined as the solutions of the following linear system:

$$ \begin{bmatrix} 1& 0 & 0 & 0 & \ldots & \ldots & 0 & 0 & 0 &0 \\ 1& 10 & 1 & 0 & \ldots & \ldots & 0 & 0 & 0 &0 \\ 0& 1 & 10 & 1 & \ldots & \ldots & 0 & 0 & 0&0 \\ \vdots &\vdots & \ddots & \ddots & \ddots & \ddots & \ldots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ldots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ddots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots & \vdots \\ 0& 0 & 0 & 0 & \ldots & \ldots & 1 & 10 & 1&0 \\ 0& 0 & 0 & 0 & \ldots & \ldots & 0 & 1 & 10 &1 \\ 0&0 & 0 & 0 & \ldots & \ldots & 0 & 0 & 0 &1 \end{bmatrix} \begin{bmatrix} \hat{M}_{0} \\ \hat{M}_{1} \\ \hat{M}_{2} \\ \vdots \\ \vdots \\ \vdots \\ \vdots \\ \hat{M}_{n-2} \\ \hat{M}_{n-1} \\ \hat{M}_{n} \end{bmatrix}=\frac{12}{h^{2}} \begin{bmatrix} \hat{u}_{0} \\ \hat{u}_{0}-2\hat{u}_{1}+\hat{u}_{2} \\ \hat{u}_{1}-2\hat{u}_{2}+\hat{u}_{3} \\ \vdots \\ \vdots \\ \vdots \\ \vdots \\ \hat{u}_{n-3}-2\hat{u}_{n-2}+\hat{u}_{n-1} \\ \hat{u}_{n-2}-2\hat{u}_{n-1}+\hat{u}_{n} \\ \hat{u}_{n} \end{bmatrix}. $$
(27)

Also the values \(\hat{m}_{i}\) are determined as follows:

$$ \begin{bmatrix} 1& 0 & 0 & 0 & \ldots & \ldots & 0 & 0 & 0 &0 \\ 1& 10 & 1 & 0 & \ldots & \ldots & 0 & 0 & 0 &0 \\ 0& 1 & 10 & 1 & \ldots & \ldots & 0 & 0 & 0&0 \\ \vdots &\vdots & \ddots & \ddots & \ddots & \ddots & \ldots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ldots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ddots & \vdots & \vdots & \vdots \\ \vdots &\vdots & \vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots & \vdots \\ 0& 0 & 0 & 0 & \ldots & \ldots & 1 & 10 & 1&0 \\ 0& 0 & 0 & 0 & \ldots & \ldots & 0 & 1 & 10 &1 \\ 0&0 & 0 & 0 & \ldots & \ldots & 0 & 0 & 0 &1 \end{bmatrix} \begin{bmatrix} \hat{m}_{0} \\ \hat{m}_{1} \\ \hat{m}_{2} \\ \vdots \\ \vdots \\ \vdots \\ \vdots \\ \hat{m}_{n-2} \\ \hat{m}_{n-1} \\ \hat{m}_{n} \end{bmatrix}=\frac{24}{h} \begin{bmatrix} \frac{-3\hat{u_{0}}+4\hat{u_{1}}-\hat{u_{2}}}{48} \\ \hat{u}_{2}-\hat{u}_{0} \\ \hat{u}_{3}-\hat{u}_{1} \\ \vdots \\ \vdots \\ \vdots \\ \vdots \\ \hat{u}_{n-1}-\hat{u}_{n-3} \\ \hat{u}_{n}-\hat{u}_{n-2} \\ \frac{3\hat{u}_{n-2}-4\hat{u}_{n-1}-\hat{u}_{n}}{48} \end{bmatrix}. $$
(28)

Also, for determining the values \(\hat{M}_{i}\) and \(\hat{m}_{i}\), in the limiting case when \(\theta \to 0\), by using relations (12), the matrices W and Z are strictly diagonally-dominant matrices, then the matrices W and Z are invertible. Hence,

$$ \textstyle\begin{cases} h^{2}W\hat{M}=R\hat{U}, & \hat{M}=\frac{1}{h^{2}}W^{-1}R\hat{U}, \\ hZ\hat{m}=S\hat{U}, & \hat{m}=\frac{1}{h}Z^{-1}S\hat{U}. \end{cases} $$
(29)

Therefore, from (26) and (29) we obtain

$$ \biggl(h^{2}W^{-1}R+ \frac{\overline{\eta }}{h} \bigl(\overline{A}Z^{-1}S+ \overline{B}Z^{-1}S+ \overline{C}+\overline{D}\bigr)+\mu I\biggr)\hat{U}= F. $$
(30)

 □

Method II. Suppose that \(M_{j}=Q''(x_{j})\) is approximated \(u''(x_{j})\) in the subintervals \([(j-1)h,jh]\) for \(i=1,2,3,\ldots,n-1\) and \(j=1,2,\ldots,i\). Also, by using equation (23), the following recurrence relation is obtained:

$$ D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}}= \frac{h^{2-\alpha }}{\varGamma (3-\alpha )}\sum _{j=1}^{i}\hat{M_{j}} \bigl((i-j+1)^{2- \alpha }-(i-j)^{2-\alpha }\bigr)+O\bigl(h^{2} \bigr). $$

Bagley–Torvik equation (1)–(2) for \(1< \alpha <2\) can be discretized as follows:

$$\begin{aligned}& \hat{ M_{i}}+\frac{\overline{\eta }h^{2-\alpha }}{\varGamma (3-\alpha )} \sum _{j=1}^{i}\bigl((i-j+1)^{2-\alpha }-(i-j)^{2-\alpha } \bigr)\hat{M_{j}}+ \mu \hat{u_{i}} \\& \quad = f_{i}, \quad i=1,2,3,\ldots,n. \end{aligned}$$
(31)

Finally, we approximate the exact solution \(u_{i}\) by the natural cubic spline function \(\widehat{Q_{i}}(x) \) for \(i = 1,2,\ldots,n\). In the matrix notation, we get

$$ \hat{M}+\overline{\eta }h^{2-\alpha }(\rho \hat{M})+\mu \hat{U}= F, $$
(32)

where \(\rho =\frac{1}{\varGamma (3-\alpha )}\sum_{j=1}^{i}((i-j+1)^{2- \alpha }-(i-j)^{2-\alpha })\).

Hence, from (29) and (32) we also obtain

$$ \frac{1}{h^{2}}W^{-1}R\hat{U}+\overline{\eta }h^{2-\alpha }\biggl(\rho \frac{1}{h ^{2}}W^{-1}R\hat{U} \biggr)+\mu \hat{U}= F. $$
(33)

Method III. In this section, we approximate the exact solution by use of the Caputo fractional derivative for \(0< \alpha <1\) as follows:

$$\begin{aligned} D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} =& \frac{1}{\varGamma (1-\alpha )} \int _{0} ^{x_{i}}(x_{i}-\eta )^{-\alpha }u'(\eta )\,d\eta . \end{aligned}$$
(34)

Using a piecewise technique, equation (34) becomes

$$\begin{aligned} D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} =& \frac{1}{\varGamma (1-\alpha )}\sum_{j=1} ^{i} \int _{(j-1)h}^{jh}\bigl(Q'(\eta )+O \bigl(h^{3}\bigr)\bigr) (x_{i}-\eta )^{-\alpha }\,d\eta . \end{aligned}$$
(35)

Since \((x_{i}-\eta )^{-\alpha }\) does not change sign on \([(j-1)h, jh]\), by the weighted mean value theorem for integrals and by applying to each integration of the last summation, we get

$$ \int _{(j-1)h}^{jh}\bigl(Q'(\eta )+O \bigl(h^{3}\bigr)\bigr) (x_{i}-\eta )^{-\alpha }\,d\eta =\bigl(Q'(\overline{ \eta })+O\bigl(h^{3}\bigr) \bigr) \int _{(j-1)h}^{jh}(x_{i}-\eta )^{-\alpha }\,d\eta . $$
(36)

After simple calculations, from equations (34) and (36) we get

$$\begin{aligned} D^{\alpha }\bigl(u(x)\bigr)|_{x=x_{i}} =& \frac{1}{\varGamma (2-\alpha )}\sum_{j=1} ^{i} \bigl(Q'(jh)+O\bigl(h^{3}\bigr)\bigr) \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \\ =&\frac{1}{\varGamma (2-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \bigl(a_{i_{1}}\tau e^{\theta (j-i)}\bigr) \\ &{}+\frac{1}{\varGamma (2-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \bigl(2a_{i_{2}}\tau e^{2\theta (j-i)}\bigr) \\ &{}+\frac{1}{\varGamma (2-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \bigl(3a_{i_{3}}\tau e^{3\theta (j-i)}\bigr) \\ &{}+\frac{1}{\varGamma (2-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \bigl(4a_{i_{4}}\tau e^{4\theta (j-i)}\bigr) \\ &{}+\frac{1}{\varGamma (2-\alpha )}\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \bigl(O\bigl(h^{3}\bigr)\bigr), \end{aligned}$$
(37)

where \(a_{i_{k}}\) for \(i=1,2,3,4\) are given in relation (8).

The values \(M_{j}, j=0,1,2,\ldots,n \), are determined by using (9) with natural boundary conditions \(M_{0}=Q''(a)=M_{n}=Q''(b)=0\); in consequence, we approximate \(u_{i}\) by \(\hat{u_{i}}\) and \(M_{i}\) by \(\hat{M_{i}}\) so that \(\hat{u_{i}}\) and \(\hat{M_{i}}\) for \(i = 1,2,\ldots,n-1\) satisfy system (9). We get

$$\begin{aligned}& \hat{M_{i}}+ \frac{\overline{\eta }h}{\varGamma (2-\alpha )}\biggl( \frac{ (e ^{\theta }-1 )^{2} (7 e^{\theta }-3 )}{3 (e ^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr)\sum_{j=1}^{i} \bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1- \alpha } \bigr)\hat{M_{j}} \\& \quad {}+ \frac{\overline{\eta }h}{\varGamma (2-\alpha )}\biggl( \frac{2 e^{-2 \theta } (e^{\theta }-1 )^{2}}{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr)\sum _{j=1} ^{i}\bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr)\hat{M}_{j+1} \\& \quad{} + \frac{\overline{\eta }}{h \varGamma (2-\alpha )}\biggl( \frac{2 (46 e ^{\theta }-29 e^{2 \theta }+7 e^{3 \theta }-18 )\theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 )} \biggr)\sum _{j=1}^{i}\bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1- \alpha } \bigr)\hat{u_{j}} \\& \quad{} + \frac{\overline{\eta }}{h\varGamma (2-\alpha )}\biggl( -\frac{2 e^{-2 \theta } (-11 e^{\theta }+16 e^{2 \theta }+1 ) \theta }{3 (e ^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 )} \biggr)\sum _{j=1}^{i}\bigl((x_{i}-jh+h)^{1-\alpha }-(x_{i}-jh)^{1-\alpha } \bigr) \hat{u}_{j+1} \\& \quad {}+ \mu \hat{u_{i}}= f_{i}+O\bigl(h^{2} \bigr),\quad i=1,2,\ldots,n-1. \end{aligned}$$
(38)

This implies that

$$\begin{aligned}& \hat{M_{i}} + \frac{\overline{\eta }h^{2-\alpha }}{\varGamma (2-\alpha )}\biggl( \frac{ (e ^{\theta }-1 )^{2} (7 e^{\theta }-3 )}{3 (e ^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr)\sum_{j=1}^{i}( \dot{\lambda }_{ij})\hat{M}_{j} \\& \quad {}+\frac{\overline{\eta }h^{2-\alpha }}{\varGamma (2-\alpha )}\biggl(\frac{2 e ^{-2 \theta } (e^{\theta }-1 )^{2}}{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr)\sum _{j=1}^{i}(\ddot{\lambda }_{ij+1}) \hat{M}_{j+1} \\& \quad {}+\frac{\overline{\eta }h^{-\alpha }}{\varGamma (2-\alpha )}\biggl( \frac{2 (46 e^{\theta }-29 e^{2 \theta }+7 e^{3 \theta }-18 ) \theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e ^{2 \theta }+7 )}\biggr)\sum _{j=1}^{i}(\tilde{\lambda }_{ij}) \hat{ u} _{j} \\& \quad {}+\frac{\overline{\eta }h^{-\alpha }}{\varGamma (2-\alpha )}\biggl( -\frac{2 e ^{-2 \theta } (-11 e^{\theta }+16 e^{2 \theta }+1 )\theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 )} \biggr)\sum _{j=1}^{i}(\bar{\lambda }_{ij+1}) \hat{u}_{j+1} \\& \quad {}+\mu \hat{u_{i}}= f_{i}+O\bigl(h^{2} \bigr),\quad i=1,2,\ldots,n-1, \end{aligned}$$
(39)

where \(\dot{\lambda }=(\dot{\lambda }_{ij})=\ddot{\lambda }=( \ddot{\lambda }_{ij})=\tilde{\lambda }=(\tilde{\lambda }_{ij})=\bar{ \lambda }=(\bar{\lambda }_{ij})=((i-j+1)^{1-\alpha }-(i-j)^{1-\alpha })\) for \(i=1,2,\ldots,n-1\) such that \((\dot{\lambda }_{i0})=(\dot{\lambda }_{in})=( \ddot{\lambda }_{i0})=(\ddot{\lambda }_{i1})=(\tilde{\lambda }_{i0})=( \tilde{\lambda }_{in})=(\bar{\lambda }_{i0})=(\bar{\lambda }_{i1})=0\). In the matrix notation, we get

$$\begin{aligned}& \hat{M} +\frac{\overline{\eta }h^{2-\alpha }}{\varGamma (2-\alpha )}\biggl( \frac{ (e^{\theta }-1 )^{2} (7 e^{\theta }-3 )}{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr) (\dot{\lambda })\hat{M} \\& \quad {}+\frac{\overline{\eta }h^{2-\alpha }}{\varGamma (2-\alpha )}\biggl( \frac{2 e ^{-2 \theta } (e^{\theta }-1 )^{2}}{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr) (\ddot{\lambda }) \hat{M} \\& \quad {}+\frac{\overline{\eta }h^{-\alpha }}{\varGamma (2-\alpha )}\biggl( \frac{2 (46 e^{\theta }-29 e^{2 \theta }+7 e^{3 \theta }-18 ) \theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e ^{2 \theta }+7 )} \biggr) (\tilde{\lambda }) \hat{ U} \\& \quad {}+\frac{\overline{\eta }h^{-\alpha }}{\varGamma (2-\alpha )}\biggl( -\frac{2 e ^{-2 \theta } (-11 e^{\theta }+16 e^{2 \theta }+1 ) \theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e ^{2 \theta }+7 )} \biggr) (\bar{\lambda }) \hat{U} \\& \quad {}+\mu \hat{U}= F+O\bigl(h^{2}\bigr), \end{aligned}$$
(40)
$$\begin{aligned}& \bigl(I+h^{2-\alpha }\varPi _{1}+h^{2-\alpha } \varPi _{2}\bigr) \hat{M}+\bigl(h^{-\alpha }\varPi _{3}+h^{-\alpha }\varPi _{4}+\mu I\bigr)\hat{U}=F, \end{aligned}$$
(41)

where \(\hat{M}=(\hat{M_{1}},\hat{M_{1}},\ldots,\hat{M_{n}})^{t}\), \(\hat{U}=(\hat{u_{1}},\hat{u_{2}},\ldots,\hat{u_{n}})^{t} \), and \(F= (f_{1},f_{2},\ldots,f_{n})^{t}\). By using (29) and (41), we have

$$ \bigl(I+h^{2-\alpha }\varPi _{1}+h^{2-\alpha } \varPi _{2}\bigr) \frac{1}{h^{2}}W^{-1}R \hat{U}+ \bigl(h^{-\alpha }\varPi _{3}+h^{-\alpha }\varPi _{4}+\mu I\bigr)\hat{U}= F $$
(42)

such that

$$\begin{aligned}& \varPi _{1}= \frac{\overline{\eta }}{\varGamma (2-\alpha )}\biggl( \frac{ (e ^{\theta }-1 )^{2} (7 e^{\theta }-3 )}{3 (e ^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr) (\dot{\lambda }), \\& \varPi _{2}= \frac{\overline{\eta }}{\varGamma (2-\alpha )}\biggl( \frac{2 e^{-2 \theta } (e^{\theta }-1 )^{2}}{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 ) \theta } \biggr) (\ddot{\lambda }), \\& \varPi _{3}= \frac{\overline{\eta }}{\varGamma (2-\alpha )}\biggl( \frac{2 (46 e^{\theta }-29 e^{2 \theta }+7 e^{3 \theta }-18 ) \theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 )} \biggr) (\tilde{\lambda }), \\& \varPi _{4}= \frac{\overline{\eta }}{\varGamma (2-\alpha )}\biggl( -\frac{2 e^{-2 \theta } (-11 e^{\theta }+16 e^{2 \theta }+1 ) \theta }{3 (e^{\theta }-1 ) (-18 e^{\theta }+7 e^{2 \theta }+7 )} \biggr) (\bar{\lambda }). \end{aligned}$$

2.2 The weighted and shifted Grünwald difference operator and exponential spline function

Method IV. In this section, we would like to develop a numerical method based on the methods in references [4, 25, 29], and [28]. Also we investigate the convergence analysis of this method. Let \(U = (u_{i})\), \(S = (s_{i})\), \(C = (c_{i})\), \(T = (t_{i})\), and \(E = (e_{i}) = U-S=U-Q_{i}(x) \) be \((n-1)\)-dimensional column vectors. We used the weighted and shifted Grünwald difference operator and exponential spline function. By using consistency relation (12)(I) and using the boundary condition, we get the system of algebraic equations

$$ NS= h^{2}BM+C, $$
(43)

where

$$\begin{aligned}& N= \textstyle\begin{cases} -2 & i=j=1,2,\ldots,n-1, \\ -1& \vert i-j \vert =1, \\ 0 & \text{otherwise}, \end{cases}\displaystyle \qquad B=\textstyle\begin{cases} \frac{4}{6} & i=j=1,2,\ldots,n-1, \\ \frac{1}{6}& \vert i-j \vert =1, \\ 0 & \text{otherwise}, \end{cases}\displaystyle \end{aligned}$$
(44)
$$\begin{aligned}& C= \begin{bmatrix} -S_{0}+\frac{h^{2}}{6}M_{0} \\ 0 \\ \vdots \\ 0 \\ -S_{n}+\frac{h^{2}}{6}M_{n} \end{bmatrix}. \end{aligned}$$
(45)

We assume that \(F=(f_{1},f_{2},f_{3},\ldots,f_{n-1})^{t}\), \(S=(s_{1},s_{2},s_{3},\ldots,s_{n-1})^{t}\)

$$ M=F-\mu S- h^{-\alpha }\bigl((G_{1}+G_{2})S+G_{3}+G_{4} \bigr), $$
(46)

where

$$\begin{aligned}& G_{1}=\overline{\eta }\vartheta \begin{bmatrix} 0& \\ g_{\alpha ,0} &0 \\ g_{\alpha ,1} &g_{\alpha ,0}&0 \\ g_{\alpha ,2}&g_{\alpha ,1}&g_{\alpha ,0}&0 \\ \vdots &\vdots &\vdots &\ddots &\ddots \\ g_{\alpha ,n-3}&g_{\alpha ,n-4}& \ldots & \ldots &g_{\alpha ,0}&0 \end{bmatrix}, \end{aligned}$$
(47)
$$\begin{aligned}& G_{2}=\overline{\eta }(1-\vartheta ) \begin{bmatrix} g_{\alpha ,0} & \\ g_{\alpha ,1} &g_{\alpha ,0} & \\ g_{\alpha ,2}&g_{\alpha ,1} &g_{\alpha ,0} \\ \vdots &\vdots & \ddots &\ddots \\ g_{\alpha ,n-2}&g_{\alpha ,n-3}& \ldots & g_{\alpha ,1}&g_{\alpha ,0} \end{bmatrix}, \end{aligned}$$
(48)
$$\begin{aligned}& G_{3}=\overline{\eta }\vartheta \omega_{1} \begin{bmatrix} g_{\alpha ,0} \\ g_{\alpha 1} \\ g_{\alpha ,2} \\ \vdots \\ g_{\alpha ,n-3} \\ g_{\alpha ,n-2} \end{bmatrix},\qquad G_{4}=\overline{\eta }(1- \vartheta ) \omega _{1} \begin{bmatrix} g_{\alpha ,1} \\ g_{\alpha 2} \\ g_{\alpha ,3} \\ \vdots \\ g_{\alpha ,n-2} \\ g_{\alpha ,n-1} \end{bmatrix}. \end{aligned}$$
(49)

Substituting equation (46) into equation (43), we obtain

$$\begin{aligned}& NS+h^{2-\alpha }B G_{1}S+h^{2-\alpha }B G_{2}S+\mu h^{2}BS \\& \quad =h^{2}BF-h^{2-\alpha }BG_{3}-h^{2-\alpha }BG_{4}+C \end{aligned}$$
(50)

and

$$\begin{aligned}& \begin{gathered}[b] NU+h^{2-\alpha }B G_{1}U+h^{2-\alpha }B G_{2}U+\mu h^{2}B U \\ \quad =h^{2}BF-h^{2-\alpha }BG_{3}-h^{2-\alpha }BG_{4}+C+T. \end{gathered} \end{aligned}$$
(51)

Now the error equation can be written as follows:

$$\begin{aligned} NE+h^{2-\alpha }B G_{1}E+h^{2-\alpha }B G_{2}E+\mu h^{2}B E =&T. \end{aligned}$$
(52)

In order to get a bound on \(\|E\|\) (the infinite norm), we need the following lemma.

Lemma 3

AssumeAto be an\((n-1)\times (n-1)\)matrix with\(\|A\|_{\infty }<1\), then the matrix\((I-A)\)is invertible in addition to\(\|(I-A)^{-1}\| _{\infty }\leq \frac{1}{1-\|A\|_{\infty }}\).

From equation (52), it can be written that

$$ E=\bigl(I+h^{2-\alpha }N^{-1}B G_{1}+h^{2-\alpha }N^{-1}B G_{2}+\mu h^{2}N ^{-1}B\bigr)^{-1}N^{-1}T. $$
(53)

Using the above lemma and (53), we get

$$ \Vert E \Vert \leq \frac{ \Vert N^{-1} \Vert \Vert T \Vert }{1- \Vert N^{-1} \Vert (h^{2-\alpha } \Vert B \Vert \Vert G _{1} \Vert +h^{2-\alpha } \Vert B \Vert \Vert G_{2} \Vert + \vert \mu \vert h^{2} \Vert B \Vert )}, $$
(54)

provided that \(\|N^{-1}\|(h^{2-\alpha }\|B\|\| G_{1}\|+h^{2-\alpha } \|B\|\| G_{2}\|+|\mu | h^{2}\|B\|)<1\). Also from equation (18) we have \(\|T\|=\frac{1}{12}h^{4}P_{4}\), where

$$ \operatorname{Max} \bigl\vert u^{(4)}(\eta _{i}) \bigr\vert =P_{4} \quad (x_{i}< \eta _{i}< x_{i+1}) $$

and \(\|B\|=1\). It was shown in [29], where \(\| G_{1}\| \leq 2|\overline{\eta }|\vartheta \), \(\|G_{2}\|\leq 2|\overline{\eta }|(1-\vartheta )\) for \(0<\alpha <1\) and \(\| G_{1}\|\leq 4|\overline{\eta }|\vartheta \), \(\|G_{2}\|\leq 4|\overline{\eta }|(1-\vartheta )\) for \(1<\alpha <2\). Also in [18] it was shown that \(\|N^{-1}\|\leq \frac{(b-a)^{2}}{8h ^{2}}\).

By substituting the values of \(\|B\|\), \(\|G_{1}\|\), \(\|G_{2}\|\), and \(\|N^{-1}\|\) in equation (54), we get

$$\begin{aligned} \Vert E \Vert \leq & \frac{ {(b-a)^{2}h^{2}P_{4}}}{12[8- (b-a)^{2}(2 \vert \overline{ \eta } \vert h^{-\alpha }\vartheta +2 \vert \overline{\eta } \vert h^{-\alpha }(1- \vartheta )+ \vert \mu \vert )]} \\ \leq &\kappa _{1}h^{2+\alpha }\equiv O\bigl(h^{2+\alpha } \bigr), \end{aligned}$$
(55)

provided \((b-a)^{2}(2|\overline{\eta }|h^{-\alpha }\vartheta +2|\overline{ \eta }|h^{-\alpha }(1-\vartheta )+|\mu |)<8\) for \(0<\alpha <1\) and \(0\leq \vartheta \leq 1\).

Theorem 1

Let\(Q_{\Delta }(x,\beta )=Q(x)\in C^{\infty }[a, b]\)be the unique nonpolynomial spline which interpolates\(u(x)\)with relations (9) and (11). Then the following error estimates hold for cubic spline (in the limiting case when\(\theta \to 0\)):

$$ \bigl\vert e(x_{i}+\tau h) \bigr\vert \leq \frac{h^{4}}{384}\phi _{4}, \qquad \operatorname{Max}_{(x_{i}< \eta _{i} < x_{i+1})} \bigl\vert u^{(4)}(\eta _{i}) \bigr\vert =\phi _{4}. $$
(56)

Proof

See [13] and [18]. Now, by using [13] we approximate \(u_{i}\) by cubic spline \(\widehat{Q} _{i}\) where

$$\begin{aligned} \textstyle\begin{cases} \vert Q_{i}(x)-\widehat{Q_{i}}(x) \vert \equiv O(h^{4}), \\ \vert Q'_{i}(x)-\widehat{Q'_{i}}(x) \vert \equiv O(h^{3}), \\ \vert Q''_{i}(x)-\widehat{Q''_{i}}(x) \vert \equiv O(h^{2}), \end{cases}\displaystyle \end{aligned}$$
(57)

and

$$ \widehat{Q_{i}}(x)=\sum _{k=1}^{4}\widehat{a_{i_{k}}}e^{k\beta (x -x _{i})}. $$
(58)

We known that \(\widehat{u}_{0}\), \(\widehat{u}_{n}\), \(\widehat{M}_{0}\), and \(\widehat{M}_{n}\) are known from boundary conditions. The notations \(\hat{M}=(\widehat{M}_{0}, \widehat{M}_{1}, \widehat{M}_{2}, \ldots, \widehat{M}_{n-1}, \widehat{M}_{n})^{T}\), \(\hat{U}=(\widehat{u}_{0}, \widehat{u}_{1}, \widehat{u}_{2}, \ldots, \widehat{u}_{n-1}, \widehat{u} _{n})^{T}\), and by using (12)(II), we get \(\widehat{m}=( \widehat{m}_{0}, \widehat{m}_{1},\widehat{m}_{2}, \ldots, \widehat{m} _{n-1},\widehat{m}_{n})^{T}\), and also \(D^{\alpha }(u(x))|_{x=x_{i}}\), \(i=0,1,2,\ldots,n\), are taken from (5). Therefore, by using (57) and (55), we get

$$\Vert U-\hat{S} \Vert _{\infty } \leq \Vert U-S \Vert _{\infty }+ \Vert S-\hat{S} \Vert _{ \infty } \leq \kappa _{1}h^{2+\alpha }+\kappa _{1}h^{4} \equiv O\bigl(h^{2+ \alpha }\bigr). $$

It follows \(\|E\|\rightarrow 0\) as \(h\rightarrow 0\). Therefore the convergence of this method has been established. □

3 Convergence analysis

In this section, we discuss the convergence analysis of exponential spline Method III. Convergence analyses of Method I and Method II are similar. So, first we write equation (41) in the points of \(x_{i}\), \(i=1,2,\ldots,n-1\):

$$ \textstyle\begin{cases} F(x_{i},u(x_{i}),u''(x_{i}))=0, \quad i=0,1,2,\ldots,n, \\ u(x_{0})=\omega _{1}, \qquad u(x_{n})=\omega _{2}. \end{cases} $$
(59)

Now, using the results obtained in (18), we have

$$ \textstyle\begin{cases} F(x_{i},Q(x_{i}),Q''(x_{i}))=0, \quad i=0,1,2,\ldots,n, \\ Q(x_{0})=\omega _{1}, \qquad Q(x_{n})=\omega _{2}. \end{cases} $$
(60)

Equations (60) construct a nonlinear system, which can be solved by Newton’s iterations method. Let \(u(x)\) be the exact solution of the problem and \(Q(x)\in C^{\infty }[0,T]\) be the exponential spline approximation to \(u(x)\) satisfied in \(Q(x_{i})=u(x_{i})\), \(i=1,2,\ldots,n-1\), and \(Q''(x_{i})=u''(x_{i})\), \(i=0,n\). We should approximate the error \(\|u(x)-Q(x)\|\). Let us assume that \(\hat{Q}(x)\) is the computed spline approximation to \(Q(x)\). To estimate \(\|u(x)-Q(x)\|\), we will estimate \(\|u(x)-\hat{Q}(x) \|\) and \(\|\hat{Q}(x)-Q(x)\|\) separately.

Lemma 4

Let\(\hat{Q}(x)\)be the unique spline interpolation to\(Q(x)\), and also suppose that partial derivatives ofFexist and\(|\frac{\partial F}{ \partial u}|\leq k_{1}\), \(|\frac{\partial F}{\partial u''}|\leq k_{2}\)for some constants\(k_{1}\)and\(k_{2}\). Then, for\(0 \leq i \leq n\), we have

$$ \bigl\vert F\bigl(t_{i},Q(x_{i}),Q''(x_{i}) \bigr)- F\bigl(x_{i},\hat{Q}(x_{i}), \hat{Q}''(x_{i})\bigr) \bigr\vert \leq O\bigl(h^{2}\bigr). $$
(61)

Proof

For \(1\leq i\leq n-1\), we get

$$\begin{aligned}& \begin{gathered} F\bigl(x_{i},Q(x_{i}),Q''(x_{i}) \bigr)- F\bigl(x_{i},\hat{Q}(x_{i}), \hat{Q}''(x_{i})\bigr) \\ \quad =F\bigl(x_{i},Q(x_{i}),Q''(x_{i}) \bigr)-F\bigl(x_{i},\hat{Q}(x_{i}),Q''(x_{i}) \bigr) \\ \qquad {}+ F\bigl(x_{i},\hat{Q}(x_{i}),Q''(x_{i}) \bigr)-F\bigl(x_{i},\hat{Q}(x_{i}),\hat{Q}''(x _{i})\bigr). \end{gathered} \end{aligned}$$

Now, using the mean value theorem for two parts of the above relation, there exist \(\xi _{i}\) and \(\nu _{i}\) such that

$$\begin{aligned}& F\bigl(x_{i},Q(x_{i}),Q''(x_{i}) \bigr)-F\bigl(x_{i},\hat{Q}(x_{i}),Q''(x_{i}) \bigr)=\frac{ \partial F}{\partial u}(\xi _{i}) \bigl(Q(x_{i})- \hat{Q}(x_{i})\bigr), \\& F\bigl(x_{i},\hat{Q}(x_{i}),Q''(x_{i}) \bigr)- F\bigl(x_{i},\hat{Q}(x_{i}), \hat{Q}''(x _{i})\bigr)= \frac{\partial F}{\partial u''}(\nu _{i}) \bigl(Q''(x_{i})- \hat{Q}''(x _{i})\bigr). \end{aligned}$$

Using relation (57), we have \(|Q(x_{i})-\hat{Q}(x_{i})| \equiv O(h^{4})\), \(|Q''(x_{i})-\hat{Q}''(x_{i})|\equiv O(h^{2})\), and taking the absolute value, we obtain

$$\begin{aligned}& \bigl\vert F\bigl(x_{i},Q(x_{i}),Q''(x_{i}) \bigr)- F\bigl(x_{i},\hat{Q}(x_{i}), \hat{Q}''(x_{i})\bigr) \bigr\vert \\& \quad \leq k_{1} \bigl\vert Q(x_{i})-\hat{Q}(x_{i}) \bigr\vert + k_{2} \bigl\vert Q''(x_{i})- \hat{Q}''(x _{i}) \bigr\vert \\& \quad \leq k_{1}O\bigl(h^{4}\bigr)+k_{2}O \bigl(h^{2}\bigr)\equiv O\bigl(h^{2}\bigr). \end{aligned}$$
(62)

 □

Theorem 2

Let\(u(x)\in C^{2}[0,T]\)be the exact solution (1) and\(Q(x)\)be the exponential spline approximation to\(u(x)\), then we have

$$ \bigl\Vert u(x)-Q(x) \bigr\Vert \leq O\bigl( h^{2}\bigr). $$

Proof

Since \(\hat{Q}(x)\) is an interpolation to \(u(x)\), thus there is a finite constant \(\varrho _{1}\) independent of h that we get

$$ \bigl\Vert u(x)-\hat{Q}(x) \bigr\Vert \leq \varrho _{1} h^{2}\equiv O\bigl(h^{2}\bigr), $$

where \(\varrho _{1}\) is a finite constant. Now, using the triangular inequality and Lemma 1, we can obtain the results as follows:

$$ \bigl\Vert u(x)-Q(x) \bigr\Vert \leq \bigl\Vert u(x)-\hat{Q}(x) \bigr\Vert + \bigl\Vert \hat{Q}(x)-Q(x) \bigr\Vert \equiv O\bigl(h ^{2}\bigr). $$

We can prove the convergence analysis for Method I and Method II in the same manner. □

4 Numerical results

In this section, we have implemented our methods for solving some of the Bagley–Torvik differential equations with different values of \(h=\frac{1}{8}, \frac{1}{16}, \frac{1}{32}, \frac{1}{64}, \frac{1}{128}, \frac{1}{256}, \frac{1}{512}, \frac{1}{1024}\), and \(\alpha =0, 0.2,0.3,0.4,0.5, 0.9\). The maximum absolute errors in solutions of the methods are tabulated in tables. We compute the absolute error for examples and compare them with the methods in [4, 9, 17, 21, 28, 29]. The convergence order (C.O.) is obtained by

$$ C.O.=\log _{2}\frac{E(h)}{E(\frac{h}{2})}, $$
(63)

where \(E(h)\) is the maximum absolute error. Numerical results can be derived by using MATHEMATICA 9.

Example 1

Consider the following boundary value problem [29]:

$$\begin{aligned} u''(x)+\overline{\eta } D^{\alpha }u(x)+\mu u(x) =&f(x), \qquad u(0)=u(1)=0,\quad x\in [0,1], \end{aligned}$$

where

$$ f(x)=4x^{2}(5x-3)+\overline{\eta } x^{4}-\alpha \biggl(\frac{120}{\varGamma (6- \alpha )}x-\frac{24}{\varGamma (5-\alpha )}\biggr)+\mu x^{4}(x-1), $$

the exact solution is given by the relation \(u(x)=x^{4}(x-1)\). The maximum absolute errors of Method III and Method IV are presented in Tables 1 and 3, and also compare the computed results with the method [29] in Table 2.

Table 1 Observed maximum absolute errors of Example 1 by using Method IV with \(\overline{\eta }=0.5\), \(\mu =1\)
Table 2 Observed maximum absolute errors of Example 1 in reference [29]
Table 3 Observed maximum absolute errors of Example 1 by using Method III with \(\overline{\eta }=0.5\), \(\mu =1\)

Example 2

Consider the following boundary value problem:

$$\begin{aligned}& D^{-\alpha }u''(x)+ u(x) =x^{6} \bigl(1-x^{2}\bigr)+ \biggl(\frac{720}{\varGamma (5+ \alpha )}x^{4+\alpha }- \frac{40\text{,}320}{\varGamma (7+\alpha )}\biggr)x^{6+\alpha }, \\& u(0) =u(1)=0, \quad x\in [0,1], \end{aligned}$$

where the exact solution is given by the relation \(u(x)=x^{6}(1-x^{2})\). The maximum absolute errors of Method III and Method IV are presented in Tables 7 and 4. Also compare the computed results with the methods [28] and [4] in Tables 5 and 6.

Table 4 Observed maximum absolute errors of Example 2 by using Method IV
Table 5 Observed maximum absolute errors of Example 2 in reference [28]
Table 6 Observed maximum absolute errors of Example 2 in reference [4]
Table 7 Observed maximum absolute errors of Example 2 by using Method III

Example 3

Consider the following Bagley–Torvik fractional boundary value problem:

$$ u''(x)+D^{\frac{3}{2}}u(x)+u(x)=x^{3}+5x+ \frac{8x^{\frac{3}{2}}}{\sqrt{ \pi }}, \quad x\in [0,1], \qquad u(0)=u(1)=0, $$

the exact solution is given by \(u(x)=x^{3}-x\). The numerical solutions are computed by Methods I and IV. In order to compare the solutions with [21] in Table 9, we have taken \(n=10,20\), and 40 in Table 8. The absolute error and the order of convergence for \(n = 4,8,16,32,64,128,256\), and 512 are given in Table 10.

Table 8 The numerical solutions of Method I for different n values with exact solution for Example 3
Table 9 The numerical solutions for different n values with exact solution for Example 3 in [21]
Table 10 Observed maximum absolute errors of Example 3

Example 4

Consider the following Bagley–Torvik fractional boundary value problem:

$$\begin{aligned}& \begin{gathered} u''(x)+D^{\frac{3}{2}}u(x)+u(x)= \gamma (\gamma -1)x^{\gamma -2}+\frac{ \varGamma (\gamma +1)}{\varGamma (\gamma -\frac{1}{2})}x^{\gamma - \frac{3}{2}}+x^{\gamma }, \\ \quad x\in [0,1],\qquad u(0)=0,\quad u'(0)=0. \end{gathered} \end{aligned}$$

The exact solution is given by \(u(x)=x^{\gamma }\). The absolute errors are compared with the methods [9] and [17]. In order to compare the solutions with [9], we have taken \(n = 8,16,32,64,128,256,512, 1024\) and \(\gamma =3,4\) in Tables 11 and 12.

Table 11 Observed maximum absolute errors of Example 4 for \(\gamma =3\)
Table 12 Observed maximum absolute errors of Example 4 for \(\gamma =4\)

5 Conclusion

Computational methods for solving the fractional Bagley–Torvik equation were proposed. The fractional differential equation term in the fractional Bagley–Torvik equation was discretized using the exponential spline function and the shifted Grünwald difference operator. Also we obtain the four numerical schemes based on the exponential spline. The convergence analyses of the shifted Grünwald difference and the exponential spline are discussed. The feasibility of the numerical algorithms was illustrated with four examples, and the approximated results were compared with the methods in [4, 9, 17, 21, 28, 29].