INTRODUCTION

It is well known that solutions of boundary value problems for differential equations with small perturbation parameters having higher derivatives may exhibit a boundary-layer behavior [3, 15, 36]. Thistype of BVPs has many applications in mathematical modelling of physical and engineering problems, such as fluid dynamics at high Reynolds nos. [1], [12], [20], aerodynamics [31], massheat transfer [30], atmospheric models [32] and in reaction-diffusion process [20].

Nowadays boundary layer problems are addressed mainly with numerical techniques. A large number of numerical techniques have been proposed by various authors for singularly perturbed boundary value problem (SPBVPs). Finite difference approximations on nonuniform grids have been investigated in [14], [33] and [35]. Numerical approximations and solutions for SPBVPs have been discussed in [2] and [28]. Theory and applications of singular perturbations in boundary-layer problems and multiple timescale dynamics have been reported in [36]. To deal with the steep solutions regions, two different forms of computational nonuniform grids by dividing the region intotwo or more with different uniform spacing were discussed in [29] for boundary-layer problems. Since the early 1960s several numerical approaches have been developed by various authors to address SPBVPs. Due to the presence of boundary layers the numerical treatment of SPBVPs has computational difficulties. Central finite difference schemes on uniformly distributed grids are usually applied to solve SPBVPs numerically. However, in many cases, unphysical oscillations are observed in the numerical solutions [2, 3]. Finite difference schemes on uniform grids are relatively simple, but they are not accurate and efficient for problems with boundary layers, because of the potential appearance of numerical oscillations. If the number of points is not large enough to resolve the boundary layer, the numerical solution is likely to have huge errors. The use of a large number of grid points to resolve this problem makes the total computation time unacceptably large. To eliminate the oscillations in the solutions, one needs a very fine grid at the layer regions. This may be improved either by using nonuniform grids (prescribed) or by an adaptive grid (generated by an additional equation). Finite difference approximations on nonuniform grids have been discussed in [2, 28, 33, 35, 36] for SPBVPs. At the beginning of the 90’s, special piecewise uniform grids have been introduced by Shishkin [25], in which simple structured grids can be used for the numerical approximation of SPBVPs. All these numerical approaches on nonuniform grids are more accurate than for the uniform case but with the same order of convergence. A truncation error analysis introduced by the use of nonuniform grids and stretched coordinates for the numerical study of the boundary-layer problems has been reported in [14, 17, 22, 37] in which numerical results are compared with that obtained on uniform grids. In [24, 26, 27] a stretched grid method was introduced in which the given boundary-layer problems are transformed into new coordinates by a smooth mapping which concentrates the grid points in the steep regions without an increase of the total number of grid nodes. This concentration improved the spatial resolution in the region of large variation which enhanced the accuracy in numerical solutions.

Adaptive grid methods, graded grid difference schemes and uniformly accurate finite difference approximations for SPBVPs have been presented in [5, 10, 11]. The rate of convergence of finite difference schemes on nonuniform grids and super convergent grids for two point BVPs have been described in [816, 38]. Further, finite difference approximations of multidimensional steady and unsteady convection-diffusion-reaction problems have been discussed in [9, 18, 19]. All these numerical approaches on nonuniform grids are more accurate than for the uniform case but with the same order of convergence. The supra-convergence phenomena of the central finite difference scheme is well-known and it was studied rigorously. In literature, the increase from second to higher order accuracy for linear boundary value problems has been reported in [6] and recently in [21]. Second order central finite differences on nonuniform grids are discussed in [21], in which an adaptive numerical method is applied to obtain 4th-order of convergence.

In the present study, we first focus on special central finite difference approximations on an optimal choice of the nonuniform grid which demonstrate not only higher order of convergence (from 2nd order to 4th order) but also an increase in the accuracy for nonlinear SPBVPs. We present two theoretical properties of the solution of the SPBVPs, which exhibit boundary layer phenomena. The main contributions in this paper, is first to construct the exact optimal higher order nonuniform grid transformations based on truncation error analysis. Further, we use these (optimal) grid transformation to compute the numerical solution of nonlinear SPBVPs. In second part, the goal is to propose an efficient adaptive numerical method which can be solve approximately such SPBVPs with an accuracy independent of the value of the perturbation parameter. We extend the results from 4th to 6th order approximations not only for linear BVPs, but we are also able to obtain an (almost) 6th order accuracy for nonlinear models. For this, we propose a nonuniform equidistributed grid and show that the second order central finite difference scheme is substantially upgraded to sixth order on this refined grid. This supra-convergence is obtained by using an appropriate monitor function, which depends on the lowest derivative. For numerical illustration, we choose nonlinear convection dominated singularly perturbed convection-diffusion-reaction problems which exhibit boundary layer(s) phenomena. Numerical results demonstrate the effectiveness of the proposed methods for obtaining higher order of convergence.

The present article is organized as follows: a convection dominated SPBVP is presented in Section 1. Theoretical observations of the considered SPBVP are presented in Section 2. Finite difference approximations on uniform grids are described in Section 3. In Section 4, we develop the higher order nonuniform grid transformation in which general central finite difference scheme on nonuniform grids and the coordinate transformation for the SPBVPs are provided in Sections 4.1 and 4.2 respectively. In Section 4.3, a local truncation error analysis of the discretized system to construct the 4th order nonuniform grids is explained. To establish the adaptive sixth order nonuniform grid, the equidistribution principle is presented in Section 5.1. Further, in Section 5.2, numerical results for different choices of nonuniform grids, are discussed. Finally, we summarize our results in Section 6.

1. CONVECTION-DIFFUSION-REACTION MODEL

Consider the following convection dominated singularly perturbed boundary value problem (SPBVP):

$$\begin{gathered} \epsilon u{\kern 1pt} ''(x) + [g(u(x))]{\kern 1pt} ' + f(u(x)) = 0,\quad x \in [0,1],\quad 0 < \epsilon < 1, \\ u(0) = \alpha ,\quad u(1) = \beta \\ \end{gathered} $$
((1))

with a small positive perturbation parameter ε and parameters \(\alpha ,\beta \geqslant 0\). We assume that there exists a unique solution for model (1). Note, however, that multiple solutions may exist for specific choices of the functions \(f\) and \(g\) (see [39] or [4]). Furthermore, we may expect boundary layers in the solution as well. For \(g{\kern 1pt} '(u) > 0\) and \(0 < \epsilon \ll 1\), problem (1) has a unique solution and exhibits a boundary layer of \(\mathcal{O}(\epsilon )\) near \(x = 0\), whereas, for \(f(u) = 0\) and \(g{\kern 1pt} '(u) < 0\), this occurs at \(x = 1\).

2. THEORETICAL OBSERVATIONS

In this section, we would like to advertise two new theoretical results connected with a generalized version of model (1):

$$\begin{gathered} \epsilon [D(u(x))u{\kern 1pt} '{\kern 1pt} (x)]{\kern 1pt} ' + [g(u(x))]{\kern 1pt} ' + f(u(x)) = 0,\quad x \in [{{x}_{L}},{{x}_{R}}],\quad 0 < \epsilon \ll 1, \\ u({{x}_{L}}) = \alpha ,\quad u({{x}_{R}}) = \beta . \\ \end{gathered} $$
((2))

where, additionally, we assume that \(D(u) > 0,\;D{\kern 1pt} '(u) \geqslant 0\) and \(g{\kern 1pt} '(u) > 0\). The results are generalizations of the ones obtained in [4]. Therein, the authors consider the special case \(D = 1\), \(g(u) = 2u\) and \(f(u) = {{e}^{u}}\).

Theorem 1.For the choice\(\alpha = \beta \geqslant 0\), the solution \(u(x)\) of model (2), assuming it exists, has a unique maximum (no minimum).

Proof. Suppose first that \(u\) is constant, i.e., \(u(x) = \alpha ,\)\(\forall x \in [{{x}_{L}},{{x}_{R}}]\). This solution satisfies the boundary conditions, but not differential Eq. (2), since \(f(u(x)) = f(\alpha ) > 0\). Therefore, \(u(x)\) must have interior extreme values. At such an extremum, say at \(x = \gamma \), we have \(u{\kern 1pt} '(\gamma ) = 0\) and, using the chain rule, we find

$$\varepsilon D{\kern 1pt} '(u(\gamma ))u'(\gamma ) + \varepsilon D(u(\gamma ))u{\kern 1pt} ''(\gamma ) + g{\kern 1pt} '(u(\gamma ))u{\kern 1pt} '(\gamma ) + f(u(\gamma )) = 0.$$

From this follows that

$$\epsilon D(u(\gamma ))u{\kern 1pt} ''(\gamma ) = - f(u(\gamma )) < 0.$$

As a consequence, the curvature of the solution is negative and, at \(x = \gamma \), we find a maximum value. There can not be further maxima, since that would imply the existence of at least one minimum, which is not possible with \(u{\kern 1pt} ''(\gamma ) < 0\). Conclusion: there is only one maximum. \(\square \)

Theorem 2.Assume that\(g{\kern 1pt} '(u) > 0\). For \(\epsilon \downarrow 0\), we find the following asymptotic expression for the solution derivative at the right boundary point of model (2):

$$u{\kern 1pt} '({{x}_{R}}) = - \frac{{f(\beta )}}{{g{\kern 1pt} '(\beta )}} - \epsilon \frac{{f(\beta )}}{{{{{[g{\kern 1pt} '(\beta )]}}^{4}}}}{\text{\{ }}D{\kern 1pt} '(\beta ){{[f(\beta )]}^{2}}g{\kern 1pt} '(\beta ) + D(\beta )[f(\beta )g{\kern 1pt} ''(\beta ) + f{\kern 1pt} '(\beta )g{\kern 1pt} '(\beta )]{\text{\} }} + O({{\epsilon }^{2}}).$$

Proof. Since we are only interested in the solution near \(x = {{x}_{R}}\), i.e., away from the boundary layer near \(x = {{x}_{L}}\), we may use the regular expansion: \(u(x) = {{u}_{0}}(x) + \epsilon {{u}_{1}}(x) + \mathcal{O}({{\epsilon }^{2}})\). Applying the expansion \(f(u) = f({{u}_{0}}) + \epsilon {{u}_{1}}(x)f{\kern 1pt} '({{u}_{0}}) + \mathcal{O}({{\epsilon }^{2}})\), and similar ones for \(f{\kern 1pt} '(u)\), \(g(u)\), \(D(u)\), \(D{\kern 1pt} '(u)\) and \(g{\kern 1pt} '(u)\), respectively, and collecting terms of equal power in \(\varepsilon \), we arrive at

$$\begin{gathered} {{\epsilon }^{0}}\,:\quad g{\kern 1pt} '({{u}_{0}})u_{0}^{'} + f({{u}_{0}}) = 0,\quad {{u}_{0}}({{x}_{R}}) = \beta , \\ {{\epsilon }^{1}}\,:\quad D{\kern 1pt} '({{u}_{0}}){{[u_{0}^{'}]}^{2}} + D({{u}_{0}})u_{0}^{{''}} + g{\kern 1pt} '({{u}_{0}})u_{1}^{'} + {{u}_{1}}g{\kern 1pt} ''({{u}_{0}})u_{0}^{'} + {{u}_{1}}f{\kern 1pt} ''({{u}_{0}}) = 0,\quad {{u}_{1}}({{x}_{R}}) = 0, \\ etcetera \ldots \\ \end{gathered} $$

From the first equation immediately follows

$$u_{0}^{'}({{x}_{R}}) = - \frac{{f(\beta )}}{{g{\kern 1pt} '(\beta )}}.$$

Using this result and the fact that \({{u}_{0}}({{x}_{R}}) = \beta \) and \({{u}_{1}}({{x}_{R}}) = 0\), we can derive

$$u_{0}^{{''}}({{x}_{R}}) = - \frac{{f{\kern 1pt} '(\beta )g{\kern 1pt} '(\beta ) - f(\beta )g{\kern 1pt} ''(\beta )}}{{[g{\kern 1pt} '{{{(\beta )}}^{2}}]}}u_{0}^{'}({{x}_{R}}).$$

Substituting this expression in the second equation, gives

$$u_{1}^{'}({{x}_{R}}) = - \frac{{f(\beta )}}{{{{{[g{\kern 1pt} '(\beta )]}}^{4}}}}{\text{\{ }}D{\kern 1pt} '(\beta ){{[f(\beta )]}^{2}}g{\kern 1pt} '(\beta ) + D(\beta )[f(\beta )g{\kern 1pt} ''(\beta ) + f{\kern 1pt} '(\beta )g{\kern 1pt} '(\beta )]{\text{\} }}.$$

Next, we note that the equation has a stable slow manifold \(M\) with an \(\mathcal{O}({{\epsilon }^{2}})\) approximation by the manifold \({{M}_{0}}\) described by \({{u}_{0}}(x) + \epsilon {{u}_{1}}(x)\). This observation can be found by applying Fenichel’s geometric perturbation theory (for more details, see [4, 36]).This implies that, away from the boundary layer at \(x = {{x}_{L}}\), we find near \(x = {{x}_{R}}\):

$$u(x) = {{u}_{0}}(x) + \epsilon {{u}_{1}}(x) + \mathcal{O}({{\epsilon }^{2}}),\quad {\text{and}}\quad u{\kern 1pt} '(x) = u_{0}^{'}(x) + \epsilon u_{1}^{'}(x) + \mathcal{O}({{\epsilon }^{2}}).$$

When choosing \(x = {{x}_{R}}\), the results follows.

In Table 1 we illustrate this for the special case with \(\alpha = \beta = 0\), \({{x}_{L}} = 0\), \({{x}_{R}} = 1\), \(f(u) = {{e}^{u}}\), \(g(u) = 2u\) and \(D = 1\) (as in [4]). Then the result in Theorem 2 predicts that \(u_{0}^{'}(1) = - 1{\text{/}}2\) and \(u_{1}^{'}(1) = - 1{\text{/}}8\) and \(u{\kern 1pt} '(1) = - 1{\text{/}}2 - \epsilon {\text{/}}8 + \mathcal{O}({{\epsilon }^{2}})\). Table 1 confirms this asymptotic behavior.

Table 1.   Asymptotic results for special choices of the functions and parameters in Theorem 2

3. DISCRETIZATIONS ON UNIFORM GRIDS

To compute numerical solutions of (1) we first work out a standard finite difference scheme by discretizing the differential equation and boundary conditions. Subdivide the continuous spatial interval \(I = [0,1]\) into a uniformly distributed discrete set of grid points \({\text{\{ }}{{x}_{j}}{\text{\} }}_{{j = 0}}^{J}\), i.e., \({{x}_{j}} = jh,\)\(j = 0,...,J\) with grid size \(h = \tfrac{1}{J}\). With \({{u}_{j}} \approx u({{x}_{j}})\), a three point central finite difference discretization of (1) is then given by

$$\epsilon \frac{{{{u}_{{j + 1}}} - 2{{u}_{j}} + {{u}_{{j - 1}}}}}{{{{h}^{2}}}} + \frac{{g({{u}_{{j + 1}}}) - g({{u}_{{j - 1}}})}}{{2h}} + f({{u}_{j}}) = 0,\quad j = 1,...,J - 1$$
((3))

with boundary conditions \({{u}_{0}} = 0,\)\({{u}_{J}} = 1\). This scheme has second order accuracy:

$$\tau = - \frac{{{{h}^{2}}}}{2}u_{j}^{{''''}} + O({{h}^{4}}).$$
((4))

This may cause the standard uniform-grid technique to be computationally inefficient, in situations where the solution possesses steep parts. In those cases, to obtain an accurate numerical approximation, a very large number of grid points should be used (or, similarly, a very small \(h\)). To clarify this phenomenon, we consider \(f(u) = 0\) and \(g(u) = u\) in model (1). Then the finite difference approximation (3) becomes

$$\epsilon \frac{{{{u}_{{j + 1}}} - 2{{u}_{j}} + {{u}_{{j - 1}}}}}{{{{h}^{2}}}} + \frac{{{{u}_{{j + 1}}} - {{u}_{{j - 1}}}}}{{2h}} = 0,\quad j = 1,...,J - 1.$$
((5))

An exact numerical solution of (5) can be found [28] and reads

$${{u}_{j}} = \frac{{{{{\left( {\tfrac{{1 + {{P}_{e}}}}{{1 - {{P}_{e}}}}} \right)}}^{j}} - 1}}{{{{{\left( {\tfrac{{1 + {{P}_{e}}}}{{1 - {{P}_{e}}}}} \right)}}^{J}} - 1}},\quad j = 1,...,J - 1,$$

where \({{P}_{\epsilon }}: = \tfrac{h}{{2\epsilon }}\) denotes the mesh-Peclet number. It can easily be checked that, for \(J < \tfrac{1}{{2\epsilon }}\), i.e., \({{P}_{e}} > 1\), the numerical solution exhibits an unwanted oscillatory behavior (see also Fig. 3), whereas, for \(J > \tfrac{1}{{2\epsilon }}\), i.e., \(0 < {{P}_{e}} < 1\), monotone numerical solutions are obtained. In the case that \(0 < \epsilon \ll 1\), this means that we would need \(J \gg 1\) (or \(h \ll 1\)) to satisfy the monotonicity conditions. It is obvious that this leads to an inefficient numerical process. Another straightforward discretization is given by an upwind approximation of the first derivative in (1) with \(g(u) = u\) and \(f(u) = 0\):

$$\epsilon \frac{{{{u}_{{j + 1}}} - 2{{u}_{j}} + {{u}_{{j - 1}}}}}{{{{h}^{2}}}} + \frac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{h} = 0,\quad j = 1,...,J - 1.$$
((6))

Again, we can find an exact numerical solution [28] of this system:

$${{u}_{j}} = \frac{{{{{(1 + {{P}_{e}})}}^{j}} - 1}}{{{{{(1 - {{P}_{e}})}}^{J}} - 1}},\quad j = 1,...,J - 1.$$

For this method, we always have \(1 + {{P}_{e}} > 1\) and, therefore, obtain a monotone solution, independent of the value of \({{P}_{e}}\) (see Fig. 3). However, the error now is reduced to first order, i.e., \(\mathcal{O}(h)\).

Fig. 1.
figure 1

Behavior of the exact numerical solutions (5) and (6), depending on the parameter \({{P}_{e}}\), for the case \(f(u) = 0\) and \(g(u) = u\). We show the oscillatory behavior when \({{P}_{e}} > 1\) (left panel) and smooth solutions when \(0 < {{P}_{e}} < 1\) (right panel).

4. FOURTH-ORDER NONUNIFORM GRID GENERATION

To generate the nonuniform grid for model (1), we follow the following steps:

Step 1. Discretize problem (1) on a nonuniform grid.

Step 2. Transform the discretized system from the physical coordinate \(x\) to a computational coordinate \(\xi \).

Step 3. Construct the optimal nonuniform grid transformation \(x(\xi )\) based on a local truncation error analysis of the discretized system.

Step 4. Compute the solution of the discretized system of problem (1) on the optimal nonuniform grid.

4.1. Discretizations on Nonuniform Grids

In order to deal with the appearance of steep boundary layers in the given model (1), nonuniformly distributed grids could be used to obtain more efficient and more accurate numerical solutions. An example of a nonuniform discretization of the first derivative in (1) is given by

$$u_{j}^{'} \approx \frac{{{{u}_{{j + 1}}} - {{u}_{{j - 1}}}}}{{2{{h}_{j}}}}.$$

Similarly, the second derivative can be approximated by

$$u_{j}^{{''}} \approx \frac{{\tfrac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \tfrac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}}}{{{{h}_{j}}}},$$

where the \({{h}_{j}}\)’s are computed as:

$$p: = {{x}_{{j + 1}}} - {{x}_{j}},\quad q: = {{x}_{j}} - {{x}_{{j - 1}}},\quad {{h}_{j}}: = \frac{{p + q}}{2}.$$

Approximating the derivatives in model (1) by using these expressions, yields the following numerical approximation:

$$\epsilon \frac{{\tfrac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \tfrac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}}}{{{{h}_{j}}}} + \frac{{g({{u}_{{j + 1}}}) - g({{u}_{{j - 1}}})}}{{2{{h}_{j}}}} + f({{u}_{j}}) = 0,\quad j = 1,2,...,J - 1$$
((7))

with boundary conditions \({{u}_{0}} = \alpha ,\;{{u}_{J}} = \beta \). The idea is to choose a nonuniform central finite difference method such that the steep parts in the solution can be resolved. We will do this by performing the following steps. First, we transform the original model from the physical domain \(I = [0,1]\) to a computational domain \(I{\kern 1pt} \text{*}\).

4.2. Coordinate Transformation

Let \(x\) and \(\xi \) denote the physical and computational coordinates, respectively. Without loss of generality, we define a composed function \({v}(\xi ): = u \circ x(\xi ) = u(x(\xi ))\) and a coordinate transformation between \(x\) and \(\xi \) as:

$$x = x(\xi ),\quad \xi \in I{\kern 1pt} \text{*} = [0,1],$$

where \(x(0) = 0\) and \(x(1) = 1\). The computational domain \(I{\kern 1pt} \text{*}\) can be discretized into \(J\) equal segments \({\text{\{ }}{{\xi }_{j}} = j\Delta \xi {\text{\} }}_{{j = 0}}^{J}\) with \(\Delta \xi = \tfrac{1}{J}\). The first derivative is then transformed as

$$u{\kern 1pt} ' = \frac{{du}}{{dx}} = \frac{{d{v}}}{{d\xi }}\frac{{d\xi }}{{dx}} = \frac{{d{v}}}{{d\xi }}\frac{1}{{{{x}_{\xi }}}}.$$
((8))

The SPBVP (1) on the computational domain \(I{\kern 1pt} \text{*}\) can be written as

$$\frac{\epsilon }{{{{x}_{\xi }}}}\frac{d}{{d\xi }}\left( {\frac{1}{{{{x}_{\xi }}}}\frac{{d{v}}}{{d\xi }}} \right) + \frac{1}{{{{x}_{\xi }}}}\frac{d}{{d\xi }}(g({v}(\xi ))) + f({v}(\xi )) = 0,\quad {v}(0) = \alpha ,\quad {v}(1) = \beta .$$
((9))

The general idea behind this is to transform the, potentially, steep solution \(u(x)\) in the \(x\)-coordinate to the, intended, milder solution \({v}(\xi )\) in the \(\xi \)-coordinate (see Fig. 2). We also assume that the Jacobian \(\mathbb{J}\) of mapping \(x(\xi )\) is bounded from below and above by some positive constant: \(0 < \mathbb{J}: = \tfrac{{dx}}{{d\xi }} < \infty \). We get the following from Eq. (9):

$$\frac{\epsilon }{\mathbb{J}}\frac{d}{{d\xi }}\left( {\frac{1}{\mathbb{J}}\frac{{d{v}}}{{d\xi }}} \right) + \frac{1}{\mathbb{J}}\frac{d}{{d\xi }}(g({v}(\xi ))) + f({v}(\xi )) = 0.$$
((10))

with the same boundary conditions \({v}(0) = \alpha ,\;{v}(1) = \beta \). Equation (10) can be discretized on the uniform grid \(h\) as follows:

$$\frac{\epsilon }{{{{\mathbb{J}}_{j}}}}\left( {\frac{{{{{v}}_{{j + 1}}} - {{{v}}_{j}}}}{{{{\mathbb{J}}_{{j + \tfrac{1}{2}}}}}} - \frac{{{{{v}}_{j}} - {{{v}}_{{j - 1}}}}}{{{{\mathbb{J}}_{{j - \tfrac{1}{2}}}}}}} \right) + \frac{{g({{{v}}_{{j + 1}}}) - g({{{v}}_{{j - 1}}})}}{{2{{\mathbb{J}}_{j}}}} + f({{{v}}_{j}}) = 0,\quad {{{v}}_{0}} = \alpha ,\quad {{{v}}_{J}} = \beta .$$
((11))

where the Jacobian J has been approximated by

$${{\mathbb{J}}_{{j + \tfrac{1}{2}}}}: = \tfrac{p}{{\Delta \xi }},\quad {{\mathbb{J}}_{{j - \tfrac{1}{2}}}}: = \tfrac{q}{{\Delta \xi }},\quad {{\mathbb{J}}_{j}}: = \tfrac{{{{\mathbb{J}}_{{j + \tfrac{1}{2}}}} + {{\mathbb{J}}_{{j - \tfrac{1}{2}}}}}}{{2\Delta \xi }}.$$

The last scheme (38) can be equivalently rewritten as (37).

Fig. 2.
figure 2

A transformation \(\phi \) from a uniform to a nonuniform grid in which the steep solution \(u(x)\) in \(x\)-coordinate transform to milder solution \({v}(\xi )\) in \(\xi \)-coordinate. In this figure \(N\) is the number of grid points (called \(J\) in the text).

Fig. 3.
figure 3

Exact solutions of the convection-diffusion problem (22) for decreasing values of \(\epsilon \).

4.3. Local Truncation Error Analysis

In the following, we study some approximation properties of scheme (7) on nonuniform grids. We set

$${{\varphi }_{j}}: = \frac{\epsilon }{{{{h}_{j}}}}\left[ {\frac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \frac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}} \right] + \frac{{g({{u}_{{j + 1}}}) - g({{u}_{{j - 1}}})}}{{2{{h}_{j}}}} + f({{u}_{j}}) = 0.$$
((12))

and compute the consistency error of the approximation \({{\varphi }_{j}}\). For this, we need to work out Taylor expansions and compose the finite differences which appear in (37):

$$\frac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} = u{\kern 1pt} ' + \frac{p}{{2!}}u{\kern 1pt} '' + \frac{{{{p}^{2}}}}{{3!}}u''' + \frac{{{{p}^{3}}}}{{4!}}{{u}^{{(4)}}} + \frac{{{{p}^{4}}}}{{5!}}{{u}^{{(5)}}} + \mathcal{O}({{p}^{5}}),$$
((13))
$$\frac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q} = u' + \frac{q}{2}u'' + \frac{{{{q}^{2}}}}{{3!}}u''' + \frac{{{{q}^{3}}}}{{4!}}{{u}^{{(4)}}} + \frac{{{{q}^{4}}}}{{5!}}{{u}^{{(5)}}} + \mathcal{O}({{q}^{5}}).$$
((14))

Assume further that the mapping \(x(\xi )\), introduced in the previous section, is sufficiently smooth. We define \(p\) and \(q\) in (45) and (46) as:

$$\begin{gathered} p: = {{x}_{{j + 1}}} - {{x}_{j}} = \Delta \xi {{x}_{\xi }} + \frac{{\Delta {{\xi }^{2}}}}{{2!}}{{x}_{{\xi \xi }}} + \frac{{\Delta {{\xi }^{3}}}}{{3!}}{{x}_{{\xi \xi \xi }}} + \mathcal{O}(\Delta {{\xi }^{4}}), \hfill \\ q: = {{x}_{j}} - {{x}_{{j - 1}}} = \Delta \xi {{x}_{\xi }} - \frac{{\Delta {{\xi }^{2}}}}{{2!}}{{x}_{{\xi \xi }}} + \frac{{\Delta {{\xi }^{3}}}}{{3!}}{{x}_{{\xi \xi \xi }}} + \mathcal{O}(\Delta {{\xi }^{4}}). \hfill \\ \end{gathered} $$
((15))

Note that we write \({{x}_{\xi }}\) instead of \({{x}_{{\xi ,j}}}\). The expression for the nonuniform second derivative approximation becomes:

$$\underbrace {\frac{1}{{{{h}_{j}}}}\frac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \frac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}}_{\tilde {u}'} = u'' + \frac{{p - q}}{3}u''' + \left( {\frac{{{{p}^{2}} - pq + {{q}^{2}}}}{{60}}} \right){{u}^{{(4)}}} + \mathcal{O}(\Delta {{\xi }^{4}}).$$
((16))

In the remainder of the text, when there is no confusion, we write for notational reasons \(u{\kern 1pt} '\) instead of \(u_{j}^{'}\), \(u''\) instead of \(u_{j}^{{''}}\), etcetera. By substituting \(p\) and \(q\) from (15) into (16), one finds

$$\tilde {u}{\kern 1pt} '' = u{\kern 1pt} '' + \frac{{\Delta {{\xi }^{2}}}}{3}{{x}_{{\xi \xi }}}u{\kern 1pt} ''' + \frac{{\Delta {{\xi }^{2}}}}{{12}}x_{\xi }^{2}u{\kern 1pt} '''' + \mathcal{O}(\Delta {{\xi }^{4}}),$$

which can be written as

$$u{\kern 1pt} '' = \tilde {u}{\kern 1pt} '' - \underbrace {\frac{{\Delta {{\xi }^{2}}}}{{12}}(4{{x}_{{\xi \xi }}}u{\kern 1pt} ''' + x_{\xi }^{2}u{\kern 1pt} '''')}_{{{\tau }_{2}}} + \mathcal{O}(\Delta {{\xi }^{4}}),$$
((17))

where \({{\tau }_{2}}\) is the truncation error for the second derivative approximation. In a similar way, we can write the first derivative term in model (1) as:

$$\frac{{g({{u}_{{j + 1}}}) - g({{u}_{{j - 1}}})}}{{p + q}} = g{\kern 1pt} '(u) + \frac{{p - q}}{{2!}}g{\kern 1pt} ''(u) + \frac{{{{p}^{2}} - pq + {{q}^{2}}}}{{3!}}g{\kern 1pt} '''(u) + \mathcal{O}(\Delta {{\xi }^{4}}),$$

from which follows that:

$$[g(u)]{\kern 1pt} ' = \underbrace {\frac{{g({{u}_{{j + 1}}}) - g({{u}_{{j - 1}}})}}{{{{x}_{{j + 1}}} - {{x}_{{j - 1}}}}}}_{\widetilde {[g(u)]'}} + \underbrace {\frac{{\Delta {{\xi }^{2}}}}{6}(3{{x}_{{\xi \xi }}}g{\kern 1pt} ''(u) + x_{\xi }^{2}g{\kern 1pt} '''(u))}_{{{\tau }_{1}}} + \mathcal{O}(\Delta {{\xi }^{4}}),$$
((18))

where \({{\tau }_{1}}\) is the truncation error for the first derivative approximation. By substituting (17) and (18) into (37), we get

$${{\varphi }_{j}} = {{\tilde {\varphi }}_{j}} + \varepsilon {{\tau }_{2}} + {{\tau }_{1}} = 0,$$

where

$${{\tilde {\varphi }}_{j}} = \tilde {u}{\kern 1pt} ''\; + \widetilde {[g(u)]{\kern 1pt} '} + f(u).$$

To obtain a higher order approximation, we set \(\epsilon {{\tau }_{2}} + {{\tau }_{1}} = 0\), which is the local truncation error for the SPBVP under consideration (1). Finally, after using the expressions for \({{\tau }_{1}}\) and \({{\tau }_{2}}\), we find the following equation for the first term in the local truncation error of model (1):

$$\frac{\epsilon }{{12}}(4{{x}_{{\xi \xi }}}u{\kern 1pt} ''' + x_{\xi }^{2}u{\kern 1pt} '''') - \frac{1}{6}(3{{x}_{{\xi \xi }}}g{\kern 1pt} ''(u) + x_{\xi }^{2}g{\kern 1pt} '''(u)) = 0.$$
((19))

Depending on the functions \(g(u)\) and \(f(u)\), we are able to find a smooth mapping \(x(\xi )\) from this last expression.

In a next step we compute then the numerical solution of problem (1) on the smooth mapping \(x(\xi )\).

4.4. Numerical Experiments

In this section we present the numerical results for linear and nonlinear convection-diffusion SPBVPs (1) with boundary layers to validate the proposed numerical strategy, presented in Section 4. Without loss of generality, we represent \(u(x,\epsilon )\) as \(u\). To compute the solution numerically, we solve the system (37) efficiently using a tridiagonal matrix algorithm on nonuniform grids. For the nonlinear case, we develop an exact optimal nonuniform grid transformation by approximating the nonlinear source term upto linear terms and apply this optimal grid transformation to compute the solution of the nonlinear SPBVP. Furthermore, we compare the results between the uniform (3) and nonuniform (37) finite difference schemes. In order to measure the quality of the numerical solution, we compute the maximum error (20). For nonlinear SPBVPs, we take the maximum value as a reference value which can be obtained from the numerical solution of uniform central discretization system (3) at high values of \(J = 7000\) for decreasing values of \(\epsilon \). We measure the accuracy of the numerical solution by computing its distance to the reference solution as

$${{\left\| {{{\varepsilon }_{h}}} \right\|}_{\infty }} \equiv {{\left\| {{{u}_{h}} - u} \right\|}_{\infty }} = \mathop {\max}\limits_{1 \leqslant j \leqslant J} \left\| {{{u}_{j}} - u({{x}_{j}})} \right\|,$$
((20))

and the order of convergence can be calculated numerically as:

$$order = {{\log}_{2}}\left[ {\frac{{{{{\left\| {{{\varepsilon }_{h}}} \right\|}}_{\infty }}}}{{{{{\left\| {{{\varepsilon }_{{h/2}}}} \right\|}}_{\infty }}}}} \right].$$
((21))

Our proposed numerical strategy shows the main effect of an optimal nonuniform grid transformation \(x(\xi )\) for a linear and nonlinear SPBVPs in the following numerical experiments.

4.4.1. Test problem 1: linear convection-diffusion model. Consider the singularly perturbed linear convection-diffusion BVP:

$$\epsilon u{\kern 1pt} '' - u{\kern 1pt} ' = 0,\quad u(0) = 0,\quad u(1) = 1$$
((22))

with \(g(u) = u\) and \(f(u) = 0\) in (37). This model has the exact solution

$$u(x) = \frac{{{{{\text{e}}}^{{x/\epsilon }}} - 1}}{{{{{\text{e}}}^{{1/\epsilon }}} - 1}}.$$
((23))

For \(0 < \epsilon \ll 1\), the solution is monotonically increasing with a boundary-layer near \(x = 1.\) Suppose that we map the steep solution \(u(x)\) of the given boundary value problem (22) to the milder solution \({v}(\xi )\) in the new coordinate \(\xi \) as is illustrated in Fig. 2. Model (22) is transformed from the physical coordinate \(x\) to the computational coordinate \(\xi \), via the mapping \(x(\xi )\), to:

$$\frac{\epsilon }{{{{x}_{\xi }}}}\left[ {\frac{{{{{v}}_{{\xi \xi }}}{{x}_{\xi }} - {{{v}}_{\xi }}{{x}_{{\xi \xi }}}}}{{x_{\xi }^{2}}}} \right] - \frac{{{{{v}}_{\xi }}}}{{{{x}_{\xi }}}} = 0.$$
((24))

Assuming that \({{x}_{\xi }} > 0\) and that the steep solution \(u(x)\) is mapped to the linear function \({v}(\xi ) = \xi \) (see Fig. 5), we obtain from (24) the following nonlinear differential equation for \(\xi \):

$$\epsilon {{x}_{{\xi \xi }}} + x_{\xi }^{2} = 0,\quad x(0) = 0,\quad x(1) = 1,$$

which has the exact solution

$$x(\xi ) = \epsilon \ln (\xi ({{e}^{{\frac{1}{\epsilon }}}} - 1) + 1).$$
((25))

This nonuniform mapping with the grid points \({{\xi }_{j}} = j\Delta \xi \) is shown in Fig. 4 (middle panel). This choice is not optimal, as we will see later. For an optimal choice of \(x(\xi )\), we need to do further analysis. To achieve this, we extract the following expression from the local truncation error Eq. (19) with \(g(u) = u\) and \(f(u) = 0\) for the given model (22):

$$\epsilon {{x}_{{\xi \xi }}} + \frac{3}{{10}}x_{\xi }^{2} = 0,\quad x(0) = 0,\quad x(1) = 1,$$

which has the exact solution

$$x(\xi ) = \frac{{10}}{3}\epsilon \ln (\xi ({{e}^{{\tfrac{3}{{10\epsilon }}}}} - 1) + 1).$$
((26))

This smooth nonuniform mapping is represented in Fig. 4 (right panel). The corresponding \(v(\xi )\) can be obtained from solving (24) by using (26), see also in Fig. 5 (right).

Fig. 4.
figure 4

The functions \(x(\xi )\) for a uniform grid (left), a nonuniform grid (25) (middle) and the optimal nonuniform grid using (26) (right).

Fig. 5.
figure 5

In the right panel we see the corresponding functions \({v}(\xi )\) from nonuniform (25) and optimal nonuniform grid (26) for \(\epsilon = 0.1\) and the left panel depicts the original function \(u(x)\) on uniform grid.

To compute the numerical solution, we solve the discretized system (37) for the given boundary value problem (4.4.1) by using (25) and (26) respectively. In Tables 2 and 3, we compare the results by using uniform and nonuniform grids (25) and (26), respectively. From these results, we observe that the numerical solution with the nonuniform grid (25) is more accurate than the uniform case (3), but they have the same order of convergence. On the other hand, the nonuniform grid (26) behaves exceptionally: the results are fourth order accurate. This transformation (26) seems to be optimal, in the sense that we improve the convergence order from 2nd to 4th by choosing a ‘better’ mapping. It is noticed that when \(\varepsilon \) decreases, the solution becomes steeper (see Fig. 3). The maximum error also slightly decreases but we need more grid points to see 2nd or 4th order of convergence (see Table 3 for \(\epsilon = {{10}^{{ - 2}}}\), 10–3, 10–4, 10–5 with grid points \(J = 640\)).

Table 2.   Maximum error and convergence order for the linear model (22) with \(\epsilon = {{10}^{{ - 1}}}\)
Table 3.   Maximum error and convergence order for the linear model (22) with grid points \(J = 640\)

4.4.2. Test problem 2: nonlinear convection-diffusion-reaction model. Consider the following singularly perturbed nonlinear convection-diffusion-reaction SPBVP [4] with homogeneous Dirichlet boundary conditions:

$$\epsilon u{\kern 1pt} '' + 2u{\kern 1pt} ' + {{{\text{e}}}^{u}} = 0,\quad u(0) = 0,\quad u(1) = 0.$$
((27))

Here, we have \(g(u) = 2u\) and \(f(u) = {{e}^{u}}\) in SPBVP (1). The solution of this nonlinear problem exhibits a boundary-layer behavior at the left boundary at \(x = 0\) (see also Fig. 6). It is difficult to compute the optimal choice of the nonuniform mapping \(x(\xi )\) for this nonlinear convection diffusion reaction model. To obtain a nearly optimal \(x(\xi )\), we approximate the nonlinear term \({{{\text{e}}}^{u}}\) in (27) by a Taylor series upto the linear term \(1 + u\). In the following, we will construct the exact optimal grids \(x(\xi )\) for the linearized model with a linear source term and compute with this grid the solution of BVP (27). We solve the nonlinear discretized system (3) on a uniform grid and scheme (37) iteratively and make use of the Matlab direct solver fsolve. To start the iterations, we used a sinusoidal function that satisfies the boundary conditions: \({{u}_{0}} = a\sin (\pi x)\) as an initial guess with an amplitude \(a\), to be specified for each value of \(\epsilon \). By approximating the nonlinear term, the BVP (27) can be written as:

$$\epsilon u{\kern 1pt} '' + 2u{\kern 1pt} ' + (1 + u) = 0,\quad u(0) = 0,\quad u(1) = 0.$$

The following function solves the linearized BVP exactly:

$$u(x) = {{C}_{1}}{{{\text{e}}}^{{\tfrac{{ - 2 + \mu }}{{2\epsilon }}x}}} + {{C}_{2}}{{{\text{e}}}^{{\tfrac{{ - 2 - \mu }}{{2\epsilon }}x}}} - 1,$$
((28))

where

$$\mu = \sqrt {4 - 4\epsilon } ,\quad {{C}_{1}} = \frac{{1 - {{{\text{e}}}^{{\tfrac{{ - 2 - \mu }}{{2\epsilon }}}}}}}{{{{{\text{e}}}^{{\tfrac{{ - 2 + \mu }}{{2\epsilon }}}}} - {{{\text{e}}}^{{\tfrac{{ - 2 - \mu }}{{2\epsilon }}}}}}},\quad {{C}_{2}} = \frac{{{{{\text{e}}}^{{\tfrac{{ - 2 + \mu }}{{2\epsilon }}}}} - 1}}{{{{{\text{e}}}^{{\tfrac{{ - 2 + \mu }}{{2\epsilon }}}}} - {{{\text{e}}}^{{\tfrac{{ - 2 - \mu }}{{2\epsilon }}}}}}}.$$

Note that, since \(0 < \epsilon \ll 1\), we have \(4 - 4\epsilon > 0\). To find an exact optimal nonuniform grid \(x(\xi )\), we describe the truncation error as mentioned in (19) with the use of the exact solution (28):

$$\begin{gathered} \epsilon {{x}_{{\xi \xi }}}\left\{ {\left( {{{C}_{1}}{{{( - 2 + \mu )}}^{3}} + {{C}_{2}}{{{( - 2 - \mu )}}^{3}}{{e}^{{\left( { - \tfrac{\mu }{\epsilon }} \right)x}}}} \right) - 6\left( {{{C}_{1}}{{{( - 2 + \mu )}}^{2}} + {{C}_{2}}{{{( - 2 - \mu )}}^{2}}{{e}^{{\left( { - \tfrac{\mu }{\epsilon }} \right)x}}}} \right)} \right\} \\ + \;x_{\xi }^{2}\left\{ {\frac{1}{8}\left( {{{C}_{1}}{{{( - 2 + \mu )}}^{4}} + {{C}_{2}}{{{( - 2 - \mu )}}^{4}}{{e}^{{\left( { - \tfrac{\mu }{\epsilon }} \right)x}}}} \right) - \left( {{{C}_{1}}{{{( - 2 + \mu )}}^{3}} + {{C}_{2}}{{{( - 2 - \mu )}}^{3}}{{e}^{{\left( { - \tfrac{\mu }{\epsilon }} \right)x}}}} \right)} \right\} = 0. \\ \end{gathered} $$

Assuming that \({{e}^{{ - \tfrac{\mu }{\epsilon }x}}} \approx 1\), we get the expression:

$$\epsilon {{x}_{{\xi \xi }}} - \frac{B}{{8A}}x_{\xi }^{2} = 0,\quad x(0) = 0,\quad x(1) = 1,$$
((29))

where

$$\begin{gathered} A = ({{C}_{1}}{{( - 2 + \mu )}^{3}} + {{C}_{2}}{{( - 2 - \mu )}^{3}}) - 6({{C}_{1}}{{( - 2 + \mu )}^{2}} + {{C}_{2}}{{( - 2 - \mu )}^{2}}), \hfill \\ B = ({{C}_{1}}{{( - 2 + \mu )}^{4}} + {{C}_{2}}{{( - 2 - \mu )}^{4}}) - 8({{C}_{1}}{{( - 2 + \mu )}^{3}} + {{C}_{2}}{{( - 2 - \mu )}^{3}}). \hfill \\ \end{gathered} $$

It can be checked that the following expression solves the problem (29) exactly (see Fig. 7):

$$x(\xi ) = \frac{{8A}}{B}\epsilon \ln \left( {\xi \left( {{{e}^{{\tfrac{B}{{8A\epsilon }}}}} - 1} \right) + 1} \right).$$
((30))

The corresponding \({v}(\xi )\) can be obtained from (8) using (30) and (28). The steep solution \(u(x)\) in \(x\)-coordinate is transformed to milder solution \({v}(\xi )\) in \(\xi \)-coordinate (see Fig. 8).

Fig. 6.
figure 6

Accurate numerical solutions of the nonlinear boundary value problem (27) for decreasing values of \(\epsilon \).

Fig. 7.
figure 7

Optimal nonuniform grid for model (27) with \(\epsilon = {{10}^{{ - 1}}}\).

Fig. 8.
figure 8

Transformation from the steep solution \(u(x)\) to the milder solution \({v}(\xi )\) for model (27) with \(\epsilon = {{10}^{{ - 1}}}\).

We compute the numerical solution of model (27), by solving the discretized system (38) on the optimal nonuniform mapping (30). For \(0 < \epsilon \ll 1\), we compare the results (in Tables 4 and 5) for the uniform \(x(\xi ) = \xi \) and the near-optimal nonuniform grid (30), respectively. We observe that the near-optimal nonuniform grid behaves more accurately and is of higher order than for the uniform case.

Table 4.   Maximum error and convergence order for the model (27) with \(\epsilon = {{10}^{{ - 1}}}\)
Table 5.   Maximum error and convergence order for model (27) with grid points \(J = 640\)

The numerical results in Table 5 illustrate that for decreasing values of \(\epsilon \), the second order of accuracy for the uniform is obtained. On the other hand, for the near-optimal case of the nonuniform grid (30), we get approximately fourth order of accuracy. For smaller values of \(\epsilon \), we need more grid points to get a second or fourth order of convergence.

4.4.3. Test problem 3: nonlinear convection-diffusion-reaction problem with two boundary layers. Consider the nonlinear singularly perturbed convection-diffusion-reaction problem as:

$$\varepsilon u{\kern 1pt} '' + [2(2x - 1)u]{\kern 1pt} ' + 4\sin u = 0,\quad u(0) = 1,\quad u(1) = 1$$
((31))

with \(g(u) = 2(2x - 1)u\) and \(f(u) = 4\sin u\). The solution of this nonlinear problem has two boundary-layers, one at \(x = 0\) and the other at \(x = 1\). It is clear that when \(\epsilon \) decreases, the solution becomes steeper (see also Fig. 9).

Fig. 9.
figure 9

Solutions of model (31) for decreasing value of \(\epsilon \).

In the following, we will construct the exact optimal nonuniform grid from the linearized form of SPBVP (31). For the computation of the numerical solution of nonlinear discretized system of (31) iteratively, we adopt the Matlab routine fsolve. The iterations are started with a sinusoidal function that satisfies the boundary conditions: \({{u}_{0}} = a\cos (2\pi x)\). This initial guess has an amplitude \(a\), to be specified for each value of \(\epsilon \).

By taking \(g{\kern 1pt} '(u) = 2(2x - 1)u{\kern 1pt} ' + 4u\) and \(f(u) = 0\), the linearized form of BVP (31) reads:

$$\epsilon u{\kern 1pt} '' + 2(2x - 1)u{\kern 1pt} ' + 4u = 0,\quad u(0) = 1,\quad u(1) = 1.$$

The exact solution of this linearized BVP, given in [23], is:

$$u(x) = {{{\text{e}}}^{{\tfrac{{ - 2x(1 - x)}}{\epsilon }}}}$$
((32))

For an exact optimal nonuniform grid \(x(\xi )\), we investigate the truncation error as mentioned in (19) with the use of the expression (32), we get the following:

$$\epsilon {{x}_{{\xi \xi }}} - \frac{{{{A}_{1}}}}{{{{A}_{2}}}}x_{\xi }^{2} = 0,\quad x(0) = 0,\quad x(1) = 1,$$
((33))

where

$$\begin{gathered} {{A}_{1}} = (16{{\xi }^{4}} - 32{{\xi }^{3}} + 24{{\xi }^{2}} - 24\epsilon \xi + 3{{\epsilon }^{2}} + 24\epsilon {{\xi }^{2}} + 6\epsilon - 8\xi + 1), \\ {{A}_{2}} = \epsilon (8{{\xi }^{3}} + 6\epsilon \xi - 12{{\xi }^{2}} - 3\epsilon + 6\xi - 1). \\ \end{gathered} $$

The following expression, calculated with Maple, solves the above linear SPBVP exactly:

$$x(\xi ) = \frac{{{{A}_{2}}}}{{{{A}_{1}}}}\epsilon \ln \left( {\frac{{{{A}_{1}}}}{{{{A}_{2}}}}({{C}_{1}}\xi + {{C}_{2}})} \right).$$
((34))

where

$${{C}_{1}} = \frac{{A_{2}^{2}{{{\text{e}}}^{{\tfrac{{{{A}_{1}}}}{{{{A}_{2}}}}}}}\left( {\tfrac{{{{A}_{1}}}}{{{{A}_{2}}}} - 1} \right)}}{{A_{1}^{2}}},\quad {{C}_{2}} = \frac{{{{A}_{2}}{{{\text{e}}}^{{\tfrac{{{{A}_{1}}}}{{{{A}_{2}}}}}}}}}{{{{A}_{1}}}}.$$

Figure 10 shows the optimal mapping (34) for linear SPBVP of (31). The milder solution \(v(\xi )\) can be obtained from (8) using (34) and (32). Transformation from \(x\)-coordinate to new \(\xi \)-coordinate is presented in Fig. 11.

Fig. 10.
figure 10

Optimal nonuniform grid for model (31) with \(\epsilon = 0.1\).

Fig. 11.
figure 11

Transformation from the steep solution \(u(x)\) to the milder solution \({v}(\xi )\) for model (27) with \(\epsilon = {{10}^{{ - 1}}}\).

We compute the numerical solution for SPBVP (31) by solving the discretized system (38) on the optimal nonuniform grid (34) for \(0 < \epsilon \ll 1\). The numerical results illustrate that, the (near-) optimal nonuniform grid (34) transformation performs exceptionally. This transformation is near-optimal, in the sense that we are able to improve the accuracy and convergence order by choosing the appropriate mapping (34). For SPBVP (31), we get approximately 4th order accuracy and Table 6 confirms this behavior.

Table 6.   Maximum error and convergence order for model (31) with \(\epsilon = {{10}^{{ - 1}}}\)

We observe that for decreasing values of \(\epsilon \), the solution becomes more steeper, therefore, we need more grid points, to improve the accuracy and see the convergence order. From Table 7 it is noticed that to achieve the same accuracy, the uniform scheme (3) needs approximately a factor of \(5\) to \(10\) more grid points than the near-optimal nonuniform grid case. The numerical results clearly demonstrate the effectiveness of the proposed near-optimal nonuniform grid.

Table 7.   Maximum error and convergence order for nonlinear model (31) with \(640\) grid points

5. SIXTH-ORDER ADAPTIVE NONUNIFORM GRIDS

In this section, we first consider the following singularly-perturbed linear boundary-value problem with inhomogeneous Dirichlet boundary conditions:

$$\epsilon u{\kern 1pt} '' - u = 0,\quad u(0) = {{{\text{e}}}^{{ - \tfrac{1}{{\sqrt \epsilon }}}}},\quad u(1) = 1,$$
((35))

which has the exact solution

$$u(x) = {{{\text{e}}}^{{\tfrac{{x - 1}}{{\sqrt \epsilon }}}}}.$$
((36))

For small values of the perturbation parameter \(0 < \varepsilon \ll 1\), the steep solution (36) shows a boundary-layer behavior at \(x = 1\). This is illustrated in Fig. 12. However, we will proceed further as if the exact solution is unknown. We will use (36) only to access the quality of a solution.

Fig. 12.
figure 12

Exact solutions of model (35) for decreasing values of \(\epsilon \).

Approximating the derivatives in model (35) by using the expressions from Section 4.1, yields the following numerical approximation:

$$\epsilon \frac{{\tfrac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \tfrac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}}}{{{{h}_{j}}}} - {{u}_{j}} = 0$$
((37))

with boundary conditions \({{u}_{0}} = {{{\text{e}}}^{{ - \tfrac{1}{{\sqrt \epsilon }}}}},\)\({{u}_{J}} = 1\).

The SPBVP (35) on the computational domain \(I{\kern 1pt} \text{*}\) can be discretized on the uniform grid \(h\) as (see also in Section 4.2):

$$\frac{\epsilon }{{{{\mathbb{J}}_{j}}}}\left( {\frac{{{{{v}}_{{j + 1}}} - {{{v}}_{j}}}}{{{{\mathbb{J}}_{{j + \tfrac{1}{2}}}}}} - \frac{{{{{v}}_{j}} - {{{v}}_{{j - 1}}}}}{{{{\mathbb{J}}_{{j - \tfrac{1}{2}}}}}}} \right) - {{{v}}_{j}} = 0,\quad {{{v}}_{0}} = {{{\text{e}}}^{{ - \tfrac{1}{{\sqrt \epsilon }}}}},\quad {{{v}}_{J}} = 1,$$
((38))

Scheme (38) is equivalently with (37). We generate an optimal adaptive nonuniform grid based on the equidistribution principle. Further, numerical solution is computed of the discretized system of given problem (35) on the optimal adaptive nonuniform grid to establish a higher order of convergence.

5.1. Adaptive Nonuniform Grid Generation

The aim of the equidistribution principle is to concentrate the nonuniformly distributed grid points in the steep regions of the solution (see [7, 13, 34, 40] and references therein). In this principle, the desired mapping \(x(\xi )\) is obtained as a solution of the nonlinear problem:

$$\frac{d}{{d\xi }}\left[ {\omega (x)\frac{{dx}}{{d\xi }}} \right] = 0,\quad x(0) = 0,\quad x(1) = 1,$$
((39))

where \(\omega (x)\) is the so-called monitor function. The name equidistribution has to do with the fact that we would like to ‘equally distribute’ the positive valued and sufficiently smooth function \(\omega (x)\) on each nonuniform interval. For this, we first define the grid points

$$0 = {{x}_{0}} < {{x}_{1}} < {{x}_{2}} < ... < {{x}_{{J - 1}}} < {{x}_{J}} = 1.$$

Next, we determine the grid point distribution such that the contribution of \(\omega \) on each subinterval \([{{x}_{{j - 1}}},{{x}_{j}}]\) is equal. A discrete version of (39), after integrating once, reads:

$$\int\limits_{{{x}_{j}}}^{{{x}_{{j + 1}}}} {\omega (x)dx} = \frac{1}{J}\int\limits_0^1 {\omega (x)dx} ,\quad j = 0,1,...,J - 1.$$

In practice, one has to choose the monitor function \(\omega (x)\) and solve the nonlinear Eq. (39) to obtain the required mapping \(x(\xi )\). Equation (39) can be discretized using central finite differences as:

$$\frac{1}{{\Delta \xi }}\left[ {{{\omega }_{{j + 1/2}}}\frac{p}{{\Delta \xi }} - {{\omega }_{{j - 1/2}}}\frac{q}{{\Delta \xi }}} \right] = 0,\quad j = 1,2,...,J - 1$$
((40))

with boundary conditions \({{x}_{0}} = 0\), \({{x}_{J}} = 1\). Equation (40) is called a discrete equidistribution principle. The discrete system can be solved efficiently using a tridiagonal matrix algorithm. The iterations are continued until convergence for a prescribed tolerance has been achieved.

5.2. Numerical Results

The aim of this section is to point out that it is possible to develop a central three-point finite-difference scheme on nonuniform grids which exhibits a higher order accuracy than expected and known until now. We solve the discretized system of SPBVP (35) on adaptive nonuniform grids based on the equidistribution principle. We establish these higher-order optimal grids (4th order and 6th order) with the help of a local truncation error analysis of the discretized system of 35. Numerical experiments show that the other choices of grid distribution lead to a substantial degradation of the accuracy. Numerical results illustrate the effectiveness of the proposed numerical strategy for linear and nonlinear SPBVPs. The accuracy numerical solution is measured by computing its distance to the reference solution as described in Eqs. (20) and (21).

5.2.1. Case 1: fourth-order accuracy. The discretization of model (35) by approximating the second derivative on nonuniform grids, is given by

$$\epsilon \frac{{\tfrac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} - \tfrac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q}}}{{\tfrac{1}{2}(p + q)}} - {{u}_{j}} = 0.$$
((41))

Scheme (41) can be equivalently rewritten as:

$$\epsilon \left( {2{{u}_{j}} - \frac{{2p}}{{p + q}}{{u}_{{j - 1}}} - \frac{{2q}}{{p + q}}{{u}_{{j + 1}}}} \right) + pq{{u}_{j}} = 0.$$
((42))

We rewrite expression (42):

$$\epsilon (2{{u}_{j}} - {{R}_{1}}{{u}_{{j - 1}}} - {{R}_{2}}{{u}_{{j + 1}}}) + {{S}_{0}}{{u}_{{j - 1}}} + {{S}_{1}}{{u}_{j}} + {{S}_{2}}{{u}_{{j + 1}}}) = 0,$$
((43))

where

$${{R}_{1}} = \frac{{2p}}{{p + q}}\quad {\text{and}}\quad {{R}_{2}} = \frac{{2q}}{{p + q}},$$
$${{S}_{0}} = 0,\quad {{S}_{1}} = pq,\quad {{S}_{2}} = 0.$$

For 4th order of convergence, the discretized system is defined as:

$$\epsilon (2{{u}_{j}} - {{R}_{1}}{{u}_{{j - 1}}} - {{R}_{2}}{{u}_{{j + 1}}}) + {{S}_{1}}{{u}_{j}} = 0.$$
((44))

This is equivalent to scheme (41).

We study the approximation properties of scheme (41) on general nonuniform grids. For this, we need to work out Taylor expansions and compose the finite differences which appear in (41):

$$\begin{gathered} \frac{{{{u}_{{j + 1}}} - {{u}_{j}}}}{p} = u{\kern 1pt} ' + \frac{p}{{2!}}u{\kern 1pt} '' + \frac{{{{p}^{2}}}}{{3!}}u{\kern 1pt} ''' + \frac{{{{p}^{3}}}}{{4!}}{{u}^{{(4)}}} + \frac{{{{p}^{4}}}}{{5!}}{{u}^{{(5)}}} + \mathcal{O}({{p}^{5}}), \\ \frac{{{{u}_{j}} - {{u}_{{j - 1}}}}}{q} = u{\kern 1pt} ' + \frac{q}{2}u{\kern 1pt} '' + \frac{{{{q}^{2}}}}{{3!}}u{\kern 1pt} ''' + \frac{{{{q}^{3}}}}{{4!}}{{u}^{{(4)}}} + \frac{{{{q}^{4}}}}{{5!}}{{u}^{{(5)}}} + \mathcal{O}({{q}^{5}}). \\ \end{gathered} $$
((45))

Assume further that the mapping \(x(\xi )\), is sufficiently smooth. Note that the grid difference functions \(p\) and \(q\) can be written as:

$$\begin{gathered} p = {{x}_{{j + 1}}} - {{x}_{j}} = \Delta \xi {{x}_{\xi }} + \frac{{\Delta {{\xi }^{2}}}}{{2!}}{{x}_{{\xi \xi }}} + \frac{{\Delta {{\xi }^{3}}}}{{3!}}{{x}_{{\xi \xi \xi }}} + \mathcal{O}(\Delta {{\xi }^{4}}), \\ q = {{x}_{j}} - {{x}_{{j - 1}}} = \Delta \xi {{x}_{\xi }} - \frac{{\Delta {{\xi }^{2}}}}{{2!}}{{x}_{{\xi \xi }}} + \frac{{\Delta {{\xi }^{3}}}}{{3!}}{{x}_{{\xi \xi \xi }}} + \mathcal{O}(\Delta {{\xi }^{4}}). \\ \end{gathered} $$
((46))

We obtain the asymptotic expression:

$$\epsilon u{\kern 1pt} '' - u - \epsilon \left( {\left( {\frac{{p - q}}{3}} \right)u{\kern 1pt} ''' - \left( {\frac{{{{p}^{2}} - pq + {{q}^{2}}}}{{12}}} \right){{u}^{{(4)}}} - \left( {\frac{{(p - q)({{p}^{2}} + {{q}^{2}}}}{{60}}} \right){{u}^{{(5)}}} + \mathcal{O}(\Delta {{\xi }^{4}})} \right) = 0.$$
((47))

We transform the system \(x \mapsto \xi \) so, from (47), one gets

$$ - \epsilon \frac{{\Delta {{\xi }^{2}}}}{3}\left[ {{{x}_{{\xi \xi }}}u{\kern 1pt} ''' + \frac{1}{4}x_{\xi }^{2}u{\kern 1pt} ''''} \right] + O(\Delta {{\xi }^{4}}) = 0.$$
((48))

In general, scheme (41) is second order accurate. However, we notice that scheme will be fourth order accurate, if the mapping \(x(\xi )\) satisfies the following equation:

$${{x}_{{\xi \xi }}}u{\kern 1pt} ''' + \frac{1}{4}x_{\xi }^{2}u{\kern 1pt} '''' = 0,$$
((49))

where \(u(x)\) is a solution of (35). Equation (49) can be rewritten as:

$${{(u{\kern 1pt} ''')}^{{3/4}}}{{[{{(u{\kern 1pt} ''')}^{{1/4}}}{{x}_{\xi }}]}_{\xi }} = 0.$$

Since \(u{\kern 1pt} ''' \propto u{\kern 1pt} '\), we obtain \({{[{{(u{\kern 1pt} ')}^{{1/4}}}{{x}_{\xi }}]}_{\xi }} = 0\). For our numerical simulations, we make the following choice of the monitor function to illustrate the use of the equidistribution principle (see Section 5.1):

$$\omega = {{(u{\kern 1pt} ')}^{{1/4}}}.$$
((50))

In the equidistribution method, we obtain the mapping \(x(\xi )\) from (39). For SPBVP (35), we can write the monitor function in a generalized form:

$${{\omega }_{\eta }}(x) = {{(u{\kern 1pt} '(x))}^{\eta }}.$$
((51))

We take the optimal choice of the monitor function (50) to establish the 4th order of convergence for model (35). The numerical experiments are performed for different choices of \(\eta \) in (51) and \(\epsilon = 0.01.\)

We slightly change the monitor function by changing the values of \(\eta \) and observe that the convergence order also changes. Table 8 shows clearly that the optimal result is obtained for \(\eta = 1{\text{/}}4\). This is the optimal choice to get the higher order of convergence \(4\) for scheme (41). On the other hand, for other choices of the monitor functions \(\omega (x)\) with different \(\eta \) in (51), we obtain 2nd order of convergence. However, for the choice \(\omega = {{(u{\kern 1pt} ')}^{2}}\), the convergence of order falls down to \( \approx {\kern 1pt} 1{\text{/}}2\), which is, of course, to be avoided for practical numerical simulation. As mentioned above, by taking different choices for the monitor functions \(\omega \), we observe a difference in accuracy and convergence order of the numerical solutions. An even higher order of convergence can be found by an appropriate choice of the monitor function in the next section.

Table 8.   Maximum error and convergence order for Case I for different choices of \(\omega \) and \(\epsilon = 0.01\)

5.2.2. Case II: sixth-order accuracy. Instead of only using the grid values \(({{x}_{j}},{{u}_{j}})\) for the approximation of the linear reaction term in (35), we consider now the case \({{S}_{0}} \ne 0\) and \({{S}_{2}} \ne 0\) in (43), which means that the reaction term will be approximated on a three-point stencil \(({{x}_{{j - 1}}},{{u}_{{j - 1}}})\), \(({{x}_{j}},{{u}_{j}})\) and \(({{x}_{{j + 1}}},{{u}_{{j + 1}}})\). We expand the various terms of expression (43) in a Taylor expansion as mentioned in (45) and (46). We obtain the following:

$$\begin{gathered} (2 - {{R}_{1}} - {{R}_{2}} + {{S}_{1}}){{u}_{j}} + \Delta \xi ({{R}_{1}}q - {{R}_{2}}p)u_{j}^{'} + \Delta {{\xi }^{2}}\left( { - \frac{{{{R}_{1}}}}{2}{{q}^{2}} - \frac{{{{R}_{2}}}}{2}{{p}^{2}} + {{S}_{0}} + {{S}_{2}}} \right)u_{j}^{{''}} \\ + \;\Delta {{\xi }^{3}}\left( {\frac{{{{R}_{1}}}}{{3!}}{{q}^{3}} - \frac{{{{R}_{2}}}}{{3!}}{{p}^{3}} - {{S}_{0}}q + {{S}_{2}}p} \right)u_{j}^{{'''}} + \Delta {{\xi }^{4}}\left( { - \frac{{{{R}_{1}}}}{{4!}}{{q}^{4}} - \frac{{{{R}_{2}}}}{{4!}}{{p}^{4}} + {{S}_{0}}\frac{{{{q}^{2}}}}{{2!}} + {{S}_{2}}\frac{{{{p}^{2}}}}{{2!}}} \right)u_{j}^{{''''}} + ... = 0. \\ \end{gathered} $$
((52))

We now determine the values for \({{S}_{i}}(i = 1,2,3)\) for Case II, where the coefficients \({{R}_{1}}\) and \({{R}_{2}}\) are similar to the ones in Case I. We can rewrite expression (52) in the following way:

$${{T}_{0}}{{u}_{j}} + \Delta \xi {{T}_{1}}u_{j}^{'} + \Delta {{\xi }^{2}}{{T}_{2}}u_{j}^{{''}} + \Delta {{\xi }^{3}}{{T}_{3}}u_{j}^{{'''}} + \Delta {{\xi }^{4}}{{T}_{4}}u_{j}^{{''''}} + ... = 0,$$

where the coefficients of \(\Delta \xi \) are set as:

$$\begin{gathered} {{T}_{0}} = 2 - {{R}_{1}} - {{R}_{2}} + {{S}_{1}} = 0,\quad {{T}_{1}} = {{R}_{1}}q - {{R}_{2}}p = 0,\quad {{T}_{2}} = - \frac{{{{R}_{1}}}}{2}{{q}^{2}} - \frac{{{{R}_{2}}}}{2}{{p}^{2}} + {{S}_{0}} + {{S}_{2}} = 0, \\ {{T}_{3}} = \frac{{{{R}_{1}}}}{{3!}}{{q}^{3}} - \frac{{{{R}_{2}}}}{{3!}}{{p}^{3}} - {{S}_{0}}q + {{S}_{2}}p = 0,\quad {{T}_{4}} = - \frac{{{{R}_{1}}}}{{4!}}{{q}^{4}} - \frac{{{{R}_{2}}}}{{4!}}{{p}^{4}} + {{S}_{0}}\frac{{{{q}^{2}}}}{{2!}} + {{S}_{2}}\frac{{{{p}^{2}}}}{{2!}} = 0. \\ \end{gathered} $$
((53))

Making use of the coefficients \({{T}_{1}}\), … \({{T}_{4}}\) and \({{R}_{1}},\;{{R}_{2}}\) from Case I, we obtain the following three expressions for the unknowns coefficients for Case II:

$${{S}_{0}} = \frac{p}{{6(p + q)}}({{q}^{2}} + pq - {{p}^{2}}),\quad {{S}_{1}} = pq - {{S}_{0}} - {{S}_{2}},\quad {{S}_{2}} = \frac{q}{{6(p + q)}}({{p}^{2}} + pq - {{q}^{2}}).$$
((54))

The terms \({{R}_{1}},{{R}_{2}}\) from \(CaseI\) and Eqs. (54) define \(CaseII\). For a higher order accuracy, we expand several more terms of the Taylor expansion of Eq. (43) and then estimate the terms asymptotically as mentioned in Eqs. (45), (46), respectively. Finally, Eq. (43) yields:

$$ - \epsilon \tfrac{{\Delta {{\xi }^{4}}}}{{20}}\left( {{{x}_{{\xi \xi }}}{{u}^{{(5)}}} + \tfrac{1}{{12}}x_{\xi }^{2}{{u}^{{(6)}}}} \right) + \mathcal{O}(\Delta {{\xi }^{6}}) = 0.$$

For Case II, we obtain a higher order of accuracy (supra-convergence), if the transformation \(x(\xi )\) satisfies the following relation:

$${{x}_{{\xi \xi }}}{{u}^{{(5)}}} + \tfrac{1}{{12}}x_{\xi }^{2}{{u}^{{(6)}}} = 0.$$

From this follows the equidistribution principle:

$${{[{{({{u}^{{(5)}}})}^{{1/12}}}{{x}_{\xi }}]}_{\xi }} = 0.$$
((55))

It is easily checked from (36), that \({{u}^{{(5)}}} \propto u{\kern 1pt} '\), and we find for Case II the equivalent equation:

$${{[{{(u{\kern 1pt} ')}^{{1/12}}}{{x}_{\xi }}]}_{\xi }} = 0.$$
((56))

Next, we numerically solve the system (43) with the monitor function \(\omega = {{(u{\kern 1pt} ')}^{{1/12}}}\) from (56). As indeed follows from the theory, we get more accurate results and a 6th order accuracy (see Table 9). By considering other choices for the monitor function, we observe that by taking \(\eta = 1{\text{/}}2\) in (51), scheme (43) suddenly drops to 2nd order of accuracy, the same as or the uniform grid case (see Fig. 13). Also, for this choice of the monitor function in Case I (see Table 8) it gives 4th order accurate solutions. We also demonstrate this by taking slightly changed values of \(\eta = 1{\text{/}}11\) or \(\eta = 1{\text{/}}13\): we obtain second order of accuracy for nonoptimal grids. The power \(\eta = 1{\text{/}}12\) in (56) gives the optimal sixth order accuracy, which is the maximum order that can be obtained on a three-point nonuniform stencil. No further improvement of the order can be reached. This follows directly from the analysis of systems (53) and (54).

Table 9.   Maximum error and convergence order for Case II for different choices of \(\omega \) and \(\epsilon = 0.01\)
Fig. 13.
figure 13

Convergence order for several choices of the monitor function \(\omega \) for Case I (left) and for Case II (right). We observe numerical evidence of the theoretically predicted convergence order, depending on the power in the monitor function. The convergence order can be two for standard choices (left and right panel), but also four (left panel) and even six (right panel) for special monitor functions, yielding supra-convergence.

5.3. Numerical Implementation for a Nonlinear Problem

To show the effects on a nonlinear model, we finally consider the SPBVP:

$${{10}^{{ - 2}}}u{\kern 1pt} '' - \sin (u) = 0,\quad u(0) = {{{\text{e}}}^{{ - 10}}},\quad u(1) = 1.$$
((57))

Equidistribution Eqs. (40) with monitor functions \(\omega = 1\), \(\omega = {{(u{\kern 1pt} ')}^{{1/4}}}\), and \(\omega = {{(u{\kern 1pt} ')}^{{1/12}}}\), respectively, are being solved iteratively in combination with (43). We cannot find an exact optimal grid transformation as for the linear case. Therefore, we approximate model (57) by approximating \(\sin (u) \approx u\). Optimal nonuniform grids, for obtaining fourth and sixth order accuracy for the linear case are given by grid transformation (51) with \(\eta = 1{\text{/}}4\) and \(\eta = 1{\text{/}}12\), respectively. A reference solution of model (57) has been obtained by applying a uniform grid with \(J = 1281\) and the routine \(fsolve\) from Matlab. The exact solution (36) of the linearized model (35) has been chosen as the initial guess for the iterative procedure. The numerical results can be found in Table 10.

Table 10.   Maximum error and convergence orders for different choices of the grids for model (57): a uniform grid (second order), nonuniform grids with \(\eta = 1{\text{/}}4\) (\( \approx \)fourth order) and \(\eta = 1{\text{/}}12\) (\( \approx \)sixth order)

We clearly observe an almost fourth order \(( \approx 3.5)\) and almost sixth order \(( \approx {\kern 1pt} 5.4)\) accuracy of the proposed nonuniform grid methods. The full orders of four and six cannot be reached, since we approximate the nonlinear function in SPBVP (57) by a linear one. Dispite of the linearization, a significant gain in accuracy can be realized for the nonlinear case as well.

6. CONCLUSIONS

In the present article, we proposed a higher order nonuniform finite difference grid, to solve singularly perturbed boundary value problems with steep boundary-layers. We have presented some theoretical properties concerning the extremum values and the asymptotic value at the right boundary point. Traditionally, a three point central finite differences on a uniform grid produces a second order of accuracy. In this paper, we have developed more accurate and higher order of accuracy nonuniform grid approximations. We have provided several examples of singularly perturbed, both linear and nonlinear, convection-diffusion-reaction problems, which demonstrate the effectiveness of the proposed numerical strategy. We presented a detailed discussion how to obtain a higher order of accuracy by considering a special way of discretizing the given system. The proposed method on optimal nonuniform grids performed exceptionally. We established numerically, not only 4th-order but also a 6th-order of accuracy by considering only three point central nonuniform finite differences. We also showed that other choices of the grid distributions lead to a substantial degradation of the accuracy. Numerical experiments have confirmed this behaviour. Comparisons between numerical results illustrate that, to achieve the same accuracy, the proposed method needs approximately a factor of 5–10 fewer grid points than the uniform case. This factor depends, of course, on the value of the small perturbation parameter \(\epsilon \) as well.