1 Introduction

Recently, fractional initial and boundary value problems have been studied extensively. Several forms of them have been proposed in standard models, and there has been a significant interest in developing numerical schemes for their solutions. Several numerical techniques, such as Laplace and Fourier transforms [1, 2], Adomian decomposition and variational iteration methods [3, 4], eigenvector expansion [5], differential transform and finite differences methods [6, 7], power series method [8], residual power series method [912], collocation method [13], operational matrix of fractional integration method [14, 15], and wavelet method [16, 17], are used to solve such problems. Many applications of fractional calculus to various branches of science such as engineering, physics and economics can be found in [18, 19]. Considerable attention has been given to the theory of fractional ordinary differential equations and integral equations [20, 21]. Additionally, the existence of solutions of ordinary and fractional boundary value problems using monotone iterative sequences has been investigated by several authors [2225]. Some applications are discussed by Singh et al. [26]. They analyze a new fractional model of chemical kinetics system related to a newly discovered Atangana-Baleanu derivative with fractional order having nonsingular and nonlocal kernel. Also, Singh et al. [27] presented a reliable algorithm based on the local fractional homotopy perturbation. Moreover, Singh et al. [28] proposed a new numerical algorithm, namely q-homotopy analysis Sumudu transform method (q-HASTM), to obtain the approximate solution for the nonlinear fractional dynamical model of interpersonal and romantic relationships.

A reproducing kernel Hilbert space method (RKHSM) is a useful framework for constructing approximate solutions of linear and nonlinear boundary value problems. In recent years, a lot of attention has been devoted to the study of RKHSM to investigate various scientific models. The RKHSM, which accurately computes the series solution, is of great interest to applied sciences. This technique gives the solution in a rapidly convergent series with components that can be easily computed. We use the RKHSM to solve this problem since it is easy to implement and it gives very accurate results. This method is used for the investigation of several scientific applications, see [2932] and [3335]. Kumar et al. [36] presented a new numerical scheme based on a combination of q-homotopy analysis approach and Laplace transform approach to examine the Fitzhugh-Nagumo (F-N) equation of fractional order. Kumar et al. [37] constituted a numerical algorithm based on the fractional homotopy analysis transform method to study the fractional model of Lienard’s equations. Baleanu et al. [3844] considered the exact solutions of wave equations by the help of the local fractional Laplace variation iteration method (LFLVIM). They developed an iterative scheme for the exact solutions of local fractional wave equations (LFWEs).

In this paper, we discuss how to solve the following class of second-order fractional Emden-Fowler problems:

$$ D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)+h(x)g \bigl(u(x)\bigr)=f(x),\quad x\in (0,1), \frac{1}{2}< \alpha \leq 1, $$
(1.1)

subject to

$$ u(0)=a,\qquad D^{\alpha }u(0)=b, $$
(1.2)

where a and b are constants. When \(\alpha =1\), \(\lambda =2\), and \(h(x)=1 \), Eq. (1.1) becomes the Lane-Emden type equation. With some special forms of \(g(u(x))\), they describe many phenomena in mathematical physics and astrophysics such as the thermal behavior of a spherical cloud of gas, theory of stellar structure, theory of thermionic currents, and isothermal gas spheres. We use the RKHSM to solve it. We derive the reproducing kernel and the RKHSM. In addition, we prove the existence and uniform convergence of the approximate solution using this approach. Error estimation for our approximation is proved. Moreover, some numerical examples are presented in Section 6 to show the efficiency of the proposed method.

We organize this paper as follows. In Section 2, we present some preliminaries which we use in this paper. In Section 3, we construct the reproducing kernel with fractional shifted Legendre polynomial form. In Section 4, we present the RKHSM for solving a second-order fractional Emden-Fowler problem. Convergence and error estimate of the proposed method are presented in this section. In Section 5, we present an iterative method to solve the second-order fractional nonlinear Emden-Fowler problem. This iterative method is a combination of the homotopy perturbation method and the RKHSM. Some numerical results are presented in Section 6 to illustrate the efficiency of the presented method. Finally, we conclude with some comments and conclusions in Section 7.

2 Preliminaries

In this section, we review the definition and some preliminary results of Caputo fractional derivatives as well as the definition of fractional shifted Legendre functions and their properties.

Definition 2.1

The Riemann-Liouville fractional integral operator \(I^{\alpha }\) of order \(\alpha >0\) on the usual Lebesgue space \(L_{1}[0,1]\) is given by

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

where \(\Gamma (\zeta )=\int_{0}^{\infty }t^{\zeta -1}e^{-t}\,dt\) is the Euler gamma function, see [18, 45, 46].

For any \(f\in L_{1}[0,1]\), \(\alpha ,\beta \geqslant 0\), and \(\gamma >-1\), \(I^{\alpha }\) exists for any \(x\in [ 0,1]\) and

$$ I^{\alpha }x^{\gamma }=\frac{\Gamma (\gamma +1)}{\Gamma (\alpha +\gamma +1)}x^{\alpha +\gamma }. $$
(2.1)

Definition 2.2

The Caputo fractional derivative of order α is defined by

$$ D^{\alpha }f(x)=I^{n-\alpha }D^{n}f(x)=\frac{1}{\Gamma (n-\alpha )}\int _{0}^{x}\frac{f^{(n)}(t)}{(x-t)^{\alpha -n+1}}\,dt $$

provided that the integral exists, where \(n= [ \alpha ] +1\), \([ \alpha ] \) is the integer part of the positive real number \(\alpha ,x>0\).

The Caputo fractional derivative satisfies the following properties for \(f\in L_{1}[0,1]\) and \(\alpha ,\beta \geqslant 0\):

$$ I^{\alpha }D^{\alpha }f(x)=f(x)-\sum _{k=0}^{n-1}f^{(k)}\bigl(0^{+} \bigr)\frac{x^{k}}{k!} $$
(2.2)

and

$$ D^{\alpha }x^{\beta }=\frac{\Gamma (\beta +1)}{\Gamma (\beta -\alpha +1)}x^{\beta -\alpha }. $$
(2.3)

The basic concept of this paper is Legendre polynomials. For this reason, we study some of their properties.

Definition 2.3

The Legendre polynomials \(\{\ell_{k}(x):k=0,1,2,\ldots \} \) are the eigenfunctions of the Sturm-Liouville problem

$$ \bigl(\bigl(1-x^{2}\bigr)\ell_{k}^{\prime }(x) \bigr)^{\prime }+k(k+1)\ell_{k}(x)=0,\quad x\in [ -1,1]. $$

In order to use these polynomials on the interval \([0,1]\), we define the shifted Legendre polynomials by \(\ell S_{i}(x)=\ell_{i}(2x-1)\). It is easy to see that

$$ \int_{0}^{1}\ell S_{i}(z) \ell S_{j}(z)\,dz=\frac{1}{2i+1}\delta _{ij}, $$

where \(\delta _{ij}= \bigl\{ \scriptsize{ \begin{array}{l@{\quad}l} 1 , & i=j \\ 0 , & i\neq j\end{array}}\). In this paper, we use orthonormal fractional shifted Legendre functions which are defined by \(S_{i}(x)=\sqrt{(2i+1)\alpha } S\ell_{i}(x^{\alpha })\), \(i=0,1,2,\ldots\) . Then

$$ \int_{0}^{1}S_{i}(x) S_{j}(x) x^{\alpha -1}\,dx=\delta _{ij}. $$

The reproducing kernel Hilbert space method is a useful numerical technique to solve nonlinear problems. The reproducing kernel is given by the following definition.

Definition 2.4

Let A be a nonempty abstract set. A function \(K:A\times A\rightarrow C\) is a reproducing kernel of the Hilbert space H if and only if

  • \(K(\cdot,x)\in H\) for all \(x\in A\),

  • \((\phi (\cdot),K(\cdot,x))=\phi (x)\) for all \(x\in A\) and \(\phi \in H\).

The second condition is called the reproducing property, and a Hilbert space which possesses a reproducing kernel is called a reproducing kernel Hilbert space (RKHS).

3 Construction of a reproducing kernel with fractional shifted Legendre functions form

Let

$$ \Omega =\operatorname{Span}\bigl\{ S_{0}(x),S_{1}(x),\ldots,S_{n}(x) \bigr\} $$

be the set of all orthonormal fractional shifted Legendre functions of degree \(\leq n\alpha \) with the following inner product:

$$ \bigl(u(y),v(y)\bigr)= \int_{0}^{1}u(y)v(y)y^{\alpha -1}\,dy $$

and the norm

$$ \Vert u \Vert \sqrt{\bigl(u(y),u(y)\bigr)}. $$

It is easy to see that Ω is a Hilbert space. In the next theorem, we show that Ω is a reproducing kernel space, and we present its reproducing kernel.

Theorem 3.1

Ω is a reproducing kernel space, and its reproducing kernel is

$$ K_{n}(x,y)=\sum_{i=0}^{n}S_{i}(x)S_{i}(y). $$
(3.1)

Proof

If \(u(x)\in \Omega \), then

$$ u(x)=\sum_{i=0}^{n}\alpha _{i}S_{i}(x). $$

Thus, for any \(y\in [ 0,1]\),

$$ K_{n}(\cdot,y)=\sum_{i=0}^{n}S_{i}(y)S_{i}( \cdot)\in \Omega $$

and

$$\begin{aligned} \bigl(u(x),K_{n}(x,y)\bigr) =&\Biggl(\sum _{i=0}^{n}\alpha _{i}S_{i}(x), \sum_{j=0}^{n}S_{j}(x)S_{j}(y) \Biggr) \\ =&\sum_{i=0}^{n}\sum _{j=0}^{n}\alpha _{i}S_{j}(y) \bigl(S_{i}(x),S_{j}(y)\bigr) \\ =&\sum_{i=0}^{n}\sum _{j=0}^{n}\alpha _{i}S_{j}(y) \\ =&u(y), \end{aligned}$$

which completes the proof. □

4 Analysis of RKHSM for a second-order fractional linear initial Emden-Fowler problem

In this section, we discuss how to solve the following class of second-order fractional linear initial Emden-Fowler problems:

$$ D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)=f(x), \quad x\in (0,1), \frac{1}{2}< \alpha \leq 1, $$
(4.1)

subject to

$$ u(0)=0,\qquad D^{\alpha }u(0)=0. $$
(4.2)

Let

$$ Lu(x)=D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x). $$

Then L is a linear operator. Let \(\{ x_{1},x_{2},\ldots,x_{n} \} \) be n nodes of nodes in the interval \([0,1]\). In this paper, we choose

$$ x_{j}=\frac{1+\cos (\frac{\pi j}{n})}{2},\quad j=1,2,\ldots n. $$

Let

$$ \psi _{i}(x)=L_{\eta }K_{n}(x,\eta )_{\shortmid _{\eta =x_{i}}} $$

for \(i=1,2,\ldots,n\), \(\psi _{n+1}(x)=S_{n+1}(x)\), and \(\psi _{n+2}(x)=S_{n+2}(x)\). Using the Gram-Schmidt orthonormalization to generate orthonormal basis \(\{ \overset{\_}{\psi }_{i}(x) \} _{i=1}^{n+2}\) of Ω, we have

$$ \overset{\_}{\psi }_{i}(x)=\sum _{j=1}^{i}\alpha _{ij}\psi _{j}(x), $$
(4.3)

where \(\alpha _{ij}\) are the coefficients of Gram-Schmidt orthonormalization, \(\alpha _{ii}>0\), \(i=1,2,\ldots,n+2\). In the next theorem, we show the existence of solution of Problem (4.1)-(4.2).

Theorem 4.1

The approximate solution of Problem (4.1)-(4.2) is given by

$$ u_{n}(x)=\sum_{i=1}^{n} \sum_{j=1}^{i}\alpha _{ij}f(x_{j})\overset{\_}{\psi }_{i}(x)+\gamma _{1}\overset{\_}{\psi }_{n+1}(x)+\gamma _{2}\overset{\_}{\psi }_{n+2}(x). $$
(4.4)

Proof

From Eq. (4.3) and from the fact that \(K_{n}(x,\eta )\) is a reproducing kernel and \(Lu(\eta )=f(\eta )\), we get

$$\begin{aligned} u_{n}(x) =&\sum_{i=1}^{n+2} \bigl(u(x),\overset{\_}{\psi }_{i}(x)\bigr)\overset {\_}{ \psi }_{i}(x) \\ =&\sum_{i=1}^{n}\bigl(u(x),\overset{\_}{ \psi }_{i}(x)\bigr)\overset{\_}{\psi }_{i}(x)+ \bigl(u(x),\overset{\_}{\psi }_{n+1}(x)\bigr)\overset{\_}{\psi }_{n+1}(x)+\bigl(u(x),\overset{\_}{\psi }_{n+2}(x) \bigr)\overset{\_}{\psi }_{n+2}(x) \\ =&\sum_{i=1}^{n}\Biggl(u(x),\sum _{j=1}^{i}\alpha _{ij}L_{\eta }K_{n}(x, \eta )_{\shortmid _{\eta =x_{j}}}\Biggr)\overset{\_}{\psi }_{i}(x)+ \bigl(u(x),\overset{\_}{\psi }_{n+1}(x)\bigr)\overset{\_}{ \psi }_{n+1}(x)\\ &{}+\bigl(u(x),\overset{\_}{\psi }_{n+2}(x)\bigr)\overset{\_}{\psi }_{n+2}(x) \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}L_{\eta } \bigl(u(x),K_{n}(x,\eta )_{\shortmid _{\eta =x_{j}}}\bigr)\overset{\_}{\psi }_{i}(x)+\bigl(u(x),\overset{\_}{\psi }_{n+1}(x) \bigr)\overset{\_}{\psi }_{n+1}(x)\\ &{}+\bigl(u(x),\overset{\_}{ \psi }_{n+2}(x)\bigr)\overset{\_}{\psi }_{n+2}(x) \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}L_{\eta }\bigl(u( \eta )\bigr)_{\shortmid _{\eta =x_{j}}}\overset{\_}{\psi }_{i}(x)+\bigl(u(x),\overset{ \_}{\psi }_{n+1}(x)\bigr)\overset{\_}{\psi }_{n+1}(x)+\bigl(u(x),\overset{\_}{\psi }_{n+2}(x) \bigr)\overset{\_}{\psi }_{n+2}(x) \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{j}) \overset{\_}{\psi }_{i}(x)+\gamma _{1}\overset{ \_}{\psi }_{n+1}(x)+\gamma _{2}\overset {\_}{\psi }_{n+2}(x), \end{aligned}$$

where \(\gamma _{1}=(u(x),\overset{\_}{\psi }_{n+1}(x))\) and \(\gamma _{2}=(u(x),\overset{\_}{\psi }_{n+2}(x))\). To find \(\gamma _{1}\) and \(\gamma _{2}\), we set

$$ u_{n}(0)=D^{\alpha }u_{n}(0)=0. $$

Next, we want to prove that \(u_{n}(x)\) is a solution to Eqs. (4.1)-(4.2) at \(x_{i}\) for \(i=1,2,\ldots,n\). For any \(k\in \{1,2,\ldots,n\}\),

$$\begin{aligned} Lu_{n}(x_{k}) =&\sum_{i=1}^{n} \sum_{j=1}^{i}\alpha _{ij}f(x_{k})L_{x} \overset{\_}{\psi }_{i}(x)_{\shortmid _{\eta =xk}}+\gamma L_{x} \overset{\_}{\psi }_{n+1}(x)_{\shortmid _{\eta =x_{k}}} \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k})L_{x} \bigl(\overset{\_}{\psi }_{i}(\eta ),K_{n}(x, \eta )_{\shortmid _{\eta =x_{k}}}\bigr)+\gamma L_{x}\bigl(\overset{\_}{\psi }_{n+1}(\eta ),K_{n}(x,\eta )_{\shortmid _{\eta =x_{k}}}\bigr) \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k}) \bigl(\overset{\_}{\psi }_{i}(\eta ),L_{x}K_{n}(x, \eta )_{\shortmid _{\eta =x_{k}}}\bigr)+\gamma \bigl(\overset{\_}{\psi }_{n+1}(\eta ),L_{x}K_{n}(x,\eta )_{\shortmid _{\eta =k}}\bigr) \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k}) \bigl(\overset{\_}{\psi }_{i}(\eta ),\psi _{k}( \eta )\bigr)_{\shortmid _{\eta =x_{k}}}+\gamma \bigl(\overset{\_}{\psi }_{n+1}(\eta ),\psi _{k}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}}. \end{aligned}$$

Then, for any \(m\in \{1,2,\ldots,n\}\),

$$\begin{aligned} \sum_{l=1}^{m}\alpha _{ml }Lu_{n}(x_{k}) =&\sum_{l=1}^{m}\alpha _{ml } \Biggl[ \sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k}) \bigl(\overset{\_}{\psi }_{i}(\eta ),\psi _{k}( \eta )\bigr)_{\shortmid _{\eta =x_{k}}} \\ &{}+\gamma _{1}\bigl(\overset{\_}{\psi }_{n+1}(\eta ),\psi _{k}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}}+\gamma _{2}\bigl(\overset{ \_}{\psi }_{n+2}(\eta ),\psi _{k}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}}\Biggr] \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k}) \Biggl(\overset{\_}{\psi }_{i}(\eta ),\sum _{l=1}^{m}\alpha _{ml }\psi _{k}( \eta )\Biggr)_{\shortmid _{\eta =x_{k}}} \\ &{}+\gamma _{1}\Biggl(\overset{\_}{\psi }_{n+1}(\eta ),\sum _{l=1}^{m}\alpha _{ml }\psi _{k}(\eta )\Biggr)_{\shortmid _{\eta =x_{k}}}+\gamma _{2}\Biggl( \overset{\_}{\psi }_{n+2}(\eta ),\sum _{l=1}^{m}\alpha _{ml }\psi _{k}( \eta )\Biggr)_{\shortmid _{\eta =x_{k}}} \\ =&\sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}f(x_{k}) \bigl(\overset{\_}{\psi }_{i}(\eta ),\overset{\_}{\psi }_{m}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}} \\ &{}+\gamma _{1}\bigl(\overset{\_}{\psi }_{n+1}(\eta ), \overset{\_}{\psi }_{m}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}}+\gamma _{2}\bigl(\overset{\_}{\psi }_{n+2}(\eta ),\overset{\_}{\psi }_{m}(\eta )\bigr)_{\shortmid _{\eta =x_{k}}} \\ =&\sum_{i=1}^{m}\alpha _{mj}f(x_{k}) \delta _{im}, \end{aligned}$$

where \(\delta _{ij}= \bigl\{\scriptsize{ \begin{array}{l@{\quad}l} 1, & i=j \\ 0, & i\neq j\end{array}} \bigr\} \). This implies that

$$ Lu_{n}(x_{k})=f(x_{k}) $$

for \(k=1,2,\ldots,n\). □

In the next theorem, we present the error estimate of our approximation.

Theorem 4.2

Let \(u_{n}(x)\) be the approximate solution of Eq. (4.1) in the space Ω and \(u(x)\) be the exact solution of Eq. (4.1). If \(\{ x_{i} \} _{i=1}^{n}\) is n nodes in \([0,1]\) and \(f(x)\in C^{4}[0,1]\), then

$$ \sup_{x\in [ 0,1]} \bigl\Vert u(x)-u_{n}(x) \bigr\Vert \leq Ch^{3}, $$

where C is constant and

$$ h=\max_{i\in \{1,2,\ldots,n-1\}} \vert x_{i+1}-x_{i} \vert . $$

Proof

Let

$$ R_{n}(x)=Lu_{n}(x)-f(x). $$

From Theorem 4.1, we see that

$$ R_{n}(x_{i})=0 $$

for \(i=1,2,\ldots,n\). Using Roll’s theorem, we get

$$ R_{n}^{\prime }(y_{i})=0,\quad y_{i}\in (x_{i},x_{i+1}), i=1,2,\ldots,n-1, $$

and

$$ R_{n}^{\prime \prime }(z_{i})=0,\quad z_{i}\in (y_{i},y_{i+1}), i=1,2,\ldots,n-2. $$

Let \(l_{i}(x)\) be an interpolating polynomial of degree 1 of \(R_{n}^{\prime \prime }(x)\) at \(z_{1}\) and \(z_{i+1}\), where \(i\in \{1,2,\ldots,n-2\}\). Then \(l\equiv 0\) on \([z_{i},z_{i+1}]\). Then there exists \(\zeta _{i}\in [ x_{i},z_{i+1}]\) and a constant \(\omega _{i}\) such that

$$ R_{n}^{\prime \prime }(x)=R_{n}^{\prime \prime }(x)-l_{i}(x)= \frac{R^{(4)}(\zeta _{i})}{2}(x-z_{i}) (x-z_{i+1})\leq \omega _{i}h^{2},\quad x\in [ x_{i},z_{i+1}]. $$

Thus,

$$ \sup_{x\in [ 0,1]} \bigl\Vert R_{n}^{\prime \prime }(x) \bigr\Vert \leq \omega h^{2}, $$

where \(\omega =\max \{\omega _{1},\omega _{2},\ldots,\omega _{n-2}\}\). Hence,

$$ R_{n}^{\prime }(x)= \int_{y_{i}}^{x}R_{n}^{\prime \prime }(t)\,dt, \quad x\in [ x_{i},x_{i+1}],i=1,2,\ldots,n-1, $$

which implies that

$$ \bigl\vert R_{n}^{\prime }(x) \bigr\vert \leq \sup _{x\in [ 0,1]} \bigl\Vert R_{n}^{\prime \prime }(x) \bigr\Vert \vert x-y_{i} \vert \leq \omega h^{2}h=\omega h^{3}. $$

Moreover,

$$ R_{n}(x)= \int_{x_{i}}^{x}R_{n}^{\prime }(v)\,dv, \quad x\in [ x_{i},x_{i+1}],i=1,2,\ldots,n-1, $$

which implies that

$$ \bigl\vert R_{n}(x) \bigr\vert \leq \sup_{x\in [ 0,1]} \bigl\Vert R_{n}^{\prime \prime }(x) \bigr\Vert \vert x-x_{i} \vert \leq \omega h^{3}h=\omega h^{4}. $$

Thus,

$$ \sup_{x\in [ 0,1]} \bigl\Vert R_{n}(x) \bigr\Vert \leq \omega h^{4}. $$

Now,

$$\begin{aligned} \bigl\Vert R_{n}(x) \bigr\Vert _{1}^{2}&=R_{n}^{2}(0)+ \int_{0}^{1}R_{n}^{\prime 2}(x)\,dx \\ &\leq \omega h^{8}+\omega ^{2}h^{6}\leq \kappa ^{2}h^{6} \end{aligned}$$

for some positive constant κ. Thus,

$$\begin{aligned} \bigl\Vert u(x)-u_{n}(x) \bigr\Vert _{\Omega } =& \bigl\Vert L^{-1}R_{n}(x) \bigr\Vert _{\Omega } \\ \leq & \bigl\Vert L^{-1} \bigr\Vert _{\Omega } \bigl\Vert R_{n}(x) \bigr\Vert _{1} \\ \leq & \bigl\Vert L^{-1} \bigr\Vert _{\Omega } \kappa h^{3}=\varrho h^{3}, \end{aligned}$$

where \(\varrho = \Vert L^{-1} \Vert _{\Omega } \kappa \). Then

$$ \sup_{x\in [ 0,1]} \bigl\Vert u(x)-u_{n}(x) \bigr\Vert \leq ch^{3}. $$

In case that the initial condition is given by

$$ u(0)=a\quad \text{and}\quad D^{\alpha }u(0)=b, $$

we use the following change of variable:

$$ y(x)=u(x)-a-bx^{\alpha }. $$

Thus, our problem becomes

$$ D^{2\alpha }y(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }y(x)=g(x),\quad x\in (0,1), 0< \alpha (x)< 1, $$

subject to

$$ y(0)=D^{\alpha }y(0)=0, $$

where \(g(x)=f(x)+\frac{b \lambda }{x^{\alpha }}\). Then we apply the procedure which is described in this section. □

5 Analysis of RKHSM for the second-order fractional nonlinear initial Emden-Fowler problem

In this section, we discuss how to solve the following class of second-order fractional nonlinear initial Emden-Fowler problems:

$$ D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)+h(x)g \bigl(u(x)\bigr)=f(x),\quad x\in (0,1), \frac{1}{2}< \alpha \leq 1, $$
(5.1)

subject to

$$ u(0)=a,\qquad D^{\alpha }u(0)=b. $$
(5.2)

Let

$$ \Psi (x,u)=h(x)g\bigl(u(x)\bigr). $$

We construct a homotopy as follows:

$$ H(u,\kappa )=D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)-f(x)+ \kappa \Psi (x,u)=0, $$
(5.3)

where \(\kappa \in [ 0,1]\) is an embedding parameter. If \(\kappa =0\), we get a linear equation

$$ D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)-f(x)=0 $$

which can be solved by using RKHSM as we described in the pervious section. If \(\lambda =1\), it turns out to be Problem (4.1). Following the homotopy perturbation method [47], we expand the solution in terms of the homotopy parameter κ as

$$ u=u_{0}+\kappa u_{1}+\kappa ^{2}u_{2}+\kappa ^{3}u_{3}+\cdots. $$
(5.4)

Substitute Eq. (5.4) into Eq. (5.3) and equate the coefficients of identical powers of λ to get the following system:

$$\begin{aligned} \kappa ^{0} :&D^{2\alpha }u_{0}(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u_{0}(x)-f(x) =0,\quad u_{0}(0)=a, D^{\alpha }u_{0}(0)=b, \\ \kappa ^{1} :&D^{2\alpha }u_{1}(x)+ \frac{\lambda }{x^{\alpha }}D^{\alpha }u_{1}(x)=-\Psi \Biggl(x,\sum _{i=0}^{\infty }\kappa ^{i}u_{i} \Biggr)\biggm| _{\kappa =0} ,\quad u_{1}(0)=D^{\alpha }u_{0}(0)=0, \\ \kappa ^{2} :&D^{2\alpha }u_{2}(x)+ \frac{\lambda }{x^{\alpha }}D^{\alpha }u_{2}(x)=-\frac{d\Psi (x,\sum_{i=0}^{\infty }\kappa ^{i}u_{i})}{d\kappa }\biggm| _{\kappa =0} ,\quad u_{2}(0)=D^{\alpha }u_{2}(0)=0, \\ \kappa ^{3} :&D^{2\alpha }u_{3}(x)+ \frac{\lambda }{x^{\alpha }}D^{\alpha }u_{3}(x)=-\frac{d^{2}\Psi (x,\sum_{i=0}^{\infty }\kappa ^{i}u_{i})}{d\kappa ^{2}}\biggm| _{\kappa =0} ,\quad u_{3}(0)=D^{\alpha }u_{3}(0)=0, \\ &\vdots \\ \kappa ^{k} :&D^{2\alpha }u_{k}(x)+ \frac{\lambda }{x^{\alpha }}D^{\alpha }u_{k}(x)=-\frac{d^{k-1}\Psi (x,\sum_{i=0}^{\infty }\kappa ^{i}u_{i})}{d\kappa ^{k-1}}\biggm| _{\kappa =0} ,\quad u_{k}(0)=D^{\alpha }u_{k}(0)=0. \end{aligned}$$

To solve the above equations, we use the RKHSM which is described in the previous section, and we obtain

$$ u_{k}(\eta )=\sum_{i=1}^{\infty } \sum_{j=1}^{i}\alpha _{ij}w_{k}(x_{j}) \overset{\_}{\psi }_{i}(x), \quad k=0,1,2,\ldots, $$
(5.5)

where

$$\begin{aligned} w_{0}(x) =&f(x) \\ w_{1}(x) =&-\Psi \Biggl(x,\sum_{i=0}^{\infty } \kappa ^{i}u_{i}\Biggr)\biggm| _{\kappa =0} \\ &\vdots \\ w_{k}(x) =&-\frac{d^{k-1}\Psi (x,\sum_{i=0}^{\infty }\kappa ^{i}u_{i})}{d\kappa ^{k-1}}\biggm| _{\kappa =0},\quad k=2,3,\ldots. \end{aligned}$$

From Eq. (5.4), it is easy to see that the solution to Problem (5.1)-(5.2) is given by

$$ u(x)=\sum_{k=0}^{\infty }u_{k}(x) =\sum_{k=0}^{\infty } \Biggl( \sum _{i=1}^{\infty }\sum_{j=1}^{i} \alpha _{ij}w_{k}(x_{j})\overset{\_}{\psi }_{i}(x) \Biggr) . $$
(5.6)

We approximate the solution of Problem (5.1)-(5.2) by

$$ u_{N,M}(x)=\sum_{k=0}^{m} \Biggl( \sum_{i=1}^{n}\sum _{j=1}^{i}\alpha _{ij}w_{k}(x_{j}) \overset{\_}{\psi }_{i}(x) \Biggr) . $$
(5.7)

6 Results and discussion

In this section, we apply the fractional shifted Legendre functions reproducing kernel method outlined in the previous sections to solve numerically the following five examples. Note that the maximum number of terms in the series is \(M=15\). Let the absolute error be defined by

$$ e_{\alpha }= \underset{x\in [ 0,1]}{\max } \biggl\vert D^{2\alpha }u(x)+\frac{\lambda }{x^{\alpha }}D^{\alpha }u(x)+h(x)g \bigl(u(x)\bigr)-f(x) \biggr\vert . $$

Example 6.1

Consider the following second-order fractional Emden-Fowler problem:

$$ D^{2\alpha }u(x)+\frac{1}{x^{\alpha }}D^{\alpha }u(x)-u(x)=0, \quad x\in (0,1), $$
(6.1)

subject to

$$ u(0)=1,\qquad D^{\alpha }u(0)=0. $$
(6.2)

The graphs of the approximate solutions for different values of α are given in Figure 1. The absolute error obtained by the presented method is shown in Table 1.

Figure 1
figure 1

The graphs of the approximate solutions for different values of α for Example  6.1 .

Table 1 Absolute error of Example 6.1

Example 6.2

Consider the following second-order fractional Emden-Fowler problem:

$$ D^{2\alpha }u(x)+\frac{1}{x^{\alpha }}D^{\alpha }u(x)+2u^{3}(x)=0, \quad x\in (0,1), $$
(6.3)

subject to

$$ u(0)=0.1,\qquad D^{\alpha }u(0)=0. $$

The graphs of the approximate solutions for different values of α are given in Figure 2. The absolute error obtained by the presented method is shown in Table 2.

Figure 2
figure 2

The graphs of the approximate solutions for different values of α for Example  6.2 .

Table 2 Absolute error of Example 6.2

Example 6.3

Consider the following second-order fractional Emden-Fowler problem:

$$ D^{2\alpha }u(x)+\frac{1}{x^{\alpha }}D^{\alpha }u(x)-u^{3}(x)+3u^{3}(x)=0, \quad x\in (0,1), $$
(6.4)

subject to

$$ u(0)=0.5,\qquad D^{\alpha }u(0)=0. $$
(6.5)

The graphs of the approximate solutions for different values of α are given in Figure 3. The absolute error obtained by the presented method is shown in Table 3.

Figure 3
figure 3

The graphs of the approximate solutions for different values of α for Example  6.3 .

Table 3 Absolute error of Example 6.3

Example 6.4

Consider the following second-order fractional Emden-Fowler problem:

$$ D^{2\alpha }u(x)+\frac{2}{x^{\alpha }}D^{\alpha }u(x)- \bigl(6+4x^{2\alpha }\bigr)u(x)=6-6x^{2\alpha }-4x^{4\alpha },\quad x \in (0,1), $$
(6.6)

subject to

$$ u(0)=0.7,\qquad D^{\alpha }u(0)=0. $$
(6.7)

The graphs of the approximate solutions for different values of α are given in Figure 4. The absolute error obtained by the presented method is shown in Table 4.

Figure 4
figure 4

The graphs of the approximate solutions for different values of α for Example  6.4 .

Table 4 Absolute error of Example 6.4

Example 6.5

Consider the following second-order fractional Emden-Fowler problem:

$$ D^{2\alpha }u(x)+\frac{4}{x^{\alpha }}D^{\alpha }u(x)- \bigl(18+9x^{4\alpha }\bigr)u(x)=20-36x^{3\alpha }-18x^{6\alpha }, \quad x\in (0,1), $$
(6.8)

subject to

$$ u(0)=1,\qquad D^{\alpha }u(0)=0. $$
(6.9)

The graphs of the approximate solutions for different values of α are given in Figure 5. The absolute error obtained by the presented method is shown in Table 5.

Figure 5
figure 5

The graphs of the approximate solutions for different values of α for Example  6.5 .

Table 5 Absolute error of Example 6.5

7 Conclusions

In this paper, we study the second-order fractional Emden-Fowler problem. The reproducing kernel Hilbert space method (RKHSM) is employed to compute an approximate solution to the proposed problem. The construction of the reproducing kernel based on the orthonormal shifted Legendre polynomials is presented. The validity of the RKHSM is ascertained by presenting five of our examples. It is worth mentioning that we get the same results as those in Wazwaz [48] for Examples 6.3-6.5 when \(\alpha =1\). We prove the existence of solution of the second-order fractional Emden-Fowler problem. The convergence of the approximate solution using the proposed method is investigated. The uniform convergence of the approximate solution to the exact solution is presented. Error estimation to the proposed method is proven. The results reveal that the proposed analytical method can achieve excellent results in predicting the solutions of such problems.