Introduction

In recent years, there has been some interest on flows of non-Newtonian fluids where inertial effects are significant. Many materials such as polymer solutions or melts, drilling muds, clastomers, certain oils and greases and many other emulsions are classified as non-Newtonian fluids. The fluids of second and third grade have been studied successfully in various types of flow situations which form a subclass of the fluids of the differential type. The third grade fluid models even for steady flow exhibits such characteristics. Due to the widespread applications such as oil recovery, paper and textile coating, composite manufacturing processes, mixture theory, filtration processes, geothermal engineering and insulation systems, flow through porous media received substantial attention [1, 2].

The present study deals with the problem of non-Newtonian fluid of third grade in a porous half space [3]. For unidirectional flow, Hayat et al. [3] have generalized the relation

$$\begin{aligned} (\nabla p)_x=-\frac{\mu \varphi }{k}\left( 1+\frac{\alpha _1}{\mu }\frac{\partial }{\partial t}\right) u, \end{aligned}$$

for a second grade fluid to the following modified Darcy’s Law for a third grade fluid

$$\begin{aligned} (\nabla p)_x=-\frac{\varphi }{k}\bigg [\mu u+\alpha _1\frac{\partial u}{\partial t}+2\beta _3\left( \frac{\partial u}{\partial y}\right) ^2 u\bigg ], \end{aligned}$$

where u denotes the fluid velocity, \(\mu \) is the dynamic viscosity and p is the pressure. k and \(\varphi \) represent the permeability and porosity of the porous half space which occupies the region \(y>0\), respectively \(\alpha _1\) and \(\beta _3\) are material constants. Defining non-dimensional fluid velocity f and the coordinate z

$$\begin{aligned}&z=\frac{V_0}{\nu }y,\quad f(z)=\frac{u}{V_0},\\&V_0=u(0),\quad \nu =\frac{\mu }{\rho }, \end{aligned}$$

where \(\nu \) and \(V_0\) represent the kinematic viscosity and the boundary value problem, modeling the steady state flow of a third grade fluid in a porous half space, becomes as below such as prime denotes differentiation with respect to z [3]:

$$\begin{aligned}&f''(z)+b_1 {f'(z)}^2 f''(z)-b_2f(z){f'(z)}^2-cf(z)=0,\nonumber \\&f(0)=1,~~\lim _{z\rightarrow \infty }f(z)=0, \end{aligned}$$
(1)

where \(b_1,b_2\) and c are defined as:

$$\begin{aligned} b_1=\frac{6\beta _3{V_0}^4}{\mu \nu ^2},~~~~\qquad b_2=\frac{2\beta _3\varphi {V_0}^2}{k\mu },~~~~\qquad c=\frac{\varphi \nu ^2}{k{V_0}^2}. \end{aligned}$$

Above parameters are depended, whereof

$$\begin{aligned} b_2=\frac{b_1 c}{3}. \end{aligned}$$
(2)

Therefore, we can rewrite Eq. (1) as

$$\begin{aligned}&f''(z)+b_1 {f'(z)}^2 f''(z)-\frac{b_1 c}{3}f(z){f'(z)}^2-cf(z)=0. \end{aligned}$$
(3)

The homotopy analysis method for solution of Eq. (1) is found in [3]. Later Ahmad [4] gave the asymptotic form of the solution and utilize this information to develop a series solution. Recently, authors in [5] solved this problem by radial basis functions.

One of the powerful method for solving the ordinary differential equations (ODEs) is spectral method in both terms of accuracy and simplicity. Spectral methods, in the context of numerical schemes for differential equations, generically belong to the family of weighted residual methods (WRMs) [6]. WRMs represent a particular group of approximation techniques, in which the residuals (or errors) are minimized in a certain way and thereby leading to specific methods including Galerkin, Petrov–Galerkin, collocation and Tau formulations [713].

The basis of spectral method is always polynomials (orthogonal polynomials). These types of basis for approximation of enough smooth functions in finite domain leads to the exponential convergence. Many science and engineering problems arise in unbounded domains. For example the steady flow of a third grade fluid in a porous half space (Eq. (3)). The orthogonal polynomials such as Legendre, Chebyshev, Hermite and Laguerre polynomials can not satisfied the steady property of this type of fluid \(f(\infty )= constant\). Therefore, a number of spectral methods for treating unbounded domains have been proposed by different researchers.

Guo [14, 15] proposed a method that proceeds by mapping the original problem in an unbounded domain to a problem in a bounded domain, and then using suitable Jacobi polynomials to approximate the resulting problems.

There is another effective direct approach for solving such problems is based on rational approximations. Christov [16] and Boyd [17, 18] developed some spectral methods on unbounded intervals by using mutually orthogonal systems of rational functions. Boyd [17] defined a new spectral basis, named rational Chebyshev functions on the semi-infinite interval, by mapping to the Chebyshev polynomials. Guo et al. [19] introduced a new set of rational Legendre functions which are mutually orthogonal in \(L^2(0,+\infty )\). They applied a spectral scheme using the rational Legendre functions for solving the Korteweg-de Vries equation on the half-line. Boyd et al. [20] applied pseudospectral methods on a semi-infinite interval and compared rational Chebyshev, Laguerre and mapped Fourier sine methods.

Authors of [2123], applied spectral method to solve nonlinear ordinary differential equations on semi-infinite intervals. Their approach was based on rational Tau and collocation methods. In Tau method, they obtained the operational matrices of derivative and product of rational Chebyshev and Legendre functions and then applied these matrices together to reduce the solution of these problems to the solution of a system of algebraic equations. The Tau approach is an approximation technique introduced by Lonczos [24] in 1938 to solve differential equations. Tau method is based on expanding the required approximate solution as the elements of a complete set of orthogonal functions. This method may be viewed as a special case of the so-called Petrov–Galerkin method. But, unlike the Galerkin approximation, the expansion functions are not required to satisfy the boundary constraint individually [2530].

In the current paper, our main aim is to apply the Tau method with two basis functions on the semi-infinite interval for solving the steady flow of a third grade fluid in a porous half space and compare the results of them together. Also any discussion on the error analysis of approximation of the function defined in \([0,\infty )\) by rational and exponential Legendre functions have been investigated. In the next section, we obtain an upper bound for estimating the error of function approximation by these basis functions. And then we show that the error of these approximation is superlinear convergence.

The remainder of this paper is organized as follows: “Properties of Rational And Exponential Legendre Functions” Section reviews the desirable properties of two functions that obtain by mapping the Legendre polynomials, namely rational Legendre and exponential Legendre functions. In “Application of the Methods” Section, we apply Tau method with two mentioned functions as basis functions separately to solve the problem. we compare our results together and with numerical solutions in “Results and Discussion” Section. Finally, “Conclusions” Section makes concluding remarks.

Properties of Rational and Exponential Legendre Functions

This section is devoted to the introduction of rational and exponential Legendre functions, that both of them are defined on the semi-infinite interval. Then, the operational matrices of derivative and their product are given.

Rational Legendre Functions

The Legendre polynomials are orthogonal in the interval \([-1, 1]\) with respect to the weight function \(\rho (y)=1\). They can be determined by the following recurrence formula [31]:

$$\begin{aligned}&P_0(y)=1, \qquad P_1(y)= y,\nonumber \\&P_{n+1}(y)=\left( \frac{2n+1}{n+1}\right) yP_{n}(y)-\left( \frac{n}{n+1}\right) P_{n-1}(y),\quad n\ge 1. \end{aligned}$$
(4)

The following Legendre polynomials property can be helped our discussion in the “Function Approximation” Section;

$$\begin{aligned} \int \limits _{-1}^{1}y^m P_n(y)~dy={\left\{ \begin{array}{ll} 0,\qquad \qquad m<n,\\ \\ \frac{2^{n+1}n!^2}{(2n+1)!},\quad n=m. \end{array}\right. } \end{aligned}$$
(5)

The rational Legendre functions, is denoted by \(R_n(x)=P_n\left( \frac{x-L}{x+L}\right) \), where L is a constant parameter and sets the length scale of the mapping. Boyd [32] has offered some guidelines for optimizing the map parameter L.

\(R_n(x)\) satisfies in the following recurrence relation:

$$\begin{aligned}&R_0(x)=1, \qquad R_1(x)=\frac{x-L}{x+L},\nonumber \\&R_{n+1}(x)=\left( \frac{2n+1}{n+1}\right) \left( \frac{x-L}{x+L}\right) R_{n}(x)-\left( \frac{n}{n+1}\right) R_{n-1}(x),\quad n\ge 1. \end{aligned}$$
(6)

By using above recursive formula the first four rational Legendre functions are obtained as below:

$$\begin{aligned} {\left\{ \begin{array}{ll} R_0(x)=1,\\ R_1(x)= \frac{x-L}{x+L},\\ R_2(x)=\frac{3}{2}\left( \frac{x-L}{x+L}\right) ^2-\frac{1}{2},\\ R_3(x)=\frac{5}{2}\left( \frac{x-L}{x+L}\right) ^3-\frac{3}{2}\left( \frac{x-L}{x+L}\right) . \end{array}\right. } \end{aligned}$$
(7)

In Fig. 1 the behavior of these four functions for \(L=1\) are plotted.

Fig. 1
figure 1

Graph of four rational Legendre functions for \(L=1\)

Rational Legendre functions (RL) are orthogonal with respect to the weight function \(w_{r}(x)=\frac{2L}{(x+L)^2}\) in the interval \([0, +\infty )\), with the orthogonality property:

$$\begin{aligned} \int \limits _{0}^{+\infty }{R_n(x)R_m(x)w_{r}(x)dx} = \frac{2}{2n+1}\delta _{nm}, \end{aligned}$$
(8)

where \(\delta _{nm}\) is the Kronecker function.

Exponential Legendre Functions

Exclusive of rational functions we can use exponential transformation to have new functions which are also defined on the semi-infinite interval. The exponential Legendre (EL) functions can be defined by \(E_n(x)=P_n\left( 1-2\mathrm {exp}(-x/L)\right) \), where parameter L is a constant parameter and, like rational functions, it sets the length scale of the mapping.

\(E_n(x)\) satisfies in the following recurrence relation:

$$\begin{aligned}&E_0(x)=1, \qquad E_1(x)=1-2\mathrm {exp}(-x/L),\nonumber \\&E_{n+1}(x)=\left( \frac{2n+1}{n+1}\right) \left( 1-2\mathrm {exp}(-x/L)\right) E_{n}(x)-\left( \frac{n}{n+1}\right) E_{n-1}(x),\quad n\ge 1.\quad \end{aligned}$$
(9)

By using above recursive formula the first four exponential Legendre functions are obtained as below:

$$\begin{aligned} {\left\{ \begin{array}{ll} E_0(x)=1,\\ E_1(x)= 1-2\mathrm {exp}(-x/L),\\ E_2(x)=\frac{3}{2}[1-2\mathrm {exp}(-x/L)]^2-\frac{1}{2},\\ E_3(x)=\frac{5}{2}[1-2\mathrm {exp}(-x/L)]^3-\frac{3}{2}[1-2\mathrm {exp}(-x/L)]. \end{array}\right. } \end{aligned}$$
(10)

In Fig. 2 the behavior of these four functions for \(L=1\) are plotted.

Fig. 2
figure 2

Graph of four exponential Legendre functions for \(L=1\)

Exponential Legendre functions are orthogonal with respect to the weight function \(w_{e}(x)=\frac{2}{L}\mathrm {exp}(-x/L)\) in the interval \([0, +\infty )\), with the orthogonality property, the same as Eq. (8):

$$\begin{aligned} \int \limits _{0}^{+\infty }{E_n(x)E_m(x)w_{e}(x)dx} = \frac{2}{2n+1}\delta _{nm}. \end{aligned}$$
(11)

Function Approximation

Let w(x) is \(w_r(x)\) or \(w_e(x)\) denotes a non-negative, integrable, real-valued function over the interval \(\Lambda =[0,\infty )\). We define

$$\begin{aligned} L^2_w(\Lambda )=\bigg \{v:\Lambda \longrightarrow \mathbb {R}~\bigg | ~v~{\texttt {is\, measurable\, and}}~\Vert v\Vert _w<\infty \bigg \}, \end{aligned}$$

where

$$\begin{aligned} \Vert v\Vert ^2_w=\int \limits _{0}^{+\infty }{v^2(x)~w(x)~dx}, \end{aligned}$$

is the norm induced by the inner product of the space \(L^2_w(\Lambda )\),

$$\begin{aligned} \langle u,v\rangle _w=\int \limits _{0}^{+\infty }{u(x)~v(x)~w(x)~dx}. \end{aligned}$$
(12)

Thus \(\bigg \{\phi _j(x)\bigg \}_{j\ge 0}\), are considered \(\bigg \{R_j(x)\bigg \}_{j\ge 0}\) or \(\bigg \{E_j(x)\bigg \}_{j\ge 0}\), denotes a system which is mutually orthogonal under (12), i.e.,

$$\begin{aligned} \langle \phi _n(x),\phi _m(x)\rangle _w=\frac{2}{2n+1}~\delta _{nm}. \end{aligned}$$

The classical Weierstrass theorem implies that such a system is complete in the space \(L^2_w(\Lambda )\). Thus, for any function \(f(x)\in L^2_w(\Lambda )\) the following expansion holds

$$\begin{aligned} f(x)=\sum \limits _{j=0}^{+\infty }{a_j\phi _j(x)}, \end{aligned}$$
(13)

where

$$\begin{aligned} \qquad \qquad \qquad a_j=\frac{2j+1}{2} \int \limits _{0}^{+\infty }{\phi _j(x)f(x)w(x)dx}. \end{aligned}$$
(14)

If f(x) in Eq. (13) is truncated up to the Nth terms, then it can be written as

$$\begin{aligned} f(x)\simeq f_N(x)=\sum \limits _{j=0}^{N-1}{a_j\phi _j(x)}=A^T\phi (x), \end{aligned}$$
(15)

with

$$\begin{aligned}&A=[a_0, a_1,\ldots , a_{N-1}]^T, \nonumber \\&\phi (x)=R(x)=\bigg [R_0(x),R_1(x),\ldots , R_{N-1}(x)\bigg ]^T \end{aligned}$$
(16)
$$\begin{aligned}&\quad \mathrm {or}\nonumber \\&\phi (x)=E(x)=\bigg [E_0(x),E_1(x),\ldots , E_{N-1}(x)\bigg ]^T. \end{aligned}$$
(17)

Now, we can estimate an upper bound for function approximation in a special case. In first, the error may be defined in the following form

$$\begin{aligned} e_n=\Vert f(x)-f_n(x)\Vert _w^2. \end{aligned}$$
(18)

The completeness of the system \(\bigg \{\phi _i(x)\bigg \}_{i\ge 0}\) is equivalent to the following property

$$\begin{aligned} f_n(x)\longrightarrow f(x),~~~~e_n\longrightarrow 0\qquad {\texttt {as}}\qquad n\longrightarrow \infty . \end{aligned}$$

Lemma 1

The error which is defined in (18) can be rewritten as

$$\begin{aligned} e_n=\sum _{i=n}^{\infty }\frac{2i+1}{2}~\langle f(x),\phi _i(x)\rangle _w^2. \end{aligned}$$
(19)

Proof

The completeness of the system \(\bigg \{\phi _i(x)\bigg \}_{i\ge 0}\) helped us to consider the error as

Using the definition of \(\Vert .\Vert _w\), one has

$$\begin{aligned} e_n=\sum _{i=n}^{\infty }\sum _{j=n}^{\infty }a_ia_j\langle \phi _i(x),\phi _j(x)\rangle _w =\sum _{i=n}^{\infty }\sum _{j=n}^{\infty }a_ia_j\frac{2}{2i+1}~\delta _{ij}= \sum _{i=n}^{\infty }\frac{2a_i^2}{2i+1}. \end{aligned}$$

And using Eq. (14) the Lemma can be proved. \(\square \)

This Lemma shows that the convergence rate is involved with function f(x). Now, by knowing that the function \(f(x)\in L^2_w(\Lambda )\) have some good properties, we could present an upper bound for estimating the error of function approximation by this basis function.

Theorem 1

Let \(f_n(x)\) is function approximation of \(f(x)\in L^2_w(\Lambda )\) obtained by (15) and \(\mathcal {F}(y)=f(\Psi (y))\) is analytic on \([-1,1]\), then an error bound for this approximation can be presented as follows:

$$\begin{aligned} e_n\le \sum _{i=n}^{\infty }\frac{4^{i+1}M_i^2~i!^2}{2(2i)!(2i+1)!} \end{aligned}$$

where

$$\begin{aligned} \Psi (y)=L\frac{1+y}{1-y} \qquad {\texttt {or}} \qquad -L\ln \left( \frac{1-y}{2}\right) , \end{aligned}$$

and \(M_i\)= Max \(|\mathcal {F}^{(i)}(y)|,y\in (-1,1)\).

Proof

We have the following properties for each case of \(\Psi (y)\),

$$\begin{aligned}&{\texttt {Case 1:}}\quad \Psi (y)=L\frac{1+y}{1-y},\quad R_n(\Psi (y))=P_n(y),\\&w_r(\Psi (y))=\frac{(1-y)^2}{2L},\quad dx=\frac{2L}{(1-y)^2}~dy,\nonumber \\&{\texttt {Case 2:}}\quad \Psi (y)=L\ln \left( \frac{2}{1-y}\right) ,\quad E_n(\Psi (y))=P_n(y),\\&w_e(\Psi (y))=\frac{1-y}{L},\quad dx=\frac{L}{1-y}~dy. \end{aligned}$$

By substituting each case in \(\langle f(x),\phi _i(x)\rangle _w\), one has

$$\begin{aligned} \langle f(x),\phi _i(x)\rangle _w=\int \limits _{-1}^{1}\mathcal {F}(y)~P_i(y)~dy. \end{aligned}$$

Also knowing that \(\mathcal {F}(y)\) is analytic, we have

$$\begin{aligned} \langle f(x),\phi _i(x)\rangle _w=\sum _{j=0}^{i-1}\frac{\mathcal {F}^{(j)}(0)}{j!}\int \limits _{-1}^{1}y^jP_i(y)~dy +\frac{\mathcal {F}^{(i)}(\xi _i)}{i!}\int \limits _{-1}^{1}y^iP_i(y)~dy,\quad \xi _i\in (-1,1). \end{aligned}$$

Using the Legendre polynomials property mentioned in Eq. (5), the above equation can be rewritten in the following form

$$\begin{aligned} \langle f(x),\phi _i(x)\rangle _w=\frac{\mathcal {F}^{(i)}(\xi _i)}{i!}\frac{2^{i+1} (i!)^2}{(2i+1)!} \le \frac{2^{i+1} i! M_i }{(2i+1)!}. \end{aligned}$$

The theorem can be proved by substituting above inequality in Eq. (19). \(\square \)

It may be understood from the previous theorem that any function defined in \(L^2_w(\Lambda )\), which their mapping under transformation \(L\frac{1+y}{1-y}\) or \(L\ln \left( \frac{2}{1-y}\right) \) are analytic, has a series solution in the form (15) corresponds to a exponential rate of convergence. But with more discussions, we could get the better result. The next theorem would show that the error defined in Eq. (18) have superlinear convergence. Firstly, we define the order of convergence is called superlinear. Among the several definitions, we choose the following one

Definition 1

\(x_n\longrightarrow \bar{x}\) with superlinear convergence if there is a positive sequence \(\lambda _n\longrightarrow 0\) and an integer number N such that

$$\begin{aligned} |x_{n+1}-\bar{x}|\le \lambda _n|x_{n}-\bar{x}|,\qquad n\ge N. \end{aligned}$$
(20)

Theorem 2

In Theorem 1, let \(M\ge M_i\), then the error is superlinear convergence to zero.

Proof

Using Theorem 1. we have

$$\begin{aligned} e_n\le M^2\sum _{i=n}^{\infty }\frac{4^{i+1}~i!^2}{2(2i)!(2i+1)!}=M^2\sum _{i=n}^{\infty }\frac{4^{i+1}i!~ i!}{2(2i)!!(2i-1)!!(2i+1)!!(2i)!!}, \end{aligned}$$

where \((2i-1)!!=(2i-1)\times (2i-3)\times \cdots \times 3\times 1\) and \((2i)!!=2i\times (2i-2)\times \cdots \times 4\times 2 =2^ii!\). Then one has

$$\begin{aligned} e_n\le 2M^2\sum _{i=n}^{\infty }\frac{1}{(2i-1)!!(2i+1)!!}\le 2M^2\sum _{i=n}^{\infty }\frac{1}{(2i)!}. \end{aligned}$$

We define \(x_n=\sum _{i=n}^{\infty }1/(2i)!\), and then, there is a positive sequence

$$\begin{aligned} \lambda _n=1-\frac{1}{(2n!)\sum _{i=n}^{\infty }\frac{1}{(2i)!}}\longrightarrow 0 \end{aligned}$$

that \(|x_{n+1}|\le \lambda _n|x_{n}|\). Therefore, \(x_n\) and subsequently \(e_n\) are superlinear convergence to zero. \(\square \)

According to Theorem 2, any function defined in \(L^2_w([0,\infty ))\), which their mapping under transformation \(L\frac{1+y}{1-y}\) or \(L\ln \left( \frac{2}{1-y}\right) \) are analytic, has a series solution in the form (15) with the superlinear convergence.

Operational Matrix of Derivative

Derivative Matrix for Rational Legendre Functions

The derivative of the vector R(x) defined in Eq. (16) can be expressed as

$$\begin{aligned} {R}'(x) = \frac{dR}{dx} \simeq D_{r}R(x), \end{aligned}$$
(21)

where \(D_{r}\) is the \(N \times N\) operational matrix for the derivative. Differentiating Eq. (6), we have:

$$\begin{aligned}&{R}'_0(x)=0,\nonumber \\&{R}'_1(x)=\frac{1}{L}\left[ \frac{2}{3}R_{0}(x)-R_{1}(x)+\frac{1}{3}R_{2}(x)\right] , \nonumber \\&{R}'_{n+1}(x)=\frac{2n+1}{n+1}(R_{n}(x)\cdot R_{1}(x))'-\frac{n}{n+1}{R}'_{n-1}(x),\quad n\ge 1. \end{aligned}$$
(22)

The matrix \(D_{r}\) can be calculated by using Eq. (22). Authors of [21] obtained that this matrix is a lower?-Hessenberg matrix and can be expressed as \(D_{r}=\frac{1}{L}(D_1+D_2)\); where \(D_1\) is a tridiagonal matrix with below form:

$$\begin{aligned} D_1 = diag~\left( ~\frac{7i^{2}-i-2}{2(2i+1)},~-i,~\frac{i(i+1)}{2(2i+1)}~\right) ,\quad i=0,\ldots ,N-1, \end{aligned}$$

and the \(d_{ij}\) elements of matrix \(D_2\) are obtained from

$$\begin{aligned} d_{ij} = {\left\{ \begin{array}{ll} 0, &{}\quad j \ge i-1 \\ (-1)^{i+j+1}(2j+1), &{}\quad j < i-1. \end{array}\right. } \end{aligned}$$
(23)

For \(N=6\), we have

$$\begin{aligned} D_{r} = \frac{1}{L} \left( \begin{array}{c@{\quad }c@{\quad }c@{\quad }c@{\quad }c@{\quad }c} \quad 0 &{}\quad 0 &{}\quad 0 &{}\quad 0 &{}\quad 0 &{}\quad 0\\ \quad \frac{2}{3} &{} -1 &{}\quad \frac{1}{3} &{} \quad 0 &{} \quad 0 &{}\quad 0\\ -1 &{} \quad \frac{12}{5} &{} -2 &{}\quad \frac{3}{5} &{}\quad 0 &{}\quad 0 \\ \quad 1 &{} -3 &{} \quad \frac{29}{7} &{} -3 &{} \quad \frac{6}{7} &{} \quad 0\\ -1 &{} \quad 3 &{} -5 &{} \quad \frac{53}{9} &{} -4 &{}\quad \frac{10}{9}\\ \quad 1 &{} -3 &{}\quad 5 &{} -7 &{}\quad \frac{84}{11} &{} -5\\ \end{array} \right) . \end{aligned}$$

Derivative Matrix for Exponential Legendre Functions

The derivative of the vector E(x) defined in Eq. (17) can be expressed as

$$\begin{aligned} {E}'(x) = \frac{dE}{dx} = D_{e}E(x), \end{aligned}$$
(24)

where \(D_{e}\) is the \(N \times N\) operational matrix for the derivative. Differentiating the Eq. (9), we get:

$$\begin{aligned}&{E}'_0(x)=0,\nonumber \\&{E}'_1(x)=\frac{1}{L}\left[ E_{0}(x)-E_{1}(x)\right] , \nonumber \\&{E}'_{n+1}(x)=\frac{2n+1}{n+1}(E_{n}(x)\cdot E_{1}(x))'-\frac{n}{n+1}{E}'_{n-1}(x),\quad n\ge 1. \end{aligned}$$
(25)

By using Eq. (25), the matrix \(D_{e}\) can be generated. The matrix \(D_{e}\) is a lower-triangular matrix and can be expressed as \(D_{e}=\frac{1}{L}(\widehat{D_1}+\widehat{D_2})\); where \(\widehat{D_1}\) is a diagonal matrix which is obtained from

$$\begin{aligned} \widehat{D_1} = diag~(-i), ~~~~~~~~~~~i=0,\ldots ,N-1, \end{aligned}$$

and \(\widehat{D_2}\) is exactly equal to \(D_2\), Eq. (23).

for \(N=6\), we have

$$\begin{aligned} D_{e} = \frac{1}{L} \left( \begin{array}{c@{\quad }c@{\quad }c@{\quad }c@{\quad }c@{\quad }c} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ \quad 1 &{} -1 &{} \quad 0 &{} \quad 0 &{} \quad 0 &{} \quad 0\\ -1 &{} \quad 3 &{} -2 &{} \quad 0 &{}\quad 0 &{}\quad 0 \\ \quad 1 &{} -3 &{} \quad 5 &{} -3 &{}\quad 0 &{}\quad 0\\ -1 &{} \quad 3 &{} -5 &{} \quad 7 &{} -4 &{} \quad 0\\ \quad 1 &{} -3 &{} \quad 5 &{} -7 &{} \quad 9 &{} -5\\ \end{array} \right) . \end{aligned}$$

As it can be seen, the form of above matrix is simpler than that of the derivation matrix for R(x). In addition, \(D_{e}\) is a lower-triangular matrix but \(D_{r}\) is a lower-Hessenberg matrix, so more zero elements exists in \(D_{e}\). Consequently, it can be computed faster. In the other hand, the truncated derivative matrix of \(D_{e}\) exactly satisfies Eq. (24), but \(D_{r}\) doesn’t have this property. Therefore, the accuracy of the exponential Legendre functions is better to approximate the function derivatives in \([0,\infty )\).

The Product Operational Matrix

Product Matrix for Rational Legendre Functions

The following property of the product of two rational Legendre function vectors will also be applied:

$$\begin{aligned} R(x) R^T(x) A \simeq \tilde{A}R(x), \end{aligned}$$
(26)

where \(\tilde{A}\) is an \(N \times N\) product operational matrix for the vector A. Using Eq. (26) and by the orthogonal property Eq. (8), the elements \(\tilde{A}_{ij}, (i=0,\ldots ,N-1,j=0,\ldots ,N-1)\) of the matrix \(\tilde{A}\) can be calculated from

$$\begin{aligned} \tilde{A}_{ij}=\left( j+\frac{1}{2}\right) \sum _{k=0}^{N-1}a_k g_{ijk}, \end{aligned}$$
(27)

where \(g_{ijk}\) is given by

$$\begin{aligned} g_{ijk}=\int \limits _0^{+\infty }{R_{i}(x)R_{j}(x)R_{k}(x)w_{r}(x)dx}. \end{aligned}$$

Also, the product of two rational Legendre functions, \(R_i(x)\) and \(R_j(x)\), can be approximated as below [33]:

$$\begin{aligned} R_i(x)R_j(x)=\sum _{l=0}^{j}\frac{d_{j-l}d_{l}d_{i-l}}{d_{i+j-l}}\left( \frac{2i+2j-4l+1}{2i+2j-2l+1}\right) R_{i+j-2l}(x), \end{aligned}$$
(28)

where \(d_l\) is obtained by the below formula

$$\begin{aligned} d_{l}=\frac{(2l)!}{2^l(l!)^2},\quad j<i. \end{aligned}$$

Multiplying Eq. (28) by \(R_k(x)w_r(x)\) integrating from 0 to \(+\infty \) and using the orthogonal property, we have

$$\begin{aligned} g_{ijk}={\left\{ \begin{array}{ll}\frac{2 d_{j-l}d_{l}d_{i-l}}{(2i+2j-2l+1)d_{i+j-l}},&{}\quad k=i+j-2l; \quad l=0,1,\ldots ,j,\\ 0,&{}\quad k\ne i+j-2l; \quad l=0,1,\ldots ,j. \end{array}\right. } \end{aligned}$$
(29)

Product Matrix for Exponential Legendre Functions

For the product of the two exponential Legendre function vectors we also have:

$$\begin{aligned} E(x) E^T(x) A \simeq \tilde{A}E(x), \end{aligned}$$
(30)

in which the elements \(\tilde{A}_{ij}\) of the matrix \(\tilde{A}\) are obtained similar to Eq. (27), such as \(g_{ijk}\) is computed the same as Eq. (29).

Application of the Methods

In this part, we apply the Tau method with rational Legendre and exponential Legendre functions as basis functions for solving the steady flow of a third grade fluid in a porous half space, Eq. (3), with initial conditions of Eq. (1).

We consider \(\phi (z)=R(z)\) in below formulas to apply rational Legendre Tau method (RLT) and assume \(\phi (z)=E(z)\) for using exponential Legendre Tau method (ELT) and approximate the problem.

We express f(z) and \(f^{(j)}(z)\) as below

$$\begin{aligned}&f(z)\simeq f_N(z)=\sum \limits _{i=0}^{N-1}{a_i \phi _i(z)} = A^T \phi (z), \end{aligned}$$
(31)
$$\begin{aligned}&f^{(j)}(z)\simeq f_N^{(j)}(z)=\sum \limits _{i=0}^{N-1}{a_i {\phi _i}^{(j)}(z)} \simeq A^T D^j \phi (z) ~~~~~ j=1,2,3, \end{aligned}$$
(32)

where \(D^j\) is the jth power of the matrix \(D_{r}\) or \(D_{e}\) given in Eqs. (21) or (24).

By using Eqs. (31) and (32), we have

$$\begin{aligned} {f_N'(z)}^2 f_N''(z)\simeq & {} A^T D \phi (z)\phi ^T(z) D^T A \phi ^T(z)(D^2)^T A \nonumber \\= & {} A^T D \phi (z)\phi ^T(z) U \phi ^T(z) V = A^T D \tilde{U}\tilde{V} \phi (z), \end{aligned}$$
(33)
$$\begin{aligned} f_N(z){f_N'(z)}^2\simeq & {} A^T \phi (z) \phi ^T(z) D^T A \phi ^T(z) D^T A \nonumber \\= & {} A^T \phi (z) \phi ^T(z) U \phi ^T(z) U = A^T \tilde{U} \tilde{U} \phi (z), \end{aligned}$$
(34)

where \(U = D^T A\), \(V = (D^2)^T A\) and the matrices \(\tilde{U}\) and \(\tilde{V}\) can be calculated similarly to Eqs. (26) or (30).

The functions M(z) for Eq. (3), can be constructed by using Eqs. (3134). So we have:

$$\begin{aligned} M(z) = \left[ A^T D^2 + b_1 A^T D \tilde{U} \tilde{V} - \frac{b_1 c}{3} A^T \tilde{U} \tilde{U} - c A^T\right] \phi (z). \end{aligned}$$

Similar to the typical Tau method [26, 34] we generate \((N-2)\) algebraic equations by applying

$$\begin{aligned} \langle M(z),\phi _k(z)\rangle = \int \limits _{0}^{+\infty }{M(z) \phi _k(z) w(z) dz} = 0, ~~~k=0,1,\ldots ,N-3, \end{aligned}$$
(35)

where w(z) is \(w_{r}(z)\) or \(w_{e}(z)\).

Using Eq. (31) for the boundary conditions in Eq. (1) and we have:

$$\begin{aligned} f_N(0) = A^T \phi (0)= 1,~~~~\lim _{z\rightarrow +\infty }f_N(z)=\lim _{z\rightarrow +\infty }A^T \phi (z)= 0. \end{aligned}$$
(36)

Equations (35) and (3) generate a set of N nonlinear algebraic equations. Consequently, the unknown coefficients \(a_i\)’s of the vector A in Eq. (31) can be calculated.

Results and Discussion

In this section, the numerical results of the model equation presented in Eq. (3), obtained by using RLT and ELT methods. In this problem, the first derivative at zero \((f'(0))\) is an important point for the numerical solution. In Table 1, the resulting values of \(f'(0)\) that obtained by using the RLT and ELT methods with \(N = 10\) and \(L = 4\) are presented for some various values of \(b_1\) and c. In this Table we made comparison between present methods and numerical solutions which are obtained by shooting method. The Table shows a good agreement between two present methods and numerical solutions. But, as can be seen, ELT method gives us results with higher degree of accuracy than RLT method. By rational functions, we could reach to the same results of accuracy as ELT method if N be considered more than 17. So using exponential Legendre functions, provide an effective but simple way to improve the convergence of the solution by Tau method. Also, this Table shows that for constant value of c, an increase in \(b_1\) leads to a rise in \(b_2\) (by using Eq. (2)), \(f'(0)\) and the velocity. This result is obviously appeared in Figs. 3 and 4. In the other hand, with constant value of \(b_1\) and the increase in c, \(f'(0)\) and the velocity decrease. Subsequently, Figs. 5 and 6 represent the velocity distribution for the various values of the parameter c. Therefore, increasing or decreasing the value of \(b_2\) has no effect on velocity.

Table 1 Comparison \(f'(0)\) of problem obtained by RLT, ELT, with shooting method solution by various parameters \(b_1\) and c
Fig. 3
figure 3

Variation of the velocity distribution for the various values of \(b_1\) and \(c=0.5\) obtained by rational Legendre Tau method

Fig. 4
figure 4

Variation of the velocity distribution for the various values of \(b_1\) and \(c=0.5\) obtained by exponential Legendre Tau method

Fig. 5
figure 5

Variation of the velocity distribution for the various values of c and \(b_1=0.6\) obtained by rational Legendre Tau method

Fig. 6
figure 6

Variation of the velocity distribution for the various values of c and \(b_1=0.6\) obtained by exponential Legendre Tau method

Tables 2 and 3 show the comparison of results for f(z) obtained by two proposed methods and the numerical solution where \(b_1=0.6\) and \(c=0.5\) and 0.9, respectively. The relative errors in these Tables show that by using exponential Legendre functions, we get higher accurate solution than using rational functions for approximate this problem.

Table 2 Comparison of f(z) for problem, between RLT, ELT and Runge–Kutta solution when \(b_1=0.6\) and \(c=0.5\) with \(N=10\)
Table 3 Comparison of f(z) for problem, between RLT, ELT and Runge–Kutta solution when \(b_1=0.6\) and \(c=0.9\) with \(N=10\)

Logarithmic graphs of absolute coefficients \(|a_i|\) of RLT and ELT functions in the approximate solutions for \(b_1=0.6\) and \(c=0.5\) and 0.9, are shown in Figs. 7 and 8, respectively. These graphs illustrate that the methods have an appropriate convergence rate by small N.

To show the accuracy of this method and give a comparison between rational and exponential Legendre Tau methods, we define the residual functions by using Eq. (3) as

$$\begin{aligned} Res(z)=f_N''(z)+b_1 {f_N'(z)}^2 f_N''(z)-b_2f_N(z){f_N'(z)}^2-cf_N(z). \end{aligned}$$
Fig. 7
figure 7

Logarithmic graph of absolute coefficients \(|a_i|\) of the rational Legendre functions when \(b_1=0.6\)

Fig. 8
figure 8

Logarithmic graph of absolute coefficients \(|a_i|\) of the exponential Legendre functions when \(b_1=0.6\)

Now by defining the Eduction norm of Res(z) and knowing that \(Res(z) \in \mathbf {RL}^{M}\) or \(\mathbf {EL}^{M}\), where the maximum value of \(M=3N+1\) and

$$\begin{aligned}&\varvec{RL}^M={\texttt {span}}\bigg \{R_{0}(z),R_{1}(z) ,\ldots ,R_{M}(z)\bigg \},\\&\varvec{EL}^M={\texttt {span}}\bigg \{E_{0}(z),E_{1}(z) ,\ldots ,E_{M}(z)\bigg \}. \end{aligned}$$

We can determine \(\Vert Res\Vert _w^2\) by the well-known Gauss quadrature formulation in the forms of

$$\begin{aligned}&\Vert Res\Vert _w^2=\int \limits _{0}^{\infty }{Res^2(z)}~w(z)dz=\sum _{i=0}^{M} w_i{Res^2(z_i)},\\&z_i=L~\frac{s_i+1}{1-s_i},\quad w_i=\frac{2L}{z_i(z_i+L)^2 \big (R_{M+1}'(z_i)\big )^2},\qquad {\texttt {Rational\, Legendre}},\\&z_i=-L~\ln \bigg (\frac{1-s_i}{2}\bigg ),\quad w_i=\frac{2}{L^2 (\mathrm e^{\frac{z_i}{L}}-1)\big (E_{M+1}'(z_i)\big )^2},\quad {\texttt {Exponential\,Legendre}} \end{aligned}$$

and \(s_i\) are zero of \(M+1\)-order of Legendre polynomial.

Figures 9 and 10 show the logarithmic graphs of the \(\Vert Res\Vert _w^2\) at \(b_1=0.6\) and \(c=0.5\) and 0.9 for rational and exponential Legendre Tau methods. These graphs illustrate the accuracy of the methods. Furthermore, they show that the accuracy of the ELT method is better than ELT method in this problem. Also in Figs. 11 and 12 the logarithmic graphs of the \(\Vert Res\Vert _w^2\) of ELT methods by \(N=10\) and various values of L are shown. These figures illustrate the interval that we can choose for L parameter to get applicable result. That is why we select \(L=4\) for solving this problem.

Fig. 9
figure 9

Graph of \(\Vert Res\Vert ^2\) by RLT and ELT methods when \(b_1=0.6\) and \(c=0.5\)

Fig. 10
figure 10

Graph of \(\Vert Res\Vert ^2\) by RLT and ELT methods when \(b_1=0.6\) and \(c=0.9\)

Fig. 11
figure 11

Graph of \(\Vert Res\Vert ^2\) of ELT methods by \(N=10\) and various L when \(b_1=0.6\) and \(c=0.5\)

Fig. 12
figure 12

Graph of \(\Vert Res\Vert ^2\) of ELT methods by \(N=10\) and various L when \(b_1=0.6\) and \(c=0.9\)

Conclusions

In present study, the steady flow of the third grade fluid in a porous half space, is considered. Based on modified Darcys law, the flow over a suddenly moved flat plate is discussed numerically by using the operational matrices of derivative and product of rational and exponential Legendre functions together with the Tau method. The influence of various values of parameters \(b_1,~b_2\) and c on the velocity profile has been seen. It’s clear that for constant value of \(b_2\), there is a direct relation between \(b_1\) and the velocity.