1 Introduction

A spline can be defined as any function constructed from one or more polynomial pieces that are joined together satisfying given differentiability requirements. There exist different types of splines (see, e.g., [9]) which can be classified depending on the restrictions introduced (see, e.g., [21]). C2-splines are used in the industry in very different kind of applications. The most familiar is computer-aided design, where splines are used to represent geometric entities (see, e.g., [7, 8, 12, 23]) or image processing (see, e.g., [10, 18, 27]). Another example is computer-aided manufacturing, where splines are involved in the modeling of geometric parts or used in the representation paths for machine tool cutters (see, e.g., [24, 28]). They are also used in the reconstruction of field data in many areas of engineering. Other kinds of splines are used to create approximations to the solution of ordinary differential equations, partial differential equations, integral equations, etc. using the finite element method (see, e.g., [6, 7, 17, 22]).

However, when the data contains real or numerical discontinuities, classical interpolation algorithms are not satisfactory. Recently, some new techniques have been developed in order to recover discontinuous functions, for example using Radial Bases Functions (RBF), see [5, 20]. In these cases, standard splines suffer from Gibbs oscillations, this phenomenon is first detected in the context of truncated Fourier expansions, [13], and it has been widely analyzed (see, e.g., [11, 14, 19]). In our paper [3], we introduced a nonlinear procedure that modifies a given spline in order to avoid these oscillations. However, this recent reconstruction loses the C2 regularity. The goal of the present work is to present a new spline combining both properties: the C2 regularity and the adaptation to discontinuities.

This article is organized as follows: Section 2 describes the framework that we will use, explains how classical splines are obtained and how to adapt them to the presence of discontinuities. Section 3 introduces and analyzes the properties of a new nonlinear weighted mean that is used to construct a new class of splines adapted to the presence of jump discontinuities having C2 regularity. Section 4 studies the approximation properties of the new class of splines close to discontinuities and a specific example is considered in Section 5. In Section 6, we analyze how the new spline avoids the Gibbs oscillations. Section 7 presents some numerical experiments where it is shown how the new nonlinear splines perform close to jump discontinuities with uniform grid spacing. Finally, Section 8 presents some conclusions.

2 Classical cubic splines versus nonlinear cubic splines

In this section, we recall the classical cubic interpolation and analyze the nonlinear modification introduced by Amat, Ruiz, Shu and Trillo in [3]. We will prove that this new type of spline is not necessarily C2, i.e., the continuity is sacrificed to avoid the presence of Gibbs oscillations. In order to obtain C2 regularity adapted to discontinuities, we slightly change the points of interpolation, i.e., we construct a quasi-interpolatory spline approximations using the same technique developed in [3].

Following the notation described in [3], let us consider the set of piecewise continuous functions in the interval [a,b], and let X be a non-uniform partition of the interval [a,b] into m subintervals,

$$X=(x_{i})^{m}_{i=0}, \quad x_{0}=a, \quad h_{i}=x_{i}-x_{i-1}.$$

Then, we can define the point-values discretization as the values of a function at these points,

$$y_{i}=y(x_{i}),\quad i=0,\cdots, m.$$

The spline g(x) in the interval [a,b] depends of the m + 1 pairs of values (xi,yi),i = 0,⋯ ,m and in each subinterval [xi,xi+ 1] it is a cubic polynomial gi(x). More precisely, g(x) = gi(x), x ∈ [xi,xi+ 1], where

$$ g_{i}(x)={a}_{i}(x-x_{i})^{3}+{b}_{i}(x-x_{i})^{2}+{c}_{i}(x-x_{i})+{d}_{i}, $$
(1)

subjected to the following conditions

$$ g_{i-1}(x_{i})=y_{i},\quad g^{\prime}_{i-1}(x_{i})=g^{\prime}_{i}(x_{i}),\quad g_{i}(x_{i})=y_{i},\quad g^{\prime\prime}_{i-1}(x_{i})=g^{\prime\prime}_{i}(x_{i}), \quad 1\leq i \leq m-1, $$
(2)

and

$$ \begin{array}{@{}rcl@{}} g_{0}(x_{0})&=&y_{0},\\ g_{m-1}(x_{m})&=&y_{m}. \end{array} $$

This way, a cubic spline that is at least C2 is obtained. If we solve the previous equations, we get that,

$$ \begin{array}{@{}rcl@{}} a_{i}&=&\frac{h_{i+1}D_{i+1}+D_{i} h_{i+1}+2y_{i}-2y_{i+1}}{h_{i+1}^{3}}, \\b_{i}&=&-\frac{h_{i+1}D_{i+1}+2D_{i} h_{i+1}+3y_{i}-3y_{i+1}}{h_{i+1}^{2}},\quad c_{i}=D_{i},\quad d_{i}=y_{i}, \end{array} $$
(3)

where Di stands for the first derivative at every interior knot. We obtain a system of equations for the Dis replacing the conditions for the spline (1) in (2),

$$ \frac{D_{i-1}}{h_{i}}+2\left( \frac{1}{h_{i}}+\frac{1}{h_{i+1}}\right)D_{i}+\frac{D_{i+1}}{h_{i+1}}=3\left( \frac{y_{i+1}-y_{i}}{h_{i+1}^{2}}+\frac{y_{i}-y_{i-1}}{{h_{i}^{2}}}\right). $$
(4)

If we take the natural boundary conditions, i.e., \(g^{\prime \prime }_{0}(x_{0})=0\) and \(g^{\prime \prime }_{m-1}(x_{m})=0\), from (1), the left boundary condition implies the equation,

$$ 2D_{0}+D_{1}=3\left( \frac{y_{1}-y_{0}}{h_{1}}\right), $$

and for the right boundary we obtain,

$$ D_{m-1}+2D_{m}=3\left( \frac{y_{m}-y_{m-1}}{h_{m}}\right). $$
(5)

Denoting

$$ \lambda_{i}={\frac{1}{h_{i}}}, \quad i=1,\hdots, m, $$
(6)

we get the system:

$$ \left[\begin{array}{lllllll} 2&1&0&0&\cdots&0&0\\ \lambda_{1}&2(\lambda_{1}+\lambda_{2})&\lambda_{2}&0&\cdots&0&0\\ 0&\lambda_{2}&2(\lambda_{2}+\lambda_{3})&\lambda_{3}&\cdots&0&0\\ \cdots&\cdots&\cdots&\cdots&\cdots&\cdots&\cdots\\ 0&0&0&0&\cdots&2(\lambda_{m}+\lambda_{m-1}) &\lambda_{m}\\ 0&0&0&0&\cdots&1&2 \end{array}\right] \left[\begin{array}{l} D_{0}\\ D_{1}\\ D_{2}\\ \cdots\\ D_{m-1}\\ D_{m} \end{array}\right]=3\cdot\left[\begin{array}{l} \delta_{1}\\ \lambda_{2}\delta_{2}+\lambda_{1}\delta_{1}\\ \lambda_{3}\delta_{3}+\lambda_{2}\delta_{2}\\ \cdots\\ \lambda_{m}\delta_{m}+\lambda_{m-1}\delta_{m-1}\\ \delta_{m} \end{array}\!\right], $$
(7)

with \(\delta _{i}=\frac {y_{i}-y_{i-1}}{h_{i}}\) for i = 1,…,m.

Denoting:

$$ \alpha_{i}=\frac{\lambda_{i}}{\lambda_{i}+\lambda_{i-1}},\quad \beta_{i}=\frac{\lambda_{i-1}}{\lambda_{i}+\lambda_{i-1}}, \quad i=1,\hdots, m, $$

the previous system can be also written as AD = 3f, with

$$ \mathbf{A}=\left[\begin{array}{lllllll} 2&1&0&0&\cdots&0&0\\ \beta_{2}&2&\alpha_{2}&0&\cdots&0&0\\ 0&\beta_{3}&2&\alpha_{3}&\cdots&0&0\\ \cdots&\cdots&\cdots&\cdots&\cdots&\cdots&\cdots\\ 0&0&0&0&\cdots&2 &\alpha_{m}\\ 0&0&0&0&\cdots&1&2 \end{array}\right], \mathbf{D}= \left[\begin{array}{l} D_{0}\\ D_{1}\\ D_{2}\\ \cdots\\ D_{m-1}\\ D_{m} \end{array}\right], \mathbf{f}=\left[\begin{array}{l} \delta_{1}\\ M_{\alpha_{2},\beta_{2}}(\delta_{2},\delta_{1})\\ M_{\alpha_{3},\beta_{3}}(\delta_{3},\delta_{2})\\ \cdots\\ M_{\alpha_{m},\beta_{m}}(\delta_{m},\delta_{m-1})\\ \delta_{m} \end{array}\right], $$
(8)

where Mα,β(x,y) is a weighted mean depending on two constants 0 < α,β < 1 such that α + β = 1 and are functions \(M_{\alpha ,\beta }:\mathbb {R}\times \mathbb {R}\to \mathbb {R}\) defined as Mα,β(x,y) = αx + βy.

As mentioned in the introduction, it is not difficult to check that linear C2 splines produce Gibbs phenomenon at zones close to the discontinuities. For this reason, in [3], the authors construct a new nonlinear spline that we present in the following subsection.

Remark 2.1

Throughout, the paper we define \(h={\max \limits } (h)_{i=1}^{m}\), and we consider approximation orders in powers of h as h ↘ 0. By the notation e = O(hα) we mean |e|≤ Chα where C is independent of h.

2.1 A class of nonlinear cubic splines

In order to design the nonlinear spline, we defined a nonlinear weighted mean. Thus, we present the following definition.

Definition 1 (Non-linear weighted mean)

Let 0 < α,β < 1, α + β = 1 be two constants and \(\mathbb {R}^{+}=\{x\in \mathbb {R}: x>0\}\). A nonlinear weighted mean, \(\tilde {H}^{+}_{\alpha ,\beta }:\mathbb {R}^{+}\times \mathbb {R}^{+} \to \mathbb {R}^{+}\), will be a function which satisfies the following five properties:

1):

\(\min \limits \{x,y\}\leq \tilde {H}^{+}_{\alpha ,\beta }(x,y)\leq \max \limits \{x,y\}\), for all \(x,y\in \mathbb {R}^{+}\).

2):

\(\tilde {H}^{+}_{\alpha ,\beta }(x,x)=x\), for all \(x\in \mathbb {R}^{+}\).

3):

Commutative (C) property. \(\tilde {H}^{+}_{\alpha ,\beta }(x,y)=\tilde {H}^{+}_{\beta ,\alpha }(y,x)\), for all \(x,y\in \mathbb {R}^{+}\).

4):

Order of accuracy (OA) property. There exist p ≥ 1 and h > 0 such that if x = O(1), y = O(1), xy > 0 and |xy| = O(h), then

$$ \left|\tilde{H}^{+}_{\alpha,\beta}(x,y)-M_{\alpha,\beta}(x,y)\right|=O(h^{p}). $$
(9)
5):

Adaptation to discontinuities (AD) property. There exists p ≥ 1 such that for all \(x,y\in \mathbb {R}\):

$$|\tilde{H}^{+}_{\alpha,\beta}(x,y)|\leq p\min\{|x|,|y|\}.$$

We extend this definition for all \((x,y)\in \mathbb {R}^{2}\) as:

$$\tilde{H}_{\alpha,\beta}(x,y)=\left\{\begin{array}{ll} sign(x)\tilde{H}^{+}_{\alpha,\beta}(|x|,|y|) & x\cdot y>0, \\ 0& x\cdot y\leq 0, \end{array}\right. $$

where

$$ sign(x)=\left\{ \begin{array}{ll} 1,& x> 0,\\ 0,& x=0,\\ -1,& x<0. \end{array}\right. $$

However, we will lose order of accuracy at critical points, i.e., when x = O(1), y = O(1) and |xy| = O(h) but xy ≤ 0. In order to solve this problem Amat et al. propose in [3] the following nonlinear weighted mean:

$$ H^{T_{\varepsilon}}_{\alpha,\beta}(x,y)=\tilde{H}_{\alpha,\beta}(x+T_{\varepsilon}(x,y),y+T_{\varepsilon}(x,y))-T_{\varepsilon}(x,y), $$
(10)

where \(T_{\varepsilon }:\mathbb {R}^{2}\to \mathbb {R}\) is a function defined as:

$$ T_{\varepsilon}(x,y) = \left\{\begin{array}{ll} sign(y)(|x|+\varepsilon(x,y)), & xy<0, \\ sign(y)\varepsilon(x,y), & xy\geq 0, \end{array} \right. $$
(11)

being ε(x,y) > 0 a function defined for all \((x,y)\in \mathbb {R}^{2}\). This function depends on the data at each interval. For simplicity, in the rest of the paper, we denote \(H_{\alpha ,\beta }=H^{T_{\varepsilon }}_{\alpha ,\beta }\).

If we choose a convenient function ε(x,y) (see Section 5 or [3]), it is possible to prove that the (C), (OA) and (AD) properties are satisfied by Hα,β for all the points in the plane \(\mathbb {R}^{2}\).

Using the same reasoning showed in [3], denoting as \(H_{\alpha _{i},\beta _{i}}(\delta _{i},\delta _{i-1})=H_{i}\), i = 2,...,m, we redefine the system (8) changing the vector f by

$$ \tilde{\mathbf{f}}=\left[\begin{array}{l} \delta_{1}\\ H_{\alpha_{2},\beta_{2}}(\delta_{2},\delta_{1})\\ H_{\alpha_{3},\beta_{3}}(\delta_{3},\delta_{2})\\ \cdots\\ H_{\alpha_{m},\beta_{m}}(\delta_{m},\delta_{m-1})\\ \delta_{m} \end{array}\right]=:\left[\begin{array}{l} \delta_{1}\\ H_{2}\\ H_{3}\\ \cdots\\ H_{m}\\ \delta_{m} \end{array}\right]. $$
(12)

Thus, the new system is \(\mathbf {A}\tilde {\mathbf {D}}=3\tilde {\mathbf {f}}\) where A is the matrix defined in (8). Then, the coefficients of this nonlinear spline are given by:

$$ \begin{array}{@{}rcl@{}} \tilde{a}_{i}&=&\frac{h_{i+1}\tilde{D}_{i+1}+\tilde{D}_{i} h_{i+1}+2y_{i}-2y_{i+1}}{h_{i+1}^{3}}, \\ \tilde{b}_{i}&=&-\frac{h_{i+1}\tilde{D}_{i+1}+2\tilde{D}_{i} h_{i+1}+3y_{i}-3y_{i+1}}{h_{i+1}^{2}},\quad \tilde{c}_{i}=\tilde{D}_{i},\quad d_{i}=y_{i}, \end{array} $$
(13)

By a direct computation it is easy to check that \(\tilde {g}_{i-1}^{\prime }(x_{i})=\tilde {g}_{i}^{\prime }(x_{i})=\tilde {D}_{i}\), so the nonlinear spline has at least C1-regularity. However, the values \(\tilde {\mathbf {D}}=(\tilde {D}_{i})_{i=0}^{m}\) obtained solving this system are not necessarily equal to the values D obtained in (8). This fact causes the spline to lose its C2 regularity because the new approximation to the derivatives, (\(\tilde {D}_{i}\)), does not satisfy (4). In particular, in [3], this system is obtained for a specific nonlinear mean.

In order to generate a spline that is C2 continuous, we propose to change the values that we use to interpolate. Thus, the resulting approximation is not interpolatory.

3 Construction of C 2-cubic splines adapted to discontinuities

The idea of this new type of spline is to obtain new data \((\hat {y}_{i})_{i=0}^{m}\) such that the associated linear system (7) agrees with the nonlinear splines defined using the modified right hand side in (12). Thus, by construction the spline will have C2 regularity at the modified points. In order to obtain values close to the original ones, we cannot introduce modifications at the slopes defined by the points whose intervals contain discontinuities. In particular, at these points we cannot expect C2 regularity.

We define the new values, \(\hat {y}_{i}\), implicitly by

$$\hat{\delta}_{i} =\frac{\hat{y}_{i} - \hat{y}_{i-1}}{h_{i}}, \quad i=1,\hdots,m,$$

such that their weighted arithmetic means coincide with the weighted nonlinear means used at the right hand side of the system (12). Thus, we define:

$$ \left\{ \begin{array}{lll} & \hat{\delta}_{i}= -\frac{\beta_{i}}{\alpha_{i}} \hat{\delta}_{i-1} + \frac{G_{\alpha_{i},\beta_{i}}(\delta_{i},\delta_{i-1},\hat{\delta}_{i-1},h_{i})}{\alpha_{i}}, \quad i=2,\hdots,m, \text{being} \hat{\delta}_{1}=\delta_{1},\\ & \hat{y}_{i}= h_{i}\cdot \hat{\delta}_{i} +\hat{y}_{i-1}, \quad i=1,\hdots,m, \text{being} \hat{y}_{0}=y_{0}, \end{array} \right. $$
(14)

where

$$ G_{\alpha,\beta}(x,y,z,h)= \left\{ \begin{array}{ll} H_{\alpha,\beta}(x,y), & \text{if } |x-y|\leq h^{\eta}, \\ \alpha x+\beta z, & \text{if } |x-y|> h^{\eta}. \end{array} \right. $$
(15)

being 0 < η < 1 a constant. The function G is defined taking into account that in smooth regions |δiδi− 1| = O(h) and close to the discontinuity |δiδi− 1| = O(1).

With this modification, the slope generated by the pairs of values defining an interval that contains a discontinuity is not modified and the other values remain at a distance of O(hp) from the original data values. In all the paper, we assume that the parameter h is sufficiently small.

The associated spline will be C2 except between the pairs of values defining an interval that contains a discontinuity, but the spline becomes only quasi-interpolatory. In any case, we will prove that the order of approximation is the same in both nonlinear schemes.

Lemma 3.1

Let j0,j1 be natural numbers with 1 ≤ j0 < j1; \((x_{i},y_{i})_{i=j_{0}}^{j_{1}}\), j1j0 + 1 points, \(h=\max \limits (h_{i})_{i=j_{0}}^{j_{1}}\), \((\delta _{i})_{i=j_{0}}^{j_{1}}\) the values defined as \(\delta _{i}=\frac {y_{i}-y_{i-1}}{h_{i}}\), for all j0ij1, and \((\hat {\delta }_{i})_{i=j_{0}}^{j_{1}}\) defined in (14) with \(\hat {\delta }_{j_{0}-1}=\delta _{j_{0}-1}\), being Hα,β(x,y) a nonlinear weighted mean satisfying the (OA) property with p ≥ 1. If |δiδi− 1| = O(h), for all i = j0 + 1,…,j1, then

$$|\delta_{i}-\hat{\delta}_{i}|=O(h^{p}), \quad i=j_{0}-1,\hdots,j_{1}.$$

Proof

By induction, we start with i = j0 since \(\delta _{j_{0}-1}=\hat {\delta }_{j_{0}-1}\), then as \(\alpha _{j_{0}}=O(1)\) and \(|\delta _{j_{0}}-\delta _{j_{0}-1}|=O(h)\), by (14), (15), and (OA) property, we get

$$ \begin{array}{@{}rcl@{}} |\delta_{j_{0}}-\hat{\delta}_{j_{0}}|&=&\left|\delta_{j_{0}}-\left( -\frac{\beta_{j_{0}}}{\alpha_{j_{0}}} \hat{\delta}_{j_{0}-1} + \frac{G_{\alpha_{j_{0}},\beta_{j_{0}}}(\delta_{j_{0}},\delta_{j_{0}-1},\hat{\delta}_{j_{0}-1},h_{j_{0}})}{\alpha_{j_{0}}}\right)\right|=\left|\delta_{j_{0}}-\left( -\frac{\beta_{j_{0}}}{\alpha_{j_{0}}} \hat{\delta}_{j_{0}-1} + \frac{H_{j_{0}}}{\alpha_{j_{0}}}\right)\right|\\&=&\frac{1}{\alpha_{j_{0}}}\left|(\alpha_{j_{0}}\delta_{j_{0}}+\beta_{j_{0}} \delta_{j_{0}-1}) - H_{j_{0}} \right|= O(h^{p}), \end{array} $$

we suppose that \(|\delta _{i-1}-\hat {\delta }_{i-1}|=O(h^{p})\), for i − 1 < j1 and prove the case i. As αi = O(1) and |δiδi− 1| = O(h), then:

$$ \begin{array}{@{}rcl@{}} |\delta_{i}-\hat{\delta}_{i}|&=&\left|\delta_{i}-\left( -\frac{\beta_{i}}{\alpha_{i}} \hat{\delta}_{i-1} + \frac{H_{i}}{\alpha_{i}}\right)\right|=\frac{1}{\alpha_{i}}\left|(\alpha_{i}\delta_{i}+\beta_{i} \hat{\delta}_{i-1}) - H_{i} \right|\\ &=&\frac{1}{\alpha_{i}}\left|(\alpha_{i}\delta_{i}+\beta_{i} \hat{\delta}_{i-1})+(\beta_{i} \hat{\delta}_{i-1}-\beta_{i} \delta_{i-1}) - H_{i} \right|\\ &\leq&\frac{1}{\alpha_{i}}\left|(\alpha_{i}\delta_{i}+\beta_{i} \hat{\delta}_{i-1})- H_{i} \right|+\beta_{i}|\delta_{i-1}- \hat{\delta}_{i-1}| =O(h^{p}). \end{array} $$

Corollary 3.2

Let j0,j1 be natural numbers with 1 ≤ j0 < j1; \((x_{i},y_{i})_{i=j_{0}}^{j_{1}}\), j1j0 + 1 points, \(h=\max \limits (h_{i})_{i=j_{0}}^{j_{1}}\), \((\delta _{i})_{i=j_{0}}^{j_{1}}\) the values defined as \(\delta _{i}=\frac {y_{i}-y_{i-1}}{h_{i}}\), for all j0ij1, and \((\hat {\delta }_{i})_{i=j_{0}}^{j_{1}}\) defined in (14) with \(\hat {\delta }_{j_{0}-1}=\delta _{j_{0}-1}\) and \(\hat {y}_{j_{0}-1}=y_{j_{0}-1}+O(h^{p+1})\), being Hα,β(x,y) a nonlinear weighted mean satisfying the (OA) property with p ≥ 1. If |δiδi− 1| = O(h), for all i = j0 + 1,…,j1, then

$$|y_{i}-\hat{y}_{i}|=O(h^{p+1}), \quad i=j_{0}-1,\hdots,j_{1}.$$

Proof

By induction, we start with i = j0 since \(y_{j_{0}-1}=\hat {y}_{j_{0}-1}+O(h^{p+1})\), by Lemma 3.1

$$ \begin{array}{@{}rcl@{}} |y_{j_{0}}-\hat{y}_{j_{0}}|&=&|y_{j_{0}} - (h_{j_{0}}\cdot \hat{\delta}_{j_{0}} +\hat{y}_{j_{0}-1})|=|h_{j_{0}}\delta_{j_{0}}+y_{j_{0}-1}-(h_{j_{0}}\cdot \hat{\delta}_{j_{0}} +\hat{y}_{j_{0}-1})|\\ &=&h_{j_{0}}|\delta_{j_{0}}-\hat{\delta}_{j_{0}}|+|y_{j_{0}-1}-\hat{y}_{j_{0}-1}|=O(h^{p+1}),\\ \end{array} $$

we suppose that \(|y_{i-1}-\hat {y}_{i-1}|=O(h^{p+1})\), for i − 1 < j1, then

$$ \begin{array}{@{}rcl@{}} |y_{i}-\hat{y}_{i}|&=&|y_{i} - (h_{i}\cdot \hat{\delta}_{i} +\hat{y}_{i-1})|=|h_{i}\delta_{i}+y_{i-1}-(h_{i}\cdot \hat{\delta}_{i} +\hat{y}_{i-1})|\leq h_{i}|\delta_{i}-\hat{\delta}_{i}|\\&&+|y_{i-1}-\hat{y}_{i-1}|=O(h^{p+1}). \end{array} $$

We suppose that there exists an isolated discontinuity (similar for k discontinuities) between two consecutive values denoted by i0 ∈{1,…,m − 1} and i0 − 1.

Using these results, if we take j0 = 1 and j1 = i0 − 1, we have

$$ |\hat{y}_{i}- y_{i}|=O(h^{p+1}), \quad i=0,\hdots,i_{0}-1.$$

We do not change the values δi at the interval where there exists a discontinuity since \(|\delta _{i_{0}}-\delta _{i_{0}-1}|> h_{i_{0}}^{\eta }\), (15). Then, by (15), we get:

$$ \hat{\delta}_{i_{0}}= -\frac{\beta_{i_{0}}}{\alpha_{i_{0}}} \hat{\delta}_{i_{0}-1} + \frac{G_{\alpha_{i_{0}},\beta_{i_{0}}}(\delta_{i_{0}},\delta_{{i_{0}}-1},\hat{\delta}_{{i_{0}}-1},h_{i_{0}})}{\alpha_{i_{0}}}=-\frac{\beta_{i_{0}}}{\alpha_{i_{0}}} \hat{\delta}_{i_{0}-1} +\frac{\alpha_{i_{0}} \delta_{i_{0}}}{\alpha_{i_{0}}}+\frac{\beta_{i_{0}} \hat{\delta}_{i_{0}-1}}{\alpha_{i_{0}}}=\delta_{i_{0}}. $$
(16)

Yet, the values yi are changed at an interval which is close to a discontinuity since:

$$ \begin{array}{@{}rcl@{}} \hat{y}_{i_{0}}&=& h_{i_{0}}\cdot \hat{\delta}_{i_{0}} +\hat{y}_{i_{0}-1}= h_{i_{0}}\cdot \delta_{i_{0}} +\hat{y}_{i_{0}-1}= h_{i_{0}}\left( \frac{y_{i_{0}}-y_{i_{0}-1}}{h_{i_{0}}}\right) +\hat{y}_{i_{0}-1}=y_{i_{0}}\\&&+(y_{i_{0}-1}-\hat{y}_{i_{0}-1})=y_{i_{0}}+O(h^{p+1}). \end{array} $$
(17)

Analogously, for i0 + 1, as \(|\delta _{i_{0}+1}-\delta _{i_{0}}|>h_{i_{0}+1}^{\eta }\), we have

$$ \hat{\delta}_{i_{0}+1}= -\frac{\beta_{i_{0}+1}}{\alpha_{i_{0}+1}} \hat{\delta}_{i_{0}} + \frac{G_{\alpha_{i_{0}+1},\beta_{i_{0}+1}}(\delta_{i_{0}+1},\delta_{{i_{0}}},\hat{\delta}_{{i_{0}}},h_{i_{0}+1})}{\alpha_{i_{0}+1}}=-\frac{\beta_{i_{0}+1}}{\alpha_{i_{0}+1}} \hat{\delta}_{i_{0}} +\frac{\alpha_{i_{0}+1} \delta_{i_{0}+1}}{\alpha_{i_{0}+1}}+\frac{\beta_{i_{0}+1} \hat{\delta}_{i_{0}}}{\alpha_{i_{0}+1}}=\delta_{i_{0}+1}, $$
(18)

then:

$$ \hat{y}_{i_{0}+1}= h_{i_{0}+1}\cdot \hat{\delta}_{i_{0}+1} +\hat{y}_{i_{0}}= h_{i_{0}+1}\cdot \delta_{i_{0}+1} +\hat{y}_{i_{0}}= h_{i_{0}+1}\left( \frac{y_{i_{0}+1}-y_{i_{0}}}{h_{i_{0}+1}}\right) + y_{i_{0}}+O(h^{p+1})=y_{i_{0}+1}+O(h^{p+1}). $$
(19)

If i0 + 2 ≤ im, we again have |δiδi− 1| = O(hi), and \(|y_{i_{0}+1}-\hat {y}_{i_{0}+1}| =O(h^{p+1})\) by (19). We have the hypotheses of Corollary 3.2 with j0 = i0 + 2 and j1 = m

$$ |\hat{y}_{i}-y_{i}|= O(h^{p+1}), i=i_{0}+1,\hdots,m. $$
(20)

With these new values, it is clear that \(\hat {\delta }_{m}\) is not necessarily equal to δm. In order to obtain exactly the system (12), we will suppose as boundary condition that satisfies

$$\hat{g}^{\prime\prime}_{m-1}(x_{m})=6\left( \frac{\delta_{m}-\hat{\delta}_{m}}{h_{i}}\right).$$

We define then the piecewise spline \(\hat {g}(x)\) by

$$ \hat{g}_{i}(x)={\hat{a}}_{i}(x-x_{i})^{3}+{\hat{b}}_{i}(x-x_{i})^{2}+\hat{c}_{i}(x-x_{i})+\hat{d}_{i}, $$
(21)

at each interval [xi,xi+ 1], i = 0,…,m, with

$$ \begin{array}{@{}rcl@{}} \hat{a}_{i}&=&\frac{h_{i+1}\hat{D}_{i+1}+\hat{D}_{i} h_{i+1}+2\hat{y}_{i}-2\hat{y}_{i+1}}{h_{i+1}^{3}}, \\ \hat{b}_{i}&=&-\frac{h_{i+1}\hat{D}_{i+1}+2\hat{D}_{i} h_{i+1}+3\hat{y}_{i}-3\hat{y}_{i+1}}{h_{i+1}^{2}},\quad \hat{c}_{i}=\hat{D}_{i},\quad \hat{d}_{i}=\hat{y}_{i}, \end{array} $$
(22)

where \(\hat {D}_{i}\) are the values obtained solving the system (12) except at the interval where the discontinuity is placed.

We can summarize this result in the following theorem.

Theorem 3.3

Let \((x_{i},y_{i})_{i=0}^{m}\) be m + 1 points, hi = xixi− 1, \(h=\max \limits (h_{i})_{i=0}^{m}\), \(\lambda _{i}=h_{i}^{-1}\),

$$ \alpha_{i}=\frac{\lambda_{i}}{\lambda_{i}+\lambda_{i-1}},\quad \beta_{i}=\frac{\lambda_{i-1}}{\lambda_{i}+\lambda_{i-1}}, \quad i=1,\hdots, m. $$

We suppose 1 ≤ i0m − 1 such that there exists a discontinuity of y(x) at the interval \([x_{i_{0}-1},x_{i_{0}}]\) and Gα,β(x,y,z,h) is the function introduced in (15) being Hα,β(x,y) a nonlinear weighted mean satisfying the (OA) property with p ≥ 1. If we define:

$$ \begin{array}{@{}rcl@{}} \hat{\delta}_{i}&=& -\frac{\beta_{i}}{\alpha_{i}} \hat{\delta}_{i-1} + \frac{G_{\alpha_{i},\beta_{i}}(\delta_{i},\delta_{i-1},\hat{\delta}_{i-1},h_{i})}{\alpha_{i}}, \quad i=2,\hdots,m, \text{being} \hat{\delta}_{1}=\delta_{1},\\ \hat{y}_{i}&=& h_{i}\cdot \hat{\delta}_{i} +\hat{y}_{i-1}, \quad i=1,\hdots,m, \text{being} \hat{y}_{0}=y_{0}, \end{array} $$

and \(\hat {g}(x)\) such that

$$ \hat{g}_{i}(x)={\hat{a}}_{i}(x-x_{i})^{3}+{\hat{b}}_{i}(x-x_{i})^{2}+\hat{c}_{i}(x-x_{i})+\hat{d}_{i}, $$

at each interval [xi,xi+ 1], i = 0,…,m, with

$$ \begin{array}{@{}rcl@{}} \hat{a}_{i}&=&\frac{h_{i+1}\hat{D}_{i+1}+\hat{D}_{i} h_{i+1}+2\hat{y}_{i}-2\hat{y}_{i+1}}{h_{i+1}^{3}}, \\ \hat{b}_{i}&=&-\frac{h_{i+1}\hat{D}_{i+1}+2\hat{D}_{i} h_{i+1}+3\hat{y}_{i}-3\hat{y}_{i+1}}{h_{i+1}^{2}},\quad \hat{c}_{i}=\hat{D}_{i},\quad \hat{d}_{i}=\hat{y}_{i}, \end{array} $$

then, the associated linear system used to calculate \(\hat {D}_{i}\), which satisfies the conditions in (2) with

$$\hat{g}_{0}(x_{0})=y_{0}, \quad \hat{g}_{0}^{\prime\prime}(x_{0})=0,\quad \hat{g}_{m-1}(x_{m})=\hat{y}_{m}, \quad \hat{g}_{m-1}^{\prime\prime}(x_{m})=6\left( \frac{\delta_{m}-\hat{\delta}_{m}}{h_{i}}\right),$$

is \(\mathbf {A}\hat {\mathbf {D}}=3\hat {\mathbf {f}}\), being A defined in (8) and

$$ \hat{\mathbf{f}}=\left[\begin{array}{l} \hat{\delta}_{1}\\ \alpha_{2} \hat{\delta}_{2} + \beta_{2} \hat{\delta}_{1}\\ \alpha_{3} \hat{\delta}_{3} + \beta_{3} \hat{\delta}_{2}\\ \cdots\\ \alpha_{i_{0}-1} \hat{\delta}_{i_{0}-1} + \beta_{i_{0}-2} \hat{\delta}_{i_{0}-2}\\ \alpha_{i_{0}} \hat{\delta}_{i_{0}} + \beta_{i_{0}-1} \hat{\delta}_{i_{0}-1}\\ \alpha_{i_{0}+1} \hat{\delta}_{i_{0}+1} + \beta_{i_{0}} \hat{\delta}_{i_{0}}\\ \alpha_{i_{0}+2} \hat{\delta}_{i_{0}+2} + \beta_{i_{0}+1} \hat{\delta}_{i_{0}+1}\\ \cdots\\ \alpha_{m} \hat{\delta}_{m} + \beta_{m} \hat{\delta}_{m-1}\\ \hat{\delta}_{m} \end{array}\right]=\left[\begin{array}{l} \delta_{1}\\ H_{2}\\ H_{3}\\ \cdots\\ H_{i_{0}-1}\\ \alpha_{i_{0}} \delta_{i_{0}} + \beta_{i_{0}-1} \delta_{i_{0}-1}\\ \alpha_{i_{0}+1} \delta_{i_{0}+1} + \beta_{i_{0}} \delta_{i_{0}}\\ H_{i_{0}+2}\\ \cdots\\ H_{m}\\ \delta_{m} \end{array}\right]. $$
(23)

Finally, mixing the conditions of the linear and nonlinear splines, (13) and (22), we define a new approximating spline, \(u(x):=\tilde {\hat {g}}(x)\), as:

$$ \tilde{\hat{g}}_{i}(x)=\tilde{{\hat{a}}}_{i}(x-x_{i})^{3}+\tilde{{\hat b}}_{i}(x-x_{i})^{2}+\tilde{\hat{c}}_{i}(x-x_{i})+\tilde{{\hat{d}}}_{i} $$
(24)

at each interval [xi,xi+ 1], i = 0,…,m, with

$$ \begin{array}{@{}rcl@{}} \tilde{{\hat{a}}}_{i}&=&\frac{h_{i+1}\tilde{D}_{i+1}+\tilde{D}_{i} h_{i+1}+2\hat{y}_{i}-2\hat{y}_{i+1}}{h_{i+1}^{3}}, \\ \tilde{\hat{b}}_{i}&=&-\frac{h_{i+1}\tilde{D}_{i+1}+2\tilde{D}_{i} h_{i+1}+3\hat{y}_{i}-3\hat{y}_{i+1}}{h_{i+1}^{2}},\quad \tilde{\hat{c}}_{i}=\tilde{D}_{i},\quad \tilde{{\hat{d}}}_{i}=\hat{y}_{i}, \end{array} $$
(25)

where \(\tilde {D}_{i}\) are the values that approximate the derivatives obtained solving the system (12) and the \(\hat {y}_{i}\) are defined using (14). We can prove the following theorem.

Theorem 3.4

Using identical notation as before, let 2 < i0 < m − 1 be an integer such that there exists a discontinuity of y(x) at the interval \([x_{i_{0}-1},x_{i_{0}}]\). Then the spline \(u(x)=\tilde {\hat {g}}(x)\) defined in (24) and (25) is \(C^{2}([x_{0},x_{m}]\setminus \{x_{i_{0}-1},x_{i_{0}},x_{i_{0}+1}\})\).

Proof

Let 2 ≤ i < i0, the \(\tilde {D}_{i}\) are the solutions of the system (12), and \(\beta _{i}=\frac {\lambda _{i-1}}{\lambda _{i}+\lambda _{i-1}}\), then we get:

$$ \begin{array}{@{}rcl@{}} &&\beta_{i} \tilde{D}_{i-2} + 2\tilde{D}_{i-1}+\alpha_{i} \tilde{D}_{i}=3H_{i}=3\alpha_{i} \hat{\delta}_{i}+3\beta_{i} \hat{\delta}_{i-1} \to\\ &&\frac{\lambda_{i-1}}{\lambda_{i-1}+\lambda_{i}}\tilde{D}_{i-2}+2\tilde{D}_{i-1}+\frac{\lambda_{i}}{\lambda_{i-1}+\lambda_{i}}\tilde{D}_{i}=\frac{3\lambda_{i}}{\lambda_{i-1}+\lambda_{i}}\hat{\delta}_{i}+ \frac{3\lambda_{i-1}}{\lambda_{i-1}+\lambda_{i}}\hat{\delta}_{i-1} \to \\ &&{\lambda_{i-1}}\tilde{D}_{i-2}+2({\lambda_{i-1}+\lambda_{i}})\tilde{D}_{i-1}+{\lambda_{i}}\tilde{D}_{i}=3\lambda_{i}\hat{\delta}_{i}+ 3{\lambda_{i-1}}\hat{\delta}_{i-1}. \end{array} $$
(26)

Using this relation we can see that:

$$ \begin{array}{@{}rcl@{}} \frac{\tilde{\hat{g}}^{\prime\prime}_{i-2}(x_{i-1})}{2}&=&\frac{\tilde{D}_{i-2}+2\tilde{D}_{i-1}}{h_{i-1}}- 3\frac{\hat{y}_{i-1}-\hat{y}_{i-2}}{h_{i-1}^{2}}={\lambda_{i-1}}\tilde{D}_{i-2}+2\lambda_{i-1}\tilde{D}_{i-1}- 3{\lambda_{i-1}}\hat{\delta}_{i-1}\\ &=&({\lambda_{i-1}}\tilde{D}_{i-2}+2(\lambda_{i-1}+\lambda_{i})\tilde{D}_{i-1}+\lambda_{i} \tilde{D}_{i})- 3{\lambda_{i-1}}\hat{\delta}_{i-1}-2\lambda_{i}\tilde{D}_{i-1}-\lambda_{i} \tilde{D}_{i}\\ &=&3\lambda_{i}\hat{\delta}_{i}+ 3{\lambda_{i-1}}\hat{\delta}_{i-1}- 3{\lambda_{i-1}}\hat{\delta}_{i-1}-2\lambda_{i}\tilde{D}_{i-1}-\lambda_{i} \tilde{D}_{i}=3\lambda_{i}\hat{\delta}_{i}-2\lambda_{i}\tilde{D}_{i-1}-\lambda_{i} \tilde{D}_{i}\\ &=&3\frac{\hat{y}_{i}-\hat{y}_{i-1}}{h_{i}}-\frac{2\tilde{D}_{i-1}+\tilde{D}_{i}}{h_{i}}\\ &=&\frac{\tilde{\hat{g}}^{\prime\prime}_{i-1}(x_{i-1})}{2}. \end{array} $$
(27)

Analogously for i0 + 1 < im − 1. □

4 On the order of accuracy

Let us start with the special case when the function is sufficiently smooth. In this case, we expect to obtain similar approximations as the original linear spline, i.e., that the distance between the new spline and the original linear spline is of the order introduced by the (OA) property, (9). We prove two auxiliary lemmas that we will use throughout the section. They consist of proving that having an estimate of the order of the approximation for the derivative values, we can estimate the order of approximation of the associated spline.

Lemma 4.1

Let \((x_{i},y_{i})_{i=0}^{m}\) be a set of points with hi = xixi− 1, being \(h=\max \limits (h_{i})_{i=1}^{m}<1\) and let g(x) be the linear spline defined by (1) and (3), being \(\tilde {g}(x)\) defined by (13) and u(x) the new spline defined by (24) and (25) with Hα,β(x,y) a nonlinear weighted mean which satisfies the (OA) property with p ≥ 1 in both cases. Let \(\hat {y}_{i}\) be defined by (14), and let \(\tilde {D}_{i}=\tilde {g}^{\prime }(x_{i})\). If there exists j0 such that

$$ \begin{array}{@{}rcl@{}} | y_{i} -\hat{y}_{i}|&=&O(h^{p+1}),\quad i=j_{0}, j_{0}+1,\\ |D_{i} - \tilde{D}_{i}|&=&O(h^{p}), \quad i=j_{0}, j_{0}+1, \end{array} $$
(28)

then

$$ \begin{array}{@{}rcl@{}} |g(x)-\tilde{g}(x)|&=&O(h^{p+1}), \quad x\in [x_{j_{0}},x_{j_{0}+1}],\\ |g(x)-u(x)|&=&O(h^{p+1}),\quad x\in [x_{j_{0}},x_{j_{0}+1}]. \end{array} $$

Proof

By (3), (13), and (28), we get

$$ \begin{array}{@{}rcl@{}} |d_{j_{0}}-\tilde{d}_{j_{0}}|&=&| y_{j_{0}} - y_{j_{0}}|=0,\\ |c_{j_{0}}-\tilde{c}_{j_{0}}|&=&|{D}_{j_{0}}-\tilde{D}_{j_{0}}|=O(h^{p}), \\ |b_{j_{0}}-\tilde{b}_{j_{0}}|&\leq & \frac{h_{{j_{0}}+1}|{D}_{{j_{0}}+1}-\tilde{D}_{{j_{0}}+1}|+2|{D}_{j_{0}} - \tilde{D}_{j_{0}}|h_{{j_{0}}+1}+3|y_{j_{0}}- y_{j_{0}}| +3|y_{{j_{0}}+1}- y_{{j_{0}}+1}|}{h_{{j_{0}}+1}^{2}}=O(h^{p-1}),\\ |{a}_{j_{0}}-\tilde{a}_{j_{0}}|&\leq& \frac{h_{{j_{0}}+1}|{D}_{{j_{0}}+1}-\tilde{D}_{{j_{0}}+1}|+|{D}_{j_{0}}- \tilde{D}_{j_{0}}| h_{{j_{0}}+1}+2|y_{j_{0}}- y_{j_{0}}| +2|y_{{j_{0}}+1}- y_{{j_{0}}+1}|}{h_{{j_{0}}+1}^{3}}=O(h^{p-2}). \end{array} $$
(29)

Analogously, by (3), (25), and (28), we have

$$ \begin{array}{@{}rcl@{}} |d_{j_{0}}-\tilde{\hat{d}}_{j_{0}}|&=&| y_{j_{0}} - \hat{y}_{j_{0}}|=O(h^{p+1}),\\ |c_{j_{0}}-\tilde{\hat{c}}_{j_{0}}|&=&| {D}_{j_{0}}-\tilde{D}_{j_{0}}|=O(h^{p}),\\ |b_{j_{0}}-\tilde{\hat b}_{j_{0}}|&\leq& \frac{h_{{j_{0}}+1}|{D}_{{j_{0}}+1}-\tilde{D}_{{j_{0}}+1}|+2|{D}_{j_{0}} - \tilde{D}_{j_{0}}|h_{{j_{0}}+1}+3|y_{j_{0}}- \hat{y}_{j_{0}}| +3|y_{{j_{0}}+1}- \hat{y}_{{j_{0}}+1}|}{h_{{j_{0}}+1}^{2}}=O(h^{p-1}),\\ |a_{j_{0}}-\tilde{\hat{a}}_{j_{0}}|&\leq& \frac{h_{{j_{0}}+1}|{D}_{{j_{0}}+1}-\tilde{D}_{{j_{0}}+1}|+|{D}_{j_{0}}- \tilde{D}_{j_{0}}| h_{{j_{0}}+1}+2|y_{j_{0}}- \hat{y}_{j_{0}}| +2|y_{{j_{0}}+1}- \hat{y}_{{j_{0}}+1}|}{h_{{j_{0}}+1}^{3}}=O(h^{p-2}). \end{array} $$
(30)

Finally, if \(x\in [x_{j_{0}},x_{j_{0}+1}]\),

$$ \begin{array}{@{}rcl@{}} | g(x)-\tilde{g}(x)|&=&|g_{j_{0}}(x)-\tilde{g}_{j_{0}}(x)|\leq | a_{j_{0}}-\tilde{a}_{j_{0}}||x-x_{j_{0}}|^{3}+| b_{j_{0}}-\tilde{b}_{j_{0}}||x-x_{j_{0}}|^{2}\\&&+| c_{j_{0}}-\tilde{c}_{j_{0}}||x-x_{j_{0}}|+| d_{j_{0}}-\tilde{d}_{j_{0}}|\\ &=&O(h^{p+1}),\\ |g(x)-u(x)|&=&|g_{j_{0}}(x)-u_{j_{0}}(x)|\leq |{a}_{j_{0}}-\tilde{\hat{a}}_{j_{0}}||x-x_{j_{0}}|^{3}+|{b}_{j_{0}}-\tilde{\hat b}_{j_{0}}||x-x_{j_{0}}|^{2}\\&&+|{c}_{j_{0}}-\tilde{\hat{c}}_{j_{0}}||x-x_{j_{0}}|+|d_{j_{0}}-\tilde{\hat{d}}_{j_{0}}|\\ &=&O(h^{p+1}). \end{array} $$

Lemma 4.2

Let \((x_{i},y_{i})_{i=0}^{m}\) be a set of points with hi = xixi− 1, being \(h=\max \limits (h_{i})_{i=1}^{m}<1\) and let g(x) be the linear spline defined by (1) with (3), \(\tilde {g}(x)\) defined by (13) and u(x) the new spline defined by (25) with Hα,β(x,y) a nonlinear weighted mean which satisfies the (OA) property with p ≥ 1 in both cases. If there exists j0 such that

$$ \begin{array}{@{}rcl@{}} | y_{i} -\hat{y}_{i}|&=&O(h^{p+1}),\quad i=j_{0}, j_{0}+1,\\ |D_{i} - \tilde{D}_{i}|&=&O(h^{p}), \quad i=j_{0}, j_{0}+1, \end{array} $$
(31)

and q ≥ 1 such that |y(x) − g(x)| = O(hq) with \(x\in [x_{j_{0}},x_{j_{0}+1}]\), then

$$ |y(x)-\tilde{g}(x)|=O\left( h^{\min(p+1,q)}\right), \quad |y(x)-u(x)|=O\left( h^{\min(p+1,q)}\right), x\in [x_{j_{0}},x_{j_{0}+1}]. $$

Proof

The proof is straightforward using Lemma 4.1. If \(x\in [x_{j_{0}},x_{j_{0}+1}]\) then

$$ \begin{array}{@{}rcl@{}} |y(x)-\tilde{g}(x)|&=&|y(x)-g(x)+g(x)-\tilde{g}(x)|\leq|y(x)-g(x)|+|g(x)\\&&-\tilde{g}(x)|=O(h^{q})+O(h^{p+1})=O(h^{\min(p+1,q)}),\\ |y(x)-u(x)|&=&|y(x)-g(x)+g(x)-u(x)|\leq|y(x)-g(x)|+|g(x)\\&&-u(x)|=O(h^{q})+O(h^{p+1})=O(h^{\min(p+1,q)}).\\ \end{array} $$

Now, with these lemmas, we can calculate the order of approximation.

Proposition 4.3

Let \((x_{i},y_{i})_{i=0}^{m}\) be a set of points with hi = xixi− 1, being \(h=\max \limits (h_{i})_{i=0}^{m}<1\) and let g(x) be the linear cubic spline defined by (1) with (3), \(\tilde {g}(x)\) defined by (13) and u(x) the new spline defined by (25) with Hα,β(x,y) a nonlinear weighted mean which satisfies the (OA) property with p ≥ 1 in both cases, then for all x ∈ [a,b]:

$$ \begin{array}{@{}rcl@{}} | g(x)-\tilde{g}(x)|&=&O(h^{p+1}),\\ |g(x)-u(x)|&=&O(h^{p+1}).\\ \end{array} $$

Proof

The proof follows by verifying the conditions of Lemma 4.1 for all i = 0,…,m − 1. Using systems (8) and (12), we obtain:

$$ \mathbf{A} \mathbf{D}-\mathbf{A}\tilde{\mathbf{D}}=\mathbf{f}-\tilde{\mathbf{f}}\to \mathbf{D}-\tilde{\mathbf{D}}=\mathbf{A}^{-1}(\mathbf{f}-\tilde{\mathbf{f}}), $$
(32)

where \(\|\mathbf {A}^{-1}\|_{\infty }=O(1)\) and by (OA) property we have that \(\|\mathbf {f}-\tilde {\mathbf {f}}\|_{\infty }=O(h^{p})\). Then \(\|\mathbf {D}-\tilde {\mathbf {D}}\|_{\infty }=O(h^{p}),\) and by Corollary 3.2, we get

$$ |y_{i} - \hat{y}_{i}|=O(h^{p+1}),\quad i=0,\hdots,m. $$

In the following corollary, we prove that if the data are values that come from the discretization of a smooth function by point values, then the new spline has the same order of accuracy as the linear one.

Corollary 4.4

Let y(x) be a function in C4([a,b]), and \(X=(x_{i})^{m}_{i=0}\), x0 = a,hi = xixi− 1, a partition of [a,b], \(h=\max \limits (h_{i})_{i=0}^{m}\) and g(x) the linear spline defined by (1) with (3), \(\tilde {g}(x)\) defined by (13) and u(x) the new spline defined by (25) with Hα,β(x,y) a nonlinear weighted mean which satisfies the (OA) property with p ≥ 1 in both cases. Given x ∈ [a,b], if there exists q ≥ 1 such that |y(x) − g(x)| = O(hq), then

$$ |y(x)-\tilde{g}(x)|=O\left( h^{\min(p+1,q)}\right), \quad |y(x)-u(x)|=O\left( h^{\min(p+1,q)}\right). $$

Proof

It is direct by Lemma 4.2 and Prop. 4.3. □

Therefore, at the smooth zones, since the classical cubic spline is of order q = 4, if we take a nonlinear average satisfying the (OA) property with p = 3, then the new spline will reach maximum order of accuracy.

Now, we will study the case with jump discontinuities. For this case, we calculate the distance between D and \(\tilde {\mathbf {D}}\). We bound the norm of the inverse matrix, A− 1 using the following lemma proved in [15] and [16] and used, for example, in [4].

Lemma 4.5

[15, 16] If the elements of A− 1 are denoted by \((a^{-1}_{j,k})_{j,k=0}^{m}\) then

$$ |a_{j,k}^{-1}|\leq \frac{2}{3}\cdot \gamma^{-|j-k|},\quad 0\leq j,k\leq m, \quad \text{with:}\quad \gamma=\left\{ \begin{array}{ll} 2, & h_{i}\neq h_{i+1}, \\ 2+\sqrt{3}, & h_{i}=h_{i+1}=h. \end{array}\right. $$
(33)

If there exists a discontinuity at the interval \([x_{i_{0}-1},x_{i_{0}}]\) with 1 ≤ i0m − 1, then \((\mathbf {f}-\tilde {\mathbf {f}})_{i_{0}-1}=f_{i_{0}-1}-\tilde {f}_{i_{0}-1}=O(1)\) and \((\mathbf {f}-\tilde {\mathbf {f}})_{i_{0}}=f_{i_{0}}-\tilde {f}_{i_{0}}=O(1)\) from

$$ (\mathbf{f}-\tilde{\mathbf{f}})_{i}=f_{i}-\tilde{f}_{i} =\left\{ \begin{array}{ll} 0, & i=0, m, \\ M_{\alpha_{i+1},\beta_{i+1}}(\delta_{i+1},\delta_{i})-H_{\alpha_{i+1},\beta_{i+1}}(\delta_{i+1},\delta_{i}), & 1\leq i \leq m-1, \end{array} \right. $$
(34)

thus, if j = 0,…,m, we can calculate that

$$ \begin{array}{@{}rcl@{}} |D_{j}-\tilde{D}_{j}| &=& |(\mathbf{A}^{-1} (\mathbf{f}-\tilde{\mathbf{f}}))_{j}|=\left|\sum\limits_{k=0}^{m} a^{-1}_{j,k} (f_{k} -\tilde{f}_{k})\right|\leq \sum\limits_{k=0}^{m} \left|a^{-1}_{j,k}\right| \left|f_{k} -\tilde{f}_{k}\right| \\ &\leq& \sum\limits_{k=1}^{i_{0}-2} \left|a^{-1}_{j,k}\right| \left|f_{k} -\tilde{f}_{k}\right| + \left|a^{-1}_{j,i_{0}-1}\right| \left|f_{i_{0}-1} -\tilde{f}_{i_{0}-1}\right| + \left|a^{-1}_{j,i_{0}}\right| \left|f_{i_{0}} -\tilde{f}_{i_{0}}\right| \\&&+ \sum\limits_{k=i_{0}+1}^{m-1}\left| a^{-1}_{j,k}\right| \left|f_{k} -\tilde{f}_{k}\right|\\ &\leq& \sum\limits_{k=1}^{i_{0}-2} \frac{2}{3}\cdot \gamma^{-|j-k|} O(h^{p}) + \left|a^{-1}_{j,i_{0}-1}\right| \left|f_{i_{0}-1} -\tilde{f}_{i_{0}-1}\right| + \left|a^{-1}_{j,i_{0}}\right| \left|f_{i_{0}} -\tilde{f}_{i_{0}}\right| \\&&+ \sum\limits_{k=i_{0}+1}^{m-1}\frac{2}{3}\cdot \gamma^{-|j-k|} O(h^{p})\\ &\leq& \left|a^{-1}_{j,i_{0}-1}\right| \left|f_{i_{0}-1} -\tilde{f}_{i_{0}-1}\right| + \left|a^{-1}_{j,i_{0}}\right| \left|f_{i_{0}} -\tilde{f}_{i_{0}}\right| + O(h^{p})\\ &\leq& \frac{2}{3}\cdot \gamma^{-|j-i_{0}+1|} \left|f_{i_{0}-1} -\tilde{f}_{i_{0}-1}\right| + \frac{2}{3}\cdot \gamma^{-|j-i_{0}|} \left|f_{i_{0}} -\tilde{f}_{i_{0}}\right| + O(h^{p}), \end{array} $$
(35)

since \({\sum }_{k=1}^{m-1}\frac {2}{3}\cdot \gamma ^{-|j-k|}\leq 2\), for all j = 1,…,m − 1. In order to obtain \(\gamma ^{-|j-i_{0}+1|}\leq h^{p}\), we have to impose that

$$ 0\leq j \leq i_{0}-1 +p\frac{\log(h)}{\log(\gamma)} \quad \text{or} \quad i_{0} -p\frac{\log(h)}{\log(\gamma)}\leq j \leq m, $$
(36)

supposing that h < 1. We can summarize this result in Proposition 4.6.

Remark 4.1

It is clear that by (36) depending on values p, h and γ, the number of points m, and the location of the discontinuity i0 have to satisfy:

$$ 0 \leq i_{0}-1 +p\frac{\log(h)}{\log(\gamma)} \leq i_{0} -p\frac{\log(h)}{\log(\gamma)} \leq m. $$

Thus, we assume that the previous expression is satisfied in the following results.

Proposition 4.6

Let \(X=(x_{i})^{m}_{i=0}\), x0 = a,hi = xixi− 1, be a partition of [a,b], \(h=\max \limits (h_{i})_{i=1}^{m}<1\). We suppose that there exists 1 ≤ i0m − 1 such that y(x) is a function in \(C^{4}([a,x_{i_{0}-1}]\cup [x_{i_{0}},b]),\) let AD = f and \(\mathbf {A}\tilde {\mathbf {D}}=\tilde {\mathbf {f}}\) be the systems defined in (8) and (12) respectively with Hα,β(x,y) satisfying the (OA) property with p ≥ 1, then:

$$ |D_{j}-\tilde{D}_{j}|=O(h^{p}),\quad 0\leq j \leq i_{0}-1 +p\frac{\log(h)}{\log(\gamma)} \quad \text{or} \quad i_{0} -p\frac{\log(h)}{\log(\gamma)}\leq j \leq m, $$

being \(\gamma =2+\sqrt {3}\) if hi = hi− 1 for all 1 ≤ im, γ = 2 otherwise.

Proof

We obtain the result because if

$$0\leq j \leq i_{0}-1 +p\frac{\log(h)}{\log(\gamma)} \quad \text{or} \quad i_{0} -p\frac{\log(h)}{\log(\gamma)}\leq j \leq m,$$

then \(\gamma ^{-|j-i_{0}+1|}\leq h^{p}\) and by (35). □

Finally, we prove that at intervals placed sufficiently far away from the discontinuities, the order of approximation obtained by the nonlinear splines is maximal.

Corollary 4.7

Let \(X=(x_{i})^{m}_{i=0}\), x0 = a,hi = xixi− 1, be a partition of [a,b], \(h=\max \limits (h_{i})_{i=0}^{m}<1\). We suppose that there exists 1 ≤ i0m − 1 such that y(x) is a function in \(C^{4}([a,x_{i_{0}-1}]\cup [x_{i_{0}},b]),\) let g(x) be the linear spline defined by (1) and (3), \(\tilde {g}(x)\) defined by (13) and u(x) the new spline defined by (25) with Hα,β(x,y) a nonlinear weighted mean which satisfies the (OA) property with p ≥ 1 in both cases, if there exists qi ≥ 1 such that \(|y_{i}(x)-g_{i}(x)|=O(h^{q_{i}})\), i = 0,…,m. Then:

$$ \begin{array}{@{}rcl@{}} |y(x)-\tilde{g}(x)|&=&O\left( h^{\min(q_{j},p+1)}\right), x\in [x_{j},x_{j+1}],\\ |y(x)-u(x)|&=&O\left( h^{\min(q_{j},p+1)}\right), x\in [x_{j},x_{j+1}], \end{array} $$

where

$$ 0\leq j \leq i_{0}-2 +p\frac{\log(h)}{\log(\gamma)} \quad \text{or} \quad i_{0} -p\frac{\log(h)}{\log(\gamma)}\leq j \leq m-1, $$

with \(\gamma =2+\sqrt {3}\) if hi = hi− 1 for all 1 ≤ im, γ = 2 otherwise.

Proof

The proof directly follows since by Lemma 4.1 and Prop. 4.6, we have

$$ \begin{array}{@{}rcl@{}} &|g(x)-\tilde{g}(x)|=O(h^{p+1}), x\in [x_{j},x_{j+1}],\\ &|g(x)-u(x)|=O(h^{p+1}), x\in [x_{j},x_{j+1}], \end{array} $$

with

$$ 0\leq j \leq i_{0}-2 +p\frac{\log(h)}{\log(\gamma)} \quad \text{or} \quad i_{0} -p\frac{\log(h)}{\log(\gamma)}\leq j \leq m-1, $$

with \(\gamma =2+\sqrt {3}\) if hi = hi− 1 for all 1 ≤ im, γ = 2 otherwise. □

5 On a specific example of a nonlinear weighted mean

In order to define a particular nonlinear weighted mean that satisfies the (C), (OA) and (AD) properties for any p, we need two principal components: a new limiter and a nonlinear translation. We take the new mean introduced in [3]. Thus, let 0 < α,β < 1 be two constants with α + β = 1, and p ≥ 1, we define

$$ \tilde{HW}_{p,\alpha,\beta}(x, y)=\left\{\begin{array}{ll} \frac{sign(x)+sign(y)}{2}(\alpha x+\beta y)\left( 1-\left|\beta\frac{x-y}{\alpha x+\beta y}\right|^{p}\right),& |y|\geq|x|, \\ \frac{sign(x)+sign(y)}{2}(\alpha x+\beta y)\left( 1-\left|\alpha\frac{x- y}{\alpha x+\beta y}\right|^{p}\right),& |x|>|y|,\\ 0,& x=y=0. \end{array}\right. $$
(37)

These means are a generalization of the means introduced in [25] and reduce to them for uniform grid spacing. The new limiter satisfies the properties presented in the following proposition. The proof is trivial and is not included for brevity.

Proposition 5.1

The \({\tilde {HW}_{p,\alpha ,\beta }}(x,y)\) mean is a nonlinear weighted mean, Def. 1. Also, for all \((x,y)\in \mathbb {R}^{2}\), it satisfies

  1. 1.

    \({\tilde {HW}_{p,\alpha ,\beta }}(-x,-y)=-{\tilde {HW}_{p,\alpha ,\beta }}(x,y)\).

  2. 2.

    \({\tilde {HW}_{p,\alpha ,\beta }}(x,y)=0, \textrm { if } xy\leq 0\).

  3. 3.

    \({\tilde {HW}_{p,\alpha ,\beta }}(x,y)=\tilde {HW}_{p,\beta ,\alpha }(y,x)\).

  4. 4.

    If xy > 0, x = O(1), y = O(1), |xy| = O(h),

    $$ \left|(\alpha x +\beta y)-{\tilde{HW}_{p,\alpha,\beta}}(x, y)\right|=O(h^{p}). $$
    (38)
  5. 5.

    \(|\tilde {HW}_{p,\beta ,\alpha }(x, y)|\le p\min \limits (|x|,|y|)\).

In order to obtain the maximal approximation order, as we have seen in Section 4, we choose p = 3, i.e., \(\tilde {HW}_{3}\). In particular, if we are working with a uniform grid spacing, hi = hi+ 1 for all i = 1,…,m − 1 then αi = βi = 1/2 and the nonlinear weighted means introduced in the previous Subsection transform into de p-power means introduced in [25]. The p-power mean has the general expression,

$$ \tilde{H}_{p}(x,y)=\frac{sign(x)+sign(y)}{2}\frac{\left|x+y\right|}{2}\left( 1-\left|\frac{x-y}{x+y}\right|^{p}\right). $$
(39)

The most important properties that make the power means appropriate are (see [1, 25] for more details):

Proposition 5.2

For all \((x,y)\in \mathbb {R}^{2}\), the \(\tilde {H}_{p}(x,y)\) mean satisfies

  1. 1.

    \(\tilde {H}_{p}(-x,-y)=-\tilde {H}_{p}(x,y)\).

  2. 2.

    \(\tilde {H}_{p}(x,y)=0 \quad if xy\leq 0\).

  3. 3.

    \(\tilde {H}_{p}(x,y)=\tilde {H}_{p}(y,x)\).

  4. 4.

    If x = O(1), y = O(1), |yx| = O(h) and xy > 0 then \(|\frac {x+y}{2}-\tilde {H}_{p}(x,y)|=O(h^{p})\).

  5. 5.

    \(|\tilde {H}_{p}(x,y)| \leq p \min \limits {(|x|,|y|)}\) (related to the adaption to the singularities).

  6. 6.

    \(|\tilde {H}_{p}(x,y)|\leq \max \limits {(|x|,|y|)}\).

Finally, to define Tε we only have to determine the function \(\varepsilon :\mathbb {R}^{2}\to \mathbb {R}^{+}\). In [3], it is suggested a nonlinear ε(x,y) based on the smoothness indicators proposed in [26], that is defined as:

$$ \varepsilon_{j}:=\frac{h^{4}}{|IS_{j}|+h^{4}}, $$
(40)

where ISj is a smoothness indicator that satisfies that is O(1) close to a jump discontinuity and O(h2) at smooth parts. It is clear that at a jump discontinuity εj is O(h4) and if |x| < |y|, we get

$$ |HW_{p,\beta,\alpha}^{T_{\varepsilon}}(x, y)|<p|x|+(p+1)O(h^{4}), $$
(41)

then the translation does not affect the adaption attained at jump discontinuities unless a change of sign in the first derivative is placed exactly at the discontinuity but it is adapted to the presence of critical points in the sense that is O(1) at critical points (and around them) and that goes to zero away from them. In order to measure the smoothness of our function, we will use the smoothness indicator designed by Jiang and Shu in [26]. The proposed expression for a non-uniform grid spacing is,

$$ IS_{j}=\sum\limits_{l=1}^{r-1} h_{j}^{2l-1}{\int}_{x_{j-\frac{1}{2}}}^{x_{j+\frac{1}{2}}}\left( \frac{d^{l}}{dx^{l}}p_{j}(x)\right)^{2} dx, $$
(42)

where r is the degree of the polynomial pj(x). We have chosen the smoothness indicators in the point values for r = 2 that result from (42). They have the following expression for a uniform grid-spacing,

$$ \begin{array}{@{}rcl@{}} IS_{j}&=&\frac{13}{12}(f_{j-1}-2f_{j}+{f_{j+1}})^{2}+(1/14)(f_{j-1}-4f_{j}+3f_{j+1})^{2}, \end{array} $$
(43)
$$ \begin{array}{@{}rcl@{}} IS_{j+1}&=&\frac{13}{12}(f_{j}-2f_{j+1}+{f_{j+2}})^{2}+(1/14)(f_{j+2}-f_{j})^{2}. \end{array} $$
(44)

If we choose a smoothness indicator with a wider stencil the results are similar. With this choice, it is proved that smoothness indicators are O(1) at a jump discontinuity and O(h2) at smooth parts (see [2] for more details).

6 Analysis of the Gibbs phenomenon for nonlinear cubic splines

Let us consider the elimination of the Gibbs phenomenon for jump discontinuities. First of all, let’s remember the definition of the Gibbs phenomenon introduced by D. Gottlieb and C.W. Shu in [11]. Given a punctually discontinuous function f and its sampling fh defined by \({f^{h}_{n}}=f(nh)\), the Gibbs phenomenon deals with the convergence of the approximation gh based on fh towards f when h goes to 0. It can be characterized by two features [11]:

  1. 1.

    Away from the discontinuity the convergence is rather slow and for any point x,

    $$|f(x)-g^{h}(x)|=O(h).$$
  2. 2.

    There is an overshoot, close to the discontinuity, that does not diminish with the reduction of h. Thus,

    $$\max|f(x)-g^{h}(x)| \textrm{ does not tend to zero with } h.$$

Following the ideas introduced in [3] it is easy to check that the new nonlinear spline does not suffer from the Gibbs phenomenon.

Theorem 6.1

The nonlinear spline obtained through (24) and (25) does not present Gibbs oscillations.

Proof

Let us analyze the right hand side of the system in (12). If we remember now that δi and δi− 1 are divided differences, we know that they are O(1/h) in the presence of a jump discontinuity. Taking into account property 5 of Proposition 5.2, we know that the right hand side of (12) will be,

$$||\tilde{\mathbf{f}}||_{\infty}=O\left( 1\right).$$

Then, the vector of derivatives \(\tilde {\mathbf {D}}\) that results from solving (12) will be,

$$||\tilde{\mathbf{D}}||_{\infty}=||A^{-1}\tilde{\mathbf{f}}||_{\infty}=O(1).$$

At smooth zones \(\hat {y}_{i+1}-\hat {y}_{i}=O(h)\) so,

$$ \begin{array}{@{}rcl@{}} \tilde{\hat{g}}_{i}(x)&=&\tilde{\hat{a}}_{i}(x-x_{i})^{3}+\tilde{\hat b}_{i}(x-x_{i})^{2}+\tilde{\hat{c}}_{i}(x-x_{i})+\tilde{\hat{d}}_{i}=O\left( \frac{1}{h^{2}}\right) O\left( h^{3}\right)\\ &&+O\left( \frac{1}{h}\right)O\left( h^{2}\right) +O\left( h\right)+\hat{y}_{i}=\hat{y}_{i}+O(h). \end{array} $$
(45)

This means that the perturbation introduced by the nonlinear spline is O(h) except at the interval that contains the discontinuity.

Now we can try to prove that the nonlinear spline provides a prediction that is in the interval \([\hat {y}_{i}, \hat {y}_{i+1}]\) when h goes to zero. In order to do so, we express the equation of the spline (1), using the change of variables \(s=\frac {x-x_{i}}{h}\), as

$$ \begin{aligned} \tilde{\hat{g}}_{i}(x)&=\hat{y}_{i}+\left( s^{2} (3-2 s)\right)(\hat{y}_{i+1}-\hat{y}_{i})+\left( s^{3}-2s^{2}+s\right)h\tilde{D}_{i}+\left( s^{3}-s^{2}\right)h\tilde{D}_{i+1}, \end{aligned} $$
(46)

where the first two terms of (46) amount to a dilation and a translation of the element s2(3 − 2s), that has a minimum at s = 0 and a maximum at s = 1, so it can not introduce Gibbs phenomenon. Let us analyze the third and fourth terms of (46). We can see that s3 − 2s2 + s and s3s2 are oscillating functions so the apparition of Gibbs phenomenon can be explained due to the presence of large coefficients accompanying these two elements. In the case of the nonlinear spline in (12) we have already analyzed that \(\tilde {D}_{i}=O(1)\). If this is the case, the two last terms in (46) go to zero when h → 0. Thus, there can not be Gibbs oscillation. □

7 Numerical experiments

The splines proposed are a modification of those introduced in [3] in order to maintain a regularity C2. In this numerical section, we are interested in checking that the new splines own the good properties of the splines presented in [3] concerning order of approximation and elimination of Gibbs-like oscillations. Moreover, we are interested in proving that the algorithm is robust with respect to the presence of perturbations in the data, for this reason we will present experiments where we perturb the functions with additive white Gaussian noise. In addition, we would like to confirm that the intervals affected by a discontinuity verify Proposition 4.6. In particular, that we always maintain at least order 1, which is not verified in the case of linear splines causing Gibbs-like oscillations, and that the order increases as we move away from the discontinuity until we recover the maximum order of accuracy.

We perform some numerical tests in order to validate the theoretical results. In particular, we divide this section in three parts: Firstly, we analyze the distance obtained when we apply the function G, (15) with η = 1/8 (we take this constant for all the examples) on the points \(\{y_{i}\}_{i=0}^{m}\) to get \(\{\hat {y}_{i}\}_{i=0}^{m}\), system given in (14). We will use a uniform grid depending on the parameter h and we will approximate the order obtained. In the second part of this section, we will analyze the Gibbs phenomenon and we will prove that the resulting spline has similar behaviour as that of the splines designed in [3]. Finally, in third part, we study the order of accuracy checking the theoretical results obtained in Section 4. We use the following two functions:

$$ f(x)=\left\{\begin{array}{l} \sin\left( \frac{17}{8}\pi x\right) \textrm{ if } x\le0,\\ \frac{1}{2}\sin\left( \frac{17}{8}\pi x\right)+10 \textrm{ if } x>0, \end{array}\right. $$
(47)

and

$$ l(x)=\left\{\begin{array}{l} \frac{1}{2}x^{5}-x^{2}\textrm{ if } x\le0,\\ x^{6}-x^{4}+x^{2}-2 \textrm{ if } x>0, \end{array}\right. $$
(48)

presented in Fig. 1.

Fig. 1
figure 1

Functions in (47) and (48) used for the experiments presented in this section

7.1 Distance between the original and the new data

For our first experiment, we discretize the functions f(x) and l(x) in the interval [− 1,1] using 2k points, \(h_{k}=\frac {2}{2^{k}-1}\) to get the data \(({y_{i}^{k}})_{i=0}^{2^{k}-1}\) and we apply the algorithm introduced in (14) to obtain \((\hat {y}_{i}^{k})_{i=0}^{2^{k}-1}\). We compute \(\ell ^{\infty }\)-norm to the left of the discontinuity, i.e.,

$$ E_{k}=\underset{i=0\hdots,2^{k-1}-1}{\max} |{y_{i}^{k}} -\hat{y}_{i}^{k}|,$$

and the numerical approximation order which is:

$$ o_{k} = \log_{2} \left( \frac{E_{k}}{E_{k+1}}\right). $$
(49)

As we can see in Table 1, the numerical order of accuracy converges to 3 when hk decreases.

Table 1 Experiment 1 with hk = 2(2k − 1)− 1 (uniform grid spacing) and estimated orders \(o_{k}=\log _{2}(E_{k}/E_{k+1})\), 7 ≤ k ≤ 13

7.2 Numerical experiments using a uniform-grid

In this subsection, we reproduce the experiments presented in [3] but introducing the modification proposed in previous sections. We start from a sampling of the functions in (47) and (48) with 8192 points in [− 1,1]. We subsample the original data to 512 points and subdivide this data to obtain 8192 samples using the proposed spline (modifying the low resolution original data as a preprocessing through (14) and (15)) and the linear spline (7) (without modifying the low resolution original data) over data with and without noise. Then we compare the result with the original data at the highest resolution. In Figs. 2 and 3, the original subsampled data has been represented with red filled circles, the original high resolution data with blue crosses and the reconstruction with black points. All the numerical experiments presented use a uniform grid spacing. The results for the non linear spline have been done using the nonlinear translated mean (10) with the translation defined in (11) and the 𝜖 defined in (40). For the experiments with noise, we have chosen additive white gaussian noise of amplitude 0.1 for the function in (48) and 0.5 for the function in (47) (Fig. 3). We can see that the results are similar to the ones obtained in [3] from a quantitative point of view, but in this case the new spline has been proved theoretically to maintain C2 regularity, an important qualitative property for applications as we mentioned in Section 1.

Fig. 2
figure 2

Top left, function in (47) reconstructed with an adapted cubic spline. Top right, a zoom around the discontinuity. The low resolution discretization (red filled circles) has 512 points and the reconstruction (black points) 8192 points.The original high resolution data has been represented with blue crosses. At the middle row, we can see the reconstruction obtained through the linear spline (7) and a zoom around the discontinuity. We can observe the Gibbs phenomenon that appears close to the discontinuity. At the bottom, we can see the nonlinear reconstruction but in this case we have added to the low resolution data white gaussian noise of amplitude 0.5

Fig. 3
figure 3

Top left, function in (48) reconstructed with an adapted cubic spline. Top right, a zoom around the discontinuity. The low resolution discretization (red filled circles) has 512 points and the reconstruction (black points) 8192 points.The original high resolution data has been represented with blue crosses. At the middle row, we can see the reconstruction obtained through the linear spline (7) and a zoom around the discontinuity. We can observe the Gibbs phenomenon that appears close to the discontinuity. At the bottom, we can see the nonlinear reconstruction but in this case we have added to the low resolution data white gaussian noise of amplitude 0.1

7.3 Accuracy close to the discontinuity

In this subsection, we check the spatial distribution of the accuracy attained by the spline close to the discontinuity. In order to do so, we measure the error in the infinity norm between the nodes of the splines obtained for the function in (48) in an experiment of subdivision similar to the ones presented in Section 7.2. We will start from a low resolution data of m = 513 nodes, i.e., \(h=\frac {2}{512}\) and then construct a linear and a nonlinear spline, computed at 15 interior points between the original nodes. Then we divide h by two in order to perform a grid refinement analysis. In particular, we center our attention at the 17 intervals (between the original nodes) to the left of x = 0 that are closer to the discontinuity, we denote the error at the interval (−nh,−(n − 1)h) as enh,n = 1,…,17. Dividing the mesh size by two and applying the order formula, (49), we obtain an approximation of the order of accuracy attained in each interval denoting the orders by onh. Since \([x_{i_{0}-1},x_{i_{0}}]=[0,h]\) is the interval where the discontinuity is contained, then

$$ [x_{i_{0}-1-n},x_{i_{0}-n}]=[-n h,-(n-1) h]. $$

Therefore, we can use Prop. 4.6 to calculate the theoretical interval where the order p + 1 is recovered, which is:

$$ -n_{0}=p\frac{\log(h)}{\log(\gamma)}, $$

where \(\gamma =2+\sqrt {3}\) because in this example the grid is uniform. In Table 2, we show these constants for every h.

Table 2 In this table, we present a grid refinement analysis for the approximation order of the nonlinear spline in the intervals from (− 5h,− 4h) until (−h,0) to the left of x = 0 using the function in (48)

It is interesting to notice that the theoretical values are slightly worse than the numerical ones. In Table 2 we can see that for h = 1.95e-03 the value − n0 = − 14.21 and in Table 3, order of accuracy p = 4 is recovered in the interval [− 8h,− 7h], (o− 8h = 4.09), i.e., there exists an error of 6 intervals where the optimal order is reached. Analogously, for all h, the optimal order 4 is reached in previous intervals (marked in bold in Table 3) to the theoretical interval achieved using Prop. 4.6 (Table 2, column 2). This phenomenon occurs because in Lemma 4.5 and in (35), we use some manipulations in the inequalities that may be unnecessary in some cases. Also, in the results shown in Fig. 4, we can see how the order grows as we get away from the discontinuity.

Table 3 In this table, we present a grid refinement analysis for the approximation order of the nonlinear spline in the intervals from (− 17h,− 16h) until (− 6h,− 5h) to the left of x = 0 using the function in (48)
Fig. 4
figure 4

Order of accuracy obtained through a grid refinement analysis in the closest intervals to left of x = 0 using the function in (48). To the left, the linear spline. To the right, the nonlinear spline

Finally, we compare the order of accuracy obtained using linear splines. Tables 4 and 5 show the order of accuracy obtained for the linear splines. Comparing with the results shown in Tables 2 and 3, we can observe that in the nonlinear case, at least order 1 is maintained in all the intervals.

Table 4 In this table, we present a grid refinement analysis for the approximation order of the linear spline in the intervals from (− 5h,− 4h) until (−h,0) to the left of x = 0 using the function in (48)
Table 5 In this table, we present a grid refinement analysis for the approximation order of the linear spline in the intervals from (− 17h,− 16h) until (− 6h,− 5h) to the left of x = 0 using the function in (48)

8 Conclusions

In this paper, we have included a new nonlinear spline avoiding the Gibbs oscillations near discontinuities and preserving the C2 regularity crucial for some applications. Some theoretical results related to the order of approximation and to the elimination of the Gibbs oscillations have been proved. The numerical results presented confirm the good properties of this new spline.