1 Introduction

The Lane–Emden equation has been used to model many phenomena in mathematical physics, astrophysics and celestial mechanics such as the thermal behavior of a spherical cloud of gas under mutual attraction of its molecules, the theory of stellar structure, and the theory of thermionic currents (Chandrasekhar 1967). This is a singular nonlinear ordinary differential equation (ODE) which was first introduced by U.S. astrophysicist, Jonathan Homer Lane (Lane 1870) who was interested in computing both the temperature and the density of mass on the surface, and 37 years later was studied in more detail by Emden (1907). In astrophysics, this ODE is a dimensionless version of Poisson’s equation for the gravitational potential of a simple stellar model (Momoniat & Harley 2006). We now briefly explain mathematical modeling of the thermal behavior of a spherical cloud which leads to the classic Lane–Emden equation. See Chandrasekhar (1967) and Parand et al. (2010) for a comprehensive coverage of the subject.

1.1 Modeling of the thermal behavior of a spherical cloud of gas

For the sake of simplicity, we consider a spherical gas cloud as shown in Figure 1. Let P(r) denote the total hydraulic pressure at a certain radius r. Due to the contribution of photons emitted from a cloud in radiation, the total pressure due to the usual gas pressure and photon radiation is formulated as follows:

$$\begin{aligned} P=\frac{1}{3}\xi T^{4}+\frac{RT}{V}, \end{aligned}$$

where the parameters \(\xi , T, R\) and V stand for the radiation constant, the absolute temperature, the gas constant and the specific volume respectively. Let M(r) be the mass of a sphere of radius r and \(G, g, \phi \) respectively denote the constant of gravitation, acceleration of gravity and gravitational potential of gas. By having the relation

$$\begin{aligned} g=\frac{GM(r)}{r^{2}}=-\frac{\mathrm{d}\phi }{\mathrm{d}r}, \end{aligned}$$

one can determine P and \(\phi \) by meeting the following three conditions:

$$\begin{aligned}&\mathrm{d}P=-g\rho \mathrm{d}r=\rho \mathrm{d}\phi , \end{aligned}$$
(1)
$$\begin{aligned}&\nabla ^{2}\phi =-4\pi G \rho ,\end{aligned}$$
(2)
$$\begin{aligned}&P=K\rho ^\gamma . \end{aligned}$$
(3)
Fig. 1
figure 1

A spherical gas cloud.

Here, \(\rho \) is the density of gas at a distance r from the centre of the spherical cloud and the constants \(\gamma =1+1/m\) and K are experimentally determined. The constant m is called the polytropic index and is related to the ratio of specific heats of gas comprising the star. Using the conditions (1)–(3), with a straightforward calculation, the following relations are revealed:

$$\begin{aligned}&\frac{\mathrm{d}P}{\mathrm{d}r}=-g\rho =-\rho \frac{GM(r)}{r^{2}}, \\&\frac{\mathrm{d}\phi }{\mathrm{d}r}=-g = -G\frac{M(r)}{r^{2}},\\&\frac{\mathrm{d}^{2}\phi }{\mathrm{d}r^{2}} =-G \left( \frac{1}{r^{2}}\frac{\mathrm{d}M(r)}{\mathrm{d}r}-2\frac{M(r)}{r^{3}}\right) . \end{aligned}$$

By substituting the above expressions into Equation (2), we obtain

$$\begin{aligned}&-G \left( \frac{1}{r^{2}}\frac{\mathrm{d}M(r)}{\mathrm{d}r}-2\frac{M(r)}{r^{3}}\right) +\frac{2}{r}\left( -G\frac{M(r)}{r^{2}}\right) \\&\quad =-4\pi G \rho , \end{aligned}$$

and consequently,

$$\begin{aligned} \frac{\mathrm{d}M(r)}{\mathrm{d}r}=4\pi \rho r^{2}. \end{aligned}$$

Therefore, the hydrostatic equilibrium conditions (HEC) are as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} \frac{\mathrm{d}P}{\mathrm{d}r}=-\rho \frac{GM(r)}{r^{2}}, \\ \frac{\mathrm{d}M(r)}{\mathrm{d}r}=4\pi \rho r^{2}, \end{array}\right. } \end{aligned}$$

Eliminating M from the recent equations yields

$$\begin{aligned} \frac{1}{r^{2}}\frac{\mathrm{d}}{\mathrm{d}r}\left( \frac{r^{2}}{\rho }\frac{\mathrm{d}P}{\mathrm{d}r}\right) =-4\pi G \rho , \end{aligned}$$

where the pressure P and the density \(\rho =V^{-1}\) vary with r. If we insert the above expression into the first equation for HEC, we obtain the following differential equation:

$$\begin{aligned} \left( \frac{K(m+1)}{4\pi G}\lambda ^ {\frac{1}{m}-1}\right) \left( \frac{1}{r^{2}}\frac{\mathrm{d}}{\mathrm{d}r}\left( r^{2}\frac{\mathrm{d}y}{\mathrm{d}r}\right) \right) =-y^{m}, \end{aligned}$$
(4)

where \(\lambda \) represents the central density of the gas cloud and y is a dimensionless quantity that are both related to \(\rho \) via \(\rho = \lambda y^{m}\). By imposing additional dimensionless variable \(r=ax\) via the relation

$$\begin{aligned} a=\left( \frac{K(m+1)}{4\pi G}\lambda ^ {\frac{1}{m}-1}\right) ^{\frac{1}{2}}, \end{aligned}$$

the differential equation (4) reduces to

$$\begin{aligned} y''+\frac{2}{x}y'+y^{m}=0, x > 0. \end{aligned}$$
(5)

In physics, this singular differential equation with the initial conditions

$$\begin{aligned} y(0)=1, y'(0)=0 \end{aligned}$$
(6)

is known as the classic Lane–Emden problem. In quantum mechanics and astrophysics, the values of m are physically meaningful and interesting and lie in the interval [0, 5]. In the literature, the exact solutions of problems (5)–(6) are known only for \(m=0,1,5\) (Parand et al. 2010) and for other values of m, with the approach of handling singularity in the presence of the origin, several methods have been efficiently employed to approximate the solution of this problem. A fairly complete discussion of these methods are presented in Parand et al. (2010, 2017); Dehghan & Shakeri (2008); Abd-Elhameed et al. (2014) and references therein.

In recent years, considerable attention has been devoted to develop the applications of fractional calculus in the fields of science and engineering. By the use of differential equations of non-integer order, dynamic behavior of different phenomena in engineering sciences, physics and other branches of science can be studied more precisely (Saadatmandi & Dehghan 2010, 2011; Saadatmandi 2014; Doha et al. 2012). Hence, this motivates us to study the efficient low-cost numerical algorithms for solving the singular Lane–Emden equations of fractional order as follows (Nasab et al. 2018):

$$\begin{aligned} \begin{aligned} D^{\alpha }y(x)+\frac{L}{x^{\alpha - \beta }}D^{\beta }y(x)+g(x,y(x))=h(x), \end{aligned} \end{aligned}$$
(7)

with the initial conditions:

$$\begin{aligned} y(0)=A, y'(0)=B, \end{aligned}$$
(8)

where \(0<x\le 1\), \( 1<\alpha \le 2\) and \( 0<\beta \le 1\). Also, A and B are constants and \(D^{\alpha }\) denotes the fractional derivative of order \(\alpha \) in the Caputo sense and defined later in the text. Moreover, g(xy(x)) is a continuous real-valued function and \(h(x)\in C[0,1]\). The existence and uniqueness of the solution of problems (7)–(8) are discussed in Ibrahim (2013) and Taleb & Dahmani (2016). To the best of our knowledge, there are only a few numerical algorithms available in the literature for the numerical solution of fractional Lane–Emden equations compared to the classical one. For instance, we can refer to the reproducing kernel method (Akgül et al. 2015), collocation method (Mechee & Senu 2012a), the least square method (Mechee & Senu 2012b), and modified differential transform method (Marasi et al. 2015). More recently, Nasab et al. (2018) applied a hybrid numerical method combining Chebyshev wavelets and a finite difference approach to obtain solutions of singular fractional Lane–Emden equations of the form (7).

Unfortunately, most of the differential equations of fractional order do not have an analytical expression of solution and the analytical solution, if any, is not suitable for numerical purposes. Therefore, in recent years, researchers have focused on the development of suitable and efficient numerical methods for solving linear/nonlinear fractional ordinary/partial differential equations. One of the most powerful and adaptive tools for obtaining numerical solutions of these equations is the use of operational matrices that have been widely extended in the field of fractional calculus over the last few years (Bhrawy et al. 2015). In fact, by the use of an operational matrix technique, the problem of solving a fractional differential equation can readily lead to the determination of solution of a system of algebraic equations. This approach reduces the computational error and the complexity of operations, speeds up computing, makes programming more easy and suitable, and does not have difficulties arising from problem-solving directly.

In the past few years, the abilities of the operational matrix of fractional derivative/integral, based on some families of the famous basic functions, in solving fractional differential/integral equations are well-reflected in the literature. For instance, we can refer to the operational matrices of fractional derivative or integral which were composed of Legendre polynomials (Saadatmandi & Dehghan 2010, 2011), Bernstein polynomials (Saadatmandi 2014; Rostamy et al. 2014, 2013), Jacobi polynomials (Doha et al. 2012), block pulse functions (Li & Sun 2011), Chebyshev polynomials (Doha et al. 2011), and B-spline functions (Lakestani et al. 2012). The interested reader is referred to Bhrawy et al. (2015) for a broad review of spectral techniques based on operational matrices of fractional derivatives and integrals for some orthogonal polynomials.

In this paper, we discuss the use of operational matrices of fractional derivatives and integrals for orthonormal Bernstein polynomials (OBPs) in solving the singular Lane–Emden equation of fraction order (7). In this work, we approximate the solution of (7) as a linear combination, with unknown coefficients, of a finite number of OBPs. Then, finding the solution of problems (7)–(8), leads to the solution of a system of algebraic equations.

The layout of this paper is as follows. In Section 2, some basic definitions and introductory concepts of fractional calculus and some properties of OBPs are presented. Section 3 is devoted to obtaining operational matrices of fractional derivatives and integrals for OBPs. In Section 4, with the aid of operational matrices of fractional integral and differential and collocation approach, two numerical techniques are driven to solve the singular fractional Lane–Emden equation (7) subject to the initial conditions (8). In Section 5, the proposed methods are applied to several examples and the numerical results are compared with those existing in the literature. Finally, concluding remarks are given in Section 6. Note that we have implemented our algorithms in Maple software.

2 Basic definitions and concepts

2.1 A brief review of fractional calculus

In this section, we present some essential basic definitions and properties of fractional calculus for subsequent discussion. The fractional calculus was born more than 300 years ago and its history goes back to the beginning of the differential and integral calculus. Various popular definitions for integral and derivative of fractional order are given. Among all these definitions, the definition of the Riemann–Liouville fractional integral and the fractional derivative of the Caputo sense are of particular importance in the field of fractional calculus. First, we give some concepts related to the definition of Riemann–Liouville fractional integral (Miller & Ross 1993; Oldham & Spanier 1974).

Definition 1

Let us denote by \(C_\mu \), where \(\mu \in \mathbb {R}\), the space of all real-valued functions on \((0,\infty )\) which can be represented in the form \(f(x)=x^pf_1(x)\), where \(f_1(x)\in C[0,\infty )\) and \(p>\mu \).

Clearly, if \(\beta \le \mu \), then \(C_\beta \subset C_\mu \).

Definition 2

Let \(n\in \mathbb {N}\bigcup \{0\}\). We say that f(x) defined on \((0,\infty )\) belongs to the space \(C_\mu ^n\), if \((f(x))^n\in C_\mu \).

Definition 3

Let \(\alpha >0\) and \(f(x)\in C_\mu \), where \(\mu \ge -1\). The Riemann–Liouville integral of fractional order is defined as follows:

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

Here, \(\Gamma (\alpha )\) is the Gamma function and the notation \(x^{\alpha -1}*f(x)\) denotes the convolution of \(x^{\alpha -1}\) and f(x).

Definition 4

Let \(\alpha >0\). The Caputo fractional derivative of order \(\alpha \) of a function \(f(x)\in C_{-1}^n\) is defined by

$$\begin{aligned}&D^\alpha f(x)\\&\quad = {\left\{ \begin{array}{ll} \frac{1}{\Gamma (n-\alpha )} \int _ 0^{x}\frac{f^{(n)}(t)}{(x-t)^{\alpha +1-n}}\, \mathrm{d}t,n\,{-}\,1\,{<}\,\alpha \,{<}\,n, n\in \mathbb {N}, \\ \frac{\mathrm{d}^n}{\mathrm{d}x^n}f(x),\quad \alpha = n\in \mathbb {N}.\\ \end{array}\right. } \end{aligned}$$

Now we present some important properties of the fractional derivative/integral of order \(\alpha \) in the Caputo or Riemann–Liouville sense which be useful in the following (Miller & Ross 1993; Oldham & Spanier 1974):

  • \(I^{0}f(x)=f(x)\).

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

  • \( I^{\alpha } D^{\alpha }f(x)=f(x)-\sum _{k=0}^{n-1}f^{k}(0^{+})\frac{x^{k}}{k!}, n-1<\alpha \le n, n\in \mathbb {N}. \)

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

  • \(D^{\alpha }f(x)=I^{m-\alpha }D^{m}f(x), \quad m\in \mathbb {N}.\)

  • \( D^\alpha C=0,\ \ \ (C \text { is a constant}).\)

  • Caputo’s fractional differentiation is a linear operator, i.e.,

    $$\begin{aligned} D^\alpha \left( \sum _{j=1}^kc_jf_j(x)\right) =\sum _{j=1}^kc_jD^\alpha f_j(x), \end{aligned}$$

    where \(\{c_j\}_{j=1}^k\) are constants.

  • The Caputo’s derivative of \(f(x)=x^m, m\in \mathbb {N}\) is given as

    $$\begin{aligned} D^\alpha x^m={\left\{ \begin{array}{ll} 0, &{}\quad m< \lceil \alpha \rceil , \\ \frac{\Gamma (m+1)}{\Gamma (m+1-\alpha )}x^{m-\alpha },&{} \quad m\ge \lceil \alpha \rceil , \end{array}\right. } \end{aligned}$$

    where \(\lceil \alpha \rceil \) denotes the smallest integer greater than or equal to \(\alpha \).

2.2 Orthonormal Bernstein polynomials

The well-known Bernstein polynomials of degree n over the unit interval [0, 1] are defined by

$$\begin{aligned} b_{i,n}(x)=\left( {\begin{array}{c}n\\ i\end{array}}\right) x^{i}(1-x)^{n-i},\quad i=0,1,\cdots ,n. \end{aligned}$$

Although these polynomials have very applicable properties in the approximation theory, they do not admit the orthogonality. The fact that they are not orthogonal turns out to be less suited for many applications, such as least-squares approximation and finite element methods. Currently, there are three approaches to solve this problem. The first one is to construct a dual basis (Saadatmandi 2014). The second approach is to use transformation matrices to transfer these polynomials to the corresponding orthogonal polynomials such as of Legendre or Chebyshev ones. As a third suggestion, one can use the Gram–Schmidt orthogonalization process to construct OBPs (Heydari et al. 2017; Shihab & Naif 2014). But as in Bellucci (2014), the Gram–Schmidt process must be repeated every time the degree of the polynomial basis is increased. Fortunately, recently an explicit representation of the OBPs has been proposed in Bellucci (2014). The OBPs of degree n over the interval [0, 1], for \(i=0,1,\ldots ,n\) are defined as follows (Bellucci 2014):

$$\begin{aligned} \begin{aligned} B_{i,n}(x)=&\sqrt{2(n-i)+1}(1-x)^{n-i}\\&\times \sum _{k=0}^{i}(-1)^{k}\left( {\begin{array}{c}2n+1-k\\ i-k\end{array}}\right) \left( {\begin{array}{c}i\\ k\end{array}}\right) x^{i-k}. \end{aligned} \end{aligned}$$
(9)

Using binomial expansion of \((1-x)^{n-i}\), Equation (9) can be rewritten as (Javadi et al. 2016; Bencheikh et al. 2016)

$$\begin{aligned} B_{i,n}(x)= & {} \sqrt{2(n-i)+1}\sum _{j=0}^{n}\nonumber \\&\times \left( \sum _{k=\mathrm{max} \left\{ 0,j-n+i\right\} }^{\mathrm{min}\left\{ i,j\right\} }\alpha _{i,j-k}\, \beta _{i,k}\right) x^{j}, \end{aligned}$$
(10)

where

$$\begin{aligned} \begin{aligned} \alpha _{i,r}&=(-1)^{r}\left( {\begin{array}{c}n-i\\ r\end{array}}\right) ,\ \ \ r=0,1,\cdots ,n-i,\\ \beta _{i,j}&=\big (-1\big )^{i-j}\left( {\begin{array}{c}2n+1-i+j\\ j\end{array}}\right) \left( {\begin{array}{c}i\\ i-j\end{array}}\right) ,\\&\qquad \qquad \qquad \qquad \qquad \qquad \qquad j=0,1,\cdots ,i. \end{aligned} \end{aligned}$$

The Bernstein polynomials \(B_{i,n}(x),\ i=0,1,\ldots ,n\) satisfy the following orthogonal relationship over the interval [0, 1]:

$$\begin{aligned} \int _{0}^{1} B_{i,n}(x)B_{j,n}(x)\,\mathrm{d}x=\delta _{ij},i,j=0,1,\cdots ,n, \end{aligned}$$

where \(\delta _{ij}\) denotes the Kronecker delta function. These polynomials form a complete orthonormal basis over [0, 1]. Hence, a square integrable function in [0, 1], say y(x), can be represented as a linear combination of OBPs. In practice, for a suitable value of \(n\in \mathbb {N}\), we can obtain an approximation for y(x) as (Javadi et al. 2016; Bencheikh et al. 2016)

$$\begin{aligned} y(x) \simeq \sum _{i=0}^{n}c_{i}B_{i,n}(x)=C^{T}Q(x), \end{aligned}$$
(11)

where the orthonormal Bernstein vector Q(x) and orthonormal Bernstein coefficient vector C are given by

$$\begin{aligned} \begin{aligned} Q(x)&= [B_{0,n}(x), B_{1,n}(x),\cdots , B_{n,n}(x)]^{T},\\ C&=[c_{0},c_{1},\cdots , c_{n}]^{T}. \end{aligned} \end{aligned}$$
(12)

The elements of C are also given by

$$\begin{aligned} c_{i}=\int _{0}^{1}y(x)B_{i,n}(x)\, \mathrm{d}x, \quad i=0,1,\cdots ,n. \end{aligned}$$

Each of the basis functions \(B_{i,n}(x)\) is a polynomial of degree n. Thus, using the Taylor expansion of \(B_{i,n}(x)\), we get

$$\begin{aligned} Q(x)=\mathbf {Z}\;T(x), \end{aligned}$$
(13)

where \( T(x)=[ 1,x,x^{2}, \cdots ,x^{n}]^{T} \) and the entries of matrix \(\mathbf {Z}=(z_{ij}) _{i,j=0}^{n}\) are obtained by (Bhrawy et al. 2015; Miller & Ross 1993)

$$\begin{aligned} z_{ij}=\sqrt{2(n-i)+1}\sum _{k=\max \left\{ 0,j-n+i\right\} }^{\min \left\{ i,j\right\} }\alpha _{i,j-k}\, \beta _{i,k}. \end{aligned}$$
(14)

3 The construction of orthonormal Bernstein operational matrices for fractional calculus

In this section, we derive the orthonormal Bernstein operational matrices of the fractional integration and differentiation. We define the first integral and the first derivative of the column vector Q(x) of OBPs as follows:

$$\begin{aligned}&\int _{0}^{x}Q(t)\, \mathrm{d}t \simeq \mathbf { P}Q(x), 0\le x\le 1. \end{aligned}$$
(15)
$$\begin{aligned}&\frac{\mathrm{d}Q(x) }{\mathrm{d}x}= \mathbf {D}Q(x), 0\le x\le 1, \end{aligned}$$
(16)

where \(\mathbf { P}_{(n+1)\times (n+1)}\) and \(\mathbf {D}_{(n+1)\times (n+1)}\) are called the operational matrices of integration and differentiation corresponding to the vector of OBPs. These matrices are fully generated by Javadi et al. (2016) and Bencheikh et al. (2016). Now we intend to extend these matrices of classical integer-order version to the fractional order.

3.1 Operational matrix of integration of fractional order

Theorem 5

Let Q(x) be the orthonormal Bernstein vector defined in (12) and also suppose \(\alpha >0\). Then

$$\begin{aligned} I^{\alpha }Q(x) \simeq \mathbf {F}^{(\alpha )}Q(x), \end{aligned}$$

where \(\mathbf {F^{(\alpha )}}\) denotes the \((n+1)\times (n+1)\) operational matrix of fractional integration of order \(\alpha \) in the Riemann–Liouville sense and can be obtained as \(\mathbf {F^{(\alpha )}=ZGE}\). Here, \(\mathbf {Z}\) is defined in (14), \(\mathbf {G}\) is a diagonal matrix of the form

$$\begin{aligned} \mathbf {G}=\mathrm{diag} \left[ \dfrac{0!}{\Gamma (\alpha +1)}, \dfrac{1!}{\Gamma (\alpha +2)}, \ldots ,\dfrac{n!}{\Gamma (\alpha +n +1)}\right] , \end{aligned}$$

and \(\mathbf {E}=(E_{i,j})\) is an \((n+1)\times (n+1)\) matrix whose elements are

$$\begin{aligned} E_{i,j}= & {} \sqrt{2(n-j)+1}\sum _{s=0}^{n}\\&\times \left( \sum _{k=\max \left\{ 0,s-n+j\right\} }^{\min \left\{ j,s\right\} }\alpha _{j,s-k}\beta _{j,k}\right) \frac{1}{i+\alpha +s +1}, \end{aligned}$$

where \(i,j=0,1,\cdots ,n.\)

Proof

By applying the operator \(I^{\alpha }\) on Q(x), we obtain

$$\begin{aligned} I^{\alpha }Q(x)=\frac{1}{\Gamma (\alpha )}x^{\alpha -1}*Q(x), 0\le x\le 1. \end{aligned}$$
(17)

Inserting Equation (13) into Equation (17), we get

$$\begin{aligned} \frac{1}{\Gamma (\alpha )}x^{\alpha -1}*(\mathbf {Z}T(x))=\frac{1}{\Gamma (\alpha )}\mathbf {Z}(x^{\alpha -1}*T(x)). \end{aligned}$$

Also, we have

$$\begin{aligned} \begin{aligned}&x^{\alpha -1}*T(x) \,{=}\, [x^{\alpha -1}*1,\;x^{\alpha -1}*x,\cdots , x^{\alpha -1}*x^{n}]^{T}\\&\quad =\Gamma (\alpha ) [I^{\alpha }1,\;I^{\alpha }x,\cdots , \;I^{\alpha }x^{n}]^{T}\\&\quad =\Gamma (\alpha )\left[ \dfrac{0!}{\Gamma (\alpha +1)}x^{\alpha },\dfrac{1!}{\Gamma (\alpha +2)}x^{\alpha +1},\right. \ldots ,\\&\qquad \left. \dfrac{n!}{\Gamma (\alpha +n+1)}x^{\alpha +n}\right] ^{T}\\&\quad =\Gamma (\alpha )\mathbf {G} \bar{T}(x), \end{aligned} \end{aligned}$$

where \(\bar{T}(x)= [x^{\alpha },\;x^{\alpha +1},\cdots ,\;x^{\alpha +n} ]^{T}. \) Now, with the aid of Equation (11), we can approximate \(x^{\alpha +i}\) by OBPs as

$$\begin{aligned} x^{\alpha +i}\simeq E_{i}^{T}Q(x), \end{aligned}$$

where \(E_i\) is a column vector whose components are denoted by \(\bar{E}_{i,j}\) and is given by

$$\begin{aligned} \begin{aligned} \bar{E}_{i,j}&=\int _{0}^{1}x^{\alpha +i}B_{j,n}(x)\, \mathrm{d}x =\sqrt{2(n-j)+1}\\&\qquad \times \sum _{s=0}^{n} \left( \sum _{k=\max \left\{ 0,s-n+j\right\} }^{\min \left\{ j,s\right\} }\alpha _{j,s-k}\beta _{j,k}\right) \\&\qquad \times \int _{0}^{1}x^{\alpha +i+s}\mathrm{d}x=\sqrt{2(n-j)+1}\\&\qquad \times \sum _{s=0}^{n}\left( \sum _{k=\max \left\{ 0,s-n+j\right\} }^{\min \left\{ j,s\right\} }\alpha _{j,s-k}\beta _{j,k}\right) \\&\qquad \times \frac{1}{i+\alpha +s+1},\quad i,j=0,1,\cdots ,n. \end{aligned} \end{aligned}$$

Finally, by defining \(\mathbf {E}\) as a matrix of size \(n+1\) whose i-th row is \(E_{i}^T\), \(i=0,1,\ldots ,n\), we observe that

$$\begin{aligned} I^{\alpha }Q(x)\simeq \mathbf { ZGE}Q(x)=\mathbf {F}^{(\alpha )}Q(x). \end{aligned}$$

\(\square \)

Remark 6

It is worth indicating that, if \(\alpha =1\), then Theorem 5 gives the same result as Equation (15), i.e., \(\mathbf {F}^{(1)}= \mathbf { P}.\)

3.2 Operational matrix of differentiation of fractional order

Theorem 7

Under the assumptions made in Theorem 5, we have

$$\begin{aligned} D^{\alpha }Q(x)\simeq \mathbf {D}^{(\alpha )}Q(x). \end{aligned}$$

Here, \(\mathbf {D}^{(\alpha )}\) denotes the \((n+1)\times (n+1)\) operational matrix of the Caputo fractional derivative of order \(\alpha \) and is defined as follows:

$$\begin{aligned} \begin{aligned}&\mathbf {D^{(\alpha )}}=\sqrt{2(n-i)+1}\\&\quad \times \begin{pmatrix} \displaystyle \sum _{j=\lceil \alpha \rceil }^{n} w_{0,j,0} &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{0,j,1} &{}\quad \ldots &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{0,j,n} \\ \vdots &{}\quad \vdots &{}\quad \cdots &{}\quad \vdots \\ \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{i,j,0} &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{i,j,1}&{}\quad \ldots &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{i,j,n} \\ \vdots &{}\quad \vdots &{}\quad \cdots &{}\quad \vdots \\ \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{n,j,0} &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{n,j,1}&{}\quad \cdots &{}\quad \displaystyle \sum _{j=\lceil \alpha \rceil }^{n}w_{n,j,n} \end{pmatrix}. \end{aligned} \end{aligned}$$

Here

$$\begin{aligned} w_{i,j,l}= & {} \Bigg (\sum _{k=\max \left\{ 0,j-n+i\right\} }^{\min \left\{ i,j\right\} }\alpha _{i,j-k}\, \beta _{i,k}\Bigg ) \\&\times \frac{\Gamma (j+1)}{\Gamma (j+1-\alpha )}u_{l,j}, \end{aligned}$$

where

$$\begin{aligned} \begin{aligned} u_{l,j}&=\sqrt{2(n-l)+1}\\&\qquad \times \sum _{s=0}^{n}\left( \sum _{k=\max \left\{ 0,s-n+l\right\} }^{\min \left\{ l,s\right\} }\alpha _{l,s-k}\beta _{l,k}\right) \\&\qquad \times \frac{1}{j-\alpha +s+1}. \end{aligned} \end{aligned}$$

Proof

Using the linear property of operator \(D^\alpha \) and with the aid of Equation (10) for \(i=0,1,2,\ldots ,n,\) we obtain

$$\begin{aligned} \begin{aligned}&D^{\alpha }B_{i,n}(x) =\sqrt{2(n-i)+1}\\&\qquad \times \sum _{j=0}^{n}\left( \sum _{k=\max \left\{ 0,j-n+i\right\} }^{\min \left\{ i,j\right\} }\alpha _{i,j-k}\beta _{i,k}\right) D^{\alpha }x^{j}\\&\quad =\sqrt{2(n-i)+1}\\&\qquad \times \sum _{j=\lceil \alpha \rceil }^{n}\left( \sum _{k=\max \left\{ 0,j-n+i\right\} }^{\min \left\{ i,j\right\} }\alpha _{i,j-k}\beta _{i,k}\right) \\&\qquad \times \frac{\Gamma (j+1)x^{j-\alpha }}{\Gamma (j+1-\alpha )}. \end{aligned} \end{aligned}$$
(18)

Now, by taking a linear combination of OBPs, we can approximate \(x^{j-\alpha }\) as follows:

$$\begin{aligned} x^{j-\alpha }\simeq \sum _{l=0}^{n}u_{l,j}B_{l,n}(x), \end{aligned}$$
(19)

where

$$\begin{aligned} u_{l,j}&=\int _{0}^{1}x^{j-\alpha }B_{l,n}(x)\mathrm{d}x=\sqrt{2(n-l)+1}\\&\quad \times \sum _{s=0}^{n}\left( \sum _{k=\max \left\{ 0,s-n+l\right\} }^{\min \left\{ l,s\right\} }\alpha _{l,s-k}\beta _{l,k}\right) \\&\quad \times \int _{0}^{1}x^{j-\alpha +s}\mathrm{d}x =\sqrt{2\big (n-l\big ) +1}\\&\quad \times \sum _{s=0}^{n}\left( \sum _{k=\max \left\{ 0,s-n+l\right\} }^{\min \left\{ l,s\right\} }\alpha _{l,s-k}\beta _{l,k}\right) \\&\quad \times \frac{1}{j-\alpha +s+1}. \end{aligned}$$

By applying Equations (18) and (19), we get

$$\begin{aligned} \begin{aligned}&D^{\alpha }B_{i,n}(x)\simeq \sqrt{2(n-i)+1}\\&\quad \times \sum _{j=\lceil \alpha \rceil }^{n}\sum _{l=0}^{n}\left( \sum _{k=\max \left\{ 0,j-n+i\right\} }^{\min \left\{ i,j\right\} }\alpha _{i,j-k}\beta _{i,k}\right) \\&\quad \times \frac{\Gamma (j+1)}{\Gamma (j+1-\alpha )}u_{l,j}B_{l,n}(x). \end{aligned} \end{aligned}$$

In other words, we have

$$\begin{aligned} D^{\alpha }B_{i,n}(x)\simeq & {} \sqrt{2(n-i)+1}\sum _{l=0}^{n}\nonumber \\&\times \left( \sum _{j=\lceil \alpha \rceil }^{n} w_{i,j,l} \right) B_{l,n}(x). \end{aligned}$$
(20)

Rewriting Equation (20) as a vector form, we obtain

$$\begin{aligned} \begin{aligned}&D^{\alpha }B_{i,n}(x)\simeq \sqrt{2(n-i)+1}\\&\quad \times \left[ \sum _{j=\lceil \alpha \rceil }^{n} w_{i,j,0},\sum _{j=\lceil \alpha \rceil }^{n} w_{i,j,1},\cdots ,\sum _{j=\lceil \alpha \rceil }^{n} w_{i,j,n} \right] Q(x). \end{aligned} \end{aligned}$$
(21)

Now, by using Equation (21), the final step is taken to reach the end of the proof. \(\square \)

Remark 8

For \(\alpha =1\), Theorem 7 gives the same result as Equation (16), i.e. \(\mathbf {D}^{(1)}= \mathbf {D}.\)

4 Solution of singular fractional Lane–Emden equation

In this section, using the operational matrices of fractional derivative or integral that were made in the previous section, and using the collocation spectral strategies, we present two numerical techniques for solving problems (7)–(8).

4.1 The first method

In this subsection, the performance of operational matrix of fractional integration for OBPs will be reflected well in the process of solution of the problems (7)–(8). First, for simplicity, using the following change of variable,

$$\begin{aligned} y(x)=y^{*}(x)+z(x), \end{aligned}$$
(22)

the initial conditions (8) turns into the homogenous ones. Here, z(x) is an unknown function of x, which satisfies trivially the condition \(z(0)=z'(0)=0.\) After inserting (22) into (7) and (8), we arrive at the following:

$$\begin{aligned}&D^{\alpha }z(x)+\frac{L}{x^{\alpha - \beta }}D^{\beta }z(x)+g(x,z(x))=h(x), \end{aligned}$$
(23)
$$\begin{aligned}&z(0)=0, z'(0)=0. \end{aligned}$$
(24)

In order to approximate the solution of problems (23)–(24), by the aid of Equation (11), we apply an orthonormal Bernstein expansion of \(D^{\alpha } z(x)\) as follows:

$$\begin{aligned} D^{\alpha } z(x)\simeq C^{T}Q(x). \end{aligned}$$
(25)

Thanks to Theorem 5 and Equation (25) and in the presence of some properties of fractional integration/differentiation, we have

$$\begin{aligned} \begin{aligned} D^{\beta }z(x)&=I^{\alpha -\beta }(D^{\alpha }z(x))\simeq I^{\alpha -\beta }( C^{T}Q(x))\\&=C^{T} I^{\alpha -\beta }Q(x)\simeq C^{T} \mathbf {F}^{(\alpha -\beta )}Q(x) \end{aligned} \end{aligned}$$
(26)

and

$$\begin{aligned} z(x)=I^{\alpha }D^{\alpha }z(x)\simeq C^{T}I^{\alpha }Q(x)\simeq C^{T}\mathbf {F}^{(\alpha )}Q(x). \end{aligned}$$
(27)

Substituting Equations (25)–(27) into Equation (23) gives

$$\begin{aligned}&C^{T}Q(x)+\frac{L}{x^{\alpha - \beta }}(C^{T}\mathbf {F}^{(\alpha -\beta )}Q(x))\nonumber \\&\quad +g(x,C^{T}\mathbf {F}^{(\alpha )}Q(x))=h(x). \end{aligned}$$
(28)

Now, Equation (28) can be collocated at \(n+1\) points as follows:

$$\begin{aligned} \begin{aligned}&C^{T}Q(x_{i})+\frac{L}{x_{i}^{\alpha -\beta }}(C^{T}\mathbf {F}^{(\alpha -\beta )}Q(x_{i}))\\&\qquad +g(x_{i},C^{T}\mathbf {F}^{(\alpha )}Q(x_{i}))\\&\quad =h(x_{i}),\quad i=1,\cdots ,n+1. \end{aligned} \end{aligned}$$
(29)

Here, we use uniform collocation points \(x_{i}=\frac{i}{n+1},\ \) \(i=1,\cdots ,n+1\). By solving this system of algebraic equations for C, and by the use of Equations (27) and (22), we obtain an approximate solution for the original problem.

\hspace*{18pt 1 Comparison of y(x) for Example 1.

4.2 The second method

Consider again Equation (7). In the second method, we approximate the unknown function y(x) in the form analogous to Equation (11). Thanks to the approximation formulae for fractional derivatives in Theorem 7, we have

$$\begin{aligned}&D^{\alpha }y(x)\simeq C^{T}DQ(x)\simeq C^{T}\mathbf {D}^{(\alpha )}Q(x), \end{aligned}$$
(30)
$$\begin{aligned}&D^{\beta }y(x)\simeq C^{T}DQ(x)\simeq C^{T}\mathbf {D}^{(\beta )}Q(x). \end{aligned}$$
(31)

Substituting Equations (11), (30) and (31) in Equation (7), we obtain

$$\begin{aligned}&C^{T}\mathbf {D}^{(\alpha )}Q(x)+\frac{L}{x^{\alpha - \beta }}(C^{T}\mathbf {D}^{(\beta )}Q(x))\nonumber \\&\quad +g(x,C^{T} Q(x))=h(x). \end{aligned}$$
(32)

Collocating Equation (32) at \(n-1\) collocation points leads to

$$\begin{aligned} \begin{aligned}&C^{T}\mathbf {D}^{(\alpha )}Q(x_{i})+\frac{L}{x_{i}^{\alpha - \beta }}(C^{T}\mathbf {D}^{(\beta )}Q(x_{i}))\\&\qquad +g(x_{i},C^{T} Q(x_{i}))\\&\quad =h(x_{i}), i=1,\cdots ,n-1. \end{aligned} \end{aligned}$$
(33)

A set of suitable collocation points is defined as follows:

$$\begin{aligned} x_{i}=\bigg (\frac{1}{2}\bigg )\Bigg (\cos \bigg (\frac{i\pi }{n}\bigg ) +1\Bigg ), \qquad i=1,\cdots ,n-1. \end{aligned}$$
(34)

In addition, the initial conditions (8) provide two algebraic equations as

$$\begin{aligned} C^{T}Q(0) =A,\quad C^{T}\mathbf {D}^{(1)}Q(0)=B. \end{aligned}$$
(35)

Finally, we can compute the values for the components of C by solving the system of equations (33) and (35). Hence, the approximate solution for y(x) can be computed by using Equation (11).

\hspace*{18pt 2 Comparison of absolute error for Example 1.
Fig. 2
figure 2

Plot of the absolute error with \(n=4\), using the first method (left) and the second method (right) for Example 1.

5 Illustrative examples

In this section, the ability of the proposed methods to make desirable outcome solutions of singular Lane–Emden equations of fractional order will be examined. For numerical evaluation of the two methods, we will use either graphical or tabular displays of exact solutions versus numerical solutions.

Example 1

We consider the classic nonlinear Lane–Emden equation

$$\begin{aligned} y''(x)+\frac{2}{x}y'(x)+\sinh \left( y(x)\right) =0, x \ge 0, \end{aligned}$$
(36)

subject to the initial conditions

$$\begin{aligned} y(0)=1, \quad y'(0)=0. \end{aligned}$$
(37)

Wazwaz (2001) used the Adomian decomposition method and provided the following solution corresponding to (36)–(37):

$$\begin{aligned} \begin{aligned} y(x)\simeq \,&1-\frac{(e^{2}-1)}{12e}x^{2}+\frac{1}{480}\frac{(e^{4}-1)}{e^{2}}x^{4}\\&-\frac{1}{30240}\frac{(2e^{6}+3e^{2}-3e^{4}-2)}{e^{3}}x^{6}\\&+\frac{1}{26127360}\frac{(61e^{8}\,{-}\,104e^{6}\,{+}\,104e^{2}\,{-}\,61)}{e^{4}}x^{8}. \end{aligned} \end{aligned}$$

Table 1 compares the approximation of y(x) obtained by the present methods with \(n=18\) and those provided in Parand et al. (2010) (denoted by Method 1), Nasab et al. (2018) (denoted by Method 2), Wazwaz (2001) (denoted by Method 3), Parand & Delkhosh (2017) (denoted by Method 4) and Parand & Hemami (2017) (denoted by Method 5). Also, in Table 2, we summarize the absolute error of our proposed methods for \(n=10\) corresponding to four sample points and provide a comparison between them and those obtained by Chebyshev wavelet method (Nasab et al. 2018) and collocation method based on Hermite polynomials (Parand et al. 2010). It is worth mentioning that the proposed method in Nasab et al. (2018) needs to solve a nonlinear system with \(2^{k-1}(M+1)\) algebraic equations, while our methods need to solve a nonlinear system in only \(n+1\) equations. Indeed, in comparison with the methods presented in Parand et al. (2010), Nasab et al. (2018); Wazwaz (2001); Parand & Delkhosh (2017) and Parand & Hemami (2017), Tables 1 and 2 indicate that our numerical schemes significantly lead to more accurate approximations. Moreover, Figure 2 illustrates the absolute error functions corresponding to our methods with \(n=4\).

\hspace*{18pt 3 Comparison of absolute error for \(n=10,15\) for Example 2.
\hspace*{18pt 4 Comparison of absolute error for \(n=7,14\) for Example 3.
Fig. 3
figure 3

Plot of the absolute error with \(n=16\), using the first method (left) and the second method (right) for Example 3.

Example 2

We consider the nonlinear spherical Lane–Emden equation of fractional order

$$\begin{aligned} \begin{aligned} D^{\alpha }y(x)+\frac{2}{x^{\alpha -\beta }}D^{\beta }y(x)=\mathrm{e}^{-y(x)}, 0<x\le 1. \end{aligned} \end{aligned}$$

with the initial conditions

$$\begin{aligned} y(0)=0, y'(0)=0. \end{aligned}$$

The exact/numerical solution of this problem with \(\alpha =3/2\) and \(\beta =3/4\) has been computed by the technique of Abdel-Salam and Nouh (2016) as follows:

$$\begin{aligned} \begin{aligned} y(x)\simeq&\, 0.2368456765x^{\frac{3}{2}}- 0.02568610429x^{3}\\&+0.005004915254x^{\frac{9}{2}}-0.001292847099x^{6}\\&+0.0004026307151x^{\frac{15}{2}}-\cdots . \end{aligned} \end{aligned}$$

We apply the proposed methods in Section 4, for solving this problem with \(n=10, 15\). In Table 3, we present a comparison of the absolute error of our methods on uniform grid points.

Fig. 4
figure 4

The graph of y(x) using the first method for different values of \(\alpha \) and \(\beta \) with \(n=25\) for Example 3.

Fig. 5
figure 5

The graph of y(x) using the second method for different values of \(\alpha \) and \(\beta \) with \(n=25\) for Example 3.

Fig. 6
figure 6

Plot of the absolute error with \(n=15\), using the first method (left) and the second method (right) for Example 4.

Example 3

In this example, we consider the fractional nonlinear Lane–Emden equation

$$\begin{aligned} D^{\alpha }y(x)+ & {} \frac{6}{x^{\alpha -\beta }}D^{\beta }y(x)\\+ & {} 14y(x)+4y(x)\ln (y(x))=0, \end{aligned}$$

subject to nonhomogeneous initial conditions

$$\begin{aligned} y(0)=1, y'(0)=0. \end{aligned}$$

The exact solution for the problem for \(\alpha =2\) and \(\beta =1\) is \(y(x)=\exp (-x^2)\) (Aminikhah & Moradian 2013). In Table 4, the absolute errors of the presented methods with \(n=7, 14\) and \(\alpha =2,\beta =1\) are compared with those obtained by Laguerre wavelet (Zhou & Xu 2016) and Legendre wavelet (Aminikhah & Moradian 2013) methods. As mentioned in Example 1, the above methods can be reduced to a nonlinear system of algebraic equations while the nonlinear systems corresponding to the present methods are significantly smaller in size. The graphs of absolute error functions of our proposed methods for \(\alpha =2\) and \(\beta =1\) are shown in Figure 3. Also the graphs of computed solution arising from the use of operational matrix of fractional integration or differentiation, for different values of \(\alpha \) and \(\beta \) and for \(n=25\) are illustrated in Figures 4 and 5. These figures tell us that when \(\alpha \) and \(\beta \) are approaching 2 and 1, respectively, the corresponding approximate solutions tend to the solution of the classic Lane–Emden problem with \(\alpha =2\) and \(\beta =1\).

Example 4

Consider the following fractional Lane–Emden equation:

$$\begin{aligned} D^{\alpha }y(x)+\frac{2}{x^{\alpha -\beta }}D^{\beta }y(x)+\sin (y(x))=h(x), \end{aligned}$$

subject to homogeneous initial conditions:

$$\begin{aligned} y(0)=0, y'(0)=0, \end{aligned}$$

where

$$\begin{aligned} h(x)= \sin (x^{3}-x^{2})+\frac{72}{5}\sqrt{\frac{x^3}{\pi }}-\frac{28}{3}\sqrt{\frac{x}{\pi }}. \end{aligned}$$

The exact solution of this problem for \(\alpha =3/2\) and \(\beta =1/2\) is \(y(x)= x^{3}-x^{2}\). The graph of absolute error functions of our numerical approaches with \(n=15\) are plotted in Figure 6.

6 Conclusion

In this research, we derive the operational matrices of fractional integration and differentiation for orthonormal Bernstein polynomials. The operational matrices are used for numerical solution of the singular fractional Lane–Emden equations. Our methods are based on the approximation of functions and collocation approach. The implementation of the present methods is very easy. Moreover, in comparison with existing methods, the high accuracy is clearly documented for both the present methods.

It is worthy to mention here that, the nature of polynomials and the easy and low cost utilization of operational matrices of differentiation and integration over OBP’s puts the present methods as computer-oriented numerical methods. In our methods, by the aid of operational matrices, the complicated fractional derivatives and their calculations reduce to a small system of linear or nonlinear algebraic equations. We also notice that in the first method, we expand \(D^\alpha z(x)\) as Equation (11) and find \(D^\beta z(x)\) and z(x) by integrating from \(D^\alpha z(x)\). Thus, in this method, z(x) will be found from the expansion of \(D^\alpha z(x)\). However, in the second method, we expand the function y(x) by OBP’s, and we find \(D^\alpha z(x)\) and \(D^\beta z(x)\) by differentiation of the expansion of y(x).