Function Repository Resource:

# CubicMonotonicInterpolation

Interpolate data with a monotonic piecewise cubic Hermite interpolant

Contributed by: Jan Mangaldan
 ResourceFunction["CubicMonotonicInterpolation"][{f1,f2,…}] constructs a monotonic cubic Hermite interpolation of the function values fi, assumed to correspond to x values 1, 2, …. ResourceFunction["CubicMonotonicInterpolation"][{{x1,f1},{x2,f2},…}] constructs a monotonic cubic Hermite interpolation of the function values fi corresponding to x values xi.

## Details and Options

ResourceFunction["CubicMonotonicInterpolation"] returns an InterpolatingFunction object, which can be used like any other pure function.
The interpolation function returned by ResourceFunction["CubicMonotonicInterpolation"][data] is set up so as to agree with data at every point explicitly specified in data.
If data is monotonic, ResourceFunction["CubicMonotonicInterpolation"] yields an interpolant that preserves the monotonicity of the data.
The function values fi are expected to be real or complex numbers.
The function arguments xi must be real numbers.
ResourceFunction["CubicMonotonicInterpolation"][data] generates an InterpolatingFunction object that returns values with the same precision as those in data.
ResourceFunction["CubicMonotonicInterpolation"] takes the following options:
 Method Automatic method to use PeriodicInterpolation False whether to treat the data as periodic
Possible settings for Method include "Steffen", "FritschCarlson" and "Stineman", with the default being Automatic.
With the setting PeriodicInterpolationTrue, only the data for a single fundamental period are required.

## Examples

### Basic Examples (3)

Construct an approximate function that interpolates the data:

 In[1]:=
 Out[1]=

Apply the function to find interpolated values:

 In[2]:=
 Out[2]=

Plot the interpolation function along with the original data:

 In[3]:=
 Out[3]=

### Scope (2)

Interpolate and plot a monotonic data set:

 In[4]:=
 Out[4]=
 In[5]:=
 Out[5]=

Form an interpolation from data given as a TimeSeries:

 In[6]:=
 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=

### Options (2)

#### Method (1)

Compare different monotonic interpolation methods:

 In[10]:=
 In[11]:=
 In[12]:=
 Out[12]=

#### PeriodicInterpolation (1)

With PeriodicInterpolation->True, the data is interpreted as one period of a periodic function:

 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=

### Properties and Relations (2)

A monotonic data set:

 In[15]:=
 In[16]:=

Compare CubicMonotonicInterpolation with the built-in "Hermite" and "Spline" methods of Interpolation. The built-in methods do not preserve monotonicity, and give spurious oscillations:

 In[17]:=
 Out[17]=

The interpolant returned by CubicMonotonicInterpolation is continuous up to its first derivative:

 In[18]:=
 In[19]:=
 Out[19]=

## Version History

• 1.0.0 – 10 February 2021