1 Introduction

OFDEs play a role in many branches and applications. These applications can be found in risk theory [1], physics [2], biological phenomena, and diseases [36]. Also, the applications of FIDEs have been presented for electromagnetic [7], microelectronics [8], and hematopoietic stem cell modeling [9]. Moreover, many models have been constructed using FOCPs [10, 11]. For that reason, the importance of fractional calculus has emerged.

Most of these problems and models have no exact solutions. Consequently, the researchers focus on investigating and developing new numerical methods. For OFDEs, in [12] the authors presented a spectral method using shifted Chebyshev polynomials (SCHPs) of the second kind. While in [13], the same authors used the same technique but with the sixth kind of SCHPs. A different technique by using a nonpolynomial spline function was employed in [14, 15]. The second kind Wright function with Erdélyi–Kober fractional derivatives was used in [16]. Similar techniques were used for approximating FIDEs. Alternative Legendre functions in [17] were used to set up an operational matrix by the collocation method. In [9], the authors used smoothed pseudo-splines refinable functions to construct Riesz wavelets. And as a direct development of the mentioned methods and algorithms, several methods have been formulated to approximate FOCPs. For details about those methods, refer to [10, 18, 19].

The spirit in using the spectral method is the choice of the basis function [20, 21]. The smoothness properties of the basis functions control the decay rate of the coefficients of expansion. The boundary conditions have no effect on the rate. Unlike the other orthogonal polynomials, ultraspherical polynomials (UPs) are not nearly as popular in use as basis functions [2224]. However, UPs motivate our interest because they include Chebyshev and Legendre polynomials and some other polynomials as subclasses of them [25].

The importance of the Galerkin method (GM) is that, for the presented technique, it can be used for the solution of a wide class of ordinary fractional problems (OFPs). Throughout this work, OFPs are OFDEs, FIDEs, or OCFPs. One of the advantages of GM is that it is not a difficult method. On the other hand, every equation has its own algorithm. The presented technique is a mix of two well-known spectral methods: collocation method [2628] and Galerkin method [2931]. We call that method pseudo-Galerkin method (pseudo-GM).

The work is coordinated as follows: in Sect. 2, we introduce Caputo’s fractional derivative. Then, UPs (SUPs) and some of their properties are presented. Finally, the notion of integration matrix (B-matrix) is presented. In Sect. 3, the main results of the paper are stated and proved. Those results give formulae that assert the derivatives of SUPs and the spectral expansion. In Sect. 4, the approximate of OFPs is stated by employing shifted ultraspherical pseudo-GM (SU-pseudo-GM). Then, the error analysis and upper bound for the expansion are estimated in Sect. 5. The correctness and effectiveness of SU-pseudo-GM are proved by different types of OFPs in Sect. 6. The last section “7” contains the conclusion and remarks.

2 Preliminaries and notations

This section presents some core definitions and concepts needed throughout this paper. We shall begin with the well-known Caputo fractional derivative for the function \(\phi (x)\) of order δ denoted by \(D^{\delta } ( \phi (x) )\):

$$ D^{\delta } \bigl( \phi (x) \bigr)=\frac{1}{\Gamma (r-\delta )} \int _{0}^{x} ( x-s )^{r-\delta -1} \frac{d^{r} \phi (s) }{ds^{r}} \,ds, $$
(1)

where \(r-1\le \delta < r\), \(r\in \mathbb{N}\).

As a direct result of Eq. (1), we have

$$ D^{\delta }x^{t}= \textstyle\begin{cases} 0, &t\in \mathbb{N} \cup \lbrace 0 \rbrace \text{ and } t < \lceil \delta \rceil, \\ \frac{\Gamma (t+1)}{\Gamma (t+1-\delta )} x^{t-\delta },&t\in \mathbb{N} \cup \lbrace 0 \rbrace \text{ and } t \ge \lceil \delta \rceil \text{ or } t\notin \mathbb{N} \text{ and } t > \lfloor \delta \rfloor. \end{cases} $$
(2)

Besides, one of the advantages of Caputo’s fractional derivative is the linearity property. For any two arbitrary constants \(C_{1}\) and \(C_{2}\),

$$ D^{\delta } \bigl(C_{1} \phi _{1}(x) + C_{2} \phi _{2}(x) \bigr)=C_{1}D^{\delta } \bigl( \phi _{1}(x) \bigr)+C_{2}D^{\delta } \bigl(\phi _{2}(x) \bigr). $$

For more details about fraction derivatives, refer to the review [32].

Proceeding with the fundamental concepts, some properties of UPs \((\mathcal{U}_{j}^{\nu }(x) )\) and SUPs \((\mathcal{U}_{j}^{*\nu }(x) )\), of degree j and real parameter \(\nu >-\frac{1}{2}\), will be presented. UPs are the special case of Jacobi polynomials with analytic form [25]:

$$ \mathcal{U}^{\nu }_{j}(x)=\sum _{r=0}^{\lfloor j/2 \rfloor } (-1)^{r} \frac{\Gamma (j-r+\nu )}{\Gamma (\nu )\Gamma (r+1)\Gamma (j-2r+1)}(2x)^{j-2r},\quad x \in [-1,1 ], j=0,1,2,\ldots $$
(3)

As special cases: \(L_{j}(x)=\mathcal{U}^{0.5}_{j}(x)\) and \(\mathcal{T}_{j}(x)=\frac{j}{2} \lim_{\nu \rightarrow 0} \frac{\mathcal{U}^{\nu }_{j}(x)}{\nu }, j \ge 1\), where \(L_{j}(x)\) and \(\mathcal{T}_{j}(x)\) are Legendre and Chebyshev polynomials, respectively.

Also, UPs can be generated from Rodrigueś formula [33]

$$ \mathcal{U}^{\nu }_{j}(x)=\frac{1}{(-2)^{j}(j!)} \frac{\Gamma ( \nu +\frac{1}{2} ) \Gamma (j+2\nu )}{\Gamma (2\nu )\Gamma ( j+\nu +\frac{1}{2} ) }\bigl(1-x^{2}\bigr)^{ \frac{1}{2}-\nu } \frac{d^{j}}{dx^{j}} \bigl(1-x^{2}\bigr)^{j+\nu -\frac{1}{2}}, $$
(4)

while SUPs, defined on the interval \([0,1 ]\), can be obtained from [34]

$$\begin{aligned} \mathcal{U}_{j}^{*\nu }(x)= \frac{ 2(\nu +j-1)(2x-1)\mathcal{U}_{j-1}^{(*\nu )}(x)-(2\nu +j-2)\mathcal{U}_{j-2}^{*\nu }(x)}{j} ,\quad j=2,3,\ldots, \end{aligned}$$
(5)

where \(\mathcal{U}_{0}^{*\nu }(x)=1\) and \(\mathcal{U}_{1}^{*\nu }(x)=2\nu ( 2 x-1 ) \).

Or in terms of its derivatives [35]

$$ \mathcal{U}_{j}^{*\nu }(x)=\frac{1}{2(j+\nu )} \biggl[ \frac{2 \nu +j}{j+1}D \mathcal{U}_{j+1}^{*\nu }(x)- \frac{j}{2 \nu +j-1}D \mathcal{U}_{j-1}^{*\nu }(x) \biggr],\quad j=2,3, \ldots $$
(6)

SUPs at the boundaries are as follows:

$$ \mathcal{U}_{j}^{*\nu }(0)=(-1)^{j} \frac{\Gamma (j+2\nu )}{\Gamma (j+1)\Gamma (2\nu )},\qquad \mathcal{U}_{j}^{*\nu }(1)= \frac{\Gamma (j+2\nu )}{\Gamma (j+1)\Gamma (2\nu )},\quad j=0,1,2, \ldots $$

The set \(\lbrace \mathcal{U}_{j}^{*\nu }(x) \rbrace _{j} \) forms an orthogonal set w.r.t. the weight function \(w^{\nu }(x)= (x-x^{2} )^{\nu -\frac{1}{2}}\):

$$ \int _{0}^{1}w^{\nu }(x) \mathcal{U}^{*\nu }_{r}(x) \mathcal{U}^{* \nu }_{s}(x) \,dx=\textstyle\begin{cases} 0,& r\ne s, \\ \psi _{r}^{\nu },& r=s, \end{cases} $$

where \(\psi _{r}= \frac{\pi 2^{1-4\nu }\Gamma (r+2\nu )}{(r+\nu ) \Gamma (r+1) ( \Gamma (\nu ) ) ^{2}}\).

Finally, the expression B-matrix will be presented. This matrix will be used for solving FIDEs and FOCPs. According to the spectral method, let \(\phi (x)\) be a differential function over the interval \([0,1]\). Then \(\phi (x)\) can be approximated using \(M+1\) points as follows [36]:

$$ \phi (x)=\sum_{m=0}^{M} c_{m}\mathcal{B}_{m} \mathcal{T}^{*}_{m}(x), $$
(7)

where

$$ \mathcal{B}_{m}=\frac{2}{M}\sum _{r=0}^{M} c_{r} \phi (x_{r} ) \mathcal{T}^{*}_{m} ( x_{r} ) $$
(8)

such that: \(\mathcal{T}^{*}_{m}(x)\) is the SCHP of degree m, \(c_{0}=c_{M}=0.5\) and \(c_{m}=1\) for \(m=1,2,\ldots,M-1\), \(x_{r}=0.5* (1-\cos \frac{r \pi }{M} ) \) are the shifted Chebyshev points (SCH-points).

From Eq. (7) and Eq. (8), we get

$$ \phi (x)=\sum_{r=0}^{M} \frac{2c_{r}}{M} \sum_{m=0}^{M} c_{m} \mathcal{T}^{*}_{m} ( x_{r} ) \mathcal{T}^{*}_{m}(x)\phi (x_{r} ). $$
(9)

According to El-Gendi [37], from Eq. (9),

$$ \int _{0}^{x_{s}}\phi (x) \,dx=\sum _{r=0}^{M}b_{sr}\phi (x_{r} ),\quad s=0,1,\ldots,M, $$
(10)

where

$$ b_{sr}=\frac{2c_{r}}{M} \sum _{m=0}^{M} c_{m} \mathcal{T}^{*}_{m} ( x_{r} ) \int _{0}^{x_{s}}\mathcal{T}^{*}_{m}(x) \,dx,\quad s,r=0,1,\ldots,M $$
(11)

are the elements of the B-matrix. Equation (10) and Eq. (11) can be written in the matrix form:

$$ \biggl[ \int _{0}^{x}\phi (x) \,dx \biggr] =B\Phi $$

such that

$$B= \begin{bmatrix} 0 & 0 & \cdots & 0 \\ b_{10} & b_{11} & \cdots & b_{1M} \\ \vdots & \vdots & \cdots & \vdots \\ b_{M0} & b_{M1} & \cdots & b_{MM} \end{bmatrix} \quad \text{and}\quad \Phi = \begin{bmatrix} \phi (x_{0} ) \\ \phi (x_{1} ) \\ \vdots \\ \phi (x_{M} ) \end{bmatrix} . $$

In the next section, some important theorems and lemmas are investigated. These theorems are needed in the process of SU-pseudo-GM. As mentioned before, this method is used to solve several types of fractional problems.

3 Shifted ultraspherical pseudo-Galerkin method (SU-pseudo-GM)

The first step, some rules and forms of UPs need to be shifted. Rodrigueś (Eq. (4)) formula is generalized in the shifted form

$$ \mathcal{U}^{*\nu }_{j}(x)=(-1)^{j} \frac{\Gamma ( \nu +\frac{1}{2} ) \Gamma (j+2\nu )}{\Gamma (j+1)\Gamma (2\nu )\Gamma ( j+\nu +\frac{1}{2} ) }\bigl(x-x^{2}\bigr)^{ \frac{1}{2}-\nu } \frac{d^{j}}{dx^{j}} \bigl(x-x^{2}\bigr)^{j+\nu -\frac{1}{2}}. $$
(12)

Thus, SUPs can be obtained from Eq. (5) or Eq. (12). The next lemma will be used to introduce a general form for the fractional derivative and the integer order integration of SUPs.

Lemma 1

The analytic form of SUPs is as follows:

$$ \mathcal{U}^{*\nu }_{j}(x)=\sum _{r=0}^{\lfloor j/2 \rfloor } \sum_{k=0}^{j-2r} \frac{(-1)^{j-r-k} 2^{j-2r+k} \Gamma (j-r+\nu )}{\Gamma (\nu )\Gamma (r+1)\Gamma (k+1)\Gamma (j-2r-k+1)}x^{k},\quad j=0,1, 2,\ldots $$

Proof

Straightforward using Eq. (3) and the binomial theorem. □

The following corollary proves the fractional derivatives of SUPs in the Caputo sense.

Corollary 2

The fractional derivatives of SUPs in the Caputo sense of order δ are as follows:

$$ D^{\delta } \bigl(\mathcal{U}^{*\nu }_{j}(x) \bigr) = \textstyle\begin{cases} 0, &j=0,1,\dots,\lceil \delta \rceil -1, \\ \sum_{r=0}^{\lfloor (j-\delta )/2 \rfloor } \sum_{k= \lceil \delta \rceil }^{j-2r} G_{rk},&j=\lceil \delta \rceil,\lceil \delta \rceil +1,\dots, \end{cases} $$

where \(G_{rk}=(-1)^{j-r-k} \frac{2^{j-2r+k} \Gamma (j-r+\nu )}{\Gamma (\nu )\Gamma (r+1)\Gamma (k-\delta +1)\Gamma (j-2r-k+1)}x^{k- \delta }\).

Proof

Using Lemma 1 and the results from Eq. (2). □

The next theorem will establish the general form of the SUPs approximation of a function \(\phi (x)\). This form is used in SU-pseudo-GM.

Theorem 3

Consider \(\phi (x)\) to be an “\(s+1\)” differentiable function. Then \(\phi (x)\) can be approximated as

$$ \phi (x)=\sum_{m=0}^{\infty } \theta _{m} \mathcal{A}_{m} \mathcal{U}^{*\nu }_{m}(x), $$
(13)

where \(\lbrace \mathcal{A}_{m} \rbrace \) are unknown constants to be determined later and

$$ \theta _{m} = \textstyle\begin{cases} 4 \nu, &m=0, \\ 2 \nu +1,&m=1, \\ 1,&2 \le m. \end{cases} $$
(14)

Proof

Let \(\phi (x)\) be approximated as follows:

$$ \phi (x)=\sum_{m=0}^{\infty } \mathcal{A}_{m} \mathcal{U}^{*\nu }_{m}(x). $$

So, by the assumption in the theorem,

$$ \phi ^{(s)}(x)=\sum_{m=0}^{\infty } \mathcal{A}_{m}^{(s)} \mathcal{U}^{*\nu }_{m}(x) $$
(15)

and

$$\begin{aligned} \phi ^{(s+1)}(x)&=\sum_{m=0}^{\infty } \mathcal{A}_{m}^{(s+1)} \mathcal{U}^{*\nu }_{m}(x) \\ &= \mathcal{A}_{0}^{(s+1)}\mathcal{U}^{*\nu }_{0}(x)+ \mathcal{A}_{1}^{(s+1)} \mathcal{U}^{*\nu }_{1}(x)+ \sum_{m=2}^{\infty } \mathcal{A}_{m}^{(s+1)} \mathcal{U}^{*\nu }_{m}(x). \end{aligned}$$

Substituting by \(\mathcal{U}^{*\nu }_{0}(x)\) and \(\mathcal{U}^{*\nu }_{1}(x)\) and using Eq. (6), we obtain

$$\begin{aligned} \phi ^{(s+1)}(x) ={}&\mathcal{A}_{0}^{(s+1)}+ \mathcal{A}_{1}^{(s+1)} 2\nu (2x-1)-\mathcal{A}_{0}^{(s+1)}4 \nu \\ &{}- \mathcal{A}_{1}^{(s+1)} 2\nu (2\nu +1) (2x-1) \\ &{}+\sum_{m=1}^{\infty } \biggl( \mathcal{A}_{m-1}^{(s+1)} \frac{2 \nu +m-1}{2(m+\nu -1)m} \\ &{}- \mathcal{A}_{m+1}^{(s+1)}\frac{m+1}{2(m+\nu +1) (\nu +m)} \biggr)D \mathcal{U}_{m}^{(*\nu )}(x). \end{aligned}$$
(16)

By differentiating Eq. (15) w.r.t. x, we have

$$ \phi ^{(s+1)}(x)=\sum_{m=1}^{\infty } \mathcal{A}_{m}^{(s)} D \mathcal{U}^{*\nu }_{m}(x) $$
(17)

Both of the equations (16) and (17) represent the \(s+1\) derivative of \(\phi (x)\). Thus the following equation must be satisfied:

$$ \mathcal{A}_{m}^{(s)}=\mathcal{A}_{m-1}^{(s+1)} \frac{2 \nu +m-1}{2(m+\nu -1)m}-\mathcal{A}_{m+1}^{(s+1)} \frac{m+1}{2(m+\nu +1) (\nu +m)}, $$

and choose a set of constants \(\lbrace \theta _{m} \rbrace \) as defended in (14). □

4 SU-pseudo-GM for solving OFPs

This section is divided into three subsections. Each section concerns solving a different type of OFP. Also, an algorithm for each problem has been added “Algorithm 1, Algorithm 2, and Algorithm 3”.

Algorithm 1
figure a

Algorithm steps for solving OFDE

Algorithm 2
figure b

Algorithm steps for solving FIDE

Algorithm 3
figure c

Algorithm steps for solving FOCP

Before proceeding to the techniques of the solution, the “M+1” collection points must be chosen. Throughout this paper three spaces of points are used. The set of equally spaced points “\(S_{1}\)”:

$$ S_{1}= \biggl\lbrace x_{m}= \frac{m}{M}, m=0,1,\ldots,M \biggr\rbrace , $$
(18)

while the second is Gauss quadrate points “\(S_{2}\)”, i.e., the zeros of SUPs:

$$ S_{2}= \bigl\lbrace x, \mathcal{U}^{*\nu }_{M+1}(x)=0 \bigr\rbrace . $$
(19)

The last set is the SCH-points “\(S_{3}\)”:

$$ S_{3}= \biggl\lbrace x_{m}=0.5 \biggl(1- \cos \frac{m \pi }{M} \biggr), m=0,1,\ldots,M \biggr\rbrace . $$
(20)

\(S_{3}\)” is used specially for solving FIDEs.

4.1 Solving OFDEs by SU-pseudo-GM

Consider OFDEs as follows:

$$ F \bigl( \eta _{0}(x), \eta _{1}(x),\ldots, \eta _{k}(x),\phi (x),D^{ \delta _{1}}\phi (x),\ldots,D^{\delta _{r}} \phi (x) \bigr)=0,\quad x\in [0,1], $$
(21)

such that

$$ \textstyle\begin{cases} \phi ^{j}(0)=d_{j}, \\ \phi ^{q}(1)=h_{q}, \end{cases}\displaystyle \quad j,q=0, \dots ,r-1, $$
(22)

where \(r,k\in \mathbb{Z}^{+}\), \(\lbrace \delta _{i} \rbrace _{1}^{r} \in \mathbb{R}^{+}\), \(\lbrace \eta _{i}(x) \rbrace _{0}^{k}\) are functions of x, the values of \(d_{j}(i=0, \dots,r-1)\) and \(h_{q}(q=0, \dots,r-1)\) describe the boundary or the initial state of \(\phi (x)\). The linearity and the nonlinearity of OFDE (21) depend on the function F.

Now, by using SUPs as the base function in the spectral approximation of \(\phi (x)\) as in Eq. (13), we have

$$ \phi (x)=\sum_{m=0}^{M} \theta _{m} \mathcal{A}_{m} \mathcal{U}^{* \nu }_{m}(x). $$
(23)

Using the straightforward differentiation in the sense of Corollary 2 leads to

$$ D^{\delta _{i}}\phi (x)=\phi ^{(\delta _{i})}(x)=\sum _{m=0}^{M} \theta _{m} \mathcal{A}_{m} D^{\delta _{i}}\mathcal{U}^{*\nu }_{m}(x). $$
(24)

Also, the initial and boundary conditions (22) have series expansion of the form

$$ \textstyle\begin{cases} \sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} D^{j} \mathcal{U}^{*\nu }_{m}(0)=d_{j}, \\ \sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} D^{q} \mathcal{U}^{*\nu }_{m}(0)=h_{q}, \end{cases}\displaystyle \quad j,q=0,\dots,r-1. $$
(25)

Substitute from Eqs. (23) and (24) into (21) by choosing \(S_{1}\) or \(S_{2}\) as nodes to get a system of linear/nonlinear algebraic equations together with Eq. (25). The unknowns of this system are \(\lbrace \mathcal{A}_{m} \rbrace _{0}^{M}\). The system can be easily solved by any method.

4.2 Solving FIDEs by SU-pseudo-GM

Herein, the SU-pseudo-GM for solving OFDEs is extended to some types of FIDEs. Consider the following FIDE:

$$ D^{\delta }\phi (x)=u(x)+ \int _{0}^{x}k(x,t) F \bigl( \phi (t) \bigr) \,dt,\quad x \in [0,1], $$
(26)

under a sufficient number of initial conditions according to δ. By applying the expansion described at Eq. (23), we obtain

$$ \sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} D^{\delta } \mathcal{U}^{*\nu }_{m}(x_{s})=u(x_{s})+ \int _{0}^{x_{s}}k(x_{s},t) F \Biggl( \sum _{m=0}^{M}\theta _{m} \mathcal{A}_{m} \mathcal{U}^{* \nu }_{m}(t) \Biggr) \,dt, $$
(27)

where \(s=0,1,\ldots,M\). Replacing the integration in Eq. (27) by the B-matrix (10) gives

$$ \sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} D^{\delta } \mathcal{U}^{*\nu }_{m}(x_{s})=u(x_{s})+ \sum_{r=0}^{M}b_{sr}k(x_{s},t_{r}) F \Biggl( \sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} \mathcal{U}^{*\nu }_{m}(t_{r}) \Biggr). $$
(28)

As in the previous section, the obtained Eq. (28) is an algebraic system. The linearity of that system depends on the linearity of the function F.

4.3 Solving FOCPs by SU-pseudo-GM

Finally, we proceed to approximating the FOCP that takes the form

$$ \text{max(min)}\quad \mathcal{J}(u)= \int _{0}^{1}F \bigl(x,\phi (x),u(x) \bigr) \,dx $$
(29)

under the conditions

$$\begin{aligned} & D^{\delta }\phi (x)=G\bigl( \bigl(x,\phi (x),u(x) \bigr) \bigr) \end{aligned}$$
(30)
$$\begin{aligned} &\phi (0)=c_{1},\qquad \phi '(0)=c_{2}, \end{aligned}$$
(31)

where \(c_{1},c_{2} \in \mathbb{R}\). By taking both techniques that are included in the last two subsections, the FOCP is transformed into a regular optimization problem.

5 Error analysis

The convergence and the error analysis for using SUPs are inevitable. Theorems and concepts for these aspects are investigated in [34, 35].

Lemma 4

Let \(\phi (x) \in L^{2}_{w^{\nu }}[0,1]\), \(\vert \phi ''(x) \vert \le B\), and it can be expanded according to expansion (13). Then

$$ \vert \mathcal{A}_{m} \vert < \frac{4 B (1+\nu )^{2}(m+1+\nu )^{2} }{(m-2)^{4}},\quad m \geq 3, $$

where \(0< \nu <1\).

Proof

For the proof, see [38]. □

Theorem 5

Let \(\phi _{M}(x)=\sum_{m=0}^{M}\theta _{m} \mathcal{A}_{m} \mathcal{U}^{*\nu }_{m}(x)\) and \(\phi (x)\), ν satisfies Lemma 4. Then

$$ \Vert \phi -\phi _{M} \Vert < \frac{B (1+\nu )^{2}(M+\nu ) }{(M-3)^{7/2}},\quad m \geq 3. $$

Proof

See [38]. □

The next section proves the effectiveness and correctness of SU-pseudo-GM by solving different types of OFPs.

6 Numerical examples

In this section, numerical examples of SU-pseudo-GM are presented. The results to those obtained are compared with other methods and the exact solution.

Example 1

Consider the linear OFDE

$$ D^{2.5}\phi (x)-3 D^{2/3} \phi (x)=u(x), $$

subject to \(\phi (0)=1\), \(\phi '(0)=c\), and \(\phi ''(0)=c^{2}\) with the exact solution \(\phi (x)=e^{c x}\) and \(u(x)= \frac{c^{2/3} e^{c x} [3 \Gamma (1/3,c x ) + ( c^{11/6} erf ( \sqrt{c x} )-3 ) \Gamma (1/3 ) ] }{\Gamma (1/3 )}\).

According to Sect. 4.1, the maximum absolute error (MAE) for SU-pseudo-GM and MAE for others are presented in Table 1 and Table 2. These tables show the demonstration of SU-pseudo-GM over the methods in [39] and [40] for all values of c and the parameter ν for the two spaces \(S_{1}\) and \(S_{2}\) at different values of M, while Fig. 1 represents the convergence at an exponential rate using \(S_{3}\).

Figure 1
figure 1

The LogError for Example 1 using \(S_{3}\)

Table 1 The MAE for Example 1
Table 2 The best MAE for Example 1

Example 2

Consider the nonlinear OFDE

$$ D^{\delta }\phi (x)+x \bigl( \phi (x) \bigr) ^{2}=x^{6}+ \frac{\Gamma (3.5)}{\Gamma (3.5-\delta )}x^{2.5-\delta }, $$

subject to \(\phi (0)=0\) with the exact solution \(\phi (x)=x^{2.5}\).

Applying the technique discussed in Sect. 4.1, we obtained the pointwise absolute error (PW-AE) shown in Table 3 for \(\delta =0.5\) and Table 4 for \(\delta =0.7\). Comparisons between SU-pseudo-GM “at different values of ν”, the neural network method (NNM) in [41], the differentiated radial basis function method (DRBF) in [42], and the integrated radial basis function method (IRBF) in [42] have been done. From both tables we recognize that:

Table 3 The PW-AE for Example 2 at \(M=10\) and \(\delta =0.5\)
Table 4 The pointwise AE for Example 2 at \(M=10\) and \(\delta =0.7\)
  • SU-pseudo-GM is more accurate and efficient than NNM in [41] for the presented values of the parameter ν, \(\delta =0.5,0.7\) and both spaces \(S_{1}\) and \(S_{2}\).

  • Using the equidistance space \(S_{1}\), SU-pseudo-GM is of almost the same accuracy as DRBF and IRBF methods in [42] for the presented values of the parameter ν and \(\delta =0.5,0.7\).

  • For \(\delta =0.5\), SU-pseudo-GM got the same accuracy as DRBF and IRBF methods in [42] at \(\nu =0.49\) using the \(S_{2}\) space.

  • For \(\delta =0.5\), SU-pseudo-GM is more accurate than DRBF and IRBF methods in [42] for \(\nu =1\) and \(\nu =-0.49\) using the \(S_{2}\) space.

  • For \(\delta =0.7\), SU-pseudo-GM is more accurate and efficient than DRBF and IRBF methods in [42] for the presented values of the parameter ν using the \(S_{2}\) space.

  • The values of the parameter ν do not affect the results while using \(S_{1}\).

During the process of approximation, we recognized that the results were not affected by changing the values of parameters ν at the small values of M.

Example 3

Consider the Bagley–Torvik fractional BVP

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

subject to \(\phi (0)=0\) and \(\phi (1)=0\) with the exact solution \(\phi (x)=-x+x^{3}\).

SU-pseudo-GM reaches the double-precision (e-16) as MAE only at \(M=3\) using any space. While in [43], MAE varies from e-04 to e-05 by increasing M from 10 to 40.

On the other hand, the authors in [44] investigated four methods. They treated the same problem with the first and fourth methods. The authors had to increase M to 256. But they only reached e-08 for the first method and e-05 for the fourth method.

Example 4

Consider the linear FIDE (Volterra type)

$$ D^{1/3}\phi (x)=-\frac{2}{9}x^{13/2}- \frac{2}{7}x^{9/2}+ \frac{3\sqrt{\pi }}{4\Gamma (13/6)}x^{7/6}+ \int _{0}^{x} \bigl( x y+(x y)^{2} \bigr) \phi (y) \,dy $$
(32)

subject to \(\phi (0)=0\) with the exact solution \(\phi (x)=x^{1.5}\).

In this example, we have to use the space \(S_{3}\) to meet the conditions of the B-matrix. The method in [45] solved Eq. (32) and got 9.5e-04 as MAE at \(M=5\). Also, [46] solved it at the same number of points but by three methods. MAE were 1.9e-02, 9.8e-0.3, and 9.8e-0.3 for the three methods. While the MAE of SU-pseudo-GM is 7.0e-04 using \(M=5\) too. The authors in [46] increased M to increase the accuracy. Their best MAE was 10−4 at \(M=40,80\). But by using SU-pseudo-GM, MAE is 8.7e-05 at \(M=10\) and 9.4e-06 at \(M=21\). Some results and comparisons are summarized in Table 5. The stability and convergence rate are shown in Fig. 2.

Figure 2
figure 2

The LogError for Example 4 using \(S_{3}\)

Table 5 The MAE for Example 4 using \(S_{3}\)

Example 5

Consider the nonlinear FIDE (Volterra–Fredholm type)

$$ \begin{aligned} D^{\sqrt{3}}\phi (x)={}&{-} \frac{15}{56}x^{8}-\frac{1}{6}x^{2}+ \frac{2 ( 2+\sqrt{3} ) }{\Gamma (2-\sqrt{3})}x^{2-\sqrt{3}} \\ &{}+ \int _{0}^{x} ( x +y ) \bigl( \phi (y) \bigr) ^{3} \,dy + \int _{0}^{1}x^{2}y \bigl( \phi (y) \bigr) ^{2} \,dy \end{aligned} $$

subject to the boundary conditions of mixed type \(\phi (0)+\phi '(0)=0\) and \(\phi (1)+\phi '(1)=3\) with the exact solution \(\phi (x)=x^{2}\).

The boundary conditions of mixed type do not affect the steps. They are just two extra equations added to the algebraic system. The PW-AE of this example using SU-pseudo-GM and two other methods in [47] is written in Table 6. The first method in [47] is “Nystrom”, while the second method depends on the wavelet. This method used the two parameters m and k for the approximation. So, \(2^{k-1}m\) is the equivalent number of iterations. The following observations have been noted from Table 6. This first method in [47] approximates the solution to 10−5 as PW-AE at \(M=16\). But SU-pseudo-GM got the same PW-AE at \(M=5\) only. On the other hand, PW-AE decreases from 10−6 to 10−2 as x changes from 0.1 to 0.9 by using “Nystrom” at \(M=16\). The double-precision “10−16” was reached using SU-pseudo-GM at \(M=16\) for all the domain points. Figure 3 ensures the accuracy, stability, and convergence rate for SU-pseudo-GM.

Figure 3
figure 3

The LogError for Example 5 using \(S_{3}\)

Table 6 The MAE for Example 5 using \(S_{3}\)

Example 6

Consider the nonlinear FOCP

$$ \begin{aligned} (\text{min})\quad \mathcal{J}= \int _{0}^{1} \biggl( \bigl( \phi (x)-x^{2} \bigr)^{2}- \biggl(v(x)+x^{4}- \frac{20 x^{0.9}}{9 \Gamma (0.9)} \biggr) ^{2} \biggr) \,dx \end{aligned} $$

subject to \(D^{1.1}\phi (x)=x^{2} \phi (x)+v(x)\) and \(\phi (0)=\phi '(0)=0\) with the exact solution \((\mathcal{J}(v), \phi (x), v(x) ) = ( 0 , x^{2}, \frac{20 x^{0.9}}{9 \Gamma (0.9)}-x^{4} ) \).

According to the integration “from 0 to 1”, all spaces”\(S_{1},S_{2},S_{3}\)” may be used. The same technique is applied. In the past examples we got algebraic systems to solve. But in the case of FOCP, the problem is transformed into an optimization problem.

The best result is \(\mathcal{J}=4.1280e-17\) at “\(M=2\)” when “\(\nu =-0.49\)” using “\(S_{2}\)” with run time 0.019. The results of SU-pseudo-GM have been compared with the results from [18, 19, 48]. In [18], the authors used wavelet expansion. They got \(\mathcal{J}=4.7187e-06\) using six iterations with run time 0.046. While in [19], \(\mathcal{J}=6.16e-16\) but at \(M=4\) with run time 0.030 and in [48], \(\mathcal{J}=5.44e-08\) at \(M=9\) as best results. Table 7 compares the results obtained by SU-pseudo-GM when \(\nu =0.49\) using \(S_{1}\) with results from [48].

Table 7 Optimality value “\(\mathcal{J}\)”, MAE of the state function “\(\phi (x)\)” and the control function “\(v(x)\)” for Example 6 using \(S_{1}\) when \(\nu =0.49\)

These comparisons show the accuracy and the efficiency of SU-pseudo-GM for solving FCOPs.

Example 7

Consider the nonlinear FOCP

$$ \begin{aligned} (\text{min})\quad \mathcal{J}={}& \int _{0}^{1} \biggl(-2e^{1+x^{2}+\phi (x)}+e^{2 ( 1+x^{2}+\phi (x) ) }+8 \sqrt{\frac{x}{\pi }}v(x)+ \bigl(v(x) \bigr) ^{2}+ \frac{16}{\pi }x \\ &{} -2\sin \bigl(1+x^{2} \bigr)v(x)-8 \sqrt{\frac{x}{\pi }} \sin \bigl(1+x^{2} \bigr)+\sin ^{2} \bigl(1+x^{2} \bigr)+1 \biggr) \,dx \end{aligned} $$

subject to \(D^{1.5}\phi (x)=\sin (\phi (x) )+v(x)\), \(\phi (0)=-1\), and \(\phi '(0)=0\) with the exact solution \((\mathcal{J}(v), \phi (x), v(x) ) = ( 0 , -1-x^{2}, -4\sqrt{\frac{x}{\pi }}+\sin (1+x^{2} ) ) \).

By applying the same steps, Table 8 summarizes the best results of \(\mathcal{J}\), MAE of the state function \(\phi (x)\), and MAE of the control function \(v(x)\). All those results are compared with the methods in [18, 19, 49, 50]. The obtained results prove the high correctness and effectiveness of SU-pseudo-GM. Figure 4 shows the stability of the optimality value.

Figure 4
figure 4

The optimal value \(\mathcal{J}(x)\) for Example 7 using \(S_{3}\) at \(\nu =-0.49\)

Table 8 Best results of Example 7

7 Conclusion

A general method developed from GM has been introduced in this work. This method uses SUPs as trails functions. We call this method SU-pseudo-GM. New formulae for the spectral expansion and fractional derivatives of SUPs have been proved. This method can handle several types of OFPs. Finally, SU-pseudo-GM was used to solve several examples. As shown in those examples, the method was easy to apply in FODEs, IFDEs, and FOCPs. To show and prove the high correctness of that method, several graphs have been constructed. Also, comparisons with other methods have been done. Three spaces have been used in the examples. The results show that the quadrature points (\(S_{2}\)) are slightly more accurate than the equidistant Riemann points (\(S_{1}\)).