1 Introduction

In this paper, we consider the following time-fractional nonlinear Schrödinger equation:

$$ i\frac{\partial^{\alpha}u(x,t)}{\partial t^{\alpha}}+\frac{\partial ^{2}u(x,t)}{\partial x^{2}}+\lambda \bigl\vert u(x,t) \bigr\vert ^{2}u(x,t)=f(x,t), \quad (x,t)\in [a,b] \times[0,T], $$
(1)

subject to the initial condition

$$ u(x,0)=\phi(x),\quad x\in [a,b], $$
(2)

and boundary conditions

$$ u(a,t)=\psi_{1}(t),\qquad u(b,t)=\psi_{2}(t), \quad t\in[0,T], $$
(3)

where \(0< \alpha< 1\) and \(\lambda\geq0\) is a constant. \(\frac {\partial^{\alpha}u(x,t)}{\partial t^{\alpha}}\) denotes the Caputo fractional derivative of the function \(u(x,t)\) defined by

$$ \frac{\partial^{\alpha}u(x,t)}{\partial t^{\alpha}}=\frac{1}{\Gamma (1-\alpha)} \int^{t}_{0}\frac{u'(s)}{(t-s)^{\alpha}}\,ds,\quad 0< \alpha < 1. $$

In recent years, fractional differential equations have attracted extensive attention in many branches of science and engineering [15]. Particularly, there has been explosive research about studying quantum phenomena by fractional calculus. The time-fractional Schrödinger equation is a fundamental equation of fractional quantum mechanics which can be obtained from the classical Schrödinger equation by replacing the time derivative by a Caputo fractional derivative [6]. Although analytic solutions of fractional Schrödinger equations can be found in terms of special functions [79], it is difficult to obtain these functions most of the time. In general cases, numerical methods have become important for the approximate solutions of time-fractional Schrödinger equations. Wei et al. [10] presented an implicit fully discrete local discontinuous Galerkin (LDG) finite element method for the time-fractional Schrödinger equation. Mohebbi et al. [11] proposed a meshless technique based on collocation and radial basis functions. In [12], a shifted Legendre collocation method was developed for solving multi-dimensional fractional Schrödinger equations subject to initial-boundary and nonlocal conditions. Garrappa et al. [13] analyzed some approaches based on the Krylov projection methods to approximate the Mittag–Leffler function which expressed the solution of the time-fractional Schrödinger equation. In [14], the stability analysis was presented for a first order difference scheme applied to a nonhomogeneous time-fractional Schrödinger equation. Bhrawy et al. [15]used Jacobi spectral collocation approximation for multi-dimensional time-fractional Schrödinger equations. Shivanian et al. [16] applied a kind of spectral meshless radial point interpolation technique to the time-fractional nonlinear Schrödinger equation in regular and irregular domains.

The possibility of using spline functions for smooth approximate solution of differential systems was given by Ahlberg et al. [17]. Since then, the spline method has been applied to solve the boundary value problems [1821] and some partial differential equations [2226]. Recently, the spline method has been extended to solve the fractional partial differential equations. In [27], Talaat et al. presented a general framework of the cubic parametric spline functions to develop a numerical method for the time-fractional Burgers’ equation. In [28], Mohammad et al. used both polynomial and non-polynomial spline functions for approximating the solution of the fractional subdiffusion equation. In [29], Ding et al. proposed two classes of difference schemes for solving the fractional reaction-subdiffusion equations based on a mixed spline function. In [30], Li et al. developed a numerical scheme for the fractional subdiffusion equation using parametric quintic spline. In [31], Yaseen et al. adopted a cubic trigonometric B-spline collocation approach for the numerical solution of fractional subdiffusion equation. In [3235], the spline method was employed for the numerical solution of time-fractional fourth order partial differential equation. In this paper, we apply the spline method based on a cubic non-polynomial spline function to the time-fractional nonlinear Schrödinger equation.

The remainder of this paper is organized as follows. In Sect. 2, we give a description of the cubic non-polynomial function. In Sect. 3, the method depends on the use of the cubic non-polynomial spline is derived. In Sect. 4, stability analysis of the scheme is performed. An illustrative example is carried out to justify the theoretical results in Sect. 5. Finally, the conclusion is included in the last section.

2 Cubic non-polynomial spline function

In order to construct a numerical method to simulate the solution of (1), we let \(x_{j}=jh\), \(j=0,1,\ldots,M\), and \(t_{n}=n\tau\), \(n=0,1,\ldots,N\), where \(h=\frac{b-a}{M}\) and \(\tau=\frac{T}{N}\) are the uniform spatial and temporal step sizes, respectively, and M, N are two positive integers. Let \(P_{j}^{n}\) be an approximation to \(u_{j}^{n}=u(x_{j},t_{n})\), obtained by the segment \(P_{\Delta j}(x,t_{n})\) of the parametric cubic spline functions \(P_{\Delta }(x,t_{n})\) passing through the points \((x_{j},P_{j}^{n})\) and \((x_{j+1},P_{j+1}^{n})\). \(P_{\Delta}(x,t_{n},\theta)=P_{\Delta }(x,t_{n})\) is a parametric cubic spline function, depending on a parameter \(\theta> 0\), satisfying the differential equation

$$ \begin{aligned}[b] P_{\Delta}''(x,t_{n})- \theta P_{\Delta}(x,t_{n})&=\frac {x_{j+1}-x}{h} \bigl[P''(x_{j},t_{n})-\theta P(x_{j},t_{n}) \bigr] \\ &\quad{}+\frac{x-x_{j}}{h} \bigl[P''(x_{j+1},t_{n})- \theta P(x_{j+1},t_{n}) \bigr], \quad x\in[x_{j},x_{j+1}], \end{aligned} $$
(4)

which satisfies the following interpolation conditions:

$$ P_{\Delta}(x_{j},t_{n})=u(x_{j},t_{n}), \qquad P_{\Delta }(x_{j+1},t_{n})=u(x_{j+1},t_{n}). $$
(5)

The spline derivative approximations to the function derivatives \(u''(x_{j},t_{n})\) are given by

$$ P_{\Delta}''(x_{j},t_{n})=S(x_{j},t_{n}), \qquad P_{\Delta }''(x_{j+1},t_{n})=S(x_{j+1},t_{n}). $$
(6)

Basing on Eq. (4) and the above interpolatory conditions (5), we have

$$ \begin{aligned}[b] P_{\Delta}(x_{j},t_{n})&= \frac{h^{2}}{\omega^{2}\sinh(\omega)} \biggl[S_{j+1}^{n}\sinh\frac{\omega(x-x_{j})}{h}+S_{j}^{n} \sinh\frac{\omega (x_{j+1}-x)}{h} \biggr] \\ &\quad{} -\frac{h^{2}}{\omega^{2}} \biggl[\frac{x-x_{j}}{h} \biggl(S_{j+1}^{n}- \frac{\omega^{2}}{h^{2}}u_{j+1}^{n} \biggr)+\frac {x_{j+1}-x}{h} \biggl(S_{j}^{n} -\frac{\omega^{2}}{h^{2}}u_{j}^{n} \biggr) \biggr], \end{aligned} $$
(7)

where \(\omega=h\sqrt{\theta}\).

Differentiating the above Eq. (7) yields the following expression:

$$ P_{\Delta}'\bigl(x^{+}_{j},t_{n} \bigr)=\frac{u_{j+1}^{n}-u_{j}^{n}}{h}+\frac {h}{\omega^{2}} \biggl[ \biggl(\frac{\omega}{\sinh(\omega)}-1 \biggr)S_{j+1}^{n} + \biggl(1-\frac{\omega\cosh(\omega)}{\sinh(\omega)} \biggr)S_{j}^{n} \biggr]. $$
(8)

Considering the interval \([x_{j-1},x_{j}]\) and proceeding similarly, we have

$$ P_{\Delta}'\bigl(x^{-}_{j},t_{n} \bigr)=\frac{u_{j}^{n}-u_{j-1}^{n}}{h}+\frac {h}{\omega^{2}} \biggl[ \biggl(\frac{\omega\cosh(\omega) }{\sinh(\omega )}-1 \biggr)S_{j}^{n} + \biggl(1-\frac{\omega}{\sinh(\omega)} \biggr)S_{j-1}^{n} \biggr]. $$
(9)

Using the continuity condition of the first derivative of the spline function \(P_{\Delta}(x,t_{n})\) at \((x_{j},t_{n})\), we get the following consistency relation:

$$ u_{j+1}^{n}-2u_{j}^{n}+u_{j-1}^{n}= \gamma S_{j+1}^{n}+\beta S_{j}^{n}+\gamma S_{j-1}^{n},\quad j=1,2,\ldots,N, $$
(10)

where \(\gamma=\frac{h^{2}}{\omega^{2}} [1-\frac{\omega}{\sinh (\omega)} ]\), \(\beta=\frac{2h^{2}}{\omega^{2}} [\frac{\omega \cosh(\omega)}{\sinh(\omega)}-1 ]\).

3 Derivation of numerical method

In this section, we develop a numerical scheme for solving (1)–(3) using cubic non-polynomial spline. The time Caputo derivative is replaced by the \(L_{1}\) -approximation and the approximation order can be given in the following lemma.

Lemma 1

([36])

Suppose \(0< \alpha< 1\) and \(g(t)\in C^{2}[0,t_{k}]\), it holds that

$$\begin{aligned} \begin{aligned}[b] & \Biggl\vert \frac{1}{\Gamma(1-\alpha)} \int^{t_{k}}_{0}\frac {g'(t)}{(t_{k}-t)^{\alpha}}\,dt\\ &\qquad {}-\frac{\tau^{-\alpha}}{\Gamma(2-\alpha)} \Biggl[b_{0}g(t_{k})-\sum^{k-1}_{m=1}(b_{k-m-1}-b_{k-m})g(t_{m})-b_{k-1}g(t_{0}) \Biggr] \Biggr\vert \\ &\quad\leq\frac{1}{\Gamma(2-\alpha)} \biggl[\frac{1-\alpha}{12}+\frac {2^{2-\alpha}}{2-\alpha}- \bigl(1+2^{-\alpha}\bigr) \biggr]\max_{0\leq t\leq t_{k}} \bigl\vert g''(t) \bigr\vert \tau^{2-\alpha}, \end{aligned} \end{aligned}$$
(11)

where \(b_{m}=(m+1)^{1-\alpha}-m^{1-\alpha}\), \(m\geq0\).

Lemma 2

([37])

Let \(0<\alpha<1\) and \(b_{m}=(m+1)^{1-\alpha}-m^{1-\alpha}\), \(m=0,1,\ldots\) , then

$$1=b_{0}>b_{1}>\cdots>b_{m}\rightarrow0,\quad \textit{as }m\rightarrow \infty. $$

Based on Lemma 1, we can approximate the Caputo fractional derivative as follows:

$$\begin{aligned} \frac{\partial^{\alpha}u_{j}^{n}}{\partial t^{\alpha}}=\mu \Biggl[b_{0}u_{j}^{n}- \sum^{n-1}_{m=1}(b_{n-m-1}-b_{n-m})u_{j}^{m}-b_{n-1}u_{j}^{0} \Biggr]+O\bigl(\tau ^{2-\alpha}\bigr), \end{aligned}$$
(12)

where \(\mu=\frac{\tau^{-\alpha}}{\Gamma(2-\alpha)}\).

The second order space derivative can be replaced by a non-polynomial spline function at \((x_{j},t_{n})\) as follows:

$$\begin{aligned} \frac{\partial^{2}u(x_{j},t_{n})}{\partial x^{2}}\approx P_{\Delta }''(x_{j},t_{n})=S_{j}^{n}, \end{aligned}$$
(13)

where \(S_{j}^{n}=S(x_{j},t_{n})\).

At the grid point \((x_{j},t_{n})\), from Eqs. (1), (12), and (13), one can write \(S_{j}^{n}\) in the form

$$ \begin{aligned}[b] S_{j}^{n}&=-i \frac{\partial^{\alpha}u_{j}^{n}}{\partial x^{\alpha }}-\lambda \bigl\vert u_{j}^{n} \bigr\vert ^{2}u_{j}^{n}+f_{j}^{n}+R_{j}^{n} \\ &=-i \mu \Biggl[b_{0}u_{j}^{n}-\sum ^{n-1}_{m=1}(b_{n-m-1}-b_{n-m})u_{j}^{m}-b_{n-1}u_{j}^{0} \Biggr] \\ &\quad{}-\lambda \bigl\vert u_{j}^{n} \bigr\vert ^{2}u_{j}^{n}+f_{j}^{n}+R_{j}^{n}. \end{aligned} $$
(14)

Replacing j with \(j-1\) and \(j+1\) in Eq. (14) respectively yields

$$ \begin{aligned}[b] S_{j-1}^{n} &=-i \mu \Biggl[b_{0}u_{j-1}^{n}-\sum ^{n-1}_{m=1}(b_{n-m-1}-b_{n-m})u_{j-1}^{m}-b_{n-1}u_{j-1}^{0} \Biggr] \\ &\quad{}-\lambda \bigl\vert u_{j-1}^{n} \bigr\vert ^{2}u_{j-1}^{n}+f_{j-1}^{n}+R_{j-1}^{n} \end{aligned} $$
(15)

and

$$ \begin{aligned}[b] S_{j+1}^{n}&=-i \mu \Biggl[b_{0}u_{j+1}^{n}-\sum ^{n-1}_{m=1}(b_{n-m-1}-b_{n-m})u_{j+1}^{m}-b_{n-1}u_{j+1}^{0} \Biggr] \\ &\quad{}-\lambda \bigl\vert u_{j+1}^{n} \bigr\vert ^{2}u_{j+1}^{n}+f_{j+1}^{n}+R_{j+1}^{n}. \end{aligned} $$
(16)

Substituting Eqs. (14)–(16) into Eq. (10), we have

$$ \begin{aligned}[b] &u_{j+1}^{n}-2u_{j}^{n}+u_{j-1}^{n}+ \gamma\lambda \bigl\vert u_{j+1}^{n} \bigr\vert ^{2}u_{j+1}^{n}+\beta\lambda \bigl\vert u_{j}^{n} \bigr\vert ^{2}u_{j}^{n}+ \gamma\lambda \bigl\vert u_{j-1}^{n} \bigr\vert ^{2}u_{j-1}^{n} \\ &\qquad{} +i\gamma\mu u_{j+1}^{n}+i\beta\mu u_{j}^{n}+i\gamma\mu u_{j-1}^{n}-\gamma f_{j+1}^{n}-\beta f_{j}^{n}-\gamma f_{j-1}^{n} \\ &\quad=i\gamma\mu(b_{0}-b_{1})u_{j+1}^{n-1}+i \beta\mu (b_{0}-b_{1})u_{j}^{n-1}+i \gamma\mu(b_{0}-b_{1})u_{j-1}^{n-1} \\ &\qquad{} +i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})u_{j+1}^{m}+b_{n-1}u_{j+1}^{0} \Biggr] \\ &\qquad{} +i\beta\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})u_{j}^{m}+b_{n-1}u_{j}^{0} \Biggr] \\ &\qquad{} +i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})u_{j-1}^{m}+b_{n-1}u_{j-1}^{0} \Biggr]+T_{j}^{n}, \end{aligned} $$
(17)

where \(T_{j}^{n}=\gamma R^{n}_{j+1}+\beta R^{n}_{j}+\gamma R^{n}_{j-1}\).

Omitting the small term \(T_{j}^{n}\) and replacing the function \(u_{j}^{n}\) with its numerical approximation \(U_{j}^{n}\) in Eq. (17), we can get the following difference scheme for Eq. (1):

$$ \begin{aligned}[b] &U_{j+1}^{n}-2U_{j}^{n}+U_{j-1}^{n}+ \gamma\lambda \bigl\vert U_{j+1}^{n} \bigr\vert ^{2}U_{j+1}^{n}+\beta\lambda \bigl\vert U_{j}^{n} \bigr\vert ^{2}U_{j}^{n}+ \gamma\lambda \bigl\vert U_{j-1}^{n} \bigr\vert ^{2}U_{j-1}^{n} \\ &\qquad{}+i\gamma\mu U_{j+1}^{n}+i\beta\mu U_{j}^{n}+i\gamma\mu U_{j-1}^{n}-\gamma f_{j+1}^{n}-\beta f_{j}^{n}-\gamma f_{j-1}^{n} \\ &\quad=i\gamma\mu(b_{0}-b_{1})U_{j+1}^{n-1}+i \beta\mu (b_{0}-b_{1})U_{j}^{n-1}+i \gamma\mu(b_{0}-b_{1})U_{j-1}^{n-1} \\ &\qquad{} +i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j+1}^{m}+b_{n-1}U_{j+1}^{0} \Biggr] \\ &\qquad{} +i\beta\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j}^{m}+b_{n-1}U_{j}^{0} \Biggr] \\ &\qquad{} +i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j-1}^{m}+b_{n-1}U_{j-1}^{0} \Biggr]. \end{aligned} $$
(18)

System (18) contains \(N-1\) equations with \(N+1\) unknowns. To get a solution to this system, we need two additional equations. These equations are obtained from the initial and boundary conditions which can be written as

$$ \begin{aligned}[b] & U_{j}^{0} = \phi(x),\quad j=0,1,\ldots,M, \\ & U_{0}^{n}=\psi_{1}(t_{0}), \qquad U_{M}^{n}=\psi_{2}(t_{n}),\quad n=0,1, \ldots,N. \end{aligned} $$
(19)

For the convenience of implementation, scheme (18) can be rewritten as the following system:

$$ \begin{aligned}[b] A_{j}U_{j-1}^{1}+B_{j}U_{j}^{1}+C_{j}U_{j+1}^{1}&=A_{j}^{\ast }U_{j-1}^{0}+B_{j}^{\ast}U_{j}^{0}+C_{j}^{\ast}U_{j+1}^{0} \\ &\quad{} +\gamma f_{j+1}^{1}+\beta f_{j}^{1}+ \gamma f_{j-1}^{1},\quad j=2,\ldots,N-1, \end{aligned} $$
(20)

and

$$ \begin{aligned}[b] &A_{j}U_{j-1}^{n}+B_{j}U_{j}^{n}+C_{j}U_{j+1}^{n}\\ &\quad =A_{j}^{\ast }U_{j-1}^{n-1}+B_{j}^{\ast}U_{j}^{n-1}+C_{j}^{\ast}U_{j+1}^{n-1} \\ &\qquad{} +\gamma f_{j+1}^{n}+\beta f_{j}^{n}+ \gamma f_{j-1}^{n}+ Q_{j}^{n},\quad j=2, \ldots,N-1\mbox{ and } n\geq2, \end{aligned} $$
(21)

where

$$ \begin{gathered} A_{j}=1+\gamma\lambda \bigl\vert \delta_{j+1}^{n} \bigr\vert ^{2}+i\gamma\mu ,\quad \delta_{j+1}^{n}=U_{j+1}^{n}, \\ B_{j}=-2+\beta\lambda \bigl\vert \delta_{j}^{n} \bigr\vert ^{2}+i\beta\mu, \quad \delta_{j}^{n}=U_{j}^{n}, \\ C_{j}=1+\gamma\lambda \bigl\vert \delta_{j-1}^{n} \bigr\vert ^{2}+i\gamma\mu ,\quad \delta_{j-1}^{n}=U_{j-1}^{n}, \\ A_{j}^{\ast}=i(b_{0}-b_{1})\gamma\mu, \\ B_{j}^{\ast}=i(b_{0}-b_{1})\beta\mu, \\ C_{j}^{\ast}=i(b_{0}-b_{1})\gamma\mu, \end{gathered} $$

and

$$ \begin{aligned}[b] Q_{j}^{n}&=i\gamma\mu \Biggl[ \sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j+1}^{m}+b_{n-1}U_{j+1}^{0} \Biggr]\\ &\quad {}+i\beta\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j}^{m}+b_{n-1}U_{j}^{0} \Biggr] \\ &\quad{} +i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j-1}^{m}+b_{n-1}U_{j-1}^{0} \Biggr]. \end{aligned} $$

Remark 1

To cope with the nonlinear terms in system (20)–(21), the following steps are taken:

  1. 1.

    At \(n=1\), we approximate \(\delta_{j}^{1}\) by \(U_{j}^{0}\) and then system (20) becomes a linear equation. We can solve the linear equation to obtain a first approximation \(\widehat{U}_{j}^{1}\) to \(U_{j}^{1}\). We iterate using (20) for some iterations with \(\delta_{j}^{1}\) approximated by \(\widehat{U}_{j}^{1}\) to refine the approximation to \(U_{j}^{1}\). The process is repeated until the result satisfies the error precision requirement.

  2. 2.

    At \(n=k\), we approximate \(\delta_{j}^{k}\) by \(U_{j}^{k-1}\) and then system (21) becomes a linear equation. We can solve the linear equation to obtain a first approximation \(\widehat{U}_{j}^{k}\) to \(U_{j}^{k}\). We iterate using (21) for some iterations with \(\delta_{j}^{k}\) approximated by \(\widehat{U}_{j}^{k}\) to refine the approximation to \(U_{j}^{k}\). The process is repeated until the result satisfies the error precision requirement.

Theorem 1

Suppose that \(T_{j}^{n}\) is the local truncation error of the jth formula in the numerical scheme(18), it holds that

$$ \begin{aligned} T_{j}^{n}&=\bigl(h^{2}-2\gamma-\beta\bigr) \frac{\partial^{2}u_{j}^{n}}{\partial x^{2}}+h^{2} \biggl(\frac{h^{2}}{12}-\gamma \biggr) \frac{\partial ^{4}u_{j}^{n}}{\partial x^{4}}\\ &\quad {}+h^{4} \biggl(\frac{h^{2}}{360}-\frac {\gamma}{12} \biggr)\frac{\partial^{6}u_{j}^{n}}{\partial x^{6}}+(2\gamma +\beta)O\bigl(\tau^{2-\alpha}\bigr)+O \bigl(h^{6}\bigr). \end{aligned} $$

Proof

From (21), we obtain the local truncation error

$$ \begin{aligned}[b] T_{j}^{n}&= \bigl(1+\gamma\lambda \bigl\vert U_{j+1}^{n} \bigr\vert ^{2}+i\gamma\mu \bigr)U_{j+1}^{n}\\ &\quad {}+\bigl(-2+\beta \lambda \bigl\vert U_{j}^{n} \bigr\vert ^{2}+i \beta\mu \bigr)U_{j}^{n}+\bigl(1+\gamma\lambda \bigl\vert u_{j-1}^{n} \bigr\vert ^{2}+i\gamma\mu \bigr)U_{j-1}^{n} \\ &\quad{} -i\gamma\mu(b_{0}-b_{1})U_{j+1}^{n-1}+i \beta\mu (b_{0}-b_{1})U_{j}^{n-1}-i \gamma\mu(b_{0}-b_{1})U_{j-1}^{n-1} \\ &\quad{} -i\gamma\mu \Biggl(\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j+1}^{m}+b_{n-1}U_{j+1}^{0} \Biggr)-\gamma f_{j+1}^{n}-\beta f_{j}^{n}- \gamma f_{j-1}^{n} \\ &\quad{} +i\beta\mu \Biggl(\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j}^{m}+b_{n-1}U_{j}^{0} \Biggr) \\ &\quad{} -i\gamma\mu \Biggl(\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m})U_{j-1}^{m}+b_{n-1}U_{j-1}^{0} \Biggr) \\ &=U_{j+1}^{n}-2U_{j}^{n}+U_{j-1}^{n}- \gamma \Biggl(i \mu\sum_{m=0}^{n-1}b_{n,m} \bigl(U_{j+1}^{m+1}-U_{j+1}^{m}\bigr)+ \lambda \bigl\vert U_{j+1}^{n} \bigr\vert ^{2}U_{j+1}^{n}-f_{j+1}^{n} \Biggr) \\ &\quad{} -\beta \Biggl(i \mu\sum_{m=0}^{n-1}b_{n,m} \bigl(U_{j}^{m+1}-U_{j}^{m}\bigr)+ \lambda \bigl\vert U_{j}^{n} \bigr\vert ^{2}U_{j}^{n}-f_{j}^{n} \Biggr) \\ &\quad{} -\gamma \Biggl(i \mu\sum_{m=0}^{n-1}b_{n,m} \bigl(U_{j-1}^{m+1}-U_{j-1}^{m}\bigr)+ \lambda \bigl\vert U_{j-1}^{n} \bigr\vert ^{2}U_{j-1}^{n}-f_{j-1}^{n} \Biggr) \\ &=U_{j+1}^{n}-2U_{j}^{n}+U_{j-1}^{n}- \gamma \biggl(\frac{\partial ^{2}U_{j-1}^{n}}{\partial x^{2}}+\frac{\partial ^{2}U_{j+1}^{n}}{\partial x^{2}} \biggr)-\beta \frac{\partial ^{2}U_{j}^{n}}{\partial x^{2}}+(2\gamma+\beta)O\bigl(\tau^{2-\alpha}\bigr). \end{aligned} $$
(22)

Expanding (22) in a Taylor series in terms of \(u(x_{j},t_{n})\) and its derivatives, we obtain

$$ \begin{aligned}[b] T_{j}^{n}&= \biggl(1-h\frac{\partial}{\partial x}+\frac{h^{2}}{2}\frac {\partial^{2}}{\partial x^{2}}- \frac{h^{3}}{6}\frac{\partial ^{3}}{\partial x^{3}}+\frac{h^{4}}{24}\frac{\partial^{4}}{\partial x^{4}}- \frac{h^{5}}{120}\frac{\partial^{5}}{\partial x^{5}}+\frac {h^{6}}{720}\frac{\partial^{6}}{\partial x^{6}}+\cdots \biggr)u_{j}^{n} \\ &\quad{} + \biggl(1+h\frac{\partial}{\partial x}+\frac{h^{2}}{2}\frac {\partial^{2}}{\partial x^{2}}+ \frac{h^{3}}{6}\frac{\partial ^{3}}{\partial x^{3}}+\frac{h^{4}}{24}\frac{\partial^{4}}{\partial x^{4}}+ \frac{h^{5}}{120}\frac{\partial^{5}}{\partial x^{5}}+\frac {h^{6}}{720}\frac{\partial^{6}}{\partial x^{6}}+\cdots \biggr)u_{j}^{n} \\ &\quad{} -2u_{j}^{n}-\gamma \biggl(\frac{\partial^{2}}{\partial x^{2}}-h \frac{\partial^{3}}{\partial x^{3}}+\frac{h^{2}}{2}\frac {\partial^{4}}{\partial x^{4}}-\frac{h^{3}}{6} \frac{\partial ^{5}}{\partial x^{5}}+\frac{h^{4}}{24}\frac{\partial^{6}}{\partial x^{6}}+\cdots \biggr)u_{j}^{n} \\ &\quad{} -\gamma \biggl(\frac{\partial^{2}}{\partial x^{2}}-h\frac {\partial^{3}}{\partial x^{3}}+ \frac{h^{2}}{2}\frac{\partial ^{4}}{\partial x^{4}}-\frac{h^{3}}{6}\frac{\partial^{5}}{\partial x^{5}}+ \frac{h^{4}}{24}\frac{\partial^{6}}{\partial x^{6}}+\cdots \biggr)u_{j}^{n} \\ &\quad{} -\beta\frac{\partial^{2}u_{j}^{n}}{\partial x^{2}}+(2\gamma +\beta)O\bigl(\tau^{2-\alpha} \bigr). \end{aligned} $$
(23)

Then, after some simple calculations, we have

$$ \begin{aligned} T_{j}^{n}&=\bigl(h^{2}-2\gamma-\beta\bigr) \frac{\partial^{2}u_{j}^{n}}{\partial x^{2}}+h^{2} \biggl(\frac{h^{2}}{12}-\gamma \biggr) \frac{\partial ^{4}u_{j}^{n}}{\partial x^{4}}\\ &\quad {}+h^{4} \biggl(\frac{h^{2}}{360}-\frac {\gamma}{12} \biggr)\frac{\partial^{6}u_{j}^{n}}{\partial x^{6}}+(2\gamma +\beta)O\bigl(\tau^{2-\alpha}\bigr)+O \bigl(h^{6}\bigr). \end{aligned} $$

By choosing suitable values of parameters γ and β, we obtain the following various methods for Eq. (1):

  1. (i)

    If we choose \(2\gamma+\beta=h^{2}\), we obtain a scheme of order \(O(\tau^{2-\alpha}+h^{2})\).

  2. (ii)

    If we choose \(2\gamma+\beta=h^{2}\) and \(\gamma=\frac {h^{2}}{12}\), we obtain a scheme of order \(O(\tau^{2-\alpha}+h^{4})\). □

4 Stability analysis

In this section, we analyze the stability of scheme (18) by means of Fourier analysis. Basing on the Fourier method which can only be applied to a linear problem, we must linearize the nonlinear term \(\lambda|u^{2}|u\) of (1) by making the quantity \(\lambda|u^{2}|\) as a local constant d.

Let \(\widetilde{U}_{j}^{n}\) be the approximate solution of (18) and define

$$ \rho_{j}^{k} = U_{j}^{k}- \widetilde{U}_{j}^{k}, \quad j=0,1,\ldots ,M,k=0,1,\ldots,N. $$
(24)

With the above definition (24) and regarding (20) and (21), we can easily get the following roundoff error equations:

$$ \begin{aligned}[b] & \rho_{j+1}^{1}-2 \rho_{j}^{1}+\rho_{j-1}^{1}+\gamma \,d \rho _{j+1}^{1}+\beta \,d \rho_{j}^{1} + \gamma \,d \rho_{j-1}^{1} +i\gamma\mu\rho_{j+1}^{1}+i \beta\mu\rho_{j}^{1}+i\gamma\mu\rho _{j-1}^{1} \\ &\quad=i\gamma\mu(b_{0}-b_{1})\rho_{j+1}^{0}+i \beta\mu (b_{0}-b_{1})\rho_{j}^{0}+i \gamma\mu(b_{0}-b_{1})\rho_{j-1}^{0}, \end{aligned} $$
(25)

and

$$ \begin{aligned}[b] &\rho_{j+1}^{n}-2 \rho_{j}^{n}+\rho_{j-1}^{n}+\gamma \,d \rho _{j+1}^{n}+\beta \,d \rho_{j}^{n} +\gamma \,d \rho_{j-1}^{n} +i\gamma\mu\rho_{j+1}^{n}+i \beta\mu\rho_{j}^{n}+i\gamma\mu\rho _{j-1}^{n} \\ &\quad=i\gamma\mu(b_{0}-b_{1})\rho_{j+1}^{n-1}+i \beta\mu (b_{0}-b_{1})\rho_{j}^{n-1}+i \gamma\mu(b_{0}-b_{1})\rho_{j-1}^{n-1} \\ &\qquad{}+i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m}) \rho_{j+1}^{m}+b_{n-1}\rho_{j+1}^{0} \Biggr] \\ &\qquad{}+i\beta\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m}) \rho_{j}^{m}+b_{n-1}\rho_{j}^{0} \Biggr] \\ &\qquad{}+i\gamma\mu \Biggl[\sum_{m=1}^{n-2}(b_{n-m-1}-b_{n-m}) \rho_{j-1}^{m}+b_{n-1}\rho_{j-1}^{0} \Biggr], \quad n\geq2. \end{aligned} $$
(26)

We define the grid function as follows:

$$\rho^{k}(x)= \textstyle\begin{cases} \rho_{j}^{k},& x_{j}-\frac{h}{2}< x\leq x_{j}+\frac{h}{2}, j=1,2,\ldots ,M-1,\\ 0,& a\leq x \leq a+\frac{h}{2} \mbox{ or } b-\frac{h}{2}< x\leq b, \end{cases} $$

where \(\rho^{k}(x)\) can be expanded in a Fourier series

$$ \rho^{k}(x)=\sum^{\infty}_{l=-\infty} \varsigma_{k}(l)e^{i2\pi lx/L}, \quad k=1,2,\ldots,N, $$
(27)

in which \(L=b-a\) and

$$ \varsigma_{k}(l)=\frac{1}{L} \int^{L}_{0}\rho^{k}(x)e^{-i2\pi lx/L}\,dx. $$

We define the following discrete \(L_{2}\) norm:

$$ \bigl\Vert \rho^{k} \bigr\Vert _{2}= \Biggl(\sum ^{M-1}_{j=1} h \bigl\vert \rho _{j}^{k} \bigr\vert ^{2} \Biggr)^{\frac{1}{2}}= \biggl[ \int^{L}_{0} \bigl\vert \rho ^{k}(x) \bigr\vert ^{2}\,dx \biggr]^{\frac{1}{2}}, $$

where \(\rho^{k}=[\rho^{k}_{1},\rho^{k}_{2},\ldots,\rho^{k}_{M-1}]^{T}\).

Based on the Parseval equality

$$ \int^{L}_{0} \bigl\vert \rho^{k}(x) \bigr\vert ^{2}\,dx=\sum^{\infty }_{l=-\infty} \bigl\vert \varsigma_{k}(l) \bigr\vert ^{2}, $$

we have

$$ \bigl\Vert \rho^{k} \bigr\Vert _{2}= \Biggl(\sum^{\infty}_{l=-\infty } \bigl\vert \varsigma_{k}(l) \bigr\vert ^{2} \Biggr)^{\frac{1}{2}}. $$
(28)

According to the above analysis, we suppose that the solution of Eqs. (25) and (26) has the following form:

$$ \rho^{k}_{j}=\varsigma_{k}e^{i\sigma jh}, $$
(29)

where \(\sigma=\frac{2\pi l}{L}\) is a real spatial wave number.

Substituting (29) into (25), we have

$$ \begin{aligned}[b] & D_{j} \varsigma_{1} \operatorname{exp} \bigl[\sigma(j-1)hi \bigr]+ E_{j} \varsigma_{1} \operatorname{exp} (\sigma jhi )+ F_{j}\varsigma_{1} \operatorname{exp} \bigl[\sigma(j+1)hi \bigr] \\ &\quad = D_{j}^{\ast}\varsigma_{0} \operatorname{exp} \bigl[ \sigma(j-1)hi \bigr]+ E_{j}^{\ast}\varsigma_{0} \operatorname{exp} (\sigma jhi )+ F_{j}^{\ast}\varsigma _{0} \operatorname{exp} \bigl[\sigma(j+1)hi \bigr], \end{aligned} $$
(30)

where

$$ \begin{gathered} D_{j}=1+\gamma\lambda d+i\gamma\mu, \qquad D_{j}^{\ast}=i\gamma\mu, \\ E_{j}=-2+\beta\lambda d+i\beta\mu, \qquad E_{j}^{\ast}=i \beta\mu, \\ F_{j}=1+\gamma\lambda d+i\gamma\mu, \qquad F_{j}^{\ast}=i \gamma\mu. \end{gathered} $$

After simple calculations, (30) leads to

$$ \varsigma_{1}=\frac{D_{j}^{\ast} \operatorname{exp}(-\sigma hi)+ E_{j}^{\ast}+ F_{j}^{\ast} \operatorname{exp}(\sigma hi)}{ D_{j} \operatorname{exp}(-\sigma hi)+ E_{j}+ F_{j} \operatorname{exp}(\sigma hi)}\varsigma_{0} . $$
(31)

Using Euler’s formula, (31) can be rewritten in the form

$$ \varsigma_{1}=\frac{(D_{j}^{\ast}+F_{j}^{\ast}) \operatorname{cos}(\sigma h)+E_{j}^{\ast}}{(D_{j}+F_{j}) \operatorname{cos}(\sigma h)+E_{j}}\varsigma_{0}, $$
(32)

or

$$ \varsigma_{1} =\frac{ [2\gamma\mu \operatorname{cos}(\sigma h)+\beta\mu ]i}{ [2\gamma\mu \operatorname{cos}(\sigma h)+\beta\mu ]i+(2+2\gamma\lambda d) \operatorname{cos}(\sigma h)+\beta \lambda d-2}\varsigma_{0}. $$
(33)

(33) can be rewritten in the form

$$ \vert \varsigma_{1} \vert =\sqrt{\frac{\xi^{2}}{\xi^{2}+\mu^{2}}} \vert \varsigma_{0} \vert \leq \vert \varsigma_{0} \vert , $$
(34)

where

$$ \begin{gathered} \xi=2\gamma\mu \operatorname{cos}(\sigma h)+\beta\mu, \\ \mu=(2+2\gamma\lambda d) \operatorname{cos}(\sigma h)+\beta\lambda d-2. \end{gathered} $$

Substituting (29) into (26) results in

$$ \begin{aligned}[b] &D_{j} \varsigma_{n} \operatorname{exp} \bigl[\sigma(j-1)hi \bigr]+ E_{j} \varsigma_{n} \operatorname{exp} (\sigma jhi )+ F_{j}\varsigma_{n} \operatorname{exp} \bigl[\sigma(j+1)hi \bigr] \\ &\quad= D_{j}^{\ast}\varsigma_{n-1} \operatorname{exp} \bigl[ \sigma(j-1)hi \bigr]+ E_{j}^{\ast}\varsigma_{n-1} \operatorname{exp} (\sigma jhi )+ F_{j}^{\ast }\varsigma_{n-1} \operatorname{exp} \bigl[ \sigma(j+1)hi \bigr]+{E}_{j}^{n}, \end{aligned} $$
(35)

where

$$ \begin{aligned} {E}_{j}^{n}&=-D_{j}^{\ast} \sum_{m=0}^{n-2}b_{n,m} \bigl\{ \varsigma_{m+1} \operatorname{exp} \bigl[\sigma(j+1)hi \bigr]-\varsigma_{m} \operatorname{exp} \bigl[\sigma (j+1)hi \bigr] \bigr\} \\ &\quad{}-E_{j}^{\ast}\sum_{m=0}^{n-2}b_{n,m} \bigl[\varsigma _{m+1} \operatorname{exp}(\sigma jhi)-\varsigma_{m} \operatorname{exp}( \sigma jhi) \bigr] \\ &\quad{} -D_{j}^{\ast}\sum_{m=0}^{n-2}b_{n,m} \bigl\{ \varsigma _{m+1} \operatorname{exp} \bigl[\sigma(j-1)hi \bigr]- \varsigma_{m} \operatorname{exp} \bigl[\sigma (j-1)hi \bigr] \bigr\} . \end{aligned} $$

(35) can be simplified as

$$ \begin{aligned}[b] \varsigma_{n}&= \frac{\xi i}{\mu+\sigma i}\varsigma_{n-1}-\frac {1}{(\mu+\xi i)\operatorname{exp}(\phi jhi)}E_{j}^{n} \\ & =\frac{\xi i}{\mu+\xi i}\varsigma_{n-1}-\frac{\xi i}{\mu+\xi i}\sum _{m=0}^{n-2}b_{n,m}(\varsigma_{m+1}- \varsigma_{m}). \end{aligned} $$
(36)

For \(n=2\), we have

$$ \varsigma_{2}=\frac{\xi i}{\mu+\xi i}\varsigma_{1}- \frac{\xi i}{\mu +\xi i}b_{2,0}(\varsigma_{1}-\varsigma_{0}). $$

Because \(|\frac{\xi i}{\mu+\xi i} |>0\), \((1-b_{2,0})>0\), and \(b_{2,0}>0\), we obtain

$$ \begin{aligned} \vert \varsigma_{2} \vert &\leq \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{1} \vert (1-b_{2,0})+ \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert b_{2,0} \\ &\leq \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert (1-b_{2,0}+b_{2,0}) \\ & \leq \vert \varsigma_{0} \vert . \end{aligned} $$

For \(n=3\), we have

$$ \varsigma_{3}=\frac{\xi i}{\mu+\xi i}\varsigma_{1}- \frac{\xi i}{\mu +\xi i}b_{3,0}(\varsigma_{1}-\varsigma_{0}) -\frac{\xi i}{\mu+\xi i}b_{3,1}(\varsigma_{2}-\varsigma_{1}). $$

Because\(|\frac{\xi i}{\mu+\xi i} |>0\), \((1-b_{3,1})>0\), \((b_{3,1}-b_{3,0})>0\), and \(b_{3,0}>0\), we obtain

$$ \begin{aligned} \vert \varsigma_{3} \vert &\leq \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{2} \vert (1-b_{3,1})+ \biggl\vert \frac{\xi i}{\mu+\sigma i} \biggr\vert \vert \varsigma_{1} \vert (b_{3,1}-b_{3,0})+ \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert b_{3,0} \\ &\leq \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert (1-b_{3,1})+ \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma _{0} \vert (b_{3,1}-b_{3,0})+ \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert b_{3,0} \\ & = \biggl\vert \frac{\xi i}{\mu+\xi i} \biggr\vert \vert \varsigma_{0} \vert \\ & \leq \vert \varsigma_{0} \vert . \end{aligned} $$

By a similar argument, it is then obtained that \(|\varsigma_{j}|\leq |\varsigma_{0}|\) for \(n=4,5,\ldots\) . Hence, the linearized method is unconditionally stable.

5 Numerical experiments

In this section, some numerical calculations are carried out to test our theoretical results. To illustrate the accuracy of the method and to compare the method with another method in the literature, we compute the maximum norm errors denoted by

$$ e_{\infty}(h,\tau)=\max_{0\leq n\leq N} \bigl\Vert U^{n}-u^{n} \bigr\Vert _{\infty}. $$

Furthermore, the temporal convergence order is denoted by

$$ \mathit{rate1}_{\infty}=\log_{2} \biggl(\frac{e_{\infty}(h,2\tau)}{e_{\infty }(h,\tau)} \biggr) $$

for sufficiently small h, and the spatial convergence order is denoted by

$$ \mathit{rate2}_{\infty}=\log_{2} \biggl(\frac{e_{\infty}(2h,\tau)}{e_{\infty }(h,\tau)} \biggr) $$

for sufficiently small τ.

Example 1

Consider the following time-fractional Schrödinger equation:

$$ i\frac{\partial^{\alpha}u(x,t)}{\partial t^{\alpha}}+\frac{\partial ^{2}u(x,t)}{\partial x^{2}}+ \bigl\vert u(x,t) \bigr\vert ^{2}u(x,t)=f(x,t), \quad 0\leq x\leq1, 0< t \leq T, $$
(37)

with the initial condition

$$ u(x,0)=0, \quad 0\leq x \leq1, $$

and boundary conditions

$$ u(0,t)=it^{2}, \qquad u(1,t)=it^{2}, $$

where

$$ \begin{aligned} f(x,t)&=-\frac{2t^{2-\alpha}}{\Gamma(3-\alpha)}\cos(2\pi x)+\bigl(-4\pi ^{2}t^{2}+t^{6}\bigr)\sin(2\pi x) \\ &\quad{}+i \biggl[\frac{2t^{2-\alpha}}{\Gamma(3-\alpha)}\sin(2\pi x)+\bigl(-4\pi^{2}t^{2}+t^{6} \bigr)\cos(2\pi x) \biggr]. \end{aligned} $$

The exact solution of (37) is given by

$$ u(x,t)=t^{2} \bigl[\sin(2\pi x)+i\cos(2\pi x) \bigr]. $$

Firstly, the temporal errors and convergence orders are given in Table 1. We take the sufficiently small spatial step \(h=\frac{1}{1000}\) and let \(\alpha=0.2,0.4,0.6\), and 0.8, respectively. It is observed that the scheme generates temporal convergence order, which is consistent with our theoretical analysis. Secondly, the spatial errors and convergence orders are tabulated in Table 2. We take the sufficiently small temporal step \(\tau=\frac{1}{5000}\) and let \(\alpha=0.2,0.4,0.6\), and 0.8, respectively. The results illustrate that our scheme has accuracy of \(O(h^{4})\) in spatial direction. That is in good agreement with our theoretical analysis. Figure 1 presents the graphs of exact and numerical solutions with \(h=\frac{1}{48}\), \(\tau=\frac{1}{500}\), and \(\alpha=0.3\).

Figure 1
figure 1

Graphs of exact and numerical solutions with \(h=\frac {1}{48}\), \(\tau=\frac{1}{500}\), and \(\alpha=0.3\)

Table 1 The temporal errors and convergence orders with \(h=\frac{1}{1000}\)
Table 2 The spatial errors and convergence orders with \(\tau=\frac{1}{5000}\)

The comparisons of our numerical solutions and the results of the method developed in [11] for \(\alpha=0.1\) and 0.3 are shown in Tables 3 and 4. We take step size \(\tau=\frac{1}{512}\) and \(h=\frac{1}{4},\frac{1}{9},\frac{1}{14},\frac{1}{19},\frac{1}{24}\), and \(\frac{1}{29}\). It can be seen that the results of this paper are better than the results of [11].

Table 3 Comparison of errors obtained for Example 1 with \(\tau=\frac {1}{512}\) and \(\alpha=0.1\)
Table 4 Comparison of errors obtained for Example 1 with \(\tau=\frac {1}{512}\) and \(\alpha=0.3\)

6 Conclusion

In this paper, we have studied a numerical method based on cubic non-polynomial spline for the solution of a time-fractional nonlinear Schrödinger equation. By using the Fourier analysis, the scheme is shown to be unconditionally stable. The truncation errors of our scheme can be reached to \(O(\tau^{2-\alpha}+h^{4})\). Numerical results coincide with the theoretical analysis.