1 Introduction

Fractional differential equations (FDEs) have a long history. It can be traced back to the works of L’Hopital since 1695 when he raised a question to Leibniz about derivative of order \(\frac{1}{2}\). In the last two decades, FDEs have drawn increasing attention due to their important applications in various fields of mathematics, sciences and engineering, such as electrochemistry [1], economic [2], mechanic [3, 4], medicine [5], signal processing [6], traffic model [7], and informatics [8].

Delay differential equation is a special kind of differential equation in which the derivative of the unknown function at a certain time is given in terms of not only the value of the unknown function at the same time, but also the values of the unknown function at previous times. Delay differential equations are introduced during various mathematical modelling of processes in engineering and sciences, such as economy, biology, medicine, chemistry, control, and electrodynamic (see for instance, [9, 10] and references therein). In general, the solution of some delay differential equations cannot be expressed in terms of elementary functions. Therefore, it is necessary to develop numerical methods to approximate the solution of these equations. Variety of numerical solution methods have been proposed, for instance, Adomian decomposition method [11], One-leg \(\theta \)-method [12], variational method [13], Legendre wavelet method [14], Chebyshev polynomials [15], and Bernoulli operational matrices [16].

Fractional delay differential equation is a natural generalization of delay differential equations of integer orders. However, there were not many works devoted to numerical methods for solving such kinds of differential equations. Some available numerical methods for solving fractional delay differential equations are based on finite difference method [17], Legendre pseudo-spectral functions [18], spectral collocation method [19], Hermit wavelet functions [20], Bernoulli wavelet functions [21], and linear interpolation method [22].

In recent years, wavelet theory has received considerable attention because of its powerful applications in several fields such as system analysis, numerical analysis, and optimal control [23]. Wavelets have several specific properties that make them useful [24]. In general, for solving fractional calculus using wavelets, the following equation has been used:

$$\begin{aligned} I^{\alpha }\Psi (t)\approx P^{\alpha }\Psi (t)\,, \end{aligned}$$

where \(I^{\alpha }\) is the Riemann–Liouville fractional integral of order \(\alpha \) for different wavelets and \(P^{\alpha }\) the operational matrix for Riemann–Liouville integration (OMRLI). The elements of \(\Psi (t)\) are the basis functions. Typical examples are the applications of Chebyshev, Legendre, Cosine and Sine (CAS), or Haar wavelets [25,26,27,28]. For obtaining \(P^{\alpha }\), these wavelets were first expanded into block-pulse functions, then the OMRLI of block-pulse functions was used for calculating \(P^{\alpha }\). In addition, for obtaining \(P^{\alpha }\), using Bernoulli wavelets in [29], the Bernoulli wavelets were first expanded into Bernoulli polynomials, then the OMRLI of Bernoulli polynomials was used for calculating \(P^{\alpha }\) for Bernoulli wavelets. It is noted that none of these wavelets calculated \(P^{\alpha }\) directly, and some approximations were involved for calculating \(I^{\alpha }\Psi (t)\).

A fractional delay differential equation can be stated as follows:

$$\begin{aligned} \left\{ \begin{aligned}&D^{\alpha }y(x)=f\left( x,y(x),y(x-\tau )\right) , \qquad x \in [0,1],\, \alpha >0,\, \tau \in (0,1),\\&y^{(i)}(0)= \lambda _i, \qquad i =0,\ldots , \lceil \alpha \rceil ,\\&y(x)=\phi (x), \qquad x<0, \end{aligned} \right. \end{aligned}$$
(1)

where y is an unknown function; f and \(\phi \) are known analytic functions; \(\alpha , \tau \), and the initial values \(\lambda _i\) are given; \(\lceil \alpha \rceil \) is the smallest integer larger than or equal to \(\alpha \). In this paper, we introduce a new numerical method for solving fractional delay differential equations in Eq. (1). The method is based on the use of Taylor wavelets. We present the exact formula for determining the fractional integral of the Taylor wavelets. The exact formula will be then applied to solve the delay differential equation in Eq. (1). This formula allows us to reduce the given delay differential equation to a system of algebraic equations, which can be solved by the Newton iteration method.

The paper is organized as follows: Basic definitions and notations from Fractional Calculus are introduced in Sect. 2. Section 3 is devoted to Taylor wavelets and their properties. In Sect. 4, we establish the exact formula for determining the fractional integral of the Taylor wavelets defined in the previous section. A numerical method for solving the fractional delay differential equation based on Taylor wavelets is presented in Sect. 5 and error estimations are given in Sect. 6. Several examples are presented in Sect. 7 to show the applicability and the effectiveness of our method.

2 Fractional-order integrals and derivatives

In this section, we recall some definitions and basis properties of fractional-order integrals and derivatives.

Definition 2.1

(see [30]) The Riemann–Liouville fractional integral of order \(\alpha \ge 0\) of a function f(x) over \([0,+\infty )\) is a function over \([0,+\infty )\) defined as

$$\begin{aligned} (I^{\alpha } f)(x)= \left\{ \begin{aligned}&\frac{1}{\Gamma (\alpha )} \int _{0}^{x} \frac{f(s)}{(x-s)^{1 - \alpha }} \mathrm{d}s = \frac{1}{\Gamma (\alpha )} x^{\alpha -1} * f(x),&\text { if } \alpha >0,\\&f(x),&\text { if } \alpha =0, \end{aligned} \right. \end{aligned}$$
(2)

where \(x^{\alpha -1} * f(x)\) is the convolution product of \(x^{\alpha -1}\) and f(x).

Definition 2.2

(see [31]) The Caputo fractional derivative of order \(\alpha \ge 0\) of a function f(x) over \([0,+\infty )\) is a function over \([0,+\infty )\) defined as

$$\begin{aligned} (D^{\alpha } f)(x)= I^{n-\alpha } f^{(n)}(x), \end{aligned}$$

where \(n = \lceil \alpha \rceil \).

Fractional-order integrals and derivatives satisfy the following properties:

Proposition 2.3

For \(\alpha \ge 0\), the following hold:

  1. 1.

    \(I^{\alpha }\) and \(D^{\alpha }\) are linear operators, i.e., \(I^{\alpha }(\lambda f+\mu g)= \lambda I^{\alpha }f + \mu I^{\alpha }g\) and \(D^{\alpha }(\lambda f+\mu g)= \lambda D^{\alpha }f + \mu D^{\alpha }g\) for every functions \(f,\,g\) and numbers \(\lambda ,\,\mu \).

  2. 2.

    \(D^{\alpha }I^{\alpha }f(x)=f(x)\).

  3. 3.

    \(I^{\alpha }D^{\alpha }f(x)=f(x)-\sum \limits _{j=0}^{\lceil \alpha \rceil } \frac{f^{(j)}(0)}{j!} x^j\).

  4. 4.

    \(I^{\alpha }x^{j}=\frac{\Gamma (j+1)}{\Gamma (j+\alpha +1)} x^{j+\alpha }\) for \(j>-1\).

  5. 5.

    \(D^{\alpha }x^{j}=\frac{\Gamma (j+1)}{\Gamma (j-\alpha +1)}x^{j-\alpha }\) for \(j>\alpha -1\).

3 Taylor wavelets

3.1 Wavelets and Taylor wavelets

Wavelets are a family of functions constructed from dilation and translation of a single function called the mother wavelet. When the dilation parameter a and the translation parameter b vary continuously, we have the following family of continuous wavelets [23]:

$$\begin{aligned} \psi _{a,b}(t)=\mid a\mid ^{\frac{-1}{2}}\psi \left( \frac{t-b}{a}\right) ,~~~~~a\ne 0,~~~a,b \in \mathbb {R} \end{aligned}$$

If we restrict the parameters a and b to discrete values as \(a = a_0^k\), and \(b = nb_0a_0^k\), where \(a_0> 1,~ b_0 > 0\), and n and k are positive integers, we obtain the family of discrete wavelets as:

$$\begin{aligned} \psi _{k,n}(t)=\mid a_{0}\mid ^{\frac{k}{2}}\psi \left( a_{0}^{k}t-nb_{0}\right) , \end{aligned}$$

which form a wavelet basis for \(L^{2}(\mathbb {R})\).

Definition 3.1

(See [32]) Let k be a positive integer. For each \(n=1,\ldots ,2^{k-1}\) and \(m \in \mathbb {N}\), the Taylor wavelet function, say \(\psi _{n,m}\), is defined over [0, 1) by

$$\begin{aligned} \psi _{n,m}(x) = \left\{ \begin{aligned}&2^{\frac{k-1}{2}} \cdot {\tilde{T}}_m \left( 2^{k-1} x-n+1 \right) ,&\text { if } \frac{n-1}{2^{k-1}} \le x < \frac{n}{2^{k-1}},\\&0,&\text { otherwise,} \end{aligned} \right. \end{aligned}$$

where

$$\begin{aligned} {\tilde{T}}_m(x)=\sqrt{2m+1}\cdot x^m \end{aligned}$$
(3)

is the normal Taylor polynomial of degree m.

The six Taylor wavelets corresponding to \(k=2\) with the order \(m <3\) are the following:

$$\begin{aligned}&\psi _{1,0}(x) = \left\{ \begin{aligned}&\sqrt{2},&\text { if } 0 \le x< \frac{1}{2},\\&0,&\text { if } \frac{1}{2} \le x< 1. \end{aligned} \right. \\&\psi _{2,0}(x) = \left\{ \begin{aligned}&0,&\text { if } 0 \le x< \frac{1}{2},\\&\sqrt{2},&\text { if } \frac{1}{2} \le x< 1. \end{aligned} \right.&\\&\psi _{1,1}(x) = \left\{ \begin{aligned}&2 \sqrt{6} x,&\text { if } 0 \le x< \frac{1}{2},\\&0,&\text { if } \frac{1}{2} \le x< 1. \end{aligned} \right. \\&\psi _{2,1}(x)= \left\{ \begin{aligned}&0,&\text { if } 0 \le x< \frac{1}{2},\\&\sqrt{6} (2x-1),&\text { if } \frac{1}{2} \le x< 1. \end{aligned} \right.&\\&\psi _{1,2}(x) = \left\{ \begin{aligned}&4 \sqrt{10} x^2,&\text { if } 0 \le x< \frac{1}{2},\\&0,&\text { if } \frac{1}{2} \le x< 1. \end{aligned} \right. \\&\psi _{2,2}(x) = \left\{ \begin{aligned}&0,&\text { if } 0 \le x< \frac{1}{2},\\&\sqrt{10} (2x-1)^2,&\text { if } \frac{1}{2} \le x < 1. \end{aligned} \right.&\end{aligned}$$

The following properties of the Taylor wavelets can be verified by a direct calculation:

Proposition 3.2

Let \(k,n_1,n_2,m_1,\ {\rm and} \ m_2\) be positive integers such that \(1 \le n_1,n_2 \le 2^{k-1}\). Then,

$$\begin{aligned} \int \limits _{0}^{1} \psi _{n_1,m_1}(x) \psi _{n_2,m_2}(x) \mathrm{d}x = \left\{ \begin{aligned}&\frac{\sqrt{\left( 2m_1+1 \right) \left( 2m_2+1 \right) }}{m_1+m_2+1},&\mathrm{if} \ n_1 = n_2,\\&0,&\mathrm{if} \ n_1 \ne n_2. \end{aligned} \right. \end{aligned}$$

3.2 Function approximation

Recall that a set \(S \subset L^2[0,1]\) is called a complete set if the linear vector space generated by S is dense in \(L^2[0,1]\). For each \(k \in \mathbb {N}\), since the space of polynomials is dense in \(L^2[0,1]\), the set

$$\begin{aligned} {\mathcal {O}}_k:= \bigcup \limits _{m=0}^{\infty } \left\{ \psi _{n,m}(x) \,|\, n=1,\ldots ,2^{k-1}\right\} \end{aligned}$$

forms a complete set. Therefore, a function f in \(L^2[0,1]\) can always be expanded as

$$\begin{aligned} f(x)=\sum \limits _{m=0}^{\infty } \sum \limits _{n=1}^{2^{k-1}} c_{n,m} \psi _{n,m}(x), \end{aligned}$$
(4)

for some sequence of real numbers \(\{c_{n,m}\}_{n,m}\).

For each positive numbers k and  M, we set

$$\begin{aligned} {\mathcal {O}}_{k,M}:= \left\{ \psi _{n,m}(x) \,|\, 1 \le n \le 2^{k-1},\, 0 \le m \le M-1\right\} . \end{aligned}$$

In the next section, we find a function in the linear vector space \(\text {span}({\mathcal {O}}_{k,M})\) which is the best approximation to a solution of a given fractional delay differential equation. The space \(\text {span}({\mathcal {O}}_{k,M})\) is a closed finite-dimensional subspace of \(L^2[0,1]\). By the Hilbert Projection Theorem (see [33, Thm. 2, p. 51]), there exists a unique function in \(\text {span}({\mathcal {O}}_{k,M})\) minimizing the distance to f. The function is obtained by truncating the series in Eq. (4) up to order \(M{-}1\), i.e.,

$$\begin{aligned} f(x) \simeq \sum \limits _{m=0}^{M-1} \sum \limits _{n=1}^{2^{k-1}} c_{n,m} \psi _{n,m}(x) = C^T \cdot \Psi _{k,M}(x), \end{aligned}$$

where

$$\begin{aligned} C= & {} \big [c_{1,0},\ldots ,c_{1,M-1},c_{2,0},\ldots ,c_{2,M-1},\ldots ,c_{2^{k-1},0},\nonumber \\&\ldots ,c_{2^{k-1},M-1}\big ]^T, \end{aligned}$$
(5)

and

$$\begin{aligned} \Psi _{k,M}= & {} \big [\psi _{1,0},\ldots ,\psi _{1,M-1},\psi _{2,0},\ldots ,\psi _{2,M-1},\ldots ,\psi _{2^{k-1},0},\nonumber \\&\ldots ,\psi _{2^{k-1},M-1}\big ]^T. \end{aligned}$$
(6)

4 Riemann–Liouville fractional integral for Taylor wavelets

An exact formula for the fractional-order integral of Taylor wavelets is presented in the following theorem:

Theorem 4.1

The integral of order \(\alpha >0\) of the function \(\psi _{n,m}\) is given by

$$ I^{\alpha } \psi _{{n,m}} (x) = \left\{ {\begin{array}{ll} {0,\;} \\ {U(x),{\text{ }}} \\ {(x) - V(x),} \\ \end{array} \begin{array}{ll} {{\text{if}}0 \le x < \frac{{(n - 1)h}}{{2^{{k - 1}} }},} \\ {{\text{if}}\frac{{(n - 1)h}}{{2^{{k - 1}} }} \le x < \frac{{nh}}{{2^{{k - 1}} }},} \\ {{\text{if}} \frac{{nh}}{{2^{{k - 1}} }} \le x < 1,} \\ \end{array} } \right. $$
(7)

where

$$\begin{aligned} U(x)= & {} \frac{2^{\left( m+\frac{1}{2}\right) (k-1)} \Gamma (m+1) \sqrt{2m+1}}{\Gamma (m+\alpha +1)} \\&\cdot \left( x-\frac{(n-1)h}{2^{k-1}}\right) ^{m+\alpha }, \end{aligned}$$

and

$$\begin{aligned} V(x)= & {} \sum \limits _{l=0}^{m} \left( {\begin{array}{c}m\\ l\end{array}}\right) \frac{2^{\left( l+\frac{1}{2}\right) (k-1)} \Gamma (l+1) \sqrt{2m+1}}{\Gamma (l+\alpha +1)}\\&\cdot \left( x-\frac{nh}{2^{k-1}}\right) ^{l+\alpha }. \end{aligned}$$

Proof

To obtain \(I^{\alpha }\psi _{n,m}\), we use the Laplace transform. Using the unit step function defined as

$$\begin{aligned} \mu _{c}(x) = \left\{ \begin{aligned} 1, \qquad \text { if } x \ge c,\\ 0, \qquad \text { if } x<c, \end{aligned} \right. \end{aligned}$$

we can rewrite the Taylor wavelet \(\psi _{n,m}(x)\) as follows:

$$\begin{aligned} \psi _{n,m}(x) =\,&\mu _{\frac{(n-1)h}{2^{k-1}}}(x) \cdot 2^{\frac{k-1}{2}} \tilde{T}_m \left( 2^{k-1}x -n+1 \right) \\&- \mu _{\frac{nh}{2^{k-1}}}(x) \cdot 2^{\frac{k-1}{2}} \tilde{T}_m \left( 2^{k-1} x -n+1 \right) \\ =\,&I_1-I_2. \end{aligned}$$

By taking the Laplace transform of \(I_1\) and using

$$\begin{aligned} \mathscr {L}\{ \mu _c(x) f(x) \} = e^{-cs} \mathscr {L}\{f(x+c)\}, \end{aligned}$$

we get

$$\begin{aligned}&\mathscr {L}\{I_1\} \\&\quad = e^{-\frac{(n-1)h}{2^{k-1}}\cdot s} 2^{\frac{k-1}{2}} \mathscr {L}\left\{ \tilde{T}_m \left( 2^{k-1} \left( x+\frac{(n-1)h}{2^{k-1}}\right) -n+1 \right) \right\} \\&\quad = e^{-\frac{(n-1)h}{2^{k-1}}\cdot s} 2^{\frac{k-1}{2}} \mathscr {L}\left\{ \tilde{T}_m \left( 2^{k-1} x \right) \right\} .&\end{aligned}$$

By substituting Eq. (3) to the right-hand side of the above equation, we obtain

$$\begin{aligned} \mathscr {L}\{I_1\}&= e^{-\frac{(n-1)h}{2^{k-1}}\cdot s} 2^{\frac{k-1}{2}} \sqrt{2m+1} \mathscr {L}\left\{ 2^{m(k-1)} x^m \right\} . \end{aligned}$$

Since \(\mathscr {L}\{x^m\} = \frac{\Gamma (m+1)}{s^{m+1}}\), we have

$$\begin{aligned} \mathscr {L}\{I_1\}&= 2^{\left( m+\frac{1}{2}\right) (k-1)} \Gamma (m+1) \sqrt{2m+1} \cdot \frac{e^{-\frac{(n-1)h}{2^{k-1}}\cdot s}}{s^{m+1}}. \end{aligned}$$

Similarly, we also have

$$\begin{aligned} \mathscr {L}\{I_2\}&= \sum \limits _{l=0}^{m} \left( {\begin{array}{c}m\\ l\end{array}}\right) 2^{\left( l+\frac{1}{2}\right) (k-1)} \Gamma (l+1) \sqrt{2m+1} \cdot \frac{e^{-\frac{nh}{2^{k-1}}\cdot s}}{s^{l+1}}. \end{aligned}$$

Using Eq. (2), we have

$$\begin{aligned} I^{\alpha }\psi _{n,m}(x)=\frac{1}{\Gamma (\alpha )} x^{\alpha -1} * \psi _{n,m}(x). \end{aligned}$$

It is well-known that \(\mathscr {L}\{f(x) * g(x)\}= \mathscr {L}\{f(x)\} \cdot \mathscr {L}\{g(x)\}\). Therefore,

$$\begin{aligned}&\mathscr {L}\left\{ I^{\alpha }\psi _{n,m}(x) \right\} \\&\quad = \frac{1}{s^{\alpha }} \cdot \mathscr {L}\left\{ \psi _{n,m}(x) \right\} \\&\quad = \frac{1}{s^{\alpha }} \cdot \mathscr {L}\left\{ I_1 \right\} - \frac{1}{s^{\alpha }} \cdot \mathscr {L}\left\{ I_2 \right\} \\&\quad = 2^{\left( m+\frac{1}{2}\right) (k-1)} \Gamma (m+1) \sqrt{2m+1} \cdot \frac{e^{-\frac{(n-1)h}{2^{k-1}}\cdot s}}{s^{m+\alpha +1}} \\&\qquad - \sum \limits _{l=0}^{m} \left( {\begin{array}{c}m\\ l\end{array}}\right) 2^{\left( l+\frac{1}{2}\right) (k-1)} \Gamma (l+1) \sqrt{2m+1} \cdot \frac{e^{-\frac{nh}{2^{k-1}}\cdot s}}{s^{l+\alpha +1}}. \end{aligned}$$

By taking the inverse Laplace transformation, we get

$$\begin{aligned} I^{\alpha }\psi _{n,m}(x) =&\frac{2^{\left( m+\frac{1}{2}\right) (k-1)} \Gamma (m+1) \sqrt{2m+1}}{\Gamma (m+\alpha +1)} \\&\cdot \left( x-\frac{(n-1)h}{2^{k-1}}\right) ^{m+\alpha } \cdot \mu _{\frac{(n-1)h}{2^{k-1}}}(x)\\&- \sum \limits _{l=0}^{m} \left( {\begin{array}{c}m\\ l\end{array}}\right) \frac{2^{\left( l+\frac{1}{2}\right) (k-1)} \Gamma (l+1) \sqrt{2m+1}}{\Gamma (l+\alpha +1)} \\&\cdot \left( x-\frac{nh}{2^{k-1}}\right) ^{l+\alpha } \cdot \mu _{\frac{nh}{2^{k-1}}}(x) \end{aligned}.$$

The theorem then follows. \(\square \)

5 Numerical solutions of fractional delay differential equations

In this section, we present a new numerical method for solving the fractional delay differential equation given in Eq. (1).

We fix a positive integer k. The function \(D^{\alpha }y(x)\) can be expanded over [0, 1) as

$$\begin{aligned} D^{\alpha }y(x) \simeq \sum \limits _{m=0}^{M-1} \sum \limits _{n=1}^{2^{k-1}} {c_{n,m} \psi _{n,m}(x)} = C^{T}\Psi _{k,M}(x), \end{aligned}$$
(8)

where C and \(\Psi _{k,M}\) are given in Eqs. (5) and (6), respectively. By applying the integral operator \(I^{\alpha }\) to both sides of Eq. (8) and using item 3 in Proposition 2.3 with \(y^{(j)}(0)=\lambda _j\) for \(j=0,\ldots ,\lceil \alpha \rceil \), we obtain

$$\begin{aligned} y(x)&\simeq \left\{ \begin{aligned}&C^{T} I^{\alpha } \Psi _{k,M}(x) + \sum \limits _{j=0}^{\lceil \alpha \rceil } \frac{\lambda _j}{j!} x^j,&\text { if } x \in [0,1),\\&\phi (x),&\text { if } x<0. \end{aligned} \right. \end{aligned}$$
(9)

Therefore,

$$\begin{aligned} y(x-\tau ) \simeq \left\{ \begin{aligned}&C^{T} I^{\alpha } \Psi _{k,M}(x-\tau ) + \sum \limits _{j=0}^{\lceil \alpha \rceil } \frac{\lambda _j}{j!} (x-\tau )^j,&\text { if } x \in [\tau ,1),\\&\phi (x-\tau ),&\text { if } x<\tau . \end{aligned} \right. \end{aligned}$$
(10)

By substituting Eqs. (8), (9) and (10) to the given fractional delay differential equation in Eq. (1) and using Eq. (7), we obtain an algebraic equation. We collocate this algebraic equation at the following \(2^{k-1}M\) Newton–Cotes nodes

$$\begin{aligned} x_i=\frac{2i-1}{2^kM},\qquad i=1,\ldots ,2^{k-1}M, \end{aligned}$$

we then obtain a system of \(2^{k-1}M\) algebraic equations in the \(2^{k-1}M\) unknown constants \(c_{n,m}\). The last system can be solved using Newton’s iteration method. The initial guess for Newton’s iterative method can be obtained similarly to the method given in [34] as follows. To choose the initial guesses, in the first stage, we set \(k = 1\) and \(M = 1\) and then apply Newton’s iterative method for solving the given system of equations. In this stage, we obtain an approximation to our problem. Next, we increase the value of M until a satisfactory convergence is achieved. We then set \(k = 2\) and use the approximate solution in the first stage as our initial guess in this stage. We continue this approach until the results are similar up to a required number of decimal places for the same k and two consecutive M values.

6 Error estimation

In this section, we estimate the error bound for the best approximation based on Taylor wavelets.

Theorem 6.1

Let \(f \in L^2[0,1]\) such that f is M times differentiable. Let \(C^T \Psi _{k,M}\) be the best approximation of f in \({\mathcal {O}}_{k,M}\). Then,

$$\begin{aligned} \left| \left|\, f - C^T\Psi _{k,M}\right| \right| _2 \le \frac{2N}{M!\, 2^{M(k+1)}}, \end{aligned}$$
(11)

where \(N=\max \limits _{\xi \in [0,1]} \left|\, f^{(M)}(\xi )\right| \).

Proof

We divide the closed interval [0, 1] into \(2^{k-1}\) subintervals \(I_{n} =\left[ \frac{n-1}{2^{k-1}},\frac{n}{2^{k-1}}\right] \) with \(n=1,\ldots ,2^{k-1}\). By the definition of Taylor wavelets, for every \(n=1,\ldots ,2^{k-1}\), the function \(C^T\Psi _{k,M}\) is also the best approximation of f over the interval \(I_n\). We denote \(P_{n,M-1}(x)\) to be the interpolating polynomial of f at the Chebyshev nodes in the interval \(I_{n}\). Due to [35, Chp. 20], the interpolation error is

$$\begin{aligned} \left|\, f(x)-P_{n,M-1}(x)\right|&\le \frac{1}{2^{M-1} M!} \left( \frac{|I_{n}|}{2} \right) ^{M} \cdot \max \limits _{\xi \in I_n} \left|\, f^{(M)} (\xi )\right| \\&\le \frac{2N}{2^{M(k+1)} M!}. \end{aligned}$$

Let \(P_{M-1}\) be the function defined over [0, 1) such that \(P_{M-1}(x)=P_{n,M-1}(x)\) for every \(x \in \left[ \frac{n-1}{2^{k-1}}, \frac{n}{2^{k-1}} \right) \), \(n=1,\ldots ,2^{k-1}\). Then,

$$\begin{aligned} \left| f(x)-P_{M-1}(x)\right| \le \frac{2N}{2^{M(k+1)} M!}, \qquad \text { for every } x \in [0,1). \end{aligned}$$
(12)

Since \(C^T\Psi _{k,M}\) is the best approximation of f in \({\mathcal {O}}_{k,M}\) and that \(P_{M-1} \in {\mathcal {O}}_{k,M}\), we conclude from Eq. (12) that

$$\begin{aligned} \left|\, \left| f-C^T\Psi _{k,M}\right| \right| _2^2&\le \left| \left|\, f-P_{M-1}\right| \right| _2^2\\&= \int \limits _{0}^{1} (f(x)-P_{M-1}(x))^2\mathrm{d}x\\&\le \int \limits _{0}^{1} \left( \frac{2N}{2^{M(k+1)} M!} \right) ^2 \mathrm{d}x = \left( \frac{2N}{2^{M(k+1)} M!} \right) ^2. \end{aligned}$$

\(\square \)

Theorem 6.2

Let \(f \in L^2[0,1]\) such that f is M times differentiable. Let \(C^T \Psi _{k,M}\) be the best approximation of f in \({\mathcal {O}}_{k,M}\). Then,

$$\begin{aligned} \left| \left| I^{\alpha }f-I^{\alpha }C^T\Psi _{k,M}\right| \right| _2 \le \frac{2N}{\Gamma (\alpha ) \sqrt{2 \alpha (2\alpha -1)}\, 2^{M(k+1)} M!}, \end{aligned}$$

where \(N=\max \limits _{\xi \in [0,1]} \left| f^{(M)}(\xi )\right| \).

Proof

Using Eq. (2) and Hölder’s inequality, we can estimate the difference between \(I^{\alpha }f\) and \(I^{\alpha }C^T\Psi \) at \(x \in [0,1]\) as follows:

$$\begin{aligned}&\left| I^{\alpha }f(x)-I^{\alpha }C^T\Psi _{k,M}(x)\right| \\&\quad \le \frac{1}{\Gamma (\alpha )} \int \limits _0^x \frac{\left| f(s)-C^T\Psi _{k,M}(s) \right| }{(x-s)^{1-\alpha }} \mathrm{d}s\\&\quad \le \frac{1}{\Gamma (\alpha )} \left( \int \limits _0^x \frac{\mathrm{d}s}{(x-s)^{2-2\alpha }} \right) ^{\frac{1}{2}} \left( \int \limits _0^x (f(s)-C^T\Psi (s))^2 \mathrm{d}s \right) ^{\frac{1}{2}}\\&\quad \le \frac{x^{\alpha -\frac{1}{2}}}{\Gamma (\alpha ) \sqrt{2\alpha -1}} \left| \left| f-C^T\Psi _{k,M}\right| \right| _2. \end{aligned}$$

Finally, we apply Eq. (11) and obtain

$$\begin{aligned}&\left| \left| I^{\alpha }f-I^{\alpha }C^T\Psi _{k,M}\right| \right| _2\\&\quad \le \frac{1}{\Gamma (\alpha ) \sqrt{2\alpha -1}} \left| \left| x^{\alpha -\frac{1}{2}}\right| \right| _2 \cdot \left| \left| f-C^T\Psi _{k,M}\right| \right| _2\\&\quad = \frac{2N}{\Gamma (\alpha ) \sqrt{2 \alpha (2\alpha -1)}\, 2^{M(k+1)} M!}. \end{aligned}$$

\(\square \)

7 Illustrative examples

In this section, we compare the efficiency of our method with that of some previously known ones.

Example 7.1

Consider the following fractional delay differential equation (see [21, Example 1]):

$$\begin{aligned} D^{\alpha }y(x)= \,& {} y(x-\tau ) - y(x) + \frac{2x^{2-\alpha }}{\Gamma (3-\alpha )} - \frac{x^{1-\alpha }}{\Gamma (2-\alpha )} \nonumber \\&+\,2 \tau x-\tau ^2-\tau , \end{aligned}$$
(13)

where \(x \in [0,1]\), \(\alpha \in (0,1]\) and \(y(x)=x^2-x\) if \(x \le 0\).

We choose \(k=2\) and \(M=3\) and approximate \(D^{\alpha }y(x)\) as

$$\begin{aligned} D^{\alpha }y(x)\simeq\, & {} c_{1,0} \psi _{1,0}(x) + c_{1,1} \psi _{1,1}(x) + c_{1,2} \psi _{1,2}(x)\\&\,+\, c_{2,0} \psi _{2,0}(x) + c_{2,1} \psi _{2,1}(x) + c_{2,2} \psi _{2,2}(x)\\=\, & {} C^T \cdot \Psi _{2,2}(x), \end{aligned}$$

where \(C=\left[ c_{1,0},c_{1,1},c_{1,2},c_{2,0},c_{2,1},c_{2,2}\right] ^T\) is the vector of unknown constants that we need to determine. Then, we have

$$ y(x) = \left\{ {\begin{array}{*{20}l} {C^{T} I^{\alpha } \Psi _{{2,2}} (x),} \hfill & {{\text{if}}\;{\text{ }}x \in [0,1],} \hfill \\ {x^{2} - x,} \hfill & {{\text{if }}\;x \le 0,} \hfill \\ \end{array} } \right. $$
(14)

and

$$ (x - \tau ) = \left\{ {\begin{array}{*{20}l} {C^{T} I^{\alpha } \Psi _{{2,2}} (x - \tau ),} \hfill & {{\text{if }}\;x \in [\tau ,\tau + 1],} \hfill \\ {(x - \tau )^{2} - x + \tau ,} \hfill & {{\text{if }}\;x \le \tau .{\text{ }}} \hfill \\ \end{array} } \right. $$
(15)

In the above formulas, \(I^{\alpha }\Psi _{2,2}\) are determined explicitly by Theorem 4.1. By substituting Eqs. (14) and (15) to Eq. (13), we obtain an algebraic equation. By collocating the algebraic equation at Newton–Cotes nodes

$$\begin{aligned} x_i=\frac{2i-1}{12}, \qquad i=1,\ldots ,6, \end{aligned}$$

we get a linear system in the \(c_{n,m}\)’s.

In case there is no delay, i.e. \(\tau =0\), the linear system becomes

$$ \left\{ {\begin{array}{*{20}l} {36\sqrt 2 c_{{1,0}} + 6\sqrt 6 c_{{1,1}} + \sqrt {10} c_{{1,2}} } \hfill & { = - {\mkern 1mu} 30,} \hfill \\ {4\sqrt 2 c_{{1,0}} + 2\sqrt 6 c_{{1,1}} + \sqrt {10} c_{{1,2}} } \hfill & { = - {\mkern 1mu} 2,} \hfill \\ {36\sqrt 2 c_{{1,0}} + 30\sqrt 6 c_{{1,1}} + 25\sqrt {10} c_{{1,2}} } \hfill & { = - {\mkern 1mu} 6,} \hfill \\ {36\sqrt 2 c_{{2,0}} + 6\sqrt 6 c_{{2,1}} + \sqrt {10} c_{{2,2}} } \hfill & { = 6,} \hfill \\ {4\sqrt 2 c_{{2,0}} + 2\sqrt 6 c_{{2,1}} + \sqrt {10} c_{{2,1}} } \hfill & { = 2,} \hfill \\ {36\sqrt 2 c_{{2,0}} + 30\sqrt 6 c_{{2,1}} + 25\sqrt {10} c_{{2,2}} } \hfill & { = 30.} \hfill \\ \end{array} } \right. $$

This system admits the unique solution:

$$\begin{aligned} \begin{array}{lll} c_{1,0}=-\frac{1}{\sqrt{2}}, &{} c_{1,1}=\frac{1}{\sqrt{6}}, &{} c_{1,2}=0,\\ c_{2,0}=0, &{} c_{2,1}=\frac{1}{\sqrt{6}}, &{} c_{2,2}=0. \end{array} \end{aligned}$$

By substituting this solution to Eq. (14), we obtain \(y(x)=x^2-x\), which is the exact solution of the given delay differential equation. It is noted that the exact solution was not obtained in [21].

In case there is delay, we obtain approximations of the solutions depending on \(\alpha \) and \(\tau \). In Table 1, we demonstrate the absolute errors for our method by selecting \(k=2\) and \(M=3\) or with the number of bases \({\hat{m}}=2^{k-1}M=6\); by the Bernoulli wavelet method in [21] by selecting \(k=2\) and \(M_1=3\) or with the same number of bases. The values in Table 1 suggest that numerical solutions produced from our method have less absolute errors than numerical solutions from the Bernoulli wavelet method in [21]. In Table 1, \(M_1\) is the degree of Bernoulli polynomials. Figure 1 shows the graphs of the exact solution and our approximate solution when \(\alpha =1\) and the delay \(\tau =0.01\).

Table 1 The absolute errors for numerical solutions of Example 7.1 when \(\alpha =1\) from our method and the Bernoulli wavelet method in [21]
Fig. 1
figure 1

The left-hand side is the graph of the exact solution (line) and the approximation solution (dashed) for Example 7.1 from our method when \(k=2,M=3\), \(\alpha =1,\) and \(\tau =0.01\). The right-hand side is the graph of the absolute error function

Example 7.2

Consider the following fractional-order delay differential equation (see [21, Example 2]):

$$ \left\{ {\begin{array}{*{20}l} {D^{\alpha } y(x) = - y(x) - y(x - 0.3) + e^{{ - x + 0.3}} ,} \hfill & {x \in [0,1],{\mkern 1mu} \alpha \in (2,3],} \hfill \\ {y(0) = 1,{\mkern 1mu} y^{\prime}(0) = - 1,{\mkern 1mu} y^{\prime\prime}(0) = 1,} \hfill & {} \hfill \\ {y(x) = e^{{ - x}} ,} \hfill & {x < 0.} \hfill \\ \end{array} } \right. $$

This problem admits the exact solution \(y(x)=e^{-x}\) when \(\alpha =3\). In Table 2, we show some values of the exact solution and the numerical solutions obtained by applying our method by choosing \(k=2,M=7\) or with the number of bases \({\hat{m}}=14\); by Bernoulli wavelet method in [21] by selecting \(k=2,M_1=7\) or with the same number of bases; by Hermit wavelet method in [36] by selecting \(k=1,M_2=25\) or with the number of bases \({\hat{m}}=2^{k-1}M_2=25\). In this table, \(M_2\) is the degree of the Hermit polynomials. Figure 2 represents the graph of the absolute error function of the numerical solution obtained from our method when \(\alpha =3, \, k=2,\) and \(M=7.\) In addition, Fig. 3 shows the graphs of the exact solution and the numerical solutions for different order \(\alpha \). The graphical detail of Fig. 3 suggests that the numerical solutions approach the exact solution when the order \(\alpha \) tends to 3.

Table 2 The exact solution for Example 7.2 with \(\alpha =3\) and numerical solutions obtained from our method, Hermit wavelet method in [36], and Bernoulli wavelet method in [21]
Fig. 2
figure 2

The left-hand side is the graph of the exact solution (line) and the numerical solution (dashed) for Example 7.2 from our method. The right-hand side is the graph of the absolute error function. Here, we choose \(k=2,\,M=7,\) and \(\alpha =3\)

Fig. 3
figure 3

The graphs of the exact solutions and the numerical solutions for Example 7.2 when \(k=2,\, M=4,\) and \(\alpha =2.7,\,2.8,\,2.9\)

Example 7.3

Consider the following fractional-order delay differential equation (see [37, Example 6]):

$$ \left\{ {\begin{array}{*{20}l} {D^{\alpha } y(x) = y(x - 1) + u(x),} \hfill & {x \in (0,2],} \hfill \\ {y(x) = 1,} \hfill & {x \le 0,} \hfill \\ \end{array} } \right. $$
(16)

where \(\alpha \in (0,1]\) and the function u(x) is defined by

$$\begin{aligned} u(x)= \left\{ \begin{aligned}&-2.1+1.05x,&x \in (0,1],\\&-1.05,&{ x \in (1,2].} \end{aligned} \right. \end{aligned}$$

In case \(\alpha =1\), this problem admits the exact solution

$$\begin{aligned} y(x)= \left\{ \begin{aligned}&1-1.1x+0.525x^2,&x \in (0,1],\\&-\,0.25+1.575x-1.075x^2+0.175x^3,&x \in (1,2]. \end{aligned} \right. \end{aligned}$$

To apply our method, we make a transformation of unknown functions \(g(x)=y(2x)\), and set \(t=\frac{x}{2}\) with \(t \in (0,1]\). We then have

$$\begin{aligned} y(x)=g\left( \frac{x}{2}\right) =g(t), \end{aligned}$$
(17)
$$\begin{aligned} y(x-1)=g\left( \frac{x-1}{2}\right) =g\left( t-\frac{1}{2}\right) , \end{aligned}$$
(18)

and

$$\begin{aligned} D^{\alpha }y(x)=2^{-\alpha } D^{\alpha }g\left( \frac{x}{2}\right) =2^{-\alpha } D^{\alpha }g(t). \end{aligned}$$
(19)

By substituting Eqs. (17)–(19) to (16), the given differential equation is transformed to the following equivalent one:

$$ \left\{ {\begin{array}{*{20}l} {2^{{ - \alpha }} D^{\alpha } g(t) = g\left( {t - \frac{1}{2}} \right) + u(2t),} \hfill & {t \in (0,1],} \hfill \\ {g(t) = 1,} \hfill & {t \le 0,} \hfill \\ \end{array} } \right. $$

where \(\alpha \in (0,1]\). In case \(\alpha =1\), by applying our method, we obtain the exact solution.

In case \(\alpha \ne 1\), the exact solution is not known. In this case, to show the efficiency of the present method, we consider the residual error

$$\begin{aligned} D^{\alpha }y(x)-y(x-1)-u(x)=\,\, & {} 2^{-\alpha } D^{\alpha }g(t)\\&-g \left( t-\frac{1}{2}\right) -u(2t). \end{aligned}$$

In Table 3, we compare the residual errors of numerical solutions obtained from our method and Legendre multiwavelet collocation method in [37] with \(\alpha =0.95\). For computing the numerical solution by applying our method, we select \(k=2\) with \(M=7\) or with the number of bases \({\hat{m}}=14\) and by selecting \(k=2\) with \(M=10\) or with the number of bases \({\hat{m}}=20\); together with the Legendre multiwavelet collocation method in [37] using \(k=2\) with \(M_3=7\) and \(k=2\) with \(M_3=10\) (hence with the same number of bases). In this table, \(M_3\) stand for the degrees of the Legendre wavelets. The left-hand side of Fig. 4 demonstrates the graph of the exact solution with \(\alpha =1\) and the numerical solution from our method with \(k=2\) and \(M=3\), while the right-hand side is the graph of the absolute error function. Figure 5 represents the graphs of different numerical solutions with different values of \(\alpha \) with \(k=2\) and \(M=3\). From Fig. 5, we see that as \(\alpha \) approaches to 1, the numerical solutions approach to the exact solution of the given differential equation with the integer order.

Table 3 The residue errors for numerical solutions of Example 7.3 from our method and the Legendre multiwavelet collocation method in [37] when \(\alpha = 0.95\)
Fig. 4
figure 4

The graphs on the left-hand side are of the numerical solution for Example 7.3 obtained from our computation (dashed) and the exact solution when \(k=2\) and \(M=3\). The graph of the absolute error is showed on the right-hand side

Fig. 5
figure 5

The graphs of the numerical solutions for Example 7.3 obtained from our computation for \(k=2\) and \(M=3\) and different values of \(\alpha \)

8 Conclusion

In this paper, we propose an exact formula for the Riemann–Liouville fractional integral of a Taylor wavelet. A new numerical method for delay fractional differential equations is presented. Using the exact formula and collocation method, we reduce the problem of computing a numerical solution of a delay fractional differential equation to the problem of solving an algebraic system. Several examples are demonstrated to show the applicability and the efficiency of the present method.