## 1 Introduction

The concept of differentiation as a convolution of some natural laws, like power law, exponential decay law and Mittag-Leffler law, is in fashion nowadays due to its ability as a mathematical tool to replicate the observed facts. These three major definitions are constructed as the convolution of derivative of a given differentiable function and power law, exponential decay law or Mittag-Leffler law [15]. This version is recognized as Caputo type but it is sometime criticized because it does not have an associated anti-derivative. The original version is the derivative of a convolution of a non-differentiable continuous function and power law, exponential decay law or Mittag-Leffler law. This last version is known as Riemann-Liouville approach that is obtained via the Abel integral and is considered as a real derivative with fractional order [35]. Nowadays research using many concepts of differentiations has been carried out and some good predictions have been obtained [611]. This derivative has been used in many research papers for theoretical purposes, and sometimes it is used to model some physical problems, but its numerical approximation is not popular in the literature. Recently, Atangana and Gomez did a work devoted to the derivation of the numerical approximation of the three Riemann-Liouville types of fractional derivatives [12]. A great advantage of the fractional differentiation with non-singular and non-local kernel suggested by Atangana and Baleanu is that, when using the Laplace transform, we obtain the usual initial condition unlike Riemann-Liouville. In addition to this, the kernel is able to portray a full memory as there is no singularity associated to it. The kernel is more natural and is a combination of power law and exponential decay law which give this kernel the ability to describe phenomena with non-local fading memory [1317]. In their work, they suggested the numerical approximation of these derivatives for first and second order. In this work, we analyze numerically the well-known Klein-Gordon equation with mass parameter, where the second time derivative will be replaced by Riemann-Liouville, Caputo-Fabrizio in Riemann-Liouville sense and Atangana-Baleanu in Riemann-Liouville sense fractional derivatives. We shall recall that the Klein-Gordon equation with mass parameter is a linear partial differential equation used to describe a relativistic wave, closely related to the Schrödinger equation [1820].

## 2 Fractional order derivatives in Riemann-Liouville sense

In this section, we present the fractional order definitions in Riemann-Liouville sense.

### Definition 1

Let f be a function not necessary differential, α be a real number such that $$0\leq \alpha \leq1$$, then the derivative with α order with power law is given as

$${}_{0}^{\mathrm{RL}}D_{t}^{\alpha} \bigl[f(t) \bigr]= \frac{1}{\Gamma(1-\alpha)}\frac {d}{dt}\int_{0}^{t}(t-y)^{-\alpha}f(y)\,dy.$$
(1)

### Definition 2

Let $$f\in H^{1}(a,b)$$, $$b>a$$, $$\alpha\in[0,1]$$ and not necessary differentiable, then the definition of the new fractional derivative (the Atangana-Baleanu fractional derivative in Riemann-Liouville sense) is given as

$${}_{0}^{\mathrm{ABR}}D_{t}^{\alpha} \bigl[ f(t) \bigr] = \frac{B(\alpha )}{1-\alpha}\frac{d}{dt} \int_{a}^{t}f(y)E_{\alpha} \biggl[ - \frac{\alpha}{1-\alpha} ( t-y ) ^{\alpha} \biggr] \,dy.$$
(2)

### Definition 3

Let f be a function not necessary differential, α be a real number such that $$0\leq \alpha \leq1$$, then the derivative with α order with exponential decay-law is given as

$${}_{0}^{\mathrm{CFR}}D_{t}^{\alpha} \bigl[ f(t) \bigr] = \frac{M(\alpha )}{1-\alpha}\frac{d}{dt} \int_{a}^{t}f(y)\exp \biggl[ -\frac{\alpha}{1-\alpha} ( t-y ) \biggr] \,dy,$$
(3)

where $$M(\alpha)$$ and $$B(\alpha)$$ denote a normalization function obeying $$M(0)=M(1)=1$$ and $$B(0)=B(1)=1$$.

## 3 Numerical analysis for the Klein-Gordon equation with mass parameter

First we give the Klein-Gordon equation with mass parameter that is considered in this paper

$$h^{2}\frac{\partial^{2}\Psi(t,x)}{\partial t^{2}}-h^{2}c^{2} \frac {\partial ^{2}\Psi(t,x)}{\partial x^{2}}+c^{4}m^{2}\Psi=0.$$
(4)

The Klein-Gordon equation with mass parameter m has solutions with complex-valued functions of the time variable t and space variables of x. Theorems of the derivation of the numerical approximation of three Riemann-Liouville types of fractional derivatives can be found in paper [12].

### Theorem 1

Let f be a function not necessary differentiable within an interval $$[a,T]$$, then the fractional derivative of f of order $$1<\alpha\leq2$$ in Riemann-Liouville sense is given as follows:

\begin{aligned}[b] &{}_{0}^{\mathrm{RL}}D_{t}^{\alpha} \bigl[ f(x) \bigr] \\ &\quad=\frac{ ( \Delta x ) ^{-1-\alpha}}{2\Gamma(3-\alpha )} \Biggl[ \sum _{k=0}^{j}f(x_{k+1})g_{j,k}^{\alpha} -2\sum_{k=0}^{j-1}f(x_{k+1})g_{j,k}^{\alpha ,1}+ \sum_{k=0}^{j-1}f(x_{k+1})g_{j,k}^{\alpha,2} \Biggr] +R_{\alpha,j,k}, \end{aligned}
(5)

where

\begin{aligned}[b] R_{\alpha,j,k}={}&\frac{ ( \Delta x ) ^{-2}}{2\Gamma (2-\alpha)} \Biggl[ \sum_{k=0}^{j} \int_{x_{k}}^{x_{k+1}}\frac{f(y)-f(x_{k+1})}{ ( x_{j+1}-y ) ^{\alpha-1}}\,dy \\ &-2\sum_{k=0}^{j-1} \int_{x_{k}}^{x_{k+1}}\frac{f(y)-f(x_{k+1})}{ ( x_{j}-y ) ^{\alpha-1}}\,dy +\sum _{k=0}^{j-1}\int _{x_{k}}^{x_{k+1}} \frac{f(y)-f(x_{k+1})}{ ( x_{j-1}-y ) ^{\alpha-1}}\,dy \Biggr] , \end{aligned}
(6)

and

$$\begin{gathered} g_{j,k}^{\alpha} =(j-k)^{1-\alpha}-(j-k+1)^{1-\alpha}, \\ g_{j,k}^{\alpha,1} =(j-k-1)^{1-\alpha}-(j-k)^{1-\alpha}, \\ g_{j,k}^{\alpha,2} =(j-k-1)^{1-\alpha}-(j-k-1)^{1-\alpha}. \end{gathered}$$
(7)

Now, we can consider the equation with the second order Riemann-Liouville derivative.

\begin{aligned}& h^{2}{}_{0}^{\mathrm{RL}}D_{t}^{\alpha} \bigl[ \Psi(t,x) \bigr] = {}_{0}^{\mathrm{RL}}D_{x}^{\alpha} \bigl[ \Psi(t,x) \bigr] h^{2}c-c^{4}m^{2}\Psi(t,x), \end{aligned}
(8)
\begin{aligned}& \begin{aligned}[b] &h^{2} \frac{ ( \Delta t ) ^{-1-\alpha}}{2\Gamma(3-\alpha )} \Biggl[ \sum _{k=0}^{j}\Psi(t_{k+1})g_{j,k}^{\alpha} -2\sum_{k=0}^{j-1}\Psi(t_{k+1})g_{j,k}^{\alpha ,1}+ \sum_{k=0}^{j-1}\Psi(t_{k+1})g_{j,k}^{\alpha,2} \Biggr] \\ &\quad=h^{2}c^{2} \biggl[ \frac{ ( \Psi_{i+1}^{j+1}-2\Psi _{i}^{j+1}+\Psi _{i-1}^{j+1} ) - ( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} ) }{2 ( \triangle x ) ^{2}} \biggr] \\ &\qquad{}-c^{4}m^{2} \biggl[ \frac{\Psi_{i}^{j+1}+\Psi_{i}^{j}}{2} \biggr] . \end{aligned} \end{aligned}
(9)

To make further work clearer, let us do regulation in the equation with sufficient parameters as follows:

$$c_{i}^{j}=\frac{h^{2} ( \Delta t ) ^{-1-\alpha}}{2\Gamma (3-\alpha )},\qquad d_{i}^{j}= \frac{h^{2}c^{2}}{2 ( \triangle x ) ^{2}},\qquad e_{i}^{j}= \frac{c^{4}m^{2}}{2}.$$
(10)

Then we rewrite the equation with parameters

\begin{aligned}[b] &c_{i}^{j} \bigl( \Psi_{i}^{j+1}g_{j,k}^{\alpha}-2 \Psi _{i}^{j}g_{j,k}^{\alpha,1}+ \Psi_{i}^{j}g_{j,k}^{\alpha,2} \bigr) \\ &\quad\quad{}+c_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}g_{j,k}^{\alpha }-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}g_{j,k}^{\alpha ,1}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}g_{j,k}^{\alpha,2} \Biggr] \\ &\quad=d_{i}^{j} \bigl[ \bigl( \Psi_{i+1}^{j+1}-2 \Psi_{i}^{j+1}+\Psi _{i-1}^{j+1} \bigr) - \bigl( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} \bigr) \bigr] \\ &\qquad{}-e_{i}^{j} \bigl( \Psi_{i}^{j+1}+ \Psi_{i}^{j} \bigr) . \end{aligned}
(11)

Finally, we have the following equation for the numerical scheme:

\begin{aligned}[b] &\Psi_{i}^{j+1} \bigl( c_{i}^{j}g_{j,k}^{\alpha }+2d_{i}^{j}+e_{i}^{j} \bigr) \\ &\quad=\Psi_{i}^{j} \bigl( 2c_{i}^{j}g_{j,k}^{\alpha ,1}-c_{i}^{j}g_{j,k}^{\alpha,2}+2d_{i}^{j}-e_{i}^{j} \bigr) \\ &\quad\quad{}-c_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}g_{j,k}^{\alpha }-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}g_{j,k}^{\alpha ,1}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}g_{j,k}^{\alpha,2} \Biggr] \\ &\qquad{}+d_{i}^{j} \bigl[ \Psi_{i+1}^{j+1}+ \Psi_{i-1}^{j+1}-\Psi _{i+1}^{j}-\Psi _{i-1}^{j} \bigr]. \end{aligned}
(12)

#### 3.1.1 Stability analysis of the numerical scheme

Let us represent a stability analysis of the numerical scheme by supposing

$$v_{i}^{j}=\Psi_{i}^{j}-w_{i}^{j},$$
(13)

where $$w_{i}^{j}$$ is the approximate solution of the equation in time and space $$(x_{i},t_{j})$$ ($${i=1,2,\ldots,N}$$, $$j=1,2,\ldots,M$$) [4].

Also the error for approximation is given as

$$v_{i}^{j}= \bigl[ v_{1}^{j},v_{2}^{j}, \ldots,v_{N}^{j} \bigr] {.}$$
(14)

So we have the following error expression for the Klein-Gordon equation with mass parameter:

\begin{aligned}[b] &v_{i}^{j+1} \bigl( c_{i}^{j}g_{j,k}^{\alpha }+2d_{i}^{j}+e_{i}^{j} \bigr) \\ &\quad=v_{i}^{j} \bigl( 2c_{i}^{j}g_{j,k}^{\alpha ,1}-c_{i}^{j}g_{j,k}^{\alpha ,2}+2d_{i}^{j}-e_{i}^{j} \bigr) \\ &\qquad{}-c_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}v_{i}^{j+1}g_{j,k}^{\alpha }-2 \sum_{k=0}^{j-2}v_{i}^{j+1}g_{j,k}^{\alpha ,1}+ \sum_{k=0}^{j-2}v_{i}^{j+1}g_{j,k}^{\alpha,2} \Biggr] \\ &\quad\quad{}+d_{i}^{j} \bigl[ v_{i+1}^{j+1}+v_{i-1}^{j+1}-v_{i+1}^{j}-v_{i-1}^{j} \bigr]. \end{aligned}
(15)

Then let us take the following equality for the stability analysis.

$$\begin{gathered} v_{m}(x,t)=\exp[at] \exp[ik_{m}x], \\ v_{m}^{j} =\exp[at] \exp[ik_{m}x], \\ v_{m}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x], \\ v_{m+1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x+ \Delta x ) \bigr], \\ v_{m-1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x- \Delta x ) \bigr], \\ v_{m+1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr], \\ v_{m-1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr], \\ v_{m-1}^{j-1} =\exp \bigl[a ( t-\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr],\end{gathered}$$
(16)

where $$k_{m}=\frac{\pi m}{L}$$, $$m=1,2,\ldots,M=\frac{L}{\Delta x}$$. If we use the equalities above, equation can be reconsidered as follows:

\begin{aligned} \begin{aligned}[b] &\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x] \bigl( c_{i}^{j}g_{j,k}^{\alpha}+2d_{i}^{j}+e_{i}^{j} \bigr) \\ &\quad=\exp[at]\exp[ik_{m}x] \bigl( 2c_{i}^{j}g_{j,k}^{\alpha ,1}-c_{i}^{j}g_{j,k}^{\alpha,2}+2d_{i}^{j}-e_{i}^{j} \bigr) \\ &\qquad{}-c_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( t+\Delta t ) \bigr] \exp [ik_{m}x]g_{j,k}^{\alpha} \\ &\qquad{} -2\sum_{k=0}^{j-2}\exp \bigl[a ( t+\Delta t ) \bigr]\exp [ik_{m}x]g_{j,k}^{\alpha,1} +\sum _{k=0}^{j-2}\exp \bigl[a ( t+ \Delta t ) \bigr]\exp [ik_{m}x]g_{j,k}^{\alpha,2} \Biggr] \\ &\quad\quad{}+d_{i}^{j} \bigl[ \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] + \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \\ &\quad\quad{}-\exp[at]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] - \exp[at]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \bigr]. \end{aligned} \end{aligned}
(17)

If we do simplification with $$\exp[at]\exp[ik_{m}x]$$, we will obtain the following:

\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl( c_{i}^{j}g_{j,k}^{\alpha }+2d_{i}^{j}+e_{i}^{j} \bigr) \\ &\quad= \bigl( 2c_{i}^{j}g_{j,k}^{\alpha,1}-c_{i}^{j}g_{j,k}^{\alpha ,2}+2d_{i}^{j}-e_{i}^{j} \bigr) \\ &\qquad{}-c_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( \Delta t ) \bigr]g_{j,k}^{\alpha} \\ &\qquad{}-2\sum_{k=0}^{j-2} \exp \bigl[a ( \Delta t ) \bigr]g_{j,k}^{\alpha,1} +\sum _{k=0}^{j-2}\exp \bigl[a ( \Delta t ) \bigr]g_{j,k}^{\alpha,2} \Biggr] \\ &\qquad{}+d_{i}^{j} \bigl[ \exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( \Delta x ) \bigr] +\exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \\ &\qquad{} -\exp \bigl[ik_{m} ( \Delta x ) \bigr] -\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr] \end{aligned} \end{aligned}
(18)
\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl[ c_{i}^{j}g_{j,k}^{\alpha}+2d_{i}^{j}+e_{i}^{j}+c_{i}^{j}.J \bigl( g_{j,k}^{\alpha}-2g_{j,k}^{\alpha,1}+g_{j,k}^{\alpha,2} \bigr) \\ &\qquad{}-d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr] \\ &\quad= \bigl( 2c_{i}^{j}g_{j,k}^{\alpha,1}-c_{i}^{j}g_{j,k}^{\alpha ,2}+2d_{i}^{j}-e_{i}^{j} \bigr) -d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \end{aligned} \end{aligned}
(19)
\begin{aligned}& \begin{aligned}[b] \exp \bigl[a ( \Delta t ) \bigr]={}&{ \bigl\{ \bigl( 2c_{i}^{j}g_{j,k}^{\alpha,1}-c_{i}^{j}g_{j,k}^{\alpha ,2}+2d_{i}^{j}-e_{i}^{j} \bigr) -d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &/ \bigl\{ c_{i}^{j}g_{j,k}^{\alpha}+2d_{i}^{j}+e_{i}^{j}+c_{i}^{j}.J \bigl( g_{j,k}^{\alpha}-2g_{j,k}^{\alpha,1}+g_{j,k}^{\alpha,2} \bigr) \\ &-d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} . \end{aligned} \end{aligned}
(20)

With the help of the following inequality step by step, we have the condition for the stability analysis.

$$\begin{gathered} \frac{v_{i}^{j+1}}{v_{i}^{j}}=\exp \bigl[a(\Delta t) \bigr], \\ \biggl\vert \frac{v_{i}^{j+1}}{v_{i}^{j}} \biggr\vert = \bigl\vert \exp \bigl[a( \Delta t) \bigr] \bigr\vert \leq1.\end{gathered}$$
(21)

Then the stability condition is given as

\begin{aligned}[b] & \bigl\vert { \bigl\{ \bigl( 2c_{i}^{j}g_{j,k}^{\alpha,1}-c_{i}^{j}g_{j,k}^{\alpha ,2}+2d_{i}^{j}-e_{i}^{j} \bigr) -d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &\qquad/ \bigl\{ c_{i}^{j}g_{j,k}^{\alpha}+2d_{i}^{j}+e_{i}^{j}+c_{i}^{j}.J \bigl( g_{j,k}^{\alpha}-2g_{j,k}^{\alpha,1}+g_{j,k}^{\alpha,2} \bigr) \\ &\qquad{}-d_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} \bigr\vert \\ &\quad \leq1.\end{aligned}
(22)

### Theorem 2

The Crank-Nicholson scheme for solving the Klein-Gordon equation with second order Riemann-Liouville is stable if inequality (22) is satisfied.

### Theorem 3

Let f be a function not necessary differentiable within an interval $$[a,T]$$, then the fractional derivative of f of order $$1<\alpha\leq2$$ in the Caputo-Fabrizio derivative in Riemann-Liouville sense is given as follows:

$${}_{0}^{\mathrm{CFR}}D_{t}^{\alpha} \bigl[ f(x) \bigr] =\frac{1}{2 ( \Delta x ) ^{2}} \Biggl[ \sum _{k=0}^{j}\frac{f(x_{k+1})}{2}d_{j,k}^{\alpha,1} -2\sum_{k=0}^{j-1}\frac{f(x_{k+1})}{2}d_{j,k}^{\alpha ,2}+ \sum_{k=0}^{j-1}\frac{f(x_{k+1})}{2}d_{j,k}^{\alpha,3} \Biggr] +F,$$
(23)

where

\begin{aligned} F={}&\frac{\alpha}{(1-\alpha)\sqrt{\pi}} \Biggl[ \sum _{k=0}^{j} \int_{x_{k}}^{x_{k+1}} \bigl( f(\tau )-f(x_{j+1}) \bigr) \exp \biggl( - \biggl( \frac{\alpha}{1-\alpha } \biggr) ^{2} ( x_{j+1}-\tau ) ^{2} \biggr) \,d\tau \\ &-2\sum_{k=0}^{j-1} \int_{x_{k}}^{x_{k+1}} \bigl( f(\tau )-f(x_{j+1}) \bigr) \exp \biggl( - \biggl( \frac{\alpha}{1-\alpha } \biggr) ^{2} ( x_{j}-\tau ) ^{2} \biggr) \,d\tau \\ &+\sum_{k=0}^{j-1} \int_{x_{k}}^{x_{k+1}} \bigl( f(\tau )-f(x_{j+1}) \bigr) \exp \biggl( - \biggl( \frac{\alpha}{1-\alpha } \biggr) ^{2} ( x_{j+1}-\tau ) ^{2} \biggr) \,d\tau \Biggr] ,\end{aligned}

and

$$\begin{gathered} d_{j,k}^{\alpha,1} = \operatorname{{erf}c} \biggl\{ - \alpha\frac{x_{j+1}-x_{k+1}}{1-\alpha} \biggr\} - \operatorname{{erf}c} \biggl\{ -\alpha\frac {x_{j+1}-x_{k}}{1-\alpha } \biggr\} , \\ d_{j,k}^{\alpha,2} =\operatorname{{erf}c} \biggl\{ -\alpha \frac{x_{j}-x_{k+1}}{1-\alpha} \biggr\} -\operatorname{{erf}c} \biggl\{ -\alpha \frac {x_{j}-x_{k}}{1-\alpha} \biggr\} , \\ g_{j,k}^{\alpha,3} =\operatorname{{erf}c} \biggl\{ -\alpha \frac{x_{j-1}-x_{k+1}}{1-\alpha} \biggr\} -\operatorname{{erf}c} \biggl\{ -\alpha \frac {x_{j-1}-x_{k}}{1-\alpha } \biggr\} . \end{gathered}$$
(24)

Also we will consider the following equation with the Caputo-Fabrizio derivative in Riemann-Liouville sense of order $$1<\alpha\leq2$$:

\begin{aligned}[b] &\frac{1}{2 ( \Delta x ) ^{2}} \Biggl[ \sum_{k=0}^{j} \frac{\Psi(x_{k+1})}{2}d_{j,k}^{\alpha,1} -2\sum _{k=0}^{j-1}\frac{\Psi(x_{k+1})}{2}d_{j,k}^{\alpha ,2}+ \sum_{k=0}^{j-1}\frac{\Psi(x_{k+1})}{2}d_{j,k}^{\alpha,3} \Biggr] \\ &\quad=h^{2}c^{2} \biggl[ \frac{ ( \Psi_{i+1}^{j+1}-2\Psi _{i}^{j+1}+\Psi _{i-1}^{j+1} ) - ( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} ) }{2 ( \triangle x ) ^{2}} \biggr] -c^{4}m^{2} \biggl[ \frac{\Psi_{i}^{j+1}+\Psi_{i}^{j}}{2} \biggr] . \end{aligned}
(25)

To continue easier, let us do simplification in the equation with sufficient parameters as follows:

$$f_{i}^{j}=\frac{1}{4 ( \Delta x ) ^{2}},\qquad g_{i}^{j}= \frac{h^{2}c^{2}}{2 ( \triangle x ) ^{2}},\qquad h_{i}^{j}=\frac {c^{4}m^{2}}{2}.$$
(26)

Then we rewrite the equation with parameters

\begin{aligned}[b] &f_{i}^{j} \bigl( \Psi_{i}^{j+1}d_{j,k}^{\alpha,1}-2 \Psi _{i}^{j}d_{j,k}^{\alpha,2}+ \Psi_{i}^{j}d_{j,k}^{\alpha,3} \bigr) \\ &\qquad{}+f_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}d_{j,k}^{\alpha ,1}-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}d_{j,k}^{\alpha ,2}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}d_{j,k}^{\alpha,3} \Biggr] \\ &\quad=g_{i}^{j} \bigl[ \bigl( \Psi_{i+1}^{j+1}-2 \Psi_{i}^{j+1}+\Psi _{i-1}^{j+1} \bigr) - \bigl( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} \bigr) \bigr] \\ &\qquad{}-h_{i}^{j} \bigl( \Psi_{i}^{j+1}+ \Psi_{i}^{j} \bigr) . \end{aligned}
(27)

Finally, we have the following equation for the numerical scheme:

\begin{aligned} \begin{aligned}[b] &\Psi_{i}^{j+1} \bigl( f_{i}^{j}d_{j,k}^{\alpha ,1}+2g_{i}^{j}+h_{i}^{j} \bigr) \\ &\quad=\Psi_{i}^{j} \bigl( 2f_{i}^{j}d_{j,k}^{\alpha ,2}-f_{i}^{j}d_{j,k}^{\alpha,3}+2g_{i}^{j}-h_{i}^{j} \bigr) \\ &\qquad{}-f_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}d_{j,k}^{\alpha ,1}-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}d_{j,k}^{\alpha ,2}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}d_{j,k}^{\alpha,3} \Biggr] \\ &\quad\quad{}+g_{i}^{j} \bigl[ \Psi_{i+1}^{j+1}+ \Psi_{i-1}^{j+1}-\Psi _{i+1}^{j}-\Psi _{i-1}^{j} \bigr] . \end{aligned} \end{aligned}
(28)

#### 3.2.1 Stability analysis of the numerical scheme for the Caputo-Fabrizio derivative in Riemann-Liouville sense

Let us represent a stability analysis of the numerical scheme by supposing

$$s_{i}^{j}=\Psi_{i}^{j}-l_{i}^{j},$$
(29)

where $$l_{i}^{j}$$ is the approximate solution of the equation in time and space $$(x_{i},t_{j})$$ ($$i=1,2,\ldots,N$$, $$j=1,2,\ldots,M$$).

Also the error for approximation is given as

$$s_{i}^{j}= \bigl[ s_{1}^{j},s_{2}^{j}, \ldots,s_{N}^{j} \bigr] {.}$$
(30)

So we have the following error expression for the Klein-Gordon equation with mass parameter:

\begin{aligned}[b] &s_{i}^{j+1} \bigl( f_{i}^{j}d_{j,k}^{\alpha ,1}+2g_{i}^{j}+h_{i}^{j} \bigr) \\ &\quad=s_{i}^{j} \bigl( 2f_{i}^{j}d_{j,k}^{\alpha ,2}-f_{i}^{j}d_{j,k}^{\alpha ,3}+2g_{i}^{j}-h_{i}^{j} \bigr) \\ &\qquad{}-f_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}s_{i}^{j+1}d_{j,k}^{\alpha ,1}-2 \sum_{k=0}^{j-2}s_{i}^{j+1}d_{j,k}^{\alpha ,2}+ \sum_{k=0}^{j-2}s_{i}^{j+1}d_{j,k}^{\alpha,3} \Biggr] \\ &\quad\quad{}+g_{i}^{j} \bigl[ s_{i+1}^{j+1}+s_{i-1}^{j+1}-s_{i+1}^{j}-s_{i-1}^{j} \bigr] .\end{aligned}
(31)

Then let us take the following equality for doing the stability analysis.

$$\begin{gathered} s_{m}(x,t)=\exp[at] \exp[ik_{m}x], \\ s_{m}^{j} =\exp[at] \exp[ik_{m}x], \\ s_{m}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x], \\ s_{m+1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x+ \Delta x ) \bigr], \\ s_{m-1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x- \Delta x ) \bigr], \\ s_{m+1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr], \\ s_{m-1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr], \\ s_{m-1}^{j-1} =\exp \bigl[a ( t-\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr], \end{gathered}$$
(32)

where $$k_{m}=\frac{\pi m}{L}$$, $$m=1,2,\ldots,M=\frac{L}{\Delta x}$$. If we use the equalities above, the equation can be reconsidered as follows:

\begin{aligned}[b] &\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x] \bigl( f_{i}^{j}d_{j,k}^{\alpha,1}+2g_{i}^{j}+h_{i}^{j} \bigr) \\ &\quad=\exp[at]\exp[ik_{m}x] \bigl( 2f_{i}^{j}d_{j,k}^{\alpha ,2}-f_{i}^{j}d_{j,k}^{\alpha,3}+2g_{i}^{j}-h_{i}^{j} \bigr) \\ &\qquad{}-f_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( t+\Delta t ) \bigr] \exp [ik_{m}x]d_{j,k}^{\alpha,1} \\ &\qquad{} -2\sum_{k=0}^{j-2}\exp \bigl[a ( t+\Delta t ) \bigr]\exp [ik_{m}x]d_{j,k}^{\alpha,2} +\sum _{k=0}^{j-2}\exp \bigl[a ( t+\Delta t ) \bigr] \exp [ik_{m}x]d_{j,k}^{\alpha,3} \Biggr] \\ &\quad\quad{} +g_{i}^{j} \bigl[ \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] + \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \\ &\qquad{}-\exp[at]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] -\exp[at] \exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \bigr]. \end{aligned}
(33)

If we do simplification with $$\exp[at]\exp[ik_{m}x]$$, we will obtain the following:

\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl( f_{i}^{j}d_{j,k}^{\alpha ,1}+2g_{i}^{j}+h_{i}^{j} \bigr) \\ &\quad= \bigl( 2f_{i}^{j}d_{j,k}^{\alpha,2}-f_{i}^{j}d_{j,k}^{\alpha ,3}+2g_{i}^{j}-h_{i}^{j} \bigr) \\ &\qquad{}-f_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( \Delta t ) \bigr]d_{j,k}^{\alpha,1} \\ &\qquad{}-2\sum_{k=0}^{j-2} \exp \bigl[a ( \Delta t ) \bigr]d_{j,k}^{\alpha,2} +\sum _{k=0}^{j-2}\exp \bigl[a ( \Delta t ) \bigr]d_{j,k}^{\alpha,3} \Biggr] \\ &\quad\quad{}+g_{i}^{j} \bigl[ \exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( \Delta x ) \bigr] +\exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \\ &\qquad{}-\exp \bigl[ik_{m} ( \Delta x ) \bigr] -\exp \bigl[ik_{m} ( - \Delta x ) \bigr] \bigr] \end{aligned} \end{aligned}
(34)
\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl[ f_{i}^{j}d_{j,k}^{\alpha,1}+2g_{i}^{j}+h_{i}^{j}+f_{i}^{j}.J \bigl( d_{j,k}^{\alpha,1}-2d_{j,k}^{\alpha,2}+d_{j,k}^{\alpha,3} \bigr) \\ &\qquad{}-g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr] \\ &\quad= \bigl( 2f_{i}^{j}d_{j,k}^{\alpha,2}-f_{i}^{j}d_{j,k}^{\alpha ,3}+2g_{i}^{j}-h_{i}^{j} \bigr) -g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \end{aligned} \end{aligned}
(35)
\begin{aligned}& \begin{aligned}[b] \exp \bigl[a ( \Delta t ) \bigr]={}&{ \bigl\{ \bigl( 2f_{i}^{j}d_{j,k}^{\alpha,2}-f_{i}^{j}d_{j,k}^{\alpha ,3}+2g_{i}^{j}-h_{i}^{j} \bigr) -g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &/ \bigl\{ f_{i}^{j}d_{j,k}^{\alpha,1}+2g_{i}^{j}+h_{i}^{j}+f_{i}^{j}.J \bigl( d_{j,k}^{\alpha,1}-2d_{j,k}^{\alpha,2}+d_{j,k}^{\alpha,3} \bigr) \\ & -g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} . \end{aligned} \end{aligned}
(36)

With the help of the following inequality step by step, we have the condition for the stability analysis.

$$\begin{gathered} \frac{s_{i}^{j+1}}{s_{i}^{j}}=\exp \bigl[a(\Delta t) \bigr], \\ \biggl\vert \frac{s_{i}^{j+1}}{s_{i}^{j}} \biggr\vert = \bigl\vert \exp \bigl[a( \Delta t) \bigr] \bigr\vert \leq1.\end{gathered}$$
(37)

Then the stability condition is given as

\begin{aligned}[b] & \bigl\vert { \bigl\{ \bigl( 2f_{i}^{j}d_{j,k}^{\alpha,2}-f_{i}^{j}d_{j,k}^{\alpha ,3}+2g_{i}^{j}-h_{i}^{j} \bigr) -g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &\qquad/ \bigl\{ f_{i}^{j}d_{j,k}^{\alpha,1}+2g_{i}^{j}+h_{i}^{j}+f_{i}^{j}.J \bigl( d_{j,k}^{\alpha,1}-2d_{j,k}^{\alpha,2}+d_{j,k}^{\alpha,3} \bigr) \\ &\qquad{} -g_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} \bigr\vert \\ &\quad\leq1. \end{aligned}
(38)

### Theorem 4

The Crank-Nicholson scheme for solving the Klein-Gordon equation with the second order Caputo-Fabrizio derivative in Riemann-Liouville sense is stable if inequality (38) is satisfied.

### Theorem 5

Let f be a function not necessary differentiable within an interval $$[a,T]$$, then the fractional derivative of f of order $$1<\alpha\leq2$$ in the Atangana-Baleanu derivative in Riemann-Liouville sense is given as follows:

\begin{aligned}[b] &{}_{0}^{\mathrm{ABR}}D_{t}^{\alpha} \bigl[ f(x) \bigr] \\ &\quad=\frac{1}{2 ( \Delta x ) ^{2}} \Biggl[ \sum _{k=0}^{j}\frac{f(x_{k+1})}{2}a_{j,k}^{\gamma,1} -2\sum_{k=0}^{j-1}\frac{f(x_{k+1})}{2}a_{j,k}^{\gamma ,2}+ \sum_{k=0}^{j-1}\frac{f(x_{k+1})}{2}a_{j,k}^{\gamma,3} \Biggr] +G,\end{aligned}
(39)

where

\begin{aligned} G={}&\frac{\gamma}{(1-\gamma)\sqrt{\pi}} \Biggl[ \sum _{k=0}^{j} \int_{x_{k}}^{x_{k+1}} \bigl( f(\varepsilon )-f(x_{j+1}) \bigr) E_{\gamma,2} \biggl( - \biggl( \frac{\gamma }{1-\gamma} \biggr) ^{2} ( x_{j+1}- \varepsilon ) ^{2} \biggr) \,d\varepsilon \\ &-2\sum_{k=0}^{j-1} \int_{x_{k}}^{x_{k+1}} \bigl( f(\varepsilon )-f(x_{j+1}) \bigr) E_{\gamma,2} \biggl( - \biggl( \frac{\gamma }{1-\gamma} \biggr) ^{2} ( x_{j}- \varepsilon ) ^{2} \biggr) \,d\varepsilon \\ &+\sum_{k=0}^{j-1} \int_{x_{k}}^{x_{k+1}} \bigl( f(\varepsilon )-f(x_{j+1}) \bigr) E_{\gamma,2} \biggl( - \biggl( \frac{\gamma }{1-\gamma} \biggr) ^{2} ( x_{j+1}- \varepsilon ) ^{2} \biggr) \,d\varepsilon \Biggr] ,\end{aligned}

and

$$\begin{gathered} a_{j,k}^{\gamma,1} =E_{\gamma,2} \biggl\{ -\gamma \frac {x_{j+1}-x_{k+1}}{1-\gamma} \biggr\} -E_{\gamma,2} \biggl\{ -\gamma \frac {x_{j+1}-x_{k}}{1-\gamma} \biggr\} , \\ a_{j,k}^{\gamma,2} =E_{\gamma,2} \biggl\{ -\gamma \frac {x_{j}-x_{k+1}}{1-\gamma} \biggr\} -E_{\gamma,2} \biggl\{ -\gamma\frac {x_{j}-x_{k}}{1-\gamma } \biggr\} , \\ a_{j,k}^{\gamma,3} =E_{\gamma,2} \biggl\{ -\gamma \frac {x_{j-1}-x_{k+1}}{1-\gamma} \biggr\} -E_{\gamma,2} \biggl\{ -\gamma\frac {x_{j-1}-x_{k}}{1-\gamma} \biggr\} .\end{gathered}$$
(40)

Now we can consider the equation again as follows:

\begin{aligned}[b] &\frac{1}{2 ( \Delta x ) ^{2}} \Biggl[ \sum_{k=0}^{j} \frac{\Psi(x_{k+1})}{2}a_{j,k}^{\gamma,1} -2\sum _{k=0}^{j-1}\frac{\Psi(x_{k+1})}{2}a_{j,k}^{\gamma ,2}+ \sum_{k=0}^{j-1}\frac{\Psi(x_{k+1})}{2}a_{j,k}^{\gamma,3} \Biggr] \\ &\quad=h^{2}c^{2} \biggl[ \frac{ ( \Psi_{i+1}^{j+1}-2\Psi _{i}^{j+1}+\Psi _{i-1}^{j+1} ) - ( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} ) }{2 ( \triangle x ) ^{2}} \biggr] -c^{4}m^{2} \biggl[ \frac{\Psi_{i}^{j+1}+\Psi_{i}^{j}}{2} \biggr] .\end{aligned}
(41)

To continue easier, let us do simplification in the equation with sufficient parameters as follows:

$$m_{i}^{j}=\frac{1}{4 ( \Delta x ) ^{2}},\quad\quad n_{i}^{j}= \frac{h^{2}c^{2}}{2 ( \triangle x ) ^{2}},\quad\quad r_{i}^{j}=\frac {c^{4}m^{2}}{2}.$$
(42)

Then we rewrite the equation with parameters

\begin{aligned}[b] &m_{i}^{j} \bigl( \Psi_{i}^{j+1}a_{j,k}^{\gamma,1}-2 \Psi _{i}^{j}a_{j,k}^{\gamma,2}+ \Psi_{i}^{j}a_{j,k}^{\gamma,3} \bigr) \\ &\qquad{}+m_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}a_{j,k}^{\gamma ,1}-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}a_{j,k}^{\gamma ,2}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}a_{j,k}^{\gamma,3} \Biggr] \\ &\quad=n_{i}^{j} \bigl[ \bigl( \Psi_{i+1}^{j+1}-2 \Psi_{i}^{j+1}+\Psi _{i-1}^{j+1} \bigr) - \bigl( \Psi_{i+1}^{j}-2\Psi_{i}^{j}+\Psi _{i-1}^{j} \bigr) \bigr] \\ &\qquad{}-r_{i}^{j} \bigl( \Psi_{i}^{j+1}+ \Psi_{i}^{j} \bigr) .\end{aligned}
(43)

Finally, we have the following equation for the numerical scheme:

\begin{aligned} \begin{aligned}[b] &\Psi_{i}^{j+1} \bigl( m_{i}^{j}a_{j,k}^{\gamma ,1}+2n_{i}^{j}+r_{i}^{j} \bigr) \\ &\quad=\Psi_{i}^{j} \bigl( 2m_{i}^{j}a_{j,k}^{\gamma ,2}-m_{i}^{j}a_{j,k}^{\gamma,3}+2n_{i}^{j}-r_{i}^{j} \bigr) \\ &\qquad{}-m_{i}^{j} \Biggl[ \sum _{k=0}^{j-1} \Psi_{i}^{j+1}a_{j,k}^{\gamma ,1}-2 \sum_{k=0}^{j-2}\Psi_{i}^{j+1}a_{j,k}^{\gamma ,2}+ \sum_{k=0}^{j-2}\Psi_{i}^{j+1}a_{j,k}^{\gamma,3} \Biggr] \\ &\qquad{}+n_{i}^{j} \bigl[ \Psi_{i+1}^{j+1}+ \Psi_{i-1}^{j+1}-\Psi _{i+1}^{j}-\Psi _{i-1}^{j} \bigr] . \end{aligned} \end{aligned}
(44)

#### 3.3.1 Stability analysis of the numerical scheme for the Atangana-Baleanu derivative in Riemann-Liouville sense

Let us represent a stability analysis of the numerical scheme by supposing

$$u_{i}^{j}=\Psi_{i}^{j}-y_{i}^{j},$$
(45)

where $$l_{i}^{j}$$ is the approximate solution of the equation in time and space $$(x_{i}, t_{j})$$ ($$i=1,2,\ldots,N$$, $$j=1,2,\ldots,M$$).

Also the error for approximation is given as

$$u_{i}^{j}= \bigl[ u_{1}^{j},u_{2}^{j}, \ldots,u_{N}^{j} \bigr] {.}$$
(46)

So we have the following error expression for the Klein-Gordon equation with mass parameter:

\begin{aligned}[b] &u_{i}^{j+1} \bigl( m_{i}^{j}a_{j,k}^{\gamma ,1}+2n_{i}^{j}+r_{i}^{j} \bigr) \\ &\quad=u_{i}^{j} \bigl( 2m_{i}^{j}a_{j,k}^{\gamma ,2}-m_{i}^{j}a_{j,k}^{\gamma ,3}+2n_{i}^{j}-r_{i}^{j} \bigr) \\ &\quad\quad{}-m_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}u_{i}^{j+1}a_{j,k}^{\gamma ,1}-2 \sum_{k=0}^{j-2}u_{i}^{j+1}a_{j,k}^{\gamma ,2}+ \sum_{k=0}^{j-2}u_{i}^{j+1}a_{j,k}^{\gamma,3} \Biggr] \\ &\quad\quad{}+n_{i}^{j} \bigl[ u_{i+1}^{j+1}+u_{i-1}^{j+1}-u_{i+1}^{j}-u_{i-1}^{j} \bigr] . \end{aligned}
(47)

Then let us take the following equality for doing the stability analysis.

$$\begin{gathered} u_{m}(x,t)=\exp[at] \exp[ik_{m}x], \\ u_{m}^{j} =\exp[at] \exp[ik_{m}x], \\ u_{m}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x], \\ u_{m+1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x+ \Delta x ) \bigr], \\ u_{m-1}^{j} =\exp[at]\exp \bigl[ik_{m} ( x- \Delta x ) \bigr], \\ u_{m+1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr], \\ u_{m-1}^{j+1} =\exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr], \\ u_{m-1}^{j-1} =\exp \bigl[a ( t-\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr], \end{gathered}$$
(48)

where $$k_{m}=\frac{\pi m}{L}$$, $$m=1,2,\ldots,M=\frac{L}{\Delta x}$$. If we use the equalities above, the equation can be reconsidered as follows:

\begin{aligned}[b] &\exp \bigl[a ( t+\Delta t ) \bigr] \exp[ik_{m}x] \bigl( m_{i}^{j}a_{j,k}^{\gamma,1}+2n_{i}^{j}+r_{i}^{j} \bigr) \\ &\quad=\exp[at]\exp[ik_{m}x] \bigl( 2m_{i}^{j}a_{j,k}^{\gamma ,2}-m_{i}^{j}a_{j,k}^{\gamma,3}+2n_{i}^{j}-r_{i}^{j} \bigr) \\ &\quad\quad{}-m_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( t+\Delta t ) \bigr] \exp [ik_{m}x]a_{j,k}^{\gamma,1} \\ &\qquad{}-2\sum_{k=0}^{j-2}\exp \bigl[a ( t+ \Delta t ) \bigr]\exp [ik_{m}x]a_{j,k}^{\gamma,2} +\sum _{k=0}^{j-2}\exp \bigl[a ( t+\Delta t ) \bigr] \exp [ik_{m}x]a_{j,k}^{\gamma,3} \Biggr] \\ &\qquad{}+n_{i}^{j} \bigl[ \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] + \exp \bigl[a ( t+\Delta t ) \bigr]\exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \\ &\qquad{}-\exp[at]\exp \bigl[ik_{m} ( x+\Delta x ) \bigr] -\exp[at] \exp \bigl[ik_{m} ( x-\Delta x ) \bigr] \bigr]. \end{aligned}
(49)

If we do simplification with $$\exp[at]\exp[ik_{m}x]$$, we will obtain the following:

\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl( m_{i}^{j}a_{j,k}^{\gamma ,1}+2n_{i}^{j}+r_{i}^{j} \bigr) \\ &\quad= \bigl( 2m_{i}^{j}a_{j,k}^{\gamma,2}-m_{i}^{j}a_{j,k}^{\gamma ,3}+2n_{i}^{j}-r_{i}^{j} \bigr) \\ &\qquad{}-m_{i}^{j} \Biggl[ \sum _{k=0}^{j-1}\exp \bigl[a ( \Delta t ) \bigr]a_{j,k}^{\gamma,1} -2\sum_{k=0}^{j-2} \exp \bigl[a ( \Delta t ) \bigr]a_{j,k}^{\gamma,2} +\sum _{k=0}^{j-2}\exp \bigl[a ( \Delta t ) \bigr]a_{j,k}^{\gamma,3} \Biggr] \\ &\qquad{}+n_{i}^{j} \bigl[ \exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( \Delta x ) \bigr] +\exp \bigl[a ( \Delta t ) \bigr]\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \\ &\qquad{} -\exp \bigl[ik_{m} ( \Delta x ) \bigr] -\exp \bigl[ik_{m} ( - \Delta x ) \bigr] \bigr] \end{aligned} \end{aligned}
(50)
\begin{aligned}& \begin{aligned}[b] &\exp \bigl[a ( \Delta t ) \bigr] \bigl[ m_{i}^{j}a_{j,k}^{\gamma,1}+2n_{i}^{j}+r_{i}^{j}+m_{i}^{j}.J \bigl( a_{j,k}^{\gamma,1}-2a_{j,k}^{\gamma,2}+a_{j,k}^{\gamma,3} \bigr) \\ &\qquad{} -n_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr] \\ &\quad= \bigl( 2m_{i}^{j}a_{j,k}^{\gamma,2}-m_{i}^{j}a_{j,k}^{\gamma ,3}+2n_{i}^{j}-r_{i}^{j} \bigr) -n_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \end{aligned} \end{aligned}
(51)
\begin{aligned}& \begin{aligned}[b] \exp \bigl[a ( \Delta t ) \bigr]={}&{ \bigl\{ \bigl( 2m_{i}^{j}a_{j,k}^{\gamma,2}-m_{i}^{j}a_{j,k}^{\gamma ,3}+2n_{i}^{j}-r_{i}^{j} \bigr) -n_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &/ \bigl\{ m_{i}^{j}a_{j,k}^{\gamma,1}+2n_{i}^{j}+r_{i}^{j}+m_{i}^{j}.J \bigl( a_{j,k}^{\gamma,1}-2a_{j,k}^{\gamma,2}+a_{j,k}^{\gamma,3} \bigr) \\ &-n_{i}^{j} \bigl( \exp \bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} . \end{aligned} \end{aligned}
(52)

With the help of the following inequality step by step, we have the condition for the stability analysis:

$$\biggl\vert \frac{u_{i}^{j+1}}{u_{i}^{j}} \biggr\vert = \bigl\vert \exp \bigl[a( \Delta t) \bigr] \bigr\vert \leq1.$$

Then the stability condition is given as

\begin{aligned}[b] & \bigl\vert {\bigl\{ \bigl( 2m_{i}^{j}a_{j,k}^{\gamma,2}-m_{i}^{j}a_{j,k}^{\gamma ,3}+2n_{i}^{j}-r_{i}^{j} \bigr) -n_{i}^{j} \bigl( \exp\bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} } \\ &\qquad/\bigl\{ m_{i}^{j}a_{j,k}^{\gamma,1}+2n_{i}^{j}+r_{i}^{j}+m_{i}^{j}.J \bigl( a_{j,k}^{\gamma,1}-2a_{j,k}^{\gamma,2}+a_{j,k}^{\gamma,3} \bigr) \\ &\qquad{}-n_{i}^{j} \bigl( \exp\bigl[ik_{m} ( \Delta x ) \bigr]+\exp \bigl[ik_{m} ( -\Delta x ) \bigr] \bigr) \bigr\} \bigr\vert \\ &\quad\leq1. \end{aligned}
(53)

### Theorem 6

The Crank-Nicholson scheme for solving the Klein-Gordon equation with the second order Atangana-Baleanu derivative in Riemann-Liouville sense is stable if inequality (50) is satisfied.

## 4 Conclusion

In this paper the Klein-Gordon equation with mass parameter was considered. The time second derivative was replaced by three different fractional derivatives, namely, Riemann-Liouville power law fractional derivative, Riemann-Liouville exponential law fractional derivative and finally Riemann-Liouville Mittag-Leffler law fractional derivative. A second approximation of each derivative was presented and used to solve the corresponding model. In detail, the stability and convergence analysis of each numerical scheme were investigated.