1 Introduction

In the recent past, modeling with fractional order differential equations has been of increasing importance due to its capability to model non local phenomena. Especially the fractional diffusion equation allows to model dynamic processes with possibly arbitrary long range interaction. This has shown to be especially useful in e.g biology [1], within quantum physics [2], for chemical reactions [3], in stock market prediction [4], in epidemic models [5] and many more. All the above shall motivate a reconsideration of the classical random walk model.

The classical diffusion equation can be derived via several ways as presented in the literature. To derive the fractional diffusion equation, it is useful to reconsider the random walk approach, used to derive the standard diffusion equation. Let x denote the position of a given particle. For the description of the random walk, we use two probability density functions. We sample from a function w the step lengths, i.e. the distance \(x_i-x_{i-1}\) and from \(\psi \) the waiting times \(t_i-t_{i-1}\) that a particle waits at a given position before continuing to move.

In the classical derivation, we implicitly assume that w and \(\psi \) do not allow arbitrary large jumps or waiting times, as their probability rapidly tends towards zero for large arguments. Therefore, the classical random walk is a local problem in space and time as the influence of particles is local due to finite jumps and finite waiting times.

However, empirical observations suggest that this is not true for all processes that can be modeled as a random walk. For example in 1996, Viswanathan et al. discovered, that the flight of an albatross can be modeled as a Levy flight [1], i.e. a random walk that allows large step lengths. This can be described with a heavy-tailed probability density function w, which decays slower for large arguments than an exponential ansatz. For Levy flights, Mandelbrot [6] suggested a distribution for the step length \(\Delta x\) as

$$\begin{aligned} Pr(\Delta x>s) = {\left\{ \begin{array}{ll} 1 \quad & \quad {\text {for}} \; s<1, \\ s^{-D} & \quad {\text {for}}\; u\ge 1, \end{array}\right. } \end{aligned}$$
(1)

where D ≥ 1 is related to the factional dimension. Since the distributions is heavy-tailed, this yields an infinite variance, different from an exponentially decaying distribution. In Fig. 1 we can see the results of an isotropic 2D random walk simulation after 1000 steps where the step length has been sampled from a normal distribution (a) and a Cauchy distribution (b), which corresponds to the simulation of a Levy flight. Note the large jumps in (b), which result from the heavy-tailed probability density function. The qualitative behavior of the Levy process and the observation by Viswanathan et al. are similar in the case, that both movements contain steps with significantly larger length than the more frequent smaller steps. This pattern can not be observed for the standard Brownian motion.

This observation should motivate a reconsideration of the classical random walk model. The above described phenomena has not only been observed in biology, but can also be found in photon transport in clouds, for correlated background media or fractals, within quantum physics [2], for chemical reactions [3], in stock market prediction [4], in epidemic models [5] and many more. In contrast to classical kinetic models, these models are no longer memorylessness, implying that actions performed at a current state depend on previously performed actions. In random processes where the memorylessness assumption is no longer valid and the mean square displacements scales like \(\langle x^2\rangle \propto t^\alpha \), fractional differential operators can be used to model the underlying microscopic behavior by fractional partial differential equations on a macroscopic level. Due to its non local nature, fractional differential equations are often harder to solve numerically than integer order differential equations. One of the reasons is the fact, that the sparsity in the used differentiation matrices vanishes and dense matrices need to be computed and used when using a finite difference approach. Therefore, applying the same algorithms that are used for standard differential equations in an adapted fashion often yields unsatisfactory results. Methods that exploit the non local structure of the problem, might be advantageous in their application to fractional problems.

In this work, we will present a spectral method to solve the time- and spacefractional diffusion equation for periodic domains in space. By carefully selecting an appropriate basis for the spatial ansatz, we can make sure that the resulting system is still sparse, allowing to invert it easily. We will further show that the resulting scheme can be used to approximating solutions to the classical wave equation by letting α, the index of the temporal derivative, approach a value of two.

Fig. 1
figure 1

Random walk of a single particle with different path-length distribution. a Normal distribution. b Levy distribution

2 The time-fractional master equation

Let us at first derive the fractional diffusion equation in time based on the approach presented by Scalas et al. [7]. Assume that we consider the probability density functions \(w(\xi )\) and \(\psi (\tau )\), such that \(\xi _i\) and \(\tau _i\) are both identically independent distributed random variables. Let p(xt) denote the probability of finding a particle at time t at position x and assume the initial distribution to be the delta function, i.e. \(p(x,0)=\delta (x)\). The master equation of the continuous time random walk (CTRW) is then given by

$$\begin{aligned} p(x,t) &=\delta (x)\Psi (t) + \int _0^t \psi (t-t')\\ &\quad \int _{-\infty }^\infty w(x-x')p(x',t')dx'dt', \end{aligned}$$
(2)

with

$$\begin{aligned} \Psi (t) = \int _t^\infty \psi (t')dt'=1-\int _0^t \psi (t')dt',\quad \psi (t) = -\frac{\partial }{\partial t} \Psi (t). \end{aligned}$$
(3)

Thus, the probability of finding a particle at (xt) equals the probability of finding a particles at a prior time \(t'\) and position \(x'\) that moves the distance \(x-x'\) after waiting \(t-t'\). Furthermore, we have to add the number of particles that did not jump from the initial position until time t, which is described by \(\delta (x)\Psi (t)\). Recall the definition for the Fourier transformation in space and the Laplace transformation in time by

$$\begin{aligned} {{\mathcal {F}}}[f(x)](\kappa ) = \int _{-\infty }^\infty e^{i \kappa x}f(x) dx =: \hat{f}(\kappa ), \end{aligned}$$
(4)

and

$$\begin{aligned} {{\mathcal {L}}}[f(t)](s) = \int _{0}^\infty e^{-s t}f(t) dt =: \tilde{f}(s), \end{aligned}$$
(5)

with \(i^2=-1\), respectively. If we now apply the Fourier–Laplace transform of the Master Eq. (2), we obtain

$$\begin{aligned} {\hat{\tilde{p}}}(\kappa ,s) = \tilde{\Psi }(s) \frac{1}{1-\hat{w}(\kappa ) \tilde{\psi }(s)}. \end{aligned}$$
(6)

Mainardi et al. suggest an equivalent formulation [8]

$$\begin{aligned} {\tilde{\Phi }}(s)\left[s{\hat{\tilde{p}}}(\kappa ,s) -1\right] = [\hat{w}(\kappa )-1] {\hat{\tilde{p}}}(\kappa ,s), \end{aligned}$$
(7)

where we define

$$\begin{aligned} {\tilde{\Phi }}(s) = \frac{\tilde{\Psi }(s)}{1-s\tilde{\Psi }(s)}. \end{aligned}$$
(8)

To get back to the space-time domain, we apply the inverse Fourier–Laplace transformation to obtain

$$\begin{aligned} \int _0^t \Phi (t-t')\frac{\partial }{\partial t'} p(x,t')dt'= -p(x,t)+\int _{-\infty }^\infty w(x-x')p(x',t)dx'. \end{aligned}$$
(9)

In this context, \(\Phi (t)\) has the role of a “memory function” and the process is no longer Markovien [8], i.e. memoryless, unless the above function degenerates into a delta function, such that \(\psi (t) = c\cdot \phi (t)\) with a positive constant c. If we assume \({\tilde{\Phi }}(s)=1\), we obtain \(\Phi (t) = \delta (t)\) and further \(\tilde{\psi }(s) = 1\cdot \tilde{\Psi }(s) = \frac{1}{1+s}\) which yields by application of the inverse Laplace transformation \(\psi (t)=1\cdot \Phi (t) = e^{-t}\) for \(t\ge 0\). This means, that we have memoryless exponential decay of the waiting time distribution and Eq. (9) reduces to

$$\begin{aligned} \frac{\partial }{\partial t} p(x,t) -p(x,t)+\int _{-\infty }^\infty w(x-x')p(x',t)dx'. \end{aligned}$$
(10)

Therefore, with the assumptions of exponential decay, we reconstruct the classical master equation for a Markovian continuous time random walk (also called the Kolmogorov-Feller equation), which we could use to reconstruct the classical diffusion equation.

However, we can also consider different approaches for the memory function \(\Phi (t)\). If \(\Phi (t)\) has power law decay, it corresponds to possibly arbitrary large waiting times, i.e. a heavy-tailed probability density function for the waiting time. With the choice

$$\begin{aligned} \Phi (t) = \frac{t^{-\alpha }}{\Gamma (1-\alpha )} ,\quad t \ge 0 ,\quad 0<\alpha <1, \end{aligned}$$
(11)

we can model the power law decay. Additionally, since \(\delta (t)\) can formally be written as \(\delta (t) = t^{-1}/\beta (0)\), we see that \(\Phi (t)=\delta (t)\) as \(\alpha \rightarrow 1\). If we plug \(\Phi (t)\) from Eq. (11) into Eq. (9), we get

$$\begin{aligned} 0& = {} \int _0^t \Phi (t-t')\frac{\partial }{\partial t'} p(x,t')dt' +p(x,t)-\int _{-\infty }^\infty w(x-x')p(x',t)dx' \end{aligned}$$
(12)
$$\begin{aligned}= & {} \frac{1}{\Gamma (1-\alpha )}\int _0^t (t-t')^{-\alpha }\frac{\partial }{\partial t'} p(x,t')dt'+p(x,t)-\int _{-\infty }^\infty w(x-x')p(x',t)dx'\end{aligned}$$
(13)
$$\begin{aligned}&= {} \frac{\partial ^\alpha }{\partial t^\alpha } p(x,t)+p(x,t)-\int _{-\infty }^\infty w(x-x')p(x',t)dx'. \end{aligned}$$
(14)

Here we use the definition of the Caputo derivative in the last step, namely

$$\begin{aligned} \frac{\partial ^\alpha }{\partial t^\alpha } f(t) = \frac{1}{\Gamma (1-\alpha )} \int _0^t \frac{ p'(t')}{(t-t')^{\alpha }}dt'. \end{aligned}$$
(15)

Another way of deriving Eq. (14) is done via the Laplace transformation of the definition of \(\Phi (t)\) in Eq. (11), given by \({\tilde{\Phi }}(s) = 1/s^{1-\alpha }\). If we plug this into the formulation of Mainardi et al. from Eq. (7), we obtain

$$\begin{aligned} s^\alpha {\hat{\tilde{p}}}(\kappa ,s)-s^{\alpha -1} = [\hat{w}(\kappa )-1]{\hat{\tilde{p}}} (\kappa ,s), \end{aligned}$$
(16)

for \(0<\alpha <1\). The Laplace transform of the fractional differential operator \(\partial ^\alpha /\partial t^\alpha \) is defined as

$$\begin{aligned} {{\mathcal {L}}}[\partial ^\alpha /\partial t^\alpha f(t)](s) = s^\alpha \tilde{f}(s) - s^{\alpha -1}\tilde{f}(0^+), \end{aligned}$$
(17)

and we can use the inverse Fourier and Laplace transform of Eq. (16) to derive

$$\begin{aligned} \frac{\partial ^\alpha }{\partial t^\alpha } p(x,t) +p(x,t)-\int _{-\infty }^\infty w(x-x')p(x',t)dx'=0, \end{aligned}$$
(18)

with initial condition \(p(x,0) = \delta (x)\). Note, that the definition \( \Phi (t) = \frac{t^{-\alpha }}{\Gamma (1-\alpha )} ,\quad t \ge 0 ,\quad 0<\alpha <1 \) implies

$$\begin{aligned} \tilde{\Psi }(s) = \frac{s^{\alpha -1}}{1+s^\alpha }\quad {\text {and}}\quad \tilde{\psi }(s) = \frac{1}{1+s^\alpha }\quad {\text {for}}\quad 0<\alpha <1. \end{aligned}$$
(19)

Applying the inverse Laplace transform, this yields

$$\begin{aligned} \Psi (t) = E_\alpha (-t^\alpha )\quad {\text {and}}\quad \psi (t) = -\frac{d}{dt}E_\alpha (-t^\alpha )\quad {\text {for}}\quad 0<\alpha <1. \end{aligned}$$
(20)

Here \(E_\alpha \) is again the special case \(E_{\alpha ,1}\), where \(E_{\alpha ,\beta }\) defines the Mittag-Leffler function. Recall, that the Mittag-Leffler function interpolates between an exponential decay for small waiting times and a power law decay for large waiting times [7], i.e.

$$\begin{aligned} E_\alpha (-t^\alpha ) ~ {\left\{ \begin{array}{ll} \exp ({-t^\alpha /\Gamma (1+\alpha )}) &{}\quad {\text {for}}\quad t \rightarrow 0, \\ t^{-\alpha }/\Gamma (1-\alpha ) &{}\quad {\text {for}}\quad t \rightarrow \infty . \end{array}\right. } \end{aligned}$$
(21)

3 Diffusion limit

Performing the diffusion limit in space allows us to derive two different types of equations. Depending on the decay of the path-length distribution w(x), we can derive the Laplace operator \(\Delta \) for the spatial derivative or a spatial derivative of fractional order. For simplicity, we assume \(w(x)=w(-x)\), i.e. the process is isotropic. The following derivation follows the approach presented by Gorenflo and Mainardi [9]. For \(0<\beta <2,\quad b>0\) and \(|x|\rightarrow \infty \) we define

$$\begin{aligned} w(x) = \frac{b}{|x|^{\beta +1}}, \end{aligned}$$
(22)

where we have an asymptotic representation of the Fourier transform as

$$\begin{aligned} \hat{w}(\kappa )\approx 1-\eta |\kappa |^\beta +o(|\kappa |^\beta ), \end{aligned}$$
(23)

as \(\kappa \rightarrow 0\), with \(\displaystyle \eta = \frac{b\pi }{\beta (\beta +1)\sin (\beta \pi /2)}\) for \(0<\beta <2\). We are now going to rescale the process, to be able to perform the diffusion limit later on. If we replace jumps of length X by scaled jumps hX, i.e. we replace w(x) with \(w_h(x)=w(x/h)/h\), this can be interpreted as performing smaller and smaller jumps as h tends to zero. Furthermore, we accelerate the spatially rescaled process by \(1/(\eta h^\beta )\), the re-speeding factor. These two components scale the process in space.

Using the subscript h, we can write the rescaled process of Eq. (18) as

$$\begin{aligned} \eta h^\beta \frac{\partial ^\alpha }{\partial t^\alpha } p_h(x,t) +p_h(x,t)-\int _{-\infty }^\infty w_h(x-x')p_h(x',t)dx'=0, \end{aligned}$$
(24)

with Laplace–Fourier transform

$$\begin{aligned} \eta h^{\beta } \left[s^\alpha \hat{\tilde{p_h}}(\kappa ,s)-s^{\alpha -1} \right]&= [\hat{w}_h(\kappa )-1]\hat{\tilde{p_h}} (\kappa ,s) , \end{aligned}$$
(25)
$$\begin{aligned} \Leftrightarrow \left[s^\alpha \hat{\tilde{p_h}}(\kappa ,s)-s^{\alpha -1}\right]&= \frac{\hat{w}_h(\kappa )-1}{\eta h^{\beta }}\hat{\tilde{p_h}} (\kappa ,s). \end{aligned}$$
(26)

Since

$$\begin{aligned} \lim _{ h\rightarrow 0}\frac{\hat{w}(h \kappa )-1}{\eta h^{\beta }} = -|\kappa |^\beta , \end{aligned}$$
(27)

for \(0<\beta \le 2\) and \(\kappa \in {\mathbb {R}}\), we can define \(\rho _h(\kappa )=\frac{\hat{w}(h\kappa )-1}{\eta h^{\beta }}\) and obtain

$$\begin{aligned}{}\left[s^\alpha \hat{\tilde{p_h}}(\kappa ,s)-s^{\alpha -1}\right] = \rho _h(\kappa )\hat{\tilde{p_h}} (\kappa ,s) \end{aligned}$$
(28)

and in the limit \(h\rightarrow 0\)

$$\begin{aligned} \left[ s^\alpha \hat{\tilde{p_0}}(\kappa ,s)-s^{\alpha -1}\right] = -|\kappa |^\beta \hat{\tilde{p_0}} (\kappa ,s) . \end{aligned}$$
(29)

Since \(-|\kappa |^\beta \) is the Fourier transform of the space-fractional Riesz derivative \(\partial ^\beta / \partial |x|^\beta \), we use the inverse Fourier–Laplace transformation to derive the space-time fractional diffusion equation

$$\begin{aligned} \frac{\partial ^\alpha }{\partial t^\alpha } p_0(x,t)&= \frac{\partial ^\beta }{\partial |x|^\beta }p_0(x,t), \end{aligned}$$
(30)
$$\begin{aligned} p_0(x)&=\delta (x). \end{aligned}$$
(31)

Some further remarks should be made, concerning the scaling and the limit \(h\rightarrow 0\). By rescaling and accelerating the complete process, we decrease the jumps, while simultaneously making the waiting times between the jumps smaller. For the limit \(h \rightarrow 0\) in Eq. (28) we use a Lemma of Gorenflo [10], that ensures the result of Eq. (27), which holds with the explicit definition \(\displaystyle \eta = \frac{b\pi }{\beta (\beta +1)\sin (\beta \pi /2)}\) if \(0<\beta <2\) as mentioned before. According to Lukacs [11], we have convergence in the distribution of \(\hat{\tilde{p_h}}(\kappa ,s)\) towards \(\hat{\tilde{p_0}}(\kappa ,s)\) by the continuity theorem of probability.

As derived in this section, we can see, that under certain assumptions on the probability density functions of the waiting time distribution and the step length distribution respectively, we are able to derive the fractional diffusion equation, which generalized the derivative operator from first or second order to arbitrary order in space and time. For the case, that \(\beta =2\) and \(\alpha =1\) the derived fractional diffusion equation coincides with the standard diffusion equation, given by

$$\begin{aligned} \frac{\partial }{\partial t} p_0(x,t)&= \frac{\partial ^2}{\partial x^2}p_0(x,t), \end{aligned}$$
(32)
$$\begin{aligned} p_0(x)&=\delta (x). \end{aligned}$$
(33)

Note, that even though we did not cover the situation, where \(\alpha \rightarrow 2\), it is possible to show, that the fractional differential equation converges towards the standard wave equation, i.e.

$$\begin{aligned} \frac{\partial ^2}{\partial t^2} p_0(x,t)&= \frac{\partial ^2}{\partial x^2}p_0(x,t) , \end{aligned}$$
(34)
$$\begin{aligned} p(x,0)&=p_0(x,t), \end{aligned}$$
(35)

which is covered by various authors in the literature. See for example the work of Luchko [12], El-Sayed [13], Mainardi [14] or Metzler and Nonnemacher [15].

4 The spectral Galerkin method

On of the standard methods for solving partial differential equations is the Galerkin method. As before, we plug in an ansatz for our solution into the original equation and require the residual of the projection onto the space spanned by the test functions to vanish. Consider the one dimensional diffusion equation

$$\begin{aligned} \frac{\partial }{\partial t}u(x,t)- \frac{\partial ^2}{\partial x^2} u(t,x) =f(x,t), \end{aligned}$$
(36)

with homogeneous initial and boundary conditions. If we further consider a space V, we obtain the weak formulation of Eq. (62) by finding \(u \in V\) such that

$$\begin{aligned} {{\mathcal {A}}}(u,v) = {{\mathcal {F}}}(v) \quad \forall v \in V, \end{aligned}$$
(37)

with the bilinear form

$$\begin{aligned} {{\mathcal {A}}}(u,v) = \langle \partial _t u,v\rangle _V + \langle \partial _x u,\partial _x v\rangle _V \end{aligned}$$
(38)

and

$$\begin{aligned} {{\mathcal {F}}}(v) = \langle f,v\rangle _V. \end{aligned}$$
(39)

We then seek solutions \(u_N\in V_N\) where \(V_N \subset V\). The weak problem in the subspace is then to find \(u_N\in V_N\) such that

$$\begin{aligned} {{\mathcal {A}}}(u_N,v_N) = {{\mathcal {F}}}(v_N) \quad \forall v_N \in V_N. \end{aligned}$$
(40)

If the bilinear form is continuous and coercive and \({{\mathcal {F}}}\) is bounded, then it is well known, that by Cea’s lemma the error of the approximation can be bounded by

$$\begin{aligned} ||u-u_N|| \le {\text {inf}}_{v_N \in V_N}||u-v_N||. \end{aligned}$$
(41)

This means, that we have the best approximation property and the error bound only depends on the approximation of the space. By choosing an appropriate basis we are then able to achieve spectral convergence simply as a result of the choice of basis functions.

5 The spectral Galerkin method of fractional order

We will now review one of the main contributions to fully spectral numerical methods in the context of fractional differential equations. In their paper from 2009, Li and Xi present a space-time spectral method for the solution of the time fractional heat equation. Let us consider from now on the one dimensional time fractional diffusion equation

$$\begin{aligned} {}_0\partial _t^\alpha u(x,t)-\partial _{xx} u(t,x) =f(x,t) , \end{aligned}$$
(42)

with \((x,t)\in \Omega := \Lambda \times I = (-1,1)\times (0,T)\) and homogeneous initial and boundary conditions

$$\begin{aligned} u(x,0)&=0, \end{aligned}$$
(43)
$$\begin{aligned} u(-1,t)=u(1,t)&= 0. \end{aligned}$$
(44)

Since we have the homogeneous initial and boundary conditions, the Riemann–Liouville and Caputo derivative coincide.

For the spectral expansion in space and time, Li and Xi provide suitable basis polynomials. Let \(P_M(\Lambda )\) and \(P_N(I)\) define the set of polynomials of degree M in space and N in time, respectively. Since we assume \(u(\partial \Lambda ,t)\equiv 0\) as well as \(u(x,0)\equiv 0\), we choose polynomials in space from

$$\begin{aligned} P_M^0(\Lambda ) = P_M(\Lambda ) \cap H_0^1(\Lambda ), \end{aligned}$$
(45)

as well as for time

$$\begin{aligned} P_N^E(I) =\{v \in P_N(I) | v(0) \equiv 0\}. \end{aligned}$$
(46)

For sake of convenience, define the multiindex \(L=(M,N)\) and

$$\begin{aligned} S_L := P_M^0(\Lambda ) \otimes P_N^E(I). \end{aligned}$$
(47)

Then the Galerkin problem is given by finding \(u_L \in S_L\) such that

$$\begin{aligned} {{\mathcal {A}}}(u_L,v_L) = {{\mathcal {F}}}(v_L) \quad \forall v_L \in S_L. \end{aligned}$$
(48)

However, it remains to specify the bilinear form in the context of fractional derivatives. For \({{\mathcal {A}}}\) to be symmetric, we need some way to symmetrize the scalar product \(\langle {}_0D_t^\alpha u,v\rangle \). We therefore cite the following two lemmas from the original paper.

Lemma 1

For \(0<\alpha <1\) and \(u\in H^\alpha (I)\), \(v\in C^\infty _0(I)\) we have

$$\begin{aligned} \left\langle {}_0D^\alpha _t u,v \right\rangle _I = \left\langle u,{}_tD_T^\alpha v\right\rangle _I. \end{aligned}$$
(49)

Proof

Applying integration by parts to the definition of the scalar product yields

$$\begin{aligned} \left\langle {}_0D^\alpha _t u,v \right\rangle _I&= \int _0^T \frac{1}{\Gamma (1-\alpha )}\frac{d}{dt}\int _0^t \frac{u(\tau )}{(t-\tau )^\alpha } \, d\tau v(t) \, dt \end{aligned}$$
(50)
$$\begin{aligned}&= \underbrace{\left[ \frac{1}{\Gamma (1-\alpha )}\int _0^t \frac{u(\tau )}{(t-\tau )^\alpha }v(t) \right] _0^T}_{=0, {\text { since}} v\in C_0^\infty } - \int _0^T \frac{1}{\Gamma (1-\alpha )}\int _0^t \frac{u(\tau )}{(t-\tau )^\alpha } \, d\tau v'(t) \, dt \end{aligned}$$
(51)
$$\begin{aligned}&= - \int _0^T \frac{1}{\Gamma (1-\alpha )}\int _0^t \frac{u(\tau )}{(t-\tau )^\alpha } \, d\tau v'(t) \, dt . \end{aligned}$$
(52)

By changing the order of integration and by employing the fact, that for \(v\in C_0^\infty \) the Riemann–Liouville definition and the Caputo definition coincide, we further obtain

$$\begin{aligned} \langle {}_0D^\alpha _t u,v\rangle _I&= - \int _0^T \frac{1}{\Gamma (1-\alpha )}\int _0^t \frac{u(\tau )}{(t-\tau )^\alpha } \, d\tau v'(t) \, dt \end{aligned}$$
(53)
$$\begin{aligned}&= - \int _0^T \frac{1}{\Gamma (1-\alpha )}\int _t^T \frac{v'(t)}{(t-\tau )^\alpha } \, dt u(\tau ) \, d\tau \end{aligned}$$
(54)
$$\begin{aligned}&= - \int _0^T \frac{1}{\Gamma (1-\alpha )}\frac{d}{dt}\int _0^t \frac{v(t)}{(t-\tau )^\alpha } \, dt u(\tau ) \, d\tau \end{aligned}$$
(55)
$$\begin{aligned}&= \left\langle u,{}_tD_T^\alpha v \right\rangle _I . \end{aligned}$$
(56)

\(\square \)

Lemma 2

For all \(0<\alpha < 1\) and \(u \in {}_0H^1(I)\), \(v \in {}_0H^{\alpha /2}(I)\) we have

$$\begin{aligned} \left\langle {}_0D^\alpha _t u,v \right\rangle _I = \left\langle {}_0D^{\alpha /2}_t u, {}_tD^{\alpha /2}_tv \right\rangle _I . \end{aligned}$$
(57)

Proof

The idea is, to use the fact, that \({}_0D^\alpha _t u = {}_0D^{\alpha /2}_t{}_0D^{\alpha /2}_t u\) and Lemma 1. \(\square \)

This yields the Galerkin problem that is considered in the following. Try to find \(u_L \in S_L\) such that

$$\begin{aligned} {{\mathcal {A}}}(u_L,v_L) = {{\mathcal {F}}}(v_L) \quad \forall v_L \in S_L, \end{aligned}$$
(58)

where the bilinear form is given by

$$\begin{aligned} {{\mathcal {A}}}(u,v) = \left\langle {}_0\partial _t^{\alpha /2}u,{}_t\partial _T^{\alpha /2} v \right\rangle _\Omega +\, \left\langle \partial _x u,\partial _x v \right\rangle _\Omega . \end{aligned}$$
(59)

It can then be shown, that in the given context, the requirements for the Lax-Milgram theorem are satisfied and convergence and uniqueness, as well as spectral convergence rate by Cae’s lemma are ensured.

6 Choosing a basis

For the Galerkin method, we have to choose appropriate bases in space and in time to guarantee the spectral convergence. We will firstly consider the expansion in time and the in space.

6.1 An Ansatz for the temporal expansion

To achieve good convergence time, we use a linear combination of Jacobi polynomials. Note, that we use different spaces for test and trial functions. Define

$$\begin{aligned} \phi _j(t)&= J_j^{-\alpha /2,0}\left( \frac{2t}{T}-1\right) +J_{j-1}^{-\alpha /2,0} \left( \frac{2t}{T}-1\right) ,\end{aligned}$$
(60)
$$\begin{aligned} \psi _n(t)&= \frac{n}{n-\alpha /2} J_n^{-\alpha /2,0}\left( \frac{2t}{T}-1\right) + J_{n-1}^{-\alpha /2,0}\left( \frac{2t}{T}-1\right) , \end{aligned}$$
(61)

where both i and j run from 1 to N and \(J_k^{\alpha ,\beta }\) are the standard Jacobi polynomials. Even though this choice might seem arbitrary, it can be verified, that these polynomials form a suitable basis that allows easy evaluation of the involved integrals in combination with the fractional differential operators. We note, that both, the set of \(\psi _n(t)\) and \(\phi _j(t)\) form a basis of \(P_N^E(I)\).

6.2 An Ansatz for the spatial expansion

We will derive a spectral method that also solves the time space fractional diffusion equation, using a Fourier ansatz for the spatial variable. This method yields spectral convergence for periodic problems, therefore no longer requiring homogeneous spatial boundary conditions. Furthermore, we will show that by letting \(\alpha \), the index of the time derivative, approach two, our method can be used to approximate solutions of the wave equation.

Summarizing this, we consider problems of the type

$$\begin{aligned} {}_0\partial _t^\alpha u(x,t)-\partial _{|x|}^{2\beta } u(t,x) =f(x,t) , \end{aligned}$$
(62)

with \((x,t)\in \Omega := \Lambda \times I = (0,2\pi )\times (0,T)\) and

$$\begin{aligned} u(x,0)&=u_0(x), \end{aligned}$$
(63)
$$\begin{aligned} u(0,t)&=u(2\pi ,t). \end{aligned}$$
(64)

With \(\alpha ,\beta \in (0,1)\) and consistency in the initial and boundary conditions. The space fractional derivative \(\partial _{|x|}^{2\beta } \) is defined by \(2\partial _{|x|}^{2\beta } u(t,x) = \partial _{x}^{2\beta } u(t,x)+{}_x\partial ^{2\beta } u(t,x)\), i.e. the symmetric combination of the left- and right-sided fractional derivative. We can transform this problem into a problem with homogeneous initial conditions by defining \(v(x,t) :=u(x,t)-u(x,0)\) and substituting \(u(x,t) = v(x,t)+u(x,0)\) in the original equation to obtain

$$\begin{aligned} {}_0\partial _t^\alpha v(x,t)-\partial _{|x|}^{2\beta } v(t,x)&=f(x,t) + \partial _{|x|}^{2\beta } u(x,0) =: \tilde{f}(x,t), \end{aligned}$$
(65)
$$\begin{aligned} v(x,0)&=0, \end{aligned}$$
(66)
$$\begin{aligned} v(0,t)&=v(2\pi ,t) . \end{aligned}$$
(67)

Under the assumption, that the problem is periodic, our initial conditions are symmetric and by denoting that the fractional differential operator in space is also symmetric, we can apply Lemma 1 to obtain the bilinear form

$$\begin{aligned} {{\mathcal {A}}}(u,v) = \left\langle {}_0\partial _t^{\alpha /2}u,{}_t\partial _T^{\alpha /2} v \right\rangle _\Omega + \left\langle \partial _{|x|}^{\beta } u,\partial _{|x|}^{\beta } v \right\rangle _\Omega . \end{aligned}$$
(68)

As shown by Zhan and Liu [16], in the case of the Riesz fractional differential operator, which is up to scaling by a constant identically to \(\partial _{|x|}^{2\beta }\), the complex Fourier expansion polynomials provide a suitable basis of eigenfunctions. Let us therefore consider the space

$$\begin{aligned} P_M(\Lambda ) = {\text {span}}\left\{ e^{imx} / \sqrt{2\pi },m\in (-M,M) \right\} . \end{aligned}$$
(69)

This choice of basis polynomials is orthonormal with respect to the standard scalar product on \(\Lambda \), i.e. \(\langle e^{imx} / \sqrt{2\pi }, e^{inx} / \sqrt{2\pi }\rangle _\Lambda =\delta _{mn}\). Zhan and Liu have shown, that the terms \(e^{imx}\) are eigenfunctions of the considered differential operator with eigenvalues \((im)^{2\beta }\) and therefore, \(\langle \partial _{|x|}^{\beta }e^{imx} / \sqrt{2\pi }, \partial _{|x|}^{\beta }e^{inx} / \sqrt{2\pi }\rangle _\Lambda =\delta _{mn}m^{2\beta }\). This property is obviously desirable, since we are able to avoid the calculation of the scalar products by numerical quadrature rules and we are able to explore sparsity. The ansatz for approximating u(xt) is then given by

$$\begin{aligned} u(x,t) = \sum _{i=1}^{\infty } \sum _{j=-\infty }^\infty u_{ij} f_i(x) \phi _j(t)\approx \sum _{m=-M}^{M} \sum _{j=1}^N u_{ij} f_m(x) \phi _j(t) =:u_L(x,t), \end{aligned}$$
(70)

with \(f_m(x)=e^{imx}/\sqrt{(}2\pi )\) and \(\phi _j(t)\) defined as before. For the convergence to be spectral we need u(xt) to be sufficiently smooth. Since we consider a periodic domain with initial conditions \(u(x,0) \not \equiv 0\), we will see that it is necessary to require additional smoothness conditions on u(x, 0), i.e. we want \(u^{(n)}(x,0)=u^{(n)}(x,2\pi )\) for as many orders of the derivative n as possible. This is not only necessary for spectral convergence of the method, but also for the approximation by the Fourier series in space, since we would otherwise encounter the Gibbs phenomenon.

7 Numerical results

We will now apply the derived method to several problems and show convergence results as well as the phenomenological influence of the fractional order of the derivatives in time and space, respectively. All examples will be based on the general formulation in Eq. (62)

7.1 Fractional diffusion equations

At first, we will consider a standard scenario in diffusive processes. Let us omit the source term f at first. For u(x, 0) we assume a standard normal distribution as the initial conditions, i.e. \(u(x,0) = \exp (-(x-\pi )^2)\), shown in Fig. 2. We then solve

$$\begin{aligned} {}_0\partial _t^\alpha v(x,t)-\partial _{|x|}^{2\beta } v(t,x)&= \partial _{|x|}^{2\beta } \exp (-(x-\pi )^2), \end{aligned}$$
(71)
$$\begin{aligned} v(x,0)&=0, \end{aligned}$$
(72)
$$\begin{aligned} v(0,t)&=v(2\pi ,t). \end{aligned}$$
(73)

The qualitative influence of the order of the fractional derivative can be seen in Fig. 3, where all combinations of equation (62) with \(\alpha \in \{ 0,0.5,1\}\) and \(2\beta \in \{0, 1.5,2\}\) are presented. For \(\alpha =0\) we only have diffusion in space and the solution is time invariant, which corresponds to the first row of plots. It can be seen, that the higher the value for \(\beta \), the more spread out the value of v(x) is over the spatial domain. For \(\alpha =0\) and \(2\beta = 2\) we then recover the equation \((I+\Delta ^2)v=\Delta ^2 u_0(x)\).

Fig. 2
figure 2

Initial conditions for the results shown in Fig. 3

If we now increase \(\alpha \), we obtain a time-dependent problem. Similar to the case, where we increase \(\beta \), an increase in \(\alpha \) causes higher diffusivity in time. For \(\alpha = 0.5\) and \(2\beta =1.5\) we recover the fully time and space fractional diffusion equation. Setting \(\alpha =1\) yields the classical time derivative and together with \(2\beta = 2\) we are left with the classical heat equation.

Fig. 3
figure 3

Solution u(xt) of the diffusion equation for different values of \(\alpha \) and \(2\beta \)

Since our method is spectral in space and time, respectively, we also expect spectral convergence of the solution in both cases. However, we know that the convergence rate of the spectral Galerkin approach depends on the smoothness of the analytic solution to the problem. Since the initial conditions have discontinuities in the derivative at the periodic boundary, this might be a limiting factor in the convergence rate. From Figs. 4a, 5, 6b we then see the convergence results in dependency of the temporal expansion order N, presented in the left column, and the spatial expansion order M in the right column. The presented cases are a sample of all of the performed simulations from Fig. 3. We only show the results, for the cases where either on or two derivatives are of fractional order. In Fig. 4a, b we set the temporal derivative \(\alpha =0.5\) and leave the spatial derivative of integer order. In Fig. 5a, b, the temporal derivative is the first derivative and we have a fractional derivative in space with \(2\beta =1.5\). The last row presents the results for the time and space fractional diffusion equation in Fig. 6a, b. We are able to derive several conclusions from the given convergence plots. From the results in Figs. 4a and 6a, the convergence rate in time for the fractional derivative is significantly slower, than for the integer order case in Fig. 5a where we converge to machine precision for even low values of N. The results suggest, that for non homogeneous initial conditions, the convergence rate in time is reduced, given \(\alpha \not \in {\mathbb {N}}\). This behaviour is in agreement with the theoretical analysis if we recall, that for fractional order derivatives, the decay is algebraic and not exponential. Therefore, any error in the initial conditions is damped slower in the case where \(\alpha =0.5\). This is also in agreement with the observations made for the case, where we will later use homogeneous initial conditions, but a right-hand side that is also non zero as for this simulation, shown in Figs. 12a, 13 and 14b.

If we now also consider the convergence in space, we observe that the methods converges fast at first, but then flattens out for M greater 12. This observation can be justified with recalling, that our analytic solution is not smooth enough, due to discontinuities in the derivatives at the periodic boundary. On the other hand we note, that the convergence rate is almost independent of the order of the derivative in space, which means, that our method is able to recover solutions for fractional spatial order derivatives in the same quality as for the integer order case.

Fig. 4
figure 4

Convergence result for fixed \(\alpha =0.5\) and \(\beta =1.0\). a Convergence in time. b Convergence in space

Fig. 5
figure 5

Convergence result for fixed \(\alpha =1.0\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

Fig. 6
figure 6

Convergence result for fixed \(\alpha =0.5\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

To support our claim, that the spatial convergence rate is reduced due to discontinuities in the solution, we consider initial conditions that allow a smoother solution in the next case. If we multiply the original initial conditions with \(x^k (2\pi -x)^k\) we obtain smooth derivatives at the boundary up to order k. This smoothed initial conditions can be seen in Fig. 7, where we also scale the initial conditions with \((2\pi )^{-k}\) to keep the order of magnitude of the solution.

The results for this modified problem are then presented in Figs. 8a, 9, 10b. Since we do not introduce a new time-dependent quantity, the convergence in time remains unchanged in comparison with the original problem. However, for the convergence in space, we no observe spectral convergence throughout all expansion orders M. Again, the convergence in space is independent of the value for \(\beta \).

Fig. 7
figure 7

Initial conditions with continuous derivatives at the periodic boundary for \(k=5\)

Fig. 8
figure 8

Convergence result for fixed \(\alpha =0.5\) and \(\beta =1.0\). a Convergence in time. b Convergence in space

Fig. 9
figure 9

Convergence result for fixed \(\alpha =1.0\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

Fig. 10
figure 10

Convergence result for fixed \(\alpha =1.0\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

To obtain faster spectral convergence in time, we now consider a case with solution u(xt) that fulfils \(u(x,0)\equiv 0\). This can be achieved, by introducing homogeneous initial conditions with a right-hand side f(xt) that also satisfies \(f(x,0)\equiv 0\). In this example, we consider the case where we use a right-hand side f(xt) that combines the smoothed initial conditions with forcing term to set \(f(x,0)\equiv 0\). One possible f(xt) that satisfies these requirements is given by

$$\begin{aligned} f(x,t) = t^k(T-t)^k \cdot x^k(2\pi -x)^k \exp (-(x-\pi )^2), \end{aligned}$$
(74)

and is visualized in Fig. 11. The convergence results for this computation are given in Figs. 12a, 13, 14b. We note, that the convergence in space stays almost unchanged. However, for the convergence in time we now observe much faster spectral convergence, due to the fact that our solution vanishes for \(t=0\). Comparing Figs. 12a and 14a to 13a, we still observe faster convergence for the integer order derivative case. A possible, heuristic explanation for this might be given, by considering fundamental property of fractional derivatives. Since integer order derivatives are local operators and fractional derivatives operate globally, this also influences the way that errors are propagated throughout the domain.

Fig. 11
figure 11

Smooth right hand side with zero values on spatial and temporal boundaries

Fig. 12
figure 12

Convergence result for fixed \(\alpha =0.5\) and \(\beta =1.0\). a Convergence in time. b Convergence in space

Fig. 13
figure 13

Convergence result for fixed \(\alpha =1.0\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

Fig. 14
figure 14

Convergence result for fixed \(\alpha =0.5\) and \(\beta =0.75\). a Convergence in time. b Convergence in space

7.2 Approximating solutions of the wave equation

Since the theoretical analysis of the spectral fractional Galerkin methods assumes, that \(\alpha /2\in (0,1)\) and not \(\alpha \in (0,1)\), we can approach values of \(\alpha =2\) arbitrary close. However, for \(\alpha =2\) the method breaks down, since the Jacobi polynomials are not defined for this case. Setting \(\alpha =1.999\) and \(2\beta = 2\), we approach the classical wave equation \(\partial _{tt}u(x,t)-\partial _{xx}u(x,t) = f(x,t)\). For the case of zero source term and sinusoidal initial conditions, the solution of the system is given in Fig. 15 and for a higher frequency of the initial conditions and a longer domain in time in Fig. 16. These experiments suggest, that the method outlined can be used to compute solutions of the fractional diffusion equation, but also approaching solutions of the fractional wave equation as \(\alpha \rightarrow 2\).

A further theoretical analysis of the rate of convergence and the applicability of the method to a broader variety of test cases is work in progress and will be investigated in future work.

Fig. 15
figure 15

Approaching the solution of the wave equation

Fig. 16
figure 16

Approaching the solution of the wave equation

8 Summary

In this work we have derived the fractional diffusion equation and explained its applicability in the modeling of diffusion processes in nature that are no longer memorylessness. This fundamentally changes the underlying behavior of the process and make the problem numerically harder to solve. We chose an appropriate spatial and temporal ansatz to expand our solution and make use of the Galerkin method, now applied in the fractional setting, where we used a Fourier expansion in space. Since these are eigenfunctions of the corresponding fractional differential operator as well as orthogonal with another, sparsity in the resulting matrices can be ensured. Numerical experiments where performed for a variety of test cases and show the expected spectral convergence for problems with smooth initial conditions. Furthermore, we applied the derived method to fractional partial differential equations that approach the classical and fractional wave equation by letting the index of the time derivative approach the value of two arbitrarily close, thus obtaining a method that handles problems with diffusive characteristics as well as wave related phenomena. While this was done in a qualitative manner, these first observations indicate that the presented method works for \(\alpha \in [0,2)\), and not only for \(\alpha \in [0,1]\). Thus extending the applicability towards the regime, governed by the wave equation.